gfs2-utils: master - libgfs2: Support the new dirent de_cookie field
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=da2bced4...
Commit: da2bced4ff2a8fa9c95fde8071f2f164c0c1466a
Parent: 86f318445da6e2ef0c38db105ece990a13b93ea2
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Feb 15 12:42:51 2016 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Mon Feb 15 12:53:35 2016 +0000
libgfs2: Support the new dirent de_cookie field
Detect whether the new de_cookie field (kernel commit 471f3db27) is
present in struct gfs2_dirent in the configure script and update the
metadata description to support that field.
It also seems that meta.c was not using the GFS2_HAS_* defines from
clusterautoconfig.h and that was causing a unit test to fail with
gfs2_dirent: __pad: offset is 28, expected 26
gfs2_dirent: size mismatch between struct 40 and fields 38
This commit adds an #include to fix that.
Fixes Rawhide bz#1307532
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
configure.ac | 2 ++
gfs2/libgfs2/meta.c | 10 ++++++++--
gfs2/libgfs2/ondisk.c | 21 ++++++++++++++++++---
3 files changed, 28 insertions(+), 5 deletions(-)
diff --git a/configure.ac b/configure.ac
index 130cb01..f6174ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -127,6 +127,8 @@ AC_CHECK_MEMBER([struct gfs2_leaf.lf_inode],[AC_DEFINE([GFS2_HAS_LEAF_HINTS],[],
[], [[#include <linux/gfs2_ondisk.h>]])
AC_CHECK_MEMBER([struct gfs2_dirent.de_rahead],[AC_DEFINE([GFS2_HAS_DE_RAHEAD],[],[Dirent readahead field])],
[], [[#include <linux/gfs2_ondisk.h>]])
+AC_CHECK_MEMBER([struct gfs2_dirent.de_cookie],[AC_DEFINE([GFS2_HAS_DE_COOKIE],[],[Dirent cookie field])],
+ [], [[#include <linux/gfs2_ondisk.h>]])
# *FLAGS handling
ENV_CFLAGS="$CFLAGS"
diff --git a/gfs2/libgfs2/meta.c b/gfs2/libgfs2/meta.c
index 4f43af5..90d5647 100644
--- a/gfs2/libgfs2/meta.c
+++ b/gfs2/libgfs2/meta.c
@@ -1,6 +1,7 @@
#include <stdint.h>
#include <string.h>
#include "libgfs2.h"
+#include "clusterautoconfig.h"
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
#define SYM(x) { x, #x },
@@ -430,10 +431,15 @@ F(de_name_len, .flags = LGFS2_MFF_BYTES)
F(de_type)
#ifdef GFS2_HAS_DE_RAHEAD
F(de_rahead)
-RF(__pad2)
+#ifdef GFS2_HAS_DE_COOKIE
+F(de_cookie)
+RF(pad3)
+#else
+RF(pad2)
+#endif /* GFS2_HAS_DE_COOKIE */
#else
RF(__pad)
-#endif
+#endif /* GFS2_HAS_DE_RAHEAD */
};
#undef STRUCT
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index b9418c5..ea1f61f 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -417,7 +417,15 @@ void gfs2_dirent_in(struct gfs2_dirent *de, char *buf)
CPIN_16(de, str, de_type);
#ifdef GFS2_HAS_DE_RAHEAD
CPIN_16(de, str, de_rahead);
-#endif
+#ifdef GFS2_HAS_DE_COOKIE
+ CPIN_32(de, str, de_cookie);
+ CPIN_08(de, str, pad3, 8);
+#else
+ CPIN_08(de, str, pad2, 12);
+#endif /* GFS2_HAS_DE_COOKIE */
+#else
+ CPIN_08(de, str, __pad, 14);
+#endif /* GFS2_HAS_DE_RAHEAD */
}
void gfs2_dirent_out(struct gfs2_dirent *de, char *buf)
@@ -429,10 +437,17 @@ void gfs2_dirent_out(struct gfs2_dirent *de, char *buf)
CPOUT_16(de, str, de_rec_len);
CPOUT_16(de, str, de_name_len);
CPOUT_16(de, str, de_type);
- memset(str->__pad, 0, sizeof(str->__pad));
#ifdef GFS2_HAS_DE_RAHEAD
CPOUT_16(de, str, de_rahead);
-#endif
+#ifdef GFS2_HAS_DE_COOKIE
+ CPOUT_32(de, str, de_cookie);
+ CPOUT_08(de, str, pad3, 8);
+#else
+ CPOUT_08(de, str, pad2, 12);
+#endif /* GFS2_HAS_DE_COOKIE */
+#else
+ CPOUT_08(de, str, __pad, 14);
+#endif /* GFS2_HAS_DE_RAHEAD */
}
void gfs2_leaf_in(struct gfs2_leaf *lf, struct gfs2_buffer_head *bh)
8 years, 1 month
gfs2-utils: master - gfs2_edit: Remove block_in_mem and fix a memory
leak
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=86f31844...
Commit: 86f318445da6e2ef0c38db105ece990a13b93ea2
Parent: 5375e2b9b5032ae3c08fefc10f067762ca2db19b
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Feb 4 10:51:03 2016 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Feb 4 10:54:11 2016 +0000
gfs2_edit: Remove block_in_mem and fix a memory leak
block_in_mem is meant to be the block number that relates to the global
bh. bh->b_blocknr can be used for the same purpose so remove
block_in_mem. Also fix a memory leak that occurs when the displayed
block changes.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/gfs2hex.c | 1 -
gfs2/edit/hexedit.c | 8 ++++----
gfs2/edit/hexedit.h | 1 -
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 1f55a43..3d280b5 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -42,7 +42,6 @@ uint64_t block = 0;
int blockhist = 0;
struct iinfo *indirect;
int indirect_blocks;
-uint64_t block_in_mem = -1;
struct gfs2_sbd sbd;
uint64_t starting_blk;
struct blkstack_info blockstack[BLOCK_STACK_SIZE];
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index a89ae36..5adf7c5 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1072,7 +1072,9 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
display_title_lines();
move(2,0);
}
- if (block_in_mem != blk) { /* If we changed blocks from the last read */
+ if (bh == NULL || bh->b_blocknr != blk) { /* If we changed blocks from the last read */
+ if (bh != NULL)
+ brelse(bh);
dev_offset = blk * sbd.bsize;
ioctl(sbd.device_fd, BLKFLSBUF, 0);
if (!(bh = bread(&sbd, blk))) {
@@ -1083,7 +1085,6 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
(unsigned long long)dev_offset);
exit(-1);
}
- block_in_mem = blk; /* remember which block is in memory */
}
line = 1;
gfs2_struct_type = display_block_type(bh, FALSE);
@@ -1869,7 +1870,6 @@ static void interactive_mode(void)
bobgets(estring, edit_row[dmode]+4, 24,
10, &ch);
process_field(efield, estring);
- block_in_mem = -1;
} else
bobgets(estring, edit_row[dmode]+6, 14,
edit_size[dmode], &ch);
@@ -2534,7 +2534,7 @@ int main(int argc, char *argv[])
edit_row[GFS2_MODE]++;
else
read_master_dir();
- block_in_mem = -1;
+
process_parameters(argc, argv, 1); /* get what to print from cmdline */
block = blockstack[0].block = starting_blk * (4096 / sbd.bsize);
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index f3220a7..4f7207b 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -54,7 +54,6 @@ extern struct gfs2_inum gfs1_license_di; /* kludge because gfs2 sb too small */
extern struct gfs2_dinode di;
extern int screen_chunk_size; /* how much of the 4K can fit on screen */
extern int gfs2_struct_type;
-extern uint64_t block_in_mem;
extern int identify;
extern int color_scheme;
extern WINDOW *wind;
8 years, 1 month
gfs2-utils: master - gfs2_edit: Don't export bh
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=5375e2b9...
Commit: 5375e2b9b5032ae3c08fefc10f067762ca2db19b
Parent: 054af0f8049c21a3d9ec6564d61332376faacc75
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Feb 4 10:28:10 2016 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Feb 4 10:29:52 2016 +0000
gfs2_edit: Don't export bh
bh is now only used in hexedit.c so restrict its visibility to that
file.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/gfs2hex.c | 1 -
gfs2/edit/hexedit.c | 1 +
gfs2/edit/hexedit.h | 1 -
3 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 4915e5c..1f55a43 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -29,7 +29,6 @@
} while (FALSE);
struct gfs2_sb sb;
-struct gfs2_buffer_head *bh;
struct gfs2_dinode di;
int line, termlines, modelines[DMODES];
char edit_fmt[80];
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 831ca45..a89ae36 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -34,6 +34,7 @@ const char *allocdesc[2][5] = {
{"Free ", "Data ", "Unlnk", "Meta ", "Resrv"},
{"Free ", "Data ", "FreeM", "Meta ", "Resrv"},};
+struct gfs2_buffer_head *bh;
struct gfs2_rgrp *lrgrp;
struct gfs2_meta_header *lmh;
struct gfs2_dinode *ldi;
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 15586d4..f3220a7 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -37,7 +37,6 @@ extern char estring[1024]; /* edit string */
extern char efield[64];
extern uint64_t dev_offset;
extern uint64_t max_block;
-extern struct gfs2_buffer_head *bh;
extern int termlines;
extern int insert;
extern const char *termtype;
8 years, 1 month
gfs2-utils: master - gfs2_edit: Don't use the global block variable
in savemeta.c
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=054af0f8...
Commit: 054af0f8049c21a3d9ec6564d61332376faacc75
Parent: fa3b33f80bd23f230e9ed0fdefb183ecf03ec84c
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Feb 4 10:09:14 2016 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Thu Feb 4 10:09:14 2016 +0000
gfs2_edit: Don't use the global block variable in savemeta.c
Tweak the display functions used by printsavedmeta to accept a bh and
use the block number from it. Remove the last uses of 'block' from
restore_data.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/gfs2hex.c | 32 ++++++++++++++++----------------
gfs2/edit/gfs2hex.h | 2 +-
gfs2/edit/hexedit.c | 4 ++--
gfs2/edit/savemeta.c | 18 +++++++-----------
4 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 101a063..4915e5c 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -455,7 +455,7 @@ static void gfs1_rgrp_print(struct gfs_rgrp *rg)
pv(rg, rg_freemeta, "%u", "0x%x");
}
-int display_gfs2(void)
+int display_gfs2(struct gfs2_buffer_head *dbh)
{
struct gfs2_meta_header mh;
struct gfs2_rgrp rg;
@@ -467,22 +467,22 @@ int display_gfs2(void)
uint32_t magic;
- magic = be32_to_cpu(*(uint32_t *)bh->b_data);
+ magic = be32_to_cpu(*(uint32_t *)dbh->b_data);
switch (magic)
{
case GFS2_MAGIC:
- gfs2_meta_header_in(&mh, bh);
+ gfs2_meta_header_in(&mh, dbh);
if (mh.mh_type > GFS2_METATYPE_QC)
print_gfs2("Unknown metadata type");
else
print_gfs2("%s:", block_type_str[mh.mh_type]);
eol(0);
-
+
switch (mh.mh_type)
{
case GFS2_METATYPE_SB:
- gfs2_sb_in(&sbd.sd_sb, bh);
+ gfs2_sb_in(&sbd.sd_sb, dbh);
gfs2_sb_print2(&sbd.sd_sb);
break;
@@ -490,10 +490,10 @@ int display_gfs2(void)
if (sbd.gfs1) {
struct gfs_rgrp rg1;
- gfs1_rgrp_in(&rg1, bh);
+ gfs1_rgrp_in(&rg1, dbh);
gfs1_rgrp_print(&rg1);
} else {
- gfs2_rgrp_in(&rg, bh);
+ gfs2_rgrp_in(&rg, dbh);
gfs2_rgrp_print(&rg);
}
break;
@@ -511,7 +511,7 @@ int display_gfs2(void)
break;
case GFS2_METATYPE_LF:
- gfs2_leaf_in(&lf, bh);
+ gfs2_leaf_in(&lf, dbh);
gfs2_leaf_print(&lf);
break;
@@ -521,33 +521,33 @@ int display_gfs2(void)
case GFS2_METATYPE_LH:
if (sbd.gfs1) {
- gfs_log_header_in(&lh1, bh);
+ gfs_log_header_in(&lh1, dbh);
gfs_log_header_print(&lh1);
} else {
- gfs2_log_header_in(&lh, bh);
+ gfs2_log_header_in(&lh, dbh);
gfs2_log_header_print(&lh);
}
break;
case GFS2_METATYPE_LD:
- gfs2_log_descriptor_in(&ld, bh);
+ gfs2_log_descriptor_in(&ld, dbh);
gfs2_log_descriptor_print(&ld);
break;
case GFS2_METATYPE_EA:
- do_eattr_extended(bh);
+ do_eattr_extended(dbh);
break;
-
+
case GFS2_METATYPE_ED:
gfs2_meta_header_print(&mh);
break;
-
+
case GFS2_METATYPE_LB:
gfs2_meta_header_print(&mh);
break;
case GFS2_METATYPE_QC:
- gfs2_quota_change_in(&qc, bh);
+ gfs2_quota_change_in(&qc, dbh);
gfs2_quota_change_print(&qc);
break;
@@ -555,7 +555,7 @@ int display_gfs2(void)
break;
}
break;
-
+
default:
print_gfs2("Unknown block type");
eol(0);
diff --git a/gfs2/edit/gfs2hex.h b/gfs2/edit/gfs2hex.h
index 1bd83c3..c3efb27 100644
--- a/gfs2/edit/gfs2hex.h
+++ b/gfs2/edit/gfs2hex.h
@@ -3,7 +3,7 @@
#include "hexedit.h"
-extern int display_gfs2(void);
+extern int display_gfs2(struct gfs2_buffer_head *dbh);
extern int edit_gfs2(void);
extern void do_dinode_extended(struct gfs2_dinode *di,
struct gfs2_buffer_head *lbh);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 07f179d..831ca45 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -333,7 +333,7 @@ int display_block_type(struct gfs2_buffer_head *dbh, int from_restore)
else if (block == JOURNALS_DUMMY_BLOCK)
print_gfs2("Journal Status: ");
else
- print_gfs2("%"PRId64" (0x%"PRIx64")", block, block);
+ print_gfs2("%"PRIu64" (0x%"PRIx64")", dbh->b_blocknr, dbh->b_blocknr);
if (termlines) {
if (edit_row[dmode] == -1)
COLORS_NORMAL;
@@ -1150,7 +1150,7 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
flagref, ref_blk);
else if (dmode == GFS2_MODE) { /* if structure display */
if (block != JOURNALS_DUMMY_BLOCK)
- display_gfs2(); /* display the gfs2 structure */
+ display_gfs2(bh); /* display the gfs2 structure */
} else
display_extended(); /* display extended blocks */
/* No else here because display_extended can switch back to hex mode */
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index e80b425..8510d77 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -27,8 +27,6 @@
#include "hexedit.h"
#include "libgfs2.h"
-extern uint64_t block;
-
#define DFT_SAVE_FILE "/tmp/gfsmeta.XXXXXX"
#define MAX_JOURNALS_SAVED 256
@@ -1076,20 +1074,18 @@ static int restore_data(int fd, gzFile gzin_fd, off_t pos, int printonly)
}
if (printonly) {
- struct gfs2_buffer_head dummy_bh;
- dummy_bh.b_data = savedata->buf;
- bh = &dummy_bh;
- block = savedata->blk;
- if (printonly > 1 && printonly == block) {
- block_in_mem = block;
- display(0, 0, 0, 0);
- bh = NULL;
+ struct gfs2_buffer_head dummy_bh = {
+ .b_data = savedata->buf,
+ .b_blocknr = savedata->blk,
+ };
+ if (printonly > 1 && printonly == savedata->blk) {
+ display_block_type(&dummy_bh, TRUE);
+ display_gfs2(&dummy_bh);
break;
} else if (printonly == 1) {
print_gfs2("%"PRId64" (l=0x%x): ", blks_saved, savedata->siglen);
display_block_type(&dummy_bh, TRUE);
}
- bh = NULL;
} else {
warm_fuzzy_stuff(savedata->blk, FALSE);
memset(savedata->buf + savedata->siglen, 0, sbd.bsize - savedata->siglen);
8 years, 1 month
gfs2-utils: master - gfs2_edit: Don't use the global bh variable in
display_block_type
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=fa3b33f8...
Commit: fa3b33f80bd23f230e9ed0fdefb183ecf03ec84c
Parent: 1cd29416945e9d630003ae46b9138892a5c87a04
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Feb 3 17:55:33 2016 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Feb 3 17:55:33 2016 +0000
gfs2_edit: Don't use the global bh variable in display_block_type
Accept it as an argument instead.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/hexedit.c | 13 ++++---------
gfs2/edit/hexedit.h | 2 +-
gfs2/edit/savemeta.c | 2 +-
3 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index f732b96..07f179d 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -313,7 +313,7 @@ uint32_t get_block_type(const struct gfs2_buffer_head *lbh, int *structlen)
/* returns: metatype if block is a GFS2 structure block type */
/* 0 if block is not a GFS2 structure */
/* ------------------------------------------------------------------------ */
-int display_block_type(int from_restore)
+int display_block_type(struct gfs2_buffer_head *dbh, int from_restore)
{
const struct gfs2_meta_header *mh;
int ret_type = 0; /* return type */
@@ -349,7 +349,7 @@ int display_block_type(int from_restore)
ret_type = GFS2_METATYPE_DI;
struct_len = 0;
} else {
- ret_type = get_block_type(bh, &struct_len);
+ ret_type = get_block_type(dbh, &struct_len);
switch (ret_type) {
case GFS2_METATYPE_SB: /* 1 */
print_gfs2("(superblock)");
@@ -398,9 +398,7 @@ int display_block_type(int from_restore)
break;
}
}
-
-
- mh = bh->iov.iov_base;
+ mh = dbh->iov.iov_base;
eol(0);
if (from_restore)
return ret_type;
@@ -1052,9 +1050,6 @@ static void read_master_dir(void)
memcpy(&masterdir, &indirect[0], sizeof(struct indirect_info));
}
-/* ------------------------------------------------------------------------ */
-/* display */
-/* ------------------------------------------------------------------------ */
int display(int identify_only, int trunc_zeros, uint64_t flagref,
uint64_t ref_blk)
{
@@ -1090,7 +1085,7 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
block_in_mem = blk; /* remember which block is in memory */
}
line = 1;
- gfs2_struct_type = display_block_type(FALSE);
+ gfs2_struct_type = display_block_type(bh, FALSE);
if (identify_only)
return 0;
indirect_blocks = 0;
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 1dd9965..15586d4 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -223,7 +223,7 @@ extern int block_is_inum_file(uint64_t blk);
extern int block_is_statfs_file(uint64_t blk);
extern int block_is_quota_file(uint64_t blk);
extern int block_is_per_node(uint64_t blk);
-extern int display_block_type(int from_restore);
+extern int display_block_type(struct gfs2_buffer_head *bh, 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,
struct gfs2_buffer_head *bh);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 17ad35d..e80b425 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -1087,7 +1087,7 @@ static int restore_data(int fd, gzFile gzin_fd, off_t pos, int printonly)
break;
} else if (printonly == 1) {
print_gfs2("%"PRId64" (l=0x%x): ", blks_saved, savedata->siglen);
- display_block_type(TRUE);
+ display_block_type(&dummy_bh, TRUE);
}
bh = NULL;
} else {
8 years, 1 month
gfs2-utils: master - gfs2_edit: Don't use the global block variable
in savemeta
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=1cd29416...
Commit: 1cd29416945e9d630003ae46b9138892a5c87a04
Parent: 78f88c8146354eeb9d34e6ec25f1a5c14ddd66c4
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Feb 3 16:39:44 2016 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Feb 3 16:39:44 2016 +0000
gfs2_edit: Don't use the global block variable in savemeta
Replace it with local variables as savemeta doesn't use its existing
value.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 29 +++++++++++++++--------------
1 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index c376db4..17ad35d 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -828,26 +828,28 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
exit(1);
}
/* Save off the superblock */
- save_block(sbd.device_fd, &mfd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sbd.bsize, block);
+ save_block(sbd.device_fd, &mfd, GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sbd.bsize, 0);
/* If this is gfs1, save off the rindex because it's not
part of the file system as it is in gfs2. */
if (sbd.gfs1) {
+ uint64_t blk;
int j;
- block = sbd1->sb_rindex_di.no_addr;
- save_block(sbd.device_fd, &mfd, block, block);
- save_inode_data(&mfd, block);
+ blk = sbd1->sb_rindex_di.no_addr;
+ save_block(sbd.device_fd, &mfd, blk, blk);
+ save_inode_data(&mfd, blk);
/* In GFS1, journals aren't part of the RG space */
for (j = 0; j < journals_found; j++) {
log_debug("Saving journal #%d\n", j + 1);
- for (block = journal_blocks[j];
- block < journal_blocks[j] + gfs1_journal_size;
- block++)
- save_block(sbd.device_fd, &mfd, block, block);
+ for (blk = journal_blocks[j];
+ blk < journal_blocks[j] + gfs1_journal_size;
+ blk++)
+ save_block(sbd.device_fd, &mfd, blk, blk);
}
}
/* Walk through the resource groups saving everything within */
for (n = osi_first(&sbd.rgtree); n; n = osi_next(n)) {
+ uint64_t blk;
struct rgrp_tree *rgd;
rgd = (struct rgrp_tree *)n;
@@ -858,10 +860,10 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
(unsigned long long)rgd->ri.ri_addr,
rgd->ri.ri_length);
/* Save off the rg and bitmaps */
- for (block = rgd->ri.ri_addr;
- block < rgd->ri.ri_data0; block++) {
- warm_fuzzy_stuff(block, FALSE);
- save_block(sbd.device_fd, &mfd, block, block);
+ for (blk = rgd->ri.ri_addr;
+ blk < rgd->ri.ri_data0; blk++) {
+ warm_fuzzy_stuff(blk, FALSE);
+ save_block(sbd.device_fd, &mfd, blk, blk);
}
/* Save off the other metadata: inodes, etc. if mode is not 'savergs' */
if (saveoption != 2) {
@@ -872,8 +874,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
/* Clean up */
/* There may be a gap between end of file system and end of device */
/* so we tell the user that we've processed everything. */
- block = sbd.fssize;
- warm_fuzzy_stuff(block, TRUE);
+ warm_fuzzy_stuff(sbd.fssize, TRUE);
printf("\nMetadata saved to file %s ", mfd.filename);
if (mfd.gziplevel) {
printf("(gzipped, level %d).\n", mfd.gziplevel);
8 years, 1 month
gfs2-utils: master - gfs2_edit: Don't use the global block variable
in save_allocated
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=78f88c81...
Commit: 78f88c8146354eeb9d34e6ec25f1a5c14ddd66c4
Parent: fb44aaf56881a16ab632beb57fd3c915426b73d1
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Feb 3 16:29:58 2016 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Feb 3 16:29:58 2016 +0000
gfs2_edit: Don't use the global block variable in save_allocated
Replace it with a local variable as save_allocated doesn't use its
existing value.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 47cabba..c376db4 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -714,6 +714,7 @@ static void get_journal_inode_blocks(void)
static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
{
int blktype;
+ uint64_t blk;
unsigned i, j, m;
uint64_t *ibuf = malloc(sbd.bsize * GFS2_NBBY * sizeof(uint64_t));
@@ -721,11 +722,11 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
m = lgfs2_bm_scan(rgd, i, ibuf, GFS2_BLKST_DINODE);
for (j = 0; j < m; j++) {
- block = ibuf[j];
- warm_fuzzy_stuff(block, FALSE);
- blktype = save_block(sbd.device_fd, mfd, block, block);
+ blk = ibuf[j];
+ warm_fuzzy_stuff(blk, FALSE);
+ blktype = save_block(sbd.device_fd, mfd, blk, blk);
if (blktype == GFS2_METATYPE_DI)
- save_inode_data(mfd, block);
+ save_inode_data(mfd, blk);
}
if (!sbd.gfs1)
@@ -735,7 +736,7 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
* If we don't, we may run into metadata allocation issues. */
m = lgfs2_bm_scan(rgd, i, ibuf, GFS2_BLKST_UNLINKED);
for (j = 0; j < m; j++) {
- save_block(sbd.device_fd, mfd, block, block);
+ save_block(sbd.device_fd, mfd, blk, blk);
}
}
free(ibuf);
8 years, 1 month
gfs2-utils: master - gfs2_edit: Don't use the global block variable
in save_ea_block
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=fb44aaf5...
Commit: fb44aaf56881a16ab632beb57fd3c915426b73d1
Parent: 608c1231f5b74f74bdc033746edacd0048c3a162
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Feb 3 16:26:28 2016 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Feb 3 16:26:28 2016 +0000
gfs2_edit: Don't use the global block variable in save_ea_block
Accept the block's owner's address as an argument instead.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 2fc4815..47cabba 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -468,7 +468,7 @@ static int save_block(int fd, struct metafd *mfd, uint64_t blk, uint64_t owner)
/*
* save_ea_block - save off an extended attribute block
*/
-static void save_ea_block(struct metafd *mfd, struct gfs2_buffer_head *metabh)
+static void save_ea_block(struct metafd *mfd, struct gfs2_buffer_head *metabh, uint64_t owner)
{
int e;
struct gfs2_ea_header ea;
@@ -486,7 +486,7 @@ static void save_ea_block(struct metafd *mfd, struct gfs2_buffer_head *metabh)
b = (uint64_t *)(metabh->b_data);
b += charoff + i;
blk = be64_to_cpu(*b);
- save_block(sbd.device_fd, mfd, blk, block);
+ save_block(sbd.device_fd, mfd, blk, owner);
}
if (!ea.ea_rec_len)
break;
@@ -519,7 +519,7 @@ static void save_indirect_blocks(struct metafd *mfd, osi_list_t *cur_list,
blktype = save_block(sbd.device_fd, mfd, indir_block, owner);
if (blktype == GFS2_METATYPE_EA) {
nbh = bread(&sbd, indir_block);
- save_ea_block(mfd, nbh);
+ save_ea_block(mfd, nbh, owner);
brelse(nbh);
}
if (height != hgt && /* If not at max height and */
@@ -640,7 +640,7 @@ static void save_inode_data(struct metafd *mfd, uint64_t iblk)
gfs2_meta_header_in(&mh, lbh);
if (mh.mh_magic == GFS2_MAGIC &&
mh.mh_type == GFS2_METATYPE_EA)
- save_ea_block(mfd, lbh);
+ save_ea_block(mfd, lbh, iblk);
else if (mh.mh_magic == GFS2_MAGIC &&
mh.mh_type == GFS2_METATYPE_IN)
save_indirect_blocks(mfd, cur_list, lbh, iblk, 2, 2);
8 years, 1 month
gfs2-utils: master - gfs2_edit: Don't use the global block variable
in get_gfs_struct_info
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=608c1231...
Commit: 608c1231f5b74f74bdc033746edacd0048c3a162
Parent: f4ffaffeb359ec4e8670b382ab4cdcf1344c18db
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Feb 3 16:22:32 2016 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Feb 3 16:22:32 2016 +0000
gfs2_edit: Don't use the global block variable in get_gfs_struct_info
Accept the block's owner's address as an argument instead.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 1b3674c..2fc4815 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -196,14 +196,16 @@ static const char *anthropomorphize(unsigned long long inhuman_value)
/*
* get_gfs_struct_info - get block type and structure length
*
+ * @lbh - The block buffer to examine
+ * @owner - The block address of the parent structure
* @block_type - pointer to integer to hold the block type
- * @struct_length - pointer to integet to hold the structure length
+ * @gstruct_len - pointer to integer to hold the structure length
*
* returns: 0 if successful
* -1 if this isn't gfs metadata.
*/
-static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, int *block_type,
- int *gstruct_len)
+static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, uint64_t owner,
+ int *block_type, int *gstruct_len)
{
struct gfs2_meta_header mh;
struct gfs2_inode *inode;
@@ -240,7 +242,7 @@ static int get_gfs_struct_info(struct gfs2_buffer_head *lbh, int *block_type,
if (S_ISDIR(inode->i_di.di_mode) ||
(sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR))
*gstruct_len = sbd.bsize;
- else if (!inode->i_di.di_height && !block_is_systemfile(block) &&
+ else if (!inode->i_di.di_height && !block_is_systemfile(owner) &&
!S_ISDIR(inode->i_di.di_mode))
*gstruct_len = sizeof(struct gfs2_dinode);
else
@@ -426,7 +428,7 @@ static int save_block(int fd, struct metafd *mfd, uint64_t blk, uint64_t owner)
because we want to know if the source inode is a system inode
not the block within the inode "blk". They may or may not
be the same thing. */
- if (get_gfs_struct_info(savebh, &blktype, &blklen) &&
+ if (get_gfs_struct_info(savebh, owner, &blktype, &blklen) &&
!block_is_systemfile(owner)) {
brelse(savebh);
return 0; /* Not metadata, and not system file, so skip it */
8 years, 1 month
gfs2-utils: master - gfs2_edit: Don't use the global block variable
in save_inode_data
by Andrew Price
Gitweb: http://git.fedorahosted.org/git/?p=gfs2-utils.git;a=commitdiff;h=f4ffaffe...
Commit: f4ffaffeb359ec4e8670b382ab4cdcf1344c18db
Parent: 4f726bc88e633ec825c3a22ecead5834862dec53
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Feb 3 16:08:54 2016 +0000
Committer: Andrew Price <anprice(a)redhat.com>
CommitterDate: Wed Feb 3 16:08:54 2016 +0000
gfs2_edit: Don't use the global block variable in save_inode_data
Accept the block's owner's address as an argument instead.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 30 +++++++++++++++---------------
1 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 7c7e504..1b3674c 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -535,7 +535,7 @@ static void save_indirect_blocks(struct metafd *mfd, osi_list_t *cur_list,
* save_inode_data - save off important data associated with an inode
*
* mfd - destination file descriptor
- * block - block number of the inode to save the data for
+ * iblk - block number of the inode to save the data for
*
* For user files, we don't want anything except all the indirect block
* pointers that reside on blocks on all but the highest height.
@@ -546,7 +546,7 @@ static void save_indirect_blocks(struct metafd *mfd, osi_list_t *cur_list,
* For file system journals, the "data" is a mixture of metadata and
* journaled data. We want all the metadata and none of the user data.
*/
-static void save_inode_data(struct metafd *mfd)
+static void save_inode_data(struct metafd *mfd, uint64_t iblk)
{
uint32_t height;
struct gfs2_inode *inode;
@@ -557,7 +557,7 @@ static void save_inode_data(struct metafd *mfd)
for (i = 0; i < GFS2_MAX_META_HEIGHT; i++)
osi_list_init(&metalist[i]);
- metabh = bread(&sbd, block);
+ metabh = bread(&sbd, iblk);
if (sbd.gfs1) {
inode = lgfs2_gfs_inode_get(&sbd, metabh);
} else {
@@ -578,7 +578,7 @@ static void save_inode_data(struct metafd *mfd)
(sbd.gfs1 && inode->i_di.__pad1 == GFS_FILE_DIR)))
height++;
else if (height && !(inode->i_di.di_flags & GFS2_DIF_SYSTEM) &&
- !block_is_systemfile(block) && !S_ISDIR(inode->i_di.di_mode))
+ !block_is_systemfile(iblk) && !S_ISDIR(inode->i_di.di_mode))
height--;
osi_list_add(&metabh->b_altlist, &metalist[0]);
for (i = 1; i <= height; i++){
@@ -588,8 +588,8 @@ static void save_inode_data(struct metafd *mfd)
for (tmp = prev_list->next; tmp != prev_list; tmp = tmp->next){
mybh = osi_list_entry(tmp, struct gfs2_buffer_head,
b_altlist);
- warm_fuzzy_stuff(block, FALSE);
- save_indirect_blocks(mfd, cur_list, mybh, block,
+ warm_fuzzy_stuff(iblk, FALSE);
+ save_indirect_blocks(mfd, cur_list, mybh, iblk,
height, i);
} /* for blocks at that height */
} /* for height */
@@ -623,9 +623,9 @@ static void save_inode_data(struct metafd *mfd)
continue;
old_leaf = leaf_no;
mybh = bread(&sbd, leaf_no);
- warm_fuzzy_stuff(block, FALSE);
+ warm_fuzzy_stuff(iblk, FALSE);
if (gfs2_check_meta(mybh, GFS2_METATYPE_LF) == 0)
- save_block(sbd.device_fd, mfd, leaf_no, block);
+ save_block(sbd.device_fd, mfd, leaf_no, iblk);
brelse(mybh);
}
}
@@ -634,26 +634,26 @@ static void save_inode_data(struct metafd *mfd)
struct gfs2_buffer_head *lbh;
lbh = bread(&sbd, inode->i_di.di_eattr);
- save_block(sbd.device_fd, mfd, inode->i_di.di_eattr, block);
+ save_block(sbd.device_fd, mfd, inode->i_di.di_eattr, iblk);
gfs2_meta_header_in(&mh, lbh);
if (mh.mh_magic == GFS2_MAGIC &&
mh.mh_type == GFS2_METATYPE_EA)
save_ea_block(mfd, lbh);
else if (mh.mh_magic == GFS2_MAGIC &&
mh.mh_type == GFS2_METATYPE_IN)
- save_indirect_blocks(mfd, cur_list, lbh, block, 2, 2);
+ save_indirect_blocks(mfd, cur_list, lbh, iblk, 2, 2);
else {
if (mh.mh_magic == GFS2_MAGIC) /* if it's metadata */
save_block(sbd.device_fd, mfd,
- inode->i_di.di_eattr, block);
+ inode->i_di.di_eattr, iblk);
fprintf(stderr,
"\nWarning: corrupt extended "
"attribute at block %llu (0x%llx) "
"detected in inode %lld (0x%llx).\n",
(unsigned long long)inode->i_di.di_eattr,
(unsigned long long)inode->i_di.di_eattr,
- (unsigned long long)block,
- (unsigned long long)block);
+ (unsigned long long)iblk,
+ (unsigned long long)iblk);
}
brelse(lbh);
}
@@ -723,7 +723,7 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
warm_fuzzy_stuff(block, FALSE);
blktype = save_block(sbd.device_fd, mfd, block, block);
if (blktype == GFS2_METATYPE_DI)
- save_inode_data(mfd);
+ save_inode_data(mfd, block);
}
if (!sbd.gfs1)
@@ -833,7 +833,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
block = sbd1->sb_rindex_di.no_addr;
save_block(sbd.device_fd, &mfd, block, block);
- save_inode_data(&mfd);
+ save_inode_data(&mfd, block);
/* In GFS1, journals aren't part of the RG space */
for (j = 0; j < journals_found; j++) {
log_debug("Saving journal #%d\n", j + 1);
8 years, 1 month