From 8d9b561370dc4b2a890a7d506bd47488dd702c80 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Thu, 22 Aug 2024 10:10:35 -0400 Subject: [PATCH] mds: move fscrypt_last_block to vector in mds_co mempool Encoding doesn't change. Fixes: https://tracker.ceph.com/issues/67687 Signed-off-by: Patrick Donnelly (cherry picked from commit 190868a8f6f28736efc988fed0d697ec2dea78b0) --- src/include/cephfs/types.h | 7 +++---- src/mds/MDCache.cc | 32 +++++++++++++++++--------------- src/mds/Server.cc | 2 +- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/include/cephfs/types.h b/src/include/cephfs/types.h index d3da63076a0..314dbfad6ca 100644 --- a/src/include/cephfs/types.h +++ b/src/include/cephfs/types.h @@ -408,9 +408,9 @@ struct inode_t { bool is_file() const { return (mode & S_IFMT) == S_IFREG; } bool is_truncating() const { return (truncate_pending > 0); } - void truncate(uint64_t old_size, uint64_t new_size, const bufferlist &fbl) { + void truncate(uint64_t old_size, uint64_t new_size, ::ceph::buffer::list::const_iterator fblp) { truncate(old_size, new_size); - fscrypt_last_block = fbl; + fblp.copy(fblp.get_remaining(), fscrypt_last_block); } void truncate(uint64_t old_size, uint64_t new_size) { ceph_assert(new_size <= old_size); @@ -608,8 +608,7 @@ struct inode_t { std::vector> fscrypt_auth; std::vector> fscrypt_file; - - bufferlist fscrypt_last_block; + std::vector> fscrypt_last_block; private: bool older_is_consistent(const inode_t &other) const; diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index f00e588c7a2..5475591b8df 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -6518,7 +6518,7 @@ void MDCache::_truncate_inode(CInode *in, LogSegment *ls) const auto& pi = in->get_inode(); dout(10) << "_truncate_inode " << pi->truncate_from << " -> " << pi->truncate_size - << " fscrypt last block length is " << pi->fscrypt_last_block.length() + << " fscrypt last block length is " << pi->fscrypt_last_block.size() << " on " << *in << dendl; ceph_assert(pi->is_truncating()); @@ -6526,7 +6526,7 @@ void MDCache::_truncate_inode(CInode *in, LogSegment *ls) ceph_assert(pi->truncate_from < (1ULL << 63)); ceph_assert(pi->truncate_size < pi->truncate_from || (pi->truncate_size == pi->truncate_from && - pi->fscrypt_last_block.length())); + pi->fscrypt_last_block.size())); SnapRealm *realm = in->find_snaprealm(); @@ -6541,18 +6541,20 @@ void MDCache::_truncate_inode(CInode *in, LogSegment *ls) ceph_assert(in->last == CEPH_NOSNAP); } dout(10) << "_truncate_inode snapc " << snapc << " on " << *in - << " fscrypt_last_block length is " << pi->fscrypt_last_block.length() + << " fscrypt_last_block length is " << pi->fscrypt_last_block.size() << dendl; auto layout = pi->layout; struct ceph_fscrypt_last_block_header header; memset(&header, 0, sizeof(header)); bufferlist data; - if (pi->fscrypt_last_block.length()) { - auto bl = pi->fscrypt_last_block.cbegin(); - DECODE_START(1, bl); - decode(header.change_attr, bl); - decode(header.file_offset, bl); - decode(header.block_size, bl); + if (pi->fscrypt_last_block.size()) { + auto _bl = bufferlist(); + _bl.append(pi->fscrypt_last_block); + auto blp = _bl.cbegin(); + DECODE_START(1, blp); + decode(header.change_attr, blp); + decode(header.file_offset, blp); + decode(header.block_size, blp); /* * The block_size will be in unit of KB, so if the last block is not @@ -6560,9 +6562,9 @@ void MDCache::_truncate_inode(CInode *in, LogSegment *ls) * header.block_size. */ if (struct_len > header.block_size) { - bl.copy(header.block_size, data); + blp.copy(header.block_size, data); } - DECODE_FINISH(bl); + DECODE_FINISH(blp); } if (data.length()) { @@ -6583,7 +6585,7 @@ void MDCache::_truncate_inode(CInode *in, LogSegment *ls) * this case we will always request a larger length to make sure the * OSD won't miss truncating the last object. */ - if (pi->fscrypt_last_block.length()) { + if (pi->fscrypt_last_block.size()) { dout(10) << "_truncate_inode truncate on inode " << *in << " hits a hole!" << dendl; length += header.block_size; } @@ -6621,7 +6623,7 @@ void MDCache::truncate_inode_write_finish(CInode *in, LogSegment *ls, ceph_assert(pi->truncate_from < (1ULL << 63)); ceph_assert(pi->truncate_size < pi->truncate_from || (pi->truncate_size == pi->truncate_from && - pi->fscrypt_last_block.length())); + pi->fscrypt_last_block.size())); SnapRealm *realm = in->find_snaprealm(); @@ -6636,7 +6638,7 @@ void MDCache::truncate_inode_write_finish(CInode *in, LogSegment *ls, ceph_assert(in->last == CEPH_NOSNAP); } dout(10) << "_truncate_inode_write snapc " << snapc << " on " << *in - << " fscrypt_last_block length is " << pi->fscrypt_last_block.length() + << " fscrypt_last_block length is " << pi->fscrypt_last_block.size() << dendl; auto layout = pi->layout; /* @@ -6668,7 +6670,7 @@ void MDCache::truncate_inode_finish(CInode *in, LogSegment *ls) pi.inode->version = in->pre_dirty(); pi.inode->truncate_from = 0; pi.inode->truncate_pending--; - pi.inode->fscrypt_last_block = bufferlist(); + pi.inode->fscrypt_last_block.clear(); EUpdate *le = new EUpdate(mds->mdlog, "truncate finish"); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 895c915e7d6..210288e97bc 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -5455,7 +5455,7 @@ void Server::handle_client_setattr(const MDRequestRef& mdr) pi.inode->time_warp_seq++; // maybe not a timewarp, but still a serialization point. if (mask & CEPH_SETATTR_SIZE) { if (truncating_smaller) { - pi.inode->truncate(old_size, req->head.args.setattr.size, req->get_data()); + pi.inode->truncate(old_size, req->head.args.setattr.size, req->get_data().cbegin()); le->metablob.add_truncate_start(cur->ino()); } else { pi.inode->size = req->head.args.setattr.size; -- 2.39.5