]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
zloop: use vfs_truncate
authorChristoph Hellwig <hch@lst.de>
Tue, 14 Apr 2026 08:17:47 +0000 (10:17 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 15 Apr 2026 19:58:36 +0000 (13:58 -0600)
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>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Link: https://patch.msgid.link/20260414081811.549755-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/zloop.c

index 672948d3653e3f1fd5abf7cb8f9e69a0d72d65b9..fc54480ed62d3991a36a0e145819f5507f0ed0b9 100644 (file)
@@ -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);
        }
 }