From: John Spray Date: Wed, 15 Mar 2017 15:32:47 +0000 (+0000) Subject: client: getattr before read on ceph.* xattrs X-Git-Tag: v11.2.1~25^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5a69e33057982d78157b75bce3fc458e03260d9e;p=ceph.git client: getattr before read on ceph.* xattrs Previously we were returning values for quota, layout xattrs without any kind of update -- the user just got whatever happened to be in our cache. Clearly this extra round trip has a cost, but reads of these xattrs are fairly rare, happening on admin intervention rather than in normal operation. Fixes: http://tracker.ceph.com/issues/17939 Signed-off-by: John Spray (cherry picked from commit 532dc4b68e538c189ef828f67cecd0d647a62250) --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 2596920814d..7b0a42d14a1 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -10341,10 +10341,21 @@ int Client::_getxattr(Inode *in, const char *name, void *value, size_t size, if (vxattr) { r = -ENODATA; - char buf[256]; + // Do a force getattr to get the latest quota before returning + // a value to userspace. + r = _getattr(in, 0, perms, true); + if (r != 0) { + // Error from getattr! + return r; + } + // call pointer-to-member function - if (!(vxattr->exists_cb && !(this->*(vxattr->exists_cb))(in))) + char buf[256]; + if (!(vxattr->exists_cb && !(this->*(vxattr->exists_cb))(in))) { r = (this->*(vxattr->getxattr_cb))(in, buf, sizeof(buf)); + } else { + r = -ENODATA; + } if (size != 0) { if (r > (int)size) {