diff mbox series

[V2,5/7] bcache: update cached_dev_init() with helper

Message ID 20190617012832.4311-6-chaitanya.kulkarni@wdc.com (mailing list archive)
State New, archived
Headers show
Series block: use right accessor to read nr_setcs | expand

Commit Message

Chaitanya Kulkarni June 17, 2019, 1:28 a.m. UTC
In the bcache when initializing the device we don't actually use any
sort of locking when reading the number of sectors from the part. This
patch updates the cached_dev_init() with newly introduced helper
function to read the nr_sects from block device's hd_parts with the help
of part_nr_sects_read().

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/md/bcache/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Coly Li June 17, 2019, 6:53 a.m. UTC | #1
On 2019/6/17 9:28 上午, Chaitanya Kulkarni wrote:
> In the bcache when initializing the device we don't actually use any
> sort of locking when reading the number of sectors from the part. This
> patch updates the cached_dev_init() with newly introduced helper
> function to read the nr_sects from block device's hd_parts with the help
> of part_nr_sects_read().
> 
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

Acked-by: Coly Li <colyli@suse.de>

Thanks.

Coly Li

> ---
>  drivers/md/bcache/super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index 1b63ac876169..6a29ba89dae1 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -1263,7 +1263,7 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
>  			q->limits.raid_partial_stripes_expensive;
>  
>  	ret = bcache_device_init(&dc->disk, block_size,
> -			 dc->bdev->bd_part->nr_sects - dc->sb.data_offset);
> +			 bdev_nr_sects(dc->bdev) - dc->sb.data_offset);
>  	if (ret)
>  		return ret;
>  
>
Chaitanya Kulkarni June 17, 2019, 4:56 p.m. UTC | #2
On 06/16/2019 11:54 PM, Coly Li wrote:
> On 2019/6/17 9:28 上午, Chaitanya Kulkarni wrote:
>> In the bcache when initializing the device we don't actually use any
>> sort of locking when reading the number of sectors from the part. This
>> patch updates the cached_dev_init() with newly introduced helper
>> function to read the nr_sects from block device's hd_parts with the help
>> of part_nr_sects_read().
>>
>> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
>
> Acked-by: Coly Li <colyli@suse.de>

Thanks Coly.
>
> Thanks.
>
> Coly Li
>
>> ---
>>   drivers/md/bcache/super.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
>> index 1b63ac876169..6a29ba89dae1 100644
>> --- a/drivers/md/bcache/super.c
>> +++ b/drivers/md/bcache/super.c
>> @@ -1263,7 +1263,7 @@ static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
>>   			q->limits.raid_partial_stripes_expensive;
>>
>>   	ret = bcache_device_init(&dc->disk, block_size,
>> -			 dc->bdev->bd_part->nr_sects - dc->sb.data_offset);
>> +			 bdev_nr_sects(dc->bdev) - dc->sb.data_offset);
>>   	if (ret)
>>   		return ret;
>>
>>
>
diff mbox series

Patch

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 1b63ac876169..6a29ba89dae1 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1263,7 +1263,7 @@  static int cached_dev_init(struct cached_dev *dc, unsigned int block_size)
 			q->limits.raid_partial_stripes_expensive;
 
 	ret = bcache_device_init(&dc->disk, block_size,
-			 dc->bdev->bd_part->nr_sects - dc->sb.data_offset);
+			 bdev_nr_sects(dc->bdev) - dc->sb.data_offset);
 	if (ret)
 		return ret;