Skip to content

Commit e0c2a9a

Browse files
teiglandswhiteho
authored andcommitted
GFS2: dlm based recovery coordination
This new method of managing recovery is an alternative to the previous approach of using the userland gfs_controld. - use dlm slot numbers to assign journal id's - use dlm recovery callbacks to initiate journal recovery - use a dlm lock to determine the first node to mount fs - use a dlm lock to track journals that need recovery Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent e343a89 commit e0c2a9a

10 files changed

Lines changed: 1098 additions & 42 deletions

File tree

‎fs/gfs2/glock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1353,7 +1353,7 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret)
13531353
spin_lock(&gl->gl_spin);
13541354
gl->gl_reply = ret;
13551355

1356-
if (unlikely(test_bit(DFL_BLOCK_LOCKS, &ls->ls_flags))) {
1356+
if (unlikely(test_bit(DFL_BLOCK_LOCKS, &ls->ls_recover_flags))) {
13571357
if (gfs2_should_freeze(gl)) {
13581358
set_bit(GLF_FROZEN, &gl->gl_flags);
13591359
spin_unlock(&gl->gl_spin);

‎fs/gfs2/glock.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,11 @@ enum {
121121

122122
struct lm_lockops {
123123
const char *lm_proto_name;
124-
int (*lm_mount) (struct gfs2_sbd *sdp, const char *fsname);
125-
void (*lm_unmount) (struct gfs2_sbd *sdp);
124+
int (*lm_mount) (struct gfs2_sbd *sdp, const char *table);
125+
void (*lm_first_done) (struct gfs2_sbd *sdp);
126+
void (*lm_recovery_result) (struct gfs2_sbd *sdp, unsigned int jid,
127+
unsigned int result);
128+
void (*lm_unmount) (struct gfs2_sbd *sdp);
126129
void (*lm_withdraw) (struct gfs2_sbd *sdp);
127130
void (*lm_put_lock) (struct gfs2_glock *gl);
128131
int (*lm_lock) (struct gfs2_glock *gl, unsigned int req_state,

‎fs/gfs2/incore.h‎

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,45 @@ struct gfs2_bufdata {
139139
#define GDLM_STRNAME_BYTES 25
140140
#define GDLM_LVB_SIZE 32
141141

142+
/*
143+
* ls_recover_flags:
144+
*
145+
* DFL_BLOCK_LOCKS: dlm is in recovery and will grant locks that had been
146+
* held by failed nodes whose journals need recovery. Those locks should
147+
* only be used for journal recovery until the journal recovery is done.
148+
* This is set by the dlm recover_prep callback and cleared by the
149+
* gfs2_control thread when journal recovery is complete. To avoid
150+
* races between recover_prep setting and gfs2_control clearing, recover_spin
151+
* is held while changing this bit and reading/writing recover_block
152+
* and recover_start.
153+
*
154+
* DFL_NO_DLM_OPS: dlm lockspace ops/callbacks are not being used.
155+
*
156+
* DFL_FIRST_MOUNT: this node is the first to mount this fs and is doing
157+
* recovery of all journals before allowing other nodes to mount the fs.
158+
* This is cleared when FIRST_MOUNT_DONE is set.
159+
*
160+
* DFL_FIRST_MOUNT_DONE: this node was the first mounter, and has finished
161+
* recovery of all journals, and now allows other nodes to mount the fs.
162+
*
163+
* DFL_MOUNT_DONE: gdlm_mount has completed successfully and cleared
164+
* BLOCK_LOCKS for the first time. The gfs2_control thread should now
165+
* control clearing BLOCK_LOCKS for further recoveries.
166+
*
167+
* DFL_UNMOUNT: gdlm_unmount sets to keep sdp off gfs2_control_wq.
168+
*
169+
* DFL_DLM_RECOVERY: set while dlm is in recovery, between recover_prep()
170+
* and recover_done(), i.e. set while recover_block == recover_start.
171+
*/
172+
142173
enum {
143174
DFL_BLOCK_LOCKS = 0,
175+
DFL_NO_DLM_OPS = 1,
176+
DFL_FIRST_MOUNT = 2,
177+
DFL_FIRST_MOUNT_DONE = 3,
178+
DFL_MOUNT_DONE = 4,
179+
DFL_UNMOUNT = 5,
180+
DFL_DLM_RECOVERY = 6,
144181
};
145182

146183
struct lm_lockname {
@@ -499,14 +536,26 @@ struct gfs2_sb_host {
499536
struct lm_lockstruct {
500537
int ls_jid;
501538
unsigned int ls_first;
502-
unsigned int ls_first_done;
503539
unsigned int ls_nodir;
504540
const struct lm_lockops *ls_ops;
505-
unsigned long ls_flags;
506541
dlm_lockspace_t *ls_dlm;
507542

508-
int ls_recover_jid_done;
509-
int ls_recover_jid_status;
543+
int ls_recover_jid_done; /* These two are deprecated, */
544+
int ls_recover_jid_status; /* used previously by gfs_controld */
545+
546+
struct dlm_lksb ls_mounted_lksb; /* mounted_lock */
547+
struct dlm_lksb ls_control_lksb; /* control_lock */
548+
char ls_control_lvb[GDLM_LVB_SIZE]; /* control_lock lvb */
549+
struct completion ls_sync_wait; /* {control,mounted}_{lock,unlock} */
550+
551+
spinlock_t ls_recover_spin; /* protects following fields */
552+
unsigned long ls_recover_flags; /* DFL_ */
553+
uint32_t ls_recover_mount; /* gen in first recover_done cb */
554+
uint32_t ls_recover_start; /* gen in last recover_done cb */
555+
uint32_t ls_recover_block; /* copy recover_start in last recover_prep */
556+
uint32_t ls_recover_size; /* size of recover_submit, recover_result */
557+
uint32_t *ls_recover_submit; /* gen in last recover_slot cb per jid */
558+
uint32_t *ls_recover_result; /* result of last jid recovery */
510559
};
511560

512561
struct gfs2_sbd {
@@ -544,6 +593,7 @@ struct gfs2_sbd {
544593
wait_queue_head_t sd_glock_wait;
545594
atomic_t sd_glock_disposal;
546595
struct completion sd_locking_init;
596+
struct delayed_work sd_control_work;
547597

548598
/* Inode Stuff */
549599

0 commit comments

Comments
 (0)