-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Refine file_impl creation by reactor #3116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Refine file_impl creation by reactor #3116
Conversation
|
@scylladb/seastar-maint , please review |
This is to keep only the fs_info evaluation in the lambda. This will help detaching this code into its own helper function in the next patch. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Place it in the internal namespace, next to s_fstype map itself. And also move the associated xfs_concurrency_from_kernel_version() helper. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Next patches will pass fs_info reference around preemption points, so the object itself should be non-moveable. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Now this configuration is applied directoy to the fs_info object. Next patches will move those objects creation to thread-pool thread where no reactor and its config are available. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Code that opens file or directory does it via thread-pool thread. In it not only the open() itself is called, but also stat() is. Next patches will make those lambdas call fstatfs() too and return back both -- the stat struct and fs_info pointer. This patch prepares this code to carry fs_info pointer out of thread-pool-invoked lambda. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Right now the fs_info map is populated in the reactor thread. This is done it make_file_impl -- it calls reactor::fstatfs(), that switches to thread-poll, then it instantiates an fs_info object in global map. After this patch, calling fstatfs and populating the map of fs_info-s is done in the thread pool. The caller in this case is reactor::open_file_dma and reactor::open_directory that do opening in thread-pool anyway. The returned pointer to fs_info object is then passed (in reactor thread) to make_file_impl() which no longer needs to access the map of fs_infos. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Now it always returns ready futures with file_impl pointer, no need to mess with futures any longer. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This method is private and was only used to facilitate the make_file_impl Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
2c83dbb to
ac83108
Compare
|
upd:
|
| int r = ::fcntl(fd, F_SETFL, open_flags | o_direct_flag); | ||
| if (r == -1 && strict_o_direct) { | ||
| auto maybe_ret = wrap_syscall(r, st); // capture errno (should be EINVAL) | ||
| auto maybe_ret = wrap_syscall(r, std::make_pair(st, fsi)); // capture errno (should be EINVAL) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be moving fs_info here. First, I'd like to keep the syscall thread minimal since it operates without a full environment (we don't want to allocate here), and second, this code is specific to non-io_uring paths. io_uring is able to execute open() via io_uring and we'd have to duplicate this code.
Creation of file is done in two reactor methods -- open_file_dma() and open_directory(). Both follow similar scheme: first they switch to thread-poll to call open(name) and stat(fd), then call make_file_impl() which returns a future (!) with file_impl pointer, and finally the file is created. The make_file_impl, in turn, is sleeping function because it sometimes (usually once in a lifetime) wants to call thread-poll again to call fstatfs(fd) and populate a collection of fs_info objects.
This PR moves the call to fstats() from make_file_impl() to open_...()'s thread-pool lambda. This change has several interesting consequences.