@@ -2013,7 +2013,7 @@ reactor::open_file_dma(std::string_view nameref, open_flags flags, file_open_opt
2013
2013
}
2014
2014
close_fd.cancel ();
2015
2015
return wrap_syscall (fd, st);
2016
- }).then ([&options, name = std::move (name), &open_flags] (syscall_result_extra<struct stat > sr) {
2016
+ }, submit_reason::file_operation ).then ([&options, name = std::move (name), &open_flags] (syscall_result_extra<struct stat > sr) {
2017
2017
sr.throw_fs_exception_if_error (" open failed" , name);
2018
2018
return make_file_impl (sr.result , options, open_flags, sr.extra );
2019
2019
}).then ([] (shared_ptr<file_impl> impl) {
@@ -2028,7 +2028,7 @@ reactor::remove_file(std::string_view pathname) noexcept {
2028
2028
return futurize_invoke ([this , pathname] {
2029
2029
return _thread_pool->submit <syscall_result<int >>([pathname = sstring (pathname)] {
2030
2030
return wrap_syscall<int >(::remove (pathname.c_str ()));
2031
- }).then ([pathname = sstring (pathname)] (syscall_result<int > sr) {
2031
+ }, submit_reason::file_operation ).then ([pathname = sstring (pathname)] (syscall_result<int > sr) {
2032
2032
sr.throw_fs_exception_if_error (" remove failed" , pathname);
2033
2033
return make_ready_future<>();
2034
2034
});
@@ -2041,7 +2041,8 @@ reactor::rename_file(std::string_view old_pathname, std::string_view new_pathnam
2041
2041
return futurize_invoke ([this , old_pathname, new_pathname] {
2042
2042
return _thread_pool->submit <syscall_result<int >>([old_pathname = sstring (old_pathname), new_pathname = sstring (new_pathname)] {
2043
2043
return wrap_syscall<int >(::rename (old_pathname.c_str (), new_pathname.c_str ()));
2044
- }).then ([old_pathname = sstring (old_pathname), new_pathname = sstring (new_pathname)] (syscall_result<int > sr) {
2044
+ }, submit_reason::file_operation
2045
+ ).then ([old_pathname = sstring (old_pathname), new_pathname = sstring (new_pathname)] (syscall_result<int > sr) {
2045
2046
sr.throw_fs_exception_if_error (" rename failed" , old_pathname, new_pathname);
2046
2047
return make_ready_future<>();
2047
2048
});
@@ -2054,7 +2055,7 @@ reactor::link_file(std::string_view oldpath, std::string_view newpath) noexcept
2054
2055
return futurize_invoke ([this , oldpath, newpath] {
2055
2056
return _thread_pool->submit <syscall_result<int >>([oldpath = sstring (oldpath), newpath = sstring (newpath)] {
2056
2057
return wrap_syscall<int >(::link (oldpath.c_str (), newpath.c_str ()));
2057
- }).then ([oldpath = sstring (oldpath), newpath = sstring (newpath)] (syscall_result<int > sr) {
2058
+ }, submit_reason::file_operation ).then ([oldpath = sstring (oldpath), newpath = sstring (newpath)] (syscall_result<int > sr) {
2058
2059
sr.throw_fs_exception_if_error (" link failed" , oldpath, newpath);
2059
2060
return make_ready_future<>();
2060
2061
});
@@ -2068,7 +2069,7 @@ reactor::chmod(std::string_view name, file_permissions permissions) noexcept {
2068
2069
return futurize_invoke ([name, mode, this ] {
2069
2070
return _thread_pool->submit <syscall_result<int >>([name = sstring (name), mode] {
2070
2071
return wrap_syscall<int >(::chmod (name.c_str (), mode));
2071
- }).then ([name = sstring (name), mode] (syscall_result<int > sr) {
2072
+ }, submit_reason::file_operation ).then ([name = sstring (name), mode] (syscall_result<int > sr) {
2072
2073
if (sr.result == -1 ) {
2073
2074
auto reason = format (" chmod(0{:o}) failed" , mode);
2074
2075
sr.throw_fs_exception (reason, fs::path (name));
@@ -2112,7 +2113,7 @@ reactor::file_type(std::string_view name, follow_symlink follow) noexcept {
2112
2113
auto stat_syscall = follow ? stat : lstat;
2113
2114
auto ret = stat_syscall (name.c_str (), &st);
2114
2115
return wrap_syscall (ret, st);
2115
- }).then ([name = sstring (name)] (syscall_result_extra<struct stat > sr) {
2116
+ }, submit_reason::file_operation ).then ([name = sstring (name)] (syscall_result_extra<struct stat > sr) {
2116
2117
if (long (sr.result ) == -1 ) {
2117
2118
if (sr.error != ENOENT && sr.error != ENOTDIR) {
2118
2119
sr.throw_fs_exception_if_error (" stat failed" , name);
@@ -2142,7 +2143,7 @@ future<size_t> reactor::read_directory(int fd, char* buffer, size_t buffer_size)
2142
2143
return _thread_pool->submit <syscall_result<long >>([fd, buffer, buffer_size] () {
2143
2144
auto ret = ::syscall (__NR_getdents64, fd, reinterpret_cast <linux_dirent64*>(buffer), buffer_size);
2144
2145
return wrap_syscall (ret);
2145
- }).then ([] (syscall_result<long > ret) {
2146
+ }, submit_reason::file_operation ).then ([] (syscall_result<long > ret) {
2146
2147
ret.throw_if_error ();
2147
2148
return make_ready_future<size_t >(ret.result );
2148
2149
});
@@ -2155,7 +2156,7 @@ reactor::inotify_add_watch(int fd, std::string_view path, uint32_t flags) {
2155
2156
return _thread_pool->submit <syscall_result<int >>([fd, path = sstring (path), flags] {
2156
2157
auto ret = ::inotify_add_watch (fd, path.c_str (), flags);
2157
2158
return wrap_syscall (ret);
2158
- }).then ([] (syscall_result<int > ret) {
2159
+ }, submit_reason::file_operation ).then ([] (syscall_result<int > ret) {
2159
2160
ret.throw_if_error ();
2160
2161
return make_ready_future<int >(ret.result );
2161
2162
});
@@ -2257,7 +2258,7 @@ reactor::spawn(std::string_view pathname,
2257
2258
return wrap_syscall<int >(::posix_spawn (&child_pid, pathname.c_str (), &actions, &attr,
2258
2259
const_cast <char * const *>(argv.data ()),
2259
2260
const_cast <char * const *>(env.data ())));
2260
- });
2261
+ }, submit_reason::process_operation );
2261
2262
}).finally ([&actions, &attr] {
2262
2263
posix_spawn_file_actions_destroy (&actions);
2263
2264
posix_spawnattr_destroy (&attr);
@@ -2295,7 +2296,7 @@ static auto next_waitpid_timeout(std::chrono::milliseconds this_timeout) {
2295
2296
future<int > reactor::waitpid (pid_t pid) {
2296
2297
return _thread_pool->submit <syscall_result<int >>([pid] {
2297
2298
return wrap_syscall<int >(syscall (__NR_pidfd_open, pid, O_NONBLOCK));
2298
- }).then ([pid, this ] (syscall_result<int > pidfd) {
2299
+ }, submit_reason::process_operation ).then ([pid, this ] (syscall_result<int > pidfd) {
2299
2300
if (pidfd.result == -1 ) {
2300
2301
// pidfd_open() was introduced in linux 5.3, so the pidfd.error could be ENOSYS on
2301
2302
// older kernels. But it could be other error like EMFILE or ENFILE. anyway, we
@@ -2308,7 +2309,7 @@ future<int> reactor::waitpid(pid_t pid) {
2308
2309
&wait_timeout] {
2309
2310
return _thread_pool->submit <syscall_result<pid_t >>([pid, &wstatus] {
2310
2311
return wrap_syscall<pid_t >(::waitpid (pid, &wstatus, WNOHANG));
2311
- }).then ([&wstatus, &wait_timeout] (syscall_result<pid_t > ret) mutable {
2312
+ }, submit_reason::process_operation ).then ([&wstatus, &wait_timeout] (syscall_result<pid_t > ret) mutable {
2312
2313
if (ret.result == 0 ) {
2313
2314
wait_timeout = next_waitpid_timeout (wait_timeout);
2314
2315
return ::seastar::sleep (wait_timeout).then ([] {
@@ -2328,7 +2329,7 @@ future<int> reactor::waitpid(pid_t pid) {
2328
2329
return pidfd.readable ().then ([pid, &wstatus, this ] {
2329
2330
return _thread_pool->submit <syscall_result<pid_t >>([pid, &wstatus] {
2330
2331
return wrap_syscall<pid_t >(::waitpid (pid, &wstatus, WNOHANG));
2331
- });
2332
+ }, submit_reason::process_operation );
2332
2333
}).then ([&wstatus] (syscall_result<pid_t > ret) {
2333
2334
ret.throw_if_error ();
2334
2335
assert (ret.result > 0 );
@@ -2353,7 +2354,7 @@ reactor::file_stat(std::string_view pathname, follow_symlink follow) noexcept {
2353
2354
auto stat_syscall = follow ? stat : lstat;
2354
2355
auto ret = stat_syscall (pathname.c_str (), &st);
2355
2356
return wrap_syscall (ret, st);
2356
- }).then ([pathname = sstring (pathname)] (syscall_result_extra<struct stat > sr) {
2357
+ }, submit_reason::file_operation ).then ([pathname = sstring (pathname)] (syscall_result_extra<struct stat > sr) {
2357
2358
sr.throw_fs_exception_if_error (" stat failed" , pathname);
2358
2359
struct stat & st = sr.extra ;
2359
2360
stat_data sd;
@@ -2391,7 +2392,7 @@ reactor::file_accessible(std::string_view pathname, access_flags flags) noexcept
2391
2392
auto aflags = std::underlying_type_t <access_flags>(flags);
2392
2393
auto ret = ::access (pathname.c_str (), aflags);
2393
2394
return wrap_syscall (ret);
2394
- }).then ([pathname = sstring (pathname), flags] (syscall_result<int > sr) {
2395
+ }, submit_reason::file_operation ).then ([pathname = sstring (pathname), flags] (syscall_result<int > sr) {
2395
2396
if (sr.result < 0 ) {
2396
2397
if ((sr.error == ENOENT && flags == access_flags::exists) ||
2397
2398
(sr.error == EACCES && flags != access_flags::exists)) {
@@ -2413,7 +2414,7 @@ reactor::file_system_at(std::string_view pathname) noexcept {
2413
2414
struct statfs st;
2414
2415
auto ret = statfs (pathname.c_str (), &st);
2415
2416
return wrap_syscall (ret, st);
2416
- }).then ([pathname = sstring (pathname)] (syscall_result_extra<struct statfs > sr) {
2417
+ }, submit_reason::file_operation ).then ([pathname = sstring (pathname)] (syscall_result_extra<struct statfs > sr) {
2417
2418
static std::unordered_map<long int , fs_type> type_mapper = {
2418
2419
{ internal::fs_magic::xfs, fs_type::xfs },
2419
2420
{ internal::fs_magic::ext2, fs_type::ext2 },
@@ -2440,7 +2441,7 @@ reactor::fstatfs(int fd) noexcept {
2440
2441
struct statfs st;
2441
2442
auto ret = ::fstatfs (fd, &st);
2442
2443
return wrap_syscall (ret, st);
2443
- }).then ([] (syscall_result_extra<struct statfs > sr) {
2444
+ }, submit_reason::file_operation ).then ([] (syscall_result_extra<struct statfs > sr) {
2444
2445
sr.throw_if_error ();
2445
2446
struct statfs st = sr.extra ;
2446
2447
return make_ready_future<struct statfs >(std::move (st));
@@ -2455,7 +2456,7 @@ reactor::statvfs(std::string_view pathname) noexcept {
2455
2456
struct statvfs st;
2456
2457
auto ret = ::statvfs (pathname.c_str (), &st);
2457
2458
return wrap_syscall (ret, st);
2458
- }).then ([pathname = sstring (pathname)] (syscall_result_extra<struct statvfs > sr) {
2459
+ }, submit_reason::file_operation ).then ([pathname = sstring (pathname)] (syscall_result_extra<struct statvfs > sr) {
2459
2460
sr.throw_fs_exception_if_error (" statvfs failed" , pathname);
2460
2461
struct statvfs st = sr.extra ;
2461
2462
return make_ready_future<struct statvfs >(std::move (st));
@@ -2479,7 +2480,7 @@ reactor::open_directory(std::string_view name) noexcept {
2479
2480
}
2480
2481
}
2481
2482
return wrap_syscall (fd, st);
2482
- }).then ([name = sstring (name), oflags] (syscall_result_extra<struct stat > sr) {
2483
+ }, submit_reason::file_operation ).then ([name = sstring (name), oflags] (syscall_result_extra<struct stat > sr) {
2483
2484
sr.throw_fs_exception_if_error (" open failed" , name);
2484
2485
return make_file_impl (sr.result , file_open_options (), oflags, sr.extra );
2485
2486
}).then ([] (shared_ptr<file_impl> file_impl) {
@@ -2495,7 +2496,7 @@ reactor::make_directory(std::string_view name, file_permissions permissions) noe
2495
2496
return _thread_pool->submit <syscall_result<int >>([name = sstring (name), permissions] {
2496
2497
auto mode = static_cast <mode_t >(permissions);
2497
2498
return wrap_syscall<int >(::mkdir (name.c_str (), mode));
2498
- }).then ([name = sstring (name)] (syscall_result<int > sr) {
2499
+ }, submit_reason::file_operation ).then ([name = sstring (name)] (syscall_result<int > sr) {
2499
2500
sr.throw_fs_exception_if_error (" mkdir failed" , name);
2500
2501
});
2501
2502
});
@@ -2508,7 +2509,7 @@ reactor::touch_directory(std::string_view name, file_permissions permissions) no
2508
2509
return _thread_pool->submit <syscall_result<int >>([name = sstring (name), permissions] {
2509
2510
auto mode = static_cast <mode_t >(permissions);
2510
2511
return wrap_syscall<int >(::mkdir (name.c_str (), mode));
2511
- }).then ([name = sstring (name)] (syscall_result<int > sr) {
2512
+ }, submit_reason::file_operation ).then ([name = sstring (name)] (syscall_result<int > sr) {
2512
2513
if (sr.result == -1 && sr.error != EEXIST) {
2513
2514
sr.throw_fs_exception (" mkdir failed" , fs::path (name));
2514
2515
}
@@ -2553,7 +2554,7 @@ reactor::fdatasync(int fd) noexcept {
2553
2554
}
2554
2555
return _thread_pool->submit <syscall_result<int >>([fd] {
2555
2556
return wrap_syscall<int >(::fdatasync (fd));
2556
- }).then ([] (syscall_result<int > sr) {
2557
+ }, submit_reason::file_operation ).then ([] (syscall_result<int > sr) {
2557
2558
sr.throw_if_error ();
2558
2559
return make_ready_future<>();
2559
2560
});
@@ -2700,6 +2701,12 @@ void reactor::register_metrics() {
2700
2701
2701
2702
namespace sm = seastar::metrics;
2702
2703
2704
+ auto io_fallback_counter = [this ](const sstring& reason_str, submit_reason r) {
2705
+ static auto reason_label = sm::label (" reason" );
2706
+ return sm::make_counter (" io_threaded_fallbacks" , std::bind (&thread_pool::count, _thread_pool.get (), r),
2707
+ sm::description (" Total number of io-threaded-fallbacks operations" ), { reason_label (reason_str), });
2708
+ };
2709
+
2703
2710
_metric_groups.add_group (" reactor" , {
2704
2711
sm::make_gauge (" tasks_pending" , std::bind (&reactor::pending_task_count, this ), sm::description (" Number of pending tasks in the queue" )),
2705
2712
// total_operations value:DERIVE:0:U
@@ -2725,9 +2732,13 @@ void reactor::register_metrics() {
2725
2732
// total_operations value:DERIVE:0:U
2726
2733
sm::make_counter (" fsyncs" , _fsyncs, sm::description (" Total number of fsync operations" )),
2727
2734
// total_operations value:DERIVE:0:U
2728
- sm::make_counter (" io_threaded_fallbacks" , std::bind (&thread_pool::operation_count, _thread_pool.get ()),
2729
- sm::description (" Total number of io-threaded-fallbacks operations" )),
2730
-
2735
+ io_fallback_counter (" aio_fallback" , submit_reason::aio_fallback),
2736
+ // total_operations value:DERIVE:0:U
2737
+ io_fallback_counter (" file_operation" , submit_reason::file_operation),
2738
+ // total_operations value:DERIVE:0:U
2739
+ io_fallback_counter (" process_operation" , submit_reason::process_operation),
2740
+ // total_operations value:DERIVE:0:U
2741
+ io_fallback_counter (" unknown" , submit_reason::unknown),
2731
2742
});
2732
2743
2733
2744
_metric_groups.add_group (" memory" , {
0 commit comments