GFS2: Pre-pull patch posting (merge window set #2)
Hi,
The following patch set contains one large patch which was previously in the DLM tree (and hence also in linux-next) but which is entirely focused on GFS2, and has thus been moved into the GFS2 tree after the merge of the recent DLM patches. In addition there are a few small bug fixes too,
Steve.
PATCH 1/5 GFS2: dlm based recovery coordination
From: David Teigland <[email protected]>
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 +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 ,
@@ -146,12 +148,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:
@@ -195,6 +204,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); }
@@ -944,7 +948,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;
@@ -1004,21 +1007,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);
@@ -1124,6 +1118,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);
@@ -1160,6 +1156,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.4
PATCH 2/5 GFS2: Fix a use-after-free that coverity spotted
In reply to Steven WhitehouseFrom: Bob Peterson <[email protected]>
In function gfs2_inplace_release it was trying to unlock a gfs2_holder structure associated with a reservation, after said reservation was freed. The problem is that the statements have the wrong order. This patch corrects the order so that the reservation is freed after the gfs2_holder is unlocked.
fs/gfs2/rgrp.c +1 -1
@@ -1108,9 +1108,9 @@ void gfs2_inplace_release(struct gfs2_inode *ip) {struct gfs2_blkreserv *rs = ip->i_res; -gfs2_blkrsv_put (ip);if (rs->rs_rgd_gh.gh_gl)gfs2_glock_dq_uninit (&rs->rs_rgd_gh); +gfs2_blkrsv_put (ip); }/**
Signature · 1 line
1.7.4
PATCH 3/5 GFS2: let spectator mount do read only recovery
In reply to Steven WhitehouseFrom: David Teigland <[email protected]>
Previously, a spectator mount would not even attempt to do journal recovery for a failed node. This meant that if all mounted nodes were spectators, everyone would be stuck after a node failed, all waiting for recovery to be performed. This is unnecessary since the failed node had a clean journal.
Instead, allow a spectator mount to do a partial "read only" recovery, which means it will check if the failed journal is clean, and if so, report a successful recovery. If the failed journal is not clean, it reports that journal recovery failed. This makes it work the same as a read only mount on a read only block device.
fs/gfs2/incore.h +1 -0
@@ -498,6 +498,7 @@ enum {SDF_NORECOVERY =4 ,SDF_DEMOTE =5 ,SDF_NOJOURNALID =6 , + SDF_RORECOVERY = 7, /* read only recovery */ };#define GFS2_FSNAME_LEN 256
fs/gfs2/ops_fstype.c +1 -1
@@ -1078,7 +1078,7 @@ static int fill_super(struct super_block *sb, struct gfs2_args *args, int silentif (sdp->sd_args.ar_spectator) { sb->s_flags |=MS_RDONLY ; -set_bit (SDF_NORECOVERY , &sdp->sd_flags); +set_bit (SDF_RORECOVERY , &sdp->sd_flags); }if (sdp->sd_args.ar_posix_acl) sb->s_flags |=MS_POSIXACL ;
fs/gfs2/recovery.c +3 -1
@@ -516,7 +516,9 @@ void gfs2_recover_func(struct work_struct *work)if (error) goto fail_gunlock_ji; -if (test_bit (SDF_JOURNAL_CHECKED , &sdp->sd_flags)) { +if (test_bit (SDF_RORECOVERY , &sdp->sd_flags)) { + ro =1 ; + }else if (test_bit (SDF_JOURNAL_CHECKED , &sdp->sd_flags)) {if (!test_bit (SDF_JOURNAL_LIVE , &sdp->sd_flags)) ro =1 ; }else {
Signature · 1 line
1.7.4
PATCH 4/5 GFS2: fail mount if journal recovery fails
In reply to Steven WhitehouseFrom: David Teigland <[email protected]>
If the first mounter fails to recover one of the journals during mount, the mount should fail.
fs/gfs2/incore.h +1 -0
@@ -429,6 +429,7 @@ struct gfs2_jdesc {#define JDF_RECOVERY 1unsigned int jd_jid;unsigned int jd_blocks; +int jd_recover_error; };struct gfs2_statfs_change_host {
fs/gfs2/recovery.c +2 -1
@@ -583,6 +583,7 @@ fail_gunlock_j:fs_info (sdp,"jid=%u: %s\n" , jd->jd_jid, (error) ?"Failed" :"Done" ); fail: + jd->jd_recover_error = error;gfs2_recovery_done (sdp, jd->jd_jid,LM_RD_GAVEUP ); done:clear_bit (JDF_RECOVERY , &jd->jd_flags);
@@ -611,6 +612,6 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd, bool wait)wait_on_bit (&jd->jd_flags,JDF_RECOVERY , gfs2_recovery_wait,TASK_UNINTERRUPTIBLE ); -return 0 ; +return wait ? jd->jd_recover_error :0 ; }
Signature · 1 line
1.7.4
PATCH 5/5 GFS2: Fix nlink setting on inode creation
In reply to Steven WhitehouseSince the nlink count will be 0, we need to use set_nlink rather than inc_nlink in order to avoid triggering the inc_nlink warning which was added recently.
fs/gfs2/inode.c +1 -3
@@ -599,9 +599,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name, error =gfs2_meta_inode_buffer (ip, &dibh);if (error) goto fail_end_trans; -inc_nlink (&ip->i_inode); -if (S_ISDIR (ip->i_inode.i_mode)) -inc_nlink (&ip->i_inode); +set_nlink (&ip->i_inode,S_ISDIR (ip->i_inode.i_mode) ?2 :1 );gfs2_trans_add_bh (ip->i_gl, dibh,1 );gfs2_dinode_out (ip, dibh->b_data);brelse (dibh);
Signature · 1 line
1.7.4