Re: [PATCH 2/8] block: move sync_blockdev from __blkdev_put to blkdev_put

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 12, 2021 at 08:18:50AM +0200, Christoph Hellwig wrote:
> Do the early unlocked syncing even earlier to move more code out of
> the recursive path.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> ---
>  fs/block_dev.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index d053510d2f6a..95fde785dae7 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -1553,16 +1553,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--;
> @@ -1589,6 +1579,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);
> +

The early sync on disk is killed in case of closing partition, but there
shouldn't much dirty data on disk, so looks fine:

Reviewed-by: Ming Lei <ming.lei@xxxxxxxxxx>

--
Ming




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux