summaryrefslogtreecommitdiff
path: root/fs/block_dev.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-05-25 08:12:55 +0200
committerJens Axboe <axboe@kernel.dk>2021-06-01 07:43:32 -0600
commit210a6d756f20f33fc546ec8682a538fbcb84ee8e (patch)
tree46e1105d6651b71e5d7d9df2c7f1651fb1de0d95 /fs/block_dev.c
parent362529d9280af4b08d2c25a4b39b8e5ae7658f9a (diff)
downloadlwn-210a6d756f20f33fc546ec8682a538fbcb84ee8e.tar.gz
lwn-210a6d756f20f33fc546ec8682a538fbcb84ee8e.zip
block: move sync_blockdev from __blkdev_put to blkdev_put
Do the early unlocked syncing even earlier to move more code out of the recursive path. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20210525061301.2242282-3-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 2b5073e3c923..41d2d9708bf8 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1552,16 +1552,6 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part)
struct gendisk *disk = bdev->bd_disk;
struct block_device *victim = NULL;
- /*
- * Sync early if it looks like we're the last one. If someone else
- * opens the block device between now and the decrement of bd_openers
- * then we did a sync that we didn't need to, but that's not the end
- * of the world and we want to avoid long (could be several minute)
- * syncs while holding the mutex.
- */
- if (bdev->bd_openers == 1)
- sync_blockdev(bdev);
-
mutex_lock_nested(&bdev->bd_mutex, for_part);
if (for_part)
bdev->bd_part_count--;
@@ -1588,6 +1578,16 @@ void blkdev_put(struct block_device *bdev, fmode_t mode)
{
struct gendisk *disk = bdev->bd_disk;
+ /*
+ * Sync early if it looks like we're the last one. If someone else
+ * opens the block device between now and the decrement of bd_openers
+ * then we did a sync that we didn't need to, but that's not the end
+ * of the world and we want to avoid long (could be several minute)
+ * syncs while holding the mutex.
+ */
+ if (bdev->bd_openers == 1)
+ sync_blockdev(bdev);
+
mutex_lock(&bdev->bd_mutex);
if (mode & FMODE_EXCL) {