linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guoqing Jiang <gqjiang@suse.com>
To: linux-raid@vger.kernel.org
Cc: shli@kernel.org, Guoqing Jiang <gqjiang@suse.com>,
	stable@vger.kernel.org#v4.1+, NeilBrown <neilb@suse.com>
Subject: [PATCH V2] md-cluster: make md-cluster also can work when compiled into kernel
Date: Sat,  3 Sep 2016 10:03:30 -0400	[thread overview]
Message-ID: <1472911410-15469-1-git-send-email-gqjiang@suse.com> (raw)
In-Reply-To: <1472813500-4921-1-git-send-email-gqjiang@suse.com>

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 <neilb@suse.com>
Reported-by: Marc Smith <marc.smith@mcc.edu>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
---
Changes:
1. call try_module_get if md_cluster_ops is already set,
otherwise try_module_get/module_put are unbalanced.

 drivers/md/md.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 67642ba..6ac5abe 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -7610,16 +7610,12 @@ 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;
-	}
-
+	if (!md_cluster_ops)
+		request_module("md-cluster");
 	spin_lock(&pers_lock);
-	if (!md_cluster_ops || !try_module_get(md_cluster_mod)) {
+	/* ensure module won't be unloaded */
+	if (!try_module_get(md_cluster_mod)) {
+		pr_err("can't get md-cluster module reference.\n");
 		spin_unlock(&pers_lock);
 		return -ENOENT;
 	}
-- 
2.6.6


  parent reply	other threads:[~2016-09-03 14:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-02 10:51 [PATCH] md-cluster: make md-cluster also can work when compiled into kernel Guoqing Jiang
2016-09-02 12:56 ` NeilBrown
2016-09-03 14:03 ` Guoqing Jiang [this message]
2016-09-04 23:24   ` [PATCH V2] " NeilBrown
2016-09-05  1:46     ` Guoqing Jiang
2016-09-05  1:56       ` NeilBrown
2016-09-05  2:17 ` [PATCH V3] " Guoqing Jiang
2016-09-05  3:10   ` NeilBrown
2016-09-08 18:03   ` Shaohua Li

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=1472911410-15469-1-git-send-email-gqjiang@suse.com \
    --to=gqjiang@suse.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.com \
    --cc=shli@kernel.org \
    --cc=stable@vger.kernel.org#v4.1+ \
    /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).