gluster-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gluster-devel] mkdir race condition


From: Emmanuel Dreyfus
Subject: Re: [Gluster-devel] mkdir race condition
Date: Sun, 20 May 2012 10:30:53 +0200
User-agent: MacSOUP/2.7 (unregistered for 1947 days)

Emmanuel Dreyfus <address@hidden> 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
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]