Linux-BTRFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents
@ 2020-02-13 12:29 fdmanana
  2020-02-13 13:03 ` Qu Wenruo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: fdmanana @ 2020-02-13 12:29 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

In btrfs_wait_ordered_range() once we find an ordered extent that has
finished with an error we exit the loop and don't wait for any other
ordered extents that might be still in progress.

All the users of btrfs_wait_ordered_range() expect that there are no more
ordered extents in progress after that function returns. So past fixes
such like the ones from the two following commits:

  ff612ba7849964 ("btrfs: fix panic during relocation after ENOSPC before
                   writeback happens")

  28aeeac1dd3080 ("Btrfs: fix panic when starting bg cache writeout after
                   IO error")

don't work when there are multiple ordered extents in the range.

Fix that by making btrfs_wait_ordered_range() wait for all ordered extents
even after it finds one that had an error.

Link: https://github.com/kdave/btrfs-progs/issues/228#issuecomment-569777554
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/ordered-data.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 4cbb4e082800..ab3711328e7d 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -686,10 +686,15 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len)
 		}
 		btrfs_start_ordered_extent(inode, ordered, 1);
 		end = ordered->file_offset;
+		/*
+		 * If the ordered extent had an error save the error but don't
+		 * exit without waiting first for all other ordered extents in
+		 * the range to complete.
+		 */
 		if (test_bit(BTRFS_ORDERED_IOERR, &ordered->flags))
 			ret = -EIO;
 		btrfs_put_ordered_extent(ordered);
-		if (ret || end == 0 || end == start)
+		if (end == 0 || end == start)
 			break;
 		end--;
 	}
-- 
2.11.0


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

* Re: [PATCH] Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents
  2020-02-13 12:29 [PATCH] Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents fdmanana
@ 2020-02-13 13:03 ` Qu Wenruo
  2020-02-13 20:13 ` Josef Bacik
  2020-02-18 16:00 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2020-02-13 13:03 UTC (permalink / raw)
  To: fdmanana, linux-btrfs

[-- Attachment #1.1: Type: text/plain, Size: 2032 bytes --]



On 2020/2/13 下午8:29, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> In btrfs_wait_ordered_range() once we find an ordered extent that has
> finished with an error we exit the loop and don't wait for any other
> ordered extents that might be still in progress.
> 
> All the users of btrfs_wait_ordered_range() expect that there are no more
> ordered extents in progress after that function returns. So past fixes
> such like the ones from the two following commits:
> 
>   ff612ba7849964 ("btrfs: fix panic during relocation after ENOSPC before
>                    writeback happens")
> 
>   28aeeac1dd3080 ("Btrfs: fix panic when starting bg cache writeout after
>                    IO error")
> 
> don't work when there are multiple ordered extents in the range.
> 
> Fix that by making btrfs_wait_ordered_range() wait for all ordered extents
> even after it finds one that had an error.
> 
> Link: https://github.com/kdave/btrfs-progs/issues/228#issuecomment-569777554
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>  fs/btrfs/ordered-data.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
> index 4cbb4e082800..ab3711328e7d 100644
> --- a/fs/btrfs/ordered-data.c
> +++ b/fs/btrfs/ordered-data.c
> @@ -686,10 +686,15 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len)
>  		}
>  		btrfs_start_ordered_extent(inode, ordered, 1);
>  		end = ordered->file_offset;
> +		/*
> +		 * If the ordered extent had an error save the error but don't
> +		 * exit without waiting first for all other ordered extents in
> +		 * the range to complete.
> +		 */
>  		if (test_bit(BTRFS_ORDERED_IOERR, &ordered->flags))
>  			ret = -EIO;
>  		btrfs_put_ordered_extent(ordered);
> -		if (ret || end == 0 || end == start)
> +		if (end == 0 || end == start)
>  			break;
>  		end--;
>  	}
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents
  2020-02-13 12:29 [PATCH] Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents fdmanana
  2020-02-13 13:03 ` Qu Wenruo
@ 2020-02-13 20:13 ` Josef Bacik
  2020-02-18 16:00 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: Josef Bacik @ 2020-02-13 20:13 UTC (permalink / raw)
  To: fdmanana, linux-btrfs

On 2/13/20 7:29 AM, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> In btrfs_wait_ordered_range() once we find an ordered extent that has
> finished with an error we exit the loop and don't wait for any other
> ordered extents that might be still in progress.
> 
> All the users of btrfs_wait_ordered_range() expect that there are no more
> ordered extents in progress after that function returns. So past fixes
> such like the ones from the two following commits:
> 
>    ff612ba7849964 ("btrfs: fix panic during relocation after ENOSPC before
>                     writeback happens")
> 
>    28aeeac1dd3080 ("Btrfs: fix panic when starting bg cache writeout after
>                     IO error")
> 
> don't work when there are multiple ordered extents in the range.
> 
> Fix that by making btrfs_wait_ordered_range() wait for all ordered extents
> even after it finds one that had an error.
> 
> Link: https://github.com/kdave/btrfs-progs/issues/228#issuecomment-569777554
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Man that subject made things sounds a lot worse than it actually was,

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

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

* Re: [PATCH] Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents
  2020-02-13 12:29 [PATCH] Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents fdmanana
  2020-02-13 13:03 ` Qu Wenruo
  2020-02-13 20:13 ` Josef Bacik
@ 2020-02-18 16:00 ` David Sterba
  2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2020-02-18 16:00 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

On Thu, Feb 13, 2020 at 12:29:50PM +0000, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> In btrfs_wait_ordered_range() once we find an ordered extent that has
> finished with an error we exit the loop and don't wait for any other
> ordered extents that might be still in progress.
> 
> All the users of btrfs_wait_ordered_range() expect that there are no more
> ordered extents in progress after that function returns. So past fixes
> such like the ones from the two following commits:
> 
>   ff612ba7849964 ("btrfs: fix panic during relocation after ENOSPC before
>                    writeback happens")
> 
>   28aeeac1dd3080 ("Btrfs: fix panic when starting bg cache writeout after
>                    IO error")
> 
> don't work when there are multiple ordered extents in the range.
> 
> Fix that by making btrfs_wait_ordered_range() wait for all ordered extents
> even after it finds one that had an error.
> 
> Link: https://github.com/kdave/btrfs-progs/issues/228#issuecomment-569777554
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Added to misc-next, thanks.

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-13 12:29 [PATCH] Btrfs: fix btrfs_wait_ordered_range() so that it waits for all ordered extents fdmanana
2020-02-13 13:03 ` Qu Wenruo
2020-02-13 20:13 ` Josef Bacik
2020-02-18 16:00 ` David Sterba

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org
	public-inbox-index linux-btrfs

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git