[Devel] [PATCH RHEL7 COMMIT] cbt: fix blk_cbt_set endless loop

Konstantin Khorenko khorenko at virtuozzo.com
Thu Feb 11 02:15:41 PST 2016


The commit is pushed to "branch-rh7-3.10.0-327.3.1-vz7.10.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.3.1.vz7.10.11
------>
commit 7a131de1ebbae1691b0b96e3d8c322a0d0a06bad
Author: Dmitry Monakhov <dmonakhov at openvz.org>
Date:   Thu Feb 11 14:15:40 2016 +0400

    cbt: fix blk_cbt_set endless loop
    
    - If (count % BITS_PER_PAGE == 0) we stuck in endless loop.
    - (!set) case was also wrong
    
    https://jira.sw.ru/browse/PSBM-43936
    
    Signed-off-by: Dmitry Monakhov <dmonakhov at openvz.org>
    Reviewed-by: Vasily Averin <vvs at virtuozzo.com>
---
 block/blk-cbt.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/block/blk-cbt.c b/block/blk-cbt.c
index 99d4a76..7a4303f 100644
--- a/block/blk-cbt.c
+++ b/block/blk-cbt.c
@@ -93,10 +93,9 @@ static int __blk_cbt_set(struct cbt_info  *cbt, blkcnt_t block,
 	while(count) {
 		unsigned long idx = block >> (PAGE_SHIFT + 3);
 		unsigned long off = block & (BITS_PER_PAGE -1);
-		unsigned long len = count & (BITS_PER_PAGE -1);
+		unsigned long len = min_t(unsigned long, BITS_PER_PAGE - off,
+					  count);
 
-		if (off + len > BITS_PER_PAGE)
-			len = BITS_PER_PAGE - off;
 		page = rcu_dereference(cbt->map[idx]);
 		if (page) {
 			spin_lock_page(page);
@@ -107,7 +106,7 @@ static int __blk_cbt_set(struct cbt_info  *cbt, blkcnt_t block,
 			continue;
 		} else {
 			if (!set) {
-				len = count & (BITS_PER_PAGE -1);
+				/* Nothing to do */
 				count -= len;
 				block += len;
 				continue;


More information about the Devel mailing list