dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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