[lustre-devel] [PATCH 143/151] lustre: ldlm: simplify lock_mode_to_index()

James Simmons jsimmons at infradead.org
Mon Sep 30 11:56:42 PDT 2019


From: NeilBrown <neilb at suse.com>

This function has the same effect as ilog2(), so just use ilog2
directly.

WC-bug-id: https://jira.whamcloud.com/browse/LU-12542
Lustre-commit: 32ae82e57cf8 ("LU-12542 ldlm: simplify lock_mode_to_index()")
Signed-off-by: NeilBrown <neilb at suse.com>
Reviewed-on: https://review.whamcloud.com/35486
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/ldlm/ldlm_extent.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/lustre/ldlm/ldlm_extent.c b/fs/lustre/ldlm/ldlm_extent.c
index 77d3e79..7c72d04 100644
--- a/fs/lustre/ldlm/ldlm_extent.c
+++ b/fs/lustre/ldlm/ldlm_extent.c
@@ -139,8 +139,7 @@ static inline int lock_mode_to_index(enum ldlm_mode mode)
 
 	LASSERT(mode != 0);
 	LASSERT(is_power_of_2(mode));
-	for (index = -1; mode; index++)
-		mode >>= 1;
+	index = ilog2(mode);
 	LASSERT(index < LCK_MODE_NUM);
 	return index;
 }
-- 
1.8.3.1



More information about the lustre-devel mailing list