From: Filipe Manana <fdmanana@kernel.org>
To: Naohiro Aota <naohiro.aota@wdc.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/4] btrfs: extend btrfs_cleanup_ordered_extens for NULL locked_page
Date: Fri, 17 Jun 2022 11:15:15 +0100 [thread overview]
Message-ID: <20220617101515.GC4041436@falcondesktop> (raw)
In-Reply-To: <6de954aed27f8e5ebccd780bbc40ce37a6ddf4f1.1655391633.git.naohiro.aota@wdc.com>
On Fri, Jun 17, 2022 at 12:45:40AM +0900, Naohiro Aota wrote:
> btrfs_cleanup_ordered_extents() assumes locked_page to be non-NULL, so it
> is not usable for submit_uncompressed_range() which can habe NULL
> locked_page.
>
> This commit supports locked_page == NULL case. Also, it rewrites redundant
> "page_offset(locked_page)".
The patch looks fine, but I don't see any patch in the patchset that actually
makes submit_uncompressed_range() use btrfs_cleanup_ordered_extents().
Did you forgot that, or am I missing something?
Thanks.
>
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> ---
> fs/btrfs/inode.c | 36 +++++++++++++++++++++---------------
> 1 file changed, 21 insertions(+), 15 deletions(-)
>
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 0c3d9998470f..4e1100f84a88 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -195,11 +195,14 @@ static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode,
> {
> unsigned long index = offset >> PAGE_SHIFT;
> unsigned long end_index = (offset + bytes - 1) >> PAGE_SHIFT;
> - u64 page_start = page_offset(locked_page);
> - u64 page_end = page_start + PAGE_SIZE - 1;
> -
> + u64 page_start, page_end;
> struct page *page;
>
> + if (locked_page) {
> + page_start = page_offset(locked_page);
> + page_end = page_start + PAGE_SIZE - 1;
> + }
> +
> while (index <= end_index) {
> /*
> * For locked page, we will call end_extent_writepage() on it
> @@ -212,7 +215,7 @@ static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode,
> * btrfs_mark_ordered_io_finished() would skip the accounting
> * for the page range, and the ordered extent will never finish.
> */
> - if (index == (page_offset(locked_page) >> PAGE_SHIFT)) {
> + if (locked_page && index == (page_start >> PAGE_SHIFT)) {
> index++;
> continue;
> }
> @@ -231,17 +234,20 @@ static inline void btrfs_cleanup_ordered_extents(struct btrfs_inode *inode,
> put_page(page);
> }
>
> - /* The locked page covers the full range, nothing needs to be done */
> - if (bytes + offset <= page_offset(locked_page) + PAGE_SIZE)
> - return;
> - /*
> - * In case this page belongs to the delalloc range being instantiated
> - * then skip it, since the first page of a range is going to be
> - * properly cleaned up by the caller of run_delalloc_range
> - */
> - if (page_start >= offset && page_end <= (offset + bytes - 1)) {
> - bytes = offset + bytes - page_offset(locked_page) - PAGE_SIZE;
> - offset = page_offset(locked_page) + PAGE_SIZE;
> + if (locked_page) {
> + /* The locked page covers the full range, nothing needs to be done */
> + if (bytes + offset <= page_start + PAGE_SIZE)
> + return;
> + /*
> + * In case this page belongs to the delalloc range being
> + * instantiated then skip it, since the first page of a range is
> + * going to be properly cleaned up by the caller of
> + * run_delalloc_range
> + */
> + if (page_start >= offset && page_end <= (offset + bytes - 1)) {
> + bytes = offset + bytes - page_offset(locked_page) - PAGE_SIZE;
> + offset = page_offset(locked_page) + PAGE_SIZE;
> + }
> }
>
> return __endio_write_update_ordered(inode, offset, bytes, false);
> --
> 2.35.1
>
next prev parent reply other threads:[~2022-06-17 10:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-16 15:45 [PATCH 0/4] btrfs: fix error handling of cow_file_range(unlock = 0) Naohiro Aota
2022-06-16 15:45 ` [PATCH 1/4] btrfs: ensure pages are unlocked on cow_file_range() failure Naohiro Aota
2022-06-17 10:11 ` Filipe Manana
2022-06-20 2:22 ` Naohiro Aota
2022-06-16 15:45 ` [PATCH 2/4] btrfs: extend btrfs_cleanup_ordered_extens for NULL locked_page Naohiro Aota
2022-06-17 10:15 ` Filipe Manana [this message]
2022-06-20 2:28 ` Naohiro Aota
2022-06-16 15:45 ` [PATCH 3/4] btrfs: fix error handling of fallbacked uncompress write Naohiro Aota
2022-06-17 10:21 ` Filipe Manana
2022-06-20 2:26 ` Naohiro Aota
2022-06-16 15:45 ` [PATCH 4/4] btrfs: replace unnecessary goto with direct return Naohiro Aota
2022-06-17 10:13 ` Filipe Manana
2022-06-20 2:22 ` Naohiro Aota
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=20220617101515.GC4041436@falcondesktop \
--to=fdmanana@kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=naohiro.aota@wdc.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.