[1/3] ceph: update i_files/i_subdirs only when Fs cap is issued
diff mbox

Message ID 20180427125534.66333-1-zyan@redhat.com
State New
Headers show

Commit Message

Yan, Zheng April 27, 2018, 12:55 p.m. UTC
In MDS, file/subdir counts of a directory inode are protected by
filelock. In request reply without Fs cap, nfiles/nsubdirs can be
stale.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
---
 fs/ceph/inode.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Patch
diff mbox

diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index b52961b1e705..d673f2ef29c4 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -838,6 +838,11 @@  static int fill_inode(struct inode *inode, struct page *locked_page,
 				&ctime, &mtime, &atime);
 	}
 
+	if (new_version || (new_issued & CEPH_CAP_FILE_SHARED)) {
+		ci->i_files = le64_to_cpu(info->files);
+		ci->i_subdirs = le64_to_cpu(info->subdirs);
+	}
+
 	if (new_version ||
 	    (new_issued & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR))) {
 		s64 old_pool = ci->i_layout.pool_id;
@@ -943,10 +948,6 @@  static int fill_inode(struct inode *inode, struct page *locked_page,
 	case S_IFDIR:
 		inode->i_op = &ceph_dir_iops;
 		inode->i_fop = &ceph_dir_fops;
-
-
-		ci->i_files = le64_to_cpu(info->files);
-		ci->i_subdirs = le64_to_cpu(info->subdirs);
 		break;
 	default:
 		pr_err("%s: %llx.%llx BAD mode 0%o\n",