linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* "Appending" data to the middle of a file using btrfs-specific features
@ 2010-12-06 12:41 Nirbheek Chauhan
  2010-12-06 16:05 ` Chris Mason
       [not found] ` <4CFE0A81.9040102@electric-spoon.com>
  0 siblings, 2 replies; 10+ messages in thread
From: Nirbheek Chauhan @ 2010-12-06 12:41 UTC (permalink / raw)
  To: linux-btrfs

Hello,

I'd like to know if there has been any discussion about adding a new
feature to write (add) data at an offset, but without overwriting
existing data, or re-writing the existing data. Essentially, in-place
addition/removal of data to a file at a place other than the end of
the file.

Some possible use-cases of such a feature would be:

(a) Databases (currently hack around this by allocating sparse files)
(b) Delta-patching (rsync, patch, xdelta, etc)
(c) Video editors (especially if combined with reflink copies)

Besides I/O savings, it would also have significant space savings if
the current subvolume being written to has been snapshotted (a common
use-case for incremental backups).

I've been told that the problem is somewhat difficult to solve
properly under block-based representation of data, but I was hoping
that btrfs' reflink mechanism and its space-efficient packing of small
files might make it doable.

A hack I can think of is to do a BTRFS_IOC_CLONE_RANGE into a new file
(upto the offset), writing whatever data is required, and then doing
another BTRFS_IOC_CLONE_RANGE with an offset for the rest of the
original file. This can be followed by a rename() over the original
file. Similarly for removing data from the middle of a file. Would
this work? Would it be cleaner to implement something equivalent
internally?

Thanks!

-- 
~Nirbheek Chauhan

Gentoo GNOME+Mozilla Team

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-12-07 11:29 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-06 12:41 "Appending" data to the middle of a file using btrfs-specific features Nirbheek Chauhan
2010-12-06 16:05 ` Chris Mason
2010-12-06 19:14   ` Nirbheek Chauhan
2010-12-06 19:33     ` Chris Mason
2010-12-06 19:35     ` Freddie Cash
2010-12-06 20:30       ` Nirbheek Chauhan
2010-12-06 20:42         ` Freddie Cash
2010-12-07  7:38           ` Nirbheek Chauhan
2010-12-07  7:50   ` Andrey Kuzmin
     [not found] ` <4CFE0A81.9040102@electric-spoon.com>
2010-12-07 11:29   ` Nirbheek Chauhan

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).