From 6d80995a1b494bb6570d23cf08ae404d9ec0a58b Mon Sep 17 00:00:00 2001 From: Gui Hecheng Date: Thu, 25 May 2017 14:53:09 +0800 Subject: [PATCH] rgw_file: fix double lock on unlink bucket When stat_buckets with FLAG_LOCKED, we would not want to lock_guard again to protect time attrs. Signed-off-by: Gui Hecheng --- src/rgw/rgw_file.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 6f211e77dac..6e0142c8bab 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -84,7 +84,9 @@ namespace rgw { RGWFileHandle::FLAG_BUCKET); if (get<0>(fhr)) { RGWFileHandle* rgw_fh = get<0>(fhr); - lock_guard guard(rgw_fh->mtx); + if (! (flags & RGWFileHandle::FLAG_LOCKED)) { + rgw_fh->mtx.lock(); + } rgw_fh->set_times(req.get_ctime()); /* restore attributes */ auto ux_key = req.get_attr(RGW_ATTR_UNIX_KEY1); @@ -92,6 +94,9 @@ namespace rgw { if (ux_key && ux_attrs) { rgw_fh->decode_attrs(ux_key, ux_attrs); } + if (! (flags & RGWFileHandle::FLAG_LOCKED)) { + rgw_fh->mtx.unlock(); + } } } return fhr; -- 2.47.3