Re: [PATCH v2] sha1_file.c:create_tmpfile(): Fix race when creating loose object dirs

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

 



On Wed, Oct 30, 2013 at 05:19:27AM -0400, Jeff King wrote:

> > To achieve this, I guess we have to follow the same procedure we do for
> > loose object creation:
> > 
> >  1. Create a temporary directory with a unique name (mkdtemp?)
> > 
> >  2. Adjust permissions
> > 
> >  3. Rename into place
> > 
> > Can this be done sufficiently atomically across all platforms?
> 
> Yeah, I think that is the only way to do it. I do not know offhand of
> any platforms that have problems with atomic directory renames, though I
> would not be surprised if some network filesystems don't handle it well.

Actually, thinking on this more, we do not want "rename into place"
semantics, as that usually implies overwrite. We would prefer a
hard-link solution, where only one linker "wins", and the other gets
EEXIST. But you cannot hard-link directories.

POSIX does specify that rename() should return EEXIST rather than
overwriting if the destination directory exists and is not empty. So
in theory that would work, as we would then just be racing against the
other process creating the actual object (and either we replace the
directory with ours before they write the object, or they write the
object first and we get EEXIST).

But I don't know how well that is followed in the real world.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]