Skip to content

Commit f26e51f

Browse files
author
Linus Torvalds
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-2.6-nmw
* git://git.kernel.org/pub/scm/linux/kernel/git/steve/gfs2-2.6-nmw: (51 commits) [DLM] block dlm_recv in recovery transition [DLM] don't overwrite castparam if it's NULL [GFS2] Get superblock a different way [GFS2] Don't try to remove buffers that don't exist [GFS2] Alternate gfs2_iget to avoid looking up inodes being freed [GFS2] Data corruption fix [GFS2] Clean up journaled data writing [GFS2] GFS2: chmod hung - fix race in thread creation [DLM] Make dlm_sendd cond_resched more [GFS2] Move inode deletion out of blocking_cb [GFS2] flocks from same process trip kernel BUG at fs/gfs2/glock.c:1118! [GFS2] Clean up gfs2_trans_add_revoke() [GFS2] Use slab operations for all gfs2_bufdata allocations [GFS2] Replace revoke structure with bufdata structure [GFS2] Fix ordering of dirty/journal for ordered buffer unstuffing [GFS2] Clean up ordered write code [GFS2] Move pin/unpin into lops.c, clean up locking [GFS2] Don't mark jdata dirty in gfs2_unstuffer_page() [GFS2] Introduce gfs2_remove_from_ail [GFS2] Correct lock ordering in unlink ...
2 parents 1462222 + c36258b commit f26e51f

49 files changed

Lines changed: 1139 additions & 961 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎fs/dlm/dlm_internal.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ struct dlm_ls {
491491
uint64_t ls_recover_seq;
492492
struct dlm_recover *ls_recover_args;
493493
struct rw_semaphore ls_in_recovery; /* block local requests */
494+
struct rw_semaphore ls_recv_active; /* block dlm_recv */
494495
struct list_head ls_requestqueue;/* queue remote requests */
495496
struct mutex ls_requestqueue_mutex;
496497
char *ls_recover_buf;

‎fs/dlm/lock.c‎

Lines changed: 85 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3638,55 +3638,8 @@ static void receive_lookup_reply(struct dlm_ls *ls, struct dlm_message *ms)
36383638
dlm_put_lkb(lkb);
36393639
}
36403640

3641-
int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery)
3641+
static void _receive_message(struct dlm_ls *ls, struct dlm_message *ms)
36423642
{
3643-
struct dlm_message *ms = (struct dlm_message *) hd;
3644-
struct dlm_ls *ls;
3645-
int error = 0;
3646-
3647-
if (!recovery)
3648-
dlm_message_in(ms);
3649-
3650-
ls = dlm_find_lockspace_global(hd->h_lockspace);
3651-
if (!ls) {
3652-
log_print("drop message %d from %d for unknown lockspace %d",
3653-
ms->m_type, nodeid, hd->h_lockspace);
3654-
return -EINVAL;
3655-
}
3656-
3657-
/* recovery may have just ended leaving a bunch of backed-up requests
3658-
in the requestqueue; wait while dlm_recoverd clears them */
3659-
3660-
if (!recovery)
3661-
dlm_wait_requestqueue(ls);
3662-
3663-
/* recovery may have just started while there were a bunch of
3664-
in-flight requests -- save them in requestqueue to be processed
3665-
after recovery. we can't let dlm_recvd block on the recovery
3666-
lock. if dlm_recoverd is calling this function to clear the
3667-
requestqueue, it needs to be interrupted (-EINTR) if another
3668-
recovery operation is starting. */
3669-
3670-
while (1) {
3671-
if (dlm_locking_stopped(ls)) {
3672-
if (recovery) {
3673-
error = -EINTR;
3674-
goto out;
3675-
}
3676-
error = dlm_add_requestqueue(ls, nodeid, hd);
3677-
if (error == -EAGAIN)
3678-
continue;
3679-
else {
3680-
error = -EINTR;
3681-
goto out;
3682-
}
3683-
}
3684-
3685-
if (dlm_lock_recovery_try(ls))
3686-
break;
3687-
schedule();
3688-
}
3689-
36903643
switch (ms->m_type) {
36913644

36923645
/* messages sent to a master node */
@@ -3761,17 +3714,90 @@ int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery)
37613714
log_error(ls, "unknown message type %d", ms->m_type);
37623715
}
37633716

3764-
dlm_unlock_recovery(ls);
3765-
out:
3766-
dlm_put_lockspace(ls);
37673717
dlm_astd_wake();
3768-
return error;
37693718
}
37703719

3720+
/* If the lockspace is in recovery mode (locking stopped), then normal
3721+
messages are saved on the requestqueue for processing after recovery is
3722+
done. When not in recovery mode, we wait for dlm_recoverd to drain saved
3723+
messages off the requestqueue before we process new ones. This occurs right
3724+
after recovery completes when we transition from saving all messages on
3725+
requestqueue, to processing all the saved messages, to processing new
3726+
messages as they arrive. */
37713727

3772-
/*
3773-
* Recovery related
3774-
*/
3728+
static void dlm_receive_message(struct dlm_ls *ls, struct dlm_message *ms,
3729+
int nodeid)
3730+
{
3731+
if (dlm_locking_stopped(ls)) {
3732+
dlm_add_requestqueue(ls, nodeid, (struct dlm_header *) ms);
3733+
} else {
3734+
dlm_wait_requestqueue(ls);
3735+
_receive_message(ls, ms);
3736+
}
3737+
}
3738+
3739+
/* This is called by dlm_recoverd to process messages that were saved on
3740+
the requestqueue. */
3741+
3742+
void dlm_receive_message_saved(struct dlm_ls *ls, struct dlm_message *ms)
3743+
{
3744+
_receive_message(ls, ms);
3745+
}
3746+
3747+
/* This is called by the midcomms layer when something is received for
3748+
the lockspace. It could be either a MSG (normal message sent as part of
3749+
standard locking activity) or an RCOM (recovery message sent as part of
3750+
lockspace recovery). */
3751+
3752+
void dlm_receive_buffer(struct dlm_header *hd, int nodeid)
3753+
{
3754+
struct dlm_message *ms = (struct dlm_message *) hd;
3755+
struct dlm_rcom *rc = (struct dlm_rcom *) hd;
3756+
struct dlm_ls *ls;
3757+
int type = 0;
3758+
3759+
switch (hd->h_cmd) {
3760+
case DLM_MSG:
3761+
dlm_message_in(ms);
3762+
type = ms->m_type;
3763+
break;
3764+
case DLM_RCOM:
3765+
dlm_rcom_in(rc);
3766+
type = rc->rc_type;
3767+
break;
3768+
default:
3769+
log_print("invalid h_cmd %d from %u", hd->h_cmd, nodeid);
3770+
return;
3771+
}
3772+
3773+
if (hd->h_nodeid != nodeid) {
3774+
log_print("invalid h_nodeid %d from %d lockspace %x",
3775+
hd->h_nodeid, nodeid, hd->h_lockspace);
3776+
return;
3777+
}
3778+
3779+
ls = dlm_find_lockspace_global(hd->h_lockspace);
3780+
if (!ls) {
3781+
log_print("invalid h_lockspace %x from %d cmd %d type %d",
3782+
hd->h_lockspace, nodeid, hd->h_cmd, type);
3783+
3784+
if (hd->h_cmd == DLM_RCOM && type == DLM_RCOM_STATUS)
3785+
dlm_send_ls_not_ready(nodeid, rc);
3786+
return;
3787+
}
3788+
3789+
/* this rwsem allows dlm_ls_stop() to wait for all dlm_recv threads to
3790+
be inactive (in this ls) before transitioning to recovery mode */
3791+
3792+
down_read(&ls->ls_recv_active);
3793+
if (hd->h_cmd == DLM_MSG)
3794+
dlm_receive_message(ls, ms, nodeid);
3795+
else
3796+
dlm_receive_rcom(ls, rc, nodeid);
3797+
up_read(&ls->ls_recv_active);
3798+
3799+
dlm_put_lockspace(ls);
3800+
}
37753801

37763802
static void recover_convert_waiter(struct dlm_ls *ls, struct dlm_lkb *lkb)
37773803
{
@@ -4429,7 +4455,8 @@ int dlm_user_unlock(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
44294455

44304456
if (lvb_in && ua->lksb.sb_lvbptr)
44314457
memcpy(ua->lksb.sb_lvbptr, lvb_in, DLM_USER_LVB_LEN);
4432-
ua->castparam = ua_tmp->castparam;
4458+
if (ua_tmp->castparam)
4459+
ua->castparam = ua_tmp->castparam;
44334460
ua->user_lksb = ua_tmp->user_lksb;
44344461

44354462
error = set_unlock_args(flags, ua, &args);
@@ -4474,7 +4501,8 @@ int dlm_user_cancel(struct dlm_ls *ls, struct dlm_user_args *ua_tmp,
44744501
goto out;
44754502

44764503
ua = (struct dlm_user_args *)lkb->lkb_astparam;
4477-
ua->castparam = ua_tmp->castparam;
4504+
if (ua_tmp->castparam)
4505+
ua->castparam = ua_tmp->castparam;
44784506
ua->user_lksb = ua_tmp->user_lksb;
44794507

44804508
error = set_unlock_args(flags, ua, &args);

‎fs/dlm/lock.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
void dlm_print_rsb(struct dlm_rsb *r);
1717
void dlm_dump_rsb(struct dlm_rsb *r);
1818
void dlm_print_lkb(struct dlm_lkb *lkb);
19-
int dlm_receive_message(struct dlm_header *hd, int nodeid, int recovery);
19+
void dlm_receive_message_saved(struct dlm_ls *ls, struct dlm_message *ms);
20+
void dlm_receive_buffer(struct dlm_header *hd, int nodeid);
2021
int dlm_modes_compat(int mode1, int mode2);
2122
int dlm_find_rsb(struct dlm_ls *ls, char *name, int namelen,
2223
unsigned int flags, struct dlm_rsb **r_ret);

‎fs/dlm/lockspace.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ static int new_lockspace(char *name, int namelen, void **lockspace,
519519
ls->ls_recover_seq = 0;
520520
ls->ls_recover_args = NULL;
521521
init_rwsem(&ls->ls_in_recovery);
522+
init_rwsem(&ls->ls_recv_active);
522523
INIT_LIST_HEAD(&ls->ls_requestqueue);
523524
mutex_init(&ls->ls_requestqueue_mutex);
524525
mutex_init(&ls->ls_clear_proc_locks);

‎fs/dlm/lowcomms.c‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -334,18 +334,8 @@ static void close_connection(struct connection *con, bool and_other)
334334
con->rx_page = NULL;
335335
}
336336

337-
/* If we are an 'othercon' then NULL the pointer to us
338-
from the parent and tidy ourself up */
339-
if (test_bit(CF_IS_OTHERCON, &con->flags)) {
340-
struct connection *parent = __nodeid2con(con->nodeid, 0);
341-
parent->othercon = NULL;
342-
kmem_cache_free(con_cache, con);
343-
}
344-
else {
345-
/* Parent connections get reused */
346-
con->retries = 0;
347-
mutex_unlock(&con->sock_mutex);
348-
}
337+
con->retries = 0;
338+
mutex_unlock(&con->sock_mutex);
349339
}
350340

351341
/* We only send shutdown messages to nodes that are not part of the cluster */
@@ -731,6 +721,8 @@ static int tcp_accept_from_sock(struct connection *con)
731721
INIT_WORK(&othercon->swork, process_send_sockets);
732722
INIT_WORK(&othercon->rwork, process_recv_sockets);
733723
set_bit(CF_IS_OTHERCON, &othercon->flags);
724+
}
725+
if (!othercon->sock) {
734726
newcon->othercon = othercon;
735727
othercon->sock = newsock;
736728
newsock->sk->sk_user_data = othercon;
@@ -1272,14 +1264,15 @@ static void send_to_sock(struct connection *con)
12721264
if (len) {
12731265
ret = sendpage(con->sock, e->page, offset, len,
12741266
msg_flags);
1275-
if (ret == -EAGAIN || ret == 0)
1267+
if (ret == -EAGAIN || ret == 0) {
1268+
cond_resched();
12761269
goto out;
1270+
}
12771271
if (ret <= 0)
12781272
goto send_error;
1279-
} else {
1273+
}
12801274
/* Don't starve people filling buffers */
12811275
cond_resched();
1282-
}
12831276

12841277
spin_lock(&con->writequeue_lock);
12851278
e->offset += ret;

‎fs/dlm/member.c‎

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
#include "rcom.h"
1919
#include "config.h"
2020

21-
/*
22-
* Following called by dlm_recoverd thread
23-
*/
24-
2521
static void add_ordered_member(struct dlm_ls *ls, struct dlm_member *new)
2622
{
2723
struct dlm_member *memb = NULL;
@@ -250,18 +246,30 @@ int dlm_recover_members(struct dlm_ls *ls, struct dlm_recover *rv, int *neg_out)
250246
return error;
251247
}
252248

253-
/*
254-
* Following called from lockspace.c
255-
*/
249+
/* Userspace guarantees that dlm_ls_stop() has completed on all nodes before
250+
dlm_ls_start() is called on any of them to start the new recovery. */
256251

257252
int dlm_ls_stop(struct dlm_ls *ls)
258253
{
259254
int new;
260255

261256
/*
262-
* A stop cancels any recovery that's in progress (see RECOVERY_STOP,
263-
* dlm_recovery_stopped()) and prevents any new locks from being
264-
* processed (see RUNNING, dlm_locking_stopped()).
257+
* Prevent dlm_recv from being in the middle of something when we do
258+
* the stop. This includes ensuring dlm_recv isn't processing a
259+
* recovery message (rcom), while dlm_recoverd is aborting and
260+
* resetting things from an in-progress recovery. i.e. we want
261+
* dlm_recoverd to abort its recovery without worrying about dlm_recv
262+
* processing an rcom at the same time. Stopping dlm_recv also makes
263+
* it easy for dlm_receive_message() to check locking stopped and add a
264+
* message to the requestqueue without races.
265+
*/
266+
267+
down_write(&ls->ls_recv_active);
268+
269+
/*
270+
* Abort any recovery that's in progress (see RECOVERY_STOP,
271+
* dlm_recovery_stopped()) and tell any other threads running in the
272+
* dlm to quit any processing (see RUNNING, dlm_locking_stopped()).
265273
*/
266274

267275
spin_lock(&ls->ls_recover_lock);
@@ -270,9 +278,15 @@ int dlm_ls_stop(struct dlm_ls *ls)
270278
ls->ls_recover_seq++;
271279
spin_unlock(&ls->ls_recover_lock);
272280

281+
/*
282+
* Let dlm_recv run again, now any normal messages will be saved on the
283+
* requestqueue for later.
284+
*/
285+
286+
up_write(&ls->ls_recv_active);
287+
273288
/*
274289
* This in_recovery lock does two things:
275-
*
276290
* 1) Keeps this function from returning until all threads are out
277291
* of locking routines and locking is truely stopped.
278292
* 2) Keeps any new requests from being processed until it's unlocked
@@ -284,9 +298,8 @@ int dlm_ls_stop(struct dlm_ls *ls)
284298

285299
/*
286300
* The recoverd suspend/resume makes sure that dlm_recoverd (if
287-
* running) has noticed the clearing of RUNNING above and quit
288-
* processing the previous recovery. This will be true for all nodes
289-
* before any nodes start the new recovery.
301+
* running) has noticed RECOVERY_STOP above and quit processing the
302+
* previous recovery.
290303
*/
291304

292305
dlm_recoverd_suspend(ls);

‎fs/dlm/midcomms.c‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*******************************************************************************
33
**
44
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
5-
** Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
5+
** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
66
**
77
** This copyrighted material is made available to anyone wishing to use,
88
** modify, copy, or redistribute it subject to the terms and conditions
@@ -27,7 +27,6 @@
2727
#include "dlm_internal.h"
2828
#include "lowcomms.h"
2929
#include "config.h"
30-
#include "rcom.h"
3130
#include "lock.h"
3231
#include "midcomms.h"
3332

@@ -117,19 +116,7 @@ int dlm_process_incoming_buffer(int nodeid, const void *base,
117116
offset &= (limit - 1);
118117
len -= msglen;
119118

120-
switch (msg->h_cmd) {
121-
case DLM_MSG:
122-
dlm_receive_message(msg, nodeid, 0);
123-
break;
124-
125-
case DLM_RCOM:
126-
dlm_receive_rcom(msg, nodeid);
127-
break;
128-
129-
default:
130-
log_print("unknown msg type %x from %u: %u %u %u %u",
131-
msg->h_cmd, nodeid, msglen, len, offset, ret);
132-
}
119+
dlm_receive_buffer(msg, nodeid);
133120
}
134121

135122
if (msg != (struct dlm_header *) __tmp)

0 commit comments

Comments
 (0)