- 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 <[email protected]>
---
 block/blk-cbt.c |    7 +++----
 1 files 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;
-- 
1.7.1

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to