Skip to contentSkip to conversation

GFS2: Clean up recovery code

Cluster-devel Steven Whitehouse 1 participant 1 message Nov 10, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

The following patch cleans up the recovery code and fixes a few bugs along the way. The bugs are:
o An incorrect assumption about the size of the journal
o An issue where the superblock was being used to store variables local to the recovery process which would cause a problem if multiple journals were recovered at once.
o Can report incorrect counts of blocks read & recovered in some cases (this is harmless, its just a logging issue)

Features:
o Moves the recovery code from lops.c into recovery.c which allows making a number of functions static and removing other bits of code.
o Removes the "before scan" functions as they are not needed (partly merged into the "scan" functions)
o Removes the "after scan" functions. These have also been merged into the "scan" functions
o We no longer call any functions which may in turn call withdraw from the recovery code. If there is an issue with recovery, we report it to the caller (and userspace).
o New uevent env variable is documented
o Superblock shrinks by 32 bytes on 64 bit arches.
o Code shrinks by about 100 lines (probably more since there are more comments now)

TODO:
o Report where error has occurred in log, as well as what the error is
o Check code for finding journal headers (maybe remove gfs2_log_header_host?)
o Testing :-)

For the moment, this is just a heads up on what I'm working on. I hope it won't be too long before I have a final version of this patch,

Steve.

Documentation/filesystems/gfs2-uevents.txt +4 -0
index fd966dc..c029596 100644
@@ -44,6 +44,10 @@ for every journal recovered, whether it is during the initial mount
 process or as the result of gfs_controld requesting a specific journal
 recovery via the /sys/fs/gfs2/<fsname>/lock_module/recovery file.
 
+If the recovery has failed, then on recent versions of GFS2 the
+ERROR= variable will also be included. This returns a kernel
+error code indicating what went wrong during recovery.
+
 Because the CHANGE uevent was used (in early versions of gfs_controld)
 without checking the environment variables to discover the state, we
 cannot add any more functions to it without running the risk of
fs/gfs2/incore.h +0 -15
index 4792200..e497aaf 100644
@@ -50,12 +50,6 @@ struct gfs2_log_operations {
 	void (*lo_add) (struct gfs2_sbd *sdp, struct gfs2_log_element *le);
 	void (*lo_before_commit) (struct gfs2_sbd *sdp);
 	void (*lo_after_commit) (struct gfs2_sbd *sdp, struct gfs2_ail *ai);
-	void (*lo_before_scan) (struct gfs2_jdesc *jd,
-				struct gfs2_log_header_host *head, int pass);
-	int (*lo_scan_elements) (struct gfs2_jdesc *jd, unsigned int start,
-				 struct gfs2_log_descriptor *ld, __be64 *ptr,
-				 int pass);
-	void (*lo_after_scan) (struct gfs2_jdesc *jd, int error, int pass);
 	const char *lo_name;
 };
 
@@ -648,15 +642,6 @@ struct gfs2_sbd {
 	struct list_head sd_ail2_list;
 	u64 sd_ail_sync_gen;
 
-	/* Replay stuff */
-
-	struct list_head sd_revoke_list;
-	unsigned int sd_replay_tail;
-
-	unsigned int sd_found_blocks;
-	unsigned int sd_found_revokes;
-	unsigned int sd_replayed_blocks;
-
 	/* For quiescing the filesystem */
 
 	struct gfs2_holder sd_freeze_gh;
fs/gfs2/lops.c +6 -239

294 lines not on this page · raw message

fs/gfs2/lops.h +0 -36
index 3c0b273..c2f8dc0 100644
@@ -73,41 +73,5 @@ static inline void lops_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
 			gfs2_log_ops[x]->lo_after_commit(sdp, ai);
 }
 
-static inline void lops_before_scan(struct gfs2_jdesc *jd,
-				    struct gfs2_log_header_host *head,
-				    unsigned int pass)
-{
-	int x;
-	for (x = 0; gfs2_log_ops[x]; x++)
-		if (gfs2_log_ops[x]->lo_before_scan)
-			gfs2_log_ops[x]->lo_before_scan(jd, head, pass);
-}
-
-static inline int lops_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
-				     struct gfs2_log_descriptor *ld,
-				     __be64 *ptr,
-				     unsigned int pass)
-{
-	int x, error;
-	for (x = 0; gfs2_log_ops[x]; x++)
-		if (gfs2_log_ops[x]->lo_scan_elements) {
-			error = gfs2_log_ops[x]->lo_scan_elements(jd, start,
-								  ld, ptr, pass);
-			if (error)
-				return error;
-		}
-
-	return 0;
-}
-
-static inline void lops_after_scan(struct gfs2_jdesc *jd, int error,
-				   unsigned int pass)
-{
-	int x;
-	for (x = 0; gfs2_log_ops[x]; x++)
-		if (gfs2_log_ops[x]->lo_before_scan)
-			gfs2_log_ops[x]->lo_after_scan(jd, error, pass);
-}
-
 #endif /* __LOPS_DOT_H__ */
 
fs/gfs2/meta_io.c +0 -18
index cb8d7a9..e89f14d 100644
@@ -136,24 +136,6 @@ void gfs2_aspace_put(struct inode *aspace)
 }
 
 /**
- * gfs2_meta_sync - Sync all buffers associated with a glock
- * @gl: The glock
- *
- */
-
-void gfs2_meta_sync(struct gfs2_glock *gl)
-{
-	struct address_space *mapping = gl->gl_aspace->i_mapping;
-	int error;
-
-	filemap_fdatawrite(mapping);
-	error = filemap_fdatawait(mapping);
-
-	if (error)
-		gfs2_io_error(gl->gl_sbd);
-}
-
-/**
  * gfs2_getbuf - Get a buffer with a given address space
  * @gl: the glock
  * @blkno: the block number (filesystem scope)
fs/gfs2/meta_io.h +0 -2
index de270c2..38cca55 100644
@@ -40,8 +40,6 @@ static inline void gfs2_buffer_copy_tail(struct buffer_head *to_bh,
 struct inode *gfs2_aspace_get(struct gfs2_sbd *sdp);
 void gfs2_aspace_put(struct inode *aspace);
 
-void gfs2_meta_sync(struct gfs2_glock *gl);
-
 struct buffer_head *gfs2_meta_new(struct gfs2_glock *gl, u64 blkno);
 int gfs2_meta_read(struct gfs2_glock *gl, u64 blkno,
 		   int flags, struct buffer_head **bhp);
fs/gfs2/ops_fstype.c +0 -2
index edfee24..bf7361a 100644
@@ -115,8 +115,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
 	atomic_set(&sdp->sd_log_in_flight, 0);
 	init_waitqueue_head(&sdp->sd_log_flush_wait);
 
-	INIT_LIST_HEAD(&sdp->sd_revoke_list);
-
 	mutex_init(&sdp->sd_freeze_lock);
 
 	return sdp;
fs/gfs2/recovery.c +372 -145

691 lines not on this page · raw message

fs/gfs2/recovery.h +0 -13
index 1616ac2..fbc6300 100644
@@ -12,19 +12,6 @@
 
 #include "incore.h"
 
-static inline void gfs2_replay_incr_blk(struct gfs2_sbd *sdp, unsigned int *blk)
-{
-	if (++*blk == sdp->sd_jdesc->jd_blocks)
-	        *blk = 0;
-}
-
-extern int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
-			   struct buffer_head **bh);
-
-extern int gfs2_revoke_add(struct gfs2_sbd *sdp, u64 blkno, unsigned int where);
-extern int gfs2_revoke_check(struct gfs2_sbd *sdp, u64 blkno, unsigned int where);
-extern void gfs2_revoke_clean(struct gfs2_sbd *sdp);
-
 extern int gfs2_find_jhead(struct gfs2_jdesc *jd,
 		    struct gfs2_log_header_host *head);
 extern int gfs2_recover_journal(struct gfs2_jdesc *gfs2_jd);
fs/gfs2/util.h +0 -17
index 33e96b0..eca400d 100644
@@ -77,23 +77,6 @@ int gfs2_meta_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
 		       const char *type, const char *function,
 		       char *file, unsigned int line);
 
-static inline int gfs2_meta_check_i(struct gfs2_sbd *sdp,
-				    struct buffer_head *bh,
-				    const char *function,
-				    char *file, unsigned int line)
-{
-	struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data;
-	u32 magic = be32_to_cpu(mh->mh_magic);
-	if (unlikely(magic != GFS2_MAGIC))
-		return gfs2_meta_check_ii(sdp, bh, "magic number", function,
-					  file, line);
-	return 0;
-}
-
-#define gfs2_meta_check(sdp, bh) \
-gfs2_meta_check_i((sdp), (bh), __func__, __FILE__, __LINE__)
-
-
 int gfs2_metatype_check_ii(struct gfs2_sbd *sdp, struct buffer_head *bh,
 			   u16 type, u16 t,
 			   const char *function,