Skip to content

Commit 894ff94

Browse files
committed
file: Change nowait_works mode detection
In the end of the day the nowait mode to use depends on three sources of information: the filesystem itself, the kernel version and the reactor option (CLI switch). By now the selection was between yes and no modes, this patch wires the read_only mode detection and activation. Signed-off-by: Pavel Emelyanov <[email protected]>
1 parent 87adc0a commit 894ff94

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

include/seastar/core/reactor_config.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct reactor_config {
4242
bool strict_o_direct = true;
4343
bool bypass_fsync = false;
4444
bool no_poll_aio = false;
45-
bool aio_nowait_works = false;
45+
std::optional<bool> aio_nowait_works = false;
4646
bool abort_on_too_long_task_queue = false;
4747
};
4848
/// \endcond

src/core/file.cc

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,10 +1107,22 @@ make_file_impl(int fd, file_open_options options, int flags, struct stat st) noe
11071107
fsi.fsync_is_exclusive = true;
11081108
}
11091109

1110-
if (fs_nowait_works && engine()._cfg.aio_nowait_works) {
1111-
fsi.nowait_works = nowait_mode::yes;
1112-
} else {
1110+
if (!fs_nowait_works) {
11131111
fsi.nowait_works = nowait_mode::no;
1112+
} else if (engine()._cfg.aio_nowait_works.has_value()) {
1113+
if (*engine()._cfg.aio_nowait_works) {
1114+
fsi.nowait_works = nowait_mode::yes;
1115+
} else {
1116+
fsi.nowait_works = nowait_mode::no;
1117+
}
1118+
} else {
1119+
if (internal::kernel_uname().whitelisted({"6.0"})) {
1120+
fsi.nowait_works = nowait_mode::read_only; // seastar issue #2974
1121+
} else if (internal::kernel_uname().whitelisted({"4.13"})) {
1122+
fsi.nowait_works = nowait_mode::yes;
1123+
} else {
1124+
fsi.nowait_works = nowait_mode::no;
1125+
}
11141126
}
11151127
s_fstype.insert(std::make_pair(st.st_dev, std::move(fsi)));
11161128
return make_file_impl(fd, std::move(options), flags, std::move(st));

src/core/reactor.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ reactor::test::get_stall_detector_report_function() {
14931493
}
14941494

14951495
bool reactor::test::linux_aio_nowait() {
1496-
return engine()._cfg.aio_nowait_works;
1496+
return engine()._cfg.aio_nowait_works.value_or(true);
14971497
}
14981498

14991499
reactor::test::long_task_queue_state
@@ -3905,7 +3905,7 @@ reactor_options::reactor_options(program_options::option_group* parent_group)
39053905
, blocked_reactor_reports_per_minute(*this, "blocked-reactor-reports-per-minute", 5, "Maximum number of backtraces reported by stall detector per minute")
39063906
, blocked_reactor_report_format_oneline(*this, "blocked-reactor-report-format-oneline", true, "Print a simplified backtrace on a single line")
39073907
, relaxed_dma(*this, "relaxed-dma", "allow using buffered I/O if DMA is not available (reduces performance)")
3908-
, linux_aio_nowait(*this, "linux-aio-nowait", internal::kernel_uname().whitelisted({"4.13"}), // base version where this works
3908+
, linux_aio_nowait(*this, "linux-aio-nowait", {},
39093909
"use the Linux NOWAIT AIO feature, which reduces reactor stalls due to aio (autodetected)")
39103910
, unsafe_bypass_fsync(*this, "unsafe-bypass-fsync", false, "Bypass fsync(), may result in data loss. Use for testing on consumer drives")
39113911
, kernel_page_cache(*this, "kernel-page-cache", false,
@@ -4450,7 +4450,7 @@ void smp::configure(const smp_options& smp_opts, const reactor_options& reactor_
44504450
.strict_o_direct = !reactor_opts.relaxed_dma,
44514451
.bypass_fsync = reactor_opts.unsafe_bypass_fsync.get_value(),
44524452
.no_poll_aio = !reactor_opts.poll_aio.get_value() || (reactor_opts.poll_aio.defaulted() && reactor_opts.overprovisioned),
4453-
.aio_nowait_works = reactor_opts.linux_aio_nowait.get_value(), // Mixed in with filesystem-provided values later
4453+
.aio_nowait_works = reactor_opts.linux_aio_nowait.defaulted() ? std::optional<bool>(std::nullopt) : std::optional<bool>(reactor_opts.linux_aio_nowait.get_value()), // Mixed in with filesystem-provided values later
44544454
.abort_on_too_long_task_queue = reactor_opts.abort_on_too_long_task_queue.get_value(),
44554455
};
44564456

0 commit comments

Comments
 (0)