gfs2: dlm based recovery coordination
PATCH 5/5 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
--- fs/gfs2/glock.c | 2 +- fs/gfs2/glock.h | 7 +- fs/gfs2/incore.h | 58 +++- fs/gfs2/lock_dlm.c | 993 ++++++++++++++++++++++++++++++++++++++++++- fs/gfs2/main.c | 10 + fs/gfs2/ops_fstype.c | 29 +- fs/gfs2/recovery.c | 4 + fs/gfs2/sys.c | 33 +- fs/gfs2/sys.h | 2 + include/linux/gfs2_ondisk.h | 2 + 10 files changed, 1098 insertions(+), 42 deletions(-)
fs/gfs2/glock.c +1 -1
@@ -1353,7 +1353,7 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret)spin_lock (&gl->gl_spin); gl->gl_reply = ret; -if (unlikely (test_bit (DFL_BLOCK_LOCKS , &ls->ls_flags))) { +if (unlikely (test_bit (DFL_BLOCK_LOCKS , &ls->ls_recover_flags))) {if (gfs2_should_freeze (gl)) {set_bit (GLF_FROZEN , &gl->gl_flags);spin_unlock (&gl->gl_spin);
fs/gfs2/glock.h +5 -2
@@ -121,8 +121,11 @@ enum {struct lm_lockops {const char *lm_proto_name; -int (*lm_mount) (struct gfs2_sbd *sdp,const char *fsname); -void (*lm_unmount) (struct gfs2_sbd *sdp); +int (*lm_mount) (struct gfs2_sbd *sdp,const char *table); +void (*lm_first_done) (struct gfs2_sbd *sdp); +void (*lm_recovery_result) (struct gfs2_sbd *sdp,unsigned int jid, +unsigned int result); +void (*lm_unmount) (struct gfs2_sbd *sdp);void (*lm_withdraw) (struct gfs2_sbd *sdp);void (*lm_put_lock) (struct gfs2_glock *gl); int (*lm_lock) (struct gfs2_glock *gl, unsigned int req_state,
fs/gfs2/incore.h +54 -4
82 lines not on this page · raw message
fs/gfs2/lock_dlm.c +983 -10
1,041 lines not on this page · raw message
fs/gfs2/main.c +10 -0
@@ -28,6 +28,8 @@#include "recovery.h" #include "dir.h" +struct workqueue_struct *gfs2_control_wq; +static struct shrinker qd_shrinker = { .shrink = gfs2_shrink_qd_memory, .seeks =DEFAULT_SEEKS ,
@@ -145,12 +147,19 @@ static int __init init_gfs2_fs(void)if (!gfs_recovery_wq) goto fail_wq; + gfs2_control_wq =alloc_workqueue ("gfs2_control" , +WQ_NON_REENTRANT |WQ_UNBOUND |WQ_FREEZABLE ,0 ); +if (!gfs2_control_wq) + goto fail_control; +gfs2_register_debugfs ();printk ("GFS2 installed\n" );return 0 ; +fail_control: +destroy_workqueue (gfs_recovery_wq); fail_wq:unregister_filesystem (&gfs2meta_fs_type); fail_unregister:
@@ -194,6 +203,7 @@ static void __exit exit_gfs2_fs(void)unregister_filesystem (&gfs2_fs_type);unregister_filesystem (&gfs2meta_fs_type);destroy_workqueue (gfs_recovery_wq); +destroy_workqueue (gfs2_control_wq);rcu_barrier ();
fs/gfs2/ops_fstype.c +16 -13
@@ -562,8 +562,12 @@ static void gfs2_others_may_mount(struct gfs2_sbd *sdp) {char *message ="FIRSTMOUNT=Done" ;char *envp[] = { message,NULL }; -struct lm_lockstruct *ls = &sdp->sd_lockstruct; - ls->ls_first_done =1 ; + +fs_info (sdp,"first mount done, others may mount\n" ); + +if (sdp->sd_lockstruct.ls_ops->lm_first_done) + sdp->sd_lockstruct.ls_ops->lm_first_done (sdp); +kobject_uevent_env (&sdp->sd_kobj,KOBJ_CHANGE , envp); }
@@ -947,7 +951,6 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent)struct gfs2_args *args = &sdp->sd_args;const char *proto = sdp->sd_proto_name;const char *table = sdp->sd_table_name; -const char *fsname;char *o, *options;int ret;
@@ -1007,21 +1010,12 @@ hostdata_error: } } -if (sdp->sd_args.ar_spectator) -snprintf (sdp->sd_fsname,GFS2_FSNAME_LEN ,"%s.s" , table); -else -snprintf (sdp->sd_fsname,GFS2_FSNAME_LEN ,"%s.%u" , table, - sdp->sd_lockstruct.ls_jid); - - fsname =strchr (table,':' ); -if (fsname) - fsname++;if (lm->lm_mount ==NULL ) {fs_info (sdp,"Now mounting FS...\n" );complete_all (&sdp->sd_locking_init);return 0 ; } - ret = lm->lm_mount (sdp, fsname); + ret = lm->lm_mount (sdp, table);if (ret ==0 )fs_info (sdp,"Joined cluster. Now mounting FS...\n" );complete_all (&sdp->sd_locking_init);
@@ -1127,6 +1121,8 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silentif (error) goto fail; +snprintf (sdp->sd_fsname,GFS2_FSNAME_LEN ,"%s" , sdp->sd_table_name); +gfs2_create_debugfs_file (sdp); error =gfs2_sys_fs_add (sdp);
@@ -1163,6 +1159,13 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silent goto fail_sb; } +if (sdp->sd_args.ar_spectator) +snprintf (sdp->sd_fsname,GFS2_FSNAME_LEN ,"%s.s" , + sdp->sd_table_name); +else +snprintf (sdp->sd_fsname,GFS2_FSNAME_LEN ,"%s.%u" , + sdp->sd_table_name, sdp->sd_lockstruct.ls_jid); + error =init_inodes (sdp,DO );if (error) goto fail_sb;
fs/gfs2/recovery.c +4 -0
@@ -436,12 +436,16 @@ static void gfs2_recovery_done(struct gfs2_sbd *sdp, unsigned int jid,char env_status[20 ];char *envp[] = { env_jid, env_status,NULL };struct lm_lockstruct *ls = &sdp->sd_lockstruct; + ls->ls_recover_jid_done = jid; ls->ls_recover_jid_status = message;sprintf (env_jid,"JID=%d" , jid);sprintf (env_status,"RECOVERY=%s" , message ==LM_RD_SUCCESS ?"Done" :"Failed" );kobject_uevent_env (&sdp->sd_kobj,KOBJ_CHANGE , envp); + +if (sdp->sd_lockstruct.ls_ops->lm_recovery_result) + sdp->sd_lockstruct.ls_ops->lm_recovery_result (sdp, jid, message); }void gfs2_recover_func (struct work_struct *work)
fs/gfs2/sys.c +21 -12
@@ -298,7 +298,7 @@ static ssize_t block_show(struct gfs2_sbd *sdp, char *buf)ssize_t ret;int val =0 ; -if (test_bit (DFL_BLOCK_LOCKS , &ls->ls_flags)) +if (test_bit (DFL_BLOCK_LOCKS , &ls->ls_recover_flags)) val =1 ; ret =sprintf (buf,"%d\n" , val);return ret;
@@ -313,9 +313,9 @@ static ssize_t block_store(struct gfs2_sbd *sdp, const char *buf, size_t len) val =simple_strtol (buf,NULL ,0 );if (val ==1 ) -set_bit (DFL_BLOCK_LOCKS , &ls->ls_flags); +set_bit (DFL_BLOCK_LOCKS , &ls->ls_recover_flags);else if (val ==0 ) { -clear_bit (DFL_BLOCK_LOCKS , &ls->ls_flags); +clear_bit (DFL_BLOCK_LOCKS , &ls->ls_recover_flags);smp_mb__after_clear_bit ();gfs2_glock_thaw (sdp); }else {
@@ -350,8 +350,8 @@ static ssize_t lkfirst_store(struct gfs2_sbd *sdp, const char *buf, size_t len) goto out;if (sdp->sd_lockstruct.ls_ops->lm_mount ==NULL ) goto out; - sdp->sd_lockstruct.ls_first = first; - rv =0 ; + sdp->sd_lockstruct.ls_first = first; + rv =0 ; out:spin_unlock (&sdp->sd_jindex_spin);return rv ? rv : len;
@@ -360,19 +360,14 @@ out:static ssize_t first_done_show (struct gfs2_sbd *sdp,char *buf) {struct lm_lockstruct *ls = &sdp->sd_lockstruct; -return sprintf (buf,"%d\n" , ls->ls_first_done); +return sprintf (buf,"%d\n" , !!test_bit (DFL_FIRST_MOUNT_DONE , &ls->ls_recover_flags)); } -static ssize_t recover_store (struct gfs2_sbd *sdp,const char *buf,size_t len) +int gfs2_recover_set (struct gfs2_sbd *sdp,unsigned jid) { -unsigned jid;struct gfs2_jdesc *jd;int rv; - rv =sscanf (buf,"%u" , &jid); -if (rv !=1 ) -return -EINVAL ; - rv = -ESHUTDOWN ;spin_lock (&sdp->sd_jindex_spin);if (test_bit (SDF_NORECOVERY , &sdp->sd_flags))
@@ -389,6 +384,20 @@ static ssize_t recover_store(struct gfs2_sbd *sdp, const char *buf, size_t len) } out:spin_unlock (&sdp->sd_jindex_spin); +return rv; +} + +static ssize_t recover_store (struct gfs2_sbd *sdp,const char *buf,size_t len) +{ +unsigned jid; +int rv; + + rv =sscanf (buf,"%u" , &jid); +if (rv !=1 ) +return -EINVAL ; + + rv =gfs2_recover_set (sdp, jid); +return rv ? rv : len; }
fs/gfs2/sys.h +2 -0
@@ -19,5 +19,7 @@ void gfs2_sys_fs_del(struct gfs2_sbd *sdp);int gfs2_sys_init (void );void gfs2_sys_uninit (void ); +int gfs2_recover_set (struct gfs2_sbd *sdp,unsigned jid); +#endif /* __SYS_DOT_H__ */
include/linux/gfs2_ondisk.h +2 -0
@@ -22,6 +22,8 @@#define GFS2_LIVE_LOCK 1#define GFS2_TRANS_LOCK 2#define GFS2_RENAME_LOCK 3 +#define GFS2_CONTROL_LOCK 4 +#define GFS2_MOUNTED_LOCK 5/* Format numbers for various metadata types */
Signature · 1 line
1.7.6
PATCH 5/5 gfs2: dlm based recovery coordination
Hi,
On Thu, 2012-01-05 at 10:46 -0600, David Teigland wrote:
[snip]
Quoted 81 lines
fs/gfs2/lock_dlm.c +80
-0+static int gdlm_mount (struct gfs2_sbd *sdp,const char *table) +{ +struct lm_lockstruct *ls = &sdp->sd_lockstruct; +char cluster[GFS2_LOCKNAME_LEN ]; +const char *fsname; +uint32_t flags; +int error, ops_result; + +/* +* initialize everything +*/ + +INIT_DELAYED_WORK (&sdp->sd_control_work, gfs2_control_func); +spin_lock_init (&ls->ls_recover_spin); + ls->ls_recover_flags =0 ; + ls->ls_recover_mount =0 ; + ls->ls_recover_start =0 ; + ls->ls_recover_block =0 ; + ls->ls_recover_size =0 ; + ls->ls_recover_submit =NULL ; + ls->ls_recover_result =NULL ; + + error =set_recover_size (sdp,NULL ,0 ); +if (error) + goto fail; + +/* +* prepare dlm_new_lockspace args +*/ + + fsname =strchr (table,':' ); +if (!fsname) { +fs_info (sdp,"no fsname found\n" ); + error = -EINVAL ; + goto fail_free; + } +memset (cluster,0 ,sizeof (cluster)); +memcpy (cluster, table,strlen (table) -strlen (fsname)); + fsname++; + + flags =DLM_LSFL_FS |DLM_LSFL_NEWEXCL ; +if (ls->ls_nodir) + flags |=DLM_LSFL_NODIR ; + +/* +* create/join lockspace +*/ + + error =dlm_new_lockspace (fsname, cluster, flags,GDLM_LVB_SIZE , + &gdlm_lockspace_ops, sdp, &ops_result, + &ls->ls_dlm); +if (error) { +fs_err (sdp,"dlm_new_lockspace error %d\n" , error); + goto fail_free; + } + +if (ops_result <0 ) { +/* +* dlm does not support ops callbacks, +* old dlm_controld/gfs_controld are used, try without ops. +*/ +fs_info (sdp,"dlm lockspace ops not used\n" ); +free_recover_size (ls); +set_bit (DFL_NO_DLM_OPS , &ls->ls_recover_flags); +return 0 ; + } + +if (!test_bit (SDF_NOJOURNALID , &sdp->sd_flags)) { +fs_err (sdp,"dlm lockspace ops disallow jid preset\n" ); + error = -EINVAL ; + goto fail_release; + } + +/* +* control_mount() uses control_lock to determine first mounter, +* and for later mounts, waits for any recoveries to be cleared. +*/ + + error =control_mount (sdp); +if (error) {
fs/gfs2/lock_dlm.c static void gdlm_cancel(struct gfs2_glock *gl) · line 1143
Quoted 10 lines
fs/gfs2/lock_dlm.c +10
-0+fs_err (sdp,"mount control error %d\n" , error); + goto fail_release; + } + +clear_bit (SDF_NOJOURNALID , &sdp->sd_flags); +smp_mb__after_clear_bit (); +wake_up_bit (&sdp->sd_flags,SDF_NOJOURNALID ); + ls->ls_first = !!test_bit (DFL_FIRST_MOUNT , &ls->ls_recover_flags); +return 0 ; +
This bit of code, which was correct last time you posted this patch appears to have reverted to its previous incorrect state. ls_first must be set before SDF_NOJOURNALID is cleared, otherwise the uninitialised value may be read,
Steve.
PATCH 5/5 gfs2: dlm based recovery coordination
Quoted 9 lines · Steven Whitehouse
fs/gfs2/lock_dlm.c static void gdlm_cancel(struct gfs2_glock *gl) · line 1143
Quoted 6 lines
fs/gfs2/lock_dlm.c +6
-0+clear_bit (SDF_NOJOURNALID , &sdp->sd_flags); +smp_mb__after_clear_bit (); +wake_up_bit (&sdp->sd_flags,SDF_NOJOURNALID ); + ls->ls_first = !!test_bit (DFL_FIRST_MOUNT , &ls->ls_recover_flags); +return 0 ; +This bit of code, which was correct last time you posted this patch appears to have reverted to its previous incorrect state.
ls_firstmust
Thanks, I'll move it back, I removed ls_first and put it back in the wrong place. I keep forgetting about it because...
Quoted 2 lines
be set before
SDF_NOJOURNALIDis cleared, otherwise the uninitialised value may be read,
in this case there can be no other reader, so it doesn't matter.
Dave
PATCH 5/5 gfs2: dlm based recovery coordination
In reply to David TeiglandHi,
Quoted 9 lines · David Teigland
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 recoverySigned-off-by David Teigland <[email protected]>
Quoted 13 lines
--- fs/gfs2/glock.c | 2 +- fs/gfs2/glock.h | 7 +- fs/gfs2/incore.h | 58 +++- fs/gfs2/lock_dlm.c | 993 ++++++++++++++++++++++++++++++++++++++++++- fs/gfs2/main.c | 10 + fs/gfs2/ops_fstype.c | 29 +- fs/gfs2/recovery.c | 4 + fs/gfs2/sys.c | 33 +- fs/gfs2/sys.h | 2 + include/linux/gfs2_ondisk.h | 2 + 10 files changed, 1098 insertions(+), 42 deletions(-)
I've just been looking at this again, and a question springs to mind... how does this deal with nodes which are read-only or spectator mounts? In the old system we used to propagate that information to gfs_controld but I've not spotted anything similar in the patch so far, so I'm wondering whether it needs to know that information or not,
Steve.
PATCH 5/5 gfs2: dlm based recovery coordination
Quoted 9 lines · Steven Whitehouse
Quoted 7 lines · David Teigland
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
Quoted 5 lines
I've just been looking at this again, and a question springs to mind... how does this deal with nodes which are read-only or spectator mounts? In the old system we used to propagate that information to
gfs_controldbut I've not spotted anything similar in the patch so far, so I'm wondering whether it needs to know that information or not,
The dlm allocates a "slot" for all lockspace members, so spectator mounts (like readonly mounts) would be given a slot/jid. In gfs_controld, spectator mounts are not be given a jid (that came from the time when adding a journal required extending the device+fs.) These days, there's probably no meaningful difference between spectator and readonly mounts.
PATCH 5/5 gfs2: dlm based recovery coordination
Quoted 16 lines · David Teigland
Quoted 9 lines · Steven Whitehouse
Quoted 7 lines · David Teigland
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 recoveryQuoted 5 lines
I've just been looking at this again, and a question springs to mind... how does this deal with nodes which are read-only or spectator mounts? In the old system we used to propagate that information to
gfs_controldbut I've not spotted anything similar in the patch so far, so I'm wondering whether it needs to know that information or not,
Quoted 5 lines
The dlm allocates a "slot" for all lockspace members, so spectator mounts (like readonly mounts) would be given a slot/jid. In
gfs_controld, spectator mounts are not be given a jid (that came from the time when adding a journal required extending the device+fs.) These days, there's probably no meaningful difference between spectator and readonly mounts.
There's one other part, and that's whether a readonly or spectator node should attempt to recover the journal of a failed node. In cluster3 this decision was always a bit mixed up, with some logic in gfs_controld and some in gfs2.
We should make a clear decision now and include it in this patch. I think gfs2_recover_func() should return GAVEUP right at the start for any of the cases where you don't want it doing recovery. What cases would you prefer?
PATCH 5/5 gfs2: dlm based recovery coordination
Hi,
Quoted 28 lines · David Teigland
Quoted 16 lines · David Teigland
Quoted 9 lines · Steven Whitehouse
Quoted 7 lines · David Teigland
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 recoveryQuoted 5 lines
I've just been looking at this again, and a question springs to mind... how does this deal with nodes which are read-only or spectator mounts? In the old system we used to propagate that information to
gfs_controldbut I've not spotted anything similar in the patch so far, so I'm wondering whether it needs to know that information or not,Quoted 5 lines
The dlm allocates a "slot" for all lockspace members, so spectator mounts (like readonly mounts) would be given a slot/jid. In
gfs_controld, spectator mounts are not be given a jid (that came from the time when adding a journal required extending the device+fs.) These days, there's probably no meaningful difference between spectator and readonly mounts.There's one other part, and that's whether a readonly or spectator node should attempt to recover the journal of a failed node. In cluster3 this decision was always a bit mixed up, with some logic in
gfs_controldand some in gfs2.
Quoted 5 lines
We should make a clear decision now and include it in this patch. I think
gfs2_recover_func()should return GAVEUP right at the start for any of the cases where you don't want it doing recovery. What cases would you prefer?
Yes, if it can't recover, then thats a good idea. We also need to ensure that we are not trying to recover nodes which don't need recovery though (see my earlier email)
Steve.
PATCH 5/5 gfs2: dlm based recovery coordination
In reply to David TeiglandHi,
Quoted 16 lines · David Teigland
Quoted 9 lines · Steven Whitehouse
Quoted 7 lines · David Teigland
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 recoveryQuoted 5 lines
I've just been looking at this again, and a question springs to mind... how does this deal with nodes which are read-only or spectator mounts? In the old system we used to propagate that information to
gfs_controldbut I've not spotted anything similar in the patch so far, so I'm wondering whether it needs to know that information or not,
Quoted 6 lines
The dlm allocates a "slot" for all lockspace members, so spectator mounts (like readonly mounts) would be given a slot/jid. In
gfs_controld, spectator mounts are not be given a jid (that came from the time when adding a journal required extending the device+fs.) These days, there's probably no meaningful difference between spectator and readonly mounts.
The issue is more related to recovery time, though. For spectator mounts, we don't have to care about recovery at all, and if one fails, it does not need to be recovered at the fs level. Spectator mounts can check the journals, but cannot recover any, so as the first mounter of the filesystem, they must fail to mount if any journals are left dirty.
For read only, it is less clear... the first read only mounter of the fs must recover all journals. After that, currently, read-only nodes do not perform recovery, although we could change that - it isn't clear what the correct path is here, so we need to pick one and stick with it. If a read-only node fails, we do not need to recover it, since there is nothing to do (as per spectator).
What I want to avoid is having a cluster of read-only mounted nodes, have one fail, and then the rest of the cluster is stuck because its trying to recover the journal for the failed node and there are no nodes which are able to perform that recovery left in the cluster.
If assigning a slot to spectator mounts means that spectator mounts now have (effectively) a journal id assigned to them, even if they never touch it, then that is a change we need to be careful to document in case someone has a small filesystem with a number of spectator mounters sharing it, and is thus unable to create more journals when they upgrade to the new system.
Steve.