Skip to content

Commit 14e0077

Browse files
Christoph Hellwigaxboe
authored andcommitted
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 <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 32be3c0 commit 14e0077

1 file changed

Lines changed: 2 additions & 15 deletions

File tree

drivers/block/zloop.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,20 +1363,6 @@ static int zloop_ctl_add(struct zloop_options *opts)
13631363
return ret;
13641364
}
13651365

1366-
static void zloop_truncate(struct file *file, loff_t pos)
1367-
{
1368-
struct mnt_idmap *idmap = file_mnt_idmap(file);
1369-
struct dentry *dentry = file_dentry(file);
1370-
struct iattr newattrs;
1371-
1372-
newattrs.ia_size = pos;
1373-
newattrs.ia_valid = ATTR_SIZE;
1374-
1375-
inode_lock(dentry->d_inode);
1376-
notify_change(idmap, dentry, &newattrs, NULL);
1377-
inode_unlock(dentry->d_inode);
1378-
}
1379-
13801366
static void zloop_forget_cache(struct zloop_device *zlo)
13811367
{
13821368
unsigned int i;
@@ -1411,7 +1397,8 @@ static void zloop_forget_cache(struct zloop_device *zlo)
14111397
if (WARN_ON_ONCE(old_wp == ULLONG_MAX))
14121398
continue;
14131399

1414-
zloop_truncate(file, (old_wp - zone->start) << SECTOR_SHIFT);
1400+
vfs_truncate(&file->f_path,
1401+
(old_wp - zone->start) << SECTOR_SHIFT);
14151402
}
14161403
}
14171404

0 commit comments

Comments
 (0)