Skip to contentSkip to conversation

New gfs2_grow command

PATCH New Robert Peterson 2 participants 4 messages May 1, 2007 – May 2, 2007 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 New gfs2_grow command

Hi All,

Attached below is the long-awaited patch to add a gfs2_grow command to extend gfs2 file systems. Please review and send me your comments. This is for bugzilla:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=234844
(which now contains the patch as an attachment.) It applies to the HEAD branch of CVS.

Note that a bunch of common code was moved from gfs2_jadd to libgfs2's misc.c as part of this patch.

Regards,

Bob Peterson
Red Hat Cluster Suite

--

--
Index: libgfs2/libgfs2.h
===================================================================
RCS file: /cvs/cluster/cluster/gfs2/libgfs2/libgfs2.h,v retrieving revision 1.11

libgfs2.h +10 -2
diff -w -u -p -p -u -r1.11 libgfs2.h
@@ -165,7 +165,7 @@ struct gfs2_sbd {
 	int expert;
 	int override;
 
-	char *device_name;
+	char device_name[PATH_MAX];
 	char *path_name;
 
 	/* Constants */
@@ -219,6 +219,9 @@ struct gfs2_sbd {
 
 	unsigned int spills;
 	unsigned int writes;
+	int metafs_fd;
+	int metafs_mounted; /* If metafs was already mounted */
+	char metafs_path[PATH_MAX]; /* where metafs is mounted */
 };
 
 extern char *prog_name;
@@ -343,7 +346,6 @@ void write_buffer(struct gfs2_sbd *sdp, 
 /* device_geometry.c */
 void device_geometry(struct gfs2_sbd *sdp);
 void fix_device_geometry(struct gfs2_sbd *sdp);
-void munge_device_geometry_for_grow(struct gfs2_sbd *sdp);
 
 /* fs_bits.c */
 #define BFITNOENT (0xFFFFFFFF)
@@ -497,6 +499,12 @@ int query(struct gfs2_options *opts, con
 
 /* misc.c */
 void compute_constants(struct gfs2_sbd *sdp);
+int find_gfs2_meta(struct gfs2_sbd *sdp);
+int dir_exists(const char *dir);
+void check_for_gfs2(struct gfs2_sbd *sdp);
+void mount_gfs2_meta(struct gfs2_sbd *sdp);
+void lock_for_admin(struct gfs2_sbd *sdp);
+void cleanup_metafs(struct gfs2_sbd *sdp);
 
 /* rgrp.c */
 int gfs2_compute_bitstructs(struct gfs2_sbd *sdp, struct rgrp_list *rgd);

Index: libgfs2/misc.c
===================================================================
RCS file: /cvs/cluster/cluster/gfs2/libgfs2/misc.c,v retrieving revision 1.2

misc.c +171 -2

189 lines not on this page · raw message

Index: mkfs/Makefile
===================================================================
RCS file: /cvs/cluster/cluster/gfs2/mkfs/Makefile,v retrieving revision 1.14

Makefile +9 -3
diff -w -u -p -p -u -r1.14 Makefile
@@ -7,9 +7,11 @@ include ../../make/defines.mk
 
 TARGET1= mkfs.gfs2
 TARGET2= gfs2_jadd
+TARGET3= gfs2_grow
 
 OBJS=	main.o \
 	main_mkfs.o \
+	main_grow.o \
 	main_jadd.o
 
 CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
@@ -21,7 +23,7 @@ CFLAGS += -I../include/ -I../libgfs2/
 LDFLAGS += -L${volidlibdir} -lvolume_id
 LDFLAGS += -L../libgfs2 -lgfs2
 
-all: ${TARGET1} ${TARGET2}
+all: ${TARGET1} ${TARGET2} ${TARGET3}
 
 ${TARGET1}: ${OBJS}
 	$(CC) -o $@ $^ $(LDFLAGS)
@@ -29,16 +31,20 @@ ${TARGET1}: ${OBJS}
 ${TARGET2}: ${TARGET1}
 	ln -s ${TARGET1} ${TARGET2}
 
+${TARGET3}: ${TARGET1}
+	ln -s ${TARGET1} ${TARGET3}
+
 %.o: %.c
 	$(CC) $(CFLAGS) -c -o $@ $^
 
 install: all
 	install -m 0755 ${TARGET1} ${sbindir}
 	ln -f ${sbindir}/${TARGET1} ${sbindir}/${TARGET2}
+	ln -f ${sbindir}/${TARGET1} ${sbindir}/${TARGET3}
 
 uninstall:
-	${UNINSTALL} ${TARGET1} ${TARGET2} ${sbindir}
+	${UNINSTALL} ${TARGET1} ${TARGET2} ${TARGET3} ${sbindir}
 
 clean:
-	rm -f *.o ${TARGET1} ${TARGET2}
+	rm -f *.o ${TARGET1} ${TARGET2} ${TARGET3}
 

Index: mkfs/main_grow.c
===================================================================
RCS file: mkfs/main_grow.c

main_grow.c new file +334 -0

334 lines not on this page · raw message

Index: mkfs/main_jadd.c
===================================================================
RCS file: /cvs/cluster/cluster/gfs2/mkfs/main_jadd.c,v retrieving revision 1.10

main_jadd.c +20 -180

262 lines not on this page · raw message

Index: mkfs/main_mkfs.c
===================================================================
RCS file: /cvs/cluster/cluster/gfs2/mkfs/main_mkfs.c,v retrieving revision 1.12

main_mkfs.c +7 -9
diff -w -u -p -p -u -r1.12 main_mkfs.c
@@ -86,7 +86,7 @@ decode_arguments(int argc, char *argv[],
 	int cont = TRUE;
 	int optchar;
 
-	sdp->device_name = NULL;
+	memset(sdp->device_name, 0, sizeof(sdp->device_name));
 	sdp->md.journals = 1;
 	strcpy(sdp->lockproto, "lock_nolock");
 
@@ -169,10 +169,10 @@ decode_arguments(int argc, char *argv[],
 		case 1:
 			if (strcmp(optarg, "gfs2") == 0)
 				continue;
-			if (sdp->device_name) {
+			if (sdp->device_name[0]) {
 				die("More than one device specified (try -h for help)");
 			} 
-			sdp->device_name = optarg;
+			strcpy(sdp->device_name, optarg);
 			break;
 
 		default:
@@ -181,11 +181,10 @@ decode_arguments(int argc, char *argv[],
 		};
 	}
 
-	if ((sdp->device_name == NULL) && (optind < argc)) {
-		sdp->device_name = argv[optind++];
-	}
+	if ((sdp->device_name[0] == 0) && (optind < argc))
+		strcpy(sdp->device_name, argv[optind++]);
 
-	if (sdp->device_name == NULL)
+	if (sdp->device_name[0] == '\0')
 		die("no device specified (try -h for help)\n");
 
 	if (optind < argc)
@@ -264,8 +263,7 @@ static void are_you_sure(struct gfs2_sbd
 		die("error identifying the contents of %s: %s\n",
 		    sdp->device_name, strerror(errno));
 
-	printf("This will destroy any data on %s.\n",
-	       sdp->device_name);
+	printf("This will destroy any data on %s.\n", sdp->device_name);
 	if (volume_id_probe_all(vid, 0, sdp->device_size) == 0)
 		printf("  It appears to contain a %s %s.\n", vid->type,
 			   vid->usage_id == VOLUME_ID_OTHER? "partition" : vid->usage);

Index: quota/check.c
===================================================================
RCS file: /cvs/cluster/cluster/gfs2/quota/check.c,v retrieving revision 1.3

check.c +31 -29

142 lines not on this page · raw message

Index: quota/gfs2_quota.h
===================================================================
RCS file: /cvs/cluster/cluster/gfs2/quota/gfs2_quota.h,v retrieving revision 1.2

gfs2_quota.h +4 -6
diff -w -u -p -p -u -r1.2 gfs2_quota.h
@@ -2,7 +2,7 @@
 *******************************************************************************
 **
 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
-**  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -98,19 +98,17 @@ extern char *prog_name;
 
 /*  main.c  */
 
-void check_for_gfs2(const char *path);
 void do_get_super(int fd, struct gfs2_sb *sb);
-void do_sync(commandline_t *comline);
+void do_sync(struct gfs2_sbd *sdp, commandline_t *comline);
 void lock_for_admin();
-int find_gfs2_meta(const char *mnt);
 void mount_gfs2_meta();
 void cleanup();
 void read_superblock(struct gfs2_sb *sb);
 
 /*  check.c  */
 
-void do_check(commandline_t *comline);
-void do_quota_init(commandline_t *comline);
+void do_check(struct gfs2_sbd *sdp, commandline_t *comline);
+void do_quota_init(struct gfs2_sbd *sdp, commandline_t *comline);
 
 /*  names.c  */
 

Index: quota/main.c
===================================================================
RCS file: /cvs/cluster/cluster/gfs2/quota/main.c,v retrieving revision 1.3

main.c +52 -195

431 lines not on this page · raw message

Index: tool/gfs2_tool.h
===================================================================
RCS file: /cvs/cluster/cluster/gfs2/tool/gfs2_tool.h,v retrieving revision 1.5

gfs2_tool.h +2 -1
diff -w -u -p -p -u -r1.5 gfs2_tool.h
@@ -2,7 +2,7 @@
 *******************************************************************************
 **
 **  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
-**  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -95,6 +95,7 @@ void set_tune(int argc, char **argv);
 void check_for_gfs2(int fd, char *path);
 char *get_list(void);
 char **str2lines(char *str);
+const char *find_debugfs_mount(void);
 char *mp2fsname(char *mp);
 char *name2value(char *str, char *name);
 uint32_t name2u32(char *str, char *name);
#1 lore raw

PATCH 1/1 New gfs2_grow command

Quoted 9 lines · Robert Peterson

Hi All,

Attached below is the long-awaited patch to add a gfs2_grow command to extend gfs2 file systems. Please review and send me your comments. This is for bugzilla:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=234844
(which now contains the patch as an attachment.) It applies to the HEAD branch of CVS.

Quoted 8 lines

Note that a bunch of common code was moved from gfs2_jadd to libgfs2's misc.c as part of this patch.

Regards,

Bob Peterson
Red Hat Cluster Suite

Hi Robert,

2 quick things.. does this patch depends on the kernel patch you submitted here?

https://www.redhat.com/archives/cluster-devel/2007-April/msg00069.html

and i think the patch is missing a change in mkfs/main.c to recognize the identity for gfs2_grow but this bit might have been left off on purpose :)

Thanks
Fabio

Signature · 1 line
I'm going to make him an offer he can't refuse.
#2 lore raw

PATCH 1/1 New gfs2_grow command

Quoted 11 lines · Fabio Massimo Di Nitto

Hi Robert,

2 quick things.. does this patch depends on the kernel patch you submitted here?

https://www.redhat.com/archives/cluster-devel/2007-April/msg00069.html

and i think the patch is missing a change in mkfs/main.c to recognize the identity for gfs2_grow but this bit might have been left off on purpose :)

Thanks
Fabio

Hi Fabio,

1. Yes, bz 234844 is already marked as dependent on bz 235430.
2. Good catch. This was mistakenly dropped from the patch (but obviously included in the version I tested.)

Regards,

Bob Peterson
Red Hat Cluster Suite

#3 lore raw

PATCH 1/1 New gfs2_grow command

Quoted 10 lines · Robert Peterson
Quoted 9 lines · Fabio Massimo Di Nitto

Hi Robert,

2 quick things.. does this patch depends on the kernel patch you submitted here?

https://www.redhat.com/archives/cluster-devel/2007-April/msg00069.html

and i think the patch is missing a change in mkfs/main.c to recognize the identity for gfs2_grow but this bit might have been left off on purpose :)

Quoted 6 lines
Quoted 2 lines

Thanks
Fabio

Hi Fabio,

1. Yes, bz 234844 is already marked as dependent on bz 235430.

Ok thanks, i will test once the patch is in -nmw tree.

Quoted 2 lines

2. Good catch. This was mistakenly dropped from the patch (but obviously included in the version I tested.)

No problem, my first though was more "malicious" as in "let see if these guys are really testing the patch" ;) or "let's avoid users to have something that will eat their data if they don't know what they are looking at" :)

Fabio

Signature · 1 line
I'm going to make him an offer he can't refuse.