scst_lib: use bdev_nr_bytes(bdev) instead of i_size_read(bdev->bd_inode)

Use the helper to query the size of a block device in bytes.
This commit is contained in:
Gleb Chesnokov
2024-07-08 13:45:29 +03:00
parent ad35eef335
commit 5f4eee5fc9
2 changed files with 13 additions and 1 deletions
+12
View File
@@ -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))
+1 -1
View File
@@ -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;