]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: use an on-stack bio in blkdev_issue_flush
authorChristoph Hellwig <hch@lst.de>
Tue, 26 Jan 2021 14:52:35 +0000 (15:52 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 27 Jan 2021 16:51:48 +0000 (09:51 -0700)
There is no point in allocating memory for a synchronous flush.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Acked-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
23 files changed:
block/blk-flush.c
drivers/md/dm-zoned-metadata.c
drivers/md/raid5-ppl.c
drivers/nvme/target/io-cmd-bdev.c
fs/block_dev.c
fs/exfat/file.c
fs/ext4/fast_commit.c
fs/ext4/fsync.c
fs/ext4/ialloc.c
fs/ext4/super.c
fs/fat/file.c
fs/hfsplus/inode.c
fs/hfsplus/super.c
fs/jbd2/checkpoint.c
fs/jbd2/commit.c
fs/jbd2/recovery.c
fs/libfs.c
fs/nilfs2/the_nilfs.h
fs/ocfs2/file.c
fs/reiserfs/file.c
fs/xfs/xfs_super.c
fs/zonefs/super.c
include/linux/blkdev.h

index 76c1624cb06c05fcfbc610423671bc30b2a9e35c..7942ca6ed3211c684437c6875e678841888b583b 100644 (file)
@@ -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);
 
index b298fefb022eb9062025b753d53e71fc42d73b74..039d17b2893849c96fe15e5a1a331bee61efee27 100644 (file)
@@ -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;
        }
 
index d0f540296fe91e585737a8d6aa2efc823cdc7a9b..e8c118e05dfd46edbccddafe109ca42077803c69 100644 (file)
@@ -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;
index 125dde3f410ee711de2e90009eb76f0c3e0d5255..bf6e0ac9ad2890170921c32ab5d8ebff2b7e8766 100644 (file)
@@ -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;
 }
index c1fe29dac4854300b175e4783c221348b9cf6c44..9d4b1a884d762c881912b4e1bc77a568e43a92c6 100644 (file)
@@ -680,7 +680,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;
 
index a92478eabfa4e43f2198ccf9b62b8632b697c8dc..183ffdf4d43c5fa781c8b7ddcde8dda4cdce2ac4 100644 (file)
@@ -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 = {
index 0a14a7c87bf82e3b20748cc627fb40d03dad6268..6e8208acfc62ac90f761090457381976df8468f3 100644 (file)
@@ -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;
 }
index 113bfb023a4a09a4a75240d0d19eb2b7e6586a15..027a7d7037a07b3647da6ece56e5bca568503db3 100644 (file)
@@ -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;
        }
index b215c564bc318a5aaf883f8f6e5a1ba6013a201f..20f2fcb799f55ff36041e1e0003adb70495f9fd4 100644 (file)
@@ -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);
index 9a6f9875aa3499fb7ac3a48a062f933b162aa2b9..fb5985102c1db78992eca8d6ffcb301772dd4d47 100644 (file)
@@ -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;
        }
index f9ee27cf4d7c2f678c67ba61f878d1494b315104..5fee74f1ad611d03f5b79f47dc177b3b977275ff 100644 (file)
@@ -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);
 }
 
 
index e3da9e96b83578d7f8989dab58a9a69a84ac6f92..ca464328b79cc54db3a89c1a3c16019c9bf9f36d 100644 (file)
@@ -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);
 
index 807119ae5adf7370622c033dcd714608eea318f1..b9e3db3f855f9625199101e2c8a5cf2b499f93aa 100644 (file)
@@ -239,7 +239,7 @@ out:
        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;
 }
index 472932b9e6bca9d6a56fe1bb7c52e9bc35ef0f3d..63b526d44886d0b84db30570a1e57ae1e121278f 100644 (file)
@@ -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);
 }
index b121d7d434c67510a58c7d962610abc68f3423cc..3cc4ab2ba7f4f25a90ae1528a49cd6928455c937 100644 (file)
@@ -825,7 +825,7 @@ start_journal_io:
        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 @@ start_journal_io:
        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)
index dc0694fcfcd123d647ecac6e78cb59e04f800a7a..69f18fe209236979acca035af00562b0ff7f72bd 100644 (file)
@@ -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;
        }
index d1c3bade9f30dd028cfc109d7fc3f8abf2c846cf..8398a0efb401c659e9e919bdd3a46630d2cd30bd 100644 (file)
@@ -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);
 
index b55cdeb4d16991cd463598b4f4e687533016934d..987c8ab02aeee6f3765d501972c5cb901db82650 100644 (file)
@@ -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;
index 85979e2214b39d81209168680885fcd317410237..df6d709d2ae3b609e854bb76df1ca40878ca2868 100644 (file)
@@ -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;
        }
index 0b641ae694f123dd706446a074532cb945b44633..1db0254bc38b26f68472f5752d97873d42451629 100644 (file)
@@ -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;
index 813be879a5e51d928f8b10523b41f835c308c523..c3e32789829f90568c7406bb1caaf74ba574494f 100644 (file)
@@ -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
index faea2ed34b4a37cafd109ea5c35800db71869ec7..ab68e27bb322e03674a300789961d8a525a32c7d 100644 (file)
@@ -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);
index 2491e17b61c489ff1e2a54f0b125eba43c6c61ea..0dea268bd61bb1bc7ecc8fe928c78e50addbec75 100644 (file)
@@ -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;
 }