Skip to contentSkip to conversation

misc patches for md

PATCH Applied Guoqing Jiang 2 participants 7 messages Jul 28, 2020 – Jul 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover misc patches for md

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(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/5 md: register new md sysfs file 'uuid' read-only

From: Sebastian Parschauer <[email protected]>

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.

[Guoqing: mention the change in md.rst]
---
 Documentation/admin-guide/md.rst | 4 ++++
 drivers/md/md.c                  | 9 +++++++++
 2 files changed, 13 insertions(+)
Documentation/admin-guide/md.rst +4 -0
index d973d469ffc4..cc8781b96b4d 100644
@@ -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::
drivers/md/md.c +9 -0
index ea48bc25cce1..0c2a0e65b4f1 100644
@@ -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,
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/5 md/raid5: remove the redundant setting of STRIPE_HANDLE

In reply to Guoqing Jiang

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

---
 drivers/md/raid5.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/md/raid5.c +2 -6
index a6ff6e1e039b..790d91aa5f40 100644
@@ -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)
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/5 md: print errno in super_written

In reply to Guoqing Jiang

It is better to print errno instead of bi_status.

---
 drivers/md/md.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/md.c +2 -1
index 0c2a0e65b4f1..8f9a89b4c7ba 100644
@@ -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)) {
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/5 raid5-cache: hold spinlock instead of mutex in r5c_journal_mode_show

In reply to Guoqing Jiang

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

---
 drivers/md/raid5-cache.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/md/raid5-cache.c +3 -6
index 82eb4a906e31..4337ae0e6af2 100644
@@ -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;
 }
 
Signature · 1 line
2.17.1
#5 lore raw

PATCH 5/5 raid5: don't duplicate code for different paths in handle_stripe

In reply to 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.

---
 drivers/md/raid5.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/md/raid5.c +3 -6
index 790d91aa5f40..b06edfaa73b0 100644
@@ -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++;
 			}
 		}
 
Signature · 1 line
2.17.1
maintainer Applied
#6 lore raw
In reply to Guoqing Jiang
Quoted 7 lines · Guoqing Jiang

Hi,

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

Thanks,
Guoqing

Applied to md-next. Thanks for the fixes!