2020-12-21 03:24:30

by Yi Li

[permalink] [raw]
Subject: [PATCH] bcache: Trivial fix to bdput

Trivial fix to bdput.

Signed-off-by: Yi Li <[email protected]>
---
drivers/md/bcache/super.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index f7ad1e26b013..1756f6926098 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2525,8 +2525,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
else
err = "device busy";
mutex_unlock(&bch_register_lock);
- if (!IS_ERR(bdev))
- bdput(bdev);
+ if (!IS_ERR(dev))
+ bdput(dev);
if (attr == &ksysfs_register_quiet)
goto done;
}
--
2.25.3




2020-12-21 05:55:56

by Yi Li

[permalink] [raw]
Subject: [PATCH v2] bcache: Trivial fix to register_bcache

Trivial fix to no need to check the bdev and do bdput.

Fixes: 4e7b5671c6a8("block: remove i_bdev")

Signed-off-by: Yi Li <[email protected]>
---
drivers/md/bcache/super.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index f7ad1e26b013..4edf666860ad 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2525,8 +2525,6 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
else
err = "device busy";
mutex_unlock(&bch_register_lock);
- if (!IS_ERR(bdev))
- bdput(bdev);
if (attr == &ksysfs_register_quiet)
goto done;
}
--
2.25.3



2020-12-21 07:37:57

by Coly Li

[permalink] [raw]
Subject: Re: [PATCH] bcache: Trivial fix to bdput

On 12/21/20 11:17 AM, Yi Li wrote:
> Trivial fix to bdput.
>
> Signed-off-by: Yi Li <[email protected]>e

Hi Yi,

Indeed these two fixes are not that trivial. I suggest to describe more
detail about why your fixes are necessary and what problems are fixed by
your patches.


Thanks.

Coly Li


> ---
> drivers/md/bcache/super.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index f7ad1e26b013..1756f6926098 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -2525,8 +2525,8 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
> else
> err = "device busy";
> mutex_unlock(&bch_register_lock);
> - if (!IS_ERR(bdev))
> - bdput(bdev);
> + if (!IS_ERR(dev))
> + bdput(dev);
> if (attr == &ksysfs_register_quiet)
> goto done;
> }
>

2020-12-21 09:57:25

by Yi Li

[permalink] [raw]
Subject: [PATCH v4] bcache:remove a superfluous check in register_bcache

There have no reassign the bdev after check It is IS_ERR.
the double check !IS_ERR(bdev) is superfluous.

After commit 4e7b5671c6a8 ("block: remove i_bdev"),
"Switch the block device lookup interfaces to directly work with a dev_t
so that struct block_device references are only acquired by the
blkdev_get variants (and the blk-cgroup special case). This means that
we now don't need an extra reference in the inode and can generally
simplify handling of struct block_device to keep the lookups contained
in the core block layer code."

so after lookup_bdev call, there no need to do bdput.

remove a superfluous check the bdev & don't call bdput after lookup_bdev.

Fixes: 4e7b5671c6a8("block: remove i_bdev")
Signed-off-by: Yi Li <[email protected]>
---
drivers/md/bcache/super.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 0e06d721cd8e..a4752ac410dc 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -2535,8 +2535,6 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
else
err = "device busy";
mutex_unlock(&bch_register_lock);
- if (!IS_ERR(bdev))
- bdput(bdev);
if (attr == &ksysfs_register_quiet)
goto done;
}
--
2.25.3



2020-12-23 09:00:45

by Christoph Hellwig

[permalink] [raw]