Skip to content

Commit

Permalink
pstore/blk: use bdev_nr_bytes instead of open coding it
Browse files Browse the repository at this point in the history
Use the proper helper to read the block device size.

Signed-off-by: Christoph Hellwig <[email protected]>
Acked-by: Kees Cook <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Christoph Hellwig authored and axboe committed Oct 18, 2021
1 parent d54f13a commit 4646198
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions fs/pstore/blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ static ssize_t psblk_generic_blk_write(const char *buf, size_t bytes,
static int __register_pstore_blk(struct pstore_device_info *dev,
const char *devpath)
{
struct inode *inode;
int ret = -ENODEV;

lockdep_assert_held(&pstore_blk_lock);
Expand All @@ -217,14 +216,13 @@ static int __register_pstore_blk(struct pstore_device_info *dev,
goto err;
}

inode = file_inode(psblk_file);
if (!S_ISBLK(inode->i_mode)) {
if (!S_ISBLK(file_inode(psblk_file)->i_mode)) {
pr_err("'%s' is not block device!\n", devpath);
goto err_fput;
}

inode = I_BDEV(psblk_file->f_mapping->host)->bd_inode;
dev->zone.total_size = i_size_read(inode);
dev->zone.total_size =
bdev_nr_bytes(I_BDEV(psblk_file->f_mapping->host));

ret = __register_pstore_device(dev);
if (ret)
Expand Down

0 comments on commit 4646198

Please sign in to comment.