linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@clusterfs.com>
To: Jan Kara <jack@suse.cz>
Cc: linux-fsdevel@vger.kernel.org, linux-ext4 <linux-ext4@vger.kernel.org>
Subject: Re: [RFC] System calls for online defrag
Date: Tue, 4 Sep 2007 12:01:53 -0600	[thread overview]
Message-ID: <20070904180153.GF5377@schatzie.adilger.int> (raw)
In-Reply-To: <20070903180329.GK7524@duck.suse.cz>

On Sep 03, 2007  20:03 +0200, Jan Kara wrote:
>   I've finally got to writing up some proposal how could look system calls
> allowing for online filesystem defragmentation and generally moving file
> blocks around for improving performance. Comments are welcome.
> 
> int sys_movedata(int datafd, int spacefd, loff_t from, size_t len)
>    The call takes blocks used to carry data starting at offset @from of length
> @len in @spacefd and places them instead of corresponding blocks in @datafd.

Calling these "@spacefd" and "@datafd" is a bit confusing.  How about "@srcfd"
and "@tgtfd" instead?  For defragmentation, are you planning to have @datafd
be the "real" inode and "@spacefd" be the temporary inode with defragged data,
or the reverse?  It isn't really clear.

> Data is copied from @datafd to newly spliced data blocks. If @spacefd contains
> a hole in the specified interval, a hole is created also in @datafd in the
> corresponding place. A data block from @spacefd and also replace a hole in
> @datafd - zeros are copied to such data block. @from and @len should be
> multiples of filesystem block size (otherwise EINVAL is returned). Data blocks
> from @datafd in the interval are released, a hole is created in @spacefd.

This is mostly clear except the last sentence.  I would think that the data
blocks in @datafd are kept, getting a copy of the data, while those in
@spacefd are released?

>   Another possibility would be to just replace data blocks without any copying
> of data (that would have to be done by the caller to before calling
> sys_movedata()). The problem here is how to avoid data loss if someone writes
> to the file after userspace has copied the data and before sys_movedata() is
> called.

Isn't that true in any case?

> ssize_t sys_allocate(int fd, int mode, loff_t goal, ssize_t len)
>   Allocate new space to file @fd at offset defined by file position.  Both file
> offset and @len should be a multiple of filesystem block size. The whole
> interval must not contain any allocated blocks. If the interval extends past
> EOF, the file size is changed accordingly.  @mode defines a way the filesystem
> will search for blocks. @mode is a bitwise OR of the following flags:
>   ALLOC_FIXED_START - allocation must start at @goal; if not specified, @goal
> is just a hint where to start an allocation
>   ALLOC_FIXED_LEN - allocate exactly space for @len; if not specified, upto
> @len bytes may be allocated.
>   ALLOC_CONTINGUOUS - allocation must be one continguous run of blocks

How is this much different than sys_fallocate()?

> int sys_get_free_blocks(const char *fs, loff_t start, loff_t end, int count,
>   struct alloc_extent *space)

One alternate possibility is to call the proposed FIEMAP on the block device,
to return lists of free/used extents?  We have a version of that patch for
ext4 and integration into filefrag, so it would be nice to avoid making up
yet another API/tool if that one is sufficient.

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.


  reply	other threads:[~2007-09-04 18:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-03 18:03 [RFC] System calls for online defrag Jan Kara
2007-09-04 18:01 ` Andreas Dilger [this message]
2007-09-05 14:24   ` Jan Kara

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=20070904180153.GF5377@schatzie.adilger.int \
    --to=adilger@clusterfs.com \
    --cc=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    /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).