public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* cluster: STABLE2 - GFS2: gfs2_edit savemeta not saving per_node quota files
@ 2009-03-31 15:49 Bob Peterson
  0 siblings, 0 replies; only message in thread
From: Bob Peterson @ 2009-03-31 15:49 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=05985c63592e45d3df24186e59768a5eccf485d6
Commit:        05985c63592e45d3df24186e59768a5eccf485d6
Parent:        61a99bda889ccf696495b4095e93b04bfdee88e2
Author:        Bob Peterson <rpeterso@redhat.com>
AuthorDate:    Tue Mar 31 10:26:17 2009 -0500
Committer:     Bob Peterson <rpeterso@redhat.com>
CommitterDate: Tue Mar 31 10:26:17 2009 -0500

GFS2: gfs2_edit savemeta not saving per_node quota files

bz 483799

The per-node quota files were not being saved by gfs2_edit
savemeta.  If you restore the file system with restoremeta,
using a different device (as we do here to analyze file
system corruption) the resulting file system is not
mountable.  It will often cause a kernel panic due to
left-over trash in those files.
---
 gfs2/edit/hexedit.c  |   39 ++++++++++++++++++++++++++++++++++++++-
 gfs2/edit/hexedit.h  |    2 ++
 gfs2/edit/savemeta.c |   24 ++++++++++++------------
 3 files changed, 52 insertions(+), 13 deletions(-)

diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 0fba438..8d3a21a 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1588,6 +1588,41 @@ int block_is_quota_file(void)
 }
 
 /* ------------------------------------------------------------------------ */
+/* block_is_per_node                                                        */
+/* ------------------------------------------------------------------------ */
+int block_is_per_node(void)
+{
+	if (!gfs1 && block == masterblock("per_node"))
+		return TRUE;
+	return FALSE;
+}
+
+/* ------------------------------------------------------------------------ */
+/* block_is_in_per_node                                                     */
+/* ------------------------------------------------------------------------ */
+int block_is_in_per_node(void)
+{
+	int d;
+	struct gfs2_dinode per_node_di;
+	struct gfs2_buffer_head *per_node_bh;
+
+	if (gfs1)
+		return FALSE;
+
+	per_node_bh = bread(&sbd.buf_list, masterblock("per_node"));
+	gfs2_dinode_in(&per_node_di, per_node_bh->b_data);
+
+	do_dinode_extended(&per_node_di, per_node_bh->b_data);
+	brelse(per_node_bh, not_updated);
+
+	for (d = 0; d < indirect->ii[0].dirents; d++) {
+		if (block == indirect->ii[0].dirent[d].block)
+			return TRUE;
+	}
+	return FALSE;
+}
+
+/* ------------------------------------------------------------------------ */
 /* block_has_extended_info                                                  */
 /* ------------------------------------------------------------------------ */
 int block_has_extended_info(void)
@@ -2658,6 +2693,7 @@ void interactive_mode(void)
 		/* arrow up */
 		/* --------------------------------------------------------- */
 		case KEY_UP:
+		case '-':
 			if (dmode == EXTENDED_MODE) {
 				if (edit_row[dmode] > 0)
 					edit_row[dmode]--;
@@ -2673,6 +2709,7 @@ void interactive_mode(void)
 		/* arrow down */
 		/* --------------------------------------------------------- */
 		case KEY_DOWN:
+		case '+':
 			if (dmode == EXTENDED_MODE) {
 				if (edit_row[dmode] + 1 < end_row[dmode]) {
 					if (edit_row[dmode] >= last_entry_onscreen[dmode])
@@ -2809,7 +2846,7 @@ void interactive_mode(void)
 			move(termlines - 1, 0);
 			printw("Keystroke not understood: 0x%03X",ch);
 			refresh();
-			sleep(1);
+			usleep(50000);
 			break;
 		} /* switch */
 	} /* while !Quit */
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 8206d97..4961062 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -164,6 +164,8 @@ EXTERN int block_is_rindex(void);
 EXTERN int block_is_inum_file(void);
 EXTERN int block_is_statfs_file(void);
 EXTERN int block_is_quota_file(void);
+EXTERN int block_is_per_node(void);
+EXTERN int block_is_in_per_node(void);
 EXTERN int display_block_type(const char *lpBuffer, int from_restore);
 EXTERN void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
 EXTERN void gfs_log_header_in(struct gfs_log_header *head, char *buf);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 4c81255..779d715 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -168,12 +168,10 @@ int block_is_a_journal(void)
 
 int block_is_systemfile(void)
 {
-	return block_is_jindex() ||
-		block_is_inum_file() ||
-		block_is_statfs_file() ||
-		block_is_quota_file() ||
-		block_is_rindex() ||
-		block_is_a_journal();
+	return block_is_jindex() || block_is_inum_file() ||
+		block_is_statfs_file() || block_is_quota_file() ||
+		block_is_rindex() || block_is_a_journal() ||
+		block_is_per_node() || block_is_in_per_node();
 }
 
 int save_block(int fd, int out_fd, uint64_t blk)
@@ -646,9 +644,10 @@ int restore_data(int fd, int in_fd, int printblocksonly)
 		}
 		rs = read(in_fd, &buf16, sizeof(uint16_t));
 		savedata->siglen = be16_to_cpu(buf16);
-		if (savedata->siglen > 0 &&
-		    savedata->siglen <= sizeof(savedata->buf)) {
-			do_read(in_fd, savedata->buf, savedata->siglen);
+		if (savedata->siglen <= sizeof(savedata->buf)) {
+			if (savedata->siglen)
+				do_read(in_fd, savedata->buf,
+					savedata->siglen);
 			if (first) {
 				gfs2_sb_in(&sbd.sd_sb, savedata->buf);
 				sbd1 = (struct gfs_sb *)&sbd.sd_sb;
@@ -684,7 +683,7 @@ int restore_data(int fd, int in_fd, int printblocksonly)
 			} else {
 				warm_fuzzy_stuff(savedata->blk, FALSE, FALSE);
 				if (savedata->blk >= last_fs_block) {
-					printf("Out of space on the destination "
+					printf("\nOut of space on the destination "
 					       "device; quitting.\n");
 					break;
 				}
@@ -694,8 +693,9 @@ int restore_data(int fd, int in_fd, int printblocksonly)
 			}
 			blks_saved++;
 		} else {
-			fprintf(stderr, "Bad record length: %d for block #%"
-				PRIu64".\n", savedata->siglen, savedata->blk);
+			fprintf(stderr, "\nBad record length: %d for block #%"
+				PRIu64 " (0x%" PRIx64").\n", savedata->siglen,
+				savedata->blk, savedata->blk);
 			return -1;
 		}
 	}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-31 15:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-31 15:49 cluster: STABLE2 - GFS2: gfs2_edit savemeta not saving per_node quota files Bob Peterson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).