From: Christoph Hellwig Date: Tue, 14 Apr 2026 08:17:47 +0000 (+0200) Subject: zloop: use vfs_truncate X-Git-Tag: v7.1-rc1~10^2~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14e0077911e3d5e11e94417861e700cbb521a107;p=thirdparty%2Fkernel%2Flinux.git zloop: use vfs_truncate 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 Reviewed-by: Damien Le Moal Reviewed-by: Johannes Thumshirn Link: https://patch.msgid.link/20260414081811.549755-3-hch@lst.de Signed-off-by: Jens Axboe --- 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 @@ out: 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); } }