From: Christopher Hoffman Date: Tue, 22 Oct 2024 17:34:27 +0000 (+0000) Subject: client: Various fixes to fix multi-fuse client X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=aa2b87c8965d59cb0baace99969738901f0b9637;p=ceph-ci.git client: Various fixes to fix multi-fuse client Provide various fixes in which size used in multi-fuse client tests. Fixes: https://tracker.ceph.com/issues/68431 Signed-off-by: Christopher Hoffman --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 1be9dda7315..9f6fbcf51c7 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -934,17 +934,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; @@ -8338,8 +8338,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; } @@ -8491,7 +8491,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)); @@ -8512,7 +8511,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); @@ -10843,7 +10844,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); @@ -11261,9 +11262,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); @@ -11284,7 +11285,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; @@ -11492,7 +11493,7 @@ retry: } // eof? short read. - if ((uint64_t)offset < in->size) + if ((uint64_t)offset < in->effective_size()) goto retry; } } @@ -11658,7 +11659,6 @@ int Client::_read_async(Fh *f, uint64_t off, uint64_t len, bufferlist *bl, std::vector 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);