Skip to content

Conversation

@xemul
Copy link
Contributor

@xemul xemul commented Nov 24, 2025

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.

  1. The make_file_impl becomes non-future function, as it really is nowadays
  2. The reactor::fstatfs(fd) method is removed
  3. One less reactor friend

@xemul
Copy link
Contributor Author

xemul commented Dec 1, 2025

@scylladb/seastar-maint , please review

xemul added 10 commits December 1, 2025 15:11
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>
@xemul xemul force-pushed the br-file-move-fsinfo-get-into-open-thread branch from 2c83dbb to ac83108 Compare December 1, 2025 12:22
@xemul
Copy link
Contributor Author

xemul commented Dec 1, 2025

upd:

@xemul xemul requested a review from avikivity December 1, 2025 12:53
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)
Copy link
Member

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.

@xemul xemul marked this pull request as draft December 2, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants