From 51c25593dd741b4df2e839fcef82b143f8c8cfca Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Tue, 23 May 2017 15:05:45 -0400 Subject: [PATCH] rgw_file: release rgw_fh lock and ref on ENOTEMPTY 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 --- src/rgw/rgw_file.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index dd6c1e8ed8f..cd497480f47 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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 "/" (uxattrs), if any */