All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thorsten Fuchs <t.fuchs@thofu.net>
To: ceph-devel@vger.kernel.org
Cc: Thorsten Fuchs <t.fuchs@thofu.net>
Subject: [PATCH] ceph: fix stale xattr when using read() on dir with '-o dirstat'
Date: Thu, 16 May 2024 19:00:21 +0200	[thread overview]
Message-ID: <20240516170021.3738-1-t.fuchs@thofu.net> (raw)

Fixes stale recursive stats (rbytes, rentries, ...) being returned for
a directory after creating/deleting entries in subdirectories.

Now `getfattr` and `cat` return the same values for the attributes.

Signed-off-by: Thorsten Fuchs <t.fuchs@thofu.net>
---
 fs/ceph/dir.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 0e9f56eaba1e..e3cf76660305 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -2116,12 +2116,16 @@ static ssize_t ceph_read_dir(struct file *file, char __user *buf, size_t size,
 	struct ceph_dir_file_info *dfi = file->private_data;
 	struct inode *inode = file_inode(file);
 	struct ceph_inode_info *ci = ceph_inode(inode);
-	int left;
+	int left, err;
 	const int bufsize = 1024;
 
 	if (!ceph_test_mount_opt(ceph_sb_to_fs_client(inode->i_sb), DIRSTAT))
 		return -EISDIR;
 
+	err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR, true);
+	if (err)
+		return err;
+
 	if (!dfi->dir_info) {
 		dfi->dir_info = kmalloc(bufsize, GFP_KERNEL);
 		if (!dfi->dir_info)
-- 
2.34.1


             reply	other threads:[~2024-05-16 17:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16 17:00 Thorsten Fuchs [this message]
2024-05-17  0:32 ` [PATCH] ceph: fix stale xattr when using read() on dir with '-o dirstat' Xiubo Li
2024-05-17  4:47   ` t.fuchs
     [not found] <10830198.216745.1716300283630@office.mailbox.org>
2024-05-21 15:55 ` Thorsten Fuchs
2024-05-22  0:36   ` Xiubo Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240516170021.3738-1-t.fuchs@thofu.net \
    --to=t.fuchs@thofu.net \
    --cc=ceph-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.