Blame SOURCES/mdadm-bitmap-examine-bitmap-failed1-when-bitmap-is-ex.patch

2c1b57
From 8cc56e8b3269305ec5483527d853464eac3bf690 Mon Sep 17 00:00:00 2001
2c1b57
From: Zhilong Liu <zlliu@suse.com>
2c1b57
Date: Mon, 28 Aug 2017 17:24:27 +0800
2c1b57
Subject: [RHEL7.5 PATCH 04/13] mdadm/bitmap: examine-bitmap failed when bitmap
2c1b57
 is external mode
2c1b57
2c1b57
--examine-bitmap: the bitmap_file_open() shouldn't omit the
2c1b57
regular file descriptor when the bitmap is external mode.
2c1b57
Such as: ./mdadm -X /mnt/3
2c1b57
2c1b57
This commit is partial revert of commit 0a6bff09d416
2c1b57
(mdadm/util: unify fstat checking blkdev into function)
2c1b57
2c1b57
Signed-off-by: Zhilong Liu <zlliu@suse.com>
2c1b57
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
2c1b57
---
2c1b57
 bitmap.c | 12 +++++++-----
2c1b57
 1 file changed, 7 insertions(+), 5 deletions(-)
2c1b57
2c1b57
diff --git a/bitmap.c b/bitmap.c
2c1b57
index 3653660..e38cb96 100644
2c1b57
--- a/bitmap.c
2c1b57
+++ b/bitmap.c
2c1b57
@@ -183,6 +183,7 @@ static int
2c1b57
 bitmap_file_open(char *filename, struct supertype **stp, int node_num)
2c1b57
 {
2c1b57
 	int fd;
2c1b57
+	struct stat stb;
2c1b57
 	struct supertype *st = *stp;
2c1b57
 
2c1b57
 	fd = open(filename, O_RDONLY|O_DIRECT);
2c1b57
@@ -192,7 +193,12 @@ bitmap_file_open(char *filename, struct supertype **stp, int node_num)
2c1b57
 		return -1;
2c1b57
 	}
2c1b57
 
2c1b57
-	if (fstat_is_blkdev(fd, filename, NULL)) {
2c1b57
+	if (fstat(fd, &stb) < 0) {
2c1b57
+		pr_err("fstat failed for %s: %s\n", filename, strerror(errno));
2c1b57
+		close(fd);
2c1b57
+		return -1;
2c1b57
+	}
2c1b57
+	if ((stb.st_mode & S_IFMT) == S_IFBLK) {
2c1b57
 		/* block device, so we are probably after an internal bitmap */
2c1b57
 		if (!st)
2c1b57
 			st = guess_super(fd);
2c1b57
@@ -211,11 +217,7 @@ bitmap_file_open(char *filename, struct supertype **stp, int node_num)
2c1b57
 				fd = -1;
2c1b57
 			}
2c1b57
 		}
2c1b57
-
2c1b57
 		*stp = st;
2c1b57
-	} else {
2c1b57
-		close(fd);
2c1b57
-		return -1;
2c1b57
 	}
2c1b57
 
2c1b57
 	return fd;
2c1b57
-- 
2c1b57
2.7.4
2c1b57