Commit 50a10043 authored by James Simmons's avatar James Simmons Committed by Greg Kroah-Hartman

staging: lustre: kg_sem semaphore handling is incorrectly

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: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8b88bcab
...@@ -186,7 +186,7 @@ int libcfs_kkuc_group_put(int group, void *payload) ...@@ -186,7 +186,7 @@ int libcfs_kkuc_group_put(int group, void *payload)
int rc = 0; int rc = 0;
int one_success = 0; int one_success = 0;
down_read(&kg_sem); down_write(&kg_sem);
list_for_each_entry(reg, &kkuc_groups[group], kr_chain) { list_for_each_entry(reg, &kkuc_groups[group], kr_chain) {
if (reg->kr_fp != NULL) { if (reg->kr_fp != NULL) {
rc = libcfs_kkuc_msg_put(reg->kr_fp, payload); rc = libcfs_kkuc_msg_put(reg->kr_fp, payload);
...@@ -198,7 +198,7 @@ int libcfs_kkuc_group_put(int group, void *payload) ...@@ -198,7 +198,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 /* don't return an error if the message has been delivered
* at least to one agent */ * at least to one agent */
...@@ -230,12 +230,12 @@ int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func, ...@@ -230,12 +230,12 @@ int libcfs_kkuc_group_foreach(int group, libcfs_kkuc_cb_t cb_func,
if (kkuc_groups[group].next == NULL) if (kkuc_groups[group].next == NULL)
return 0; return 0;
down_write(&kg_sem); down_read(&kg_sem);
list_for_each_entry(reg, &kkuc_groups[group], kr_chain) { list_for_each_entry(reg, &kkuc_groups[group], kr_chain) {
if (reg->kr_fp != NULL) if (reg->kr_fp != NULL)
rc = cb_func(reg->kr_data, cb_arg); rc = cb_func(reg->kr_data, cb_arg);
} }
up_write(&kg_sem); up_read(&kg_sem);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment