Re: mkdir race condition

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

 



Emmanuel Dreyfus <manu@xxxxxxxxxx> 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@xxxxxxxxxx



[Index of Archives]     [Gluster Users]     [Ceph Users]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux