dcavalca / rpms / mdadm

Forked from rpms/mdadm 3 years ago
Clone

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

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