Hi Jens, this series contains various cleanups for how bios are allocated or initialized plus related fallout. Diffstat: Documentation/filesystems/f2fs.rst | 1 block/bio.c | 167 ++++++++++++++++++------------------- block/blk-crypto-fallback.c | 2 block/blk-flush.c | 17 +-- drivers/block/drbd/drbd_actlog.c | 2 drivers/block/drbd/drbd_bitmap.c | 2 drivers/block/drbd/drbd_int.h | 2 drivers/block/drbd/drbd_main.c | 13 -- drivers/block/drbd/drbd_req.c | 5 - drivers/block/drbd/drbd_req.h | 12 -- drivers/block/drbd/drbd_worker.c | 5 - drivers/md/dm-clone-target.c | 14 --- drivers/md/dm-zoned-metadata.c | 6 - drivers/md/md.c | 48 +++------- drivers/md/md.h | 2 drivers/md/raid1.c | 2 drivers/md/raid10.c | 2 drivers/md/raid5-ppl.c | 2 drivers/md/raid5.c | 108 +++++++++-------------- drivers/nvme/target/io-cmd-bdev.c | 2 fs/block_dev.c | 2 fs/btrfs/volumes.c | 2 fs/exfat/file.c | 2 fs/ext4/fast_commit.c | 4 fs/ext4/fsync.c | 2 fs/ext4/ialloc.c | 2 fs/ext4/super.c | 2 fs/f2fs/data.c | 28 ------ fs/f2fs/f2fs.h | 2 fs/f2fs/segment.c | 12 -- fs/f2fs/super.c | 1 fs/fat/file.c | 2 fs/hfsplus/inode.c | 2 fs/hfsplus/super.c | 2 fs/jbd2/checkpoint.c | 2 fs/jbd2/commit.c | 4 fs/jbd2/recovery.c | 2 fs/libfs.c | 2 fs/nfs/blocklayout/blocklayout.c | 5 - fs/nilfs2/segbuf.c | 4 fs/nilfs2/the_nilfs.h | 2 fs/ocfs2/file.c | 2 fs/reiserfs/file.c | 2 fs/xfs/xfs_super.c | 2 fs/zonefs/super.c | 4 include/linux/bio.h | 6 - include/linux/blkdev.h | 4 include/linux/swap.h | 1 mm/page_io.c | 45 ++------- mm/swapfile.c | 10 -- 50 files changed, 213 insertions(+), 363 deletions(-)
Use bio_alloc instead of open coding it. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/zonefs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c index bec47f2d074beb..faea2ed34b4a37 100644 --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@ -678,7 +678,7 @@ static ssize_t zonefs_file_dio_append(struct kiocb *iocb, struct iov_iter *from) if (!nr_pages) return 0; - bio = bio_alloc_bioset(GFP_NOFS, nr_pages, &fs_bio_set); + bio = bio_alloc(GFP_NOFS, nr_pages); if (!bio) return -ENOMEM; -- 2.29.2
Use bio_kmalloc instead of open coding it. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/btrfs/volumes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 0a6de859eb2226..584ba093cf4966 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -421,7 +421,7 @@ static struct btrfs_device *__alloc_device(struct btrfs_fs_info *fs_info) * Preallocate a bio that's always going to be used for flushing device * barriers and matches the device lifespan */ - dev->flush_bio = bio_alloc_bioset(GFP_KERNEL, 0, NULL); + dev->flush_bio = bio_kmalloc(GFP_KERNEL, 0); if (!dev->flush_bio) { kfree(dev); return ERR_PTR(-ENOMEM); -- 2.29.2
Use bio_kmalloc instead of open coding it. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/blk-crypto-fallback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c index 50c225398e4d60..e8327c50d7c9f4 100644 --- a/block/blk-crypto-fallback.c +++ b/block/blk-crypto-fallback.c @@ -164,7 +164,7 @@ static struct bio *blk_crypto_clone_bio(struct bio *bio_src) struct bio_vec bv; struct bio *bio; - bio = bio_alloc_bioset(GFP_NOIO, bio_segments(bio_src), NULL); + bio = bio_kmalloc(GFP_NOIO, bio_segments(bio_src)); if (!bio) return NULL; bio->bi_bdev = bio_src->bi_bdev; -- 2.29.2
bio_kmalloc shares almost no logic with the bio_set based fast path in bio_alloc_bioset. Split it into an entirely separate implementation. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/bio.c | 167 ++++++++++++++++++++++---------------------- include/linux/bio.h | 6 +- 2 files changed, 86 insertions(+), 87 deletions(-) diff --git a/block/bio.c b/block/bio.c index dfd7740a32300a..d4375619348c52 100644 --- a/block/bio.c +++ b/block/bio.c @@ -396,123 +396,101 @@ static void punt_bios_to_rescuer(struct bio_set *bs) * @nr_iovecs: number of iovecs to pre-allocate * @bs: the bio_set to allocate from. * - * Description: - * If @bs is NULL, uses kmalloc() to allocate the bio; else the allocation is - * backed by the @bs's mempool. + * Allocate a bio from the mempools in @bs. * - * When @bs is not NULL, if %__GFP_DIRECT_RECLAIM is set then bio_alloc will - * always be able to allocate a bio. This is due to the mempool guarantees. - * To make this work, callers must never allocate more than 1 bio at a time - * from this pool. Callers that need to allocate more than 1 bio must always - * submit the previously allocated bio for IO before attempting to allocate - * a new one. Failure to do so can cause deadlocks under memory pressure. + * If %__GFP_DIRECT_RECLAIM is set then bio_alloc will always be able to + * allocate a bio. This is due to the mempool guarantees. To make this work, + * callers must never allocate more than 1 bio at a time from the general pool. + * Callers that need to allocate more than 1 bio must always submit the + * previously allocated bio for IO before attempting to allocate a new one. + * Failure to do so can cause deadlocks under memory pressure. * - * Note that when running under submit_bio_noacct() (i.e. any block - * driver), bios are not submitted until after you return - see the code in - * submit_bio_noacct() that converts recursion into iteration, to prevent - * stack overflows. + * Note that when running under submit_bio_noacct() (i.e. any block driver), + * bios are not submitted until after you return - see the code in + * submit_bio_noacct() that converts recursion into iteration, to prevent + * stack overflows. * - * This would normally mean allocating multiple bios under - * submit_bio_noacct() would be susceptible to deadlocks, but we have - * deadlock avoidance code that resubmits any blocked bios from a rescuer - * thread. + * This would normally mean allocating multiple bios under submit_bio_noacct() + * would be susceptible to deadlocks, but we have + * deadlock avoidance code that resubmits any blocked bios from a rescuer + * thread. * - * However, we do not guarantee forward progress for allocations from other - * mempools. Doing multiple allocations from the same mempool under - * submit_bio_noacct() should be avoided - instead, use bio_set's front_pad - * for per bio allocations. + * However, we do not guarantee forward progress for allocations from other + * mempools. Doing multiple allocations from the same mempool under + * submit_bio_noacct() should be avoided - instead, use bio_set's front_pad + * for per bio allocations. * - * RETURNS: - * Pointer to new bio on success, NULL on failure. + * Returns: Pointer to new bio on success, NULL on failure. */ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned int nr_iovecs, struct bio_set *bs) { gfp_t saved_gfp = gfp_mask; - unsigned front_pad; - unsigned inline_vecs; - struct bio_vec *bvl = NULL; struct bio *bio; void *p; - if (!bs) { - if (nr_iovecs > UIO_MAXIOV) - return NULL; - - p = kmalloc(struct_size(bio, bi_inline_vecs, nr_iovecs), gfp_mask); - front_pad = 0; - inline_vecs = nr_iovecs; - } else { - /* should not use nobvec bioset for nr_iovecs > 0 */ - if (WARN_ON_ONCE(!mempool_initialized(&bs->bvec_pool) && - nr_iovecs > 0)) - return NULL; - /* - * submit_bio_noacct() converts recursion to iteration; this - * means if we're running beneath it, any bios we allocate and - * submit will not be submitted (and thus freed) until after we - * return. - * - * This exposes us to a potential deadlock if we allocate - * multiple bios from the same bio_set() while running - * underneath submit_bio_noacct(). If we were to allocate - * multiple bios (say a stacking block driver that was splitting - * bios), we would deadlock if we exhausted the mempool's - * reserve. - * - * We solve this, and guarantee forward progress, with a rescuer - * workqueue per bio_set. If we go to allocate and there are - * bios on current->bio_list, we first try the allocation - * without __GFP_DIRECT_RECLAIM; if that fails, we punt those - * bios we would be blocking to the rescuer workqueue before - * we retry with the original gfp_flags. - */ - - if (current->bio_list && - (!bio_list_empty(¤t->bio_list[0]) || - !bio_list_empty(¤t->bio_list[1])) && - bs->rescue_workqueue) - gfp_mask &= ~__GFP_DIRECT_RECLAIM; + /* should not use nobvec bioset for nr_iovecs > 0 */ + if (WARN_ON_ONCE(!mempool_initialized(&bs->bvec_pool) && nr_iovecs > 0)) + return NULL; + /* + * submit_bio_noacct() converts recursion to iteration; this means if + * we're running beneath it, any bios we allocate and submit will not be + * submitted (and thus freed) until after we return. + * + * This exposes us to a potential deadlock if we allocate multiple bios + * from the same bio_set() while running underneath submit_bio_noacct(). + * If we were to allocate multiple bios (say a stacking block driver + * that was splitting bios), we would deadlock if we exhausted the + * mempool's reserve. + * + * We solve this, and guarantee forward progress, with a rescuer + * workqueue per bio_set. If we go to allocate and there are bios on + * current->bio_list, we first try the allocation without + * __GFP_DIRECT_RECLAIM; if that fails, we punt those bios we would be + * blocking to the rescuer workqueue before we retry with the original + * gfp_flags. + */ + if (current->bio_list && + (!bio_list_empty(¤t->bio_list[0]) || + !bio_list_empty(¤t->bio_list[1])) && + bs->rescue_workqueue) + gfp_mask &= ~__GFP_DIRECT_RECLAIM; + + p = mempool_alloc(&bs->bio_pool, gfp_mask); + if (!p && gfp_mask != saved_gfp) { + punt_bios_to_rescuer(bs); + gfp_mask = saved_gfp; p = mempool_alloc(&bs->bio_pool, gfp_mask); - if (!p && gfp_mask != saved_gfp) { - punt_bios_to_rescuer(bs); - gfp_mask = saved_gfp; - p = mempool_alloc(&bs->bio_pool, gfp_mask); - } - - front_pad = bs->front_pad; - inline_vecs = BIO_INLINE_VECS; } - if (unlikely(!p)) return NULL; - bio = p + front_pad; - bio_init(bio, NULL, 0); - - if (nr_iovecs > inline_vecs) { + bio = p + bs->front_pad; + if (nr_iovecs > BIO_INLINE_VECS) { unsigned long idx = 0; + struct bio_vec *bvl = NULL; bvl = bvec_alloc(gfp_mask, nr_iovecs, &idx, &bs->bvec_pool); if (!bvl && gfp_mask != saved_gfp) { punt_bios_to_rescuer(bs); gfp_mask = saved_gfp; - bvl = bvec_alloc(gfp_mask, nr_iovecs, &idx, &bs->bvec_pool); + bvl = bvec_alloc(gfp_mask, nr_iovecs, &idx, + &bs->bvec_pool); } if (unlikely(!bvl)) goto err_free; bio->bi_flags |= idx << BVEC_POOL_OFFSET; - bio->bi_max_vecs = bvec_nr_vecs(idx); + bio_init(bio, bvl, bvec_nr_vecs(idx)); } else if (nr_iovecs) { - bvl = bio->bi_inline_vecs; - bio->bi_max_vecs = inline_vecs; + bio_init(bio, bio->bi_inline_vecs, BIO_INLINE_VECS); + } else { + bio_init(bio, NULL, 0); } bio->bi_pool = bs; - bio->bi_io_vec = bvl; return bio; err_free: @@ -521,6 +499,31 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned int nr_iovecs, } EXPORT_SYMBOL(bio_alloc_bioset); +/** + * bio_kmalloc - kmalloc a bio for I/O + * @gfp_mask: the GFP_* mask given to the slab allocator + * @nr_iovecs: number of iovecs to pre-allocate + * + * Use kmalloc to allocate and initialize a bio. + * + * Returns: Pointer to new bio on success, NULL on failure. + */ +struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned int nr_iovecs) +{ + struct bio *bio; + + if (nr_iovecs > UIO_MAXIOV) + return NULL; + + bio = kmalloc(struct_size(bio, bi_inline_vecs, nr_iovecs), gfp_mask); + if (unlikely(!bio)) + return NULL; + bio_init(bio, nr_iovecs ? bio->bi_inline_vecs : NULL, nr_iovecs); + bio->bi_pool = NULL; + return bio; +} +EXPORT_SYMBOL(bio_kmalloc); + void zero_fill_bio_iter(struct bio *bio, struct bvec_iter start) { unsigned long flags; diff --git a/include/linux/bio.h b/include/linux/bio.h index 676870b2c88d80..c74857cf12528c 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -408,6 +408,7 @@ extern int biovec_init_pool(mempool_t *pool, int pool_entries); extern int bioset_init_from_src(struct bio_set *bs, struct bio_set *src); extern struct bio *bio_alloc_bioset(gfp_t, unsigned int, struct bio_set *); +struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned int nr_iovecs); extern void bio_put(struct bio *); extern void __bio_clone_fast(struct bio *, struct bio *); @@ -420,11 +421,6 @@ static inline struct bio *bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs) return bio_alloc_bioset(gfp_mask, nr_iovecs, &fs_bio_set); } -static inline struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned int nr_iovecs) -{ - return bio_alloc_bioset(gfp_mask, nr_iovecs, NULL); -} - extern blk_qc_t submit_bio(struct bio *); extern void bio_endio(struct bio *); -- 2.29.2
There is no point in allocating memory for a synchronous flush. Signed-off-by: Christoph Hellwig <hch@lst.de> --- block/blk-flush.c | 17 ++++++----------- drivers/md/dm-zoned-metadata.c | 6 +++--- drivers/md/raid5-ppl.c | 2 +- drivers/nvme/target/io-cmd-bdev.c | 2 +- fs/block_dev.c | 2 +- fs/exfat/file.c | 2 +- fs/ext4/fast_commit.c | 4 ++-- fs/ext4/fsync.c | 2 +- fs/ext4/ialloc.c | 2 +- fs/ext4/super.c | 2 +- fs/fat/file.c | 2 +- fs/hfsplus/inode.c | 2 +- fs/hfsplus/super.c | 2 +- fs/jbd2/checkpoint.c | 2 +- fs/jbd2/commit.c | 4 ++-- fs/jbd2/recovery.c | 2 +- fs/libfs.c | 2 +- fs/nilfs2/the_nilfs.h | 2 +- fs/ocfs2/file.c | 2 +- fs/reiserfs/file.c | 2 +- fs/xfs/xfs_super.c | 2 +- fs/zonefs/super.c | 2 +- include/linux/blkdev.h | 4 ++-- 23 files changed, 33 insertions(+), 38 deletions(-) diff --git a/block/blk-flush.c b/block/blk-flush.c index 76c1624cb06c05..7942ca6ed3211c 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -432,23 +432,18 @@ void blk_insert_flush(struct request *rq) /** * blkdev_issue_flush - queue a flush * @bdev: blockdev to issue flush for - * @gfp_mask: memory allocation flags (for bio_alloc) * * Description: * Issue a flush for the block device in question. */ -int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask) +int blkdev_issue_flush(struct block_device *bdev) { - struct bio *bio; - int ret = 0; + struct bio bio; - bio = bio_alloc(gfp_mask, 0); - bio_set_dev(bio, bdev); - bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH; - - ret = submit_bio_wait(bio); - bio_put(bio); - return ret; + bio_init(&bio, NULL, 0); + bio_set_dev(&bio, bdev); + bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH; + return submit_bio_wait(&bio); } EXPORT_SYMBOL(blkdev_issue_flush); diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c index b298fefb022eb9..039d17b2893849 100644 --- a/drivers/md/dm-zoned-metadata.c +++ b/drivers/md/dm-zoned-metadata.c @@ -819,7 +819,7 @@ static int dmz_write_sb(struct dmz_metadata *zmd, unsigned int set) ret = dmz_rdwr_block(dev, REQ_OP_WRITE, zmd->sb[set].block, mblk->page); if (ret == 0) - ret = blkdev_issue_flush(dev->bdev, GFP_NOIO); + ret = blkdev_issue_flush(dev->bdev); return ret; } @@ -862,7 +862,7 @@ static int dmz_write_dirty_mblocks(struct dmz_metadata *zmd, /* Flush drive cache (this will also sync data) */ if (ret == 0) - ret = blkdev_issue_flush(dev->bdev, GFP_NOIO); + ret = blkdev_issue_flush(dev->bdev); return ret; } @@ -933,7 +933,7 @@ int dmz_flush_metadata(struct dmz_metadata *zmd) /* If there are no dirty metadata blocks, just flush the device cache */ if (list_empty(&write_list)) { - ret = blkdev_issue_flush(dev->bdev, GFP_NOIO); + ret = blkdev_issue_flush(dev->bdev); goto err; } diff --git a/drivers/md/raid5-ppl.c b/drivers/md/raid5-ppl.c index d0f540296fe91e..e8c118e05dfd46 100644 --- a/drivers/md/raid5-ppl.c +++ b/drivers/md/raid5-ppl.c @@ -1037,7 +1037,7 @@ static int ppl_recover(struct ppl_log *log, struct ppl_header *pplhdr, } /* flush the disk cache after recovery if necessary */ - ret = blkdev_issue_flush(rdev->bdev, GFP_KERNEL); + ret = blkdev_issue_flush(rdev->bdev); out: __free_page(page); return ret; diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c index 125dde3f410ee7..bf6e0ac9ad2890 100644 --- a/drivers/nvme/target/io-cmd-bdev.c +++ b/drivers/nvme/target/io-cmd-bdev.c @@ -333,7 +333,7 @@ static void nvmet_bdev_execute_flush(struct nvmet_req *req) u16 nvmet_bdev_flush(struct nvmet_req *req) { - if (blkdev_issue_flush(req->ns->bdev, GFP_KERNEL)) + if (blkdev_issue_flush(req->ns->bdev)) return NVME_SC_INTERNAL | NVME_SC_DNR; return 0; } diff --git a/fs/block_dev.c b/fs/block_dev.c index 6f5bd9950baf45..bc957ef7cebaae 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -681,7 +681,7 @@ int blkdev_fsync(struct file *filp, loff_t start, loff_t end, int datasync) * i_mutex and doing so causes performance issues with concurrent * O_SYNC writers to a block device. */ - error = blkdev_issue_flush(bdev, GFP_KERNEL); + error = blkdev_issue_flush(bdev); if (error == -EOPNOTSUPP) error = 0; diff --git a/fs/exfat/file.c b/fs/exfat/file.c index a92478eabfa4e4..183ffdf4d43c5f 100644 --- a/fs/exfat/file.c +++ b/fs/exfat/file.c @@ -361,7 +361,7 @@ int exfat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync) if (err) return err; - return blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL); + return blkdev_issue_flush(inode->i_sb->s_bdev); } const struct file_operations exfat_file_operations = { diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index 0a14a7c87bf82e..6e8208acfc62ac 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -1076,7 +1076,7 @@ static int ext4_fc_perform_commit(journal_t *journal) * flush before we start writing fast commit blocks. */ if (journal->j_fs_dev != journal->j_dev) - blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS); + blkdev_issue_flush(journal->j_fs_dev); blk_start_plug(&plug); if (sbi->s_fc_bytes == 0) { @@ -1535,7 +1535,7 @@ static int ext4_fc_replay_inode(struct super_block *sb, struct ext4_fc_tl *tl) out: iput(inode); if (!ret) - blkdev_issue_flush(sb->s_bdev, GFP_KERNEL); + blkdev_issue_flush(sb->s_bdev); return 0; } diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c index 113bfb023a4a09..027a7d7037a07b 100644 --- a/fs/ext4/fsync.c +++ b/fs/ext4/fsync.c @@ -174,7 +174,7 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync) ret = ext4_fsync_journal(inode, datasync, &needs_barrier); if (needs_barrier) { - err = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL); + err = blkdev_issue_flush(inode->i_sb->s_bdev); if (!ret) ret = err; } diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index b215c564bc318a..20f2fcb799f55f 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c @@ -1583,7 +1583,7 @@ int ext4_init_inode_table(struct super_block *sb, ext4_group_t group, if (ret < 0) goto err_out; if (barrier) - blkdev_issue_flush(sb->s_bdev, GFP_NOFS); + blkdev_issue_flush(sb->s_bdev); skip_zeroout: ext4_lock_group(sb, group); diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 9a6f9875aa3499..fb5985102c1db7 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5709,7 +5709,7 @@ static int ext4_sync_fs(struct super_block *sb, int wait) needs_barrier = true; if (needs_barrier) { int err; - err = blkdev_issue_flush(sb->s_bdev, GFP_KERNEL); + err = blkdev_issue_flush(sb->s_bdev); if (!ret) ret = err; } diff --git a/fs/fat/file.c b/fs/fat/file.c index f9ee27cf4d7c2f..5fee74f1ad611d 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c @@ -195,7 +195,7 @@ int fat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync) if (err) return err; - return blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL); + return blkdev_issue_flush(inode->i_sb->s_bdev); } diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c index e3da9e96b83578..ca464328b79cc5 100644 --- a/fs/hfsplus/inode.c +++ b/fs/hfsplus/inode.c @@ -340,7 +340,7 @@ int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end, } if (!test_bit(HFSPLUS_SB_NOBARRIER, &sbi->flags)) - blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL); + blkdev_issue_flush(inode->i_sb->s_bdev); inode_unlock(inode); diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index 807119ae5adf73..b9e3db3f855f96 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c @@ -239,7 +239,7 @@ static int hfsplus_sync_fs(struct super_block *sb, int wait) mutex_unlock(&sbi->vh_mutex); if (!test_bit(HFSPLUS_SB_NOBARRIER, &sbi->flags)) - blkdev_issue_flush(sb->s_bdev, GFP_KERNEL); + blkdev_issue_flush(sb->s_bdev); return error; } diff --git a/fs/jbd2/checkpoint.c b/fs/jbd2/checkpoint.c index 472932b9e6bca9..63b526d44886d0 100644 --- a/fs/jbd2/checkpoint.c +++ b/fs/jbd2/checkpoint.c @@ -416,7 +416,7 @@ int jbd2_cleanup_journal_tail(journal_t *journal) * jbd2_cleanup_journal_tail() doesn't get called all that often. */ if (journal->j_flags & JBD2_BARRIER) - blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS); + blkdev_issue_flush(journal->j_fs_dev); return __jbd2_update_log_tail(journal, first_tid, blocknr); } diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c index b121d7d434c675..3cc4ab2ba7f4f2 100644 --- a/fs/jbd2/commit.c +++ b/fs/jbd2/commit.c @@ -825,7 +825,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) if (commit_transaction->t_need_data_flush && (journal->j_fs_dev != journal->j_dev) && (journal->j_flags & JBD2_BARRIER)) - blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS); + blkdev_issue_flush(journal->j_fs_dev); /* Done it all: now write the commit record asynchronously. */ if (jbd2_has_feature_async_commit(journal)) { @@ -932,7 +932,7 @@ void jbd2_journal_commit_transaction(journal_t *journal) stats.run.rs_blocks_logged++; if (jbd2_has_feature_async_commit(journal) && journal->j_flags & JBD2_BARRIER) { - blkdev_issue_flush(journal->j_dev, GFP_NOFS); + blkdev_issue_flush(journal->j_dev); } if (err) diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c index dc0694fcfcd123..69f18fe2092369 100644 --- a/fs/jbd2/recovery.c +++ b/fs/jbd2/recovery.c @@ -326,7 +326,7 @@ int jbd2_journal_recover(journal_t *journal) err = err2; /* Make sure all replayed data is on permanent storage */ if (journal->j_flags & JBD2_BARRIER) { - err2 = blkdev_issue_flush(journal->j_fs_dev, GFP_KERNEL); + err2 = blkdev_issue_flush(journal->j_fs_dev); if (!err) err = err2; } diff --git a/fs/libfs.c b/fs/libfs.c index d1c3bade9f30dd..8398a0efb401c6 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1117,7 +1117,7 @@ int generic_file_fsync(struct file *file, loff_t start, loff_t end, err = __generic_file_fsync(file, start, end, datasync); if (err) return err; - return blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL); + return blkdev_issue_flush(inode->i_sb->s_bdev); } EXPORT_SYMBOL(generic_file_fsync); diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h index b55cdeb4d16991..987c8ab02aeee6 100644 --- a/fs/nilfs2/the_nilfs.h +++ b/fs/nilfs2/the_nilfs.h @@ -375,7 +375,7 @@ static inline int nilfs_flush_device(struct the_nilfs *nilfs) */ smp_wmb(); - err = blkdev_issue_flush(nilfs->ns_bdev, GFP_KERNEL); + err = blkdev_issue_flush(nilfs->ns_bdev); if (err != -EIO) err = 0; return err; diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 85979e2214b39d..df6d709d2ae3b6 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -194,7 +194,7 @@ static int ocfs2_sync_file(struct file *file, loff_t start, loff_t end, needs_barrier = true; err = jbd2_complete_transaction(journal, commit_tid); if (needs_barrier) { - ret = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL); + ret = blkdev_issue_flush(inode->i_sb->s_bdev); if (!err) err = ret; } diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c index 0b641ae694f123..1db0254bc38b26 100644 --- a/fs/reiserfs/file.c +++ b/fs/reiserfs/file.c @@ -159,7 +159,7 @@ static int reiserfs_sync_file(struct file *filp, loff_t start, loff_t end, barrier_done = reiserfs_commit_for_inode(inode); reiserfs_write_unlock(inode->i_sb); if (barrier_done != 1 && reiserfs_barrier_flush(inode->i_sb)) - blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL); + blkdev_issue_flush(inode->i_sb->s_bdev); inode_unlock(inode); if (barrier_done < 0) return barrier_done; diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 813be879a5e51d..c3e32789829f90 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -342,7 +342,7 @@ void xfs_blkdev_issue_flush( xfs_buftarg_t *buftarg) { - blkdev_issue_flush(buftarg->bt_bdev, GFP_NOFS); + blkdev_issue_flush(buftarg->bt_bdev); } STATIC void diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c index faea2ed34b4a37..ab68e27bb322e0 100644 --- a/fs/zonefs/super.c +++ b/fs/zonefs/super.c @@ -541,7 +541,7 @@ static int zonefs_file_fsync(struct file *file, loff_t start, loff_t end, if (ZONEFS_I(inode)->i_ztype == ZONEFS_ZTYPE_CNV) ret = file_write_and_wait_range(file, start, end); if (!ret) - ret = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL); + ret = blkdev_issue_flush(inode->i_sb->s_bdev); if (ret) zonefs_io_error(inode, true); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 20f3706b6b2e68..09f7ac5507d146 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1288,7 +1288,7 @@ static inline bool blk_needs_flush_plug(struct task_struct *tsk) !list_empty(&plug->cb_list)); } -int blkdev_issue_flush(struct block_device *, gfp_t); +int blkdev_issue_flush(struct block_device *bdev); long nr_blockdev_pages(void); #else /* CONFIG_BLOCK */ struct blk_plug { @@ -1316,7 +1316,7 @@ static inline bool blk_needs_flush_plug(struct task_struct *tsk) return false; } -static inline int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask) +static inline int blkdev_issue_flush(struct block_device *bdev) { return 0; } -- 2.29.2
Use blkdev_issue_flush instead of open coding it. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/md/dm-clone-target.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/md/dm-clone-target.c b/drivers/md/dm-clone-target.c index bdb255edc20043..a90bdf9b2ca6bd 100644 --- a/drivers/md/dm-clone-target.c +++ b/drivers/md/dm-clone-target.c @@ -85,12 +85,6 @@ struct clone { struct dm_clone_metadata *cmd; - /* - * bio used to flush the destination device, before committing the - * metadata. - */ - struct bio flush_bio; - /* Region hydration hash table */ struct hash_table_bucket *ht; @@ -1155,11 +1149,7 @@ static int commit_metadata(struct clone *clone, bool *dest_dev_flushed) goto out; } - bio_reset(&clone->flush_bio); - bio_set_dev(&clone->flush_bio, clone->dest_dev->bdev); - clone->flush_bio.bi_opf = REQ_OP_WRITE | REQ_PREFLUSH; - - r = submit_bio_wait(&clone->flush_bio); + r = blkdev_issue_flush(clone->dest_dev->bdev); if (unlikely(r)) { __metadata_operation_failed(clone, "flush destination device", r); goto out; @@ -1886,7 +1876,6 @@ static int clone_ctr(struct dm_target *ti, unsigned int argc, char **argv) bio_list_init(&clone->deferred_flush_completions); clone->hydration_offset = 0; atomic_set(&clone->hydrations_in_flight, 0); - bio_init(&clone->flush_bio, NULL, 0); clone->wq = alloc_workqueue("dm-" DM_MSG_PREFIX, WQ_MEM_RECLAIM, 0); if (!clone->wq) { @@ -1958,7 +1947,6 @@ static void clone_dtr(struct dm_target *ti) struct clone *clone = ti->private; mutex_destroy(&clone->commit_lock); - bio_uninit(&clone->flush_bio); for (i = 0; i < clone->nr_ctr_args; i++) kfree(clone->ctr_args[i]); -- 2.29.2
Use the blkdev_issue_flush helper instead of duplicating it. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/f2fs/data.c | 3 ++- fs/f2fs/f2fs.h | 1 - fs/f2fs/segment.c | 12 +----------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 8cbf0315975228..0cf0c605992431 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -56,7 +56,8 @@ static inline struct bio *__f2fs_bio_alloc(gfp_t gfp_mask, return bio_alloc_bioset(gfp_mask, nr_iovecs, &f2fs_bioset); } -struct bio *f2fs_bio_alloc(struct f2fs_sb_info *sbi, int npages, bool noio) +static struct bio *f2fs_bio_alloc(struct f2fs_sb_info *sbi, int npages, + bool noio) { if (noio) { /* No failure on bio allocation */ diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index bb11759191dcc9..902bd3267c03e1 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3424,7 +3424,6 @@ void f2fs_destroy_checkpoint_caches(void); */ int __init f2fs_init_bioset(void); void f2fs_destroy_bioset(void); -struct bio *f2fs_bio_alloc(struct f2fs_sb_info *sbi, int npages, bool noio); int f2fs_init_bio_entry_cache(void); void f2fs_destroy_bio_entry_cache(void); void f2fs_submit_bio(struct f2fs_sb_info *sbi, diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index deca74cb17dfd8..c495f170ee400b 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -566,17 +566,7 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi, bool from_bg) static int __submit_flush_wait(struct f2fs_sb_info *sbi, struct block_device *bdev) { - struct bio *bio; - int ret; - - bio = f2fs_bio_alloc(sbi, 0, false); - if (!bio) - return -ENOMEM; - - bio->bi_opf = REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH; - bio_set_dev(bio, bdev); - ret = submit_bio_wait(bio); - bio_put(bio); + int ret = blkdev_issue_flush(bdev); trace_f2fs_issue_flush(bdev, test_opt(sbi, NOBARRIER), test_opt(sbi, FLUSH_MERGE), ret); -- 2.29.2
Sleeping bio allocations do not fail, which means that injecting an error into sleeping bio allocations is a little silly. Signed-off-by: Christoph Hellwig <hch@lst.de> --- Documentation/filesystems/f2fs.rst | 1 - fs/f2fs/data.c | 29 ++++------------------------- fs/f2fs/f2fs.h | 1 - fs/f2fs/super.c | 1 - 4 files changed, 4 insertions(+), 28 deletions(-) diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst index dae15c96e659e2..624f5f3ed93e86 100644 --- a/Documentation/filesystems/f2fs.rst +++ b/Documentation/filesystems/f2fs.rst @@ -179,7 +179,6 @@ fault_type=%d Support configuring fault injection type, should be FAULT_KVMALLOC 0x000000002 FAULT_PAGE_ALLOC 0x000000004 FAULT_PAGE_GET 0x000000008 - FAULT_ALLOC_BIO 0x000000010 FAULT_ALLOC_NID 0x000000020 FAULT_ORPHAN 0x000000040 FAULT_BLOCK 0x000000080 diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 0cf0c605992431..9fb6be65592b1f 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -50,28 +50,6 @@ void f2fs_destroy_bioset(void) bioset_exit(&f2fs_bioset); } -static inline struct bio *__f2fs_bio_alloc(gfp_t gfp_mask, - unsigned int nr_iovecs) -{ - return bio_alloc_bioset(gfp_mask, nr_iovecs, &f2fs_bioset); -} - -static struct bio *f2fs_bio_alloc(struct f2fs_sb_info *sbi, int npages, - bool noio) -{ - if (noio) { - /* No failure on bio allocation */ - return __f2fs_bio_alloc(GFP_NOIO, npages); - } - - if (time_to_inject(sbi, FAULT_ALLOC_BIO)) { - f2fs_show_injection_info(sbi, FAULT_ALLOC_BIO); - return NULL; - } - - return __f2fs_bio_alloc(GFP_KERNEL, npages); -} - static bool __is_cp_guaranteed(struct page *page) { struct address_space *mapping = page->mapping; @@ -433,7 +411,7 @@ static struct bio *__bio_alloc(struct f2fs_io_info *fio, int npages) struct f2fs_sb_info *sbi = fio->sbi; struct bio *bio; - bio = f2fs_bio_alloc(sbi, npages, true); + bio = bio_alloc_bioset(GFP_NOIO, npages, &f2fs_bioset); f2fs_target_device(sbi, fio->new_blkaddr, bio); if (is_read_io(fio->op)) { @@ -1029,8 +1007,9 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr, struct bio_post_read_ctx *ctx; unsigned int post_read_steps = 0; - bio = f2fs_bio_alloc(sbi, min_t(int, nr_pages, BIO_MAX_PAGES), - for_write); + bio = bio_alloc_bioset(for_write ? GFP_NOIO : GFP_KERNEL, + min_t(int, nr_pages, BIO_MAX_PAGES), + &f2fs_bioset); if (!bio) return ERR_PTR(-ENOMEM); diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 902bd3267c03e1..6c78365d80ceb5 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -43,7 +43,6 @@ enum { FAULT_KVMALLOC, FAULT_PAGE_ALLOC, FAULT_PAGE_GET, - FAULT_ALLOC_BIO, FAULT_ALLOC_NID, FAULT_ORPHAN, FAULT_BLOCK, diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index b4a07fe62d1a58..3a312642907e86 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -45,7 +45,6 @@ const char *f2fs_fault_name[FAULT_MAX] = { [FAULT_KVMALLOC] = "kvmalloc", [FAULT_PAGE_ALLOC] = "page alloc", [FAULT_PAGE_GET] = "page get", - [FAULT_ALLOC_BIO] = "alloc bio", [FAULT_ALLOC_NID] = "alloc nid", [FAULT_ORPHAN] = "orphan", [FAULT_BLOCK] = "no more block", -- 2.29.2
Given that drbd_md_io_bio_set is initialized during module initialization and the module fails to load if the initialization fails there is no need to fall back to plain bio_alloc. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/block/drbd/drbd_actlog.c | 2 +- drivers/block/drbd/drbd_bitmap.c | 2 +- drivers/block/drbd/drbd_int.h | 2 -- drivers/block/drbd/drbd_main.c | 13 ------------- 4 files changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c index 7227fc7ab8ed1e..72cf7603d51fc7 100644 --- a/drivers/block/drbd/drbd_actlog.c +++ b/drivers/block/drbd/drbd_actlog.c @@ -138,7 +138,7 @@ static int _drbd_md_sync_page_io(struct drbd_device *device, op_flags |= REQ_FUA | REQ_PREFLUSH; op_flags |= REQ_SYNC; - bio = bio_alloc_drbd(GFP_NOIO); + bio = bio_alloc_bioset(GFP_NOIO, 1, &drbd_md_io_bio_set); bio_set_dev(bio, bdev->md_bdev); bio->bi_iter.bi_sector = sector; err = -EIO; diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c index df53dca5d02c7e..c1f816f896a89a 100644 --- a/drivers/block/drbd/drbd_bitmap.c +++ b/drivers/block/drbd/drbd_bitmap.c @@ -976,7 +976,7 @@ static void drbd_bm_endio(struct bio *bio) static void bm_page_io_async(struct drbd_bm_aio_ctx *ctx, int page_nr) __must_hold(local) { - struct bio *bio = bio_alloc_drbd(GFP_NOIO); + struct bio *bio = bio_alloc_bioset(GFP_NOIO, 1, &drbd_md_io_bio_set); struct drbd_device *device = ctx->device; struct drbd_bitmap *b = device->bitmap; struct page *page; diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h index b2c93a29c251fd..02db50d7e4c668 100644 --- a/drivers/block/drbd/drbd_int.h +++ b/drivers/block/drbd/drbd_int.h @@ -1422,8 +1422,6 @@ extern mempool_t drbd_md_io_page_pool; /* We also need to make sure we get a bio * when we need it for housekeeping purposes */ extern struct bio_set drbd_md_io_bio_set; -/* to allocate from that set */ -extern struct bio *bio_alloc_drbd(gfp_t gfp_mask); /* And a bio_set for cloning */ extern struct bio_set drbd_io_bio_set; diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 1c8c18b2a25f33..788dd97e6026b8 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c @@ -138,19 +138,6 @@ static const struct block_device_operations drbd_ops = { .release = drbd_release, }; -struct bio *bio_alloc_drbd(gfp_t gfp_mask) -{ - struct bio *bio; - - if (!bioset_initialized(&drbd_md_io_bio_set)) - return bio_alloc(gfp_mask, 1); - - bio = bio_alloc_bioset(gfp_mask, 1, &drbd_md_io_bio_set); - if (!bio) - return NULL; - return bio; -} - #ifdef __CHECKER__ /* When checking with sparse, and this is an inline function, sparse will give tons of false positives. When this is a real functions sparse works. -- 2.29.2
Open code drbd_req_make_private_bio in the two callers to prepare for further changes. Also don't bother to initialize bi_next as the bio code already does that that. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/block/drbd/drbd_req.c | 5 ++++- drivers/block/drbd/drbd_req.h | 12 ------------ drivers/block/drbd/drbd_worker.c | 5 ++++- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/block/drbd/drbd_req.c b/drivers/block/drbd/drbd_req.c index ea0f31ab334361..9dbb660a7d7c8e 100644 --- a/drivers/block/drbd/drbd_req.c +++ b/drivers/block/drbd/drbd_req.c @@ -30,7 +30,10 @@ static struct drbd_request *drbd_req_new(struct drbd_device *device, struct bio return NULL; memset(req, 0, sizeof(*req)); - drbd_req_make_private_bio(req, bio_src); + req->private_bio = bio_clone_fast(bio_src, GFP_NOIO, &drbd_io_bio_set); + req->private_bio->bi_private = req; + req->private_bio->bi_end_io = drbd_request_endio; + req->rq_state = (bio_data_dir(bio_src) == WRITE ? RQ_WRITE : 0) | (bio_op(bio_src) == REQ_OP_WRITE_SAME ? RQ_WSAME : 0) | (bio_op(bio_src) == REQ_OP_WRITE_ZEROES ? RQ_ZEROES : 0) diff --git a/drivers/block/drbd/drbd_req.h b/drivers/block/drbd/drbd_req.h index 55bb0f8721faa3..511f39a08de453 100644 --- a/drivers/block/drbd/drbd_req.h +++ b/drivers/block/drbd/drbd_req.h @@ -256,18 +256,6 @@ enum drbd_req_state_bits { #define MR_WRITE 1 #define MR_READ 2 -static inline void drbd_req_make_private_bio(struct drbd_request *req, struct bio *bio_src) -{ - struct bio *bio; - bio = bio_clone_fast(bio_src, GFP_NOIO, &drbd_io_bio_set); - - req->private_bio = bio; - - bio->bi_private = req; - bio->bi_end_io = drbd_request_endio; - bio->bi_next = NULL; -} - /* Short lived temporary struct on the stack. * We could squirrel the error to be returned into * bio->bi_iter.bi_size, or similar. But that would be too ugly. */ diff --git a/drivers/block/drbd/drbd_worker.c b/drivers/block/drbd/drbd_worker.c index 02044ab7f767d5..64563bfdf0da02 100644 --- a/drivers/block/drbd/drbd_worker.c +++ b/drivers/block/drbd/drbd_worker.c @@ -1523,8 +1523,11 @@ int w_restart_disk_io(struct drbd_work *w, int cancel) if (bio_data_dir(req->master_bio) == WRITE && req->rq_state & RQ_IN_ACT_LOG) drbd_al_begin_io(device, &req->i); - drbd_req_make_private_bio(req, req->master_bio); + req->private_bio = bio_clone_fast(req->master_bio, GFP_NOIO, + &drbd_io_bio_set); bio_set_dev(req->private_bio, device->ldev->backing_bdev); + req->private_bio->bi_private = req; + req->private_bio->bi_end_io = drbd_request_endio; submit_bio_noacct(req->private_bio); return 0; -- 2.29.2
bio_alloc_mddev is never called with a NULL mddev, and ->bio_set is initialized in md_run, so it always must be initialized as well. Just open code the remaining call to bio_alloc_bioset. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/md/md.c | 12 +----------- drivers/md/md.h | 2 -- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 2 +- 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 7d1bb24add3107..e2b9dbb6e888f6 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -340,16 +340,6 @@ static int start_readonly; */ static bool create_on_open = true; -struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs, - struct mddev *mddev) -{ - if (!mddev || !bioset_initialized(&mddev->bio_set)) - return bio_alloc(gfp_mask, nr_iovecs); - - return bio_alloc_bioset(gfp_mask, nr_iovecs, &mddev->bio_set); -} -EXPORT_SYMBOL_GPL(bio_alloc_mddev); - static struct bio *md_bio_alloc_sync(struct mddev *mddev) { if (!mddev || !bioset_initialized(&mddev->sync_set)) @@ -613,7 +603,7 @@ static void submit_flushes(struct work_struct *ws) atomic_inc(&rdev->nr_pending); atomic_inc(&rdev->nr_pending); rcu_read_unlock(); - bi = bio_alloc_mddev(GFP_NOIO, 0, mddev); + bi = bio_alloc_bioset(GFP_NOIO, 0, &mddev->bio_set); bi->bi_end_io = md_end_flush; bi->bi_private = rdev; bio_set_dev(bi, rdev->bdev); diff --git a/drivers/md/md.h b/drivers/md/md.h index f13290ccc1c248..bcbba1b5ec4a71 100644 --- a/drivers/md/md.h +++ b/drivers/md/md.h @@ -742,8 +742,6 @@ extern void md_rdev_clear(struct md_rdev *rdev); extern void md_handle_request(struct mddev *mddev, struct bio *bio); extern void mddev_suspend(struct mddev *mddev); extern void mddev_resume(struct mddev *mddev); -extern struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs, - struct mddev *mddev); extern void md_reload_sb(struct mddev *mddev, int raid_disk); extern void md_update_sb(struct mddev *mddev, int force); diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 3b19141cdb4bc2..d2378765dc154f 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1104,7 +1104,7 @@ static void alloc_behind_master_bio(struct r1bio *r1_bio, int i = 0; struct bio *behind_bio = NULL; - behind_bio = bio_alloc_mddev(GFP_NOIO, vcnt, r1_bio->mddev); + behind_bio = bio_alloc_bioset(GFP_NOIO, vcnt, &r1_bio->mddev->bio_set); if (!behind_bio) return; diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index be8f14afb6d143..e1eefbec15d444 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -4531,7 +4531,7 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, return sectors_done; } - read_bio = bio_alloc_mddev(GFP_KERNEL, RESYNC_PAGES, mddev); + read_bio = bio_alloc_bioset(GFP_KERNEL, RESYNC_PAGES, &mddev->bio_set); bio_set_dev(read_bio, rdev->bdev); read_bio->bi_iter.bi_sector = (r10_bio->devs[r10_bio->read_slot].addr -- 2.29.2
Use an on-stack bio and biovec for the single page synchronous I/O. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/md/md.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index e2b9dbb6e888f6..6a27f52007c871 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -1021,29 +1021,29 @@ int md_super_wait(struct mddev *mddev) int sync_page_io(struct md_rdev *rdev, sector_t sector, int size, struct page *page, int op, int op_flags, bool metadata_op) { - struct bio *bio = md_bio_alloc_sync(rdev->mddev); - int ret; + struct bio bio; + struct bio_vec bvec; + + bio_init(&bio, &bvec, 1); if (metadata_op && rdev->meta_bdev) - bio_set_dev(bio, rdev->meta_bdev); + bio_set_dev(&bio, rdev->meta_bdev); else - bio_set_dev(bio, rdev->bdev); - bio_set_op_attrs(bio, op, op_flags); + bio_set_dev(&bio, rdev->bdev); + bio.bi_opf = op | op_flags; if (metadata_op) - bio->bi_iter.bi_sector = sector + rdev->sb_start; + bio.bi_iter.bi_sector = sector + rdev->sb_start; else if (rdev->mddev->reshape_position != MaxSector && (rdev->mddev->reshape_backwards == (sector >= rdev->mddev->reshape_position))) - bio->bi_iter.bi_sector = sector + rdev->new_data_offset; + bio.bi_iter.bi_sector = sector + rdev->new_data_offset; else - bio->bi_iter.bi_sector = sector + rdev->data_offset; - bio_add_page(bio, page, size, 0); + bio.bi_iter.bi_sector = sector + rdev->data_offset; + bio_add_page(&bio, page, size, 0); - submit_bio_wait(bio); + submit_bio_wait(&bio); - ret = !bio->bi_status; - bio_put(bio); - return ret; + return !bio.bi_status; } EXPORT_SYMBOL_GPL(sync_page_io); -- 2.29.2
md_bio_alloc_sync is never called with a NULL mddev, and ->sync_set is initialized in md_run, so it always must be initialized as well. Just open code the remaining call to bio_alloc_bioset. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/md/md.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/md/md.c b/drivers/md/md.c index 6a27f52007c871..399c81bddc1ae1 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -340,14 +340,6 @@ static int start_readonly; */ static bool create_on_open = true; -static struct bio *md_bio_alloc_sync(struct mddev *mddev) -{ - if (!mddev || !bioset_initialized(&mddev->sync_set)) - return bio_alloc(GFP_NOIO, 1); - - return bio_alloc_bioset(GFP_NOIO, 1, &mddev->sync_set); -} - /* * We have a system wide 'event count' that is incremented * on any 'interesting' event, and readers of /proc/mdstat @@ -989,7 +981,7 @@ void md_super_write(struct mddev *mddev, struct md_rdev *rdev, if (test_bit(Faulty, &rdev->flags)) return; - bio = md_bio_alloc_sync(mddev); + bio = bio_alloc_bioset(GFP_NOIO, 1, &mddev->sync_set); atomic_inc(&rdev->nr_pending); -- 2.29.2
Refactor raid5_read_one_chunk so that all simple checks are done before allocating the bio. Signed-off-by: Christoph Hellwig <hch@lst.de> --- drivers/md/raid5.c | 108 +++++++++++++++++++-------------------------- 1 file changed, 45 insertions(+), 63 deletions(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index f411b9e5c332f4..a348b2adf2a9f9 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -5393,90 +5393,72 @@ static void raid5_align_endio(struct bio *bi) static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio) { struct r5conf *conf = mddev->private; - int dd_idx; - struct bio* align_bi; + struct bio *align_bio; struct md_rdev *rdev; - sector_t end_sector; + sector_t sector, end_sector, first_bad; + int bad_sectors, dd_idx; if (!in_chunk_boundary(mddev, raid_bio)) { pr_debug("%s: non aligned\n", __func__); return 0; } - /* - * use bio_clone_fast to make a copy of the bio - */ - align_bi = bio_clone_fast(raid_bio, GFP_NOIO, &mddev->bio_set); - if (!align_bi) - return 0; - /* - * set bi_end_io to a new function, and set bi_private to the - * original bio. - */ - align_bi->bi_end_io = raid5_align_endio; - align_bi->bi_private = raid_bio; - /* - * compute position - */ - align_bi->bi_iter.bi_sector = - raid5_compute_sector(conf, raid_bio->bi_iter.bi_sector, - 0, &dd_idx, NULL); - end_sector = bio_end_sector(align_bi); + sector = raid5_compute_sector(conf, raid_bio->bi_iter.bi_sector, 0, + &dd_idx, NULL); + end_sector = bio_end_sector(raid_bio); + rcu_read_lock(); + if (r5c_big_stripe_cached(conf, sector)) + goto out_rcu_unlock; + rdev = rcu_dereference(conf->disks[dd_idx].replacement); if (!rdev || test_bit(Faulty, &rdev->flags) || rdev->recovery_offset < end_sector) { rdev = rcu_dereference(conf->disks[dd_idx].rdev); - if (rdev && - (test_bit(Faulty, &rdev->flags) || + if (!rdev) + goto out_rcu_unlock; + if (test_bit(Faulty, &rdev->flags) || !(test_bit(In_sync, &rdev->flags) || - rdev->recovery_offset >= end_sector))) - rdev = NULL; + rdev->recovery_offset >= end_sector)) + goto out_rcu_unlock; } - if (r5c_big_stripe_cached(conf, align_bi->bi_iter.bi_sector)) { - rcu_read_unlock(); - bio_put(align_bi); + atomic_inc(&rdev->nr_pending); + rcu_read_unlock(); + + align_bio = bio_clone_fast(raid_bio, GFP_NOIO, &mddev->bio_set); + bio_set_dev(align_bio, rdev->bdev); + align_bio->bi_end_io = raid5_align_endio; + align_bio->bi_private = raid_bio; + align_bio->bi_iter.bi_sector = sector; + + raid_bio->bi_next = (void *)rdev; + + if (is_badblock(rdev, sector, bio_sectors(align_bio), &first_bad, + &bad_sectors)) { + bio_put(align_bio); + rdev_dec_pending(rdev, mddev); return 0; } - if (rdev) { - sector_t first_bad; - int bad_sectors; - - atomic_inc(&rdev->nr_pending); - rcu_read_unlock(); - raid_bio->bi_next = (void*)rdev; - bio_set_dev(align_bi, rdev->bdev); - - if (is_badblock(rdev, align_bi->bi_iter.bi_sector, - bio_sectors(align_bi), - &first_bad, &bad_sectors)) { - bio_put(align_bi); - rdev_dec_pending(rdev, mddev); - return 0; - } + /* No reshape active, so we can trust rdev->data_offset */ + align_bio->bi_iter.bi_sector += rdev->data_offset; - /* No reshape active, so we can trust rdev->data_offset */ - align_bi->bi_iter.bi_sector += rdev->data_offset; + spin_lock_irq(&conf->device_lock); + wait_event_lock_irq(conf->wait_for_quiescent, conf->quiesce == 0, + conf->device_lock); + atomic_inc(&conf->active_aligned_reads); + spin_unlock_irq(&conf->device_lock); - spin_lock_irq(&conf->device_lock); - wait_event_lock_irq(conf->wait_for_quiescent, - conf->quiesce == 0, - conf->device_lock); - atomic_inc(&conf->active_aligned_reads); - spin_unlock_irq(&conf->device_lock); + if (mddev->gendisk) + trace_block_bio_remap(align_bio, disk_devt(mddev->gendisk), + raid_bio->bi_iter.bi_sector); + submit_bio_noacct(align_bio); + return 1; - if (mddev->gendisk) - trace_block_bio_remap(align_bi, disk_devt(mddev->gendisk), - raid_bio->bi_iter.bi_sector); - submit_bio_noacct(align_bi); - return 1; - } else { - rcu_read_unlock(); - bio_put(align_bi); - return 0; - } +out_rcu_unlock: + rcu_read_unlock(); + return 0; } static struct bio *chunk_aligned_read(struct mddev *mddev, struct bio *raid_bio) -- 2.29.2
bio_alloc never returns NULL when it can sleep. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/nfs/blocklayout/blocklayout.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c index 3be6836074ae92..1a96ce28efb026 100644 --- a/fs/nfs/blocklayout/blocklayout.c +++ b/fs/nfs/blocklayout/blocklayout.c @@ -123,11 +123,6 @@ bl_alloc_init_bio(int npg, struct block_device *bdev, sector_t disk_sector, npg = min(npg, BIO_MAX_PAGES); bio = bio_alloc(GFP_NOIO, npg); - if (!bio && (current->flags & PF_MEMALLOC)) { - while (!bio && (npg /= 2)) - bio = bio_alloc(GFP_NOIO, npg); - } - if (bio) { bio->bi_iter.bi_sector = disk_sector; bio_set_dev(bio, bdev); -- 2.29.2
bio_alloc never returns NULL when it can sleep. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/nilfs2/segbuf.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c index 1a8729eded8b14..1e75417bfe6e52 100644 --- a/fs/nilfs2/segbuf.c +++ b/fs/nilfs2/segbuf.c @@ -386,10 +386,6 @@ static struct bio *nilfs_alloc_seg_bio(struct the_nilfs *nilfs, sector_t start, struct bio *bio; bio = bio_alloc(GFP_NOIO, nr_vecs); - if (bio == NULL) { - while (!bio && (nr_vecs >>= 1)) - bio = bio_alloc(GFP_NOIO, nr_vecs); - } if (likely(bio)) { bio_set_dev(bio, nilfs->ns_bdev); bio->bi_iter.bi_sector = -- 2.29.2
Just reuse the block_device and sector from the swap_info structure, just as used by the SWP_SYNCHRONOUS path. Also remove the checks for NULL returns from bio_alloc as that can't happen for sleeping allocations. Signed-off-by: Christoph Hellwig <hch@lst.de> --- include/linux/swap.h | 1 - mm/page_io.c | 45 +++++++++++++------------------------------- mm/swapfile.c | 10 ---------- 3 files changed, 13 insertions(+), 43 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 596bc2f4d9b03e..3f1f7ae0fbe9e1 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -468,7 +468,6 @@ extern int free_swap_and_cache(swp_entry_t); int swap_type_of(dev_t device, sector_t offset); int find_first_swap(dev_t *device); extern unsigned int count_swap_pages(int, int); -extern sector_t map_swap_page(struct page *, struct block_device **); extern sector_t swapdev_block(int, pgoff_t); extern int page_swapcount(struct page *); extern int __swap_count(swp_entry_t entry); diff --git a/mm/page_io.c b/mm/page_io.c index a75f35464a4e73..92f7941c6d018b 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -26,25 +26,6 @@ #include <linux/uio.h> #include <linux/sched/task.h> -static struct bio *get_swap_bio(gfp_t gfp_flags, - struct page *page, bio_end_io_t end_io) -{ - struct bio *bio; - - bio = bio_alloc(gfp_flags, 1); - if (bio) { - struct block_device *bdev; - - bio->bi_iter.bi_sector = map_swap_page(page, &bdev); - bio_set_dev(bio, bdev); - bio->bi_iter.bi_sector <<= PAGE_SHIFT - 9; - bio->bi_end_io = end_io; - - bio_add_page(bio, page, thp_size(page), 0); - } - return bio; -} - void end_swap_bio_write(struct bio *bio) { struct page *page = bio_first_page_all(bio); @@ -361,13 +342,13 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, return 0; } - bio = get_swap_bio(GFP_NOIO, page, end_write_func); - if (bio == NULL) { - set_page_dirty(page); - unlock_page(page); - return -ENOMEM; - } + bio = bio_alloc(GFP_NOIO, 1); + bio_set_dev(bio, sis->bdev); + bio->bi_iter.bi_sector = swap_page_sector(page); bio->bi_opf = REQ_OP_WRITE | REQ_SWAP | wbc_to_write_flags(wbc); + bio->bi_end_io = end_write_func; + bio_add_page(bio, page, thp_size(page), 0); + bio_associate_blkg_from_page(bio, page); count_swpout_vm_event(page); set_page_writeback(page); @@ -427,18 +408,18 @@ int swap_readpage(struct page *page, bool synchronous) } ret = 0; - bio = get_swap_bio(GFP_KERNEL, page, end_swap_bio_read); - if (bio == NULL) { - unlock_page(page); - ret = -ENOMEM; - goto out; - } + bio = bio_alloc(GFP_KERNEL, 1); + bio_set_dev(bio, sis->bdev); + bio->bi_opf = REQ_OP_READ; + bio->bi_iter.bi_sector = swap_page_sector(page); + bio->bi_end_io = end_swap_bio_read; + bio_add_page(bio, page, thp_size(page), 0); + disk = bio->bi_bdev->bd_disk; /* * Keep this task valid during swap readpage because the oom killer may * attempt to access it in the page fault retry time check. */ - bio_set_op_attrs(bio, REQ_OP_READ, 0); if (synchronous) { bio->bi_opf |= REQ_HIPRI; get_task_struct(current); diff --git a/mm/swapfile.c b/mm/swapfile.c index 9fffc5af29d1b9..bfa9e8b0c2ef61 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2301,16 +2301,6 @@ static sector_t map_swap_entry(swp_entry_t entry, struct block_device **bdev) return se->start_block + (offset - se->start_page); } -/* - * Returns the page offset into bdev for the specified page's swap entry. - */ -sector_t map_swap_page(struct page *page, struct block_device **bdev) -{ - swp_entry_t entry; - entry.val = page_private(page); - return map_swap_entry(entry, bdev); -} - /* * Free all of a swapdev's extent information */ -- 2.29.2
On 1/26/21 9:52 AM, Christoph Hellwig wrote:
> Use bio_kmalloc instead of open coding it.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
yay I contributed,
Josef
On 26/01/2021 16:01, Christoph Hellwig wrote:
> Use bio_alloc instead of open coding it.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/zonefs/super.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index bec47f2d074beb..faea2ed34b4a37 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -678,7 +678,7 @@ static ssize_t zonefs_file_dio_append(struct kiocb *iocb, struct iov_iter *from)
> if (!nr_pages)
> return 0;
>
> - bio = bio_alloc_bioset(GFP_NOFS, nr_pages, &fs_bio_set);
> + bio = bio_alloc(GFP_NOFS, nr_pages);
> if (!bio)
> return -ENOMEM;
>
>
Whoopsie my bad,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
On 1/26/21 7:01 AM, Christoph Hellwig wrote:
> Use bio_alloc instead of open coding it.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Ha Ha I was going send out a patch for this :P.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
On 1/26/21 7:04 AM, Christoph Hellwig wrote:
> Use bio_kmalloc instead of open coding it.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
On 1/26/21 7:07 AM, Christoph Hellwig wrote:
> There is no point in allocating memory for a synchronous flush.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
True, looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
On 1/26/21 7:27 AM, Christoph Hellwig wrote:
> bio_alloc never returns NULL when it can sleep.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
Looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
On Tue, Jan 26, 2021 at 03:52:33PM +0100, Christoph Hellwig wrote:
> Use bio_kmalloc instead of open coding it.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/blk-crypto-fallback.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c
> index 50c225398e4d60..e8327c50d7c9f4 100644
> --- a/block/blk-crypto-fallback.c
> +++ b/block/blk-crypto-fallback.c
> @@ -164,7 +164,7 @@ static struct bio *blk_crypto_clone_bio(struct bio *bio_src)
> struct bio_vec bv;
> struct bio *bio;
>
> - bio = bio_alloc_bioset(GFP_NOIO, bio_segments(bio_src), NULL);
> + bio = bio_kmalloc(GFP_NOIO, bio_segments(bio_src));
> if (!bio)
> return NULL;
> bio->bi_bdev = bio_src->bi_bdev;
> --
Looks good,
Reviewed-by: Eric Biggers <ebiggers@google.com>
On 2021/01/26 23:58, Christoph Hellwig wrote:
> Use bio_alloc instead of open coding it.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/zonefs/super.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index bec47f2d074beb..faea2ed34b4a37 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -678,7 +678,7 @@ static ssize_t zonefs_file_dio_append(struct kiocb *iocb, struct iov_iter *from)
> if (!nr_pages)
> return 0;
>
> - bio = bio_alloc_bioset(GFP_NOFS, nr_pages, &fs_bio_set);
> + bio = bio_alloc(GFP_NOFS, nr_pages);
> if (!bio)
> return -ENOMEM;
>
>
Acked-by: Damien Le Moal <damien.lemoal@wdc.com>
--
Damien Le Moal
Western Digital Research
On Tue, Jan 26, 2021 at 7:19 AM Christoph Hellwig <hch@lst.de> wrote: > > Refactor raid5_read_one_chunk so that all simple checks are done > before allocating the bio. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Song Liu <song@kernel.org> Thanks for the clean-up! > --- > drivers/md/raid5.c | 108 +++++++++++++++++++-------------------------- > 1 file changed, 45 insertions(+), 63 deletions(-) > > diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c > index f411b9e5c332f4..a348b2adf2a9f9 100644 > --- a/drivers/md/raid5.c > +++ b/drivers/md/raid5.c > @@ -5393,90 +5393,72 @@ static void raid5_align_endio(struct bio *bi) > static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio) > { > struct r5conf *conf = mddev->private; > - int dd_idx; > - struct bio* align_bi; > + struct bio *align_bio; > struct md_rdev *rdev; > - sector_t end_sector; > + sector_t sector, end_sector, first_bad; > + int bad_sectors, dd_idx; > > if (!in_chunk_boundary(mddev, raid_bio)) { > pr_debug("%s: non aligned\n", __func__); > return 0; > } > - /* > - * use bio_clone_fast to make a copy of the bio > - */ > - align_bi = bio_clone_fast(raid_bio, GFP_NOIO, &mddev->bio_set); > - if (!align_bi) > - return 0; > - /* > - * set bi_end_io to a new function, and set bi_private to the > - * original bio. > - */ > - align_bi->bi_end_io = raid5_align_endio; > - align_bi->bi_private = raid_bio; > - /* > - * compute position > - */ > - align_bi->bi_iter.bi_sector = > - raid5_compute_sector(conf, raid_bio->bi_iter.bi_sector, > - 0, &dd_idx, NULL); > > - end_sector = bio_end_sector(align_bi); > + sector = raid5_compute_sector(conf, raid_bio->bi_iter.bi_sector, 0, > + &dd_idx, NULL); > + end_sector = bio_end_sector(raid_bio); > + > rcu_read_lock(); > + if (r5c_big_stripe_cached(conf, sector)) > + goto out_rcu_unlock; > + > rdev = rcu_dereference(conf->disks[dd_idx].replacement); > if (!rdev || test_bit(Faulty, &rdev->flags) || > rdev->recovery_offset < end_sector) { > rdev = rcu_dereference(conf->disks[dd_idx].rdev); > - if (rdev && > - (test_bit(Faulty, &rdev->flags) || > + if (!rdev) > + goto out_rcu_unlock; > + if (test_bit(Faulty, &rdev->flags) || > !(test_bit(In_sync, &rdev->flags) || > - rdev->recovery_offset >= end_sector))) > - rdev = NULL; > + rdev->recovery_offset >= end_sector)) > + goto out_rcu_unlock; > } > > - if (r5c_big_stripe_cached(conf, align_bi->bi_iter.bi_sector)) { > - rcu_read_unlock(); > - bio_put(align_bi); > + atomic_inc(&rdev->nr_pending); > + rcu_read_unlock(); > + > + align_bio = bio_clone_fast(raid_bio, GFP_NOIO, &mddev->bio_set); > + bio_set_dev(align_bio, rdev->bdev); > + align_bio->bi_end_io = raid5_align_endio; > + align_bio->bi_private = raid_bio; > + align_bio->bi_iter.bi_sector = sector; > + > + raid_bio->bi_next = (void *)rdev; > + > + if (is_badblock(rdev, sector, bio_sectors(align_bio), &first_bad, > + &bad_sectors)) { > + bio_put(align_bio); > + rdev_dec_pending(rdev, mddev); > return 0; > } > > - if (rdev) { > - sector_t first_bad; > - int bad_sectors; > - > - atomic_inc(&rdev->nr_pending); > - rcu_read_unlock(); > - raid_bio->bi_next = (void*)rdev; > - bio_set_dev(align_bi, rdev->bdev); > - > - if (is_badblock(rdev, align_bi->bi_iter.bi_sector, > - bio_sectors(align_bi), > - &first_bad, &bad_sectors)) { > - bio_put(align_bi); > - rdev_dec_pending(rdev, mddev); > - return 0; > - } > + /* No reshape active, so we can trust rdev->data_offset */ > + align_bio->bi_iter.bi_sector += rdev->data_offset; > > - /* No reshape active, so we can trust rdev->data_offset */ > - align_bi->bi_iter.bi_sector += rdev->data_offset; > + spin_lock_irq(&conf->device_lock); > + wait_event_lock_irq(conf->wait_for_quiescent, conf->quiesce == 0, > + conf->device_lock); > + atomic_inc(&conf->active_aligned_reads); > + spin_unlock_irq(&conf->device_lock); > > - spin_lock_irq(&conf->device_lock); > - wait_event_lock_irq(conf->wait_for_quiescent, > - conf->quiesce == 0, > - conf->device_lock); > - atomic_inc(&conf->active_aligned_reads); > - spin_unlock_irq(&conf->device_lock); > + if (mddev->gendisk) > + trace_block_bio_remap(align_bio, disk_devt(mddev->gendisk), > + raid_bio->bi_iter.bi_sector); > + submit_bio_noacct(align_bio); > + return 1; > > - if (mddev->gendisk) > - trace_block_bio_remap(align_bi, disk_devt(mddev->gendisk), > - raid_bio->bi_iter.bi_sector); > - submit_bio_noacct(align_bi); > - return 1; > - } else { > - rcu_read_unlock(); > - bio_put(align_bi); > - return 0; > - } > +out_rcu_unlock: > + rcu_read_unlock(); > + return 0; > } > > static struct bio *chunk_aligned_read(struct mddev *mddev, struct bio *raid_bio) > -- > 2.29.2 >
On Tue, Jan 26, 2021 at 7:12 AM Christoph Hellwig <hch@lst.de> wrote: > > bio_alloc_mddev is never called with a NULL mddev, and ->bio_set is > initialized in md_run, so it always must be initialized as well. Just > open code the remaining call to bio_alloc_bioset. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Song Liu <song@kernel.org> > --- > drivers/md/md.c | 12 +----------- > drivers/md/md.h | 2 -- > drivers/md/raid1.c | 2 +- > drivers/md/raid10.c | 2 +- > 4 files changed, 3 insertions(+), 15 deletions(-) > > diff --git a/drivers/md/md.c b/drivers/md/md.c > index 7d1bb24add3107..e2b9dbb6e888f6 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -340,16 +340,6 @@ static int start_readonly; > */ > static bool create_on_open = true; > > -struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs, > - struct mddev *mddev) > -{ > - if (!mddev || !bioset_initialized(&mddev->bio_set)) > - return bio_alloc(gfp_mask, nr_iovecs); > - > - return bio_alloc_bioset(gfp_mask, nr_iovecs, &mddev->bio_set); > -} > -EXPORT_SYMBOL_GPL(bio_alloc_mddev); > - > static struct bio *md_bio_alloc_sync(struct mddev *mddev) > { > if (!mddev || !bioset_initialized(&mddev->sync_set)) > @@ -613,7 +603,7 @@ static void submit_flushes(struct work_struct *ws) > atomic_inc(&rdev->nr_pending); > atomic_inc(&rdev->nr_pending); > rcu_read_unlock(); > - bi = bio_alloc_mddev(GFP_NOIO, 0, mddev); > + bi = bio_alloc_bioset(GFP_NOIO, 0, &mddev->bio_set); > bi->bi_end_io = md_end_flush; > bi->bi_private = rdev; > bio_set_dev(bi, rdev->bdev); > diff --git a/drivers/md/md.h b/drivers/md/md.h > index f13290ccc1c248..bcbba1b5ec4a71 100644 > --- a/drivers/md/md.h > +++ b/drivers/md/md.h > @@ -742,8 +742,6 @@ extern void md_rdev_clear(struct md_rdev *rdev); > extern void md_handle_request(struct mddev *mddev, struct bio *bio); > extern void mddev_suspend(struct mddev *mddev); > extern void mddev_resume(struct mddev *mddev); > -extern struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs, > - struct mddev *mddev); > > extern void md_reload_sb(struct mddev *mddev, int raid_disk); > extern void md_update_sb(struct mddev *mddev, int force); > diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c > index 3b19141cdb4bc2..d2378765dc154f 100644 > --- a/drivers/md/raid1.c > +++ b/drivers/md/raid1.c > @@ -1104,7 +1104,7 @@ static void alloc_behind_master_bio(struct r1bio *r1_bio, > int i = 0; > struct bio *behind_bio = NULL; > > - behind_bio = bio_alloc_mddev(GFP_NOIO, vcnt, r1_bio->mddev); > + behind_bio = bio_alloc_bioset(GFP_NOIO, vcnt, &r1_bio->mddev->bio_set); > if (!behind_bio) > return; > > diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c > index be8f14afb6d143..e1eefbec15d444 100644 > --- a/drivers/md/raid10.c > +++ b/drivers/md/raid10.c > @@ -4531,7 +4531,7 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr, > return sectors_done; > } > > - read_bio = bio_alloc_mddev(GFP_KERNEL, RESYNC_PAGES, mddev); > + read_bio = bio_alloc_bioset(GFP_KERNEL, RESYNC_PAGES, &mddev->bio_set); > > bio_set_dev(read_bio, rdev->bdev); > read_bio->bi_iter.bi_sector = (r10_bio->devs[r10_bio->read_slot].addr > -- > 2.29.2 >
On Tue, Jan 26, 2021 at 7:14 AM Christoph Hellwig <hch@lst.de> wrote: > > Use an on-stack bio and biovec for the single page synchronous I/O. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Song Liu <song@kernel.org> > --- > drivers/md/md.c | 26 +++++++++++++------------- > 1 file changed, 13 insertions(+), 13 deletions(-) > > diff --git a/drivers/md/md.c b/drivers/md/md.c > index e2b9dbb6e888f6..6a27f52007c871 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -1021,29 +1021,29 @@ int md_super_wait(struct mddev *mddev) > int sync_page_io(struct md_rdev *rdev, sector_t sector, int size, > struct page *page, int op, int op_flags, bool metadata_op) > { > - struct bio *bio = md_bio_alloc_sync(rdev->mddev); > - int ret; > + struct bio bio; > + struct bio_vec bvec; > + > + bio_init(&bio, &bvec, 1); > > if (metadata_op && rdev->meta_bdev) > - bio_set_dev(bio, rdev->meta_bdev); > + bio_set_dev(&bio, rdev->meta_bdev); > else > - bio_set_dev(bio, rdev->bdev); > - bio_set_op_attrs(bio, op, op_flags); > + bio_set_dev(&bio, rdev->bdev); > + bio.bi_opf = op | op_flags; > if (metadata_op) > - bio->bi_iter.bi_sector = sector + rdev->sb_start; > + bio.bi_iter.bi_sector = sector + rdev->sb_start; > else if (rdev->mddev->reshape_position != MaxSector && > (rdev->mddev->reshape_backwards == > (sector >= rdev->mddev->reshape_position))) > - bio->bi_iter.bi_sector = sector + rdev->new_data_offset; > + bio.bi_iter.bi_sector = sector + rdev->new_data_offset; > else > - bio->bi_iter.bi_sector = sector + rdev->data_offset; > - bio_add_page(bio, page, size, 0); > + bio.bi_iter.bi_sector = sector + rdev->data_offset; > + bio_add_page(&bio, page, size, 0); > > - submit_bio_wait(bio); > + submit_bio_wait(&bio); > > - ret = !bio->bi_status; > - bio_put(bio); > - return ret; > + return !bio.bi_status; > } > EXPORT_SYMBOL_GPL(sync_page_io); > > -- > 2.29.2 >
On Tue, Jan 26, 2021 at 7:17 AM Christoph Hellwig <hch@lst.de> wrote: > > md_bio_alloc_sync is never called with a NULL mddev, and ->sync_set is > initialized in md_run, so it always must be initialized as well. Just > open code the remaining call to bio_alloc_bioset. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Song Liu <song@kernel.org> > --- > drivers/md/md.c | 10 +--------- > 1 file changed, 1 insertion(+), 9 deletions(-) > > diff --git a/drivers/md/md.c b/drivers/md/md.c > index 6a27f52007c871..399c81bddc1ae1 100644 > --- a/drivers/md/md.c > +++ b/drivers/md/md.c > @@ -340,14 +340,6 @@ static int start_readonly; > */ > static bool create_on_open = true; > > -static struct bio *md_bio_alloc_sync(struct mddev *mddev) > -{ > - if (!mddev || !bioset_initialized(&mddev->sync_set)) > - return bio_alloc(GFP_NOIO, 1); > - > - return bio_alloc_bioset(GFP_NOIO, 1, &mddev->sync_set); > -} > - > /* > * We have a system wide 'event count' that is incremented > * on any 'interesting' event, and readers of /proc/mdstat > @@ -989,7 +981,7 @@ void md_super_write(struct mddev *mddev, struct md_rdev *rdev, > if (test_bit(Faulty, &rdev->flags)) > return; > > - bio = md_bio_alloc_sync(mddev); > + bio = bio_alloc_bioset(GFP_NOIO, 1, &mddev->sync_set); > > atomic_inc(&rdev->nr_pending); > > -- > 2.29.2 >
On 1/26/21 7:52 AM, Christoph Hellwig wrote:
> Hi Jens,
>
> this series contains various cleanups for how bios are allocated or
> initialized plus related fallout.
Applied, thanks.
--
Jens Axboe
On 01/26, Christoph Hellwig wrote: > Sleeping bio allocations do not fail, which means that injecting an error > into sleeping bio allocations is a little silly. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Already merged tho. Acked-by: Jaegeuk Kim <jaegeuk@kernel.org> > --- > Documentation/filesystems/f2fs.rst | 1 - > fs/f2fs/data.c | 29 ++++------------------------- > fs/f2fs/f2fs.h | 1 - > fs/f2fs/super.c | 1 - > 4 files changed, 4 insertions(+), 28 deletions(-) > > diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst > index dae15c96e659e2..624f5f3ed93e86 100644 > --- a/Documentation/filesystems/f2fs.rst > +++ b/Documentation/filesystems/f2fs.rst > @@ -179,7 +179,6 @@ fault_type=%d Support configuring fault injection type, should be > FAULT_KVMALLOC 0x000000002 > FAULT_PAGE_ALLOC 0x000000004 > FAULT_PAGE_GET 0x000000008 > - FAULT_ALLOC_BIO 0x000000010 > FAULT_ALLOC_NID 0x000000020 > FAULT_ORPHAN 0x000000040 > FAULT_BLOCK 0x000000080 > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index 0cf0c605992431..9fb6be65592b1f 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -50,28 +50,6 @@ void f2fs_destroy_bioset(void) > bioset_exit(&f2fs_bioset); > } > > -static inline struct bio *__f2fs_bio_alloc(gfp_t gfp_mask, > - unsigned int nr_iovecs) > -{ > - return bio_alloc_bioset(gfp_mask, nr_iovecs, &f2fs_bioset); > -} > - > -static struct bio *f2fs_bio_alloc(struct f2fs_sb_info *sbi, int npages, > - bool noio) > -{ > - if (noio) { > - /* No failure on bio allocation */ > - return __f2fs_bio_alloc(GFP_NOIO, npages); > - } > - > - if (time_to_inject(sbi, FAULT_ALLOC_BIO)) { > - f2fs_show_injection_info(sbi, FAULT_ALLOC_BIO); > - return NULL; > - } > - > - return __f2fs_bio_alloc(GFP_KERNEL, npages); > -} > - > static bool __is_cp_guaranteed(struct page *page) > { > struct address_space *mapping = page->mapping; > @@ -433,7 +411,7 @@ static struct bio *__bio_alloc(struct f2fs_io_info *fio, int npages) > struct f2fs_sb_info *sbi = fio->sbi; > struct bio *bio; > > - bio = f2fs_bio_alloc(sbi, npages, true); > + bio = bio_alloc_bioset(GFP_NOIO, npages, &f2fs_bioset); > > f2fs_target_device(sbi, fio->new_blkaddr, bio); > if (is_read_io(fio->op)) { > @@ -1029,8 +1007,9 @@ static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr, > struct bio_post_read_ctx *ctx; > unsigned int post_read_steps = 0; > > - bio = f2fs_bio_alloc(sbi, min_t(int, nr_pages, BIO_MAX_PAGES), > - for_write); > + bio = bio_alloc_bioset(for_write ? GFP_NOIO : GFP_KERNEL, > + min_t(int, nr_pages, BIO_MAX_PAGES), > + &f2fs_bioset); > if (!bio) > return ERR_PTR(-ENOMEM); > > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index 902bd3267c03e1..6c78365d80ceb5 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -43,7 +43,6 @@ enum { > FAULT_KVMALLOC, > FAULT_PAGE_ALLOC, > FAULT_PAGE_GET, > - FAULT_ALLOC_BIO, > FAULT_ALLOC_NID, > FAULT_ORPHAN, > FAULT_BLOCK, > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index b4a07fe62d1a58..3a312642907e86 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -45,7 +45,6 @@ const char *f2fs_fault_name[FAULT_MAX] = { > [FAULT_KVMALLOC] = "kvmalloc", > [FAULT_PAGE_ALLOC] = "page alloc", > [FAULT_PAGE_GET] = "page get", > - [FAULT_ALLOC_BIO] = "alloc bio", > [FAULT_ALLOC_NID] = "alloc nid", > [FAULT_ORPHAN] = "orphan", > [FAULT_BLOCK] = "no more block", > -- > 2.29.2
On 2021/1/26 22:52, Christoph Hellwig wrote:
> Use the blkdev_issue_flush helper instead of duplicating it.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Chao Yu <yuchao0@huawei.com>
Thanks,
On 2021/1/26 22:52, Christoph Hellwig wrote:
> Sleeping bio allocations do not fail, which means that injecting an error
> into sleeping bio allocations is a little silly.
>
> Signed-off-by: Christoph Hellwig<hch@lst.de>
Acked-by: Chao Yu <yuchao0@huawei.com>
Thanks,
On Tue, Jan 26, 2021 at 03:52:34PM +0100, Christoph Hellwig wrote:
> bio_kmalloc shares almost no logic with the bio_set based fast path
> in bio_alloc_bioset. Split it into an entirely separate implementation.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> block/bio.c | 167 ++++++++++++++++++++++----------------------
> include/linux/bio.h | 6 +-
> 2 files changed, 86 insertions(+), 87 deletions(-)
This patch causes current linux-next to OOM for me when running xfstests
after about ten minutes. Haven't looked into why yet, this is just the
results of a git bisect.
The qemu command line is:
qemu-system-x86_64 -nodefaults -nographic -cpu host -machine accel=kvm,nvdimm -m 2G,slots=8,maxmem=1T -smp 6 -kernel /home/willy/kernel/folio/.build_test_kernel-x86_64/kpgk/vmlinuz -append console=hvc0 root=/dev/sda rw log_buf_len=8M ktest.dir=/home/willy/kernel/ktest ktest.env=/tmp/build-test-kernel-nJO6QgxOmo/env quiet systemd.show_status=0 systemd.log-target=journal crashkernel=128M no_console_suspend -device virtio-serial -chardev stdio,id=console -device virtconsole,chardev=console -serial unix:/tmp/build-test-kernel-nJO6QgxOmo/vm-kgdb,server,nowait -monitor unix:/tmp/build-test-kernel-nJO6QgxOmo/vm-mon,server,nowait -gdb unix:/tmp/build-test-kernel-nJO6QgxOmo/vm-gdb,server,nowait -device virtio-rng-pci -virtfs local,path=/,mount_tag=host,security_model=none -device virtio-scsi-pci,id=hba -nic user,model=virtio,hostfwd=tcp:127.0.0.1:24674-:22 -drive if=none,format=raw,id=disk0,file=/var/lib/ktest/root.amd64,snapshot=on -device scsi-hd,bus=hba.0,drive=disk0 -drive if=none,format=raw,id=disk1,file=/tmp/build-test-kernel-nJO6QgxOmo/dev-1,cache=unsafe -device scsi-hd,bus=hba.0,drive=disk1 -drive if=none,format=raw,id=disk2,file=/tmp/build-test-kernel-nJO6QgxOmo/dev-2,cache=unsafe -device scsi-hd,bus=hba.0,drive=disk2 -drive if=none,format=raw,id=disk3,file=/tmp/build-test-kernel-nJO6QgxOmo/dev-3,cache=unsafe -device scsi-hd,bus=hba.0,drive=disk3
Hi Christoph, I tried with latest for-5.12/block branch, and got below issue when trying to create raid1 array. [ 80.605832] BUG: kernel NULL pointer dereference, address: 0000000000000018 [ 80.606159] #PF: supervisor read access in kernel mode [ 80.606159] #PF: error_code(0x0000) - not-present page [ 80.606159] PGD 0 P4D 0 [ 80.606159] Oops: 0000 [#1] SMP NOPTI [ 80.606159] CPU: 1 PID: 207 Comm: mdadm Not tainted 5.11.0-rc5+ #37 [ 80.606159] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 [ 80.606159] RIP: 0010:bdev_read_only+0x0/0x30 [ 80.606159] Code: 89 df 5b 5d e9 71 21 e7 ff 81 e6 ff ff 0f 00 48 c7 c7 40 99 d9 9e e8 0f e5 04 00 eb a0 0f 1f 00 66 2e 0f 1f 84 00 00 00 00 00 <80> 7f 18 00 b8 01 00 00 00 75 11 48 8b 97 60 03 00 00 48 8b 4a 40 [ 80.606159] RSP: 0018:ffffb14f405dfd38 EFLAGS: 00000246 [ 80.606159] RAX: 0000000000000000 RBX: ffff9b0e0863b018 RCX: ffff9b0e01edc000 [ 80.606159] RDX: ffff9b0e01b54c00 RSI: ffff9b0e0863b000 RDI: 0000000000000000 [ 80.606159] RBP: ffff9b0e01272200 R08: 0000000000000000 R09: 0000000000000000 [ 80.606159] R10: ffffee978004da40 R11: 0000000000000cc0 R12: ffff9b0e0863b000 [ 80.606159] R13: ffff9b0e01f2cc00 R14: ffff9b0e0863b000 R15: 0000000000000000 [ 80.606159] FS: 00007f522ec65740(0000) GS:ffff9b0e7bc80000(0000) knlGS:0000000000000000 [ 80.606159] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 80.606159] CR2: 0000000000000018 CR3: 0000000001364000 CR4: 00000000000006e0 [ 80.606159] Call Trace: [ 80.606159] bind_rdev_to_array+0x2f7/0x380 [ 80.606159] ? cred_has_capability+0x80/0x120 [ 80.606159] md_add_new_disk+0x204/0x630 [ 80.606159] ? security_capable+0x33/0x50 [ 80.606159] md_ioctl+0xee7/0x1690 [ 80.606159] ? selinux_file_ioctl+0x143/0x200 [ 80.606159] blkdev_ioctl+0x1ff/0x240 [ 80.606159] block_ioctl+0x34/0x40 [ 80.606159] __x64_sys_ioctl+0x89/0xc0 [ 80.606159] do_syscall_64+0x33/0x40 [ 80.606159] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 80.606159] RIP: 0033:0x7f522e564317 [ 80.606159] Code: b3 66 90 48 8b 05 71 4b 2d 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 41 4b 2d 00 f7 d8 64 89 01 48 [ 80.606159] RSP: 002b:00007ffc3abd96f8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [ 80.606159] RAX: ffffffffffffffda RBX: 00005653ee690350 RCX: 00007f522e564317 [ 80.606159] RDX: 00005653ee694058 RSI: 0000000040140921 RDI: 0000000000000004 [ 80.606159] RBP: 00005653ee690410 R08: 00007f522e839db0 R09: 0000000000000000 [ 80.606159] R10: 00005653ee690010 R11: 0000000000000246 R12: 0000000000000000 [ 80.606159] R13: 0000000000000000 R14: 0000000000000000 R15: 00005653ee694010 [ 80.606159] Modules linked in: [ 80.606159] CR2: 0000000000000018 [ 80.622996] ---[ end trace 22144b856a3c1001 ]--- [ 80.623285] RIP: 0010:bdev_read_only+0x0/0x30 [ 80.623501] Code: 89 df 5b 5d e9 71 21 e7 ff 81 e6 ff ff 0f 00 48 c7 c7 40 99 d9 9e e8 0f e5 04 00 eb a0 0f 1f 00 66 2e 0f 1f 84 00 00 00 00 00 <80> 7f 18 00 b8 01 00 00 00 75 11 48 8b 97 60 03 00 00 48 8b 4a 40 [ 80.624544] RSP: 0018:ffffb14f405dfd38 EFLAGS: 00000246 [ 80.624788] RAX: 0000000000000000 RBX: ffff9b0e0863b018 RCX: ffff9b0e01edc000 [ 80.625136] RDX: ffff9b0e01b54c00 RSI: ffff9b0e0863b000 RDI: 0000000000000000 [ 80.625449] RBP: ffff9b0e01272200 R08: 0000000000000000 R09: 0000000000000000 [ 80.625761] R10: ffffee978004da40 R11: 0000000000000cc0 R12: ffff9b0e0863b000 [ 80.626112] R13: ffff9b0e01f2cc00 R14: ffff9b0e0863b000 R15: 0000000000000000 [ 80.626429] FS: 00007f522ec65740(0000) GS:ffff9b0e7bc80000(0000) knlGS:0000000000000000 [ 80.626784] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 80.627035] CR2: 0000000000000018 CR3: 0000000001364000 CR4: 00000000000006e0 Killed Thanks, Guoqing
On Sat, Jan 30, 2021 at 03:56:46AM +0000, Matthew Wilcox wrote:
> On Tue, Jan 26, 2021 at 03:52:34PM +0100, Christoph Hellwig wrote:
> > bio_kmalloc shares almost no logic with the bio_set based fast path
> > in bio_alloc_bioset. Split it into an entirely separate implementation.
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > ---
> > block/bio.c | 167 ++++++++++++++++++++++----------------------
> > include/linux/bio.h | 6 +-
> > 2 files changed, 86 insertions(+), 87 deletions(-)
>
> This patch causes current linux-next to OOM for me when running xfstests
> after about ten minutes. Haven't looked into why yet, this is just the
> results of a git bisect.
I've run tests on linux-next all weekend and could not reproduce
the issue. Can you share your .config?