From: Thomas Bellman <bellman@nsc.liu.se>
To: Olaf van der Spek <olafvdspek@gmail.com>
Cc: Massimo Maggi <massimo@mmmm.it>,
linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: Atomic file data replace API
Date: Sat, 08 Jan 2011 22:43:03 +0100 [thread overview]
Message-ID: <4D28DA67.6060404@nsc.liu.se> (raw)
In-Reply-To: <AANLkTin4BTH-1CfNtEt8CTspGJ9vJ_9mokP4hBM7c0Dw@mail.gmail.com>
Olaf van der Spek wrote:
> On Fri, Jan 7, 2011 at 8:29 PM, Thomas Bellman <bellman@nsc.liu.se> wrote:
>> What is the visibility of the changes for other processes supposed
>> to be in the meantime? I.e., if things happen in this order:
>
> Should be atomic too, at close time.
>
>> 1. Process A does fda = open("foo.txt", O_TRUNC|O_ATOMIC)
>> 2. Process B does fdb = open("foo.txt", O_RDONLY)
>> 3. B does read(fdb, buf, 4096)
>> 4. A does write(fda, "NEW DATA\n", 9)
>> 5. Process C comes in and does fdc = open("foo.txt", O_RDONLY)
>> 6. C does read(fdc, buf, 4096)
>> 7. A calls close(fda)
>>
>> Does B see an empty file, or does it see the old contents of
>> the file?
>
> Old file, otherwise A wouldn't be atomic.
>
>> Does C see "NEW DATA\n", or does it see the old
>> contents of the file, or perhaps an empty file?
>
> Old file again, as the 'transaction' isn't finished until close.
So, basically database transactions with an isolation level of
"committed read", for file operations. That's something I have
wanted for a long time, especially if I also get a rollback()
operation, but have never heard of any Unix that implemented it.
A separate commit() operation would be better than conflating it
with close(). And as I said, we want a rollback() as well. And
a process that terminates without committing the transaction that
it is performing, should have the transaction automatically rolled
back.
I only have a very shallow knowledge about the internals of the
Linux kernel in regards to filesystems, but I suspect that this
could be implemented almost entirely within the VFS, and not need
to touch the actual filesystems, as long as you are satisfied
with a limited amount of transaction space (what fits in RAM +
swap).
I'm looking forward to your implementation. :-) Even though I
suspect that it would be a rather large undertaking to implement...
/Bellman
next prev parent reply other threads:[~2011-01-08 21:43 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-06 20:01 Atomic file data replace API Olaf van der Spek
2011-01-07 13:55 ` Mike Fleetwood
2011-01-07 14:01 ` Olaf van der Spek
2011-01-07 14:10 ` Olaf van der Spek
2011-01-07 14:58 ` Chris Mason
2011-01-07 15:01 ` Olaf van der Spek
2011-01-07 15:05 ` Chris Mason
2011-01-07 15:08 ` Olaf van der Spek
2011-01-07 15:13 ` Chris Mason
2011-01-07 15:17 ` Olaf van der Spek
2011-01-07 16:12 ` Chris Mason
2011-01-07 16:19 ` Olaf van der Spek
2011-01-07 16:26 ` Hubert Kario
2011-01-07 19:29 ` Chris Mason
2011-01-08 14:40 ` Olaf van der Spek
2011-01-26 18:30 ` Olaf van der Spek
2011-01-26 19:30 ` Chris Mason
2011-01-26 21:56 ` Olaf van der Spek
2011-01-07 16:32 ` Massimo Maggi
2011-01-07 16:34 ` Olaf van der Spek
2011-01-07 19:29 ` Thomas Bellman
2011-01-08 14:36 ` Olaf van der Spek
2011-01-08 21:43 ` Thomas Bellman [this message]
2011-01-09 15:16 ` Olaf van der Spek
2011-01-09 18:56 ` Thomas Bellman
2011-01-09 19:06 ` Olaf van der Spek
2011-01-09 20:13 ` Phillip Susi
2011-01-08 1:11 ` Phillip Susi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D28DA67.6060404@nsc.liu.se \
--to=bellman@nsc.liu.se \
--cc=linux-btrfs@vger.kernel.org \
--cc=massimo@mmmm.it \
--cc=olafvdspek@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).