Skip to content

Commit

Permalink
scst_lib: use bdev_nr_bytes(bdev) instead of i_size_read(bdev->bd_inode)
Browse files Browse the repository at this point in the history
Use the helper to query the size of a block device in bytes.
  • Loading branch information
lnocturno committed Jul 8, 2024
1 parent ad35eef commit 5f4eee5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions scst/include/backport.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,18 @@ static inline void bdev_release_backport(struct bdev_handle *handle)

#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0)
/*
* See also commit 6436bd90f76e ("block: add a bdev_nr_bytes helper") # v5.16.
*/
static inline loff_t bdev_nr_bytes_backport(struct block_device *bdev)
{
return i_size_read(bdev->bd_inode);
}

#define bdev_nr_bytes bdev_nr_bytes_backport
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) && \
(!defined(RHEL_RELEASE_CODE) || \
RHEL_RELEASE_CODE -0 < RHEL_RELEASE_VERSION(9, 1))
Expand Down
2 changes: 1 addition & 1 deletion scst/src/scst_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -6178,7 +6178,7 @@ loff_t scst_bdev_size(const char *path)
if (rc)
return rc;

res = i_size_read(bdev_desc.bdev->bd_inode);
res = bdev_nr_bytes(bdev_desc.bdev);

scst_release_bdev(&bdev_desc);
return res;
Expand Down

0 comments on commit 5f4eee5

Please sign in to comment.