linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kirill Tkhai <ktkhai@virtuozzo.com>
To: Andreas Dilger <adilger@dilger.ca>
Cc: "Theodore Y. Ts'o" <tytso@mit.edu>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Mike Snitzer <snitzer@redhat.com>, Jan Kara <jack@suse.cz>,
	Eric Biggers <ebiggers@google.com>,
	riteshh@linux.ibm.com, krisman@collabora.com, surajjs@amazon.com,
	Dmitry Monakhov <dmonakhov@gmail.com>,
	mbobrowski@mbobrowski.org, Eric Whitney <enwlinux@gmail.com>,
	sblbir@amazon.com, Khazhismel Kumykov <khazhy@google.com>,
	linux-ext4 <linux-ext4@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux FS Devel <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH RFC 0/5] fs, ext4: Physical blocks placement hint for fallocate(0): fallocate2(). TP defrag.
Date: Wed, 11 Mar 2020 23:29:13 +0300	[thread overview]
Message-ID: <46c1ed68-ba2f-5738-1257-8fd1b6b87023@virtuozzo.com> (raw)
In-Reply-To: <C4175F35-E9D4-4B79-B1A0-047A51DE3287@dilger.ca>

On 11.03.2020 22:26, Andreas Dilger wrote:
> On Mar 3, 2020, at 2:57 AM, Kirill Tkhai <ktkhai@virtuozzo.com> wrote:
>>
>> On 02.03.2020 19:56, Theodore Y. Ts'o wrote:
>>> Kirill,
>>>
>>> In a couple of your comments on this patch series, you mentioned
>>> "defragmentation".  Is that because you're trying to use this as part
>>> of e4defrag, or at least, using EXT4_IOC_MOVE_EXT?
>>>
>>> If that's the case, you should note that input parameter for that
>>> ioctl is:
>>>
>>> struct move_extent {
>>> 	__u32 reserved;		/* should be zero */
>>> 	__u32 donor_fd;		/* donor file descriptor */
>>> 	__u64 orig_start;	/* logical start offset in block for orig */
>>> 	__u64 donor_start;	/* logical start offset in block for donor */
>>> 	__u64 len;		/* block length to be moved */
>>> 	__u64 moved_len;	/* moved block length */
>>> };
>>>
>>> Note that the donor_start is separate from the start of the file that
>>> is being defragged.  So you could have the userspace application
>>> fallocate a large chunk of space for that donor file, and then use
>>> that donor file to defrag multiple files if you want to close pack
>>> them.
>>
>> The practice shows it's not so. Your suggestion was the first thing we tried,
>> but it works bad and just doubles/triples IO.
>>
>> Let we have two files of 512Kb, and they are placed in separate 1Mb clusters:
>>
>> [[512Kb file][512Kb free]][[512Kb file][512Kb free]]
>>
>> We want to pack both of files in the same 1Mb cluster. Packed together on block
>> device, they will be in the same server of underlining distributed storage file
>> system. This gives a big performance improvement, and this is the price I aimed.
>>
>> In case of I fallocate a large hunk for both of them, I have to move them
>> both to this new hunk. So, instead of moving 512Kb of data, we will have to move
>> 1Mb of data, i.e. double size, which is counterproductive.
>>
>> Imaging another situation, when we have
>> [[1020Kb file]][4Kb free]][[4Kb file][1020Kb free]]
>>
>> Here we may just move [4Kb file] into [4Kb free]. But your suggestion again
>> forces us to move 1Mb instead of 4Kb, which makes IO 256 times worse! This is
>> terrible! And this is the thing I try prevent with finding a new interface.
> 
> One idea I had, which may work for your use case, is to run fallocate() on
> the *1MB-4KB file* to allocate the last 4KB in that hunk, then use that block
> as the donor file for the 1MB+4KB file.  The ext4 allocation algorithms should
> always give you that 4KB chunk if it is free, and that avoids the need to try
> and force the allocator to select that block through some other method.

Do you mean the following:

1)fallocate() 4K at the end of *1MB-4KB* the first file (==> this increases the file length).
2)EXT4_IOC_MOVE_EXT *4KB* the second file in that new hunk.
3)truncate 4KB at the end of the first file.

?

If so, this can't be an online defrag, since some process may want to increase *1MB-4KB*
file in between. This will just bring to data corruption.
Another problem is that power lose between 1 and 3 will result in that file length remain
*1MB* instead of *1MB-4KB*.

So, we still need some kernel support to implement this.

  reply	other threads:[~2020-03-11 20:30 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 13:40 [PATCH RFC 0/5] fs, ext4: Physical blocks placement hint for fallocate(0): fallocate2(). TP defrag Kirill Tkhai
2020-02-26 13:40 ` [PATCH RFC 1/5] fs: Add new argument to file_operations::fallocate() Kirill Tkhai
2020-02-26 13:41 ` [PATCH RFC 2/5] fs: Add new argument to vfs_fallocate() Kirill Tkhai
2020-02-26 13:41 ` [PATCH RFC 3/5] fs: Add fallocate2() syscall Kirill Tkhai
2020-02-26 13:41 ` [PATCH RFC 4/5] ext4: Prepare ext4_mb_discard_preallocations() for handling EXT4_MB_HINT_GOAL_ONLY Kirill Tkhai
2020-02-26 13:41 ` [PATCH RFC 5/5] ext4: Add fallocate2() support Kirill Tkhai
2020-02-26 15:55   ` Christoph Hellwig
2020-02-26 20:05     ` Kirill Tkhai
2020-02-26 21:51       ` Andreas Dilger
2020-02-27 12:24         ` Kirill Tkhai
2020-02-28 15:35           ` Andreas Dilger
2020-02-28 21:16             ` Dave Chinner
2020-02-29 20:12               ` Andreas Dilger
2020-03-01  0:06                 ` Dave Chinner
2020-03-02 10:33               ` Kirill Tkhai
2020-03-02 11:07             ` Kirill Tkhai
2020-02-27  6:59       ` Konstantin Khlebnikov
2020-02-27 10:42         ` Kirill Tkhai
2020-02-27  7:33       ` Dave Chinner
2020-02-27 11:12         ` Kirill Tkhai
2020-02-27 21:56           ` Dave Chinner
2020-02-28 12:41             ` Kirill Tkhai
2020-02-29 22:41               ` Dave Chinner
2020-03-02 10:17                 ` Kirill Tkhai
2020-02-27 10:39 ` [PATCH RFC 0/5] fs, ext4: Physical blocks placement hint for fallocate(0): fallocate2(). TP defrag Ritesh Harjani
2020-02-28  7:07 ` xiaohui li
2020-02-28 12:46   ` Kirill Tkhai
2020-03-02 16:56 ` Theodore Y. Ts'o
2020-03-03  9:57   ` Kirill Tkhai
2020-03-03 16:55     ` Theodore Y. Ts'o
2020-03-03 17:36       ` Kirill Tkhai
2020-03-11 19:26     ` Andreas Dilger
2020-03-11 20:29       ` Kirill Tkhai [this message]
2020-03-12  0:31         ` Andreas Dilger
2020-03-12  9:23           ` Kirill Tkhai

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=46c1ed68-ba2f-5738-1257-8fd1b6b87023@virtuozzo.com \
    --to=ktkhai@virtuozzo.com \
    --cc=adilger@dilger.ca \
    --cc=dmonakhov@gmail.com \
    --cc=ebiggers@google.com \
    --cc=enwlinux@gmail.com \
    --cc=jack@suse.cz \
    --cc=khazhy@google.com \
    --cc=krisman@collabora.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbobrowski@mbobrowski.org \
    --cc=riteshh@linux.ibm.com \
    --cc=sblbir@amazon.com \
    --cc=snitzer@redhat.com \
    --cc=surajjs@amazon.com \
    --cc=tytso@mit.edu \
    --cc=viro@zeniv.linux.org.uk \
    /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).