From: Igor Fedotov Date: Tue, 2 Sep 2025 15:41:50 +0000 (+0300) Subject: os/bluestore: enable non-buffered IO on WAL read X-Git-Tag: v21.0.1~18^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=e882a4f014b31527e41fed6e5f02da3f9b10f17d;p=ceph.git os/bluestore: enable non-buffered IO on WAL read Signed-off-by: Igor Fedotov --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 36da0b4c4c9..e36455e3030 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -1429,7 +1429,7 @@ int BlueFS::_replay(bool noop, bool to_stdout) FileReader *log_reader = new FileReader( log_file, cct->_conf->bluefs_max_prefetch, - true); // ignore eof + {.ignore_eof = true, .buffered = false}); bool seen_recs = false; @@ -2576,10 +2576,10 @@ int64_t BlueFS::_read_random( int r; if (!cct->_conf->bluefs_check_for_zeros) { r = _bdev_read_random(p->bdev, p->offset + x_off, l, out, - cct->_conf->bluefs_buffered_io); + h->buffered); } else { r = _read_random_and_check(p->bdev, p->offset + x_off, l, out, - cct->_conf->bluefs_buffered_io); + h->buffered); } ceph_assert(r == 0); off += l; @@ -2654,7 +2654,7 @@ void BlueFS::_envmode_index_file( File::envelope_t flush; bool envelope_good; uint64_t file_size = file->fnode.size; - FileReader *h = new FileReader(file, 4096, true); + FileReader *h = new FileReader(file, 4096, {.ignore_eof = true, .buffered = false}); ceph_assert(h); while(scan_ofs < file->fnode.allocated) { envelope_good = _read_envelope(h, scan_ofs, env_ofs, &flush); @@ -2892,14 +2892,13 @@ int64_t BlueFS::_read( int r; // when reading BlueFS log (only happens on startup) use non-buffered io // it makes it in sync with logic in _flush_range() - bool use_buffered_io = h->file->fnode.ino == 1 ? false : cct->_conf->bluefs_buffered_io; if (!cct->_conf->bluefs_check_for_zeros) { r = _bdev_read(p->bdev, p->offset + x_off, l, &buf->bl, ioc[p->bdev], - use_buffered_io); + h->buffered); } else { r = _read_and_check( p->bdev, p->offset + x_off, l, &buf->bl, ioc[p->bdev], - use_buffered_io); + h->buffered); } logger->inc(l_bluefs_read_disk_count, 1); logger->inc(l_bluefs_read_disk_bytes, l); @@ -4935,11 +4934,13 @@ int BlueFS::open_for_read( return -ENOENT; } File *file = q->second.get(); - if (file->envelope_mode() && !file->envelopes_indexed) { + bool envelope = file->envelope_mode(); + if (envelope && !file->envelopes_indexed) { _envmode_index_file(file); } *h = new FileReader(file, random ? 4096 : cct->_conf->bluefs_max_prefetch, - file->envelope_mode()); + {.ignore_eof = envelope, + .buffered = envelope ? false : cct->_conf->bluefs_buffered_io}); dout(10) << __func__ << " h " << *h << " on " << file->fnode << dendl; return 0; } diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 5030271a80d..ede361a6b5d 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -549,21 +549,27 @@ public: } }; + struct FileReaderOpts { + bool ignore_eof; + bool buffered; + }; struct FileReader { MEMPOOL_CLASS_HELPERS(); FileRef file; FileReaderBuffer buf; bool ignore_eof; ///< used when reading our log file + bool buffered; ceph::shared_mutex lock { ceph::make_shared_mutex(std::string(), false, false, false) }; - FileReader(FileRef f, uint64_t mpf, bool ie) + FileReader(FileRef f, uint64_t mpf, const FileReaderOpts opts) : file(f), buf(mpf), - ignore_eof(ie) { + ignore_eof(opts.ignore_eof), + buffered(opts.buffered) { ++file->num_readers; } ~FileReader() {