linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* md read-only fixes
@ 2021-02-01 13:17 Christoph Hellwig
  2021-02-01 13:17 ` [PATCH 1/2] md: check for NULL ->meta_bdev before calling bdev_read_only Christoph Hellwig
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Christoph Hellwig @ 2021-02-01 13:17 UTC (permalink / raw)
  To: axboe, song; +Cc: guoqing.jiang, linux-block, linux-raid

Hi all,

patch 1 fixes a regression in md in for-5.12/block, and patch 2
fixes a little inconsistency in the same area.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] md: check for NULL ->meta_bdev before calling bdev_read_only
  2021-02-01 13:17 md read-only fixes Christoph Hellwig
@ 2021-02-01 13:17 ` Christoph Hellwig
  2021-02-01 13:17 ` [PATCH 2/2] md: use rdev_read_only in restart_array Christoph Hellwig
  2021-02-01 16:35 ` md read-only fixes Jens Axboe
  2 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2021-02-01 13:17 UTC (permalink / raw)
  To: axboe, song; +Cc: guoqing.jiang, linux-block, linux-raid

->meta_bdev is optional and not set for most arrays.  Add a
rdev_read_only helper that calls bdev_read_only for both devices
in a safe way.

Fixes: 6f0d9689b670 ("block: remove the NULL bdev check in bdev_read_only")
Reported-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/md.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 399c81bddc1ae1..7c0f6107865383 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2399,6 +2399,12 @@ int md_integrity_add_rdev(struct md_rdev *rdev, struct mddev *mddev)
 }
 EXPORT_SYMBOL(md_integrity_add_rdev);
 
+static bool rdev_read_only(struct md_rdev *rdev)
+{
+	return bdev_read_only(rdev->bdev) ||
+		(rdev->meta_bdev && bdev_read_only(rdev->meta_bdev));
+}
+
 static int bind_rdev_to_array(struct md_rdev *rdev, struct mddev *mddev)
 {
 	char b[BDEVNAME_SIZE];
@@ -2408,8 +2414,7 @@ static int bind_rdev_to_array(struct md_rdev *rdev, struct mddev *mddev)
 	if (find_rdev(mddev, rdev->bdev->bd_dev))
 		return -EEXIST;
 
-	if ((bdev_read_only(rdev->bdev) || bdev_read_only(rdev->meta_bdev)) &&
-	    mddev->pers)
+	if (rdev_read_only(rdev) && mddev->pers)
 		return -EROFS;
 
 	/* make sure rdev->sectors exceeds mddev->dev_sectors */
@@ -5843,9 +5848,7 @@ int md_run(struct mddev *mddev)
 			continue;
 		sync_blockdev(rdev->bdev);
 		invalidate_bdev(rdev->bdev);
-		if (mddev->ro != 1 &&
-		    (bdev_read_only(rdev->bdev) ||
-		     bdev_read_only(rdev->meta_bdev))) {
+		if (mddev->ro != 1 && rdev_read_only(rdev)) {
 			mddev->ro = 1;
 			if (mddev->gendisk)
 				set_disk_ro(mddev->gendisk, 1);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] md: use rdev_read_only in restart_array
  2021-02-01 13:17 md read-only fixes Christoph Hellwig
  2021-02-01 13:17 ` [PATCH 1/2] md: check for NULL ->meta_bdev before calling bdev_read_only Christoph Hellwig
@ 2021-02-01 13:17 ` Christoph Hellwig
  2021-02-01 16:35 ` md read-only fixes Jens Axboe
  2 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2021-02-01 13:17 UTC (permalink / raw)
  To: axboe, song; +Cc: guoqing.jiang, linux-block, linux-raid

Make the read-only check in restart_array identical to the other two
read-only checks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/md/md.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7c0f6107865383..21da0c48f6c21e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6143,7 +6143,7 @@ static int restart_array(struct mddev *mddev)
 		if (test_bit(Journal, &rdev->flags) &&
 		    !test_bit(Faulty, &rdev->flags))
 			has_journal = true;
-		if (bdev_read_only(rdev->bdev))
+		if (rdev_read_only(rdev))
 			has_readonly = true;
 	}
 	rcu_read_unlock();
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: md read-only fixes
  2021-02-01 13:17 md read-only fixes Christoph Hellwig
  2021-02-01 13:17 ` [PATCH 1/2] md: check for NULL ->meta_bdev before calling bdev_read_only Christoph Hellwig
  2021-02-01 13:17 ` [PATCH 2/2] md: use rdev_read_only in restart_array Christoph Hellwig
@ 2021-02-01 16:35 ` Jens Axboe
  2021-02-18  9:30   ` Tkaczyk, Mariusz
  2 siblings, 1 reply; 6+ messages in thread
From: Jens Axboe @ 2021-02-01 16:35 UTC (permalink / raw)
  To: Christoph Hellwig, song; +Cc: guoqing.jiang, linux-block, linux-raid

On 2/1/21 6:17 AM, Christoph Hellwig wrote:
> Hi all,
> 
> patch 1 fixes a regression in md in for-5.12/block, and patch 2
> fixes a little inconsistency in the same area.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: md read-only fixes
  2021-02-01 16:35 ` md read-only fixes Jens Axboe
@ 2021-02-18  9:30   ` Tkaczyk, Mariusz
  2021-02-24  8:45     ` Song Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Tkaczyk, Mariusz @ 2021-02-18  9:30 UTC (permalink / raw)
  To: song; +Cc: linux-raid

On 01.02.2021 17:35, Jens Axboe wrote:
> On 2/1/21 6:17 AM, Christoph Hellwig wrote:
>> Hi all,
>>
>> patch 1 fixes a regression in md in for-5.12/block, and patch 2
>> fixes a little inconsistency in the same area.
> 
> Applied, thanks.
> 

Hi Song,
Could you cherry-pick those fixes? The issue blocks our daily tests.

Thanks,
Mariusz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: md read-only fixes
  2021-02-18  9:30   ` Tkaczyk, Mariusz
@ 2021-02-24  8:45     ` Song Liu
  0 siblings, 0 replies; 6+ messages in thread
From: Song Liu @ 2021-02-24  8:45 UTC (permalink / raw)
  To: Tkaczyk, Mariusz; +Cc: linux-raid

On Thu, Feb 18, 2021 at 1:31 AM Tkaczyk, Mariusz
<mariusz.tkaczyk@linux.intel.com> wrote:
>
> On 01.02.2021 17:35, Jens Axboe wrote:
> > On 2/1/21 6:17 AM, Christoph Hellwig wrote:
> >> Hi all,
> >>
> >> patch 1 fixes a regression in md in for-5.12/block, and patch 2
> >> fixes a little inconsistency in the same area.
> >
> > Applied, thanks.
> >
>
> Hi Song,
> Could you cherry-pick those fixes? The issue blocks our daily tests.

I rebased md-next on top of Linus' master branch. Could you please try the
tests?

Thanks,
Song

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-24  8:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 13:17 md read-only fixes Christoph Hellwig
2021-02-01 13:17 ` [PATCH 1/2] md: check for NULL ->meta_bdev before calling bdev_read_only Christoph Hellwig
2021-02-01 13:17 ` [PATCH 2/2] md: use rdev_read_only in restart_array Christoph Hellwig
2021-02-01 16:35 ` md read-only fixes Jens Axboe
2021-02-18  9:30   ` Tkaczyk, Mariusz
2021-02-24  8:45     ` Song Liu

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).