]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
client: Various fixes to fix multi-fuse client
authorChristopher Hoffman <choffman@redhat.com>
Tue, 22 Oct 2024 17:34:27 +0000 (17:34 +0000)
committerChristopher Hoffman <choffman@redhat.com>
Wed, 5 Nov 2025 13:59:34 +0000 (13:59 +0000)
Provide various fixes in which size used in
multi-fuse client tests.

Fixes: https://tracker.ceph.com/issues/68431
Signed-off-by: Christopher Hoffman <choffman@redhat.com>
src/client/Client.cc

index 9fdf3514ed484557650a9b4a371220406fb10ecb..b594de7b6d539b84e83ab72aaf3f16f96eba75ac 100644 (file)
@@ -954,17 +954,17 @@ void Client::trim_dentry(Dentry *dn)
 void Client::update_inode_file_size(Inode *in, int issued, uint64_t size,
                                    uint64_t truncate_seq, uint64_t truncate_size)
 {
-  uint64_t prior_size = in->size;
+  uint64_t prior_size = in->effective_size();
 
   // In the case of a pending trunc size that is smaller than orig size
   // (i.e. truncating from 8M to 4M) passed truncate_seq will be larger
   // than inode truncate_seq. This shows passed size is latest.
   if (truncate_seq > in->truncate_seq ||
       (truncate_seq == in->truncate_seq && size > in->effective_size())) {
-    ldout(cct, 10) << "size " << in->size << " -> " << size << dendl;
+    ldout(cct, 10) << "size " << in->effective_size() << " -> " << size << dendl;
     if (in->is_fscrypt_enabled()) {
       in->set_effective_size(size);
-      size = fscrypt_block_from_ofs(size);
+      size = fscrypt_next_block_start(size);
     }
     in->size = size;
     in->reported_size = size;
@@ -8404,8 +8404,8 @@ int Client::_do_setattr(Inode *in, struct ceph_statx *stx, int mask,
     return -EROFS;
   }
   if ((mask & CEPH_SETATTR_SIZE) &&
-      (uint64_t)stx->stx_size > in->size &&
-      is_quota_bytes_exceeded(in, (uint64_t)stx->stx_size - in->size,
+      (uint64_t)stx->stx_size > in->effective_size() &&
+      is_quota_bytes_exceeded(in, (uint64_t)stx->stx_size - in->effective_size(),
                              perms)) {
     return -EDQUOT;
   }
@@ -8557,7 +8557,6 @@ int Client::_do_setattr(Inode *in, struct ceph_statx *stx, int mask,
 
     if (in->fscrypt_ctx &&
         (!(mask & CEPH_SETATTR_FSCRYPT_FILE))) {
-      stx_size = fscrypt_next_block_start(stx_size);
       ldout(cct,10) << "fscrypt: set file size: orig stx_size=" << stx->stx_size <<" new stx_size=" << stx_size << dendl;
 
       alt_aux.resize(sizeof(stx->stx_size));
@@ -8578,7 +8577,9 @@ int Client::_do_setattr(Inode *in, struct ceph_statx *stx, int mask,
         !(mask & CEPH_SETATTR_KILL_SGUID) &&
         stx_size >= in->size) {
       if (stx_size > in->size) {
-        in->size = in->reported_size = stx_size;
+        in->reported_size = stx_size;
+        in->set_effective_size(stx_size);
+        in->size = fscrypt_next_block_start(stx_size);
         in->cap_dirtier_uid = perms.uid();
         in->cap_dirtier_gid = perms.gid();
         in->mark_caps_dirty(CEPH_CAP_FILE_EXCL);
@@ -10905,7 +10906,7 @@ int Client::_open(const InodeRef& in, int flags, mode_t mode, Fh **fhp,
       req->head.args.open.mask = DEBUG_GETATTR_CAPS;
     else
       req->head.args.open.mask = 0;
-    req->head.args.open.old_size = in->size;   // for O_TRUNC
+    req->head.args.open.old_size = in->effective_size();   // for O_TRUNC
     req->set_inode(in);
     result = make_request(req, perms);
 
@@ -11324,9 +11325,9 @@ void Client::C_Read_Sync_NonBlocking::finish(int r)
 
   // short read?
   if (r >= 0 && r < wanted) {
-    if (pos < in->size) {
+    if (pos < in->effective_size()) {
       // zero up to known EOF
-      int64_t some = in->size - pos;
+      int64_t some = in->effective_size() - pos;
       if (some > left)
         some = left;
       auto z = buffer::ptr_node::create(some);
@@ -11347,7 +11348,7 @@ void Client::C_Read_Sync_NonBlocking::finish(int r)
     }
 
     // eof?  short read.
-    if ((uint64_t)pos >= in->size)
+    if ((uint64_t)pos >= in->effective_size())
       goto success;
 
     wanted = left;
@@ -11555,7 +11556,7 @@ retry:
       }
 
       // eof?  short read.
-      if ((uint64_t)offset < in->size)
+      if ((uint64_t)offset < in->effective_size())
        goto retry;
     }
   }
@@ -11724,7 +11725,6 @@ int Client::_read_async(Fh *f, uint64_t off, uint64_t len, bufferlist *bl,
   std::vector<ObjectCacher::ObjHole> holes;
   r = objectcacher->file_read_ex(&in->oset, &in->layout, in->snapid,
                                  read_start, read_len, bl, 0, &holes, io_finish.get());
   if (onfinish != nullptr) {
     // put the cap ref since we're releasing C_Read_Async_Finisher
     put_cap_ref(in, CEPH_CAP_FILE_CACHE);