Message ID | CAOcd+r10Q08zhvjMawOrQ8jWBReD6dYxeEtiZSoqUEuHCeM27g@mail.gmail.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On 10/11/15 20:09, Alex Lyakas wrote: > Hi Naota, > > What happens if btrfs_bio_alloc() in submit_extent_page fails? Then we > return -ENOMEM to the caller, but we do not set *bio_ret to NULL. And > if *bio_ret was non-NULL upon entry into submit_extent_page, then we > had submitted this bio before getting to btrfs_bio_alloc(). So should > btrfs_bio_alloc() failure be handled in the same way? > > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c > index 3915c94..cd443bc 100644 > --- a/fs/btrfs/extent_io.c > +++ b/fs/btrfs/extent_io.c > @@ -2834,8 +2834,11 @@ static int submit_extent_page(int rw, struct > extent_io_tree *tree, > > bio = btrfs_bio_alloc(bdev, sector, BIO_MAX_PAGES, > GFP_NOFS | __GFP_HIGH); > - if (!bio) > + if (!bio) { > + if (bio_ret) > + *bio_ret = NULL; > return -ENOMEM; > + } > > bio_add_page(bio, page, page_size, offset); > bio->bi_end_io = end_io_func; > Did you get any feedback on this? It seems it could cause data loss or corruption on allocation failures, no? -h -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Holger, I think it will cause an invalid paging request, just like in case that Naohiro has fixed. I am not running the "latest and greatest" btrfs in my system, and it is not easy to set it up, that's why I cannot submit patches based on the latest code, I can only review and comment on patches. Alex. On Thu, Nov 5, 2015 at 3:08 PM, Holger Hoffstätte <holger.hoffstaette@googlemail.com> wrote: > On 10/11/15 20:09, Alex Lyakas wrote: >> Hi Naota, >> >> What happens if btrfs_bio_alloc() in submit_extent_page fails? Then we >> return -ENOMEM to the caller, but we do not set *bio_ret to NULL. And >> if *bio_ret was non-NULL upon entry into submit_extent_page, then we >> had submitted this bio before getting to btrfs_bio_alloc(). So should >> btrfs_bio_alloc() failure be handled in the same way? >> >> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c >> index 3915c94..cd443bc 100644 >> --- a/fs/btrfs/extent_io.c >> +++ b/fs/btrfs/extent_io.c >> @@ -2834,8 +2834,11 @@ static int submit_extent_page(int rw, struct >> extent_io_tree *tree, >> >> bio = btrfs_bio_alloc(bdev, sector, BIO_MAX_PAGES, >> GFP_NOFS | __GFP_HIGH); >> - if (!bio) >> + if (!bio) { >> + if (bio_ret) >> + *bio_ret = NULL; >> return -ENOMEM; >> + } >> >> bio_add_page(bio, page, page_size, offset); >> bio->bi_end_io = end_io_func; >> > > Did you get any feedback on this? It seems it could cause data loss or > corruption on allocation failures, no? > > -h > -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 3915c94..cd443bc 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2834,8 +2834,11 @@ static int submit_extent_page(int rw, struct extent_io_tree *tree, bio = btrfs_bio_alloc(bdev, sector, BIO_MAX_PAGES, GFP_NOFS | __GFP_HIGH); - if (!bio) + if (!bio) { + if (bio_ret) + *bio_ret = NULL; return -ENOMEM; + } bio_add_page(bio, page, page_size, offset);