@@ -1984,7 +1984,7 @@ reactor::open_file_dma(std::string_view nameref, open_flags flags, file_open_opt
1984
1984
}
1985
1985
close_fd.cancel ();
1986
1986
return wrap_syscall (fd, st);
1987
- }).then ([&options, name = std::move (name), &open_flags] (syscall_result_extra<struct stat > sr) {
1987
+ }, submit_reason::file_operation ).then ([&options, name = std::move (name), &open_flags] (syscall_result_extra<struct stat > sr) {
1988
1988
sr.throw_fs_exception_if_error (" open failed" , name);
1989
1989
return make_file_impl (sr.result , options, open_flags, sr.extra );
1990
1990
}).then ([] (shared_ptr<file_impl> impl) {
@@ -1999,7 +1999,7 @@ reactor::remove_file(std::string_view pathname) noexcept {
1999
1999
return futurize_invoke ([this , pathname] {
2000
2000
return _thread_pool->submit <syscall_result<int >>([pathname = sstring (pathname)] {
2001
2001
return wrap_syscall<int >(::remove (pathname.c_str ()));
2002
- }).then ([pathname = sstring (pathname)] (syscall_result<int > sr) {
2002
+ }, submit_reason::file_operation ).then ([pathname = sstring (pathname)] (syscall_result<int > sr) {
2003
2003
sr.throw_fs_exception_if_error (" remove failed" , pathname);
2004
2004
return make_ready_future<>();
2005
2005
});
@@ -2012,7 +2012,8 @@ reactor::rename_file(std::string_view old_pathname, std::string_view new_pathnam
2012
2012
return futurize_invoke ([this , old_pathname, new_pathname] {
2013
2013
return _thread_pool->submit <syscall_result<int >>([old_pathname = sstring (old_pathname), new_pathname = sstring (new_pathname)] {
2014
2014
return wrap_syscall<int >(::rename (old_pathname.c_str (), new_pathname.c_str ()));
2015
- }).then ([old_pathname = sstring (old_pathname), new_pathname = sstring (new_pathname)] (syscall_result<int > sr) {
2015
+ }, submit_reason::file_operation
2016
+ ).then ([old_pathname = sstring (old_pathname), new_pathname = sstring (new_pathname)] (syscall_result<int > sr) {
2016
2017
sr.throw_fs_exception_if_error (" rename failed" , old_pathname, new_pathname);
2017
2018
return make_ready_future<>();
2018
2019
});
@@ -2025,7 +2026,7 @@ reactor::link_file(std::string_view oldpath, std::string_view newpath) noexcept
2025
2026
return futurize_invoke ([this , oldpath, newpath] {
2026
2027
return _thread_pool->submit <syscall_result<int >>([oldpath = sstring (oldpath), newpath = sstring (newpath)] {
2027
2028
return wrap_syscall<int >(::link (oldpath.c_str (), newpath.c_str ()));
2028
- }).then ([oldpath = sstring (oldpath), newpath = sstring (newpath)] (syscall_result<int > sr) {
2029
+ }, submit_reason::file_operation ).then ([oldpath = sstring (oldpath), newpath = sstring (newpath)] (syscall_result<int > sr) {
2029
2030
sr.throw_fs_exception_if_error (" link failed" , oldpath, newpath);
2030
2031
return make_ready_future<>();
2031
2032
});
@@ -2039,7 +2040,7 @@ reactor::chmod(std::string_view name, file_permissions permissions) noexcept {
2039
2040
return futurize_invoke ([name, mode, this ] {
2040
2041
return _thread_pool->submit <syscall_result<int >>([name = sstring (name), mode] {
2041
2042
return wrap_syscall<int >(::chmod (name.c_str (), mode));
2042
- }).then ([name = sstring (name), mode] (syscall_result<int > sr) {
2043
+ }, submit_reason::file_operation ).then ([name = sstring (name), mode] (syscall_result<int > sr) {
2043
2044
if (sr.result == -1 ) {
2044
2045
auto reason = format (" chmod(0{:o}) failed" , mode);
2045
2046
sr.throw_fs_exception (reason, fs::path (name));
@@ -2083,7 +2084,7 @@ reactor::file_type(std::string_view name, follow_symlink follow) noexcept {
2083
2084
auto stat_syscall = follow ? stat : lstat;
2084
2085
auto ret = stat_syscall (name.c_str (), &st);
2085
2086
return wrap_syscall (ret, st);
2086
- }).then ([name = sstring (name)] (syscall_result_extra<struct stat > sr) {
2087
+ }, submit_reason::file_operation ).then ([name = sstring (name)] (syscall_result_extra<struct stat > sr) {
2087
2088
if (long (sr.result ) == -1 ) {
2088
2089
if (sr.error != ENOENT && sr.error != ENOTDIR) {
2089
2090
sr.throw_fs_exception_if_error (" stat failed" , name);
@@ -2218,7 +2219,7 @@ reactor::spawn(std::string_view pathname,
2218
2219
return wrap_syscall<int >(::posix_spawn (&child_pid, pathname.c_str (), &actions, &attr,
2219
2220
const_cast <char * const *>(argv.data ()),
2220
2221
const_cast <char * const *>(env.data ())));
2221
- });
2222
+ }, submit_reason::process_operation );
2222
2223
}).finally ([&actions, &attr] {
2223
2224
posix_spawn_file_actions_destroy (&actions);
2224
2225
posix_spawnattr_destroy (&attr);
@@ -2269,7 +2270,7 @@ future<int> reactor::waitpid(pid_t pid) {
2269
2270
&wait_timeout] {
2270
2271
return _thread_pool->submit <syscall_result<pid_t >>([pid, &wstatus] {
2271
2272
return wrap_syscall<pid_t >(::waitpid (pid, &wstatus, WNOHANG));
2272
- }).then ([&wstatus, &wait_timeout] (syscall_result<pid_t > ret) mutable {
2273
+ }, submit_reason::process_operation ).then ([&wstatus, &wait_timeout] (syscall_result<pid_t > ret) mutable {
2273
2274
if (ret.result == 0 ) {
2274
2275
wait_timeout = next_waitpid_timeout (wait_timeout);
2275
2276
return ::seastar::sleep (wait_timeout).then ([] {
@@ -2289,7 +2290,7 @@ future<int> reactor::waitpid(pid_t pid) {
2289
2290
return pidfd.readable ().then ([pid, &wstatus, this ] {
2290
2291
return _thread_pool->submit <syscall_result<pid_t >>([pid, &wstatus] {
2291
2292
return wrap_syscall<pid_t >(::waitpid (pid, &wstatus, WNOHANG));
2292
- });
2293
+ }, submit_reason::process_operation );
2293
2294
}).then ([&wstatus] (syscall_result<pid_t > ret) {
2294
2295
ret.throw_if_error ();
2295
2296
assert (ret.result > 0 );
@@ -2314,7 +2315,7 @@ reactor::file_stat(std::string_view pathname, follow_symlink follow) noexcept {
2314
2315
auto stat_syscall = follow ? stat : lstat;
2315
2316
auto ret = stat_syscall (pathname.c_str (), &st);
2316
2317
return wrap_syscall (ret, st);
2317
- }).then ([pathname = sstring (pathname)] (syscall_result_extra<struct stat > sr) {
2318
+ }, submit_reason::file_operation ).then ([pathname = sstring (pathname)] (syscall_result_extra<struct stat > sr) {
2318
2319
sr.throw_fs_exception_if_error (" stat failed" , pathname);
2319
2320
struct stat & st = sr.extra ;
2320
2321
stat_data sd;
@@ -2352,7 +2353,7 @@ reactor::file_accessible(std::string_view pathname, access_flags flags) noexcept
2352
2353
auto aflags = std::underlying_type_t <access_flags>(flags);
2353
2354
auto ret = ::access (pathname.c_str (), aflags);
2354
2355
return wrap_syscall (ret);
2355
- }).then ([pathname = sstring (pathname), flags] (syscall_result<int > sr) {
2356
+ }, submit_reason::file_operation ).then ([pathname = sstring (pathname), flags] (syscall_result<int > sr) {
2356
2357
if (sr.result < 0 ) {
2357
2358
if ((sr.error == ENOENT && flags == access_flags::exists) ||
2358
2359
(sr.error == EACCES && flags != access_flags::exists)) {
@@ -2374,7 +2375,7 @@ reactor::file_system_at(std::string_view pathname) noexcept {
2374
2375
struct statfs st;
2375
2376
auto ret = statfs (pathname.c_str (), &st);
2376
2377
return wrap_syscall (ret, st);
2377
- }).then ([pathname = sstring (pathname)] (syscall_result_extra<struct statfs > sr) {
2378
+ }, submit_reason::file_operation ).then ([pathname = sstring (pathname)] (syscall_result_extra<struct statfs > sr) {
2378
2379
static std::unordered_map<long int , fs_type> type_mapper = {
2379
2380
{ internal::fs_magic::xfs, fs_type::xfs },
2380
2381
{ internal::fs_magic::ext2, fs_type::ext2 },
@@ -2401,7 +2402,7 @@ reactor::fstatfs(int fd) noexcept {
2401
2402
struct statfs st;
2402
2403
auto ret = ::fstatfs (fd, &st);
2403
2404
return wrap_syscall (ret, st);
2404
- }).then ([] (syscall_result_extra<struct statfs > sr) {
2405
+ }, submit_reason::file_operation ).then ([] (syscall_result_extra<struct statfs > sr) {
2405
2406
sr.throw_if_error ();
2406
2407
struct statfs st = sr.extra ;
2407
2408
return make_ready_future<struct statfs >(std::move (st));
@@ -2416,7 +2417,7 @@ reactor::statvfs(std::string_view pathname) noexcept {
2416
2417
struct statvfs st;
2417
2418
auto ret = ::statvfs (pathname.c_str (), &st);
2418
2419
return wrap_syscall (ret, st);
2419
- }).then ([pathname = sstring (pathname)] (syscall_result_extra<struct statvfs > sr) {
2420
+ }, submit_reason::file_operation ).then ([pathname = sstring (pathname)] (syscall_result_extra<struct statvfs > sr) {
2420
2421
sr.throw_fs_exception_if_error (" statvfs failed" , pathname);
2421
2422
struct statvfs st = sr.extra ;
2422
2423
return make_ready_future<struct statvfs >(std::move (st));
@@ -2440,7 +2441,7 @@ reactor::open_directory(std::string_view name) noexcept {
2440
2441
}
2441
2442
}
2442
2443
return wrap_syscall (fd, st);
2443
- }).then ([name = sstring (name), oflags] (syscall_result_extra<struct stat > sr) {
2444
+ }, submit_reason::file_operation ).then ([name = sstring (name), oflags] (syscall_result_extra<struct stat > sr) {
2444
2445
sr.throw_fs_exception_if_error (" open failed" , name);
2445
2446
return make_file_impl (sr.result , file_open_options (), oflags, sr.extra );
2446
2447
}).then ([] (shared_ptr<file_impl> file_impl) {
@@ -2456,7 +2457,7 @@ reactor::make_directory(std::string_view name, file_permissions permissions) noe
2456
2457
return _thread_pool->submit <syscall_result<int >>([name = sstring (name), permissions] {
2457
2458
auto mode = static_cast <mode_t >(permissions);
2458
2459
return wrap_syscall<int >(::mkdir (name.c_str (), mode));
2459
- }).then ([name = sstring (name)] (syscall_result<int > sr) {
2460
+ }, submit_reason::file_operation ).then ([name = sstring (name)] (syscall_result<int > sr) {
2460
2461
sr.throw_fs_exception_if_error (" mkdir failed" , name);
2461
2462
});
2462
2463
});
@@ -2469,7 +2470,7 @@ reactor::touch_directory(std::string_view name, file_permissions permissions) no
2469
2470
return _thread_pool->submit <syscall_result<int >>([name = sstring (name), permissions] {
2470
2471
auto mode = static_cast <mode_t >(permissions);
2471
2472
return wrap_syscall<int >(::mkdir (name.c_str (), mode));
2472
- }).then ([name = sstring (name)] (syscall_result<int > sr) {
2473
+ }, submit_reason::file_operation ).then ([name = sstring (name)] (syscall_result<int > sr) {
2473
2474
if (sr.result == -1 && sr.error != EEXIST) {
2474
2475
sr.throw_fs_exception (" mkdir failed" , fs::path (name));
2475
2476
}
@@ -2514,7 +2515,7 @@ reactor::fdatasync(int fd) noexcept {
2514
2515
}
2515
2516
return _thread_pool->submit <syscall_result<int >>([fd] {
2516
2517
return wrap_syscall<int >(::fdatasync (fd));
2517
- }).then ([] (syscall_result<int > sr) {
2518
+ }, submit_reason::file_operation ).then ([] (syscall_result<int > sr) {
2518
2519
sr.throw_if_error ();
2519
2520
return make_ready_future<>();
2520
2521
});
@@ -2658,6 +2659,12 @@ void reactor::register_metrics() {
2658
2659
2659
2660
namespace sm = seastar::metrics;
2660
2661
2662
+ auto io_fallback_counter = [this ](const sstring& reason_str, submit_reason r) {
2663
+ static auto reason_label = sm::label (" reason" );
2664
+ return sm::make_counter (" io_threaded_fallbacks" , std::bind (&thread_pool::count, _thread_pool.get (), r),
2665
+ sm::description (" Total number of io-threaded-fallbacks operations" ), { reason_label (reason_str), });
2666
+ };
2667
+
2661
2668
_metric_groups.add_group (" reactor" , {
2662
2669
sm::make_gauge (" tasks_pending" , std::bind (&reactor::pending_task_count, this ), sm::description (" Number of pending tasks in the queue" )),
2663
2670
// total_operations value:DERIVE:0:U
@@ -2683,9 +2690,13 @@ void reactor::register_metrics() {
2683
2690
// total_operations value:DERIVE:0:U
2684
2691
sm::make_counter (" fsyncs" , _fsyncs, sm::description (" Total number of fsync operations" )),
2685
2692
// total_operations value:DERIVE:0:U
2686
- sm::make_counter (" io_threaded_fallbacks" , std::bind (&thread_pool::operation_count, _thread_pool.get ()),
2687
- sm::description (" Total number of io-threaded-fallbacks operations" )),
2688
-
2693
+ io_fallback_counter (" aio_fallback" , submit_reason::aio_fallback),
2694
+ // total_operations value:DERIVE:0:U
2695
+ io_fallback_counter (" file_operation" , submit_reason::file_operation),
2696
+ // total_operations value:DERIVE:0:U
2697
+ io_fallback_counter (" process_operation" , submit_reason::process_operation),
2698
+ // total_operations value:DERIVE:0:U
2699
+ io_fallback_counter (" unknown" , submit_reason::unknown),
2689
2700
});
2690
2701
2691
2702
_metric_groups.add_group (" memory" , {
0 commit comments