[Gluster-devel] mkdir race condition

Emmanuel Dreyfus manu at netbsd.org
Sun May 20 08:30:53 UTC 2012


Emmanuel Dreyfus <manu at netbsd.org> wrote:

> It seems posix_handle_mkdir_hashes() attempts to mkdir two directories
> at once: ec/ec2. How is it supposed to work? Should parent directory be
> created somewhere else?

This fixes the problem. Any comment?

--- xlators/storage/posix/src/posix-handle.c.orig
+++ xlators/storage/posix/src/posix-handle.c
@@ -405,8 +405,16 @@
         parpath = dirname (duppath);
         parpath = dirname (duppath);
 
         ret = mkdir (parpath, 0700);
+       if (ret == -1 && errno == ENOENT) {
+               char *tmppath = NULL;
+
+               tmppath = strdupa(parpath);
+               ret = mkdir (dirname (tmppath), 0700);
+               if (ret == 0)
+                       ret = mkdir (parpath, 0700);
+       }
         if (ret == -1 && errno != EEXIST) {
                 gf_log (this->name, GF_LOG_ERROR,
                         "error mkdir hash-1 %s (%s)",
                         parpath, strerror (errno));
-- 
Emmanuel Dreyfus
http://hcpnet.free.fr/pubz
manu at netbsd.org




More information about the Gluster-devel mailing list