]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: enable non-buffered IO on WAL read 65275/head
authorIgor Fedotov <igor.fedotov@croit.io>
Tue, 2 Sep 2025 15:41:50 +0000 (18:41 +0300)
committerIgor Fedotov <igor.fedotov@croit.io>
Tue, 2 Jun 2026 19:31:43 +0000 (22:31 +0300)
Signed-off-by: Igor Fedotov <igor.fedotov@croit.io>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h

index 36da0b4c4c9429797ba209b625ff3e33dc8456bc..e36455e30305288d7d3597c9c1d167bffc53c6f4 100644 (file)
@@ -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;
 }
index 5030271a80dec97da97414f95412b739539a1362..ede361a6b5dc0e764d725a33617aff374d2c2aa7 100644 (file)
@@ -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() {