[Ocfs2-users] OCFS2 and Snapshots
Sunil Mushran
Sunil.Mushran at oracle.com
Fri Jul 21 16:51:25 CDT 2006
Cool.
Andre Brinkmann wrote:
> I hope this patch is in a better "diff -u -p"-format :-)
>
> Patch for the Makefile
> ===============
>
> --- tunefs.ocfs2/Makefile 2006-04-21 23:40:29.000000000 +0200
> +++ tunefs.ocfs2_new/Makefile 2006-07-21 14:29:48.000000000 +0200
> @@ -36,6 +36,6 @@ OBJS = $(subst .c,.o,$(CFILES))
> DIST_FILES = $(CFILES) tunefs.ocfs2.8.in
>
> tunefs.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS)
> - $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS)
> $(COM_ERR_LIBS)
> + $(LINK) $(LIBOCFS2_LIBS) $(UUID_LIBS) $(LIBO2DLM_LIBS)
> $(LIBO2CB_LIBS) $(COM_ERR_LIBS)
>
> include $(TOPDIR)/Postamble.make
>
>
> Patch for tunefs-c
> ============
>
> --- tunefs.ocfs2/tunefs.c 2006-04-21 23:40:29.000000000 +0200
> +++ tunefs.ocfs2_new/tunefs.c 2006-07-21 14:25:19.000000000 +0200
> @@ -44,6 +44,7 @@
> #include <inttypes.h>
> #include <ctype.h>
> #include <signal.h>
> +#include <uuid/uuid.h>
>
> #include <ocfs2.h>
> #include <ocfs2_fs.h>
> @@ -70,6 +71,7 @@ typedef struct _ocfs2_tune_opts {
> char *progname;
> char *device;
> int verbose;
> + int uuid;
> int quiet;
> int prompt;
> time_t tune_time;
> @@ -84,7 +86,7 @@ static void usage(const char *progname)
> {
> fprintf(stderr, "usage: %s [-N number-of-node-slots] "
> "[-L volume-label]\n"
> - "\t[-J journal-options] [-S volume-size] [-qvV] "
> + "\t[-J journal-options] [-S volume-size] [-qvuV] "
> "device\n",
> progname);
> exit(0);
> @@ -242,6 +244,7 @@ static void get_options(int argc, char *
> { "quiet", 0, 0, 'q' },
> { "version", 0, 0, 'V' },
> { "journal-options", 0, 0, 'J'},
> + { "uuid-reset", 0, 0, 'u'},
> { "volume-size", 0, 0, 'S'},
> { 0, 0, 0, 0}
> };
> @@ -254,7 +257,7 @@ static void get_options(int argc, char *
> opts.prompt = 1;
>
> while (1) {
> - c = getopt_long(argc, argv, "L:N:J:S:vqVx", long_options,
> + c = getopt_long(argc, argv, "L:N:J:S:vquVx", long_options,
> NULL);
>
> if (c == -1)
> @@ -303,6 +306,10 @@ static void get_options(int argc, char *
> opts.vol_size = val;
> break;
>
> + case 'u':
> + opts.uuid = 1;
> + break;
> +
> case 'v':
> opts.verbose = 1;
> break;
> @@ -471,6 +478,38 @@ static void update_volume_label(ocfs2_fi
> return ;
> }
>
> +
> +static void update_uuid (ocfs2_filesys *fs, int *changed)
> +{
> + unsigned char *uuid = OCFS2_RAW_SB(fs->fs_super)->s_uuid;
> + size_t i, max = sizeof(OCFS2_RAW_SB(fs->fs_super)->s_uuid);
> + uuid_t uuid_new;
> +
> + /* print out old uuid of device */
> + printf ("Try to change uuid: \n");
> + for(i = 0; i < max; i++)
> + printf("%02x ", uuid[i]);
> +
> + printf("\n");
> +
> + /* generate new uuid */
> + uuid_generate(uuid_new);
> +
> + memset (OCFS2_RAW_SB(fs->fs_super)->s_uuid, 0,
> OCFS2_VOL_UUID_LEN);
> + memcpy (OCFS2_RAW_SB(fs->fs_super)->s_uuid, uuid_new,
> OCFS2_VOL_UUID_LEN);
> +
> + /* print out new uuid */
> + printf ("New uuid: \n");
> + for(i = 0; i < max; i++)
> + printf("%02x ", uuid[i]);
> +
> + printf("\n");
> +
> + *changed = 1;
> +
> + return ;
> +}
> +
> static errcode_t update_slots(ocfs2_filesys *fs, int *changed)
> {
> errcode_t ret = 0;
> @@ -553,6 +592,7 @@ int main(int argc, char **argv)
> errcode_t ret = 0;
> ocfs2_filesys *fs = NULL;
> int upd_label = 0;
> + int upd_uuid = 0;
> int upd_slots = 0;
> int upd_jrnls = 0;
> int upd_vsize = 0;
> @@ -674,6 +714,10 @@ int main(int argc, char **argv)
> vol_size, opts.vol_size);
> }
>
> + /* update unique serial number of device has been selected */
> + if (opts.uuid)
> + printf (" Change unique serial number of device \n ");
> +
> /* Abort? */
> if (opts.prompt) {
> printf("Proceed (y/N): ");
> @@ -690,6 +734,13 @@ int main(int argc, char **argv)
> printf("Changed volume label\n");
> }
>
> + /* update the unique serial number */
> + if (opts.uuid) {
> + update_uuid (fs, &upd_uuid);
> + if (upd_uuid)
> + printf ("Changed volume uuid \n");
> + }
> +
> /* update number of slots */
> if (opts.num_slots) {
> ret = update_slots(fs, &upd_slots);
> @@ -726,7 +777,7 @@ int main(int argc, char **argv)
> }
>
> /* write superblock */
> - if (upd_label || upd_slots || upd_vsize) {
> + if (upd_label || upd_slots || upd_vsize || upd_uuid) {
> block_signals(SIG_BLOCK);
> ret = ocfs2_write_super(fs);
> if (ret) {
>
>
>
> Sunil Mushran wrote:
>> Please could you send it to me again in the "diff -u -p" format.
>>
>> Andre Brinkmann wrote:
>>> Sorry,
>>>
>>> here the patch as text:
>>>
>>> For the Makefile:
>>>
>>> 39c39
>>> < $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS)
>>> $(COM_ERR_LIBS)
>>> ---
>>> > $(LINK) $(LIBOCFS2_LIBS) $(UUID_LIBS) $(LIBO2DLM_LIBS)
>>> $(LIBO2CB_LIBS) $(COM_ERR_LIBS)
>>>
>>>
>>> For tunefs.ocfs2.c:
>>>
>>> 46a47
>>> > #include <uuid/uuid.h>
>>> 72a74
>>> > int uuid;
>>> 87c89
>>> < "\t[-J journal-options] [-S volume-size] [-qvV] "
>>> ---
>>> > "\t[-J journal-options] [-S volume-size] [-qvuV] "
>>> 244a247
>>> > { "uuid-reset", 0, 0, 'u'},
>>> 257c260
>>> < c = getopt_long(argc, argv, "L:N:J:S:vqVx", long_options,
>>> ---
>>> > c = getopt_long(argc, argv, "L:N:J:S:vquVx", long_options,
>>> 305a309,312
>>> > case 'u':
>>> > opts.uuid = 1;
>>> > break;
>>> >
>>> 473a481,512
>>> >
>>> > static void update_uuid (ocfs2_filesys *fs, int *changed)
>>> > {
>>> > unsigned char *uuid = OCFS2_RAW_SB(fs->fs_super)->s_uuid;
>>> > size_t i, max = sizeof(OCFS2_RAW_SB(fs->fs_super)->s_uuid);
>>> > uuid_t uuid_new;
>>> >
>>> > /* print out old uuid of device */
>>> > printf ("Try to change uuid: \n");
>>> > for(i = 0; i < max; i++)
>>> > printf("%02x ", uuid[i]);
>>> >
>>> > printf("\n");
>>> >
>>> > /* generate new uuid */
>>> > uuid_generate(uuid_new); >
>>> > memset (OCFS2_RAW_SB(fs->fs_super)->s_uuid, 0,
>>> OCFS2_VOL_UUID_LEN);
>>> > memcpy (OCFS2_RAW_SB(fs->fs_super)->s_uuid, uuid_new,
>>> OCFS2_VOL_UUID_LEN);
>>> > > /* print out new uuid */
>>> > printf ("New uuid: \n");
>>> > for(i = 0; i < max; i++)
>>> > printf("%02x ", uuid[i]);
>>> >
>>> > printf("\n");
>>> > > *changed = 1;
>>> >
>>> > return ;
>>> > }
>>> >
>>> 555a595
>>> > int upd_uuid = 0;
>>> 676a717,720
>>> > /* update unique serial number of device has been
>>> selected */
>>> > if (opts.uuid)
>>> > printf (" Change unique serial number of device
>>> \n ");
>>> >
>>> 692a737,743
>>> > /* update the unique serial number */
>>> > if (opts.uuid) {
>>> > update_uuid (fs, &upd_uuid);
>>> > if (upd_uuid)
>>> > printf ("Changed volume uuid \n");
>>> > }
>>> >
>>> 729c780
>>> < if (upd_label || upd_slots || upd_vsize) {
>>> ---
>>> > if (upd_label || upd_slots || upd_vsize || upd_uuid) {
>>>
>>>
>>> _______________________________________________
>>> Ocfs2-users mailing list
>>> Ocfs2-users at oss.oracle.com
>>> http://oss.oracle.com/mailman/listinfo/ocfs2-users
>>>
>
More information about the Ocfs2-users
mailing list