From bb053b5be4d35352d0e1b926967c7c837de008af Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 12 Oct 2016 07:04:41 -0400 Subject: [PATCH] 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 --- src/client/Client.cc | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 4b06c54071013..5d96bda9e2266 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) -- 2.39.5