linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
To: shli@fb.com
Cc: linux-raid@vger.kernel.org,
	Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Subject: [PATCH v4 6/7] raid5-ppl: support disk hot add/remove with PPL
Date: Tue, 21 Feb 2017 20:44:00 +0100	[thread overview]
Message-ID: <20170221194401.18733-7-artur.paszkiewicz@intel.com> (raw)
In-Reply-To: <20170221194401.18733-1-artur.paszkiewicz@intel.com>

Add a function to modify the log by removing an rdev when a drive fails
or adding when a spare/replacement is activated as a raid member.

Removing a disk just clears the child log rdev pointer. No new stripes
will be accepted for this child log in ppl_write_stripe() and running io
units will be processed without writing PPL to the device.

Adding a disk sets the child log rdev pointer and writes an empty PPL
header.

Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
---
 drivers/md/raid5-ppl.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/md/raid5.c     | 15 +++++++++++++++
 drivers/md/raid5.h     |  8 ++++++++
 3 files changed, 70 insertions(+)

diff --git a/drivers/md/raid5-ppl.c b/drivers/md/raid5-ppl.c
index a7693353243a..c2070d124849 100644
--- a/drivers/md/raid5-ppl.c
+++ b/drivers/md/raid5-ppl.c
@@ -319,6 +319,12 @@ static void ppl_submit_iounit(struct ppl_io_unit *io)
 
 	bio = bio_alloc_bioset(GFP_NOIO, BIO_MAX_PAGES, ppl_conf->bs);
 	bio->bi_private = io;
+
+	if (!log->rdev || test_bit(Faulty, &log->rdev->flags)) {
+		ppl_log_endio(bio);
+		return;
+	}
+
 	bio->bi_end_io = ppl_log_endio;
 	bio->bi_opf = REQ_OP_WRITE | REQ_FUA;
 	bio->bi_bdev = log->rdev->bdev;
@@ -1098,3 +1104,44 @@ int ppl_init_log(struct r5conf *conf)
 	ppl_exit_log(ppl_conf);
 	return ret;
 }
+
+int ppl_modify_log(struct ppl_conf *ppl_conf, struct md_rdev *rdev,
+		   enum ppl_modify_log_operation operation)
+{
+	struct ppl_log *log;
+	int ret = 0;
+	char b[BDEVNAME_SIZE];
+
+	if (!rdev)
+		return -EINVAL;
+
+	pr_debug("%s: disk: %d operation: %s dev: %s\n",
+		 __func__, rdev->raid_disk,
+		 operation == PPL_MODIFY_LOG_DISK_REMOVE ? "remove" :
+		 (operation == PPL_MODIFY_LOG_DISK_ADD ? "add" : "?"),
+		 bdevname(rdev->bdev, b));
+
+	if (rdev->raid_disk < 0)
+		return 0;
+
+	if (rdev->raid_disk >= ppl_conf->count)
+		return -ENODEV;
+
+	log = &ppl_conf->child_logs[rdev->raid_disk];
+
+	mutex_lock(&log->io_mutex);
+	if (operation == PPL_MODIFY_LOG_DISK_REMOVE) {
+		log->rdev = NULL;
+	} else if (operation == PPL_MODIFY_LOG_DISK_ADD) {
+		ret = ppl_validate_rdev(rdev);
+		if (!ret) {
+			log->rdev = rdev;
+			ret = ppl_write_empty_header(log);
+		}
+	} else {
+		ret = -EINVAL;
+	}
+	mutex_unlock(&log->io_mutex);
+
+	return ret;
+}
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 8b52392457d8..b17e90f06f19 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -7623,6 +7623,12 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
 			*rdevp = rdev;
 		}
 	}
+	if (conf->ppl) {
+		err = ppl_modify_log(conf->ppl, rdev,
+				     PPL_MODIFY_LOG_DISK_REMOVE);
+		if (err)
+			goto abort;
+	}
 	if (p->replacement) {
 		/* We must have just cleared 'rdev' */
 		p->rdev = p->replacement;
@@ -7632,6 +7638,10 @@ static int raid5_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
 			   */
 		p->replacement = NULL;
 		clear_bit(WantReplacement, &rdev->flags);
+
+		if (conf->ppl)
+			err = ppl_modify_log(conf->ppl, p->rdev,
+					     PPL_MODIFY_LOG_DISK_ADD);
 	} else
 		/* We might have just removed the Replacement as faulty-
 		 * clear the bit just in case
@@ -7695,6 +7705,11 @@ static int raid5_add_disk(struct mddev *mddev, struct md_rdev *rdev)
 			if (rdev->saved_raid_disk != disk)
 				conf->fullsync = 1;
 			rcu_assign_pointer(p->rdev, rdev);
+
+			if (conf->ppl)
+				err = ppl_modify_log(conf->ppl, rdev,
+						     PPL_MODIFY_LOG_DISK_ADD);
+
 			goto out;
 		}
 	}
diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h
index f915a7a0e752..43cfa5fa71b3 100644
--- a/drivers/md/raid5.h
+++ b/drivers/md/raid5.h
@@ -806,4 +806,12 @@ extern void ppl_exit_log(struct ppl_conf *log);
 extern int ppl_write_stripe(struct ppl_conf *log, struct stripe_head *sh);
 extern void ppl_write_stripe_run(struct ppl_conf *log);
 extern void ppl_stripe_write_finished(struct stripe_head *sh);
+
+enum ppl_modify_log_operation {
+	PPL_MODIFY_LOG_DISK_REMOVE,
+	PPL_MODIFY_LOG_DISK_ADD,
+};
+extern int ppl_modify_log(struct ppl_conf *log, struct md_rdev *rdev,
+			  enum ppl_modify_log_operation operation);
+
 #endif
-- 
2.11.0


  parent reply	other threads:[~2017-02-21 19:44 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-21 19:43 [PATCH v4 0/7] Partial Parity Log for MD RAID 5 Artur Paszkiewicz
2017-02-21 19:43 ` [PATCH v4 1/7] md: superblock changes for PPL Artur Paszkiewicz
2017-02-21 19:43 ` [PATCH v4 2/7] raid5: calculate partial parity for a stripe Artur Paszkiewicz
2017-02-27 23:45   ` Shaohua Li
2017-03-01 16:12     ` Artur Paszkiewicz
2017-02-21 19:43 ` [PATCH v4 3/7] raid5-ppl: Partial Parity Log write logging implementation Artur Paszkiewicz
2017-02-28  0:04   ` Shaohua Li
2017-03-01 16:13     ` Artur Paszkiewicz
2017-03-01 17:51       ` Shaohua Li
2017-02-21 19:43 ` [PATCH v4 4/7] md: add sysfs entries for PPL Artur Paszkiewicz
2017-02-28  0:37   ` Shaohua Li
2017-03-01 16:13     ` Artur Paszkiewicz
2017-02-21 19:43 ` [PATCH v4 5/7] raid5-ppl: load and recover the log Artur Paszkiewicz
2017-02-28  1:12   ` Shaohua Li
2017-03-01 16:14     ` Artur Paszkiewicz
2017-03-01 17:59       ` Shaohua Li
2017-03-02  8:40         ` Artur Paszkiewicz
2017-02-21 19:44 ` Artur Paszkiewicz [this message]
2017-02-28  1:22   ` [PATCH v4 6/7] raid5-ppl: support disk hot add/remove with PPL Shaohua Li
2017-03-01 16:14     ` Artur Paszkiewicz
2017-02-21 19:44 ` [PATCH v4 7/7] raid5-ppl: runtime PPL enabling or disabling Artur Paszkiewicz
2017-02-28  1:31   ` Shaohua Li
2017-03-01 16:14     ` Artur Paszkiewicz
2017-02-28  1:35 ` [PATCH v4 0/7] Partial Parity Log for MD RAID 5 Shaohua Li
2017-03-01 16:12   ` Artur Paszkiewicz

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=20170221194401.18733-7-artur.paszkiewicz@intel.com \
    --to=artur.paszkiewicz@intel.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=shli@fb.com \
    /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).