aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2023-12-11 17:37:39 +0100
committerCarlos Maiolino <cem@kernel.org>2023-12-18 14:57:49 +0100
commit024b577aa8e7b43217e57f25585dc2617c1cc17b (patch)
tree432457bbd3ca87b25c398a108bf75ca44810f366
parent652683748da1333dee33f6d8634f33d294923bb8 (diff)
downloadxfsprogs-dev-024b577aa8e7b43217e57f25585dc2617c1cc17b.tar.gz
libxfs: pass the device fd to discard_blocks
No need to do a dev_t to fd lookup when the caller already has the fd. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r--mkfs/xfs_mkfs.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index dd5f4c8b64..01c6ce33bd 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1325,19 +1325,15 @@ done:
}
static void
-discard_blocks(dev_t dev, uint64_t nsectors, int quiet)
+discard_blocks(int fd, uint64_t nsectors, int quiet)
{
- int fd;
uint64_t offset = 0;
/* Discard the device 2G at a time */
const uint64_t step = 2ULL << 30;
const uint64_t count = BBTOB(nsectors);
- fd = libxfs_device_to_fd(dev);
- if (fd <= 0)
- return;
-
- /* The block discarding happens in smaller batches so it can be
+ /*
+ * The block discarding happens in smaller batches so it can be
* interrupted prematurely
*/
while (offset < count) {
@@ -2875,11 +2871,11 @@ discard_devices(
*/
if (!xi->disfile)
- discard_blocks(xi->ddev, xi->dsize, quiet);
+ discard_blocks(xi->dfd, xi->dsize, quiet);
if (xi->rtdev && !xi->risfile)
- discard_blocks(xi->rtdev, xi->rtsize, quiet);
+ discard_blocks(xi->rtfd, xi->rtsize, quiet);
if (xi->logdev && xi->logdev != xi->ddev && !xi->lisfile)
- discard_blocks(xi->logdev, xi->logBBsize, quiet);
+ discard_blocks(xi->logfd, xi->logBBsize, quiet);
}
static void