]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ceph: fix cap release race
authorYan, Zheng <zheng.z.yan@intel.com>
Mon, 3 Jun 2013 10:22:17 +0000 (18:22 +0800)
committerSage Weil <sage@inktank.com>
Thu, 13 Jun 2013 15:46:30 +0000 (08:46 -0700)
ceph_encode_inode_release() can race with ceph_open() and release
caps wanted by open files. So it should call __ceph_caps_wanted()
to get the wanted caps.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Reviewed-by: Sage Weil <sage@inktank.com>
fs/ceph/caps.c

index da0f9b8a3bcb7c906d1beaca275921196860f325..54c290b083ab75c3a082d7c909ab8312d15a8448 100644 (file)
@@ -3042,21 +3042,19 @@ int ceph_encode_inode_release(void **p, struct inode *inode,
                     (cap->issued & unless) == 0)) {
                        if ((cap->issued & drop) &&
                            (cap->issued & unless) == 0) {
-                               dout("encode_inode_release %p cap %p %s -> "
-                                    "%s\n", inode, cap,
+                               int wanted = __ceph_caps_wanted(ci);
+                               if ((ci->i_ceph_flags & CEPH_I_NODELAY) == 0)
+                                       wanted |= cap->mds_wanted;
+                               dout("encode_inode_release %p cap %p "
+                                    "%s -> %s, wanted %s -> %s\n", inode, cap,
                                     ceph_cap_string(cap->issued),
-                                    ceph_cap_string(cap->issued & ~drop));
+                                    ceph_cap_string(cap->issued & ~drop),
+                                    ceph_cap_string(cap->mds_wanted),
+                                    ceph_cap_string(wanted));
+
                                cap->issued &= ~drop;
                                cap->implemented &= ~drop;
-                               if (ci->i_ceph_flags & CEPH_I_NODELAY) {
-                                       int wanted = __ceph_caps_wanted(ci);
-                                       dout("  wanted %s -> %s (act %s)\n",
-                                            ceph_cap_string(cap->mds_wanted),
-                                            ceph_cap_string(cap->mds_wanted &
-                                                            ~wanted),
-                                            ceph_cap_string(wanted));
-                                       cap->mds_wanted &= wanted;
-                               }
+                               cap->mds_wanted = wanted;
                        } else {
                                dout("encode_inode_release %p cap %p %s"
                                     " (force)\n", inode, cap,