Thread (9 messages) 9 messages, 3 authors, 2016-09-08

Re: [PATCH] md-cluster: make md-cluster also can work when compiled into kernel

From: NeilBrown <hidden>
Date: 2016-09-02 12:56:48

On Fri, Sep 02 2016, Guoqing Jiang wrote:
quoted hunk ↗ jump to hunk
The md-cluster is compiled as module by default,
if it is compiled by built-in way, then we can't
make md-cluster works.

[64782.630008] md/raid1:md127: active with 2 out of 2 mirrors
[64782.630528] md-cluster module not found.
[64782.630530] md127: Could not setup cluster service (-2)

Fixes: edb39c9 ("Introduce md_cluster_operations to handle cluster functions")
Cc: stable@vger.kernel.org # v4.1+
Cc: NeilBrown <redacted>
Reported-by: Marc Smith <redacted>
Signed-off-by: Guoqing Jiang <redacted>
---
 drivers/md/md.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index bdbbb6e1..3b19d21 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7619,20 +7619,17 @@ EXPORT_SYMBOL(unregister_md_cluster_operations);
 
 int md_setup_cluster(struct mddev *mddev, int nodes)
 {
-	int err;
-
-	err = request_module("md-cluster");
-	if (err) {
-		pr_err("md-cluster module not found.\n");
-		return -ENOENT;
-	}
-
-	spin_lock(&pers_lock);
-	if (!md_cluster_ops || !try_module_get(md_cluster_mod)) {
+	if (!md_cluster_ops) {
+		/* load module and ensure it won't be unloaded */
+		request_module("md-cluster");
+		spin_lock(&pers_lock);
+		if (!try_module_get(md_cluster_mod)) {
+			pr_err("can't get md-cluster module reference.\n");
+			spin_unlock(&pers_lock);
+			return -ENODEV;
+		}
 		spin_unlock(&pers_lock);
-		return -ENOENT;
 	}
-	spin_unlock(&pers_lock);
 
 	return md_cluster_ops->join(mddev, nodes);
 }
-- 
2.6.6
No good.  If md_cluster_ops is set, try_module_get() won't be called, so
it will be possible to unload the module while it is in use.

NeilBrown

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help