Discussion:
[developer] Implementing atomic swap as extension to renameat()?
Irek Szczesniak
2013-12-16 11:08:56 UTC
Permalink
How hard would it be to implement an atomic swap operation of two file
names, for example in ZFS and UFS?

Irek


-------------------------------------------
illumos-developer
Archives: https://www.listbox.com/member/archive/182179/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182179/21175072-86d49504
Modify Your Subscription: https://www.listbox.com/member/?member_id=21175072&id_secret=21175072-abdf7b7e
Powered by Listbox: http://www.listbox.com
Michael Schuster
2013-12-16 11:11:05 UTC
Permalink
Hi Irek,

for my understanding: what is the use case for such an operation?

TIA
Michael
Post by Irek Szczesniak
How hard would it be to implement an atomic swap operation of two file
names, for example in ZFS and UFS?
Irek
-------------------------------------------
illumos-developer
Archives: https://www.listbox.com/member/archive/182179/=now
https://www.listbox.com/member/archive/rss/182179/21175194-5367c2f3
https://www.listbox.com/member/?&
Powered by Listbox: http://www.listbox.com
--
Michael Schuster
http://recursiveramblings.wordpress.com/



-------------------------------------------
illumos-developer
Archives: https://www.listbox.com/member/archive/182179/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182179/21175072-86d49504
Modify Your Subscription: https://www.listbox.com/member/?member_id=21175072&id_secret=21175072-abdf7b7e
Powered by Listbox: http://www.listbox.com
Irek Szczesniak
2013-12-16 11:19:13 UTC
Permalink
On Mon, Dec 16, 2013 at 12:11 PM, Michael Schuster
Post by Michael Schuster
Hi Irek,
for my understanding: what is the use case for such an operation?
Swap two directories (or files) without the need for an intermediate
temporary name or the risk that someone else can interfere with the
operation.

Irek
Post by Michael Schuster
TIA
Michael
Post by Irek Szczesniak
How hard would it be to implement an atomic swap operation of two file
names, for example in ZFS and UFS?
Irek
-------------------------------------------
illumos-developer
Archives: https://www.listbox.com/member/archive/182179/=now
https://www.listbox.com/member/archive/rss/182179/21175194-5367c2f3
https://www.listbox.com/member/?&
Powered by Listbox: http://www.listbox.com
--
Michael Schuster
http://recursiveramblings.wordpress.com/
--
Irek


-------------------------------------------
illumos-developer
Archives: https://www.listbox.com/member/archive/182179/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182179/21175072-86d49504
Modify Your Subscription: https://www.listbox.com/member/?member_id=21175072&id_secret=21175072-abdf7b7e
Powered by Listbox: http://www.listbox.com
Michael Schuster
2013-12-16 11:24:03 UTC
Permalink
Hi,
Post by Irek Szczesniak
On Mon, Dec 16, 2013 at 12:11 PM, Michael Schuster
Post by Michael Schuster
Hi Irek,
for my understanding: what is the use case for such an operation?
Swap two directories (or files) without the need for an intermediate
temporary name or the risk that someone else can interfere with the
operation.
that's the obvious application ... but in what real-life situation would
you want to do that? Note: I don't want to disparage the idea, I'd just
like to understand the situation you want to address.

regards
Michael
--
Michael Schuster
http://recursiveramblings.wordpress.com/



-------------------------------------------
illumos-developer
Archives: https://www.listbox.com/member/archive/182179/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182179/21175072-86d49504
Modify Your Subscription: https://www.listbox.com/member/?member_id=21175072&id_secret=21175072-abdf7b7e
Powered by Listbox: http://www.listbox.com
Irek Szczesniak
2013-12-16 13:21:37 UTC
Permalink
On Mon, Dec 16, 2013 at 12:24 PM, Michael Schuster
Hi,
Post by Irek Szczesniak
On Mon, Dec 16, 2013 at 12:11 PM, Michael Schuster
Post by Michael Schuster
Hi Irek,
for my understanding: what is the use case for such an operation?
Swap two directories (or files) without the need for an intermediate
temporary name or the risk that someone else can interfere with the
operation.
that's the obvious application ... but in what real-life situation would you
want to do that? Note: I don't want to disparage the idea, I'd just like to
understand the situation you want to address.
One of the *possible* applications would be to replace per-directory
locks (implemented via mkdir for portability) in a distributed system
where there is one input queue (a directory) and multiple workers. The
basic concept is that if a worker is ready it creates an empty
directory and swaps it with the queue directory (tasks are queued by
mv'ing them into the queue directory, so this is atomic, too), works
on the queue, deletes the empty directory and then becomes 'ready'
again.

Damn posix people forgot to give renameat() a flags field. Bummer ;(

Irek


-------------------------------------------
illumos-developer
Archives: https://www.listbox.com/member/archive/182179/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182179/21175072-86d49504
Modify Your Subscription: https://www.listbox.com/member/?member_id=21175072&id_secret=21175072-abdf7b7e
Powered by Listbox: http://www.listbox.com

Loading...