public inbox for linux-api@vger.kernel.org
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: Nikolay Borisov <nborisov@suse.com>,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com,
	linux-fsdevel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-api@vger.kernel.org, Qu Wenruo <wqu@suse.com>
Subject: Re: [PATCH v10 06/14] btrfs: optionally extend i_size in cow_file_range_inline()
Date: Mon, 23 Aug 2021 16:46:08 -0700	[thread overview]
Message-ID: <YSQzQNMLy3qOY9VW@relinquished.localdomain> (raw)
In-Reply-To: <5a35da37-1504-361a-46bc-3fe1c1846871@gmx.com>

On Tue, Aug 24, 2021 at 07:32:06AM +0800, Qu Wenruo wrote:
> 
> 
> On 2021/8/24 上午2:16, Omar Sandoval wrote:
> > On Sat, Aug 21, 2021 at 09:11:26AM +0800, Qu Wenruo wrote:
> > > 
> > > 
> > > On 2021/8/21 上午2:11, Omar Sandoval wrote:
> > > > On Fri, Aug 20, 2021 at 05:13:34PM +0800, Qu Wenruo wrote:
> > > > > 
> > > > > 
> > > > > On 2021/8/20 下午4:51, Nikolay Borisov wrote:
> > > > > > 
> > > > > > 
> > > > > > On 18.08.21 г. 0:06, Omar Sandoval wrote:
> > > > > > > From: Omar Sandoval <osandov@fb.com>
> > > > > > > 
> > > > > > > Currently, an inline extent is always created after i_size is extended
> > > > > > > from btrfs_dirty_pages(). However, for encoded writes, we only want to
> > > > > > > update i_size after we successfully created the inline extent.
> > > > > 
> > > > > To me, the idea of write first then update isize is just going to cause
> > > > > tons of inline extent related prblems.
> > > > > 
> > > > > The current example is falloc, which only update the isize after the
> > > > > falloc finishes.
> > > > > 
> > > > > This behavior has already bothered me quite a lot, as it can easily
> > > > > create mixed inline and regular extents.
> > > > 
> > > > Do you have an example of how this would happen? I have the inode and
> > > > extent bits locked during an encoded write, and I see that fallocate
> > > > does the same.
> > > 
> > > xfs_io -f -c "pwrite 0 1K" -c "sync" -c "falloc 0 4k" -c "pwrite 4k 4k"
> > > 
> > > The [0, 1K) will be written as inline without doubt.
> > > 
> > > Then we go to falloc, it will try to zero the range [1K, 4K), but it
> > > doesn't increase the isize.
> > > Thus the page [0, 4k) will still be written back as inline, since isize
> > > is still 1K.
> > > 
> > > Later [4K, 8K) will be written back as regular, causing mixed extents.
> > 
> > I'll have to read fallocate more closely to follow what's going on here
> > and figure out if it applies to encoded writes. Please help me out if
> > you see how this would be an issue with encoded writes.
> 
> This won't cause anything wrong, if the encoded writes follows the
> existing inline extents requirement (always at offset 0).
> 
> Otherwise, the read path could be affected to handle inlined extent at
> non-zero offset.
> 
> > 
> > > > > Can't we remember the old isize (with proper locking), enlarge isize
> > > > > (with holes filled), do the write.
> > > > > 
> > > > > If something wrong happened, we truncate the isize back to its old isize.
> > > > > 
> > > [...]
> > > > > > 
> > > > > > Urgh, just some days ago Qu was talking about how awkward it is to have
> > > > > > mixed extents in a file. And now, AFAIU, you are making them more likely
> > > > > > since now they can be created not just at the beginning of the file but
> > > > > > also after i_size write. While this won't be a problem in and of itself
> > > > > > it goes just the opposite way of us trying to shrink the possible cases
> > > > > > when we can have mixed extents.
> > > > > 
> > > > > Tree-checker should reject such inline extent at non-zero offset.
> > > > 
> > > > This change does not allow creating inline extents at a non-zero offset.
> > > > 
> > > > > > Qu what is your take on that?
> > > > > 
> > > > > My question is, why encoded write needs to bother the inline extents at all?
> > > > > 
> > > > > My intuition of such encoded write is, it should not create inline
> > > > > extents at all.
> > > > > 
> > > > > Or is there any special use-case involved for encoded write?
> > > > 
> > > > We create compressed inline extents with normal writes. We should be
> > > > able to send and receive them without converting them into regular
> > > > extents.
> > > > 
> > > But my first impression for any encoded write is that, they should work
> > > like DIO, thus everything should be sectorsize aligned.
> > > 
> > > Then why could they create inline extent? As inline extent can only be
> > > possible when the isize is smaller than sectorsize.
> > 
> > ENCODED_WRITE is not defined as "O_DIRECT, but encoded". It happens to
> > have some resemblance to O_DIRECT because we have alignment requirements
> > for new extents and because we bypass the page cache, but there's no
> > reason to copy arbitrary restrictions from O_DIRECT. If someone is using
> > ENCODED_WRITE to write compressed data, then they care about space
> > efficiency, so we should make efficient use of inline extents.
> > 
> Then as long as the inline extent requirement for 0 offset is still
> followed, I'll be fine with that.
> 
> But for non-zero offset inline extent? It looks like a much larger
> change, and may affect read path.
> 
> So I'd prefer we keep the 0 offset requirement for inline extent, and
> find a better way to work around.

Ah, okay. I didn't get rid of the 0 offset requirement and I have no
plans to. In fact, this patch kind of does the opposite: it gets rid of
the start parameter to cow_file_range_inline() because it doesn't make
sense for it to ever be anything other than 0 (and we're already
checking that start == 0 in the callers).

  reply	other threads:[~2021-08-23 23:46 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17 21:06 [PATCH v10 00/14] btrfs: add ioctls and send/receive support for reading/writing compressed data Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 01/14] fs: export rw_verify_area() Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 02/14] fs: export variant of generic_write_checks without iov_iter Omar Sandoval
2021-08-20  7:59   ` Nikolay Borisov
2021-08-20 17:31     ` Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 03/14] btrfs: don't advance offset for compressed bios in btrfs_csum_one_bio() Omar Sandoval
2021-08-20  8:08   ` Nikolay Borisov
2021-08-20 17:37     ` Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 04/14] btrfs: add ram_bytes and offset to btrfs_ordered_extent Omar Sandoval
2021-08-20  8:34   ` Nikolay Borisov
2021-08-20 17:43     ` Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 05/14] btrfs: support different disk extent size for delalloc Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 06/14] btrfs: optionally extend i_size in cow_file_range_inline() Omar Sandoval
2021-08-20  8:51   ` Nikolay Borisov
2021-08-20  9:13     ` Qu Wenruo
2021-08-20 18:11       ` Omar Sandoval
2021-08-21  1:11         ` Qu Wenruo
2021-08-23 18:16           ` Omar Sandoval
2021-08-23 23:32             ` Qu Wenruo
2021-08-23 23:46               ` Omar Sandoval [this message]
2021-08-17 21:06 ` [PATCH v10 07/14] btrfs: add definitions + documentation for encoded I/O ioctls Omar Sandoval
2021-08-20  8:56   ` Nikolay Borisov
2021-08-20 17:48     ` Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 08/14] btrfs: add BTRFS_IOC_ENCODED_READ Omar Sandoval
2021-08-20 12:30   ` Nikolay Borisov
2021-08-20 17:58     ` Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 09/14] btrfs: add BTRFS_IOC_ENCODED_WRITE Omar Sandoval
2021-08-20 13:44   ` Nikolay Borisov
2021-08-20 17:59     ` Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 10/14] btrfs: add send stream v2 definitions Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 11/14] btrfs: send: write larger chunks when using stream v2 Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 12/14] btrfs: send: allocate send buffer with alloc_page() and vmap() for v2 Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 13/14] btrfs: send: send compressed extents with encoded writes Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 14/14] btrfs: send: enable support for stream v2 and compressed writes Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 01/10] btrfs-progs: receive: support v2 send stream larger tlv_len Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 02/10] btrfs-progs: receive: dynamically allocate sctx->read_buf Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 03/10] btrfs-progs: receive: support v2 send stream DATA tlv format Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 04/10] btrfs-progs: receive: add send stream v2 cmds and attrs to send.h Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 05/10] btrfs-progs: receive: process encoded_write commands Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 06/10] btrfs-progs: receive: encoded_write fallback to explicit decode and write Omar Sandoval
2021-08-18 18:07   ` Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 07/10] btrfs-progs: receive: process fallocate commands Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 08/10] btrfs-progs: receive: process setflags ioctl commands Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 09/10] btrfs-progs: send: stream v2 ioctl flags Omar Sandoval
2021-08-17 21:06 ` [PATCH v10 10/10] btrfs-progs: receive: add tests for basic encoded_write send/receive Omar Sandoval

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=YSQzQNMLy3qOY9VW@relinquished.localdomain \
    --to=osandov@osandov.com \
    --cc=kernel-team@fb.com \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=nborisov@suse.com \
    --cc=quwenruo.btrfs@gmx.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=wqu@suse.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