On Sun, Sep 01, 2019 at 01:51:22PM +0800, Gao Xiang wrote: > From: Gao Xiang <gaoxiang25@xxxxxxxxxx> > > As Christoph pointed out [1], "erofs_grab_bio tries to > handle a bio_alloc failure, except that the function will > not actually fail due the mempool backing it." > > Sorry about useless code, fix it now. A lot of file systems used to have this, it is a classic that gets copy and pasted everywhere. If you feel like doing a little project it might make sense to check for other places that do the same. > + bio = erofs_grab_bio(sb, blkaddr, 1, sb, read_endio); > > if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) { > err = -EFAULT; > @@ -275,13 +270,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio, > if (nblocks > BIO_MAX_PAGES) > nblocks = BIO_MAX_PAGES; > > - bio = erofs_grab_bio(sb, blknr, nblocks, sb, > - read_endio, false); > - if (IS_ERR(bio)) { > - err = PTR_ERR(bio); > - bio = NULL; > - goto err_out; > - } > + bio = erofs_grab_bio(sb, blknr, nblocks, sb, read_endio); Btw, I think you should remove erofs_grab_bio in its current form. The full code in data.c is indeed used in two places, so a local erofs_raw_page_alloc_bio (or whatever name you prefer) helper here that hardcodes the sb amd read_endio argument to simplify it a bit makes sense. > diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c > index f06a2fad7af2..abe28565d6c0 100644 > --- a/fs/erofs/zdata.c > +++ b/fs/erofs/zdata.c > @@ -1265,7 +1265,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, > if (!bio) { > bio = erofs_grab_bio(sb, first_index + i, > BIO_MAX_PAGES, bi_private, > - z_erofs_vle_read_endio, true); > + z_erofs_vle_read_endio); But I think here you might as well open code it entirely, or at least us a separate (and local to zdata.c) helper. _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel