Skip to content

Commit 0a37714

Browse files
committed
Merge tag 'dlm-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm
Pull dlm updates from David Teigland: "The dlm posix lock handling (for gfs2) has three notable changes: - Local pids returned from GETLK are no longer negated. A previous patch negating remote pids mistakenly changed local pids also. - SETLKW operations can now be interrupted only when the process is killed, and not from other signals. General interruption was resulting in previously acquired locks being cleared, not just the in-progress lock. Handling this correctly will require extending a cancel capability to user space (a future feature.) - If multiple threads are requesting posix locks (with SETLKW), fix incorrect matching of results to the requests. The dlm networking has several minor cleanups, and one notable change: - Avoid delaying ack messages for too long (used for message reliability), resulting in a backlog of un-acked messages. These could previously be delayed as a result of either too many or too few other messages being sent. Now an upper and lower threshold is used to determine when an ack should be sent" * tag 'dlm-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/linux-dlm: fs: dlm: remove filter local comms on close fs: dlm: add send ack threshold and append acks to msgs fs: dlm: handle sequence numbers as atomic fs: dlm: handle lkb wait count as atomic_t fs: dlm: filter ourself midcomms calls fs: dlm: warn about messages from left nodes fs: dlm: move dlm_purge_lkb_callbacks to user module fs: dlm: cleanup STOP_IO bitflag set when stop io fs: dlm: don't check othercon twice fs: dlm: unregister memory at the very last fs: dlm: fix missing pending to false fs: dlm: clear pending bit when queue was empty fs: dlm: revert check required context while close fs: dlm: fix mismatch of plock results from userspace fs: dlm: make F_SETLK use unkillable wait_event fs: dlm: interrupt posix locks only when process is killed fs: dlm: fix cleanup pending ops when interrupted fs: dlm: return positive pid value for F_GETLK dlm: Replace all non-returning strlcpy with strscpy
2 parents 9e06150 + fc4ea42 commit 0a37714

File tree

13 files changed

+203
-222
lines changed

13 files changed

+203
-222
lines changed

fs/dlm/ast.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,6 @@ void dlm_callback_set_last_ptr(struct dlm_callback **from,
3636
*from = to;
3737
}
3838

39-
void dlm_purge_lkb_callbacks(struct dlm_lkb *lkb)
40-
{
41-
struct dlm_callback *cb, *safe;
42-
43-
list_for_each_entry_safe(cb, safe, &lkb->lkb_callbacks, list) {
44-
list_del(&cb->list);
45-
kref_put(&cb->ref, dlm_release_callback);
46-
}
47-
48-
clear_bit(DLM_IFL_CB_PENDING_BIT, &lkb->lkb_iflags);
49-
50-
/* invalidate */
51-
dlm_callback_set_last_ptr(&lkb->lkb_last_cast, NULL);
52-
dlm_callback_set_last_ptr(&lkb->lkb_last_cb, NULL);
53-
lkb->lkb_last_bast_mode = -1;
54-
}
55-
5639
int dlm_enqueue_lkb_callback(struct dlm_lkb *lkb, uint32_t flags, int mode,
5740
int status, uint32_t sbflags)
5841
{
@@ -181,10 +164,12 @@ void dlm_callback_work(struct work_struct *work)
181164

182165
spin_lock(&lkb->lkb_cb_lock);
183166
rv = dlm_dequeue_lkb_callback(lkb, &cb);
184-
spin_unlock(&lkb->lkb_cb_lock);
185-
186-
if (WARN_ON_ONCE(rv == DLM_DEQUEUE_CALLBACK_EMPTY))
167+
if (WARN_ON_ONCE(rv == DLM_DEQUEUE_CALLBACK_EMPTY)) {
168+
clear_bit(DLM_IFL_CB_PENDING_BIT, &lkb->lkb_iflags);
169+
spin_unlock(&lkb->lkb_cb_lock);
187170
goto out;
171+
}
172+
spin_unlock(&lkb->lkb_cb_lock);
188173

189174
for (;;) {
190175
castfn = lkb->lkb_astfn;

fs/dlm/ast.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ void dlm_callback_set_last_ptr(struct dlm_callback **from,
2626
struct dlm_callback *to);
2727

2828
void dlm_release_callback(struct kref *ref);
29-
void dlm_purge_lkb_callbacks(struct dlm_lkb *lkb);
3029
void dlm_callback_work(struct work_struct *work);
3130
int dlm_callback_start(struct dlm_ls *ls);
3231
void dlm_callback_stop(struct dlm_ls *ls);

fs/dlm/dlm_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ struct dlm_lkb {
246246
int8_t lkb_highbast; /* highest mode bast sent for */
247247

248248
int8_t lkb_wait_type; /* type of reply waiting for */
249-
int8_t lkb_wait_count;
249+
atomic_t lkb_wait_count;
250250
int lkb_wait_nodeid; /* for debugging */
251251

252252
struct list_head lkb_statequeue; /* rsb g/c/w list */

fs/dlm/lock.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,7 @@ static int add_to_waiters(struct dlm_lkb *lkb, int mstype, int to_nodeid)
14071407
{
14081408
struct dlm_ls *ls = lkb->lkb_resource->res_ls;
14091409
int error = 0;
1410+
int wc;
14101411

14111412
mutex_lock(&ls->ls_waiters_mutex);
14121413

@@ -1428,20 +1429,17 @@ static int add_to_waiters(struct dlm_lkb *lkb, int mstype, int to_nodeid)
14281429
error = -EBUSY;
14291430
goto out;
14301431
}
1431-
lkb->lkb_wait_count++;
1432+
wc = atomic_inc_return(&lkb->lkb_wait_count);
14321433
hold_lkb(lkb);
14331434

14341435
log_debug(ls, "addwait %x cur %d overlap %d count %d f %x",
1435-
lkb->lkb_id, lkb->lkb_wait_type, mstype,
1436-
lkb->lkb_wait_count, dlm_iflags_val(lkb));
1436+
lkb->lkb_id, lkb->lkb_wait_type, mstype, wc,
1437+
dlm_iflags_val(lkb));
14371438
goto out;
14381439
}
14391440

1440-
DLM_ASSERT(!lkb->lkb_wait_count,
1441-
dlm_print_lkb(lkb);
1442-
printk("wait_count %d\n", lkb->lkb_wait_count););
1443-
1444-
lkb->lkb_wait_count++;
1441+
wc = atomic_fetch_inc(&lkb->lkb_wait_count);
1442+
DLM_ASSERT(!wc, dlm_print_lkb(lkb); printk("wait_count %d\n", wc););
14451443
lkb->lkb_wait_type = mstype;
14461444
lkb->lkb_wait_nodeid = to_nodeid; /* for debugging */
14471445
hold_lkb(lkb);
@@ -1504,7 +1502,7 @@ static int _remove_from_waiters(struct dlm_lkb *lkb, int mstype,
15041502
log_debug(ls, "remwait %x convert_reply zap overlap_cancel",
15051503
lkb->lkb_id);
15061504
lkb->lkb_wait_type = 0;
1507-
lkb->lkb_wait_count--;
1505+
atomic_dec(&lkb->lkb_wait_count);
15081506
unhold_lkb(lkb);
15091507
goto out_del;
15101508
}
@@ -1531,16 +1529,15 @@ static int _remove_from_waiters(struct dlm_lkb *lkb, int mstype,
15311529
if (overlap_done && lkb->lkb_wait_type) {
15321530
log_error(ls, "remwait error %x reply %d wait_type %d overlap",
15331531
lkb->lkb_id, mstype, lkb->lkb_wait_type);
1534-
lkb->lkb_wait_count--;
1532+
atomic_dec(&lkb->lkb_wait_count);
15351533
unhold_lkb(lkb);
15361534
lkb->lkb_wait_type = 0;
15371535
}
15381536

1539-
DLM_ASSERT(lkb->lkb_wait_count, dlm_print_lkb(lkb););
1537+
DLM_ASSERT(atomic_read(&lkb->lkb_wait_count), dlm_print_lkb(lkb););
15401538

15411539
clear_bit(DLM_IFL_RESEND_BIT, &lkb->lkb_iflags);
1542-
lkb->lkb_wait_count--;
1543-
if (!lkb->lkb_wait_count)
1540+
if (atomic_dec_and_test(&lkb->lkb_wait_count))
15441541
list_del_init(&lkb->lkb_wait_reply);
15451542
unhold_lkb(lkb);
15461543
return 0;
@@ -2669,7 +2666,7 @@ static int validate_lock_args(struct dlm_ls *ls, struct dlm_lkb *lkb,
26692666
goto out;
26702667

26712668
/* lock not allowed if there's any op in progress */
2672-
if (lkb->lkb_wait_type || lkb->lkb_wait_count)
2669+
if (lkb->lkb_wait_type || atomic_read(&lkb->lkb_wait_count))
26732670
goto out;
26742671

26752672
if (is_overlap(lkb))
@@ -2731,7 +2728,7 @@ static int validate_unlock_args(struct dlm_lkb *lkb, struct dlm_args *args)
27312728

27322729
/* normal unlock not allowed if there's any op in progress */
27332730
if (!(args->flags & (DLM_LKF_CANCEL | DLM_LKF_FORCEUNLOCK)) &&
2734-
(lkb->lkb_wait_type || lkb->lkb_wait_count))
2731+
(lkb->lkb_wait_type || atomic_read(&lkb->lkb_wait_count)))
27352732
goto out;
27362733

27372734
/* an lkb may be waiting for an rsb lookup to complete where the
@@ -4616,7 +4613,7 @@ static void _receive_message(struct dlm_ls *ls, struct dlm_message *ms,
46164613
{
46174614
int error = 0, noent = 0;
46184615

4619-
if (!dlm_is_member(ls, le32_to_cpu(ms->m_header.h_nodeid))) {
4616+
if (WARN_ON_ONCE(!dlm_is_member(ls, le32_to_cpu(ms->m_header.h_nodeid)))) {
46204617
log_limit(ls, "receive %d from non-member %d %x %x %d",
46214618
le32_to_cpu(ms->m_type),
46224619
le32_to_cpu(ms->m_header.h_nodeid),
@@ -4754,7 +4751,7 @@ static void dlm_receive_message(struct dlm_ls *ls, struct dlm_message *ms,
47544751
/* If we were a member of this lockspace, left, and rejoined,
47554752
other nodes may still be sending us messages from the
47564753
lockspace generation before we left. */
4757-
if (!ls->ls_generation) {
4754+
if (WARN_ON_ONCE(!ls->ls_generation)) {
47584755
log_limit(ls, "receive %d from %d ignore old gen",
47594756
le32_to_cpu(ms->m_type), nodeid);
47604757
return;
@@ -5066,10 +5063,9 @@ int dlm_recover_waiters_post(struct dlm_ls *ls)
50665063
/* drop all wait_count references we still
50675064
* hold a reference for this iteration.
50685065
*/
5069-
while (lkb->lkb_wait_count) {
5070-
lkb->lkb_wait_count--;
5066+
while (!atomic_dec_and_test(&lkb->lkb_wait_count))
50715067
unhold_lkb(lkb);
5072-
}
5068+
50735069
mutex_lock(&ls->ls_waiters_mutex);
50745070
list_del_init(&lkb->lkb_wait_reply);
50755071
mutex_unlock(&ls->ls_waiters_mutex);

fs/dlm/lockspace.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -935,15 +935,3 @@ void dlm_stop_lockspaces(void)
935935
log_print("dlm user daemon left %d lockspaces", count);
936936
}
937937

938-
void dlm_stop_lockspaces_check(void)
939-
{
940-
struct dlm_ls *ls;
941-
942-
spin_lock(&lslist_lock);
943-
list_for_each_entry(ls, &lslist, ls_list) {
944-
if (WARN_ON(!rwsem_is_locked(&ls->ls_in_recovery) ||
945-
!dlm_locking_stopped(ls)))
946-
break;
947-
}
948-
spin_unlock(&lslist_lock);
949-
}

fs/dlm/lockspace.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ struct dlm_ls *dlm_find_lockspace_local(void *id);
2727
struct dlm_ls *dlm_find_lockspace_device(int minor);
2828
void dlm_put_lockspace(struct dlm_ls *ls);
2929
void dlm_stop_lockspaces(void);
30-
void dlm_stop_lockspaces_check(void);
3130
int dlm_new_user_lockspace(const char *name, const char *cluster,
3231
uint32_t flags, int lvblen,
3332
const struct dlm_lockspace_ops *ops,

fs/dlm/lowcomms.c

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,6 @@ int dlm_lowcomms_connect_node(int nodeid)
546546
struct connection *con;
547547
int idx;
548548

549-
if (nodeid == dlm_our_nodeid())
550-
return 0;
551-
552549
idx = srcu_read_lock(&connections_srcu);
553550
con = nodeid2con(nodeid, 0);
554551
if (WARN_ON_ONCE(!con)) {
@@ -735,19 +732,15 @@ static void stop_connection_io(struct connection *con)
735732
if (con->othercon)
736733
stop_connection_io(con->othercon);
737734

735+
spin_lock_bh(&con->writequeue_lock);
736+
set_bit(CF_IO_STOP, &con->flags);
737+
spin_unlock_bh(&con->writequeue_lock);
738+
738739
down_write(&con->sock_lock);
739740
if (con->sock) {
740741
lock_sock(con->sock->sk);
741742
restore_callbacks(con->sock->sk);
742-
743-
spin_lock_bh(&con->writequeue_lock);
744-
set_bit(CF_IO_STOP, &con->flags);
745-
spin_unlock_bh(&con->writequeue_lock);
746743
release_sock(con->sock->sk);
747-
} else {
748-
spin_lock_bh(&con->writequeue_lock);
749-
set_bit(CF_IO_STOP, &con->flags);
750-
spin_unlock_bh(&con->writequeue_lock);
751744
}
752745
up_write(&con->sock_lock);
753746

@@ -867,37 +860,16 @@ struct dlm_processed_nodes {
867860
struct list_head list;
868861
};
869862

870-
static void add_processed_node(int nodeid, struct list_head *processed_nodes)
871-
{
872-
struct dlm_processed_nodes *n;
873-
874-
list_for_each_entry(n, processed_nodes, list) {
875-
/* we already remembered this node */
876-
if (n->nodeid == nodeid)
877-
return;
878-
}
879-
880-
/* if it's fails in worst case we simple don't send an ack back.
881-
* We try it next time.
882-
*/
883-
n = kmalloc(sizeof(*n), GFP_NOFS);
884-
if (!n)
885-
return;
886-
887-
n->nodeid = nodeid;
888-
list_add(&n->list, processed_nodes);
889-
}
890-
891863
static void process_dlm_messages(struct work_struct *work)
892864
{
893-
struct dlm_processed_nodes *n, *n_tmp;
894865
struct processqueue_entry *pentry;
895866
LIST_HEAD(processed_nodes);
896867

897868
spin_lock(&processqueue_lock);
898869
pentry = list_first_entry_or_null(&processqueue,
899870
struct processqueue_entry, list);
900871
if (WARN_ON_ONCE(!pentry)) {
872+
process_dlm_messages_pending = false;
901873
spin_unlock(&processqueue_lock);
902874
return;
903875
}
@@ -908,7 +880,6 @@ static void process_dlm_messages(struct work_struct *work)
908880
for (;;) {
909881
dlm_process_incoming_buffer(pentry->nodeid, pentry->buf,
910882
pentry->buflen);
911-
add_processed_node(pentry->nodeid, &processed_nodes);
912883
free_processqueue_entry(pentry);
913884

914885
spin_lock(&processqueue_lock);
@@ -923,13 +894,6 @@ static void process_dlm_messages(struct work_struct *work)
923894
list_del(&pentry->list);
924895
spin_unlock(&processqueue_lock);
925896
}
926-
927-
/* send ack back after we processed couple of messages */
928-
list_for_each_entry_safe(n, n_tmp, &processed_nodes, list) {
929-
list_del(&n->list);
930-
dlm_midcomms_receive_done(n->nodeid);
931-
kfree(n);
932-
}
933897
}
934898

935899
/* Data received from remote end */
@@ -1500,8 +1464,7 @@ int dlm_lowcomms_close(int nodeid)
15001464
call_srcu(&connections_srcu, &con->rcu, connection_release);
15011465
if (con->othercon) {
15021466
clean_one_writequeue(con->othercon);
1503-
if (con->othercon)
1504-
call_srcu(&connections_srcu, &con->othercon->rcu, connection_release);
1467+
call_srcu(&connections_srcu, &con->othercon->rcu, connection_release);
15051468
}
15061469
srcu_read_unlock(&connections_srcu, idx);
15071470

fs/dlm/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ static void __exit exit_dlm(void)
7373
dlm_plock_exit();
7474
dlm_user_exit();
7575
dlm_config_exit();
76-
dlm_memory_exit();
7776
dlm_lockspace_exit();
7877
dlm_midcomms_exit();
7978
dlm_unregister_debugfs();
79+
dlm_memory_exit();
8080
}
8181

8282
module_init(init_dlm);

fs/dlm/member.c

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,21 @@ static void add_ordered_member(struct dlm_ls *ls, struct dlm_member *new)
307307
}
308308
}
309309

310+
static int add_remote_member(int nodeid)
311+
{
312+
int error;
313+
314+
if (nodeid == dlm_our_nodeid())
315+
return 0;
316+
317+
error = dlm_lowcomms_connect_node(nodeid);
318+
if (error < 0)
319+
return error;
320+
321+
dlm_midcomms_add_member(nodeid);
322+
return 0;
323+
}
324+
310325
static int dlm_add_member(struct dlm_ls *ls, struct dlm_config_node *node)
311326
{
312327
struct dlm_member *memb;
@@ -316,16 +331,16 @@ static int dlm_add_member(struct dlm_ls *ls, struct dlm_config_node *node)
316331
if (!memb)
317332
return -ENOMEM;
318333

319-
error = dlm_lowcomms_connect_node(node->nodeid);
334+
memb->nodeid = node->nodeid;
335+
memb->weight = node->weight;
336+
memb->comm_seq = node->comm_seq;
337+
338+
error = add_remote_member(node->nodeid);
320339
if (error < 0) {
321340
kfree(memb);
322341
return error;
323342
}
324343

325-
memb->nodeid = node->nodeid;
326-
memb->weight = node->weight;
327-
memb->comm_seq = node->comm_seq;
328-
dlm_midcomms_add_member(node->nodeid);
329344
add_ordered_member(ls, memb);
330345
ls->ls_num_nodes++;
331346
return 0;
@@ -370,11 +385,19 @@ static void clear_memb_list(struct list_head *head,
370385
}
371386
}
372387

373-
static void clear_members_cb(int nodeid)
388+
static void remove_remote_member(int nodeid)
374389
{
390+
if (nodeid == dlm_our_nodeid())
391+
return;
392+
375393
dlm_midcomms_remove_member(nodeid);
376394
}
377395

396+
static void clear_members_cb(int nodeid)
397+
{
398+
remove_remote_member(nodeid);
399+
}
400+
378401
void dlm_clear_members(struct dlm_ls *ls)
379402
{
380403
clear_memb_list(&ls->ls_nodes, clear_members_cb);
@@ -562,7 +585,7 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
562585

563586
neg++;
564587
list_move(&memb->list, &ls->ls_nodes_gone);
565-
dlm_midcomms_remove_member(memb->nodeid);
588+
remove_remote_member(memb->nodeid);
566589
ls->ls_num_nodes--;
567590
dlm_lsop_recover_slot(ls, memb);
568591
}

0 commit comments

Comments
 (0)