From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>, Damien Le Moal <dlemoal@kernel.org>
Cc: linux-block@vger.kernel.org
Subject: [PATCH 2/6] zloop: use vfs_truncate
Date: Tue, 14 Apr 2026 10:17:47 +0200 [thread overview]
Message-ID: <20260414081811.549755-3-hch@lst.de> (raw)
In-Reply-To: <20260414081811.549755-1-hch@lst.de>
While vfs_truncate does various extra checks that we don't really need,
it is always better to use a VFS helper rather than open coding the
logic.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/block/zloop.c | 17 ++---------------
1 file changed, 2 insertions(+), 15 deletions(-)
diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
index 672948d3653e..fc54480ed62d 100644
--- a/drivers/block/zloop.c
+++ b/drivers/block/zloop.c
@@ -1363,20 +1363,6 @@ static int zloop_ctl_add(struct zloop_options *opts)
return ret;
}
-static void zloop_truncate(struct file *file, loff_t pos)
-{
- struct mnt_idmap *idmap = file_mnt_idmap(file);
- struct dentry *dentry = file_dentry(file);
- struct iattr newattrs;
-
- newattrs.ia_size = pos;
- newattrs.ia_valid = ATTR_SIZE;
-
- inode_lock(dentry->d_inode);
- notify_change(idmap, dentry, &newattrs, NULL);
- inode_unlock(dentry->d_inode);
-}
-
static void zloop_forget_cache(struct zloop_device *zlo)
{
unsigned int i;
@@ -1411,7 +1397,8 @@ static void zloop_forget_cache(struct zloop_device *zlo)
if (WARN_ON_ONCE(old_wp == ULLONG_MAX))
continue;
- zloop_truncate(file, (old_wp - zone->start) << SECTOR_SHIFT);
+ vfs_truncate(&file->f_path,
+ (old_wp - zone->start) << SECTOR_SHIFT);
}
}
--
2.53.0
next prev parent reply other threads:[~2026-04-14 8:18 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-14 8:17 zloop fixes Christoph Hellwig
2026-04-14 8:17 ` [PATCH 1/6] zloop: fix write pointer calculation in zloop_forget_cache Christoph Hellwig
2026-04-14 9:26 ` Damien Le Moal
2026-04-14 8:17 ` Christoph Hellwig [this message]
2026-04-14 9:26 ` [PATCH 2/6] zloop: use vfs_truncate Damien Le Moal
2026-04-14 8:17 ` [PATCH 3/6] zloop: improve the unaligned write pointer warning Christoph Hellwig
2026-04-14 9:27 ` Damien Le Moal
2026-04-14 8:17 ` [PATCH 4/6] zloop: set RQF_QUIET when completing requests on deleted devices Christoph Hellwig
2026-04-14 9:28 ` Damien Le Moal
2026-04-14 8:17 ` [PATCH 5/6] zloop: factor out zloop_mark_{full,empty} helpers Christoph Hellwig
2026-04-14 9:29 ` Damien Le Moal
2026-04-14 8:17 ` [PATCH 6/6] zloop: remove irq-safe locking Christoph Hellwig
2026-04-14 9:30 ` Damien Le Moal
2026-04-14 16:20 ` zloop fixes Johannes Thumshirn
2026-04-15 20:03 ` Jens Axboe
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=20260414081811.549755-3-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--cc=linux-block@vger.kernel.org \
/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