From: Igor Fedotov Date: Mon, 6 Apr 2020 13:43:06 +0000 (+0300) Subject: os/bluestore: kill buf param in BlueFS::read X-Git-Tag: v16.1.0~2628^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=645b923722a8d1727f3c44d5c6bc7f9e93bafb78;p=ceph.git os/bluestore: kill buf param in BlueFS::read This param is redundant as it's accessible via FileReader instance. Signed-off-by: Igor Fedotov --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index fbb5958e108..003e581d6f6 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -1006,7 +1006,7 @@ int BlueFS::_replay(bool noop, bool to_stdout) uint64_t read_pos = pos; bufferlist bl; { - int r = _read(log_reader, &log_reader->buf, read_pos, super.block_size, + int r = _read(log_reader, read_pos, super.block_size, &bl, NULL); ceph_assert(r == (int)super.block_size); read_pos += r; @@ -1059,7 +1059,7 @@ int BlueFS::_replay(bool noop, bool to_stdout) dout(20) << __func__ << " need 0x" << std::hex << more << std::dec << " more bytes" << dendl; bufferlist t; - int r = _read(log_reader, &log_reader->buf, read_pos, more, &t, NULL); + int r = _read(log_reader, read_pos, more, &t, NULL); if (r < (int)more) { derr << __func__ << " 0x" << std::hex << pos << ": stop: len is 0x" << bl.length() + more << std::dec @@ -1129,7 +1129,7 @@ int BlueFS::_replay(bool noop, bool to_stdout) uint64_t skip = offset - read_pos; if (skip) { bufferlist junk; - int r = _read(log_reader, &log_reader->buf, read_pos, skip, &junk, + int r = _read(log_reader, read_pos, skip, &junk, NULL); if (r != (int)skip) { dout(10) << __func__ << " 0x" << std::hex << read_pos @@ -1960,12 +1960,13 @@ int BlueFS::_read_random( int BlueFS::_read( FileReader *h, ///< [in] read from here - FileReaderBuffer *buf, ///< [in] reader state uint64_t off, ///< [in] offset size_t len, ///< [in] this many bytes bufferlist *outbl, ///< [out] optional: reference the result here char *out) ///< [out] optional: or copy it here { + FileReaderBuffer *buf = &(h->buf); + bool prefetch = !outbl && !out; dout(10) << __func__ << " h " << h << " 0x" << std::hex << off << "~" << len << std::dec diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 4de478bb9a8..708741cf844 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -390,7 +390,6 @@ private: int _read( FileReader *h, ///< [in] read from here - FileReaderBuffer *buf, ///< [in] reader state uint64_t offset, ///< [in] offset size_t len, ///< [in] this many bytes ceph::buffer::list *outbl, ///< [out] optional: reference the result here @@ -557,12 +556,12 @@ public: std::unique_lock l(lock); return _fsync(h, l); } - int read(FileReader *h, FileReaderBuffer *buf, uint64_t offset, size_t len, + int read(FileReader *h, uint64_t offset, size_t len, ceph::buffer::list *outbl, char *out) { // no need to hold the global lock here; we only touch h and // h->file, and read vs write or delete is already protected (via // atomics and asserts). - return _read(h, buf, offset, len, outbl, out); + return _read(h, offset, len, outbl, out); } int read_random(FileReader *h, uint64_t offset, size_t len, char *out) { diff --git a/src/os/bluestore/BlueRocksEnv.cc b/src/os/bluestore/BlueRocksEnv.cc index 7f2f8991b9e..3397104dc36 100644 --- a/src/os/bluestore/BlueRocksEnv.cc +++ b/src/os/bluestore/BlueRocksEnv.cc @@ -47,7 +47,7 @@ class BlueRocksSequentialFile : public rocksdb::SequentialFile { // // REQUIRES: External synchronization rocksdb::Status Read(size_t n, rocksdb::Slice* result, char* scratch) override { - int r = fs->read(h, &h->buf, h->buf.pos, n, NULL, scratch); + int r = fs->read(h, h->buf.pos, n, NULL, scratch); ceph_assert(r >= 0); *result = rocksdb::Slice(scratch, r); return rocksdb::Status::OK(); @@ -123,7 +123,7 @@ class BlueRocksRandomAccessFile : public rocksdb::RandomAccessFile { // Readahead the file starting from offset by n bytes for caching. rocksdb::Status Prefetch(uint64_t offset, size_t n) override { - fs->read(h, &h->buf, offset, n, nullptr, nullptr); + fs->read(h, offset, n, nullptr, nullptr); return rocksdb::Status::OK(); } diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index 66b5a796dde..ffb011b6208 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -642,7 +642,7 @@ int main(int argc, char **argv) int left = size; while (left) { bufferlist bl; - r = fs->read(h, &h->buf, pos, left, &bl, NULL); + r = fs->read(h, pos, left, &bl, NULL); if (r <= 0) { cerr << "read " << dir << "/" << file << " from " << pos << " failed: " << cpp_strerror(r) << std::endl; diff --git a/src/test/objectstore/test_bluefs.cc b/src/test/objectstore/test_bluefs.cc index ef838ab124f..388ecc408f3 100644 --- a/src/test/objectstore/test_bluefs.cc +++ b/src/test/objectstore/test_bluefs.cc @@ -158,8 +158,7 @@ TEST(BlueFS, write_read) { BlueFS::FileReader *h; ASSERT_EQ(0, fs.open_for_read("dir", "file", &h)); bufferlist bl; - BlueFS::FileReaderBuffer buf(4096); - ASSERT_EQ(9, fs.read(h, &buf, 0, 1024, &bl, NULL)); + ASSERT_EQ(9, fs.read(h, 0, 1024, &bl, NULL)); ASSERT_EQ(0, strncmp("foobarbaz", bl.c_str(), 9)); delete h; } @@ -231,10 +230,9 @@ TEST(BlueFS, very_large_write) { BlueFS::FileReader *h; ASSERT_EQ(0, fs.open_for_read("dir", "bigfile", &h)); bufferlist bl; - BlueFS::FileReaderBuffer readbuf(10485760); for (unsigned i = 0; i < 3*1024*1048576ull / sizeof(buf); ++i) { bl.clear(); - fs.read(h, &readbuf, i * sizeof(buf), sizeof(buf), &bl, NULL); + fs.read(h, i * sizeof(buf), sizeof(buf), &bl, NULL); int r = memcmp(buf, bl.c_str(), sizeof(buf)); if (r) { cerr << "read got mismatch at offset " << i*sizeof(buf) << " r " << r