[Devel] [PATCH RHEL7 COMMIT] blk-cbt: Don't open-code is_power_of_2() function

Konstantin Khorenko khorenko at virtuozzo.com
Wed Feb 22 20:15:15 MSK 2023


The commit is pushed to "branch-rh7-3.10.0-1160.83.1.vz7.194.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.83.1.vz7.194.4
------>
commit aad5d57d4c270aba388e717f74a765e75a619840
Author: Nikolay Borisov <nikolay.borisov at virtuozzo.com>
Date:   Fri Jan 27 13:34:40 2023 +0200

    blk-cbt: Don't open-code is_power_of_2() function
    
    Fixes: acdc18e4d1aa ("cbt: introduce changed block tracking")
    
    Signed-off-by: Nikolay Borisov <nikolay.borisov at virtuozzo.com>
    Reviewed-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
---
 block/blk-cbt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/block/blk-cbt.c b/block/blk-cbt.c
index 21a5d4019ee9..05241cdd57fe 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -17,6 +17,7 @@
 #include <linux/spinlock.h>
 #include <linux/pagemap.h>
 #include <linux/vmalloc.h>
+#include <linux/log2.h>
 #include <asm/atomic.h>
 #include <asm/uaccess.h>
 
@@ -484,7 +485,7 @@ static int cbt_ioc_init(struct block_device *bdev, struct blk_user_cbt_info __us
 	if (copy_from_user(&ci, ucbt_ioc, sizeof(ci)))
 		return -EFAULT;
 
-	if (((ci.ci_blksize -1) & ci.ci_blksize))
+	if (!is_power_of_2(ci.ci_blksize))
 		return -EINVAL;
 
 	q = bdev_get_queue(bdev);


More information about the Devel mailing list