Message ID | 20201118084800.2339180-11-hch@lst.de (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [01/20] blk-cgroup: fix a hd_struct leak in blkcg_fill_root_iostats | expand |
On Wed 18-11-20 09:47:50, Christoph Hellwig wrote: > Reorder the code to have one big section for the last close, and to use > bdev_is_partition. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Looks good. You can add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > fs/block_dev.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/fs/block_dev.c b/fs/block_dev.c > index 29db12c3bb501c..4c4d6c30382c06 100644 > --- a/fs/block_dev.c > +++ b/fs/block_dev.c > @@ -1745,22 +1745,22 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) > WARN_ON_ONCE(bdev->bd_holders); > sync_blockdev(bdev); > kill_bdev(bdev); > - > bdev_write_inode(bdev); > - } > - if (bdev->bd_contains == bdev) { > - if (disk->fops->release) > + > + if (!bdev_is_partition(bdev) && disk->fops->release) > disk->fops->release(disk, mode); > - } > - if (!bdev->bd_openers) { > + > disk_put_part(bdev->bd_part); > bdev->bd_part = NULL; > bdev->bd_disk = NULL; > - if (bdev != bdev->bd_contains) > + if (bdev_is_partition(bdev)) > victim = bdev->bd_contains; > bdev->bd_contains = NULL; > > put_disk_and_module(disk); > + } else { > + if (!bdev_is_partition(bdev) && disk->fops->release) > + disk->fops->release(disk, mode); > } > mutex_unlock(&bdev->bd_mutex); > bdput(bdev); > -- > 2.29.2 >
diff --git a/fs/block_dev.c b/fs/block_dev.c index 29db12c3bb501c..4c4d6c30382c06 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1745,22 +1745,22 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) WARN_ON_ONCE(bdev->bd_holders); sync_blockdev(bdev); kill_bdev(bdev); - bdev_write_inode(bdev); - } - if (bdev->bd_contains == bdev) { - if (disk->fops->release) + + if (!bdev_is_partition(bdev) && disk->fops->release) disk->fops->release(disk, mode); - } - if (!bdev->bd_openers) { + disk_put_part(bdev->bd_part); bdev->bd_part = NULL; bdev->bd_disk = NULL; - if (bdev != bdev->bd_contains) + if (bdev_is_partition(bdev)) victim = bdev->bd_contains; bdev->bd_contains = NULL; put_disk_and_module(disk); + } else { + if (!bdev_is_partition(bdev) && disk->fops->release) + disk->fops->release(disk, mode); } mutex_unlock(&bdev->bd_mutex); bdput(bdev);
Reorder the code to have one big section for the last close, and to use bdev_is_partition. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/block_dev.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)