The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org, Oleg Drokin <oleg.drokin@intel.com>,
	Andreas Dilger <andreas.dilger@intel.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	lustre-devel@lists.lustre.org,
	James Simmons <jsimmons@infradead.org>
Subject: [PATCH 1/5] staging:lustre: kg_sem semaphore handling is incorrectly
Date: Fri, 23 Oct 2015 15:59:13 -0400	[thread overview]
Message-ID: <1445630357-27149-2-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1445630357-27149-1-git-send-email-jsimmons@infradead.org>

During the removal of the cfs wrappers the kg_sem semaphore
was handled incorrectly. We need to take a write lock when
writing data to the kkuc_groups. The libcfs_kkuc_group_foreach
needs to only take a read lock. This makes use match the
OpenSFS development branch.

Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 .../lustre/lustre/libcfs/kernel_user_comm.c        |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c
index d9b7c6b..48df275 100644
--- a/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c
+++ b/drivers/staging/lustre/lustre/libcfs/kernel_user_comm.c
@@ -184,7 +184,7 @@ int libcfs_kkuc_group_put(int group, void *payload)
 	int		 rc = 0;
 	int one_success = 0;
 
-	down_read(&kg_sem);
+	down_write(&kg_sem);
 	list_for_each_entry(reg, &kkuc_groups[group], kr_chain) {
 		if (reg->kr_fp != NULL) {
 			rc = libcfs_kkuc_msg_put(reg->kr_fp, payload);
@@ -196,7 +196,7 @@ int libcfs_kkuc_group_put(int group, void *payload)
 			}
 		}
 	}
-	up_read(&kg_sem);
+	up_write(&kg_sem);
 
 	/* don't return an error if the message has been delivered
 	 * at least to one agent */
@@ -228,12 +228,12 @@ int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func,
 	if (kkuc_groups[group].next == NULL)
 		return 0;
 
-	down_write(&kg_sem);
+	down_read(&kg_sem);
 	list_for_each_entry(reg, &kkuc_groups[group], kr_chain) {
 		if (reg->kr_fp != NULL)
 			rc = cb_func(reg->kr_data, cb_arg);
 	}
-	up_write(&kg_sem);
+	up_read(&kg_sem);
 
 	return rc;
 }
-- 
1.7.1


  reply	other threads:[~2015-10-23 19:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-23 19:59 [PATCH 0/5] staging:lustre: split kernel comm between user and kernel James Simmons
2015-10-23 19:59 ` James Simmons [this message]
2015-10-23 19:59 ` [PATCH] staging:lustre: Prevent duplicate CT registrations James Simmons
2015-10-26  8:52   ` Dan Carpenter
2015-11-04  0:20     ` Simmons, James A.
2015-10-23 19:59 ` [PATCH] staging:lustre: move kernel_user_comm.c from libcfs to lustre James Simmons
2015-10-23 19:59 ` [PATCH 4/5] staging:lustre: split kernel comm between user and kernel James Simmons
2015-10-23 19:59 ` [PATCH 5/5] staging:lustre: Update license and copyright for kernel comm James Simmons
2015-10-25  1:56 ` [PATCH 0/5] staging:lustre: split kernel comm between user and kernel Greg Kroah-Hartman

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=1445630357-27149-2-git-send-email-jsimmons@infradead.org \
    --to=jsimmons@infradead.org \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lustre-devel@lists.lustre.org \
    --cc=oleg.drokin@intel.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