]> git.baikalelectronics.ru Git - kernel.git/commitdiff
fs: remove mpage_alloc
authorChristoph Hellwig <hch@lst.de>
Mon, 24 Jan 2022 09:10:49 +0000 (10:10 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 2 Feb 2022 14:49:59 +0000 (07:49 -0700)
open code mpage_alloc in it's two callers and simplify the results
because of the context:

 - __mpage_writepage always passes GFP_NOFS and can thus always sleep and
    will never get a NULL return from bio_alloc at all.
 - do_mpage_readpage can only get a non-sleeping context for readahead
   which never sets PF_MEMALLOC and thus doesn't need the retry loop
   either.

Both cases will never have __GFP_HIGH set.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220124091107.642561-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/mpage.c

index 87f5cfef6caa71c7333cca396563605700882f23..06e95d777e940a46a4669cc7136dfcdbc76bea8c 100644 (file)
@@ -66,29 +66,6 @@ static struct bio *mpage_bio_submit(int op, int op_flags, struct bio *bio)
        return NULL;
 }
 
-static struct bio *
-mpage_alloc(struct block_device *bdev,
-               sector_t first_sector, int nr_vecs,
-               gfp_t gfp_flags)
-{
-       struct bio *bio;
-
-       /* Restrict the given (page cache) mask for slab allocations */
-       gfp_flags &= GFP_KERNEL;
-       bio = bio_alloc(gfp_flags, nr_vecs);
-
-       if (bio == NULL && (current->flags & PF_MEMALLOC)) {
-               while (!bio && (nr_vecs /= 2))
-                       bio = bio_alloc(gfp_flags, nr_vecs);
-       }
-
-       if (bio) {
-               bio_set_dev(bio, bdev);
-               bio->bi_iter.bi_sector = first_sector;
-       }
-       return bio;
-}
-
 /*
  * support function for mpage_readahead.  The fs supplied get_block might
  * return an up to date buffer.  This is used to map that buffer into
@@ -296,10 +273,11 @@ alloc_new:
                                                                page))
                                goto out;
                }
-               args->bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9),
-                                       bio_max_segs(args->nr_pages), gfp);
+               args->bio = bio_alloc(gfp, bio_max_segs(args->nr_pages));
                if (args->bio == NULL)
                        goto confused;
+               bio_set_dev(args->bio, bdev);
+               args->bio->bi_iter.bi_sector = blocks[0] << (blkbits - 9);
        }
 
        length = first_hole << blkbits;
@@ -608,10 +586,9 @@ alloc_new:
                                                                page, wbc))
                                goto out;
                }
-               bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9),
-                               BIO_MAX_VECS, GFP_NOFS|__GFP_HIGH);
-               if (bio == NULL)
-                       goto confused;
+               bio = bio_alloc(GFP_NOFS, BIO_MAX_VECS);
+               bio_set_dev(bio, bdev);
+               bio->bi_iter.bi_sector = blocks[0] << (blkbits - 9);
 
                wbc_init_bio(wbc, bio);
                bio->bi_write_hint = inode->i_write_hint;