Message ID | 20200720014209.11485-1-robbieko@synology.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: fix page leaks after failure to lock page for delalloc | expand |
On 20.07.20 г. 4:42 ч., robbieko wrote: > From: Robbie Ko <robbieko@synology.com> > > When locking pages for delalloc, we check if it's dirty and mapping still > matches, if it does not match, we will return -EAGAIN and release all > pages. > > Signed-off-by: Robbie Ko <robbieko@synology.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> > --- > fs/btrfs/extent_io.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c > index 68c96057ad2d..22fc47f9c900 100644 > --- a/fs/btrfs/extent_io.c > +++ b/fs/btrfs/extent_io.c > @@ -1999,7 +1999,8 @@ static int __process_pages_contig(struct address_space *mapping, > if (!PageDirty(pages[i]) || > pages[i]->mapping != mapping) { > unlock_page(pages[i]); > - put_page(pages[i]); > + for (; i < ret; i++) > + put_page(pages[i]); > err = -EAGAIN; > goto out; > } >
On Mon, Jul 20, 2020 at 09:42:09AM +0800, robbieko wrote: > From: Robbie Ko <robbieko@synology.com> > > When locking pages for delalloc, we check if it's dirty and mapping still > matches, if it does not match, we will return -EAGAIN and release all > pages. > > Signed-off-by: Robbie Ko <robbieko@synology.com> Nice catch, added to misc-next, thanks.
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 68c96057ad2d..22fc47f9c900 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1999,7 +1999,8 @@ static int __process_pages_contig(struct address_space *mapping, if (!PageDirty(pages[i]) || pages[i]->mapping != mapping) { unlock_page(pages[i]); - put_page(pages[i]); + for (; i < ret; i++) + put_page(pages[i]); err = -EAGAIN; goto out; }