]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: release rgw_fh lock and ref on ENOTEMPTY 15246/head
authorMatt Benjamin <mbenjamin@redhat.com>
Tue, 23 May 2017 19:05:45 +0000 (15:05 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Tue, 23 May 2017 19:44:59 +0000 (15:44 -0400)
An early return in new unlink bucket num_entries check was
missing a conditional unlock and unref.

Fixes: http://tracker.ceph.com/issues/20061
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_file.cc

index dd6c1e8ed8f76a339ae3b21e0d3cf4fd58297753..cd497480f47440f06cab5b38db23e378c4685f4a 100644 (file)
@@ -273,7 +273,9 @@ namespace rgw {
       /* a bucket may have an object storing Unix attributes, check
        * for and delete it */
       LookupFHResult fhr;
-      fhr = stat_bucket(parent, name, bs, RGWFileHandle::FLAG_LOCKED);
+      fhr = stat_bucket(parent, name, bs, (rgw_fh) ?
+                       RGWFileHandle::FLAG_LOCKED :
+                       RGWFileHandle::FLAG_NONE);
       bkt_fh = get<0>(fhr);
       if (unlikely(! bkt_fh)) {
        /* implies !rgw_fh, so also !LOCKED */
@@ -281,7 +283,14 @@ namespace rgw {
       }
 
       if (bs.num_entries > 1) {
-       unref(bkt_fh); /* return extra ref */
+       unref(bkt_fh); /* return stat_bucket ref */
+       if (likely(!! rgw_fh)) { /* return lock and ref from
+                                 * lookup_fh (or caller in the
+                                 * special case of
+                                 * RGWFileHandle::FLAG_UNLINK_THIS) */
+         rgw_fh->mtx.unlock();
+         unref(rgw_fh);
+       }
        return -ENOTEMPTY;
       } else {
        /* delete object w/key "<bucket>/" (uxattrs), if any */