* atomically swap two files
@ 2010-11-25 20:11 Frank A. Kingswood
2010-11-26 11:47 ` Pádraig Brady
0 siblings, 1 reply; 3+ messages in thread
From: Frank A. Kingswood @ 2010-11-25 20:11 UTC (permalink / raw)
To: linux-kernel
Hi!
Is it possible to swap two files in an atomic way, so that after the
syscall either the two files have exchanged names or neither has been
modified?
I suspect that btrfs could do it, but I'm wondering about ext3/4.
Frank
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: atomically swap two files
2010-11-25 20:11 atomically swap two files Frank A. Kingswood
@ 2010-11-26 11:47 ` Pádraig Brady
2010-11-26 14:19 ` Dave Chinner
0 siblings, 1 reply; 3+ messages in thread
From: Pádraig Brady @ 2010-11-26 11:47 UTC (permalink / raw)
To: Frank A. Kingswood; +Cc: linux-kernel
On 25/11/10 20:11, Frank A. Kingswood wrote:
> Hi!
>
> Is it possible to swap two files in an atomic way, so that after the
> syscall either the two files have exchanged names or neither has been
> modified?
>
> I suspect that btrfs could do it, but I'm wondering about ext3/4.
I don't think there is anything equivalent to exchangedata() on Linux
http://developer.apple.com/library/mac/#DOCUMENTATION/Darwin/Reference/ManPages/man2/exchangedata.2.html
I've written some notes on atomically replacing
file contents with standard tools here:
http://www.pixelbeat.org/docs/unix_file_replacement.html
cheers,
Pádraig.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: atomically swap two files
2010-11-26 11:47 ` Pádraig Brady
@ 2010-11-26 14:19 ` Dave Chinner
0 siblings, 0 replies; 3+ messages in thread
From: Dave Chinner @ 2010-11-26 14:19 UTC (permalink / raw)
To: Pádraig Brady; +Cc: Frank A. Kingswood, linux-kernel
On Fri, Nov 26, 2010 at 11:47:52AM +0000, Pádraig Brady wrote:
> On 25/11/10 20:11, Frank A. Kingswood wrote:
> > Hi!
> >
> > Is it possible to swap two files in an atomic way, so that after the
> > syscall either the two files have exchanged names or neither has been
> > modified?
> >
> > I suspect that btrfs could do it, but I'm wondering about ext3/4.
>
> I don't think there is anything equivalent to exchangedata() on Linux
> http://developer.apple.com/library/mac/#DOCUMENTATION/Darwin/Reference/ManPages/man2/exchangedata.2.html
XFS can do that, though the interface is an ioctl (XFS_IOC_SWAPEXT)
whose parameters are closely tied to the functionality of the only
user: the online defragmenter (xfs_fsr). It would be pretty easy to
wire it up to such a syscall if one existed, though....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-11-26 14:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-25 20:11 atomically swap two files Frank A. Kingswood
2010-11-26 11:47 ` Pádraig Brady
2010-11-26 14:19 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).