From: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
To: shli@kernel.org
Cc: linux-raid@vger.kernel.org,
Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Subject: [PATCH 07/12] md: mddev_find_container helper function
Date: Thu, 24 Nov 2016 13:28:42 +0100 [thread overview]
Message-ID: <20161124122847.16456-8-artur.paszkiewicz@intel.com> (raw)
In-Reply-To: <20161124122847.16456-1-artur.paszkiewicz@intel.com>
This allows finding the parent container of a subarray for external
metadata arrays.
Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
---
drivers/md/md.c | 37 +++++++++++++++++++++++++++++++++++++
drivers/md/md.h | 3 +++
2 files changed, 40 insertions(+)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7028d54..5a14f8e 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -595,6 +595,43 @@ static struct mddev *mddev_find(dev_t unit)
goto retry;
}
+struct mddev *mddev_find_container(struct mddev *subarray)
+{
+ struct mddev *mddev, *ret = NULL;
+ char *container_name;
+ int len = 0;
+ int i;
+
+ if (!subarray->external)
+ return NULL;
+
+ container_name = subarray->metadata_type + 1;
+ i = 0;
+ while (container_name[i]) {
+ if (container_name[i] == '/') {
+ len = i;
+ break;
+ }
+ i++;
+ }
+ if (len == 0)
+ return NULL;
+
+ spin_lock(&all_mddevs_lock);
+ list_for_each_entry(mddev, &all_mddevs, all_mddevs) {
+ char *name = mdname(mddev);
+ if (strlen(name) == len &&
+ strncmp(name, container_name, len) == 0) {
+ ret = mddev;
+ break;
+ }
+ }
+ spin_unlock(&all_mddevs_lock);
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(mddev_find_container);
+
static struct attribute_group md_redundancy_group;
void mddev_unlock(struct mddev *mddev)
diff --git a/drivers/md/md.h b/drivers/md/md.h
index d1e56f8..ca0b68f 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -711,4 +711,7 @@ static inline int mddev_is_clustered(struct mddev *mddev)
{
return mddev->cluster_info && mddev->bitmap_info.nodes > 1;
}
+
+extern struct mddev *mddev_find_container(struct mddev *subarray);
+
#endif /* _MD_MD_H */
--
2.10.1
next prev parent reply other threads:[~2016-11-24 12:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-24 12:28 [PATCH 00/12] Partial Parity Log for MD RAID 5 Artur Paszkiewicz
2016-11-24 12:28 ` [PATCH 01/12] raid5-cache: move declarations to separate header Artur Paszkiewicz
2016-11-24 12:28 ` [PATCH 02/12] raid5-cache: add policy logic Artur Paszkiewicz
2016-11-24 12:28 ` [PATCH 03/12] raid5-cache: add a new policy Artur Paszkiewicz
2016-11-24 12:28 ` [PATCH 04/12] md: superblock changes for PPL Artur Paszkiewicz
2016-11-24 12:28 ` [PATCH 05/12] raid5-ppl: Partial Parity Log implementation Artur Paszkiewicz
2016-11-25 2:26 ` kbuild test robot
2016-11-25 8:52 ` Artur Paszkiewicz
2016-11-24 12:28 ` [PATCH 06/12] raid5-ppl: calculate partial parity Artur Paszkiewicz
2016-11-24 12:28 ` Artur Paszkiewicz [this message]
2016-11-24 12:28 ` [PATCH 08/12] md: expose rdev->sb_start as sysfs attribute Artur Paszkiewicz
2016-11-24 12:28 ` [PATCH 09/12] raid5-ppl: read PPL signature from IMSM metadata Artur Paszkiewicz
2016-11-24 12:28 ` [PATCH 10/12] raid5-ppl: recovery from dirty shutdown using PPL Artur Paszkiewicz
2016-11-24 12:28 ` [PATCH 11/12] raid5-ppl: support disk add/remove with distributed PPL Artur Paszkiewicz
2016-11-24 12:28 ` [PATCH 12/12] raid5-ppl: runtime PPL enabling or disabling 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=20161124122847.16456-8-artur.paszkiewicz@intel.com \
--to=artur.paszkiewicz@intel.com \
--cc=linux-raid@vger.kernel.org \
--cc=shli@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).