From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
To: Eryu Guan <guan@eryu.me>
Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org,
Nikolay Borisov <nborisov@suse.com>,
Damien Le Moal <Damien.LeMoal@wdc.com>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
Naohiro Aota <naohiro.aota@wdc.com>
Subject: [PATCH v3] fstests: don't rely on /proc/partitions for device size
Date: Sat, 27 Mar 2021 00:34:37 +0900 [thread overview]
Message-ID: <20210326153437.27840-1-johannes.thumshirn@wdc.com> (raw)
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
next reply other threads:[~2021-03-26 15:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-26 15:34 Johannes Thumshirn [this message]
2021-03-28 21:31 ` [PATCH v3] fstests: don't rely on /proc/partitions for device size Damien Le Moal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210326153437.27840-1-johannes.thumshirn@wdc.com \
--to=johannes.thumshirn@wdc.com \
--cc=Damien.LeMoal@wdc.com \
--cc=fstests@vger.kernel.org \
--cc=guan@eryu.me \
--cc=linux-btrfs@vger.kernel.org \
--cc=naohiro.aota@wdc.com \
--cc=nborisov@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).