mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
blk_ioctl_{discard,zeroout}(): we only want ->bd_inode->i_mapping here...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Link: https://lore.kernel.org/r/20240411145346.2516848-6-viro@zeniv.linux.org.uk Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
22f89a4f8c
commit
881494ed03
@ -97,7 +97,6 @@ static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode,
|
|||||||
{
|
{
|
||||||
uint64_t range[2];
|
uint64_t range[2];
|
||||||
uint64_t start, len, end;
|
uint64_t start, len, end;
|
||||||
struct inode *inode = bdev->bd_inode;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!(mode & BLK_OPEN_WRITE))
|
if (!(mode & BLK_OPEN_WRITE))
|
||||||
@ -121,13 +120,13 @@ static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode,
|
|||||||
end > bdev_nr_bytes(bdev))
|
end > bdev_nr_bytes(bdev))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
filemap_invalidate_lock(inode->i_mapping);
|
filemap_invalidate_lock(bdev->bd_mapping);
|
||||||
err = truncate_bdev_range(bdev, mode, start, start + len - 1);
|
err = truncate_bdev_range(bdev, mode, start, start + len - 1);
|
||||||
if (err)
|
if (err)
|
||||||
goto fail;
|
goto fail;
|
||||||
err = blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL);
|
err = blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL);
|
||||||
fail:
|
fail:
|
||||||
filemap_invalidate_unlock(inode->i_mapping);
|
filemap_invalidate_unlock(bdev->bd_mapping);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +166,6 @@ static int blk_ioctl_zeroout(struct block_device *bdev, blk_mode_t mode,
|
|||||||
{
|
{
|
||||||
uint64_t range[2];
|
uint64_t range[2];
|
||||||
uint64_t start, end, len;
|
uint64_t start, end, len;
|
||||||
struct inode *inode = bdev->bd_inode;
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!(mode & BLK_OPEN_WRITE))
|
if (!(mode & BLK_OPEN_WRITE))
|
||||||
@ -190,7 +188,7 @@ static int blk_ioctl_zeroout(struct block_device *bdev, blk_mode_t mode,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Invalidate the page cache, including dirty pages */
|
/* Invalidate the page cache, including dirty pages */
|
||||||
filemap_invalidate_lock(inode->i_mapping);
|
filemap_invalidate_lock(bdev->bd_mapping);
|
||||||
err = truncate_bdev_range(bdev, mode, start, end);
|
err = truncate_bdev_range(bdev, mode, start, end);
|
||||||
if (err)
|
if (err)
|
||||||
goto fail;
|
goto fail;
|
||||||
@ -199,7 +197,7 @@ static int blk_ioctl_zeroout(struct block_device *bdev, blk_mode_t mode,
|
|||||||
BLKDEV_ZERO_NOUNMAP);
|
BLKDEV_ZERO_NOUNMAP);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
filemap_invalidate_unlock(inode->i_mapping);
|
filemap_invalidate_unlock(bdev->bd_mapping);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user