Skip to content

Commit 09e7cb7

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 <xemul@scylladb.com>
1 parent fe09fb4 commit 09e7cb7

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;
4646
};
4747
/// \endcond
4848

src/core/file.cc

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

1125-
if (fs_nowait_works && engine()._cfg.aio_nowait_works) {
1126-
fsi.nowait_works = nowait_mode::yes;
1127-
} else {
1125+
if (!fs_nowait_works) {
11281126
fsi.nowait_works = nowait_mode::no;
1127+
} else if (engine()._cfg.aio_nowait_works.has_value()) {
1128+
if (*engine()._cfg.aio_nowait_works) {
1129+
fsi.nowait_works = nowait_mode::yes;
1130+
} else {
1131+
fsi.nowait_works = nowait_mode::no;
1132+
}
1133+
} else {
1134+
if (internal::kernel_uname().whitelisted({"6.0"})) {
1135+
fsi.nowait_works = nowait_mode::read_only; // seastar issue #2974
1136+
} else if (internal::kernel_uname().whitelisted({"4.13"})) {
1137+
fsi.nowait_works = nowait_mode::yes;
1138+
} else {
1139+
fsi.nowait_works = nowait_mode::no;
1140+
}
11291141
}
11301142
s_fstype.insert(std::make_pair(st.st_dev, std::move(fsi)));
11311143
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
@@ -1482,7 +1482,7 @@ reactor::test::get_stall_detector_report_function() {
14821482
}
14831483

14841484
bool reactor::test::linux_aio_nowait() {
1485-
return engine()._cfg.aio_nowait_works;
1485+
return engine()._cfg.aio_nowait_works.value_or(true);
14861486
}
14871487

14881488
void
@@ -3866,7 +3866,7 @@ reactor_options::reactor_options(program_options::option_group* parent_group)
38663866
, blocked_reactor_reports_per_minute(*this, "blocked-reactor-reports-per-minute", 5, "Maximum number of backtraces reported by stall detector per minute")
38673867
, blocked_reactor_report_format_oneline(*this, "blocked-reactor-report-format-oneline", true, "Print a simplified backtrace on a single line")
38683868
, relaxed_dma(*this, "relaxed-dma", "allow using buffered I/O if DMA is not available (reduces performance)")
3869-
, linux_aio_nowait(*this, "linux-aio-nowait", internal::kernel_uname().whitelisted({"4.13"}), // base version where this works
3869+
, linux_aio_nowait(*this, "linux-aio-nowait", {},
38703870
"use the Linux NOWAIT AIO feature, which reduces reactor stalls due to aio (autodetected)")
38713871
, unsafe_bypass_fsync(*this, "unsafe-bypass-fsync", false, "Bypass fsync(), may result in data loss. Use for testing on consumer drives")
38723872
, kernel_page_cache(*this, "kernel-page-cache", false,
@@ -4408,7 +4408,7 @@ void smp::configure(const smp_options& smp_opts, const reactor_options& reactor_
44084408
.strict_o_direct = !reactor_opts.relaxed_dma,
44094409
.bypass_fsync = reactor_opts.unsafe_bypass_fsync.get_value(),
44104410
.no_poll_aio = !reactor_opts.poll_aio.get_value() || (reactor_opts.poll_aio.defaulted() && reactor_opts.overprovisioned),
4411-
.aio_nowait_works = reactor_opts.linux_aio_nowait.get_value(), // Mixed in with filesystem-provided values later
4411+
.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
44124412
};
44134413

44144414
// Disable hot polling if sched wakeup granularity is too high

0 commit comments

Comments
 (0)