Skip to content

Commit 477c122

Browse files
committed
Merge tag 'dlm-7.2' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm
Pull dlm updates from David Teigland: "There are four fixes/cleanups in this series; none are likely to be issues in real usage: - improve debugfs error exit path - fix sequence number ordering in an artificial test case - fix usercopy_abort for lvb data - use hlist_for_each_entry_srcu for srcu lists" * tag 'dlm-7.2' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm: dlm: init per node debugfs before add to node hash dlm: fix add msg handle in send_queue ordered dlm: add usercopy whitelist to dlm_cb cache dlm: use hlist_for_each_entry_srcu for SRCU protected lists
2 parents 974b3de + e61113c commit 477c122

3 files changed

Lines changed: 24 additions & 13 deletions

File tree

fs/dlm/lowcomms.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ static struct connection *__find_con(int nodeid, int r)
271271
{
272272
struct connection *con;
273273

274-
hlist_for_each_entry_rcu(con, &connection_hash[r], list) {
274+
hlist_for_each_entry_srcu(con, &connection_hash[r], list,
275+
srcu_read_lock_held(&connections_srcu)) {
275276
if (con->nodeid == nodeid)
276277
return con;
277278
}
@@ -426,7 +427,8 @@ static int addr_to_nodeid(struct sockaddr_storage *addr, int *nodeid,
426427

427428
idx = srcu_read_lock(&connections_srcu);
428429
for (i = 0; i < CONN_HASH_SIZE; i++) {
429-
hlist_for_each_entry_rcu(con, &connection_hash[i], list) {
430+
hlist_for_each_entry_srcu(con, &connection_hash[i], list,
431+
srcu_read_lock_held(&connections_srcu)) {
430432
WARN_ON_ONCE(!con->addr_count);
431433

432434
spin_lock(&con->addrs_lock);
@@ -1729,7 +1731,8 @@ void dlm_lowcomms_shutdown(void)
17291731

17301732
idx = srcu_read_lock(&connections_srcu);
17311733
for (i = 0; i < CONN_HASH_SIZE; i++) {
1732-
hlist_for_each_entry_rcu(con, &connection_hash[i], list) {
1734+
hlist_for_each_entry_srcu(con, &connection_hash[i], list,
1735+
srcu_read_lock_held(&connections_srcu)) {
17331736
shutdown_connection(con, true);
17341737
stop_connection_io(con);
17351738
flush_workqueue(process_workqueue);
@@ -1968,7 +1971,8 @@ void dlm_lowcomms_exit(void)
19681971

19691972
idx = srcu_read_lock(&connections_srcu);
19701973
for (i = 0; i < CONN_HASH_SIZE; i++) {
1971-
hlist_for_each_entry_rcu(con, &connection_hash[i], list) {
1974+
hlist_for_each_entry_srcu(con, &connection_hash[i], list,
1975+
srcu_read_lock_held(&connections_srcu)) {
19721976
spin_lock(&connections_lock);
19731977
hlist_del_rcu(&con->list);
19741978
spin_unlock(&connections_lock);

fs/dlm/memory.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ int __init dlm_memory_init(void)
4848
if (!rsb_cache)
4949
goto rsb;
5050

51-
cb_cache = kmem_cache_create("dlm_cb", sizeof(struct dlm_callback),
51+
cb_cache = kmem_cache_create_usercopy("dlm_cb", sizeof(struct dlm_callback),
5252
__alignof__(struct dlm_callback), 0,
53+
offsetof(struct dlm_callback, lvbptr),
54+
sizeof_field(struct dlm_callback, lvbptr),
5355
NULL);
5456
if (!cb_cache)
5557
goto cb;

fs/dlm/midcomms.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,8 @@ static struct midcomms_node *__find_node(int nodeid, int r)
275275
{
276276
struct midcomms_node *node;
277277

278-
hlist_for_each_entry_rcu(node, &node_hash[r], hlist) {
278+
hlist_for_each_entry_srcu(node, &node_hash[r], hlist,
279+
srcu_read_lock_held(&nodes_srcu)) {
279280
if (node->nodeid == nodeid)
280281
return node;
281282
}
@@ -355,6 +356,7 @@ int dlm_midcomms_addr(int nodeid, struct sockaddr_storage *addr)
355356
if (!node)
356357
return -ENOMEM;
357358

359+
node->debugfs = dlm_create_debug_comms_file(nodeid, node);
358360
node->nodeid = nodeid;
359361
spin_lock_init(&node->state_lock);
360362
spin_lock_init(&node->send_queue_lock);
@@ -368,7 +370,6 @@ int dlm_midcomms_addr(int nodeid, struct sockaddr_storage *addr)
368370
hlist_add_head_rcu(&node->hlist, &node_hash[r]);
369371
spin_unlock_bh(&nodes_lock);
370372

371-
node->debugfs = dlm_create_debug_comms_file(nodeid, node);
372373
return 0;
373374
}
374375

@@ -968,10 +969,10 @@ static void midcomms_new_msg_cb(void *data)
968969
atomic_inc(&mh->node->send_queue_cnt);
969970

970971
spin_lock_bh(&mh->node->send_queue_lock);
972+
/* need to be locked with list_add_tail_rcu() because list is ordered */
973+
mh->seq = atomic_fetch_inc(&mh->node->seq_send);
971974
list_add_tail_rcu(&mh->list, &mh->node->send_queue);
972975
spin_unlock_bh(&mh->node->send_queue_lock);
973-
974-
mh->seq = atomic_fetch_inc(&mh->node->seq_send);
975976
}
976977

977978
static struct dlm_msg *dlm_midcomms_get_msg_3_2(struct dlm_mhandle *mh, int nodeid,
@@ -1165,7 +1166,8 @@ void dlm_midcomms_exit(void)
11651166

11661167
idx = srcu_read_lock(&nodes_srcu);
11671168
for (i = 0; i < CONN_HASH_SIZE; i++) {
1168-
hlist_for_each_entry_rcu(node, &node_hash[i], hlist) {
1169+
hlist_for_each_entry_srcu(node, &node_hash[i], hlist,
1170+
srcu_read_lock_held(&nodes_srcu)) {
11691171
dlm_delete_debug_comms_file(node->debugfs);
11701172

11711173
spin_lock(&nodes_lock);
@@ -1325,7 +1327,8 @@ void dlm_midcomms_version_wait(void)
13251327

13261328
idx = srcu_read_lock(&nodes_srcu);
13271329
for (i = 0; i < CONN_HASH_SIZE; i++) {
1328-
hlist_for_each_entry_rcu(node, &node_hash[i], hlist) {
1330+
hlist_for_each_entry_srcu(node, &node_hash[i], hlist,
1331+
srcu_read_lock_held(&nodes_srcu)) {
13291332
ret = wait_event_timeout(node->shutdown_wait,
13301333
node->version != DLM_VERSION_NOT_SET ||
13311334
node->state == DLM_CLOSED ||
@@ -1396,15 +1399,17 @@ void dlm_midcomms_shutdown(void)
13961399
mutex_lock(&close_lock);
13971400
idx = srcu_read_lock(&nodes_srcu);
13981401
for (i = 0; i < CONN_HASH_SIZE; i++) {
1399-
hlist_for_each_entry_rcu(node, &node_hash[i], hlist) {
1402+
hlist_for_each_entry_srcu(node, &node_hash[i], hlist,
1403+
srcu_read_lock_held(&nodes_srcu)) {
14001404
midcomms_shutdown(node);
14011405
}
14021406
}
14031407

14041408
dlm_lowcomms_shutdown();
14051409

14061410
for (i = 0; i < CONN_HASH_SIZE; i++) {
1407-
hlist_for_each_entry_rcu(node, &node_hash[i], hlist) {
1411+
hlist_for_each_entry_srcu(node, &node_hash[i], hlist,
1412+
srcu_read_lock_held(&nodes_srcu)) {
14081413
midcomms_node_reset(node);
14091414
}
14101415
}

0 commit comments

Comments
 (0)