dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

Blame SOURCES/0016-Fix-reshape-for-decreasing-data-offset.patch

8fbece
From cab114c5ca870e5f1b57fb2602cd9a038271c2e0 Mon Sep 17 00:00:00 2001
8fbece
From: Corey Hickey <bugfood-c@fatooh.org>
8fbece
Date: Mon, 11 Feb 2019 17:18:38 -0800
8fbece
Subject: [RHEL7.7 PATCH 16/24] Fix reshape for decreasing data offset
8fbece
8fbece
...when not changing the number of disks.
8fbece
8fbece
This patch needs context to explain. These are the relevant parts of
8fbece
the original code (condensed and annotated):
8fbece
8fbece
if (dir > 0) {
8fbece
    /* Increase data offset (reshape backwards) */
8fbece
    if (data_offset < sd->data_offset + min) {
8fbece
        pr_err("--data-offset too small on %s\n",
8fbece
               dn);
8fbece
        goto release;
8fbece
    }
8fbece
} else {
8fbece
    /* Decrease data offset (reshape forwards) */
8fbece
    if (data_offset < sd->data_offset - min) {
8fbece
        pr_err("--data-offset too small on %s\n",
8fbece
               dn);
8fbece
        goto release;
8fbece
    }
8fbece
}
8fbece
8fbece
When this code is reached, mdadm has already decided on a reshape
8fbece
direction. When increasing the data offset, the reshape runs backwards
8fbece
(dir==1); when decreasing the data offset, the reshape runs forwards
8fbece
(dir==-1).
8fbece
8fbece
The conditional within the backwards reshape is correct: the requested
8fbece
offset must be larger than the old offset plus a minimum delta; thus the
8fbece
reshape has room to work.
8fbece
8fbece
For the forwards reshape, the requested offset needs to be smaller than
8fbece
the old offset minus a minimum delta; to do this correctly, the
8fbece
comparison must be reversed.
8fbece
8fbece
Also update the error message.
8fbece
8fbece
Note: I have tested this change on a RAID 5 on Linux 4.18.0 and verified
8fbece
that there were no errors from the kernel and that the device data
8fbece
remained intact. I do not know if there are considerations for different
8fbece
RAID levels.
8fbece
8fbece
Signed-off-by: Corey Hickey <bugfood-c@fatooh.org>
8fbece
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
8fbece
---
8fbece
 Grow.c | 4 ++--
8fbece
 1 file changed, 2 insertions(+), 2 deletions(-)
8fbece
8fbece
diff --git a/Grow.c b/Grow.c
8fbece
index 6d32661..764374f 100644
8fbece
--- a/Grow.c
8fbece
+++ b/Grow.c
8fbece
@@ -2613,8 +2613,8 @@ static int set_new_data_offset(struct mdinfo *sra, struct supertype *st,
8fbece
 					goto release;
8fbece
 				}
8fbece
 				if (data_offset != INVALID_SECTORS &&
8fbece
-				    data_offset < sd->data_offset - min) {
8fbece
-					pr_err("--data-offset too small on %s\n",
8fbece
+				    data_offset > sd->data_offset - min) {
8fbece
+					pr_err("--data-offset too large on %s\n",
8fbece
 						dn);
8fbece
 					goto release;
8fbece
 				}
8fbece
-- 
8fbece
2.7.5
8fbece