]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds: move fscrypt_last_block to vector in mds_co mempool
authorPatrick Donnelly <pdonnell@redhat.com>
Thu, 22 Aug 2024 14:10:35 +0000 (10:10 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Thu, 5 Sep 2024 13:39:33 +0000 (09:39 -0400)
Encoding doesn't change.

Fixes: https://tracker.ceph.com/issues/67687
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit 190868a8f6f28736efc988fed0d697ec2dea78b0)

src/include/cephfs/types.h
src/mds/MDCache.cc
src/mds/Server.cc

index d3da63076a006ce98c005ad9e5e2a899a1303929..314dbfad6ca88d2bddda51e3f1c26a254a677db9 100644 (file)
@@ -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<uint8_t,Allocator<uint8_t>> fscrypt_auth;
   std::vector<uint8_t,Allocator<uint8_t>> fscrypt_file;
-
-  bufferlist fscrypt_last_block;
+  std::vector<uint8_t,Allocator<uint8_t>> fscrypt_last_block;
 
 private:
   bool older_is_consistent(const inode_t &other) const;
index f00e588c7a2e3644cb21d8f5feffcee394785c25..5475591b8dfdc1bdb9fefacbe14f121923ae6547 100644 (file)
@@ -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");
 
index 895c915e7d6b6693c135ba355a3de4504ad55b75..210288e97bc86156a1400e20ef683242c17c3f20 100644 (file)
@@ -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;