From: Jeff Layton Date: Wed, 12 Oct 2016 11:04:41 +0000 (-0400) Subject: client: fix handling of ctime and change_attr in fill_statx X-Git-Tag: v11.1.0~625^2~8 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=bb053b5be4d35352d0e1b926967c7c837de008af;p=ceph-ci.git client: fix handling of ctime and change_attr in fill_statx 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 --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 4b06c540710..5d96bda9e22 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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)