]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix handling of ctime and change_attr in fill_statx
authorJeff Layton <jlayton@redhat.com>
Wed, 12 Oct 2016 11:04:41 +0000 (07:04 -0400)
committerJeff Layton <jlayton@redhat.com>
Wed, 12 Oct 2016 11:04:41 +0000 (07:04 -0400)
Technically, we need all the shared caps to fill those fields out, to
force synchronization from all the clients. Ensure that we have the
right caps before filling out those fields.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/client/Client.cc

index 4b06c5407101399970d264b651c22c6749c4d89a..5d96bda9e2266d82c42e3276fc4bd6e53d15b8d6 100644 (file)
@@ -6864,14 +6864,8 @@ void Client::fill_statx(Inode *in, unsigned int mask, struct ceph_statx *stx)
 
   if (mask & CEPH_CAP_FILE_SHARED) {
 
-    if (in->ctime > in->mtime)
-      in->ctime.to_timespec(&stx->stx_ctime);
-    else
-      in->mtime.to_timespec(&stx->stx_ctime);
-
     in->atime.to_timespec(&stx->stx_atime);
     in->mtime.to_timespec(&stx->stx_mtime);
-    stx->stx_version = in->change_attr;
 
     if (in->is_dir()) {
       if (cct->_conf->client_dirsize_rbytes)
@@ -6883,9 +6877,20 @@ void Client::fill_statx(Inode *in, unsigned int mask, struct ceph_statx *stx)
       stx->stx_size = in->size;
       stx->stx_blocks = (in->size + 511) >> 9;
     }
-    stx->stx_mask |= (CEPH_STATX_ATIME|CEPH_STATX_MTIME|CEPH_STATX_CTIME|
-                     CEPH_STATX_SIZE|CEPH_STATX_BLOCKS|CEPH_STATX_VERSION);
+    stx->stx_mask |= (CEPH_STATX_ATIME|CEPH_STATX_MTIME|
+                     CEPH_STATX_SIZE|CEPH_STATX_BLOCKS);
+  }
+
+  /* Change time and change_attr both require all shared caps to view */
+  if ((mask & CEPH_STAT_CAP_INODE_ALL) == CEPH_STAT_CAP_INODE_ALL) {
+    stx->stx_version = in->change_attr;
+    if (in->ctime > in->mtime)
+      in->ctime.to_timespec(&stx->stx_ctime);
+    else
+      in->mtime.to_timespec(&stx->stx_ctime);
+    stx->stx_mask |= (CEPH_STATX_CTIME|CEPH_STATX_VERSION);
   }
+
 }
 
 void Client::touch_dn(Dentry *dn)