linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] misc patches for md
@ 2020-07-28 10:01 Guoqing Jiang
  2020-07-28 10:01 ` [PATCH 1/5] md: register new md sysfs file 'uuid' read-only Guoqing Jiang
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Guoqing Jiang @ 2020-07-28 10:01 UTC (permalink / raw)
  To: song; +Cc: linux-raid, Guoqing Jiang

Hi,

Please review the patchset which has quite small change, :).

Thanks,
Guoqing

Guoqing Jiang (5):
  md: register new md sysfs file 'uuid' read-only
  md/raid5: remove the redundant setting of STRIPE_HANDLE
  md: print errno in super_written
  raid5-cache: hold spinlock instead of mutex in r5c_journal_mode_show
  raid5: don't duplicate code for different paths in handle_stripe

 Documentation/admin-guide/md.rst |  4 ++++
 drivers/md/md.c                  | 12 +++++++++++-
 drivers/md/raid5-cache.c         |  9 +++------
 drivers/md/raid5.c               | 17 +++++------------
 4 files changed, 23 insertions(+), 19 deletions(-)

-- 
2.17.1

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

* [PATCH 1/5] md: register new md sysfs file 'uuid' read-only
  2020-07-28 10:01 [PATCH 0/5] misc patches for md Guoqing Jiang
@ 2020-07-28 10:01 ` Guoqing Jiang
  2020-07-28 10:01 ` [PATCH 2/5] md/raid5: remove the redundant setting of STRIPE_HANDLE Guoqing Jiang
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Guoqing Jiang @ 2020-07-28 10:01 UTC (permalink / raw)
  To: song; +Cc: linux-raid, Sebastian Parschauer, Guoqing Jiang

From: Sebastian Parschauer <s.parschauer@gmx.de>

Report the UUID of the MD array in the following format:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

This is useful if you don't want to wait for udev to identify array.
And it is also easy for script to monitor it with the format.

Signed-off-by: Sebastian Parschauer <s.parschauer@gmx.de>
[Guoqing: mention the change in md.rst]
Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
---
 Documentation/admin-guide/md.rst | 4 ++++
 drivers/md/md.c                  | 9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/Documentation/admin-guide/md.rst b/Documentation/admin-guide/md.rst
index d973d469ffc4..cc8781b96b4d 100644
--- a/Documentation/admin-guide/md.rst
+++ b/Documentation/admin-guide/md.rst
@@ -426,6 +426,10 @@ All md devices contain:
      The accepted values when writing to this file are ``ppl`` and ``resync``,
      used to enable and disable PPL.
 
+  uuid
+     This indicates the UUID of the array in the following format:
+     xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
+
 
 As component devices are added to an md array, they appear in the ``md``
 directory as new directories named::
diff --git a/drivers/md/md.c b/drivers/md/md.c
index ea48bc25cce1..0c2a0e65b4f1 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -4225,6 +4225,14 @@ raid_disks_store(struct mddev *mddev, const char *buf, size_t len)
 static struct md_sysfs_entry md_raid_disks =
 __ATTR(raid_disks, S_IRUGO|S_IWUSR, raid_disks_show, raid_disks_store);
 
+static ssize_t
+uuid_show(struct mddev *mddev, char *page)
+{
+	return sprintf(page, "%pU\n", mddev->uuid);
+}
+static struct md_sysfs_entry md_uuid =
+__ATTR(uuid, S_IRUGO, uuid_show, NULL);
+
 static ssize_t
 chunk_size_show(struct mddev *mddev, char *page)
 {
@@ -5481,6 +5489,7 @@ static struct attribute *md_default_attrs[] = {
 	&md_level.attr,
 	&md_layout.attr,
 	&md_raid_disks.attr,
+	&md_uuid.attr,
 	&md_chunk_size.attr,
 	&md_size.attr,
 	&md_resync_start.attr,
-- 
2.17.1

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

* [PATCH 2/5] md/raid5: remove the redundant setting of STRIPE_HANDLE
  2020-07-28 10:01 [PATCH 0/5] misc patches for md Guoqing Jiang
  2020-07-28 10:01 ` [PATCH 1/5] md: register new md sysfs file 'uuid' read-only Guoqing Jiang
@ 2020-07-28 10:01 ` Guoqing Jiang
  2020-07-28 10:01 ` [PATCH 3/5] md: print errno in super_written Guoqing Jiang
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Guoqing Jiang @ 2020-07-28 10:01 UTC (permalink / raw)
  To: song; +Cc: linux-raid, Guoqing Jiang

The flag is already set before compare rcw with rmw, so it is
not necessary to do it again.

Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
---
 drivers/md/raid5.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index a6ff6e1e039b..790d91aa5f40 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3995,10 +3995,8 @@ static int handle_stripe_dirtying(struct r5conf *conf,
 					set_bit(R5_LOCKED, &dev->flags);
 					set_bit(R5_Wantread, &dev->flags);
 					s->locked++;
-				} else {
+				} else
 					set_bit(STRIPE_DELAYED, &sh->state);
-					set_bit(STRIPE_HANDLE, &sh->state);
-				}
 			}
 		}
 	}
@@ -4023,10 +4021,8 @@ static int handle_stripe_dirtying(struct r5conf *conf,
 					set_bit(R5_Wantread, &dev->flags);
 					s->locked++;
 					qread++;
-				} else {
+				} else
 					set_bit(STRIPE_DELAYED, &sh->state);
-					set_bit(STRIPE_HANDLE, &sh->state);
-				}
 			}
 		}
 		if (rcw && conf->mddev->queue)
-- 
2.17.1

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

* [PATCH 3/5] md: print errno in super_written
  2020-07-28 10:01 [PATCH 0/5] misc patches for md Guoqing Jiang
  2020-07-28 10:01 ` [PATCH 1/5] md: register new md sysfs file 'uuid' read-only Guoqing Jiang
  2020-07-28 10:01 ` [PATCH 2/5] md/raid5: remove the redundant setting of STRIPE_HANDLE Guoqing Jiang
@ 2020-07-28 10:01 ` Guoqing Jiang
  2020-07-28 10:01 ` [PATCH 4/5] raid5-cache: hold spinlock instead of mutex in r5c_journal_mode_show Guoqing Jiang
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Guoqing Jiang @ 2020-07-28 10:01 UTC (permalink / raw)
  To: song; +Cc: linux-raid, Guoqing Jiang

It is better to print errno instead of bi_status.

Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
---
 drivers/md/md.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 0c2a0e65b4f1..8f9a89b4c7ba 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -978,7 +978,8 @@ static void super_written(struct bio *bio)
 	struct mddev *mddev = rdev->mddev;
 
 	if (bio->bi_status) {
-		pr_err("md: super_written gets error=%d\n", bio->bi_status);
+		pr_err("md: %s gets error=%d\n", __func__,
+		       blk_status_to_errno(bio->bi_status));
 		md_error(mddev, rdev);
 		if (!test_bit(Faulty, &rdev->flags)
 		    && (bio->bi_opf & MD_FAILFAST)) {
-- 
2.17.1

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

* [PATCH 4/5] raid5-cache: hold spinlock instead of mutex in r5c_journal_mode_show
  2020-07-28 10:01 [PATCH 0/5] misc patches for md Guoqing Jiang
                   ` (2 preceding siblings ...)
  2020-07-28 10:01 ` [PATCH 3/5] md: print errno in super_written Guoqing Jiang
@ 2020-07-28 10:01 ` Guoqing Jiang
  2020-07-28 10:01 ` [PATCH 5/5] raid5: don't duplicate code for different paths in handle_stripe Guoqing Jiang
  2020-07-29  1:14 ` [PATCH 0/5] misc patches for md Song Liu
  5 siblings, 0 replies; 7+ messages in thread
From: Guoqing Jiang @ 2020-07-28 10:01 UTC (permalink / raw)
  To: song; +Cc: linux-raid, Guoqing Jiang

Replace mddev_lock with spin_lock to align with other show methods in
raid5_attrs.

Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
---
 drivers/md/raid5-cache.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 82eb4a906e31..4337ae0e6af2 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -2537,13 +2537,10 @@ static ssize_t r5c_journal_mode_show(struct mddev *mddev, char *page)
 	struct r5conf *conf;
 	int ret;
 
-	ret = mddev_lock(mddev);
-	if (ret)
-		return ret;
-
+	spin_lock(&mddev->lock);
 	conf = mddev->private;
 	if (!conf || !conf->log) {
-		mddev_unlock(mddev);
+		spin_unlock(&mddev->lock);
 		return 0;
 	}
 
@@ -2563,7 +2560,7 @@ static ssize_t r5c_journal_mode_show(struct mddev *mddev, char *page)
 	default:
 		ret = 0;
 	}
-	mddev_unlock(mddev);
+	spin_unlock(&mddev->lock);
 	return ret;
 }
 
-- 
2.17.1

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

* [PATCH 5/5] raid5: don't duplicate code for different paths in handle_stripe
  2020-07-28 10:01 [PATCH 0/5] misc patches for md Guoqing Jiang
                   ` (3 preceding siblings ...)
  2020-07-28 10:01 ` [PATCH 4/5] raid5-cache: hold spinlock instead of mutex in r5c_journal_mode_show Guoqing Jiang
@ 2020-07-28 10:01 ` Guoqing Jiang
  2020-07-29  1:14 ` [PATCH 0/5] misc patches for md Song Liu
  5 siblings, 0 replies; 7+ messages in thread
From: Guoqing Jiang @ 2020-07-28 10:01 UTC (permalink / raw)
  To: song; +Cc: linux-raid, Guoqing Jiang

As we can see, R5_LOCKED is set and s.locked is increased whether
R5_ReWrite is set or not, so move it to common path.

Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com>
---
 drivers/md/raid5.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 790d91aa5f40..b06edfaa73b0 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -4966,14 +4966,11 @@ static void handle_stripe(struct stripe_head *sh)
 				if (!test_bit(R5_ReWrite, &dev->flags)) {
 					set_bit(R5_Wantwrite, &dev->flags);
 					set_bit(R5_ReWrite, &dev->flags);
-					set_bit(R5_LOCKED, &dev->flags);
-					s.locked++;
-				} else {
+				} else
 					/* let's read it back */
 					set_bit(R5_Wantread, &dev->flags);
-					set_bit(R5_LOCKED, &dev->flags);
-					s.locked++;
-				}
+				set_bit(R5_LOCKED, &dev->flags);
+				s.locked++;
 			}
 		}
 
-- 
2.17.1

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

* Re: [PATCH 0/5] misc patches for md
  2020-07-28 10:01 [PATCH 0/5] misc patches for md Guoqing Jiang
                   ` (4 preceding siblings ...)
  2020-07-28 10:01 ` [PATCH 5/5] raid5: don't duplicate code for different paths in handle_stripe Guoqing Jiang
@ 2020-07-29  1:14 ` Song Liu
  5 siblings, 0 replies; 7+ messages in thread
From: Song Liu @ 2020-07-29  1:14 UTC (permalink / raw)
  To: Guoqing Jiang; +Cc: linux-raid

On Tue, Jul 28, 2020 at 3:02 AM Guoqing Jiang
<guoqing.jiang@cloud.ionos.com> wrote:
>
> Hi,
>
> Please review the patchset which has quite small change, :).
>
> Thanks,
> Guoqing


Applied to md-next. Thanks for the fixes!

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

end of thread, other threads:[~2020-07-29  1:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28 10:01 [PATCH 0/5] misc patches for md Guoqing Jiang
2020-07-28 10:01 ` [PATCH 1/5] md: register new md sysfs file 'uuid' read-only Guoqing Jiang
2020-07-28 10:01 ` [PATCH 2/5] md/raid5: remove the redundant setting of STRIPE_HANDLE Guoqing Jiang
2020-07-28 10:01 ` [PATCH 3/5] md: print errno in super_written Guoqing Jiang
2020-07-28 10:01 ` [PATCH 4/5] raid5-cache: hold spinlock instead of mutex in r5c_journal_mode_show Guoqing Jiang
2020-07-28 10:01 ` [PATCH 5/5] raid5: don't duplicate code for different paths in handle_stripe Guoqing Jiang
2020-07-29  1:14 ` [PATCH 0/5] misc patches for md 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).