Rich Freeman on 27 Feb 2012 17:57:57 -0800


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

Re: [PLUG] VI without a swapfile?


On Mon, Feb 27, 2012 at 8:02 PM, Jeff Bailey <skydiver38@verizon.net> wrote:
> I've done some googling (and will do more), but does anyone know anything
> about preventing vi from creating a duplicate file (editing in place, or
> whatever you want to call it).

I suspect this is because on most sane filesystems if you save the
changes to a new fine, then move it over the old one, you end up with
an atomic operation (either you end up with the old file intact, or
the new file intact, and in the former case sometimes with a junk file
as well).  If you overwrite a file in place most filesystems do not
handle that atomically and you could destroy the previous copy and
only end up with a partial file, or no file at all.

I'd have to re-read the threads but I believe there is some debate
among filesystem purists about whether that is in fact sane or not,
how fsync fits into all of this, and some other nuances of
applications having to work around filesystem quirks.  Read up on the
big ext3 ordered data debate from a few years ago.

Personally I think Linux should just have some kind of safe atomic
write call so that application writers can just invoke it and let the
kernel worry about how it should be implemented (moves, fsyncs,
copy-on-write-with-transactions, or whatever).  The last thing I want
is every application invoking fsync left and right in hopes of working
around quirks, and killing my cache performance.

Rich
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug