fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] fstests: don't rely on /proc/partitions for device size
@ 2021-03-26 15:34 Johannes Thumshirn
  2021-03-28 21:31 ` Damien Le Moal
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Thumshirn @ 2021-03-26 15:34 UTC (permalink / raw)
  To: Eryu Guan
  Cc: fstests, linux-btrfs, Nikolay Borisov, Damien Le Moal,
	Johannes Thumshirn, Naohiro Aota

Non-partitionable devices, like zoned block devices, aren't showing up in in
/proc/partitions and therefore we cannot rely on it to get a device's size.

Use blockdev --getsz to get the block device size.

Cc: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

---
Changes to v2:
- Don't forget the sectors to kb conversion (Damien)

Changes to v1:
- Use blockdev --getsz instead of sysfs (Nikolay/Damien)
---
 common/rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/rc b/common/rc
index 1c814b9aabf1..2f295fa05484 100644
--- a/common/rc
+++ b/common/rc
@@ -3778,7 +3778,7 @@ _get_available_space()
 # return device size in kb
 _get_device_size()
 {
-	grep -w `_short_dev $1` /proc/partitions | awk '{print $3}'
+	echo $(($(blockdev --getsz $1) >> 1))
 }
 
 # Make sure we actually have dmesg checking set up.
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] fstests: don't rely on /proc/partitions for device size
  2021-03-26 15:34 [PATCH v3] fstests: don't rely on /proc/partitions for device size Johannes Thumshirn
@ 2021-03-28 21:31 ` Damien Le Moal
  0 siblings, 0 replies; 2+ messages in thread
From: Damien Le Moal @ 2021-03-28 21:31 UTC (permalink / raw)
  To: Johannes Thumshirn, Eryu Guan
  Cc: fstests, linux-btrfs, Nikolay Borisov, Naohiro Aota

On 2021/03/27 0:34, Johannes Thumshirn wrote:
> Non-partitionable devices, like zoned block devices, aren't showing up in in
> /proc/partitions and therefore we cannot rely on it to get a device's size.
> 
> Use blockdev --getsz to get the block device size.
> 
> Cc: Naohiro Aota <naohiro.aota@wdc.com>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> 
> ---
> Changes to v2:
> - Don't forget the sectors to kb conversion (Damien)
> 
> Changes to v1:
> - Use blockdev --getsz instead of sysfs (Nikolay/Damien)
> ---
>  common/rc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/rc b/common/rc
> index 1c814b9aabf1..2f295fa05484 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -3778,7 +3778,7 @@ _get_available_space()
>  # return device size in kb
>  _get_device_size()
>  {
> -	grep -w `_short_dev $1` /proc/partitions | awk '{print $3}'
> +	echo $(($(blockdev --getsz $1) >> 1))
>  }
>  
>  # Make sure we actually have dmesg checking set up.
> 

Looks good to me.

Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>

-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-28 21:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26 15:34 [PATCH v3] fstests: don't rely on /proc/partitions for device size Johannes Thumshirn
2021-03-28 21:31 ` Damien Le Moal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).