From: Gleb C. <lna...@ya...> - 2024-07-08 10:47:52
|
Commit: 5f4eee5 GitHub URL: https://github.com/SCST-project/scst/commit/5f4eee5fc938a655710c18a9997dc5d780e46673 Author: Gleb Chesnokov Date: 2024-07-08T13:45:29+03:00 Log Message: ----------- 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. Modified Paths: -------------- scst/include/backport.h | 12 ++++++++++++ scst/src/scst_lib.c | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) =================================================================== diff --git a/scst/include/backport.h b/scst/include/backport.h index c540277..7967508 100644 --- a/scst/include/backport.h +++ b/scst/include/backport.h @@ -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)) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 8823921..ba776be 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -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; |