linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhilong Liu <zlliu@suse.com>
To: Jes.Sorensen@gmail.com
Cc: linux-raid@vger.kernel.org, Zhilong Liu <zlliu@suse.com>
Subject: [PATCH 1/5] mdadm/bitmap: examine-bitmap failed when bitmap is external mode
Date: Mon, 28 Aug 2017 17:24:27 +0800	[thread overview]
Message-ID: <1503912271-6463-2-git-send-email-zlliu@suse.com> (raw)
In-Reply-To: <1503912271-6463-1-git-send-email-zlliu@suse.com>

--examine-bitmap: the bitmap_file_open() shouldn't omit the
regular file descriptor when the bitmap is external mode.
Such as: ./mdadm -X /mnt/3

This commit is partial revert of commit 0a6bff09d416
(mdadm/util: unify fstat checking blkdev into function)

Signed-off-by: Zhilong Liu <zlliu@suse.com>
---
 bitmap.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/bitmap.c b/bitmap.c
index 3653660..de5f9db 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -183,6 +183,7 @@ static int
 bitmap_file_open(char *filename, struct supertype **stp, int node_num)
 {
 	int fd;
+	struct stat stb;
 	struct supertype *st = *stp;
 
 	fd = open(filename, O_RDONLY|O_DIRECT);
@@ -192,7 +193,13 @@ bitmap_file_open(char *filename, struct supertype **stp, int node_num)
 		return -1;
 	}
 
-	if (fstat_is_blkdev(fd, filename, NULL)) {
+	if (fstat(fd, &stb) < 0) {
+		pr_err("fstat failed for %s: %s\n",
+			filename, strerror(errno));
+		close(fd);
+		return -1;
+	}
+	if ((stb.st_mode & S_IFMT) == S_IFBLK) {
 		/* block device, so we are probably after an internal bitmap */
 		if (!st)
 			st = guess_super(fd);
@@ -211,11 +218,7 @@ bitmap_file_open(char *filename, struct supertype **stp, int node_num)
 				fd = -1;
 			}
 		}
-
 		*stp = st;
-	} else {
-		close(fd);
-		return -1;
 	}
 
 	return fd;
-- 
2.6.6


  reply	other threads:[~2017-08-28  9:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28  9:24 [PATCH 0/5] mdadm/test: Update for mdadm test part Zhilong Liu
2017-08-28  9:24 ` Zhilong Liu [this message]
2017-09-01 15:20   ` [PATCH 1/5] mdadm/bitmap: examine-bitmap failed when bitmap is external mode Jes Sorensen
2017-08-28  9:24 ` [PATCH 2/5] mdadm/test: use the first element of array as parsing condition Zhilong Liu
2017-09-01 15:22   ` Jes Sorensen
2017-08-28  9:24 ` [PATCH 3/5] mdadm/test: get rid of the tests/testdev Zhilong Liu
2017-09-01 15:26   ` Jes Sorensen
2017-08-28  9:24 ` [PATCH 4/5] mdadm/test: get rid of tests/check Zhilong Liu
2017-09-01 15:27   ` Jes Sorensen
2017-08-28  9:24 ` [PATCH 5/5] mdadm/test: add new testcase for testing readonly/readwrite Zhilong Liu
2017-09-01 15:28   ` Jes Sorensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1503912271-6463-2-git-send-email-zlliu@suse.com \
    --to=zlliu@suse.com \
    --cc=Jes.Sorensen@gmail.com \
    --cc=linux-raid@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).