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

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