]> git.baikalelectronics.ru Git - kernel.git/commitdiff
block: add a bdev_stable_writes helper
authorChristoph Hellwig <hch@lst.de>
Fri, 15 Apr 2022 04:52:45 +0000 (06:52 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 18 Apr 2022 01:49:59 +0000 (19:49 -0600)
Add a helper to check the stable writes flag based on the block_device
instead of having to poke into the block layer internal request_queue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Link: https://lore.kernel.org/r/20220415045258.199825-15-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/dm-table.c
fs/super.c
include/linux/blkdev.h
mm/swapfile.c

index 5e38d0dd009d5d82237c998ae553017e8be01c41..d46839faa0ca5ebad6b9dcfd41d246fe74f8a590 100644 (file)
@@ -1950,9 +1950,7 @@ static int device_requires_stable_pages(struct dm_target *ti,
                                        struct dm_dev *dev, sector_t start,
                                        sector_t len, void *data)
 {
-       struct request_queue *q = bdev_get_queue(dev->bdev);
-
-       return blk_queue_stable_writes(q);
+       return bdev_stable_writes(dev->bdev);
 }
 
 int dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
index f1d4a193602d673b8aaf435d9d2d1c25388221b1..60f57c7bc0a69a0cb931a957c354ed740aaba9f0 100644 (file)
@@ -1204,7 +1204,7 @@ static int set_bdev_super(struct super_block *s, void *data)
        s->s_dev = s->s_bdev->bd_dev;
        s->s_bdi = bdi_get(s->s_bdev->bd_disk->bdi);
 
-       if (blk_queue_stable_writes(s->s_bdev->bd_disk->queue))
+       if (bdev_stable_writes(s->s_bdev))
                s->s_iflags |= SB_I_STABLE_WRITES;
        return 0;
 }
index 075b16d4560e741a214aa10f0f84abae99280748..a433798c3343e67976712e6dec7abae480a7a808 100644 (file)
@@ -1330,6 +1330,12 @@ static inline bool bdev_nonrot(struct block_device *bdev)
        return blk_queue_nonrot(bdev_get_queue(bdev));
 }
 
+static inline bool bdev_stable_writes(struct block_device *bdev)
+{
+       return test_bit(QUEUE_FLAG_STABLE_WRITES,
+                       &bdev_get_queue(bdev)->queue_flags);
+}
+
 static inline bool bdev_write_cache(struct block_device *bdev)
 {
        return test_bit(QUEUE_FLAG_WC, &bdev_get_queue(bdev)->queue_flags);
index d5ab7ec4d92ca3a202953aa903ef963258add93f..4069f17a82c8e038bc35efb99664a523a4cf0e6f 100644 (file)
@@ -3065,7 +3065,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
                goto bad_swap_unlock_inode;
        }
 
-       if (p->bdev && blk_queue_stable_writes(p->bdev->bd_disk->queue))
+       if (p->bdev && bdev_stable_writes(p->bdev))
                p->flags |= SWP_STABLE_WRITES;
 
        if (p->bdev && p->bdev->bd_disk->fops->rw_page)