]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: getattr before read on ceph.* xattrs
authorJohn Spray <john.spray@redhat.com>
Wed, 15 Mar 2017 15:32:47 +0000 (15:32 +0000)
committerNathan Cutler <ncutler@suse.com>
Sun, 4 Jun 2017 09:38:37 +0000 (11:38 +0200)
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 <john.spray@redhat.com>
(cherry picked from commit 532dc4b68e538c189ef828f67cecd0d647a62250)

src/client/Client.cc

index 616a8b2273cc098f5ae434ecfeba0d678e0b2186..840958e528a9847b8089e43ca87dd72d08884129 100644 (file)
@@ -9827,10 +9827,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) {