diff mbox series

[COMPILE,TESTED,6/8] target/pscsi: use helper in pscsi_get_blocks()

Message ID 20190613145955.4813-7-chaitanya.kulkarni@wdc.com (mailing list archive)
State Superseded
Headers show
Series block: use right accessor to read nr_sects | expand

Commit Message

Chaitanya Kulkarni June 13, 2019, 2:59 p.m. UTC
This patch updates the pscsi_get_blocks() with newly introduced helper
function to read the nr_sects from block device's hd_parts with the
help if part_nr_sects_read() protected by appropriate locking.

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

Comments

Bart Van Assche June 13, 2019, 3:36 p.m. UTC | #1
On 6/13/19 7:59 AM, Chaitanya Kulkarni wrote:
> This patch updates the pscsi_get_blocks() with newly introduced helper
> function to read the nr_sects from block device's hd_parts with the
> help if part_nr_sects_read() protected by appropriate locking.
> 
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
>   drivers/target/target_core_pscsi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
> index c9d92b3e777d..da481edab2de 100644
> --- a/drivers/target/target_core_pscsi.c
> +++ b/drivers/target/target_core_pscsi.c
> @@ -1030,7 +1030,7 @@ static sector_t pscsi_get_blocks(struct se_device *dev)
>   	struct pscsi_dev_virt *pdv = PSCSI_DEV(dev);
>   
>   	if (pdv->pdv_bd && pdv->pdv_bd->bd_part)
> -		return pdv->pdv_bd->bd_part->nr_sects;
> +		return bdev_nr_sects(pdv->pdv_bd);
>   
>   	return 0;
>   }

As far as I can see bd_part does not change between blkdev_get() and 
blkdev_put(). Since the pscsi code guarantees that blkdev_put() is not 
called concurrently with pscsi_get_blocks() this patch is not necessary.

Bart.
Chaitanya Kulkarni June 13, 2019, 4:08 p.m. UTC | #2
Okay, I'll drop this patch in the V2.

On 06/13/2019 08:36 AM, Bart Van Assche wrote:
> On 6/13/19 7:59 AM, Chaitanya Kulkarni wrote:
>> This patch updates the pscsi_get_blocks() with newly introduced helper
>> function to read the nr_sects from block device's hd_parts with the
>> help if part_nr_sects_read() protected by appropriate locking.
>>
>> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
>> ---
>>    drivers/target/target_core_pscsi.c | 2 +-
>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
>> index c9d92b3e777d..da481edab2de 100644
>> --- a/drivers/target/target_core_pscsi.c
>> +++ b/drivers/target/target_core_pscsi.c
>> @@ -1030,7 +1030,7 @@ static sector_t pscsi_get_blocks(struct se_device *dev)
>>    	struct pscsi_dev_virt *pdv = PSCSI_DEV(dev);
>>
>>    	if (pdv->pdv_bd && pdv->pdv_bd->bd_part)
>> -		return pdv->pdv_bd->bd_part->nr_sects;
>> +		return bdev_nr_sects(pdv->pdv_bd);
>>
>>    	return 0;
>>    }
>
> As far as I can see bd_part does not change between blkdev_get() and
> blkdev_put(). Since the pscsi code guarantees that blkdev_put() is not
> called concurrently with pscsi_get_blocks() this patch is not necessary.
>
> Bart.
>
>
>
diff mbox series

Patch

diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c
index c9d92b3e777d..da481edab2de 100644
--- a/drivers/target/target_core_pscsi.c
+++ b/drivers/target/target_core_pscsi.c
@@ -1030,7 +1030,7 @@  static sector_t pscsi_get_blocks(struct se_device *dev)
 	struct pscsi_dev_virt *pdv = PSCSI_DEV(dev);
 
 	if (pdv->pdv_bd && pdv->pdv_bd->bd_part)
-		return pdv->pdv_bd->bd_part->nr_sects;
+		return bdev_nr_sects(pdv->pdv_bd);
 
 	return 0;
 }