]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file: prevent conflict of mkdir between restarts 15655/head
authorGui Hecheng <guihecheng@cmss.chinamobile.com>
Tue, 13 Jun 2017 06:39:14 +0000 (14:39 +0800)
committerGui Hecheng <guihecheng@cmss.chinamobile.com>
Tue, 13 Jun 2017 07:28:37 +0000 (15:28 +0800)
Fixes: http://tracker.ceph.com/issues/20275
Signed-off-by: Gui Hecheng <guihecheng@cmss.chinamobile.com>
src/rgw/rgw_file.cc

index da7b26b69ace68efba2b099c3b6a91f8666b91e1..e5032d0a5104a8221cf49848fb3b45622ab5568a 100644 (file)
@@ -486,9 +486,18 @@ namespace rgw {
   MkObjResult RGWLibFS::mkdir(RGWFileHandle* parent, const char *name,
                              struct stat *st, uint32_t mask, uint32_t flags)
   {
-    MkObjResult mkr{nullptr, -EINVAL};
     int rc, rc2;
+    rgw_file_handle *lfh;
 
+    rc = rgw_lookup(get_fs(), parent->get_fh(), name, &lfh,
+                   RGW_LOOKUP_FLAG_NONE);
+    if (! rc) {
+      /* conflict! */
+      rc = rgw_fh_rele(get_fs(), lfh, RGW_FH_RELE_FLAG_NONE);
+      return MkObjResult{nullptr, -EEXIST};
+    }
+
+    MkObjResult mkr{nullptr, -EINVAL};
     LookupFHResult fhr;
     RGWFileHandle* rgw_fh = nullptr;
     buffer::list ux_key, ux_attrs;