dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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