Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
List overview
Download
cluster-commits
April 2016
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
cluster-commits@lists.stg.fedorahosted.org
2 participants
9 discussions
Start a n
N
ew thread
dlm: dlm-4.0.5 tag has been created
by David Teigland
26 Apr '16
26 Apr '16
1
0
0
0
dlm: master - release 4.0.5
by David Teigland
26 Apr '16
26 Apr '16
Gitweb:
http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=8ab42921111467e79…
Commit: 8ab42921111467e798b04c848f4bc2551ef31c9c Parent: 4b5225db34bfb7452b5e7bb388846511ba0bf42f Author: David Teigland <teigland(a)redhat.com> AuthorDate: Tue Apr 26 15:09:41 2016 -0500 Committer: David Teigland <teigland(a)redhat.com> CommitterDate: Tue Apr 26 15:09:41 2016 -0500 release 4.0.5 Signed-off-by: David Teigland <teigland(a)redhat.com> --- include/version.cf | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/include/version.cf b/include/version.cf index f128f14..7ee106c 100644 --- a/include/version.cf +++ b/include/version.cf @@ -1,6 +1,6 @@ #ifndef _RELEASE_VERSION_CF_ #define _RELEASE_VERSION_CF_ -#define RELEASE_VERSION "4.0.4" +#define RELEASE_VERSION "4.0.5" #endif
1
0
0
0
dlm: master - dlm_controld: fix missing braces
by David Teigland
26 Apr '16
26 Apr '16
Gitweb:
http://git.fedorahosted.org/git/?p=dlm.git;a=commitdiff;h=4b5225db34bfb7452…
Commit: 4b5225db34bfb7452b5e7bb388846511ba0bf42f Parent: 78979b03eb3d6f16adfdd816d8d4d4ca70ac3cd8 Author: Valentin Vidic <Valentin.Vidic(a)CARNet.hr> AuthorDate: Tue Apr 26 15:06:43 2016 -0500 Committer: David Teigland <teigland(a)redhat.com> CommitterDate: Tue Apr 26 15:06:43 2016 -0500 dlm_controld: fix missing braces Fix missing braces in commit a51b2bbe4132 "If an error occurs unlink the lock file and exit with status 1" --- dlm_controld/main.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/dlm_controld/main.c b/dlm_controld/main.c index 4f1399f..13b3834 100644 --- a/dlm_controld/main.c +++ b/dlm_controld/main.c @@ -1028,9 +1028,10 @@ static int loop(void) for (;;) { rv = poll(pollfd, client_maxi + 1, poll_timeout); if (rv == -1 && errno == EINTR) { - if (daemon_quit && list_empty(&lockspaces)) + if (daemon_quit && list_empty(&lockspaces)) { rv = 0; goto out; + } if (daemon_quit) { log_error("shutdown ignored, active lockspaces"); daemon_quit = 0;
1
0
0
0
gfs2-utils: master - mkfs.gfs2: Open the target device with O_EXCL
by Andrew Price
05 Apr '16
05 Apr '16
Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=3d9879c4f7…
Commit: 3d9879c4f7e27cad55e30b054ce570e601cf431a Parent: 132c7cbafc706281f2aad97e205883123eb89550 Author: Andrew Price <anprice(a)redhat.com> AuthorDate: Tue Apr 5 14:38:03 2016 +0100 Committer: Andrew Price <anprice(a)redhat.com> CommitterDate: Tue Apr 5 14:45:04 2016 +0100 mkfs.gfs2: Open the target device with O_EXCL O_EXCL will let local mounters know that the device is busy while mkfs.gfs2 is running so that they don't try to access it. Before: # mount /dev/vdc /mnt/test mount: /dev/vdc: can't read superblock With O_EXCL: # mount /dev/vdc /mnt/test mount: /dev/vdc is already mounted or /mnt/test busy Signed-off-by: Andrew Price <anprice(a)redhat.com> --- gfs2/mkfs/main_mkfs.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c index 107d3cc..4436f93 100644 --- a/gfs2/mkfs/main_mkfs.c +++ b/gfs2/mkfs/main_mkfs.c @@ -854,7 +854,7 @@ static void open_dev(struct mkfs_dev *dev) { int error; - dev->fd = open(dev->path, O_RDWR | O_CLOEXEC); + dev->fd = open(dev->path, O_RDWR|O_CLOEXEC|O_EXCL); if (dev->fd < 0) { perror(dev->path); exit(1);
1
0
0
0
gfs2-utils: master - gfs2_edit: Don't hijack bh->b_data in read_master_dir
by Andrew Price
05 Apr '16
05 Apr '16
Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=132c7cbafc…
Commit: 132c7cbafc706281f2aad97e205883123eb89550 Parent: a2a19478ace9177513a56fba102c576726a0a13c Author: Andrew Price <anprice(a)redhat.com> AuthorDate: Tue Apr 5 14:09:38 2016 +0100 Committer: Andrew Price <anprice(a)redhat.com> CommitterDate: Tue Apr 5 14:45:04 2016 +0100 gfs2_edit: Don't hijack bh->b_data in read_master_dir read_master_dir() reads data that doesn't match the bh's metadata into bh->b_data, which confuses display() later when it checks whether re-reading the block is required. Use bread() in read_master_dir() instead to keep the bh consistent, and make sure read_superblock() doesn't leak the buffer earlier. Signed-off-by: Andrew Price <anprice(a)redhat.com> --- gfs2/edit/hexedit.c | 30 ++++++++++-------------------- 1 files changed, 10 insertions(+), 20 deletions(-) diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c index 1fea017..2ce111d 100644 --- a/gfs2/edit/hexedit.c +++ b/gfs2/edit/hexedit.c @@ -943,9 +943,6 @@ static int block_has_extended_info(void) return FALSE; } -/* ------------------------------------------------------------------------ */ -/* read_superblock - read the superblock */ -/* ------------------------------------------------------------------------ */ static void read_superblock(int fd) { sbd1 = (struct gfs_sb *)&sbd.sd_sb; @@ -1013,6 +1010,8 @@ static void read_superblock(int fd) gfs2_lookupi(sbd.master_dir, "rindex", 6, &sbd.md.riinode); } } + brelse(bh); + bh = NULL; } static int read_rindex(void) @@ -1032,26 +1031,17 @@ static int read_rindex(void) return 0; } -/* ------------------------------------------------------------------------ */ -/* read_master_dir - read the master directory */ -/* ------------------------------------------------------------------------ */ -static void read_master_dir(void) +static int read_master_dir(void) { ioctl(sbd.device_fd, BLKFLSBUF, 0); - lseek(sbd.device_fd, sbd.sd_sb.sb_master_dir.no_addr * sbd.bsize, - SEEK_SET); - if (read(sbd.device_fd, bh->b_data, sbd.bsize) != sbd.bsize) { - fprintf(stderr, "read error: %s from %s:%d: " - "master dir block %lld (0x%llx)\n", - strerror(errno), __FUNCTION__, - __LINE__, - (unsigned long long)sbd.sd_sb.sb_master_dir.no_addr, - (unsigned long long)sbd.sd_sb.sb_master_dir.no_addr); - exit(-1); - } + + bh = bread(&sbd, sbd.sd_sb.sb_master_dir.no_addr); + if (bh == NULL) + return 1; gfs2_dinode_in(&di, bh); /* parse disk inode into structure */ do_dinode_extended(&di, bh); /* get extended data, if any */ memcpy(&masterdir, &indirect[0], sizeof(struct indirect_info)); + return 0; } int display(int identify_only, int trunc_zeros, uint64_t flagref, @@ -2535,8 +2525,8 @@ int main(int argc, char *argv[]) max_block = lseek(fd, 0, SEEK_END) / sbd.bsize; if (sbd.gfs1) edit_row[GFS2_MODE]++; - else - read_master_dir(); + else if (read_master_dir() != 0) + exit(-1); process_parameters(argc, argv, 1); /* get what to print from cmdline */
1
0
0
0
gfs2-utils: master - mkfs.gfs2: Remove unnecessary externs from progress functions
by Andrew Price
01 Apr '16
01 Apr '16
Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=a2a19478ac…
Commit: a2a19478ace9177513a56fba102c576726a0a13c Parent: 97b1a767122320d752c3a3bfa6b037f8ce004dd5 Author: Andrew Price <anprice(a)redhat.com> AuthorDate: Tue Mar 29 14:07:54 2016 +0100 Committer: Andrew Price <anprice(a)redhat.com> CommitterDate: Fri Apr 1 18:33:42 2016 +0100 mkfs.gfs2: Remove unnecessary externs from progress functions Signed-off-by: Andrew Price <anprice(a)redhat.com> --- gfs2/mkfs/progress.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gfs2/mkfs/progress.c b/gfs2/mkfs/progress.c index 538ee71..d4c2768 100644 --- a/gfs2/mkfs/progress.c +++ b/gfs2/mkfs/progress.c @@ -62,7 +62,7 @@ void gfs2_progress_init(struct gfs2_progress_bar *progress, uint64_t max, const last_update = 0; } -extern void gfs2_progress_update(struct gfs2_progress_bar *progress, uint64_t value) +void gfs2_progress_update(struct gfs2_progress_bar *progress, uint64_t value) { time_t current_time; @@ -80,7 +80,7 @@ extern void gfs2_progress_update(struct gfs2_progress_bar *progress, uint64_t va fprintf(stdout, "%.*s", (2 * progress->max_digits) + 3, backspaces); } -extern void gfs2_progress_close(struct gfs2_progress_bar *progress, const char *message) +void gfs2_progress_close(struct gfs2_progress_bar *progress, const char *message) { if (progress->skip_progress) return;
1
0
0
0
gfs2-utils: master - gfs2-utils tests: Add fsck.gfs2 rgrp/rindex repair tests
by Andrew Price
01 Apr '16
01 Apr '16
Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=97b1a76712…
Commit: 97b1a767122320d752c3a3bfa6b037f8ce004dd5 Parent: 863e28ec19f92d772aae87d71ed0b202e2ce18c2 Author: Andrew Price <anprice(a)redhat.com> AuthorDate: Tue Mar 29 12:07:16 2016 +0100 Committer: Andrew Price <anprice(a)redhat.com> CommitterDate: Tue Mar 29 12:17:40 2016 +0100 gfs2-utils tests: Add fsck.gfs2 rgrp/rindex repair tests Add some tests which exercise fsck.gfs2's resource group and rindex repair code. Two of the tests currently fail (more work to do there) so they're left commented out. Adds a GFS_NUKERG_CHECK macro to make writing tests like these simpler. Signed-off-by: Andrew Price <anprice(a)redhat.com> --- tests/fsck.at | 20 ++++++++++++++++++++ tests/testsuite.at | 11 ++++++++++- 2 files changed, 30 insertions(+), 1 deletions(-) diff --git a/tests/fsck.at b/tests/fsck.at index 4d25f40..5e49985 100644 --- a/tests/fsck.at +++ b/tests/fsck.at @@ -14,3 +14,23 @@ AT_SETUP([Fix invalid goal blocks]) AT_KEYWORDS(fsck.gfs2 fsck) GFS_LANG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [set '/' { di_goal_meta: 0 }]) AT_CLEANUP + +AT_SETUP([Fix bad resource group #0]) +AT_KEYWORDS(fsck.gfs2 fsck) +GFS_NUKERG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [-r 0]) +AT_CLEANUP + +#AT_SETUP([Fix bad resource group #1]) +#AT_KEYWORDS(fsck.gfs2 fsck) +#GFS_NUKERG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [-r 1]) +#AT_CLEANUP + +#AT_SETUP([Fix bad rindex entry #0]) +#AT_KEYWORDS(fsck.gfs2 fsck) +#GFS_NUKERG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [-i 0]) +#AT_CLEANUP + +AT_SETUP([Fix bad rindex entry #1]) +AT_KEYWORDS(fsck.gfs2 fsck) +GFS_NUKERG_CHECK([mkfs.gfs2 -O -p lock_nolock $GFS_TGT], [-i 1]) +AT_CLEANUP diff --git a/tests/testsuite.at b/tests/testsuite.at index 0422b02..cc1bd54 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -12,7 +12,7 @@ AT_CHECK($1, 0, [ignore], [ignore]) AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore])]) # Regenerate, mkfs, modify fs with gfs2l, fsck -# Usage: GFS_TGT_REGEN ([<mkfs.gfs2 command>], [<gfs2l script>]) +# Usage: GFS_LANG_CHECK ([<mkfs.gfs2 command>], [<gfs2l script>]) m4_define([GFS_LANG_CHECK], [GFS_TGT_REGEN AT_CHECK($1, 0, [ignore], [ignore]) @@ -20,6 +20,15 @@ AT_CHECK([echo "$2" | gfs2l ${GFS_TGT}], 0, [ignore], [ignore]) AT_CHECK([fsck.gfs2 -y $GFS_TGT], 1, [ignore], [ignore]) AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore])]) +# Regenerate, mkfs, modify fs with nukerg, fsck +# Usage: GFS_NUKERG_CHECK ([<mkfs.gfs2 command>], [<gfs2l script>]) +m4_define([GFS_NUKERG_CHECK], +[GFS_TGT_REGEN +AT_CHECK($1, 0, [ignore], [ignore]) +AT_CHECK([nukerg $2 $GFS_TGT], 0, [ignore], [ignore]) +AT_CHECK([fsck.gfs2 -y $GFS_TGT], 1, [ignore], [ignore]) +AT_CHECK([fsck.gfs2 -n $GFS_TGT], 0, [ignore], [ignore])]) + # Set up a unit test, skipping if unit tests are disabled # Usage: GFS_UNIT_TEST ([name], [keywords]) m4_define([GFS_UNIT_TEST],
1
0
0
0
gfs2-utils: master - gfs2-utils tests: Add helper program to damage rgrps
by Andrew Price
01 Apr '16
01 Apr '16
Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=863e28ec19…
Commit: 863e28ec19f92d772aae87d71ed0b202e2ce18c2 Parent: ddaff5fecfb523cc6e0be0f36c4cd3fddeb5d807 Author: Andrew Price <anprice(a)redhat.com> AuthorDate: Sun Mar 27 23:41:39 2016 +0100 Committer: Andrew Price <anprice(a)redhat.com> CommitterDate: Tue Mar 29 12:16:53 2016 +0100 gfs2-utils tests: Add helper program to damage rgrps Add a small program named nukerg, based on Bob Peterson's program of the same name, which can be used to scribble over resource groups and rindex entries to test resource group repair in fsck.gfs2. Signed-off-by: Andrew Price <anprice(a)redhat.com> --- .gitignore | 1 + tests/Makefile.am | 13 ++ tests/nukerg.c | 348 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 362 insertions(+), 0 deletions(-) diff --git a/.gitignore b/.gitignore index bc8236e..b615b87 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ gfs2/tune/tunegfs2 test-driver tests/check_meta tests/check_rgrp +tests/nukerg tests/testvol tests/testsuite.log tests/testsuite.dir diff --git a/tests/Makefile.am b/tests/Makefile.am index 5a37319..1f98cb4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,6 +11,19 @@ DISTCLEANFILES = \ CLEANFILES = testvol +noinst_PROGRAMS = nukerg + +nukerg_SOURCES = nukerg.c +nukerg_CPPFLAGS = \ + -D_FILE_OFFSET_BITS=64 \ + -D_LARGEFILE64_SOURCE \ + -D_GNU_SOURCE +nukerg_CFLAGS = \ + -I$(top_srcdir)/gfs2/libgfs2 \ + -I$(top_srcdir)/gfs2/include +nukerg_LDADD = \ + $(top_builddir)/gfs2/libgfs2/libgfs2.la + if HAVE_CHECK UNIT_TESTS = \ check_meta \ diff --git a/tests/nukerg.c b/tests/nukerg.c new file mode 100644 index 0000000..f2018fb --- /dev/null +++ b/tests/nukerg.c @@ -0,0 +1,348 @@ +#include <unistd.h> +#include <stdio.h> +#include <stdint.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <string.h> +#include <stdlib.h> +#include <limits.h> + +#include <libgfs2.h> + +const char *prog_name = "nukerg"; + +static void usage(void) +{ + printf("%s zeroes a list of gfs2 resource groups or rindex entries.\n", prog_name); + printf("\n"); + printf("Usage:\n"); + printf(" %s -r <num_list>|-i <num_list> /dev/your/device\n", prog_name); + printf("\n"); + printf(" -r: Destroy resource groups\n"); + printf(" -i: Destroy resource group index (rindex) entries\n"); + printf("\n"); + printf("num_list: A comma- or space-separated list of resource group or rindex\n"); + printf(" numbers (0-indexed) to be destroyed. Use '*' for all.\n"); + printf("\n"); + printf("Both -r and -i can be specified. Resource groups will necessarily\n"); + printf("be destroyed before rindex entries.\n"); +} + +#define RGNUMS_SIZE (256) + +struct opts { + const char *device; + unsigned rgnums[RGNUMS_SIZE]; + size_t rgnum_count; + unsigned rinums[RGNUMS_SIZE]; + size_t rinum_count; + + unsigned got_help:1; + unsigned got_device:1; + unsigned got_rgnums:1; + unsigned got_rinums:1; +}; + +static int parse_uint(char *str, unsigned *uint) +{ + long long tmpll; + char *endptr; + + if (str == NULL || *str == '\0') + return 1; + + errno = 0; + tmpll = strtoll(str, &endptr, 10); + if (errno || tmpll < 0 || tmpll > UINT_MAX || *endptr != '\0') + return 1; + + *uint = (unsigned)tmpll; + return 0; +} + +#define ALL_RGS ((unsigned)-1) + +static size_t parse_uint_list(char *str, unsigned *list, char **tokp, size_t nleft) +{ + const char *delim = " ,"; + size_t i; + + for (i = 0, *tokp = strsep(&str, delim); *tokp != NULL; + i++, *tokp = strsep(&str, delim)) + { + int ret; + + if (i >= nleft) + return (size_t)-1; /* List would overflow */ + + /* Allow * to denote "all" */ + if (strcmp(*tokp, "*") == 0) { + list[0] = ALL_RGS; + return 1; + } + ret = parse_uint(*tokp, &list[i]); + if (ret != 0) + return 0; /* Invalid token, *tokp points to it */ + } + return i; /* Will be 0 if str is NULL or empty (*tokp is NULL in that case) */ +} + +static int parse_ri_list(char *str, struct opts *opts) +{ + unsigned *rinums = opts->rinums + opts->rinum_count; + size_t nleft = RGNUMS_SIZE - opts->rinum_count; + char *errtok = NULL; + size_t n; + + n = parse_uint_list(str, rinums, &errtok, nleft); + if (n == 0) { + if (errtok == NULL) + fprintf(stderr, "No rindex entries given\n"); + else + fprintf(stderr, "Invalid rindex entry: '%s'\n", errtok); + return 1; + } + else if (n == (size_t)-1) { + fprintf(stderr, "Too many rindex entries\n"); + return 1; + } + opts->rinum_count += n; + opts->got_rinums = 1; + return 0; +} + +static int parse_rg_list(char *str, struct opts *opts) +{ + unsigned *rgnums = opts->rgnums + opts->rgnum_count; + size_t nleft = RGNUMS_SIZE - opts->rgnum_count; + char *errtok = NULL; + size_t n; + + n = parse_uint_list(optarg, rgnums, &errtok, nleft); + if (n == 0) { + if (errtok == NULL) + fprintf(stderr, "No resource groups given\n"); + else + fprintf(stderr, "Invalid resource group number: '%s'\n", errtok); + return 1; + } else if (n == (size_t)-1) { + fprintf(stderr, "Too many resource group numbers\n"); + return 1; + } + opts->rgnum_count += n; + opts->got_rgnums = 1; + return 0; +} + +static int opts_get(int argc, char *argv[], struct opts *opts) +{ + int c; + + memset(opts, 0, sizeof(*opts)); + + while (1) { + c = getopt(argc, argv, "-hi:r:"); + if (c == -1) + break; + + switch (c) { + case 'h': + opts->got_help = 1; + usage(); + return 0; + case 'i': + if (parse_ri_list(optarg, opts)) + return 1; + break; + case 'r': + if (parse_rg_list(optarg, opts)) + return 1; + break; + case 1: + if (opts->got_device) { + fprintf(stderr, "More than one device specified. "); + fprintf(stderr, "Try -h for help.\n"); + return 1; + } + opts->device = optarg; + opts->got_device = 1; + break; + case '?': + default: + usage(); + return 1; + } + } + return 0; +} + +static int nuke_rgs(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, unsigned *rgnums, size_t count) +{ + struct gfs2_rgrp blankrg; + lgfs2_rgrp_t rg; + unsigned i; + + memset(&blankrg, 0, sizeof(blankrg)); + + for (rg = lgfs2_rgrp_first(rgs), i = 0; rg; rg = lgfs2_rgrp_next(rg), i++) { + const struct gfs2_rindex *ri = lgfs2_rgrp_index(rg); + unsigned j; + + for (j = 0; j < count; j++) { + uint64_t addr = ri->ri_addr; + off_t off = addr * sdp->bsize; + ssize_t bytes; + + if (i != rgnums[j] && rgnums[j] != ALL_RGS) + continue; + + printf("Nuking rg #%u at block 0x%"PRIx64"\n", i, addr); + + bytes = pwrite(sdp->device_fd, &blankrg, sizeof(blankrg), off); + if (bytes != sizeof(blankrg)) { + fprintf(stderr, "Write failed (%u bytes): %s", + (unsigned)bytes, strerror(errno)); + return 1; + } + } + } + return 0; +} + +static int nuke_ris(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, unsigned *rinums, size_t count) +{ + struct gfs2_rindex blankri; + lgfs2_rgrp_t rg; + unsigned i; + + memset(&blankri, 0, sizeof(blankri)); + + for (rg = lgfs2_rgrp_first(rgs), i = 0; rg; rg = lgfs2_rgrp_next(rg), i++) { + unsigned j; + + for (j = 0; j < count; j++) { + int bytes = 0; + uint64_t off; + + if (i != rinums[j] && rinums[j] != ALL_RGS) + continue; + + printf("Nuking rindex entry %u.\n", i); + + off = i * sizeof(struct gfs2_rindex); + bytes = gfs2_writei(sdp->md.riinode, &blankri, off, + sizeof(struct gfs2_rindex)); + if (bytes != sizeof(struct gfs2_rindex)) { + fprintf(stderr, "Write failed (%d bytes): %s", + bytes, strerror(errno)); + return 1; + } + } + } + return 0; +} + +static lgfs2_rgrps_t read_rindex(struct gfs2_sbd *sdp) +{ + lgfs2_rgrps_t rgs; + unsigned rgcount; + unsigned i; + + gfs2_lookupi(sdp->master_dir, "rindex", 6, &sdp->md.riinode); + if (sdp->md.riinode == NULL) { + perror("Failed to look up rindex"); + return NULL; + } + rgs = lgfs2_rgrps_init(sdp, 0, 0); + if (rgs == NULL) { + fprintf(stderr, "Failed to initialize resource group set: %s\n", + strerror(errno)); + return NULL; + } + rgcount = sdp->md.riinode->i_di.di_size / sizeof(struct gfs2_rindex); + for (i = 0; i < rgcount; i++) { + const struct gfs2_rindex *ri; + + ri = lgfs2_rindex_read_one(sdp->md.riinode, rgs, i); + if (ri == NULL) { + fprintf(stderr, "Failed to read rindex entry %u: %s\n", + i, strerror(errno)); + return NULL; + } + } + printf("%u rindex entries found.\n", i); + return rgs; +} + +static int fill_super_block(struct gfs2_sbd *sdp) +{ + sdp->sd_sb.sb_bsize = GFS2_BASIC_BLOCK; + sdp->bsize = sdp->sd_sb.sb_bsize; + + if (compute_constants(sdp) != 0) { + fprintf(stderr, "Failed to compute file system constants.\n"); + return 1; + } + if (read_sb(sdp) != 0) { + perror("Failed to read superblock\n"); + return 1; + } + sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr); + if (sdp->master_dir == NULL) { + fprintf(stderr, "Failed to read master directory inode.\n"); + return 1; + } + return 0; +} + +int main(int argc, char **argv) +{ + struct gfs2_sbd sbd; + lgfs2_rgrps_t rgs; + struct opts opts; + int ret; + + memset(&sbd, 0, sizeof(sbd)); + + ret = opts_get(argc, argv, &opts); + if (ret != 0 || opts.got_help) + exit(ret); + + if (!opts.got_device) { + fprintf(stderr, "No device specified.\n"); + usage(); + exit(1); + } + if (!opts.got_rgnums && !opts.got_rinums) { + fprintf(stderr, "No resource groups or rindex entries specified.\n"); + usage(); + exit(1); + } + if ((sbd.device_fd = open(opts.device, O_RDWR)) < 0) { + perror(opts.device); + exit(1); + } + if (fill_super_block(&sbd) != 0) + exit(1); + + rgs = read_rindex(&sbd); + if (rgs == NULL) + exit(1); + + if (opts.got_rgnums && nuke_rgs(&sbd, rgs, opts.rgnums, opts.rgnum_count) != 0) + exit(1); + + if (opts.got_rinums && nuke_ris(&sbd, rgs, opts.rinums, opts.rinum_count) != 0) + exit(1); + + inode_put(&sbd.md.riinode); + inode_put(&sbd.master_dir); + lgfs2_rgrps_free(&rgs); + fsync(sbd.device_fd); + close(sbd.device_fd); + exit(0); +} + +/* This function is for libgfs2's sake. */ +void print_it(const char *label, const char *fmt, const char *fmt2, ...) {}
1
0
0
0
gfs2-utils: master - libgfs2: New function lgfs2_rindex_read_one()
by Andrew Price
01 Apr '16
01 Apr '16
Gitweb:
http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=ddaff5fecf…
Commit: ddaff5fecfb523cc6e0be0f36c4cd3fddeb5d807 Parent: 72553fb7cdfa7d69e0d7473cfd388078d7dedae5 Author: Andrew Price <anprice(a)redhat.com> AuthorDate: Sun Mar 27 03:33:38 2016 +0100 Committer: Andrew Price <anprice(a)redhat.com> CommitterDate: Tue Mar 29 12:14:29 2016 +0100 libgfs2: New function lgfs2_rindex_read_one() Add a simple function to read an rindex entry into a set of resource groups. Signed-off-by: Andrew Price <anprice(a)redhat.com> --- gfs2/libgfs2/libgfs2.h | 2 ++ gfs2/libgfs2/rgrp.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 0 deletions(-) diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index 7c87884..d6c54b3 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -177,6 +177,7 @@ struct gfs2_bitmap }; struct gfs2_sbd; +struct gfs2_inode; typedef struct _lgfs2_rgrps *lgfs2_rgrps_t; struct rgrp_tree { @@ -196,6 +197,7 @@ extern lgfs2_rgrps_t lgfs2_rgrps_init(struct gfs2_sbd *sdp, uint64_t align, uint extern void lgfs2_rgrps_free(lgfs2_rgrps_t *rgs); extern uint64_t lgfs2_rindex_entry_new(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry, uint64_t addr, uint32_t len); extern unsigned lgfs2_rindex_read_fd(int fd, lgfs2_rgrps_t rgs); +extern const struct gfs2_rindex *lgfs2_rindex_read_one(struct gfs2_inode *rip, lgfs2_rgrps_t rgs, unsigned i); extern uint64_t lgfs2_rgrp_align_addr(const lgfs2_rgrps_t rgs, uint64_t addr); extern uint32_t lgfs2_rgrp_align_len(const lgfs2_rgrps_t rgs, uint32_t len); extern unsigned lgfs2_rgsize_for_data(uint64_t blksreq, unsigned bsize); diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c index 766bdfc..7066a5c 100644 --- a/gfs2/libgfs2/rgrp.c +++ b/gfs2/libgfs2/rgrp.c @@ -430,6 +430,38 @@ unsigned lgfs2_rindex_read_fd(int fd, lgfs2_rgrps_t rgs) } /** + * Read a rindex entry into a set of resource groups + * rip: The inode of the rindex file + * rgs: The set of resource groups. + * i: The index of the entry to read from the rindex file + * Returns the new rindex entry added to the set or NULL on error with errno + * set. + */ +const struct gfs2_rindex *lgfs2_rindex_read_one(struct gfs2_inode *rip, lgfs2_rgrps_t rgs, unsigned i) +{ + uint64_t off = i * sizeof(struct gfs2_rindex); + char buf[sizeof(struct gfs2_rindex)]; + struct gfs2_rindex ri; + lgfs2_rgrp_t rg; + int ret; + + errno = EINVAL; + if (rip == NULL || rgs == NULL) + return NULL; + + ret = gfs2_readi(rip, buf, off, sizeof(struct gfs2_rindex)); + if (ret != sizeof(struct gfs2_rindex)) + return NULL; + + gfs2_rindex_in(&ri, buf); + rg = lgfs2_rgrps_append(rgs, &ri); + if (rg == NULL) + return NULL; + + return &rg->ri; +} + +/** * Free a set of resource groups created with lgfs2_rgrps_append() etc. This * does not write any dirty buffers to disk. See lgfs2_rgrp_write(). * rgs: A pointer to the set of resource groups to be freed.
1
0
0
0
Results per page:
10
25
50
100
200