linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] Btrfs: fix wrong file range cleanup after an error filling dealloc range
@ 2020-05-27 10:15 fdmanana
  2020-05-27 15:01 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: fdmanana @ 2020-05-27 10:15 UTC (permalink / raw)
  To: linux-btrfs

From: Filipe Manana <fdmanana@suse.com>

If an error happens while running dellaloc in COW mode for a range, we can
end up calling extent_clear_unlock_delalloc() for a range that goes beyond
our range's end offset by 1 byte, which affects 1 extra page. This results
in clearing bits and doing page operations (such as a page unlock) outside
our target range.

Fix that by calling extent_clear_unlock_delalloc() with an inclusive end
offset, instead of an exclusive end offset, at cow_file_range().

Fixes: a315e68f6e8b30 ("Btrfs: fix invalid attempt to free reserved space on failure to cow range")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 320d1062068d..79f833f920d3 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1142,7 +1142,7 @@ static noinline int cow_file_range(struct inode *inode,
 	 */
 	if (extent_reserved) {
 		extent_clear_unlock_delalloc(inode, start,
-					     start + cur_alloc_size,
+					     start + cur_alloc_size - 1,
 					     locked_page,
 					     clear_bits,
 					     page_ops);
-- 
2.11.0


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

* Re: [PATCH 1/3] Btrfs: fix wrong file range cleanup after an error filling dealloc range
  2020-05-27 10:15 [PATCH 1/3] Btrfs: fix wrong file range cleanup after an error filling dealloc range fdmanana
@ 2020-05-27 15:01 ` David Sterba
  2020-05-27 16:31   ` Filipe Manana
  0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2020-05-27 15:01 UTC (permalink / raw)
  To: fdmanana; +Cc: linux-btrfs

On Wed, May 27, 2020 at 11:15:53AM +0100, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> If an error happens while running dellaloc in COW mode for a range, we can
> end up calling extent_clear_unlock_delalloc() for a range that goes beyond
> our range's end offset by 1 byte, which affects 1 extra page. This results
> in clearing bits and doing page operations (such as a page unlock) outside
> our target range.
> 
> Fix that by calling extent_clear_unlock_delalloc() with an inclusive end
> offset, instead of an exclusive end offset, at cow_file_range().
> 
> Fixes: a315e68f6e8b30 ("Btrfs: fix invalid attempt to free reserved space on failure to cow range")
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

1-3 added to misc-next, thanks.

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

* Re: [PATCH 1/3] Btrfs: fix wrong file range cleanup after an error filling dealloc range
  2020-05-27 15:01 ` David Sterba
@ 2020-05-27 16:31   ` Filipe Manana
  2020-05-27 18:40     ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Filipe Manana @ 2020-05-27 16:31 UTC (permalink / raw)
  To: dsterba, Filipe Manana, linux-btrfs

On Wed, May 27, 2020 at 4:02 PM David Sterba <dsterba@suse.cz> wrote:
>
> On Wed, May 27, 2020 at 11:15:53AM +0100, fdmanana@kernel.org wrote:
> > From: Filipe Manana <fdmanana@suse.com>
> >
> > If an error happens while running dellaloc in COW mode for a range, we can
> > end up calling extent_clear_unlock_delalloc() for a range that goes beyond
> > our range's end offset by 1 byte, which affects 1 extra page. This results
> > in clearing bits and doing page operations (such as a page unlock) outside
> > our target range.
> >
> > Fix that by calling extent_clear_unlock_delalloc() with an inclusive end
> > offset, instead of an exclusive end offset, at cow_file_range().
> >
> > Fixes: a315e68f6e8b30 ("Btrfs: fix invalid attempt to free reserved space on failure to cow range")
> > Signed-off-by: Filipe Manana <fdmanana@suse.com>
>
> 1-3 added to misc-next, thanks.

So I noticed earlier that in patch 3/3, I mention "generic/061"
instead of "btrfs/061". Would you mind amending the changelog with
just that?

Thanks.

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

* Re: [PATCH 1/3] Btrfs: fix wrong file range cleanup after an error filling dealloc range
  2020-05-27 16:31   ` Filipe Manana
@ 2020-05-27 18:40     ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2020-05-27 18:40 UTC (permalink / raw)
  To: Filipe Manana; +Cc: dsterba, linux-btrfs

On Wed, May 27, 2020 at 05:31:48PM +0100, Filipe Manana wrote:
> On Wed, May 27, 2020 at 4:02 PM David Sterba <dsterba@suse.cz> wrote:
> >
> > On Wed, May 27, 2020 at 11:15:53AM +0100, fdmanana@kernel.org wrote:
> > > From: Filipe Manana <fdmanana@suse.com>
> > >
> > > If an error happens while running dellaloc in COW mode for a range, we can
> > > end up calling extent_clear_unlock_delalloc() for a range that goes beyond
> > > our range's end offset by 1 byte, which affects 1 extra page. This results
> > > in clearing bits and doing page operations (such as a page unlock) outside
> > > our target range.
> > >
> > > Fix that by calling extent_clear_unlock_delalloc() with an inclusive end
> > > offset, instead of an exclusive end offset, at cow_file_range().
> > >
> > > Fixes: a315e68f6e8b30 ("Btrfs: fix invalid attempt to free reserved space on failure to cow range")
> > > Signed-off-by: Filipe Manana <fdmanana@suse.com>
> >
> > 1-3 added to misc-next, thanks.
> 
> So I noticed earlier that in patch 3/3, I mention "generic/061"
> instead of "btrfs/061". Would you mind amending the changelog with
> just that?

Changelog updated, thanks.

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

end of thread, other threads:[~2020-05-27 18:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 10:15 [PATCH 1/3] Btrfs: fix wrong file range cleanup after an error filling dealloc range fdmanana
2020-05-27 15:01 ` David Sterba
2020-05-27 16:31   ` Filipe Manana
2020-05-27 18:40     ` David Sterba

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).