[gfs2-utils] 32/40: gfs2l: Sparse fixes
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit cac95a6a32d24148f5fda3f51beb22530f4a422c
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Jun 10 18:05:49 2021 +0100
gfs2l: Sparse fixes
Remove a VLA and fix the endianness tagging of some casts.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/gfs2l.c | 15 +++++++++++----
gfs2/libgfs2/lang.c | 6 +++---
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/gfs2/libgfs2/gfs2l.c b/gfs2/libgfs2/gfs2l.c
index 15dcd25d..6fc6cd37 100644
--- a/gfs2/libgfs2/gfs2l.c
+++ b/gfs2/libgfs2/gfs2l.c
@@ -28,10 +28,16 @@ static int metastrcmp(const void *a, const void *b)
return strcmp(m1->name, m2->name);
}
-static void print_structs(void)
+static int print_structs(void)
{
- const struct lgfs2_metadata *mlist[lgfs2_metadata_size];
+ const struct lgfs2_metadata **mlist;
int i;
+
+ mlist = calloc(lgfs2_metadata_size, sizeof(struct lgfs2_metadata *));
+ if (mlist == NULL) {
+ perror("Failed to create metadata type array");
+ return 1;
+ }
for (i = 0; i < lgfs2_metadata_size; i++)
mlist[i] = &lgfs2_metadata[i];
@@ -39,6 +45,8 @@ static void print_structs(void)
for (i = 0; i < lgfs2_metadata_size; i++)
if (mlist[i]->mh_type != GFS2_METATYPE_NONE)
printf("%s\n", mlist[i]->name);
+ free(mlist);
+ return 0;
}
static void print_fields(const char *name)
@@ -69,8 +77,7 @@ static int getopts(int argc, char *argv[], struct cmdopts *opts)
}
break;
case 'T':
- print_structs();
- exit(0);
+ exit(print_structs());
case 'F':
print_fields(optarg);
exit(0);
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index 740d1a7b..dd46cd21 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -327,13 +327,13 @@ static int field_print(char *buf, uint64_t addr, const struct lgfs2_metadata *mt
printf("%"PRIu8"\n", *(uint8_t *)fieldp);
break;
case 2:
- printf("%"PRIu16"\n", be16_to_cpu(*(uint16_t *)fieldp));
+ printf("%"PRIu16"\n", be16_to_cpu(*(__be16 *)fieldp));
break;
case 4:
- printf("%"PRIu32"\n", be32_to_cpu(*(uint32_t *)fieldp));
+ printf("%"PRIu32"\n", be32_to_cpu(*(__be32 *)fieldp));
break;
case 8:
- printf("%"PRIu64"\n", be64_to_cpu(*(uint64_t *)fieldp));
+ printf("%"PRIu64"\n", be64_to_cpu(*(__be64 *)fieldp));
break;
default:
// "Reserved" field so just print 0
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 31/40: libgfs2: Broaden use of struct lgfs2_inum
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 95de05e0b48f6fe579c2d3d0f76a032de5bd2557
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Jun 10 17:49:50 2021 +0100
libgfs2: Broaden use of struct lgfs2_inum
Now that we have this structure, use it where appropriate. This allows
struct gfs2_inode and others to be tidied up.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 27 +++++----
gfs2/edit/extended.c | 18 +++---
gfs2/edit/gfs2hex.c | 3 +-
gfs2/edit/hexedit.c | 46 +++++++--------
gfs2/edit/hexedit.h | 5 +-
gfs2/edit/journal.c | 4 +-
gfs2/edit/savemeta.c | 8 +--
gfs2/fsck/afterpass1_common.c | 4 +-
gfs2/fsck/fs_recovery.c | 6 +-
gfs2/fsck/initialize.c | 120 ++++++++++++++++++-------------------
gfs2/fsck/link.c | 21 +++----
gfs2/fsck/lost_n_found.c | 68 ++++++++++-----------
gfs2/fsck/metawalk.c | 70 +++++++++++-----------
gfs2/fsck/pass1.c | 133 +++++++++++++++++++-----------------------
gfs2/fsck/pass1b.c | 16 ++---
gfs2/fsck/pass2.c | 128 +++++++++++++++++-----------------------
gfs2/fsck/pass3.c | 15 +++--
gfs2/fsck/pass4.c | 14 ++---
gfs2/fsck/rgrepair.c | 2 +-
gfs2/fsck/util.c | 19 +++---
gfs2/fsck/util.h | 2 +-
gfs2/glocktop/glocktop.c | 4 +-
gfs2/libgfs2/fs_ops.c | 56 +++++++++---------
gfs2/libgfs2/gfs1.c | 18 +++---
gfs2/libgfs2/gfs2l.c | 2 +-
gfs2/libgfs2/lang.c | 10 ++--
gfs2/libgfs2/libgfs2.h | 63 +++++++++++---------
gfs2/libgfs2/ondisk.c | 56 +++++-------------
gfs2/libgfs2/structures.c | 8 +--
gfs2/mkfs/main_grow.c | 2 +-
gfs2/mkfs/main_mkfs.c | 11 ++--
tests/nukerg.c | 2 +-
32 files changed, 445 insertions(+), 516 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 4439b77a..5228c532 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -709,7 +709,7 @@ static int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip)
if (((isreg||isdir) && ip->i_height <= 1) ||
(isjdata && ip->i_height == 0)) {
if (!issys)
- ip->i_goal_meta = ip->i_addr;
+ ip->i_goal_meta = ip->i_num.in_addr;
return 0; /* nothing to do */
}
@@ -801,7 +801,7 @@ static int fix_cdpn_symlink(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, s
return -1;
}
memset(fix, 0, sizeof(struct inode_dir_block));
- fix->di_addr = ip->i_addr;
+ fix->di_addr = ip->i_num.in_addr;
osi_list_add_prev((osi_list_t *)&fix->list,
(osi_list_t *)&cdpns_to_fix);
}
@@ -865,13 +865,13 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
return -1;
}
- inode_was_gfs1 = (inode->i_formal_ino == inode->i_addr);
+ inode_was_gfs1 = (inode->i_num.in_formal_ino == inode->i_num.in_addr);
/* Fix the inode number: */
- inode->i_formal_ino = sbp->md.next_inum;
+ inode->i_num.in_formal_ino = sbp->md.next_inum;
/* Fix the inode type: gfs1 uses di_type, gfs2 uses di_mode. */
inode->i_mode &= ~S_IFMT;
- switch (inode->i_pad1) { /* formerly di_type */
+ switch (inode->i_di_type) {
case GFS_FILE_DIR: /* directory */
inode->i_mode |= S_IFDIR;
/* Add this directory to the list of dirs to fix later. */
@@ -882,7 +882,7 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
goto err_freei;
}
memset(fixdir, 0, sizeof(struct inode_block));
- fixdir->di_addr = inode->i_addr;
+ fixdir->di_addr = inode->i_num.in_addr;
osi_list_add_prev((osi_list_t *)&fixdir->list,
(osi_list_t *)&dirs_to_fix);
break;
@@ -1058,8 +1058,8 @@ static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr, osi_li
break;
/* If this is the root inode block, remember it for later: */
if (block == root_inode_addr) {
- sbp->sd_root_dir.no_addr = block;
- sbp->sd_root_dir.no_formal_ino = sbp->md.next_inum;
+ sbp->sd_root_dir.in_addr = block;
+ sbp->sd_root_dir.in_formal_ino = sbp->md.next_inum;
}
bh = bread(sbp, block);
if (!gfs2_check_meta(bh->b_data, GFS_METATYPE_DI)) {/* if it is an dinode */
@@ -1117,8 +1117,8 @@ static int fetch_inum(struct gfs2_sbd *sbp, uint64_t iblock,
fix_inode = lgfs2_inode_read(sbp, iblock);
if (fix_inode == NULL)
return 1;
- inum->in_formal_ino = fix_inode->i_formal_ino;
- inum->in_addr = fix_inode->i_addr;
+ inum->in_formal_ino = fix_inode->i_num.in_formal_ino;
+ inum->in_addr = fix_inode->i_num.in_addr;
if (eablk)
*eablk = fix_inode->i_eattr;
@@ -1232,7 +1232,7 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
osi_list_foreach(tmp, &cdpns_to_fix.list) {
fix = osi_list_entry(tmp, struct inode_dir_block, list);
if (fix->di_addr == inum.in_addr)
- fix->di_paddr = dip->i_addr;
+ fix->di_paddr = dip->i_num.in_addr;
}
}
@@ -2234,7 +2234,7 @@ int main(int argc, char **argv)
/* ---------------------------------------------- */
if (!error) {
/* Add a string notifying inode converstion start? */
- error = inode_renumber(&sb2, sb2.sd_root_dir.no_addr,
+ error = inode_renumber(&sb2, sb2.sd_root_dir.in_addr,
(osi_list_t *)&cdpns_to_fix);
if (error)
log_crit(_("\n%s: Error renumbering inodes.\n"), opts.device);
@@ -2296,8 +2296,7 @@ int main(int argc, char **argv)
"GFS2 file system structures.\n"), sb2.jsize);
/* Build the master subdirectory. */
build_master(&sb2); /* Does not do inode_put */
- sb2.sd_meta_dir.no_addr = sb2.master_dir->i_addr;
- sb2.sd_meta_dir.no_formal_ino = sb2.master_dir->i_formal_ino;
+ sb2.sd_meta_dir = sb2.master_dir->i_num;
/* Build empty journal index file. */
error = conv_build_jindex(&sb2);
if (error) {
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 58cc2134..975a514c 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -329,17 +329,17 @@ static int display_leaf(struct iinfo *ind)
line - start_line - 1 ==
edit_row[dmode] - start_row[dmode]) {
COLORS_HIGHLIGHT;
- sprintf(estring, "%"PRIx64, ind->ii[0].dirent[d].inum.addr);
+ sprintf(estring, "%"PRIx64, ind->ii[0].dirent[d].inum.in_addr);
strcpy(edit_fmt, "%llx");
}
}
print_gfs2("%d/%d [%08"PRIX32"] %"PRIu64"/%"PRIu64" (0x%"PRIx64"/0x%"PRIx64") +%"PRIu16": ",
total_dirents, d + 1,
ind->ii[0].dirent[d].hash,
- ind->ii[0].dirent[d].inum.formal_ino,
- ind->ii[0].dirent[d].inum.addr,
- ind->ii[0].dirent[d].inum.formal_ino,
- ind->ii[0].dirent[d].inum.addr,
+ ind->ii[0].dirent[d].inum.in_formal_ino,
+ ind->ii[0].dirent[d].inum.in_addr,
+ ind->ii[0].dirent[d].inum.in_formal_ino,
+ ind->ii[0].dirent[d].inum.in_addr,
ind->ii[0].dirent[d].rahead
);
}
@@ -477,10 +477,10 @@ static int print_gfs2_jindex(void)
for (d = 0; d < indirect->ii[0].dirents; d++) {
if (strncmp(indirect->ii[0].dirent[d].filename, "journal", 7))
continue;
- ip = lgfs2_inode_read(&sbd, indirect->ii[0].dirent[d].inum.addr);
+ ip = lgfs2_inode_read(&sbd, indirect->ii[0].dirent[d].inum.in_addr);
print_gfs2("%s: 0x%-5"PRIx64" %"PRIu64"MB ",
indirect->ii[0].dirent[d].filename,
- indirect->ii[0].dirent[d].inum.addr,
+ indirect->ii[0].dirent[d].inum.in_addr,
ip->i_size / 1048576);
error = lgfs2_find_jhead(ip, &head);
if (error) {
@@ -644,7 +644,7 @@ int display_extended(void)
brelse(tmp_bh);
} else if (block_is_journals(block)) {
if (sbd.gfs1)
- block = sbd.sd_jindex_di.no_addr;
+ block = sbd.sd_jindex_di.in_addr;
else
block = masterblock("jindex");
print_gfs2_jindex();
@@ -655,7 +655,7 @@ int display_extended(void)
return -1;
else if (block_is_rgtree(block)) {
if (sbd.gfs1)
- tmp_bh = bread(&sbd, sbd.sd_rindex_di.no_addr);
+ tmp_bh = bread(&sbd, sbd.sd_rindex_di.in_addr);
else
tmp_bh = bread(&sbd, masterblock("rindex"));
tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index a18df909..d1878639 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -213,8 +213,7 @@ void idirent_in(struct idirent *id, void *dep)
{
struct gfs2_dirent *de = dep;
- id->inum.formal_ino = be64_to_cpu(de->de_inum.no_formal_ino);
- id->inum.addr = be64_to_cpu(de->de_inum.no_addr);
+ lgfs2_inum_in(&id->inum, &de->de_inum);
id->hash = be32_to_cpu(de->de_hash);
id->rec_len = be16_to_cpu(de->de_rec_len);
id->name_len = be16_to_cpu(de->de_name_len);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index fb643ac3..00f5aa03 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -439,9 +439,9 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
if (rgd)
gfs2_rgrp_relse(&sbd, rgd);
}
- if (block == sbd.sd_root_dir.no_addr)
+ if (block == sbd.sd_root_dir.in_addr)
print_gfs2("--------------- Root directory ------------------");
- else if (!sbd.gfs1 && block == sbd.sd_meta_dir.no_addr)
+ else if (!sbd.gfs1 && block == sbd.sd_meta_dir.in_addr)
print_gfs2("-------------- Master directory -----------------");
else if (!sbd.gfs1 && block == RGLIST_DUMMY_BLOCK)
print_gfs2("------------------ RG List ----------------------");
@@ -449,11 +449,11 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
print_gfs2("-------------------- Journal List --------------------");
else {
if (sbd.gfs1) {
- if (block == sbd.sd_rindex_di.no_addr)
+ if (block == sbd.sd_rindex_di.in_addr)
print_gfs2("---------------- rindex file -------------------");
else if (block == gfs1_quota_di.no_addr)
print_gfs2("---------------- Quota file --------------------");
- else if (block == sbd.sd_jindex_di.no_addr)
+ else if (block == sbd.sd_jindex_di.in_addr)
print_gfs2("--------------- Journal Index ------------------");
else if (block == gfs1_license_di.no_addr)
print_gfs2("--------------- License file -------------------");
@@ -462,7 +462,7 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
int d;
for (d = 2; d < 8; d++) {
- if (block == masterdir.dirent[d].inum.addr) {
+ if (block == masterdir.dirent[d].inum.in_addr) {
if (!strncmp(masterdir.dirent[d].filename, "jindex", 6))
print_gfs2("--------------- Journal Index ------------------");
else if (!strncmp(masterdir.dirent[d].filename, "per_node", 8))
@@ -687,7 +687,7 @@ uint64_t masterblock(const char *fn)
for (d = 2; d < 8; d++)
if (!strncmp(masterdir.dirent[d].filename, fn, strlen(fn)))
- return (masterdir.dirent[d].inum.addr);
+ return (masterdir.dirent[d].inum.in_addr);
return 0;
}
@@ -753,7 +753,7 @@ static uint64_t get_rg_addr(int rgnum)
struct gfs2_inode *riinode;
if (sbd.gfs1)
- gblock = sbd.sd_rindex_di.no_addr;
+ gblock = sbd.sd_rindex_di.in_addr;
else
gblock = masterblock("rindex");
riinode = lgfs2_inode_read(&sbd, gblock);
@@ -827,7 +827,7 @@ int has_indirect_blocks(void)
int block_is_rindex(uint64_t blk)
{
- if ((sbd.gfs1 && blk == sbd.sd_rindex_di.no_addr) ||
+ if ((sbd.gfs1 && blk == sbd.sd_rindex_di.in_addr) ||
(blk == masterblock("rindex")))
return TRUE;
return FALSE;
@@ -835,7 +835,7 @@ int block_is_rindex(uint64_t blk)
int block_is_jindex(uint64_t blk)
{
- if ((sbd.gfs1 && blk == sbd.sd_jindex_di.no_addr))
+ if ((sbd.gfs1 && blk == sbd.sd_jindex_di.in_addr))
return TRUE;
return FALSE;
}
@@ -936,13 +936,13 @@ static void read_superblock(int fd)
sizeof(uint64_t);
sbd.sd_diptrs = (sbd.sd_bsize - sizeof(struct gfs_dinode)) /
sizeof(uint64_t);
- sbd.md.riinode = lgfs2_inode_read(&sbd, sbd.sd_rindex_di.no_addr);
+ sbd.md.riinode = lgfs2_inode_read(&sbd, sbd.sd_rindex_di.in_addr);
} else {
sbd.sd_inptrs = (sbd.sd_bsize - sizeof(struct gfs2_meta_header)) /
sizeof(uint64_t);
sbd.sd_diptrs = (sbd.sd_bsize - sizeof(struct gfs2_dinode)) /
sizeof(uint64_t);
- sbd.master_dir = lgfs2_inode_read(&sbd, sbd.sd_meta_dir.no_addr);
+ sbd.master_dir = lgfs2_inode_read(&sbd, sbd.sd_meta_dir.in_addr);
if (sbd.master_dir == NULL) {
sbd.md.riinode = NULL;
} else {
@@ -973,7 +973,7 @@ static int read_master_dir(void)
{
ioctl(sbd.device_fd, BLKFLSBUF, 0);
- bh = bread(&sbd, sbd.sd_meta_dir.no_addr);
+ bh = bread(&sbd, sbd.sd_meta_dir.in_addr);
if (bh == NULL)
return 1;
di = (struct gfs2_dinode *)bh->b_data;
@@ -989,12 +989,12 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
if (block == RGLIST_DUMMY_BLOCK) {
if (sbd.gfs1)
- blk = sbd.sd_rindex_di.no_addr;
+ blk = sbd.sd_rindex_di.in_addr;
else
blk = masterblock("rindex");
} else if (block == JOURNALS_DUMMY_BLOCK) {
if (sbd.gfs1)
- blk = sbd.sd_jindex_di.no_addr;
+ blk = sbd.sd_jindex_di.in_addr;
else
blk = masterblock("jindex");
} else
@@ -1029,20 +1029,18 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
lgfs2_sb_in(&sbd, bh->b_data);
memset(indirect, 0, sizeof(struct iinfo));
- ii->block = sbd.sd_meta_dir.no_addr;
+ ii->block = sbd.sd_meta_dir.in_addr;
ii->is_dir = TRUE;
ii->dirents = 2;
id = &ii->dirent[0];
memcpy(id->filename, "root", 4);
- id->inum.formal_ino = sbd.sd_root_dir.no_formal_ino;
- id->inum.addr = sbd.sd_root_dir.no_addr;
+ id->inum = sbd.sd_root_dir;
id->type = DT_DIR;
id = &ii->dirent[1];
memcpy(id->filename, "master", 7);
- id->inum.formal_ino = sbd.sd_meta_dir.no_formal_ino;
- id->inum.addr = sbd.sd_meta_dir.no_addr;
+ id->inum = sbd.sd_meta_dir;
id->type = DT_DIR;
}
else if (gfs2_struct_type == GFS2_METATYPE_DI) {
@@ -1316,19 +1314,19 @@ uint64_t check_keywords(const char *kword)
if (!strcmp(kword, "sb") ||!strcmp(kword, "superblock"))
blk = 0x10 * (4096 / sbd.sd_bsize); /* superblock */
else if (!strcmp(kword, "root") || !strcmp(kword, "rootdir"))
- blk = sbd.sd_root_dir.no_addr;
+ blk = sbd.sd_root_dir.in_addr;
else if (!strcmp(kword, "master")) {
if (sbd.gfs1)
fprintf(stderr, "This is GFS1; there's no master directory.\n");
- else if (!sbd.sd_meta_dir.no_addr) {
+ else if (!sbd.sd_meta_dir.in_addr) {
fprintf(stderr, "GFS2 master directory not found on %s\n", device);
exit(-1);
} else
- blk = sbd.sd_meta_dir.no_addr;
+ blk = sbd.sd_meta_dir.in_addr;
}
else if (!strcmp(kword, "jindex")) {
if (sbd.gfs1)
- blk = sbd.sd_jindex_di.no_addr;
+ blk = sbd.sd_jindex_di.in_addr;
else
blk = masterblock("jindex"); /* journal index */
}
@@ -1344,7 +1342,7 @@ uint64_t check_keywords(const char *kword)
}
else if (!strcmp(kword, "rindex") || !strcmp(kword, "rgindex")) {
if (sbd.gfs1)
- blk = sbd.sd_rindex_di.no_addr;
+ blk = sbd.sd_rindex_di.in_addr;
else
blk = masterblock("rindex");
} else if (!strcmp(kword, "rgs")) {
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index f60d836d..dd509085 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -64,10 +64,7 @@ extern int details;
extern const char *allocdesc[2][5];
struct idirent {
- struct {
- uint64_t formal_ino;
- uint64_t addr;
- } inum;
+ struct lgfs2_inum inum;
uint32_t hash;
uint16_t rec_len;
uint16_t name_len;
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index b3333861..95fa7c23 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -46,7 +46,7 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
/* Figure out the block of the jindex file */
if (sbd.gfs1)
- jindex_block = sbd.sd_jindex_di.no_addr;
+ jindex_block = sbd.sd_jindex_di.in_addr;
else
jindex_block = masterblock("jindex");
/* read in the block */
@@ -77,7 +77,7 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
if (journal_num > indirect->ii[0].dirents - 2)
return 0;
- jblock = indirect->ii[0].dirent[journal_num + 2].inum.addr;
+ jblock = indirect->ii[0].dirent[journal_num + 2].inum.in_addr;
j_bh = bread(&sbd, jblock);
jdi = (struct gfs2_dinode *)j_bh->b_data;
*j_size = be64_to_cpu(jdi->di_size);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 09761fe2..4beff2ca 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -278,7 +278,7 @@ static int init_per_node_lookup(void)
for (i = 0; i < indirect_blocks; i++) {
int d;
for (d = 0; d < indirect->ii[i].dirents; d++) {
- int ret = insert_per_node_lookup(indirect->ii[i].dirent[d].inum.addr);
+ int ret = insert_per_node_lookup(indirect->ii[i].dirent[d].inum.in_addr);
if (ret != 0)
return ret;
}
@@ -946,7 +946,7 @@ static void get_journal_inode_blocks(void)
struct gfs_jindex ji;
char jbuf[sizeof(struct gfs_jindex)];
- j_inode = lgfs2_gfs_inode_read(&sbd, sbd.sd_jindex_di.no_addr);
+ j_inode = lgfs2_gfs_inode_read(&sbd, sbd.sd_jindex_di.in_addr);
if (j_inode == NULL) {
fprintf(stderr, "Error reading journal inode: %s\n", strerror(errno));
return;
@@ -963,7 +963,7 @@ static void get_journal_inode_blocks(void)
} else {
if (journal + 3 > indirect->ii[0].dirents)
break;
- jblock = indirect->ii[0].dirent[journal + 2].inum.addr;
+ jblock = indirect->ii[0].dirent[journal + 2].inum.in_addr;
}
journal_blocks[journals_found++] = jblock;
}
@@ -1159,7 +1159,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
uint64_t blk;
int j;
- blk = sbd.sd_rindex_di.no_addr;
+ blk = sbd.sd_rindex_di.in_addr;
buf = check_read_block(sbd.device_fd, blk, blk, NULL, NULL);
if (buf != NULL) {
save_buf(&mfd, buf, blk, sbd.sd_bsize);
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c
index c216a5da..9b849316 100644
--- a/gfs2/fsck/afterpass1_common.c
+++ b/gfs2/fsck/afterpass1_common.c
@@ -88,7 +88,7 @@ static int delete_block_if_notdup(struct gfs2_inode *ip, uint64_t block,
if (q == GFS2_BLKST_FREE) {
log_info(_("%s block %"PRIu64" (0x%"PRIx64"), part of inode "
"%"PRIu64" (0x%"PRIx64"), was already free.\n"),
- btype, block, block, ip->i_addr, ip->i_addr);
+ btype, block, block, ip->i_num.in_addr, ip->i_num.in_addr);
return META_IS_GOOD;
}
if (find_remove_dup(ip, block, btype, &removed_lastmeta)) { /* a dup */
@@ -101,7 +101,7 @@ static int delete_block_if_notdup(struct gfs2_inode *ip, uint64_t block,
log_err(_("Not clearing duplicate reference in inode at block #%"PRIu64
" (0x%"PRIx64") to block #%"PRIu64" (0x%"PRIx64") "
"because it's referenced by another inode.\n"),
- ip->i_addr, ip->i_addr, block, block);
+ ip->i_num.in_addr, ip->i_num.in_addr, block, block);
} else {
check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, block, 0,
GFS2_BLKST_FREE);
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 130e9854..c357310e 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -625,7 +625,7 @@ static int rangecheck_jblock(struct gfs2_inode *ip, uint64_t block)
if((block > ip->i_sbd->fssize) || (block <= LGFS2_SB_ADDR(ip->i_sbd))) {
log_info( _("Bad block pointer (out of range) found in "
"journal inode %"PRIu64" (0x%"PRIx64").\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
return META_ERROR; /* Exits check_metatree quicker */
}
return META_IS_GOOD;
@@ -650,7 +650,7 @@ static int rangecheck_jmeta(struct iptr iptr, struct gfs2_buffer_head **bh, int
"indirect block pointer %"PRIu64" (0x%"PRIx64") "
"(points to something that is not an "
"indirect block).\n"),
- ip->i_addr, ip->i_addr, block, block);
+ ip->i_num.in_addr, ip->i_num.in_addr, block, block);
brelse(*bh);
*bh = NULL;
return META_SKIP_FURTHER;
@@ -871,7 +871,7 @@ int init_jindex(struct gfs2_sbd *sdp, int allow_ji_rebuild)
/* rgrepair requires the journals be read in in order to distinguish
"real" rgrps from rgrps that are just copies left in journals. */
if (sdp->gfs1)
- sdp->md.jiinode = lgfs2_inode_read(sdp, sdp->sd_jindex_di.no_addr);
+ sdp->md.jiinode = lgfs2_inode_read(sdp, sdp->sd_jindex_di.in_addr);
else
gfs2_lookupi(sdp->master_dir, "jindex", 6, &sdp->md.jiinode);
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 9d661dce..0869a43e 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -464,7 +464,7 @@ static int rebuild_master(struct gfs2_sbd *sdp)
}
log_err(_("Trying to rebuild the master directory.\n"));
inum.in_formal_ino = sdp->md.next_inum++;
- inum.in_addr = sdp->sd_meta_dir.no_addr;
+ inum.in_addr = sdp->sd_meta_dir.in_addr;
err = init_dinode(sdp, &bh, &inum, S_IFDIR | 0755, GFS2_DIF_SYSTEM, &inum);
if (err != 0)
return -1;
@@ -477,7 +477,7 @@ static int rebuild_master(struct gfs2_sbd *sdp)
if (fix_md.jiinode) {
inum.in_formal_ino = sdp->md.next_inum++;
- inum.in_addr = fix_md.jiinode->i_addr;
+ inum.in_addr = fix_md.jiinode->i_num.in_addr;
err = dir_add(sdp->master_dir, "jindex", 6, &inum,
IF2DT(S_IFDIR | 0700));
if (err) {
@@ -495,7 +495,7 @@ static int rebuild_master(struct gfs2_sbd *sdp)
if (fix_md.pinode) {
inum.in_formal_ino = sdp->md.next_inum++;
- inum.in_addr = fix_md.pinode->i_addr;
+ inum.in_addr = fix_md.pinode->i_num.in_addr;
err = dir_add(sdp->master_dir, "per_node", 8, &inum,
IF2DT(S_IFDIR | 0700));
if (err) {
@@ -515,7 +515,7 @@ static int rebuild_master(struct gfs2_sbd *sdp)
if (fix_md.inum) {
inum.in_formal_ino = sdp->md.next_inum++;
- inum.in_addr = fix_md.inum->i_addr;
+ inum.in_addr = fix_md.inum->i_num.in_addr;
err = dir_add(sdp->master_dir, "inum", 4, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -533,7 +533,7 @@ static int rebuild_master(struct gfs2_sbd *sdp)
if (fix_md.statfs) {
inum.in_formal_ino = sdp->md.next_inum++;
- inum.in_addr = fix_md.statfs->i_addr;
+ inum.in_addr = fix_md.statfs->i_num.in_addr;
err = dir_add(sdp->master_dir, "statfs", 6, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -551,7 +551,7 @@ static int rebuild_master(struct gfs2_sbd *sdp)
if (fix_md.riinode) {
inum.in_formal_ino = sdp->md.next_inum++;
- inum.in_addr = fix_md.riinode->i_addr;
+ inum.in_addr = fix_md.riinode->i_num.in_addr;
err = dir_add(sdp->master_dir, "rindex", 6, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -568,7 +568,7 @@ static int rebuild_master(struct gfs2_sbd *sdp)
if (fix_md.qinode) {
inum.in_formal_ino = sdp->md.next_inum++;
- inum.in_addr = fix_md.qinode->i_addr;
+ inum.in_addr = fix_md.qinode->i_num.in_addr;
err = dir_add(sdp->master_dir, "quota", 5, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -800,7 +800,7 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
log_info( _("Initializing special inodes...\n"));
/* Get root dinode */
- sdp->md.rooti = lgfs2_inode_read(sdp, sdp->sd_root_dir.no_addr);
+ sdp->md.rooti = lgfs2_inode_read(sdp, sdp->sd_root_dir.in_addr);
if (sdp->md.rooti == NULL)
return -1;
@@ -845,19 +845,19 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
if (sdp->gfs1) {
/* In gfs1, the license_di is always 3 blocks after the jindex_di */
- if ((sdp->sd_license_di.no_addr != sdp->sd_jindex_di.no_addr + 3) ||
- (sdp->sd_license_di.no_formal_ino != sdp->sd_jindex_di.no_addr + 3)) {
+ if ((sdp->sd_license_di.in_addr != sdp->sd_jindex_di.in_addr + 3) ||
+ (sdp->sd_license_di.in_formal_ino != sdp->sd_jindex_di.in_addr + 3)) {
if (!query( _("The gfs system statfs inode pointer is incorrect. "
"Okay to correct? (y/n) "))) {
log_err( _("fsck.gfs2 cannot continue without a valid "
"statfs file; aborting.\n"));
goto fail;
}
- sdp->sd_license_di.no_addr = sdp->sd_license_di.no_formal_ino
- = sdp->sd_jindex_di.no_addr + 3;
+ sdp->sd_license_di.in_addr = sdp->sd_license_di.in_formal_ino
+ = sdp->sd_jindex_di.in_addr + 3;
}
- sdp->md.statfs = lgfs2_inode_read(sdp, sdp->sd_license_di.no_addr);
+ sdp->md.statfs = lgfs2_inode_read(sdp, sdp->sd_license_di.in_addr);
if (sdp->md.statfs == NULL) {
log_crit(_("Error reading statfs inode: %s\n"), strerror(errno));
goto fail;
@@ -902,19 +902,19 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
if (sdp->gfs1) {
/* In gfs1, the quota_di is always 2 blocks after the jindex_di */
- if ((sdp->sd_quota_di.no_addr != sdp->sd_jindex_di.no_addr + 2) ||
- (sdp->sd_quota_di.no_formal_ino != sdp->sd_jindex_di.no_addr + 2)) {
+ if ((sdp->sd_quota_di.in_addr != sdp->sd_jindex_di.in_addr + 2) ||
+ (sdp->sd_quota_di.in_formal_ino != sdp->sd_jindex_di.in_addr + 2)) {
if (!query( _("The gfs system quota inode pointer is incorrect. "
" Okay to correct? (y/n) "))) {
log_err( _("fsck.gfs2 cannot continue without a valid "
"quota file; aborting.\n"));
goto fail;
}
- sdp->sd_quota_di.no_addr = sdp->sd_quota_di.no_formal_ino
- = sdp->sd_jindex_di.no_addr + 2;
+ sdp->sd_quota_di.in_addr = sdp->sd_quota_di.in_formal_ino
+ = sdp->sd_jindex_di.in_addr + 2;
}
- sdp->md.qinode = lgfs2_inode_read(sdp, sdp->sd_quota_di.no_addr);
+ sdp->md.qinode = lgfs2_inode_read(sdp, sdp->sd_quota_di.in_addr);
if (sdp->md.qinode == NULL) {
log_crit(_("Error reading quota inode: %s\n"), strerror(errno));
goto fail;
@@ -969,7 +969,7 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
*/
static int is_journal_copy(struct gfs2_inode *ip)
{
- if (ip->i_addr == ip->i_bh->b_blocknr)
+ if (ip->i_num.in_addr == ip->i_bh->b_blocknr)
return 0;
return 1; /* journal copy */
}
@@ -990,20 +990,20 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
struct lgfs2_inum inum;
int error;
- if (ip->i_formal_ino == 2) {
- if (sdp->sd_meta_dir.no_addr)
+ if (ip->i_num.in_formal_ino == 2) {
+ if (sdp->sd_meta_dir.in_addr)
return;
log_warn(_("Found system master directory at: 0x%"PRIx64".\n"),
- ip->i_addr);
- sdp->sd_meta_dir.no_addr = ip->i_addr;
+ ip->i_num.in_addr);
+ sdp->sd_meta_dir.in_addr = ip->i_num.in_addr;
return;
}
- if ((!sdp->gfs1 && ip->i_formal_ino == 3) ||
+ if ((!sdp->gfs1 && ip->i_num.in_formal_ino == 3) ||
(sdp->gfs1 && (ip->i_flags & GFS2_DIF_JDATA) &&
(ip->i_size % sizeof(struct gfs_jindex) == 0))) {
if (fix_md.jiinode || is_journal_copy(ip))
goto out_discard_ip;
- log_warn(_("Found system jindex file at: 0x%"PRIx64"\n"), ip->i_addr);
+ log_warn(_("Found system jindex file at: 0x%"PRIx64"\n"), ip->i_num.in_addr);
fix_md.jiinode = ip;
} else if (!sdp->gfs1 && is_dir(ip, sdp->gfs1)) {
/* Check for a jindex dir entry. Only one system dir has a
@@ -1015,9 +1015,9 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
goto out_discard_ip;
}
fix_md.jiinode = child_ip;
- sdp->sd_meta_dir.no_addr = ip->i_addr;
+ sdp->sd_meta_dir.in_addr = ip->i_num.in_addr;
log_warn(_("Found system master directory at: 0x%"PRIx64"\n"),
- ip->i_addr);
+ ip->i_num.in_addr);
return;
}
@@ -1029,40 +1029,40 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
if (fix_md.pinode || is_journal_copy(ip))
goto out_discard_ip;
log_warn(_("Found system per_node directory at: 0x%"PRIx64"\n"),
- ip->i_addr);
+ ip->i_num.in_addr);
fix_md.pinode = ip;
error = dir_search(ip, "..", 2, NULL, &inum);
if (!error && inum.in_addr) {
- sdp->sd_meta_dir.no_addr = inum.in_addr;
+ sdp->sd_meta_dir.in_addr = inum.in_addr;
log_warn(_("From per_node's '..' master directory backtracked to: "
"0x%"PRIx64"\n"), inum.in_addr);
}
return;
}
- log_debug(_("Unknown system directory at block 0x%"PRIx64"\n"), ip->i_addr);
+ log_debug(_("Unknown system directory at block 0x%"PRIx64"\n"), ip->i_num.in_addr);
goto out_discard_ip;
} else if (!sdp->gfs1 && ip->i_size == 8) {
if (fix_md.inum || is_journal_copy(ip))
goto out_discard_ip;
fix_md.inum = ip;
- log_warn(_("Found system inum file at: 0x%"PRIx64"\n"), ip->i_addr);
+ log_warn(_("Found system inum file at: 0x%"PRIx64"\n"), ip->i_num.in_addr);
} else if (ip->i_size == 24) {
if (fix_md.statfs || is_journal_copy(ip))
goto out_discard_ip;
fix_md.statfs = ip;
- log_warn(_("Found system statfs file at: 0x%"PRIx64"\n"), ip->i_addr);
+ log_warn(_("Found system statfs file at: 0x%"PRIx64"\n"), ip->i_num.in_addr);
} else if ((ip->i_size % 96) == 0) {
if (fix_md.riinode || is_journal_copy(ip))
goto out_discard_ip;
fix_md.riinode = ip;
- log_warn(_("Found system rindex file at: 0x%"PRIx64"\n"), ip->i_addr);
+ log_warn(_("Found system rindex file at: 0x%"PRIx64"\n"), ip->i_num.in_addr);
} else if (!fix_md.qinode && ip->i_size >= 176 &&
- ip->i_formal_ino >= 12 &&
- ip->i_formal_ino <= 100) {
+ ip->i_num.in_formal_ino >= 12 &&
+ ip->i_num.in_formal_ino <= 100) {
if (is_journal_copy(ip))
goto out_discard_ip;
fix_md.qinode = ip;
- log_warn(_("Found system quota file at: 0x%"PRIx64"\n"), ip->i_addr);
+ log_warn(_("Found system quota file at: 0x%"PRIx64"\n"), ip->i_num.in_addr);
} else {
out_discard_ip:
inode_put(&ip);
@@ -1079,23 +1079,23 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
struct lgfs2_inum inum;
int error;
- if (sdp->sd_root_dir.no_addr) /* if we know the root dinode */
+ if (sdp->sd_root_dir.in_addr) /* if we know the root dinode */
return; /* we don't need to find the root */
if (!is_dir(ip, sdp->gfs1)) /* if this isn't a directory */
return; /* it can't lead us to the root anyway */
- if (ip->i_formal_ino == 1) {
+ if (ip->i_num.in_formal_ino == 1) {
struct gfs2_buffer_head *root_bh;
- if (ip->i_addr == ip->i_bh->b_blocknr) {
+ if (ip->i_num.in_addr == ip->i_bh->b_blocknr) {
log_warn(_("Found the root directory at: 0x%"PRIx64".\n"),
- ip->i_addr);
- sdp->sd_root_dir.no_addr = ip->i_addr;
+ ip->i_num.in_addr);
+ sdp->sd_root_dir.in_addr = ip->i_num.in_addr;
return;
}
log_warn(_("The root dinode should be at block 0x%"PRIx64" but it "
"seems to be destroyed.\n"),
- ip->i_addr);
+ ip->i_num.in_addr);
log_warn(_("Found a copy of the root directory in a journal "
"at block: 0x%"PRIx64".\n"),
ip->i_bh->b_blocknr);
@@ -1103,7 +1103,7 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
log_err(_("Damaged root dinode not fixed.\n"));
return;
}
- root_bh = bread(sdp, ip->i_addr);
+ root_bh = bread(sdp, ip->i_num.in_addr);
memcpy(root_bh->b_data, ip->i_bh->b_data, sdp->sd_bsize);
bmodified(root_bh);
brelse(root_bh);
@@ -1112,10 +1112,10 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
}
while (ip) {
gfs2_lookupi(ip, "..", 2, &parent_ip);
- if (parent_ip && parent_ip->i_addr == ip->i_addr) {
+ if (parent_ip && parent_ip->i_num.in_addr == ip->i_num.in_addr) {
log_warn(_("Found the root directory at: 0x%"PRIx64"\n"),
- ip->i_addr);
- sdp->sd_root_dir.no_addr = ip->i_addr;
+ ip->i_num.in_addr);
+ sdp->sd_root_dir.in_addr = ip->i_num.in_addr;
inode_put(&parent_ip);
inode_put(&ip);
return;
@@ -1276,22 +1276,22 @@ static int sb_repair(struct gfs2_sbd *sdp)
GFS2_DEFAULT_BSIZE);
if (error)
return error;
- if (!sdp->sd_meta_dir.no_addr) {
+ if (!sdp->sd_meta_dir.in_addr) {
log_err(_("Unable to locate the system master directory.\n"));
return -1;
}
- if (!sdp->sd_root_dir.no_addr) {
+ if (!sdp->sd_root_dir.in_addr) {
log_err(_("Unable to locate the root directory.\n"));
if (possible_root == HIGHEST_BLOCK) {
/* Take advantage of the fact that mkfs.gfs2
creates master immediately after root. */
log_err(_("Can't find any dinodes that might "
"be the root; using master - 1.\n"));
- possible_root = sdp->sd_meta_dir.no_addr - 1;
+ possible_root = sdp->sd_meta_dir.in_addr - 1;
}
log_err(_("Found a possible root at: 0x%llx\n"),
(unsigned long long)possible_root);
- sdp->sd_root_dir.no_addr = possible_root;
+ sdp->sd_root_dir.in_addr = possible_root;
sdp->md.rooti = lgfs2_inode_read(sdp, possible_root);
if (!sdp->md.rooti || sdp->md.rooti->i_magic != GFS2_MAGIC) {
struct gfs2_buffer_head *bh = NULL;
@@ -1319,16 +1319,16 @@ static int sb_repair(struct gfs2_sbd *sdp)
/* Step 3 - Rebuild the lock protocol and file system table name */
if (query(_("Okay to fix the GFS2 superblock? (y/n)"))) {
log_info(_("Found system master directory at: 0x%"PRIx64"\n"),
- sdp->sd_meta_dir.no_addr);
- sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.no_addr);
+ sdp->sd_meta_dir.in_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.in_addr);
if (sdp->master_dir == NULL) {
log_crit(_("Error reading master inode: %s\n"), strerror(errno));
return -1;
}
- sdp->master_dir->i_addr = sdp->sd_meta_dir.no_addr;
+ sdp->master_dir->i_num.in_addr = sdp->sd_meta_dir.in_addr;
log_info(_("Found the root directory at: 0x%"PRIx64"\n"),
- sdp->sd_root_dir.no_addr);
- sdp->md.rooti = lgfs2_inode_read(sdp, sdp->sd_root_dir.no_addr);
+ sdp->sd_root_dir.in_addr);
+ sdp->md.rooti = lgfs2_inode_read(sdp, sdp->sd_root_dir.in_addr);
if (sdp->md.rooti == NULL) {
log_crit(_("Error reading root inode: %s\n"), strerror(errno));
return -1;
@@ -1431,7 +1431,7 @@ static int reconstruct_single_journal(struct gfs2_sbd *sdp, int jnum,
lh.lh_header.mh_format = GFS2_FORMAT_LH;
lh.lh_header.__pad0 = 0x101674; /* mh_generation */
lh.lh_flags = GFS2_LOG_HEAD_UNMOUNT;
- lh.lh_first = sdp->md.journal[jnum]->i_addr + (seg * sdp->sd_seg_size);
+ lh.lh_first = sdp->md.journal[jnum]->i_num.in_addr + (seg * sdp->sd_seg_size);
lh.lh_sequence = sequence;
bh = bget(sdp, lh.lh_first * sdp->sd_bsize);
@@ -1555,7 +1555,7 @@ static int init_rindex(struct gfs2_sbd *sdp)
int err;
if (sdp->gfs1)
- sdp->md.riinode = lgfs2_inode_read(sdp, sdp->sd_rindex_di.no_addr);
+ sdp->md.riinode = lgfs2_inode_read(sdp, sdp->sd_rindex_di.in_addr);
else
gfs2_lookupi(sdp->master_dir, "rindex", 6, &sdp->md.riinode);
@@ -1644,14 +1644,14 @@ int initialize(struct gfs2_sbd *sdp, int force_check, int preen,
if (sdp->gfs1)
sdp->master_dir = NULL;
else
- sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.no_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.in_addr);
if (!sdp->gfs1 &&
(sdp->master_dir->i_magic != GFS2_MAGIC ||
- sdp->master_dir->i_type != GFS2_METATYPE_DI ||
+ sdp->master_dir->i_mh_type != GFS2_METATYPE_DI ||
!sdp->master_dir->i_size)) {
inode_put(&sdp->master_dir);
rebuild_master(sdp);
- sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.no_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.in_addr);
if (sdp->master_dir == NULL) {
log_crit(_("Error reading master directory: %s\n"), strerror(errno));
return FSCK_ERROR;
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index 43dd6df4..06d4a022 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -41,29 +41,26 @@ int set_di_nlink(struct gfs2_inode *ip)
struct dir_info *di;
if (is_dir(ip, ip->i_sbd->gfs1)) {
- di = dirtree_find(ip->i_addr);
+ di = dirtree_find(ip->i_num.in_addr);
if (di == NULL) {
log_err(_("Error: directory %"PRIu64" (0x%"PRIx64") is not "
"in the dir_tree (set).\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
return -1;
}
di->di_nlink = ip->i_nlink;
return 0;
}
if (ip->i_nlink == 1) {
- link1_set(&nlink1map, ip->i_addr, 1);
+ link1_set(&nlink1map, ip->i_num.in_addr, 1);
return 0;
}
/*log_debug( _("Setting link count to %u for %" PRIu64
" (0x%" PRIx64 ")\n"), count, inode_no, inode_no);*/
/* If the list has entries, look for one that matches inode_no */
- ii = inodetree_find(ip->i_addr);
+ ii = inodetree_find(ip->i_num.in_addr);
if (!ii) {
- struct lgfs2_inum no = {
- .in_addr = ip->i_addr,
- .in_formal_ino = ip->i_formal_ino
- };
+ struct lgfs2_inum no = ip->i_num;
ii = inodetree_insert(no);
}
if (ii)
@@ -84,7 +81,7 @@ int set_di_nlink(struct gfs2_inode *ip)
int incr_link_count(struct lgfs2_inum no, struct gfs2_inode *ip, const char *why)
{
struct inode_info *ii = NULL;
- uint64_t referenced_from = ip ? ip->i_addr : 0;
+ uint64_t referenced_from = ip ? ip->i_num.in_addr : 0;
struct dir_info *di;
struct gfs2_inode *link_ip;
@@ -115,7 +112,7 @@ int incr_link_count(struct lgfs2_inum no, struct gfs2_inode *ip, const char *why
link_ip = fsck_load_inode(ip->i_sbd, no.in_addr);
/* Check formal ino against dinode before adding to inode tree. */
- if (no.in_formal_ino != link_ip->i_formal_ino) {
+ if (no.in_formal_ino != link_ip->i_num.in_formal_ino) {
fsck_inode_put(&link_ip);
return INCR_LINK_INO_MISMATCH; /* inode mismatch */
}
@@ -135,8 +132,8 @@ int incr_link_count(struct lgfs2_inum no, struct gfs2_inode *ip, const char *why
fsck_inode_put(&link_ip);
return INCR_LINK_BAD;
}
- ii->num.in_addr = link_ip->i_addr;
- ii->num.in_formal_ino = link_ip->i_formal_ino;
+ ii->num.in_addr = link_ip->i_num.in_addr;
+ ii->num.in_formal_ino = link_ip->i_num.in_formal_ino;
fsck_inode_put(&link_ip);
ii->di_nlink = 1; /* Must be 1 or it wouldn't have gotten into the
nlink1map */
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 4e543fb1..a9ff85bd 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -26,19 +26,19 @@ static void add_dotdot(struct gfs2_inode *ip)
int err;
log_info(_("Adding .. entry to directory %"PRIu64" (0x%"PRIx64") pointing back to lost+found\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
/* If there's a pre-existing .. directory entry, we have to
back out the links. */
- di = dirtree_find(ip->i_addr);
+ di = dirtree_find(ip->i_num.in_addr);
if (di && valid_block(sdp, di->dotdot_parent.in_addr)) {
struct gfs2_inode *dip;
log_debug(_("Directory (0x%"PRIx64") already had a '..' link to (0x%"PRIx64").\n"),
- ip->i_addr, di->dotdot_parent.in_addr);
+ ip->i_num.in_addr, di->dotdot_parent.in_addr);
dip = fsck_load_inode(sdp, di->dotdot_parent.in_addr);
- if (dip->i_formal_ino == di->dotdot_parent.in_formal_ino) {
- decr_link_count(di->dotdot_parent.in_addr, ip->i_addr, sdp->gfs1,
+ if (dip->i_num.in_formal_ino == di->dotdot_parent.in_formal_ino) {
+ decr_link_count(di->dotdot_parent.in_addr, ip->i_num.in_addr, sdp->gfs1,
_(".. unlinked, moving to lost+found"));
if (dip->i_nlink > 0) {
dip->i_nlink--;
@@ -59,9 +59,9 @@ static void add_dotdot(struct gfs2_inode *ip)
log_debug(_("Directory (0x%"PRIx64")'s link to parent "
"(0x%"PRIx64") had a formal inode discrepancy: "
"was 0x%"PRIx64", expected 0x%"PRIx64"\n"),
- ip->i_addr, di->dotdot_parent.in_addr,
+ ip->i_num.in_addr, di->dotdot_parent.in_addr,
di->dotdot_parent.in_formal_ino,
- dip->i_formal_ino);
+ dip->i_num.in_formal_ino);
log_debug(_("The parent directory was not changed.\n"));
}
fsck_inode_put(&dip);
@@ -71,18 +71,17 @@ static void add_dotdot(struct gfs2_inode *ip)
log_debug(_("Couldn't find a valid '..' entry "
"for orphan directory (0x%"PRIx64"): "
"'..' = 0x%"PRIx64"\n"),
- ip->i_addr, di->dotdot_parent.in_addr);
+ ip->i_num.in_addr, di->dotdot_parent.in_addr);
else
log_debug(_("Couldn't find directory (0x%"PRIx64") "
"in directory tree.\n"),
- ip->i_addr);
+ ip->i_num.in_addr);
}
if (gfs2_dirent_del(ip, "..", 2))
log_warn( _("add_inode_to_lf: Unable to remove "
"\"..\" directory entry.\n"));
- no.in_addr = lf_dip->i_addr;
- no.in_formal_ino = lf_dip->i_formal_ino;
+ no = lf_dip->i_num;
err = dir_add(ip, "..", 2, &no, (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
if (err) {
log_crit(_("Error adding .. directory: %s\n"),
@@ -127,10 +126,7 @@ void make_sure_lf_exists(struct gfs2_inode *ip)
set_di_nlink(sdp->md.rooti);
if (sdp->md.rooti->i_entries > root_entries) {
- struct lgfs2_inum no = {
- .in_addr = lf_dip->i_addr,
- .in_formal_ino = lf_dip->i_formal_ino
- };
+ struct lgfs2_inum no = lf_dip->i_num;
lf_was_created = 1;
/* This is a new lost+found directory, so set its block type
and increment link counts for the directories */
@@ -141,23 +137,23 @@ void make_sure_lf_exists(struct gfs2_inode *ip)
/* Set the bitmap AFTER the dirtree insert so that function
check_n_fix_bitmap will realize it's a dinode and adjust
the rgrp counts properly. */
- fsck_bitmap_set(ip, lf_dip->i_addr, _("lost+found dinode"), GFS2_BLKST_DINODE);
+ fsck_bitmap_set(ip, lf_dip->i_num.in_addr, _("lost+found dinode"), GFS2_BLKST_DINODE);
/* root inode links to lost+found */
- no.in_addr = sdp->md.rooti->i_addr;
- no.in_formal_ino = sdp->md.rooti->i_formal_ino;
+ no.in_addr = sdp->md.rooti->i_num.in_addr;
+ no.in_formal_ino = sdp->md.rooti->i_num.in_formal_ino;
incr_link_count(no, lf_dip, _("root"));
/* lost+found link for '.' from itself */
- no.in_addr = lf_dip->i_addr;
- no.in_formal_ino = lf_dip->i_formal_ino;
+ no.in_addr = lf_dip->i_num.in_addr;
+ no.in_formal_ino = lf_dip->i_num.in_formal_ino;
incr_link_count(no, lf_dip, "\".\"");
/* lost+found link for '..' back to root */
incr_link_count(no, sdp->md.rooti, "\"..\"");
if (sdp->gfs1)
- lf_dip->i_pad1 = GFS_FILE_DIR;
+ lf_dip->i_di_type = GFS_FILE_DIR;
}
log_info(_("lost+found directory is dinode %"PRIu64" (0x%"PRIx64")\n"),
- lf_dip->i_addr, lf_dip->i_addr);
- di = dirtree_find(lf_dip->i_addr);
+ lf_dip->i_num.in_addr, lf_dip->i_num.in_addr);
+ di = dirtree_find(lf_dip->i_num.in_addr);
if (di) {
log_info( _("Marking lost+found inode connected\n"));
di->checked = 1;
@@ -183,7 +179,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
uint32_t mode;
make_sure_lf_exists(ip);
- if (ip->i_addr == lf_dip->i_addr) {
+ if (ip->i_num.in_addr == lf_dip->i_num.in_addr) {
log_err( _("Trying to add lost+found to itself...skipping"));
return 0;
}
@@ -196,41 +192,40 @@ int add_inode_to_lf(struct gfs2_inode *ip){
switch (mode) {
case S_IFDIR:
add_dotdot(ip);
- sprintf(tmp_name, "lost_dir_%"PRIu64, ip->i_addr);
+ sprintf(tmp_name, "lost_dir_%"PRIu64, ip->i_num.in_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR);
break;
case S_IFREG:
- sprintf(tmp_name, "lost_file_%"PRIu64, ip->i_addr);
+ sprintf(tmp_name, "lost_file_%"PRIu64, ip->i_num.in_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_REG : DT_REG);
break;
case S_IFLNK:
- sprintf(tmp_name, "lost_link_%"PRIu64, ip->i_addr);
+ sprintf(tmp_name, "lost_link_%"PRIu64, ip->i_num.in_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_LNK : DT_LNK);
break;
case S_IFBLK:
- sprintf(tmp_name, "lost_blkdev_%"PRIu64, ip->i_addr);
+ sprintf(tmp_name, "lost_blkdev_%"PRIu64, ip->i_num.in_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_BLK : DT_BLK);
break;
case S_IFCHR:
- sprintf(tmp_name, "lost_chrdev_%"PRIu64, ip->i_addr);
+ sprintf(tmp_name, "lost_chrdev_%"PRIu64, ip->i_num.in_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_CHR : DT_CHR);
break;
case S_IFIFO:
- sprintf(tmp_name, "lost_fifo_%"PRIu64, ip->i_addr);
+ sprintf(tmp_name, "lost_fifo_%"PRIu64, ip->i_num.in_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_FIFO : DT_FIFO);
break;
case S_IFSOCK:
- sprintf(tmp_name, "lost_socket_%"PRIu64, ip->i_addr);
+ sprintf(tmp_name, "lost_socket_%"PRIu64, ip->i_num.in_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_SOCK : DT_SOCK);
break;
default:
- sprintf(tmp_name, "lost_%"PRIu64, ip->i_addr);
+ sprintf(tmp_name, "lost_%"PRIu64, ip->i_num.in_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_REG : DT_REG);
break;
}
- no.in_addr = ip->i_addr;
- no.in_formal_ino = ip->i_formal_ino;
+ no = ip->i_num;
err = dir_add(lf_dip, tmp_name, strlen(tmp_name), &no, inode_type);
if (err) {
log_crit(_("Error adding directory %s: %s\n"),
@@ -242,12 +237,11 @@ int add_inode_to_lf(struct gfs2_inode *ip){
incr_link_count(no, lf_dip, _("from lost+found"));
/* If it's a directory, lost+found is back-linked to it via .. */
if (mode == S_IFDIR) {
- no.in_addr = lf_dip->i_addr;
- no.in_formal_ino = lf_dip->i_formal_ino;
+ no = lf_dip->i_num;
incr_link_count(no, ip, _("to lost+found"));
}
log_notice(_("Added inode #%"PRIu64" (0x%"PRIx64") to lost+found\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
lgfs2_dinode_out(lf_dip, lf_dip->i_bh->b_data);
bwrite(lf_dip->i_bh);
return 0;
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 7b5bd873..edeaed88 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -174,7 +174,7 @@ int _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
static const char *prev_caller = NULL;
if (print_level >= MSG_DEBUG) {
- if ((ip->i_addr == prev_ino_addr) &&
+ if ((ip->i_num.in_addr == prev_ino_addr) &&
(mark == prev_mark) && caller == prev_caller) {
log_info("(0x%"PRIx64") ", bblock);
prevcount++;
@@ -184,13 +184,13 @@ int _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
}
/* I'm circumventing the log levels here on purpose to make the
output easier to debug. */
- } else if (ip->i_addr == bblock) {
+ } else if (ip->i_num.in_addr == bblock) {
if (prevcount) {
log_info("\n");
prevcount = 0;
}
printf(_("(%s:%d) %s inode found at block (0x%"PRIx64"): marking as '%s'\n"),
- caller, fline, btype, ip->i_addr, block_type_string(mark));
+ caller, fline, btype, ip->i_num.in_addr, block_type_string(mark));
} else {
if (prevcount) {
log_info("\n");
@@ -198,9 +198,9 @@ int _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
}
printf(_("(%s:%d) inode (0x%"PRIx64") references %s block"
" (0x%"PRIx64"): marking as '%s'\n"),
- caller, fline, ip->i_addr, btype, bblock, block_type_string(mark));
+ caller, fline, ip->i_num.in_addr, btype, bblock, block_type_string(mark));
}
- prev_ino_addr = ip->i_addr;
+ prev_ino_addr = ip->i_num.in_addr;
prev_mark = mark;
prev_caller = caller;
}
@@ -232,24 +232,24 @@ struct gfs2_inode *fsck_system_inode(struct gfs2_sbd *sdp, uint64_t block)
{
int j;
- if (lf_dip && lf_dip->i_addr == block)
+ if (lf_dip && lf_dip->i_num.in_addr == block)
return lf_dip;
if (!sdp->gfs1)
return is_system_inode(sdp, block);
- if (sdp->md.statfs && block == sdp->md.statfs->i_addr)
+ if (sdp->md.statfs && block == sdp->md.statfs->i_num.in_addr)
return sdp->md.statfs;
- if (sdp->md.jiinode && block == sdp->md.jiinode->i_addr)
+ if (sdp->md.jiinode && block == sdp->md.jiinode->i_num.in_addr)
return sdp->md.jiinode;
- if (sdp->md.riinode && block == sdp->md.riinode->i_addr)
+ if (sdp->md.riinode && block == sdp->md.riinode->i_num.in_addr)
return sdp->md.riinode;
- if (sdp->md.qinode && block == sdp->md.qinode->i_addr)
+ if (sdp->md.qinode && block == sdp->md.qinode->i_num.in_addr)
return sdp->md.qinode;
- if (sdp->md.rooti && block == sdp->md.rooti->i_addr)
+ if (sdp->md.rooti && block == sdp->md.rooti->i_num.in_addr)
return sdp->md.rooti;
for (j = 0; j < sdp->md.journals; j++)
if (sdp->md.journal && sdp->md.journal[j] &&
- block == sdp->md.journal[j]->i_addr)
+ block == sdp->md.journal[j]->i_num.in_addr)
return sdp->md.journal[j];
return NULL;
}
@@ -296,7 +296,7 @@ void fsck_inode_put(struct gfs2_inode **ip_in)
struct gfs2_inode *ip = *ip_in;
struct gfs2_inode *sysip;
- sysip = fsck_system_inode(ip->i_sbd, ip->i_addr);
+ sysip = fsck_system_inode(ip->i_sbd, ip->i_num.in_addr);
if (!sysip)
inode_put(ip_in);
}
@@ -422,7 +422,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
"entry %d of directory %"PRIu64" (0x%"PRIx64") "
"is corrupt.\n"),
bh->b_blocknr, bh->b_blocknr, (*count) + 1,
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
if (query( _("Attempt to repair it? (y/n) "))) {
if (dirent_repair(ip, bh, &d, dent, type,
first)) {
@@ -456,7 +456,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
"zero in leaf %"PRIu64" (0x%"PRIx64") of "
"directory %"PRIu64" (0x%"PRIx64")!\n"),
bh->b_blocknr, bh->b_blocknr,
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
if (query(_("Attempt to remove it? (y/n) "))) {
dirblk_truncate(ip, prev, bh);
log_err(_("The corrupt directory "
@@ -494,7 +494,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
if ((char *)dent + d.dr_rec_len >= bh_end){
log_debug(_("Last entry processed for %"PRIu64"->%"PRIu64
"(0x%"PRIx64"->0x%"PRIx64"), di_blocks=%"PRIu64".\n"),
- ip->i_addr, bh->b_blocknr, ip->i_addr,
+ ip->i_num.in_addr, bh->b_blocknr, ip->i_num.in_addr,
bh->b_blocknr, ip->i_blocks);
break;
}
@@ -529,7 +529,7 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
if (!valid_block_ip(ip, *leaf_no)) {
log_err( _("Leaf block #%"PRIu64" (0x%"PRIx64") is out of range for "
"directory #%"PRIu64" (0x%"PRIx64") at index %d (0x%x).\n"),
- *leaf_no, *leaf_no, ip->i_addr, ip->i_addr,
+ *leaf_no, *leaf_no, ip->i_num.in_addr, ip->i_num.in_addr,
lindex, lindex);
msg = _("that is out of range");
goto bad_leaf;
@@ -576,7 +576,7 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
if (be32_to_cpu(lfp->lf_header.mh_type) != GFS2_METATYPE_LF) {
log_err(_("Inode %"PRIu64" (0x%"PRIx64") points to bad leaf %"PRIu64
" (0x%"PRIx64").\n"),
- ip->i_addr, ip->i_addr, *leaf_no, *leaf_no);
+ ip->i_num.in_addr, ip->i_num.in_addr, *leaf_no, *leaf_no);
msg = _("that is not a leaf");
goto bad_leaf;
}
@@ -605,7 +605,7 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
log_err(_("Leaf %"PRIu64" (0x%"PRIx64") entry count in "
"directory %"PRIu64" (0x%"PRIx64") does not match "
"number of entries found - is %u, found %u\n"),
- *leaf_no, *leaf_no, ip->i_addr, ip->i_addr,
+ *leaf_no, *leaf_no, ip->i_num.in_addr, ip->i_num.in_addr,
leaf->lf_entries, count);
if (query( _("Update leaf entry count? (y/n) "))) {
leaf->lf_entries = count;
@@ -621,7 +621,7 @@ out:
if (di_depth < ip->i_depth) {
log_debug(_("Depth of directory %"PRIu64" (0x%"PRIx64") changed from "
"%d to %d; adjusting ref_count from %d to %d\n"),
- ip->i_addr, ip->i_addr, di_depth, ip->i_depth,
+ ip->i_num.in_addr, ip->i_num.in_addr, di_depth, ip->i_depth,
*ref_count, (*ref_count) << (ip->i_depth - di_depth));
(*ref_count) <<= (ip->i_depth - di_depth);
}
@@ -643,7 +643,7 @@ bad_leaf:
if (di_depth < ip->i_depth) {
log_debug(_("Depth of directory %"PRIu64" (0x%"PRIx64") changed from "
"%d to %d. Adjusting ref_count from %d to %d\n"),
- ip->i_addr, ip->i_addr, di_depth, ip->i_depth,
+ ip->i_num.in_addr, ip->i_num.in_addr, di_depth, ip->i_depth,
*ref_count, (*ref_count) << (ip->i_depth - di_depth));
(*ref_count) <<= (ip->i_depth - di_depth);
}
@@ -748,7 +748,7 @@ int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
}
if (first_ok_leaf == -1) { /* no valid leaf found */
log_err(_("Directory #%"PRIu64" (0x%"PRIx64") has no valid leaf blocks\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
free(tbl);
posix_fadvise(sdp->device_fd, 0, 0, POSIX_FADV_NORMAL);
return 1;
@@ -763,7 +763,7 @@ int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
if (!tbl_valid) {
free(tbl);
- log_debug(_("Re-reading 0x%"PRIx64" hash table.\n"), ip->i_addr);
+ log_debug(_("Re-reading 0x%"PRIx64" hash table.\n"), ip->i_num.in_addr);
tbl = get_dir_hash(ip);
if (tbl == NULL) {
perror("get_dir_hash");
@@ -819,19 +819,19 @@ int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
} while (1); /* while we have chained leaf blocks */
if (orig_di_depth != ip->i_depth) {
log_debug(_("Depth of 0x%"PRIx64" changed from %d to %d\n"),
- ip->i_addr, orig_di_depth, ip->i_depth);
+ ip->i_num.in_addr, orig_di_depth, ip->i_depth);
tbl_valid = 0;
lindex <<= (ip->i_depth - orig_di_depth);
hsize = (1 << ip->i_depth);
}
if (orig_di_height != ip->i_height) {
log_debug(_("Height of 0x%"PRIx64" changed from %d to %d\n"),
- ip->i_addr, orig_di_height, ip->i_height);
+ ip->i_num.in_addr, orig_di_height, ip->i_height);
tbl_valid = 0;
}
if (orig_di_blocks != ip->i_blocks) {
log_debug(_("Block count of 0x%"PRIx64" changed from %"PRIu64" to %"PRIu64"\n"),
- ip->i_addr, orig_di_blocks, ip->i_blocks);
+ ip->i_num.in_addr, orig_di_blocks, ip->i_blocks);
tbl_valid = 0;
}
lindex += ref_count;
@@ -927,7 +927,7 @@ static int check_leaf_eattr(struct gfs2_inode *ip, uint64_t block,
log_debug(_("Checking EA leaf block #%"PRIu64" (0x%"PRIx64") for "
"inode #%"PRIu64" (0x%"PRIx64").\n"),
- block, block, ip->i_addr, ip->i_addr);
+ block, block, ip->i_num.in_addr, ip->i_num.in_addr);
error = pass->check_eattr_leaf(ip, block, parent, &bh,
pass->private);
@@ -1064,8 +1064,8 @@ int check_inode_eattr(struct gfs2_inode *ip, struct metawalk_fxns *pass)
log_debug(_("Checking EA indirect block #%"PRIu64" (0x%"PRIx64") for "
"inode #%"PRIu64" (0x%"PRIx64")..\n"),
- ip->i_eattr, ip->i_eattr, ip->i_addr, ip->i_addr);
- error = pass->check_eattr_indir(ip, ip->i_eattr, ip->i_addr,
+ ip->i_eattr, ip->i_eattr, ip->i_num.in_addr, ip->i_num.in_addr);
+ error = pass->check_eattr_indir(ip, ip->i_eattr, ip->i_num.in_addr,
&indirect_buf, pass->private);
if (!error) {
error = check_indirect_eattr(ip, ip->i_eattr,
@@ -1077,7 +1077,7 @@ int check_inode_eattr(struct gfs2_inode *ip, struct metawalk_fxns *pass)
brelse(indirect_buf);
return error;
}
- error = check_leaf_eattr(ip, ip->i_eattr, ip->i_addr, pass);
+ error = check_leaf_eattr(ip, ip->i_eattr, ip->i_num.in_addr, pass);
if (error)
stack;
@@ -1405,7 +1405,7 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
/* If there isn't much pointer corruption check the pointers */
log_debug("Processing data blocks for inode 0x%"PRIx64", metadata block 0x%"PRIx64".\n",
- ip->i_addr, metablock);
+ ip->i_num.in_addr, metablock);
for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
if (!*ptr)
continue;
@@ -1568,7 +1568,7 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
log_notice( _("\rLarge file at %"PRIu64" (0x%"PRIx64") - 100 percent "
"complete. "
"\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
fflush(stdout);
}
undo_metalist:
@@ -1577,7 +1577,7 @@ undo_metalist:
log_err(_("Error: inode %"PRIu64" (0x%"PRIx64") had unrecoverable errors at "
"metadata block %"PRIu64" (0x%"PRIx64"), offset %d (0x%x), block "
"%"PRIu64" (0x%"PRIx64").\n"),
- ip->i_addr, ip->i_addr, error_blk.metablk, error_blk.metablk,
+ ip->i_num.in_addr, ip->i_num.in_addr, error_blk.metablk, error_blk.metablk,
error_blk.metaoff, error_blk.metaoff, error_blk.errblk, error_blk.errblk);
if (!query( _("Remove the invalid inode? (y/n) "))) {
free_metalist(ip, metalist);
@@ -1613,7 +1613,7 @@ undo_metalist:
"block undoing work "
"for inode %"PRIu64" "
"(0x%"PRIx64").\n",
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
rc = 0;
}
}
@@ -1630,7 +1630,7 @@ undo_metalist:
to undo. */
delete_all_dups(ip);
/* Set the dinode as "bad" so it gets deleted */
- fsck_bitmap_set(ip, ip->i_addr, "corrupt", GFS2_BLKST_FREE);
+ fsck_bitmap_set(ip, ip->i_num.in_addr, "corrupt", GFS2_BLKST_FREE);
log_err(_("The corrupt inode was invalidated.\n"));
out:
free_metalist(ip, metalist);
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 9526aed2..8a8ce97c 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -135,7 +135,7 @@ static int pass1_repair_leaf(struct gfs2_inode *ip, uint64_t *leaf_no,
int pad_size, i;
log_err(_("Directory Inode %"PRIu64" (0x%"PRIx64") points to leaf %"PRIu64" (0x%"PRIx64") %s.\n"),
- ip->i_addr, ip->i_addr, *leaf_no, *leaf_no, msg);
+ ip->i_num.in_addr, ip->i_num.in_addr, *leaf_no, *leaf_no, msg);
if (!query( _("Attempt to patch around it? (y/n) "))) {
log_err( _("Bad leaf left in place.\n"));
goto out;
@@ -150,14 +150,14 @@ static int pass1_repair_leaf(struct gfs2_inode *ip, uint64_t *leaf_no,
pad_size = ref_count * sizeof(uint64_t);
log_err(_("Writing zeros to the hash table of directory %"PRIu64
" (0x%"PRIx64") at index: 0x%x for 0x%x pointers.\n"),
- ip->i_addr, ip->i_addr, lindex, ref_count);
+ ip->i_num.in_addr, ip->i_num.in_addr, lindex, ref_count);
if (ip->i_sbd->gfs1)
gfs1_writei(ip, padbuf, lindex * sizeof(uint64_t), pad_size);
else
gfs2_writei(ip, padbuf, lindex * sizeof(uint64_t), pad_size);
free(padbuf);
log_err(_("Directory Inode %"PRIu64" (0x%"PRIx64") patched.\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
out:
*leaf_no = 0;
@@ -200,10 +200,10 @@ static int resuscitate_metalist(struct iptr iptr, struct gfs2_buffer_head **bh,
*was_duplicate = 0;
*bh = NULL;
if (!valid_block_ip(ip, block)){ /* blk outside of FS */
- fsck_blockmap_set(ip, ip->i_addr, _("itself"), GFS2_BLKST_UNLINKED);
+ fsck_blockmap_set(ip, ip->i_num.in_addr, _("itself"), GFS2_BLKST_UNLINKED);
log_err(_("Bad indirect block pointer (invalid or out of "
"range) found in system inode %"PRIu64" (0x%"PRIx64").\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
*is_valid = 0;
return META_IS_GOOD;
}
@@ -246,7 +246,7 @@ static int resuscitate_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (!valid_block_ip(ip, block)) {
log_err(_("Block # referenced by system directory entry %s in inode "
"%"PRIu64" (0x%"PRIx64") is invalid or out of range; ignored.\n"),
- tmp_name, ip->i_addr, ip->i_addr);
+ tmp_name, ip->i_num.in_addr, ip->i_num.in_addr);
return 0;
}
/* If this is a system dinode, we'll handle it later in
@@ -286,7 +286,7 @@ static int p1check_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
log_err(_("Found duplicate block #%"PRIu64" (0x%"PRIx64") referenced "
"as a directory leaf in dinode "
"%"PRIu64" (0x%"PRIx64") - was marked %d (%s)\n"),
- block, block, ip->i_addr, ip->i_addr, q,
+ block, block, ip->i_num.in_addr, ip->i_num.in_addr, q,
block_type_string(q));
add_duplicate_ref(ip, block, REF_AS_META, 0, INODE_VALID);
if (q == (ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE :
@@ -321,11 +321,11 @@ static int pass1_check_metalist(struct iptr iptr, struct gfs2_buffer_head **bh,
"unrecoverable" errors. The inode itself should be
set "free" and removed from the inodetree by
undo_check_metalist. */
- fsck_blockmap_set(ip, ip->i_addr,
+ fsck_blockmap_set(ip, ip->i_num.in_addr,
_("bad block referencing"), GFS2_BLKST_UNLINKED);
log_debug(_("Bad indirect block (invalid/out of range) "
"found in inode %"PRIu64" (0x%"PRIx64").\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
return META_SKIP_FURTHER;
}
@@ -341,7 +341,7 @@ static int pass1_check_metalist(struct iptr iptr, struct gfs2_buffer_head **bh,
log_err(_("Found duplicate block #%"PRIu64" (0x%"PRIx64") referenced "
"as metadata in indirect block for dinode "
"%"PRIu64" (0x%"PRIx64") - was marked %d (%s)\n"),
- block, block, ip->i_addr, ip->i_addr, q,
+ block, block, ip->i_num.in_addr, ip->i_num.in_addr, q,
block_type_string(q));
*was_duplicate = 1;
}
@@ -353,7 +353,7 @@ static int pass1_check_metalist(struct iptr iptr, struct gfs2_buffer_head **bh,
log_err(_("Inode %"PRIu64" (0x%"PRIx64") has a bad indirect block "
"pointer %"PRIu64" (0x%"PRIx64") (points to something "
"that is not %s).\n"),
- ip->i_addr, ip->i_addr, block, block, blktypedesc);
+ ip->i_num.in_addr, ip->i_num.in_addr, block, block, blktypedesc);
if (query(_("Zero the indirect block pointer? (y/n) "))){
*iptr_ptr(iptr) = 0;
bmodified(iptr.ipt_bh);
@@ -400,7 +400,7 @@ static int undo_reference(struct gfs2_inode *ip, uint64_t block, int meta,
struct rgrp_tree *rgd;
if (!valid_block_ip(ip, block)) { /* blk outside of FS */
- fsck_blockmap_set(ip, ip->i_addr, _("bad block referencing"), GFS2_BLKST_FREE);
+ fsck_blockmap_set(ip, ip->i_num.in_addr, _("bad block referencing"), GFS2_BLKST_FREE);
return 1;
}
@@ -487,7 +487,7 @@ static int blockmap_set_as_data(struct gfs2_inode *ip, uint64_t block)
log_err(_("Inode %"PRIu64" (0x%"PRIx64") has a reference to block %"PRIu64" (0x%"PRIx64") "
"as a data block, but it appears to be a dinode we haven't checked yet.\n"),
- ip->i_addr, ip->i_addr, block, block);
+ ip->i_num.in_addr, ip->i_num.in_addr, block, block);
error = -1;
out:
if (!error)
@@ -506,8 +506,8 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
if (!valid_block_ip(ip, block)) {
log_err(_("inode %"PRIu64" (0x%"PRIx64") has a bad data block pointer "
"%"PRIu64" (0x%"PRIx64") (invalid or out of range) "),
- ip->i_addr, ip->i_addr, block, block);
- if (metablock == ip->i_addr)
+ ip->i_num.in_addr, ip->i_num.in_addr, block, block);
+ if (metablock == ip->i_num.in_addr)
log_err("\n");
else
log_err(_("from metadata block %"PRIu64" (0x%"PRIx64")\n"),
@@ -515,7 +515,7 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
/* Mark the owner of this block with the bad_block
* designator so we know to check it for out of range
* blocks later */
- fsck_blockmap_set(ip, ip->i_addr, _("bad (out of range) data"), GFS2_BLKST_UNLINKED);
+ fsck_blockmap_set(ip, ip->i_num.in_addr, _("bad (out of range) data"), GFS2_BLKST_UNLINKED);
return -1;
}
bc->data_count++; /* keep the count sane anyway */
@@ -528,8 +528,8 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
log_err(_("Found duplicate %s block %"PRIu64" (0x%"PRIx64") "
"referenced as data by dinode %"PRIu64" (0x%"PRIx64") "),
block_type_string(q),
- block, block, ip->i_addr, ip->i_addr);
- if (metablock == ip->i_addr)
+ block, block, ip->i_num.in_addr, ip->i_num.in_addr);
+ if (metablock == ip->i_num.in_addr)
log_err("\n");
else
log_err(_("from metadata block %llu (0x%llx)\n"),
@@ -608,7 +608,7 @@ static int ask_remove_inode_eattr(struct gfs2_inode *ip,
if (ip->i_eattr == 0)
return 0; /* eattr was removed prior to this call */
log_err(_("Inode %"PRIu64" (0x%"PRIx64") has unrecoverable Extended Attribute errors.\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
if (query( _("Clear all Extended Attributes from the inode? (y/n) "))){
undo_reference(ip, ip->i_eattr, 0, bc);
ip->i_eattr = 0;
@@ -664,7 +664,7 @@ static int undo_eattr_indir_or_leaf(struct gfs2_inode *ip, uint64_t block,
static void complain_eas(struct gfs2_inode *ip, uint64_t block,
const char *emsg)
{
- log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): %s"), ip->i_addr, ip->i_addr, emsg);
+ log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): %s"), ip->i_num.in_addr, ip->i_num.in_addr, emsg);
log_err(_(" at block #%"PRIu64" (0x%"PRIx64").\n"), block, block);
}
@@ -733,11 +733,11 @@ static int finish_eattr_indir(struct gfs2_inode *ip, int leaf_pointers,
if (leaf_pointer_errors == leaf_pointers) /* All eas were bad */
return ask_remove_inode_eattr(ip, bc);
log_debug(_("Marking inode #%"PRIu64" (0x%"PRIx64") with extended attribute block\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
if (!leaf_pointer_errors)
return 0;
log_err(_("Inode %"PRIu64" (0x%"PRIx64") has recoverable indirect extended attribute errors.\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
if (query( _("Okay to fix the block count for the inode? (y/n) "))) {
ip->i_blocks = 1 + bc->indir_count + bc->data_count + bc->ea_count;
bmodified(ip->i_bh);
@@ -833,7 +833,7 @@ static int check_extended_leaf_eattr(struct gfs2_inode *ip, int i,
log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): extended attribute block "
"%"PRIu64" (0x%"PRIx64") has an extended leaf block #%"PRIu64" "
"(0x%"PRIx64") that is invalid or out of range.\n"),
- ip->i_addr, ip->i_addr, ip->i_eattr, ip->i_eattr, el_blk, el_blk);
+ ip->i_num.in_addr, ip->i_num.in_addr, ip->i_eattr, ip->i_eattr, el_blk, el_blk);
fsck_blockmap_set(ip, ip->i_eattr, _("bad (out of range) Extended Attribute "),
GFS2_BLKST_UNLINKED);
error = 1;
@@ -877,7 +877,7 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
log_warn(_("Inode #%"PRIu64" (0x%"PRIx64"): extended attribute leaf "
"block #%"PRIu64" (0x%"PRIx64") is invalid or out of "
"range.\n"),
- ip->i_addr, ip->i_addr, block, block);
+ ip->i_num.in_addr, ip->i_num.in_addr, block, block);
fsck_blockmap_set(ip, ip->i_eattr, _("bad (out of range) extended attribute leaf"),
GFS2_BLKST_UNLINKED);
return 1;
@@ -1036,7 +1036,7 @@ static int mark_block_invalid(struct gfs2_inode *ip, uint64_t block,
log_info(_("%s block %"PRIu64" (0x%"PRIx64"), part of inode "
"%"PRIu64" (0x%"PRIx64"), was previously referenced so "
"the invalid reference is ignored.\n"),
- btype, block, block, ip->i_addr, ip->i_addr);
+ btype, block, block, ip->i_num.in_addr, ip->i_num.in_addr);
return META_IS_GOOD;
}
fsck_blockmap_set(ip, block, btype, GFS2_BLKST_UNLINKED);
@@ -1126,7 +1126,7 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block,
(*bad_pointers)++;
log_info(_("Bad %s block pointer (invalid or out of range "
"#%ld) found in inode %"PRIu64" (0x%"PRIx64").\n"),
- btypes[btype], *bad_pointers, ip->i_addr, ip->i_addr);
+ btypes[btype], *bad_pointers, ip->i_num.in_addr, ip->i_num.in_addr);
if ((*bad_pointers) <= BAD_POINTER_TOLERANCE)
return META_IS_GOOD;
else
@@ -1138,13 +1138,13 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block,
(*bad_pointers)++;
log_info(_("Duplicated %s block pointer (violation %ld, block %"PRIu64
" (0x%"PRIx64")) found in inode %"PRIu64" (0x%"PRIx64").\n"),
- btypes[btype], *bad_pointers, block, block, ip->i_addr, ip->i_addr);
+ btypes[btype], *bad_pointers, block, block, ip->i_num.in_addr, ip->i_num.in_addr);
if ((*bad_pointers) <= BAD_POINTER_TOLERANCE)
return META_IS_GOOD;
else {
log_debug(_("Inode 0x%"PRIx64" bad pointer tolerance "
"exceeded: block 0x%"PRIx64".\n"),
- ip->i_addr, block);
+ ip->i_num.in_addr, block);
return META_ERROR; /* Exits check_metatree quicker */
}
}
@@ -1248,8 +1248,7 @@ static int set_ip_blockmap(struct gfs2_inode *ip)
default:
return -EINVAL;
}
- no.in_addr = ip->i_addr;
- no.in_formal_ino = ip->i_formal_ino;
+ no = ip->i_num;
if (fsck_blockmap_set(ip, block, ty, GFS2_BLKST_DINODE) ||
(mode == S_IFDIR && !dirtree_insert(no))) {
stack;
@@ -1349,7 +1348,7 @@ static int pass1_check_metatree(struct gfs2_inode *ip,
error = check_metatree(ip, pass);
if (error)
- gfs2_blockmap_set(bl, ip->i_addr, GFS2_BLKST_FREE);
+ gfs2_blockmap_set(bl, ip->i_num.in_addr, GFS2_BLKST_FREE);
return error;
}
@@ -1377,7 +1376,7 @@ static void reprocess_inode(struct gfs2_inode *ip, const char *desc)
alloc_fxns.private = (void *)desc;
log_info(_("%s inode %"PRIu64" (0x%"PRIx64") had blocks added; reprocessing "
"its metadata tree at height=%d.\n"), desc,
- ip->i_addr, ip->i_addr, ip->i_height);
+ ip->i_num.in_addr, ip->i_num.in_addr, ip->i_height);
error = pass1_check_metatree(ip, &alloc_fxns);
if (error)
log_err( _("Error %d reprocessing the %s metadata tree.\n"),
@@ -1404,8 +1403,8 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
error = pass1_check_metatree(ip, &rangecheck_fxns);
if (bad_pointers > BAD_POINTER_TOLERANCE) {
log_err(_("Error: inode %"PRIu64" (0x%"PRIx64") has more than %d bad pointers.\n"),
- ip->i_addr, ip->i_addr, BAD_POINTER_TOLERANCE);
- fsck_blockmap_set(ip, ip->i_addr, _("badly corrupt"), GFS2_BLKST_FREE);
+ ip->i_num.in_addr, ip->i_num.in_addr, BAD_POINTER_TOLERANCE);
+ fsck_blockmap_set(ip, ip->i_num.in_addr, _("badly corrupt"), GFS2_BLKST_FREE);
return 0;
}
@@ -1417,7 +1416,7 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
processed its metadata with pass1_fxns, none of its
metadata will be flagged as metadata or data blocks yet.
Therefore, we don't need to invalidate anything. */
- fsck_blockmap_set(ip, ip->i_addr, _("invalid mode"), GFS2_BLKST_FREE);
+ fsck_blockmap_set(ip, ip->i_num.in_addr, _("invalid mode"), GFS2_BLKST_FREE);
return 0;
} else if (error)
goto bad_dinode;
@@ -1454,7 +1453,7 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
}
log_err(_("Clearing the bad Extended Attributes in "
"inode %"PRIu64" (0x%"PRIx64").\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
eattr_undo_fxns.private = &bc;
check_inode_eattr(ip, &eattr_undo_fxns);
ask_remove_inode_eattr(ip, &bc);
@@ -1465,7 +1464,7 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
if (ip->i_blocks != (1 + bc.indir_count + bc.data_count + bc.ea_count)) {
log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): Ondisk block count (%"PRIu64
") does not match what fsck found (%"PRIu64")\n"),
- ip->i_addr, ip->i_addr, ip->i_blocks, 1 + bc.indir_count +
+ ip->i_num.in_addr, ip->i_num.in_addr, ip->i_blocks, 1 + bc.indir_count +
bc.data_count + bc.ea_count);
log_info(_("inode has: %"PRIu64", but fsck counts: Dinode:1 + "
"indir:%"PRIu64" + data: %"PRIu64" + ea: %"PRIu64"\n"),
@@ -1474,10 +1473,10 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
ip->i_blocks = 1 + bc.indir_count + bc.data_count + bc.ea_count;
bmodified(ip->i_bh);
log_err(_("Block count for #%"PRIu64" (0x%"PRIx64") fixed\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
} else
log_err(_("Bad block count for #%"PRIu64" (0x%"PRIx64") not fixed\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
}
return 0;
@@ -1495,15 +1494,15 @@ static void check_i_goal(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
ip->i_goal_meta > sdp->fssize) {
log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): Bad allocation goal block "
"found: %"PRIu64" (0x%"PRIx64")\n"),
- ip->i_addr, ip->i_addr, ip->i_goal_meta, ip->i_goal_meta);
+ ip->i_num.in_addr, ip->i_num.in_addr, ip->i_goal_meta, ip->i_goal_meta);
if (query(_("Fix goal block in inode #%"PRIu64" (0x%"PRIx64")? (y/n) "),
- ip->i_addr, ip->i_addr)) {
- ip->i_goal_meta = ip->i_addr;
+ ip->i_num.in_addr, ip->i_num.in_addr)) {
+ ip->i_goal_meta = ip->i_num.in_addr;
bmodified(ip->i_bh);
} else
log_err(_("Allocation goal block in inode #%"PRIu64
" (0x%"PRIx64") not fixed\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
}
}
@@ -1520,25 +1519,25 @@ static int handle_di(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
ip = fsck_inode_get(sdp, rgd, bh);
- if (ip->i_addr != block) {
+ if (ip->i_num.in_addr != block) {
log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): Bad inode address found: %"PRIu64
" (0x%"PRIx64")\n"),
- block, block, ip->i_addr, ip->i_addr);
+ block, block, ip->i_num.in_addr, ip->i_num.in_addr);
if (query(_("Fix address in inode at block #%"PRIu64" (0x%"PRIx64")? (y/n) "),
block, block)) {
- ip->i_addr = ip->i_formal_ino = block;
+ ip->i_num.in_addr = ip->i_num.in_formal_ino = block;
bmodified(ip->i_bh);
} else
log_err(_("Address in inode at block #%"PRIu64" (0x%"PRIx64" not fixed\n"),
block, block);
}
- if (sdp->gfs1 && ip->i_formal_ino != block) {
+ if (sdp->gfs1 && ip->i_num.in_formal_ino != block) {
log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): GFS1 formal inode number "
"mismatch: was %"PRIu64" (0x%"PRIx64")\n"),
- block, block, ip->i_formal_ino, ip->i_formal_ino);
+ block, block, ip->i_num.in_formal_ino, ip->i_num.in_formal_ino);
if (query(_("Fix formal inode number in inode #%"PRIu64" (0x%"PRIx64")? (y/n) "),
block, block)) {
- ip->i_formal_ino = block;
+ ip->i_num.in_formal_ino = block;
bmodified(ip->i_bh);
} else
log_err( _("Inode number in inode at block #%lld "
@@ -1570,7 +1569,7 @@ static int check_system_inode(struct gfs2_sbd *sdp,
if (*sysinode) {
/* Read in the system inode, look at its dentries, and start
* reading through them */
- iblock = (*sysinode)->i_addr;
+ iblock = (*sysinode)->i_num.in_addr;
log_info( _("System inode for '%s' is located at block %llu"
" (0x%llx)\n"), filename,
(unsigned long long)iblock,
@@ -1595,14 +1594,11 @@ static int check_system_inode(struct gfs2_sbd *sdp,
if (ds.q == GFS2_BLKST_FREE) {
log_info( _("The inode exists but the block is not "
"marked 'in use'; fixing it.\n"));
- fsck_blockmap_set(*sysinode, (*sysinode)->i_addr,
+ fsck_blockmap_set(*sysinode, (*sysinode)->i_num.in_addr,
filename, GFS2_BLKST_DINODE);
ds.q = GFS2_BLKST_DINODE;
if (isdir) {
- struct lgfs2_inum no = {
- .in_addr = (*sysinode)->i_addr,
- .in_formal_ino = (*sysinode)->i_formal_ino
- };
+ struct lgfs2_inum no = (*sysinode)->i_num;
dirtree_insert(no);
}
}
@@ -1648,14 +1644,11 @@ static int check_system_inode(struct gfs2_sbd *sdp,
}
if (*sysinode == sdp->md.jiinode)
ji_update(sdp);
- fsck_blockmap_set(*sysinode, (*sysinode)->i_addr,
+ fsck_blockmap_set(*sysinode, (*sysinode)->i_num.in_addr,
filename, GFS2_BLKST_DINODE);
ds.q = GFS2_BLKST_DINODE;
if (isdir) {
- struct lgfs2_inum no = {
- .in_addr = (*sysinode)->i_addr,
- .in_formal_ino = (*sysinode)->i_formal_ino
- };
+ struct lgfs2_inum no = (*sysinode)->i_num;
dirtree_insert(no);
}
} else {
@@ -1714,7 +1707,7 @@ static int check_system_inodes(struct gfs2_sbd *sdp)
All other system dinodes in master will be taken care of by function
resuscitate_metalist. But master won't since it has no parent.*/
if (!sdp->gfs1) {
- fsck_blockmap_set(sdp->master_dir, sdp->master_dir->i_addr,
+ fsck_blockmap_set(sdp->master_dir, sdp->master_dir->i_num.in_addr,
"master", GFS2_BLKST_DINODE);
if (check_system_inode(sdp, &sdp->master_dir, "master",
build_master, 1, NULL, 1)) {
@@ -1724,7 +1717,7 @@ static int check_system_inodes(struct gfs2_sbd *sdp)
}
/* Mark the root dinode as a "dinode" in the block map as we did
for master, since it has no parent. */
- fsck_blockmap_set(sdp->md.rooti, sdp->md.rooti->i_addr,
+ fsck_blockmap_set(sdp->md.rooti, sdp->md.rooti->i_num.in_addr,
"root", GFS2_BLKST_DINODE);
if (check_system_inode(sdp, &sdp->md.rooti, "root", build_root, 1,
NULL, 0)) {
@@ -1773,17 +1766,13 @@ static int check_system_inodes(struct gfs2_sbd *sdp)
/* gfs1 has four dinodes that are set in the superblock and
therefore not linked to anything else. We need to adjust
the link counts so pass4 doesn't get confused. */
- no.in_addr = sdp->md.statfs->i_addr;
- no.in_formal_ino = sdp->md.statfs->i_formal_ino;
+ no = sdp->md.statfs->i_num;
incr_link_count(no, NULL, _("gfs1 statfs inode"));
- no.in_addr = sdp->md.jiinode->i_addr;
- no.in_formal_ino = sdp->md.jiinode->i_formal_ino;
+ no = sdp->md.jiinode->i_num;
incr_link_count(no, NULL, _("gfs1 jindex inode"));
- no.in_addr = sdp->md.riinode->i_addr;
- no.in_formal_ino = sdp->md.riinode->i_formal_ino;
+ no = sdp->md.riinode->i_num;
incr_link_count(no, NULL, _("gfs1 rindex inode"));
- no.in_addr = sdp->md.qinode->i_addr;
- no.in_formal_ino = sdp->md.qinode->i_formal_ino;
+ no = sdp->md.qinode->i_num;
incr_link_count(no, NULL, _("gfs1 quota inode"));
return 0;
}
@@ -1879,7 +1868,7 @@ static int pass1_process_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd, uin
(unsigned long long)block,
block_type_string(q));
ip = fsck_inode_get(sdp, rgd, bh);
- if (is_inode && ip->i_addr == block)
+ if (is_inode && ip->i_num.in_addr == block)
add_duplicate_ref(ip, block, REF_IS_INODE, 0,
INODE_VALID);
else
@@ -2127,7 +2116,7 @@ int pass1(struct gfs2_sbd *sdp)
}
/* rgrps and bitmaps don't have bits to represent
their blocks, so don't do this:
- check_n_fix_bitmap(sdp, rgd, rgd->ri.ri_addr + i, 0,
+ check_n_fix_bitmap(sdp, rgd, rgd->ri.ri_num.in_addr + i, 0,
gfs2_meta_rgrp);*/
}
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index 8d702959..dd7653b9 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -350,17 +350,17 @@ static void resolve_dup_references(struct gfs2_sbd *sdp, struct duptree *dt,
and dirtree entries exist. That way, the
bitmap_set will do proper accounting for
the rgrp dinode count. */
- fsck_bitmap_set(ip, ip->i_addr,
+ fsck_bitmap_set(ip, ip->i_num.in_addr,
_("duplicate referencing bad"),
GFS2_BLKST_FREE);
/* Remove the inode from the inode tree */
- ii = inodetree_find(ip->i_addr);
+ ii = inodetree_find(ip->i_num.in_addr);
if (ii)
inodetree_delete(ii);
- di = dirtree_find(ip->i_addr);
+ di = dirtree_find(ip->i_num.in_addr);
if (di)
dirtree_delete(di);
- link1_set(&nlink1map, ip->i_addr,
+ link1_set(&nlink1map, ip->i_num.in_addr,
0);
/* We delete the dup_handler inode count and
duplicate id BEFORE clearing the metadata,
@@ -424,13 +424,13 @@ static int clone_data(struct gfs2_inode *ip, uint64_t metablock,
if (clonet->first) {
log_debug(_("Inode %"PRIu64" (0x%"PRIx64")'s first reference to "
"block %"PRIu64" (0x%"PRIx64") is targeted for cloning.\n"),
- ip->i_addr, ip->i_addr, block, block);
+ ip->i_num.in_addr, ip->i_num.in_addr, block, block);
clonet->first = 0;
return 0;
}
log_err(_("Error: Inode %"PRIu64" (0x%"PRIx64")'s reference to block %"PRIu64
" (0x%"PRIx64") should be replaced with a clone.\n"),
- ip->i_addr, ip->i_addr, block, block);
+ ip->i_num.in_addr, ip->i_num.in_addr, block, block);
if (query( _("Okay to clone the duplicated reference? (y/n) "))) {
error = lgfs2_meta_alloc(ip, &cloneblock);
if (!error) {
@@ -493,7 +493,7 @@ static void clone_dup_ref_in_inode(struct gfs2_inode *ip, struct duptree *dt)
log_err(_("There are multiple references to block %"PRIu64" (0x%"PRIx64") in "
"inode %"PRIu64" (0x%"PRIx64")\n"),
- ip->i_addr, ip->i_addr, dt->block, dt->block);
+ ip->i_num.in_addr, ip->i_num.in_addr, dt->block, dt->block);
error = check_metatree(ip, &pass1b_fxns_clone);
if (error) {
log_err(_("Error cloning duplicate reference(s) to block %"PRIu64
@@ -875,7 +875,7 @@ static int find_block_ref(struct gfs2_sbd *sdp, uint64_t inode)
/* double-check the meta header just to be sure it's metadata */
if (ip->i_magic != GFS2_MAGIC ||
- ip->i_type != GFS2_METATYPE_DI) {
+ ip->i_mh_type != GFS2_METATYPE_DI) {
if (!sdp->gfs1)
log_debug( _("Block %lld (0x%llx) is not a dinode.\n"),
(unsigned long long)inode,
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index c7adc16c..566fc93d 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -80,7 +80,7 @@ static int set_dotdot_dir(struct gfs2_sbd *sdp, uint64_t childblock, struct lgfs
}
/* Special case for root inode because we set it earlier */
if (di->dotdot_parent.in_addr &&
- sdp->md.rooti->i_addr != di->dinode.in_addr) {
+ sdp->md.rooti->i_num.in_addr != di->dinode.in_addr) {
/* This should never happen */
log_crit(_("Dotdot parent already set for block %"PRIu64" (0x%"PRIx64") "
"-> %"PRIu64" (0x%"PRIx64")\n"),
@@ -183,14 +183,14 @@ static int bad_formal_ino(struct gfs2_inode *ip, struct gfs2_dirent *dent,
struct gfs2_inode *dent_ip;
dent_ip = fsck_load_inode(ip->i_sbd, entry.in_addr);
- inum.in_addr = dent_ip->i_addr;
- inum.in_formal_ino = dent_ip->i_formal_ino;
+ inum.in_addr = dent_ip->i_num.in_addr;
+ inum.in_formal_ino = dent_ip->i_num.in_formal_ino;
fsck_inode_put(&dent_ip);
}
}
log_err(_("Directory entry '%s' pointing to block %"PRIu64" (0x%"PRIx64") in "
"directory %"PRIu64" (0x%"PRIx64") has the wrong 'formal' inode number.\n"),
- tmp_name, entry.in_addr, entry.in_addr, ip->i_addr, ip->i_addr);
+ tmp_name, entry.in_addr, entry.in_addr, ip->i_num.in_addr, ip->i_num.in_addr);
log_err(_("The directory entry has %"PRIu64" (0x%"PRIx64") "
"but the inode has %"PRIu64" (0x%"PRIx64")\n"),
entry.in_formal_ino, entry.in_formal_ino,
@@ -206,20 +206,17 @@ static int bad_formal_ino(struct gfs2_inode *ip, struct gfs2_dirent *dent,
has a '..' pointing back, just fix up the no_formal_ino. */
child_ip = lgfs2_inode_read(sdp, entry.in_addr);
error = dir_search(child_ip, "..", 2, NULL, &childs_dotdot);
- if (!error && childs_dotdot.in_addr == ip->i_addr) {
+ if (!error && childs_dotdot.in_addr == ip->i_num.in_addr) {
log_err( _("The entry points to another directory with intact "
"linkage.\n"));
if (query( _("Fix the bad directory entry? (y/n) "))) {
- struct lgfs2_inum no;
log_err( _("Fixing the corrupt directory entry.\n"));
entry.in_formal_ino = inum.in_formal_ino;
d->dr_inum.in_formal_ino = entry.in_formal_ino;
lgfs2_dirent_out(d, dent);
bmodified(bh);
incr_link_count(entry, ip, _("fixed reference"));
- no.in_addr = ip->i_addr;
- no.in_formal_ino = ip->i_formal_ino;
- set_parent_dir(sdp, entry, no);
+ set_parent_dir(sdp, entry, ip->i_num);
} else {
log_err( _("Directory entry not fixed.\n"));
}
@@ -274,7 +271,7 @@ static int check_leaf_depth(struct gfs2_inode *ip, uint64_t leaf_no,
log_err(_("Leaf block %"PRIu64" (0x%"PRIx64") in dinode %"PRIu64" (0x%"PRIx64") has the "
"wrong depth: is %d (length %d), should be %d (length %d).\n"),
- leaf_no, leaf_no, ip->i_addr, ip->i_addr,
+ leaf_no, leaf_no, ip->i_num.in_addr, ip->i_num.in_addr,
cur_depth, ref_count, correct_depth, exp_count);
if (!query( _("Fix the leaf block? (y/n)"))) {
log_err( _("The leaf block was not fixed.\n"));
@@ -362,7 +359,7 @@ static int wrong_leaf(struct gfs2_inode *ip, struct lgfs2_inum *entry,
}
if (lgfs2_get_leaf_ptr(ip, hash_index, &real_leaf)) {
log_err(_("Could not read leaf %d in dinode %"PRIu64": %s\n"), hash_index,
- ip->i_addr, strerror(errno));
+ ip->i_num.in_addr, strerror(errno));
}
if (real_leaf != planned_leaf) {
log_err(_("The planned leaf was split. The new leaf "
@@ -387,11 +384,7 @@ static int wrong_leaf(struct gfs2_inode *ip, struct lgfs2_inum *entry,
to nuke the dent from this leaf when we return, but we
still need to do the "good dent" accounting. */
if (d->dr_type == (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR)) {
- struct lgfs2_inum no = {
- .in_addr = ip->i_addr,
- .in_formal_ino = ip->i_formal_ino
- };
- error = set_parent_dir(sdp, d->dr_inum, no);
+ error = set_parent_dir(sdp, d->dr_inum, ip->i_num);
if (error > 0)
/* This is a bit of a kludge, but returning 0
in this case causes the caller to go through
@@ -447,7 +440,7 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (!valid_block_ip(ip, entry->in_addr)) {
log_err(_("Block # referenced by directory entry %s in inode %"PRIu64
" (0x%"PRIx64") is invalid\n"),
- tmp_name, ip->i_addr, ip->i_addr);
+ tmp_name, ip->i_num.in_addr, ip->i_num.in_addr);
if (query( _("Clear directory entry to out of range block? (y/n) "))) {
return 1;
} else {
@@ -518,7 +511,7 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (*q != GFS2_BLKST_DINODE) {
log_err(_("Directory entry '%s' referencing inode %"PRIu64" (0x%"PRIx64") "
"in dir inode %"PRIu64" (0x%"PRIx64") block type %d: %s.\n"),
- tmp_name, entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr,
+ tmp_name, entry->in_addr, entry->in_addr, ip->i_num.in_addr, ip->i_num.in_addr,
*q, *q == GFS2_BLKST_FREE ?
_("was previously marked invalid") :
_("was deleted or is not an inode"));
@@ -551,7 +544,7 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (error < 0) {
log_err(_("Error: directory entry type is incompatible with block type at block %"PRIu64
" (0x%"PRIx64") in directory inode %"PRIu64" (0x%"PRIx64").\n"),
- entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr);
+ entry->in_addr, entry->in_addr, ip->i_num.in_addr, ip->i_num.in_addr);
log_err( _("Directory entry type is %d, block type is %d.\n"),
d->dr_type, *q);
stack;
@@ -567,7 +560,7 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
log_err( _("Stale directory entry remains\n"));
return 0;
}
- if (ip->i_addr == entry->in_addr)
+ if (ip->i_num.in_addr == entry->in_addr)
entry_ip = ip;
else
entry_ip = fsck_load_inode(sdp, entry->in_addr);
@@ -595,7 +588,7 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (inum.in_formal_ino != entry->in_formal_ino) {
log_err(_("Directory entry '%s' pointing to block %"PRIu64" (0x%"PRIx64") "
"in directory %"PRIu64" (0x%"PRIx64") has the wrong 'formal' inode number.\n"),
- tmp_name, entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr);
+ tmp_name, entry->in_addr, entry->in_addr, ip->i_num.in_addr, ip->i_num.in_addr);
log_err(_("The directory entry has %"PRIu64" (0x%"PRIx64") but the "
"inode has %"PRIu64" (0x%"PRIx64")\n"),
entry->in_formal_ino, entry->in_formal_ino,
@@ -614,7 +607,7 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
log_err(_("Directory entry '%s' pointing to block %"PRIu64
" (0x%"PRIx64") in directory %"PRIu64" (0x%"PRIx64") "
"is not really a GFS1 dinode.\n"), tmp_name,
- entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr);
+ entry->in_addr, entry->in_addr, ip->i_num.in_addr, ip->i_num.in_addr);
brelse(tbh);
return 1;
}
@@ -649,7 +642,7 @@ static int dirref_find(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
log_err(_("The original reference to inode %"PRIu64" (0x%"PRIx64") from "
"directory %"PRIu64" (0x%"PRIx64") has the wrong 'formal' inode "
- "number.\n"), entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr);
+ "number.\n"), entry->in_addr, entry->in_addr, ip->i_num.in_addr, ip->i_num.in_addr);
memset(fn, 0, sizeof(fn));
if (de->dr_name_len < MAX_FILENAME)
strncpy(fn, filename, de->dr_name_len);
@@ -663,7 +656,7 @@ static int dirref_find(struct gfs2_inode *ip, struct gfs2_dirent *dent,
log_err(_("The corrupt directory entry was not fixed.\n"));
goto out;
}
- decr_link_count(entry->in_addr, ip->i_addr, ip->i_sbd->gfs1,
+ decr_link_count(entry->in_addr, ip->i_num.in_addr, ip->i_sbd->gfs1,
_("bad original reference"));
dirent2_del(ip, bh, prev, dent);
log_err(_("The corrupt directory entry '%s' was deleted.\n"), fn);
@@ -735,7 +728,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
struct gfs2_sbd *sdp = ip->i_sbd;
int q = 0;
char tmp_name[MAX_FILENAME];
- struct lgfs2_inum entry, no;
+ struct lgfs2_inum entry;
struct dir_status *ds = (struct dir_status *) priv;
int error;
struct gfs2_inode *entry_ip = NULL;
@@ -763,18 +756,18 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (!strcmp(".", tmp_name)) {
log_debug(_("Found . dentry in directory %"PRIu64" (0x%"PRIx64")\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
if (ds->dotdir) {
log_err(_("Already found '.' entry in directory %"PRIu64" (0x%"PRIx64")\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
if (!query( _("Clear duplicate '.' entry? (y/n) "))) {
log_err( _("Duplicate '.' entry remains\n"));
/* FIXME: Should we continue on here
* and check the rest of the '.' entry? */
goto dentry_is_valid;
}
- if (ip->i_addr == entry.in_addr)
+ if (ip->i_num.in_addr == entry.in_addr)
entry_ip = ip;
else
entry_ip = fsck_load_inode(sdp, entry.in_addr);
@@ -788,19 +781,19 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
* location */
/* check that '.' refers to this inode */
- if (entry.in_addr != ip->i_addr) {
+ if (entry.in_addr != ip->i_num.in_addr) {
log_err(_("'.' entry's value incorrect in directory %"PRIu64" (0x%"PRIx64")."
" Points to %"PRIu64" (0x%"PRIx64") when it should point to %"PRIu64
" (0x%"PRIx64").\n"),
entry.in_addr, entry.in_addr, entry.in_addr, entry.in_addr,
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
if (!query( _("Remove '.' reference? (y/n) "))) {
log_err( _("Invalid '.' reference remains\n"));
/* Not setting ds->dotdir here since
* this '.' entry is invalid */
goto dentry_is_valid;
}
- if (ip->i_addr == entry.in_addr)
+ if (ip->i_num.in_addr == entry.in_addr)
entry_ip = ip;
else
entry_ip = fsck_load_inode(sdp, entry.in_addr);
@@ -815,10 +808,10 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
if (!strcmp("..", tmp_name)) {
log_debug(_("Found '..' dentry in directory %"PRIu64" (0x%"PRIx64")\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
if (ds->dotdotdir) {
log_err(_("Already had a '..' entry in directory %"PRIu64" (0x%"PRIx64")\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
if (!query( _("Clear duplicate '..' entry? (y/n) "))) {
log_err( _("Duplicate '..' entry remains\n"));
/* FIXME: Should we continue on here
@@ -827,7 +820,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
goto dentry_is_valid;
}
- if (ip->i_addr == entry.in_addr)
+ if (ip->i_num.in_addr == entry.in_addr)
entry_ip = ip;
else
entry_ip = fsck_load_inode(sdp, entry.in_addr);
@@ -840,12 +833,12 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (!isdir) {
log_err(_("Found '..' entry in directory %"PRIu64" (0x%"PRIx64") "
"pointing to something that's not a directory"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
if (!query( _("Clear bad '..' directory entry? (y/n) "))) {
log_err( _("Bad '..' directory entry remains\n"));
goto dentry_is_valid;
}
- if (ip->i_addr == entry.in_addr)
+ if (ip->i_num.in_addr == entry.in_addr)
entry_ip = ip;
else
entry_ip = fsck_load_inode(sdp, entry.in_addr);
@@ -860,7 +853,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* Add the address this entry is pointing to
* to this inode's dotdot_parent in
* dir_info */
- if (set_dotdot_dir(sdp, ip->i_addr, entry)) {
+ if (set_dotdot_dir(sdp, ip->i_num.in_addr, entry)) {
stack;
return -1;
}
@@ -892,9 +885,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
/*log_debug( _("Found plain directory dentry\n"));*/
- no.in_addr = ip->i_addr;
- no.in_formal_ino = ip->i_formal_ino;
- error = set_parent_dir(sdp, entry, no);
+ error = set_parent_dir(sdp, entry, ip->i_num);
if (error > 0) {
log_err(_("%s: Hard link to block %"PRIu64" (0x%"PRIx64") detected.\n"),
tmp_name, entry.in_addr, entry.in_addr);
@@ -962,7 +953,7 @@ static int write_new_leaf(struct gfs2_inode *dip, int start_lindex,
if ((1 << factor) != num_copies) {
log_err(_("Program error: num_copies not a factor of 2.\n"));
log_err(_("num_copies=%d, dinode = %"PRIu64" (0x%"PRIx64")\n"),
- num_copies, dip->i_addr, dip->i_addr);
+ num_copies, dip->i_num.in_addr, dip->i_num.in_addr);
log_err(_("lindex = %d (0x%x)\n"), start_lindex, start_lindex);
stack;
free(padbuf);
@@ -1009,7 +1000,7 @@ static int write_new_leaf(struct gfs2_inode *dip, int start_lindex,
pad_size = num_copies * sizeof(uint64_t);
log_err(_("Writing to the hash table of directory %"PRIu64
" (0x%"PRIx64") at index: 0x%x for 0x%lx pointers.\n"),
- dip->i_addr, dip->i_addr,
+ dip->i_num.in_addr, dip->i_num.in_addr,
start_lindex, (unsigned long)pad_size / sizeof(uint64_t));
if (dip->i_sbd->gfs1)
count = gfs1_writei(dip, padbuf, start_lindex *
@@ -1042,7 +1033,7 @@ static void pad_with_leafblks(struct gfs2_inode *ip, uint64_t *tbl,
log_err(_("Padding inode %"PRIu64" (0x%"PRIx64") hash table at offset %d (0x%x) "
"for %d pointers.\n"),
- ip->i_addr, ip->i_addr, lindex, lindex, len);
+ ip->i_num.in_addr, ip->i_num.in_addr, lindex, lindex, len);
while (len) {
new_len = 1;
/* Determine the next factor of 2 down from extras. We can't
@@ -1153,10 +1144,7 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
/* If it's a directory, lost+found is
back-linked to it via .. */
if (isdir) {
- struct lgfs2_inum no = {
- .in_addr = lf_dip->i_addr,
- .in_formal_ino = lf_dip->i_formal_ino
- };
+ struct lgfs2_inum no = lf_dip->i_num;
incr_link_count(no, NULL, _("to lost+found"));
}
log_err(_("Relocated \"%s\", block %"PRIu64" (0x%"PRIx64") to lost+found.\n"),
@@ -1233,7 +1221,7 @@ static int pass2_repair_leaf(struct gfs2_inode *ip, uint64_t *leaf_no,
uint64_t bn = 0;
log_err(_("Directory Inode %"PRIu64" (0x%"PRIx64") points to leaf %"PRIu64" (0x%"PRIx64") %s.\n"),
- ip->i_addr, ip->i_addr, *leaf_no, *leaf_no, msg);
+ ip->i_num.in_addr, ip->i_num.in_addr, *leaf_no, *leaf_no, msg);
if (!query( _("Attempt to patch around it? (y/n) "))) {
log_err( _("Bad leaf left in place.\n"));
goto out;
@@ -1258,7 +1246,7 @@ static int pass2_repair_leaf(struct gfs2_inode *ip, uint64_t *leaf_no,
ref_count -= refs;
}
log_err(_("Directory Inode %"PRIu64" (0x%"PRIx64") repaired.\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
out:
*leaf_no = bn;
return new_leaf_blks;
@@ -1320,7 +1308,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
*proper_len = len;
log_err(_("Dinode %"PRIu64" (0x%"PRIx64") has a hash table error at index "
"0x%x, length 0x%x: leaf block %"PRIu64" (0x%"PRIx64")\n"),
- ip->i_addr, ip->i_addr, lindex, len, leafblk, leafblk);
+ ip->i_num.in_addr, ip->i_num.in_addr, lindex, len, leafblk, leafblk);
if (!query( _("Fix the hash table? (y/n) "))) {
log_err(_("Hash table not fixed.\n"));
return 0;
@@ -1512,7 +1500,7 @@ static int check_hash_tbl_dups(struct gfs2_inode *ip, uint64_t *tbl,
log_err(_("Dinode %"PRIu64" (0x%"PRIx64") has duplicate leaf pointers "
"to block %"PRIu64" (0x%"PRIx64") at offsets %u (0x%x) "
"(for 0x%x) and %u (0x%x) (for 0x%x)\n"),
- ip->i_addr, ip->i_addr, leafblk, leafblk, lindex, lindex,
+ ip->i_num.in_addr, ip->i_num.in_addr, leafblk, leafblk, lindex, lindex,
len, l, l, len2);
/* See which set of references is valid: the one passed in
@@ -1656,7 +1644,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
log_err(_("Dinode %"PRIu64" (0x%"PRIx64") has bad leaf pointers "
"at offset %d for %d\n"),
- ip->i_addr, ip->i_addr, lindex, len);
+ ip->i_num.in_addr, ip->i_num.in_addr, lindex, len);
if (!query( _("Fix the hash table? (y/n) "))) {
log_err(_("Hash table not fixed.\n"));
lindex += len;
@@ -1742,7 +1730,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
log_err(_("Dinode %"PRIu64" (0x%"PRIx64") has a hash table "
"inconsistency at index %d (0x%x) for %d\n"),
- ip->i_addr, ip->i_addr,
+ ip->i_num.in_addr, ip->i_num.in_addr,
i, i, len);
if (!query( _("Fix the hash table? (y/n) "))) {
log_err(_("Hash table not fixed.\n"));
@@ -1899,7 +1887,7 @@ build_it:
log_err(_("Error rebuilding %s.\n"), fn);
return -1;
}
- fsck_bitmap_set(ip, ip->i_addr, fn, GFS2_BLKST_DINODE);
+ fsck_bitmap_set(ip, ip->i_num.in_addr, fn, GFS2_BLKST_DINODE);
log_err(_("System file %s rebuilt.\n"), fn);
goto out_good;
}
@@ -1921,7 +1909,7 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
return -1;
}
- iblock = sysinode->i_addr;
+ iblock = sysinode->i_num.in_addr;
ds.q = bitmap_type(sysinode->i_sbd, iblock);
pass2_fxns.private = (void *) &ds;
@@ -1950,10 +1938,7 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
if (!ds.dotdir) {
log_err( _("No '.' entry found for %s directory.\n"), dirname);
if (query( _("Is it okay to add '.' entry? (y/n) "))) {
- struct lgfs2_inum no = {
- .in_addr = sysinode->i_addr,
- .in_formal_ino = sysinode->i_formal_ino
- };
+ struct lgfs2_inum no = sysinode->i_num;
log_warn( _("Adding '.' entry\n"));
error = dir_add(sysinode, ".", 1, &no,
(sysinode->i_sbd->gfs1 ? GFS_FILE_DIR : DT_DIR));
@@ -1970,16 +1955,16 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
}
if (sysinode->i_entries != ds.entry_count) {
log_err(_("%s inode %"PRIu64" (0x%"PRIx64"): Entries is %d - should be %d\n"),
- dirname, sysinode->i_addr, sysinode->i_addr, sysinode->i_entries,
+ dirname, sysinode->i_num.in_addr, sysinode->i_num.in_addr, sysinode->i_entries,
ds.entry_count);
if (query( _("Fix entries for %s inode %"PRIu64" (0x%"PRIx64")? (y/n) "),
- dirname, sysinode->i_addr, sysinode->i_addr)) {
+ dirname, sysinode->i_num.in_addr, sysinode->i_num.in_addr)) {
sysinode->i_entries = ds.entry_count;
bmodified(sysinode->i_bh);
log_warn( _("Entries updated\n"));
} else {
log_err(_("Entries for inode %"PRIu64" (0x%"PRIx64") left out of sync\n"),
- sysinode->i_addr, sysinode->i_addr);
+ sysinode->i_num.in_addr, sysinode->i_num.in_addr);
}
}
error = 0;
@@ -2009,20 +1994,20 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
*/
static inline int is_system_dir(struct gfs2_sbd *sdp, uint64_t block)
{
- if (block == sdp->md.rooti->i_addr)
+ if (block == sdp->md.rooti->i_num.in_addr)
return 1;
if (sdp->gfs1)
return 0;
- if (block == sdp->md.jiinode->i_addr ||
- block == sdp->md.pinode->i_addr ||
- block == sdp->master_dir->i_addr)
+ if (block == sdp->md.jiinode->i_num.in_addr ||
+ block == sdp->md.pinode->i_num.in_addr ||
+ block == sdp->master_dir->i_num.in_addr)
return 1;
return 0;
}
static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
{
- uint64_t dirblk = ip->i_addr;
+ uint64_t dirblk = ip->i_num.in_addr;
struct dir_status ds = {0};
int error;
@@ -2075,10 +2060,7 @@ static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
(unsigned long long)dirblk, (unsigned long long)dirblk);
if (query( _("Is it okay to add '.' entry? (y/n) "))) {
- struct lgfs2_inum no = {
- .in_addr = ip->i_addr,
- .in_formal_ino = ip->i_formal_ino
- };
+ struct lgfs2_inum no = ip->i_num;
error = dir_add(ip, ".", 1, &no,
(sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
if (error) {
@@ -2097,7 +2079,7 @@ static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
if (!fsck_abort && ip->i_entries != ds.entry_count) {
log_err(_("Entries is %d - should be %d for inode block %"PRIu64" (0x%"PRIx64")\n"),
- ip->i_entries, ds.entry_count, ip->i_addr, ip->i_addr);
+ ip->i_entries, ds.entry_count, ip->i_num.in_addr, ip->i_num.in_addr);
if (query(_("Fix the entry count? (y/n) "))) {
ip->i_entries = ds.entry_count;
bmodified(ip->i_bh);
@@ -2172,7 +2154,7 @@ int pass2(struct gfs2_sbd *sdp)
/* If we created lost+found, its links should have been
properly adjusted, so don't check it. */
- if (lf_was_created && (dirblk == lf_dip->i_addr)) {
+ if (lf_was_created && (dirblk == lf_dip->i_num.in_addr)) {
log_debug(_("Pass2 skipping the new lost+found.\n"));
continue;
}
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index f96881f5..fa2fd388 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -40,8 +40,7 @@ static int attach_dotdot_to(struct gfs2_sbd *sdp, uint64_t newdotdot,
log_warn( _("Unable to remove \"..\" directory entry.\n"));
else
decr_link_count(olddotdot, block, sdp->gfs1, _("old \"..\""));
- no.in_addr = pip->i_addr;
- no.in_formal_ino = pip->i_formal_ino;
+ no = pip->i_num;
err = dir_add(ip, filename, filename_len, &no,
(sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
if (err) {
@@ -166,38 +165,38 @@ int pass3(struct gfs2_sbd *sdp)
struct gfs2_inode *ip;
int q;
- di = dirtree_find(sdp->md.rooti->i_addr);
+ di = dirtree_find(sdp->md.rooti->i_num.in_addr);
if (di) {
log_info( _("Marking root inode connected\n"));
di->checked = 1;
}
if (sdp->gfs1) {
- di = dirtree_find(sdp->md.statfs->i_addr);
+ di = dirtree_find(sdp->md.statfs->i_num.in_addr);
if (di) {
log_info( _("Marking GFS1 statfs file inode "
"connected\n"));
di->checked = 1;
}
- di = dirtree_find(sdp->md.jiinode->i_addr);
+ di = dirtree_find(sdp->md.jiinode->i_num.in_addr);
if (di) {
log_info( _("Marking GFS1 jindex file inode "
"connected\n"));
di->checked = 1;
}
- di = dirtree_find(sdp->md.riinode->i_addr);
+ di = dirtree_find(sdp->md.riinode->i_num.in_addr);
if (di) {
log_info( _("Marking GFS1 rindex file inode "
"connected\n"));
di->checked = 1;
}
- di = dirtree_find(sdp->md.qinode->i_addr);
+ di = dirtree_find(sdp->md.qinode->i_num.in_addr);
if (di) {
log_info( _("Marking GFS1 quota file inode "
"connected\n"));
di->checked = 1;
}
} else {
- di = dirtree_find(sdp->master_dir->i_addr);
+ di = dirtree_find(sdp->master_dir->i_num.in_addr);
if (di) {
log_info( _("Marking master directory inode "
"connected\n"));
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index 4deac26c..0891e143 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -29,14 +29,14 @@ struct metawalk_fxns pass4_fxns_delete = {
static int fix_link_count(uint32_t counted_links, struct gfs2_inode *ip)
{
log_info(_("Fixing inode link count (%d->%d) for %"PRIu64" (0x%"PRIx64") \n"),
- ip->i_nlink, counted_links, ip->i_addr, ip->i_addr);
+ ip->i_nlink, counted_links, ip->i_num.in_addr, ip->i_num.in_addr);
if (ip->i_nlink == counted_links)
return 0;
ip->i_nlink = counted_links;
bmodified(ip->i_bh);
log_debug(_("Changing inode %"PRIu64" (0x%"PRIx64") to have %u links\n"),
- ip->i_addr, ip->i_addr, counted_links);
+ ip->i_num.in_addr, ip->i_num.in_addr, counted_links);
return 0;
}
@@ -161,7 +161,7 @@ static int adjust_lf_links(int lf_addition)
if (!lf_addition)
return 0;
- if (!(lf_di = dirtree_find(lf_dip->i_addr))) {
+ if (!(lf_di = dirtree_find(lf_dip->i_num.in_addr))) {
log_crit(_("Unable to find lost+found inode in "
"inode_hash!!\n"));
return -1;
@@ -186,9 +186,9 @@ static int scan_inode_list(struct gfs2_sbd *sdp)
ii = (struct inode_info *)tmp;
/* Don't check reference counts on the special gfs files */
if (sdp->gfs1 &&
- ((ii->num.in_addr == sdp->md.riinode->i_addr) ||
- (ii->num.in_addr == sdp->md.qinode->i_addr) ||
- (ii->num.in_addr == sdp->md.statfs->i_addr)))
+ ((ii->num.in_addr == sdp->md.riinode->i_num.in_addr) ||
+ (ii->num.in_addr == sdp->md.qinode->i_num.in_addr) ||
+ (ii->num.in_addr == sdp->md.statfs->i_num.in_addr)))
continue;
if (ii->counted_links == 0) {
if (handle_unlinked(sdp, ii->num.in_addr,
@@ -222,7 +222,7 @@ static int scan_dir_list(struct gfs2_sbd *sdp)
di = (struct dir_info *)tmp;
/* Don't check reference counts on the special gfs files */
if (sdp->gfs1 &&
- di->dinode.in_addr == sdp->md.jiinode->i_addr)
+ di->dinode.in_addr == sdp->md.jiinode->i_num.in_addr)
continue;
if (di->counted_links == 0) {
if (handle_unlinked(sdp, di->dinode.in_addr,
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 9d165083..da62cc47 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -59,7 +59,7 @@ static void find_journaled_rgs(struct gfs2_sbd *sdp)
for (j = 0; j < sdp->md.journals; j++) {
ip = sdp->md.journal[j];
log_debug(_("Checking for rgrps in journal%d which starts at block 0x%"PRIx64".\n"),
- j, ip->i_addr);
+ j, ip->i_num.in_addr);
jblocks = ip->i_size / sdp->sd_bsize;
false_count = 0;
for (b = 0; b < jblocks; b++) {
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 29b3ce81..762266df 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -51,7 +51,8 @@ void big_file_comfort(struct gfs2_inode *ip, uint64_t blks_checked)
percent = (blks_checked * 100) / ip->i_blocks;
log_notice(_("\rChecking %"PRIu64"%c of %"PRIu64"%c of file at %"PRIu64" (0x%"PRIx64")"
"- %"PRIu64" percent complete. \r"),
- chksize, human_abbrev[cs], fsize, human_abbrev[i], ip->i_addr, ip->i_addr, percent);
+ chksize, human_abbrev[cs], fsize, human_abbrev[i], ip->i_num.in_addr,
+ ip->i_num.in_addr, percent);
fflush(stdout);
}
@@ -277,13 +278,13 @@ struct inode_with_dups *find_dup_ref_inode(struct duptree *dt,
osi_list_foreach(ref, &dt->ref_invinode_list) {
id = osi_list_entry(ref, struct inode_with_dups, list);
- if (id->block_no == ip->i_addr)
+ if (id->block_no == ip->i_num.in_addr)
return id;
}
osi_list_foreach(ref, &dt->ref_inode_list) {
id = osi_list_entry(ref, struct inode_with_dups, list);
- if (id->block_no == ip->i_addr)
+ if (id->block_no == ip->i_num.in_addr)
return id;
}
return NULL;
@@ -363,7 +364,7 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
(unsigned long long)block);
log_info(_("I'll consider the reference from inode %"PRIu64
" (0x%"PRIx64") the first reference.\n"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
dt->dup_flags |= DUPFLAG_REF1_IS_DUPL;
dt->refs++;
}
@@ -388,8 +389,8 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
log_crit( _("Unable to allocate inode_with_dups structure\n"));
return META_ERROR;
}
- id->block_no = ip->i_addr;
- q = bitmap_type(ip->i_sbd, ip->i_addr);
+ id->block_no = ip->i_num.in_addr;
+ q = bitmap_type(ip->i_sbd, ip->i_num.in_addr);
/* If it's an invalid dinode, put it first on the invalid
inode reference list otherwise put it on the normal list. */
if (!inode_valid || q == GFS2_BLKST_UNLINKED)
@@ -413,7 +414,7 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
"as %s in %s inode #%"PRIu64" (0x%"PRIx64")\n"),
id->dup_count, block, block, reftypes[reftype],
inode_valid ? _("valid") : _("invalid"),
- ip->i_addr, ip->i_addr);
+ ip->i_num.in_addr, ip->i_num.in_addr);
if (first)
log_info( _("This is the original reference.\n"));
else {
@@ -609,14 +610,14 @@ void delete_all_dups(struct gfs2_inode *ip)
osi_list_foreach_safe(tmp, &dt->ref_invinode_list, x) {
id = osi_list_entry(tmp, struct inode_with_dups, list);
- if (id->block_no == ip->i_addr) {
+ if (id->block_no == ip->i_num.in_addr) {
dup_listent_delete(dt, id);
found = 1;
}
}
osi_list_foreach_safe(tmp, &dt->ref_inode_list, x) {
id = osi_list_entry(tmp, struct inode_with_dups, list);
- if (id->block_no == ip->i_addr) {
+ if (id->block_no == ip->i_num.in_addr) {
dup_listent_delete(dt, id);
found = 1;
}
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index 182868a6..d56bb24b 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -95,7 +95,7 @@ static inline int is_dir(struct gfs2_inode *ip, int gfs1)
static inline uint32_t gfs_to_gfs2_mode(struct gfs2_inode *ip)
{
- uint16_t gfs1mode = ip->i_pad1;
+ uint16_t gfs1mode = ip->i_di_type;
switch (gfs1mode) {
case GFS_FILE_DIR:
diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
index e7282517..437ee0ba 100644
--- a/gfs2/glocktop/glocktop.c
+++ b/gfs2/glocktop/glocktop.c
@@ -635,13 +635,13 @@ static const char *show_inode(const char *id, int fd, unsigned long long block)
if (error)
break;
/* Stop at the root inode */
- if (ip->i_addr == parent->i_addr) {
+ if (ip->i_num.in_addr == parent->i_num.in_addr) {
inode_put(&parent);
break;
}
inode_put(&ip);
ip = parent;
- dirarray[subdepth++] = parent->i_addr;
+ dirarray[subdepth++] = parent->i_num.in_addr;
}
display_filename(fd, block, dirarray, subdepth);
} else if (S_ISREG(ip->i_mode)) {
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index dae6d1b7..e533b9de 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -64,25 +64,25 @@ struct gfs2_inode *is_system_inode(struct gfs2_sbd *sdp, uint64_t block)
{
int j;
- if (sdp->md.inum && block == sdp->md.inum->i_addr)
+ if (sdp->md.inum && block == sdp->md.inum->i_num.in_addr)
return sdp->md.inum;
- if (sdp->md.statfs && block == sdp->md.statfs->i_addr)
+ if (sdp->md.statfs && block == sdp->md.statfs->i_num.in_addr)
return sdp->md.statfs;
- if (sdp->md.jiinode && block == sdp->md.jiinode->i_addr)
+ if (sdp->md.jiinode && block == sdp->md.jiinode->i_num.in_addr)
return sdp->md.jiinode;
- if (sdp->md.riinode && block == sdp->md.riinode->i_addr)
+ if (sdp->md.riinode && block == sdp->md.riinode->i_num.in_addr)
return sdp->md.riinode;
- if (sdp->md.qinode && block == sdp->md.qinode->i_addr)
+ if (sdp->md.qinode && block == sdp->md.qinode->i_num.in_addr)
return sdp->md.qinode;
- if (sdp->md.pinode && block == sdp->md.pinode->i_addr)
+ if (sdp->md.pinode && block == sdp->md.pinode->i_num.in_addr)
return sdp->md.pinode;
- if (sdp->md.rooti && block == sdp->md.rooti->i_addr)
+ if (sdp->md.rooti && block == sdp->md.rooti->i_num.in_addr)
return sdp->md.rooti;
- if (sdp->master_dir && block == sdp->master_dir->i_addr)
+ if (sdp->master_dir && block == sdp->master_dir->i_num.in_addr)
return sdp->master_dir;
for (j = 0; j < sdp->md.journals; j++)
if (sdp->md.journal && sdp->md.journal[j] &&
- block == sdp->md.journal[j]->i_addr)
+ block == sdp->md.journal[j]->i_num.in_addr)
return sdp->md.journal[j];
return NULL;
}
@@ -90,7 +90,7 @@ struct gfs2_inode *is_system_inode(struct gfs2_sbd *sdp, uint64_t block)
void inode_put(struct gfs2_inode **ip_in)
{
struct gfs2_inode *ip = *ip_in;
- uint64_t block = ip->i_addr;
+ uint64_t block = ip->i_num.in_addr;
struct gfs2_sbd *sdp = ip->i_sbd;
if (ip->i_bh->b_modified) {
@@ -318,8 +318,8 @@ int lgfs2_file_alloc(lgfs2_rgrp_t rg, uint64_t di_size, struct gfs2_inode *ip, u
struct lgfs2_rbm rbm = { .rgd = rg, .offset = 0, .bii = 0 };
uint32_t blocks = lgfs2_space_for_data(sdp, sdp->sd_bsize, di_size);
- if (ip->i_addr != 0) {
- if (lgfs2_rbm_from_block(&rbm, ip->i_addr) != 0)
+ if (ip->i_num.in_addr != 0) {
+ if (lgfs2_rbm_from_block(&rbm, ip->i_num.in_addr) != 0)
return 1;
} else if (lgfs2_rbm_find(&rbm, GFS2_BLKST_FREE, &blocks) != 0) {
return 1;
@@ -334,16 +334,16 @@ int lgfs2_file_alloc(lgfs2_rgrp_t rg, uint64_t di_size, struct gfs2_inode *ip, u
ip->i_sbd = sdp;
ip->i_magic = GFS2_MAGIC;
- ip->i_type = GFS2_METATYPE_DI;
+ ip->i_mh_type = GFS2_METATYPE_DI;
ip->i_format = GFS2_FORMAT_DI;
ip->i_size = di_size;
- ip->i_addr = lgfs2_rbm_to_block(&rbm);
- ip->i_formal_ino = sdp->md.next_inum++;
+ ip->i_num.in_addr = lgfs2_rbm_to_block(&rbm);
+ ip->i_num.in_formal_ino = sdp->md.next_inum++;
ip->i_mode = mode;
ip->i_nlink = 1;
ip->i_blocks = blocks;
ip->i_atime = ip->i_mtime = ip->i_ctime = sdp->time;
- ip->i_goal_data = ip->i_addr + ip->i_blocks - 1;
+ ip->i_goal_data = ip->i_num.in_addr + ip->i_blocks - 1;
ip->i_goal_meta = ip->i_goal_data - ((di_size + sdp->sd_bsize - 1) / sdp->sd_bsize);
ip->i_height = calc_tree_height(ip, di_size);
ip->i_flags = flags;
@@ -485,7 +485,7 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
if (inode_is_stuffed(ip)) {
if (!lblock) {
- *dblock = ip->i_addr;
+ *dblock = ip->i_num.in_addr;
if (extlen)
*extlen = 1;
}
@@ -524,7 +524,7 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
} else {
- if (*dblock == ip->i_addr)
+ if (*dblock == ip->i_num.in_addr)
bh = ip->i_bh;
else
bh = bread(sdp, *dblock);
@@ -626,7 +626,7 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
}
if (dblock) {
- if (dblock == ip->i_addr)
+ if (dblock == ip->i_num.in_addr)
bh = ip->i_bh;
else
bh = bread(sdp, dblock);
@@ -718,7 +718,7 @@ int __gfs2_writei(struct gfs2_inode *ip, void *buf,
bmodified(bh);
}
} else {
- if (dblock == ip->i_addr)
+ if (dblock == ip->i_num.in_addr)
bh = ip->i_bh;
else
bh = bread(sdp, dblock);
@@ -1002,7 +1002,7 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
oleaf->lf_depth = cpu_to_be16(oleaf->lf_depth);
nleaf->lf_depth = oleaf->lf_depth;
- nleaf->lf_inode = cpu_to_be64(dip->i_addr);
+ nleaf->lf_inode = cpu_to_be64(dip->i_num.in_addr);
dip->i_blocks++;
bmodified(dip->i_bh);
@@ -1202,7 +1202,7 @@ restart:
nleaf = (struct gfs2_leaf *)nbh->b_data;
nleaf->lf_depth = leaf->lf_depth;
nleaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE);
- nleaf->lf_inode = cpu_to_be64(dip->i_addr);
+ nleaf->lf_inode = cpu_to_be64(dip->i_num.in_addr);
err = dirent_alloc(dip, nbh, len, &dent);
if (err)
return err;
@@ -1255,7 +1255,7 @@ static void dir_make_exhash(struct gfs2_inode *dip)
leaf = (struct gfs2_leaf *)bh->b_data;
leaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE);
leaf->lf_entries = cpu_to_be16(dip->i_entries);
- leaf->lf_inode = cpu_to_be64(dip->i_addr);
+ leaf->lf_inode = cpu_to_be64(dip->i_num.in_addr);
buffer_copy_tail(sdp, bh, sizeof(struct gfs2_leaf),
dip->i_bh, sizeof(struct gfs2_dinode));
@@ -1436,14 +1436,14 @@ int lgfs2_write_filemeta(struct gfs2_inode *ip)
struct metapath mp;
struct gfs2_sbd *sdp = ip->i_sbd;
uint64_t dblocks = (ip->i_size + sdp->sd_bsize - 1) / sdp->sd_bsize;
- uint64_t ptr0 = ip->i_addr + 1;
+ uint64_t ptr0 = ip->i_num.in_addr + 1;
unsigned ptrs = 1;
struct gfs2_meta_header mh = {
.mh_magic = cpu_to_be32(GFS2_MAGIC),
.mh_type = cpu_to_be32(GFS2_METATYPE_IN),
.mh_format = cpu_to_be32(GFS2_FORMAT_IN)
};
- struct gfs2_buffer_head *bh = bget(sdp, ip->i_addr);
+ struct gfs2_buffer_head *bh = bget(sdp, ip->i_num.in_addr);
if (bh == NULL)
return 1;
@@ -1495,10 +1495,8 @@ static struct gfs2_inode *__createi(struct gfs2_inode *dip,
gfs2_lookupi(dip, filename, strlen(filename), &ip);
if (!ip) {
- struct lgfs2_inum parent = {
- .in_formal_ino = dip->i_formal_ino,
- .in_addr = dip->i_addr,
- };
+ struct lgfs2_inum parent = dip->i_num;
+
err = lgfs2_dinode_alloc(sdp, 1, &bn);
if (err != 0)
return NULL;
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 10a196df..feb8d22a 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -33,7 +33,7 @@ gfs1_metapointer(char *buf, unsigned int height, struct metapath *mp)
int is_gfs_dir(struct gfs2_inode *ip)
{
- if (ip->i_pad1 == GFS_FILE_DIR)
+ if (ip->i_di_type == GFS_FILE_DIR)
return 1;
return 0;
}
@@ -86,7 +86,7 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
if (!ip->i_height) { /* stuffed */
if (!lblock) {
- *dblock = ip->i_addr;
+ *dblock = ip->i_num.in_addr;
if (extlen)
*extlen = 1;
}
@@ -125,7 +125,7 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
} else {
- if (*dblock == ip->i_addr)
+ if (*dblock == ip->i_num.in_addr)
bh = ip->i_bh;
else
bh = bread(sdp, *dblock);
@@ -208,12 +208,12 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
return -1;
}
- if (dblock == ip->i_addr)
+ if (dblock == ip->i_num.in_addr)
bh = ip->i_bh;
else
bh = bread(sdp, dblock);
- if (journaled && dblock != ip->i_addr ) {
+ if (journaled && dblock != ip->i_num.in_addr ) {
struct gfs2_meta_header mh = {
.mh_magic = cpu_to_be32(GFS2_MAGIC),
.mh_type = cpu_to_be32(GFS2_METATYPE_JD),
@@ -256,10 +256,10 @@ static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp, char *buf)
}
di = (struct gfs_dinode *)buf;
ip->i_magic = be32_to_cpu(di->di_header.mh_magic);
- ip->i_type = be32_to_cpu(di->di_header.mh_type);
+ ip->i_mh_type = be32_to_cpu(di->di_header.mh_type);
ip->i_format = be32_to_cpu(di->di_header.mh_format);
- ip->i_formal_ino = be64_to_cpu(di->di_num.no_formal_ino);
- ip->i_addr = be64_to_cpu(di->di_num.no_addr);
+ ip->i_num.in_formal_ino = be64_to_cpu(di->di_num.no_formal_ino);
+ ip->i_num.in_addr = be64_to_cpu(di->di_num.no_addr);
ip->i_mode = be32_to_cpu(di->di_mode);
ip->i_uid = be32_to_cpu(di->di_uid);
ip->i_gid = be32_to_cpu(di->di_gid);
@@ -275,7 +275,7 @@ static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp, char *buf)
ip->i_goal_meta = (uint64_t)be32_to_cpu(di->di_goal_mblk);
ip->i_flags = be32_to_cpu(di->di_flags);
ip->i_payload_format = be32_to_cpu(di->di_payload_format);
- ip->i_pad1 = be16_to_cpu(di->di_type);
+ ip->i_di_type = be16_to_cpu(di->di_type);
ip->i_height = be16_to_cpu(di->di_height);
ip->i_depth = be16_to_cpu(di->di_depth);
ip->i_entries = be32_to_cpu(di->di_entries);
diff --git a/gfs2/libgfs2/gfs2l.c b/gfs2/libgfs2/gfs2l.c
index 2872d70e..15dcd25d 100644
--- a/gfs2/libgfs2/gfs2l.c
+++ b/gfs2/libgfs2/gfs2l.c
@@ -131,7 +131,7 @@ static int openfs(const char *path, struct gfs2_sbd *sdp)
return 1;
}
- sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.no_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.in_addr);
gfs2_lookupi(sdp->master_dir, "rindex", 6, &sdp->md.riinode);
sdp->fssize = sdp->device.length;
if (sdp->md.riinode) {
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index f0870457..740d1a7b 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -158,11 +158,11 @@ static uint64_t ast_lookup_path(char *path, struct gfs2_sbd *sbd)
uint64_t bn = 0;
segment = strtok_r(path, "/", &c);
- ip = lgfs2_inode_read(sbd, sbd->sd_root_dir.no_addr);
+ ip = lgfs2_inode_read(sbd, sbd->sd_root_dir.in_addr);
while (ip != NULL) {
if (segment == NULL) { // No more segments
- bn = ip->i_addr;
+ bn = ip->i_num.in_addr;
inode_put(&ip);
return bn;
}
@@ -215,13 +215,13 @@ static uint64_t ast_lookup_id(const char *id, struct gfs2_sbd *sbd)
bn = LGFS2_SB_ADDR(sbd);
break;
case ID_MASTER:
- bn = sbd->sd_meta_dir.no_addr;
+ bn = sbd->sd_meta_dir.in_addr;
break;
case ID_ROOT:
- bn = sbd->sd_root_dir.no_addr;
+ bn = sbd->sd_root_dir.in_addr;
break;
case ID_RINDEX:
- bn = sbd->md.riinode->i_addr;
+ bn = sbd->md.riinode->i_num.in_addr;
break;
default:
return 0;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index ad9b5651..b343b64e 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -242,6 +242,11 @@ struct gfs2_buffer_head {
int b_modified;
};
+struct lgfs2_inum {
+ uint64_t in_formal_ino;
+ uint64_t in_addr;
+};
+
struct gfs2_inode {
struct gfs2_buffer_head *i_bh;
struct gfs2_sbd *i_sbd;
@@ -250,10 +255,9 @@ struct gfs2_inode {
/* Native-endian versions of the dinode fields */
uint32_t i_magic;
- uint32_t i_type;
+ uint32_t i_mh_type;
uint32_t i_format;
- uint64_t i_formal_ino;
- uint64_t i_addr;
+ struct lgfs2_inum i_num;
uint32_t i_mode;
uint32_t i_uid;
uint32_t i_gid;
@@ -265,23 +269,32 @@ struct gfs2_inode {
uint64_t i_ctime;
uint32_t i_major;
uint32_t i_minor;
- uint64_t i_goal_meta;
- uint64_t i_goal_data;
- uint64_t i_generation;
+
uint32_t i_flags;
uint32_t i_payload_format;
- uint16_t i_pad1;
uint16_t i_height;
- uint32_t i_pad2;
- uint16_t i_pad3;
uint16_t i_depth;
uint32_t i_entries;
- uint64_t i_pad4_addr;
- uint64_t i_pad4_formal_ino;
uint64_t i_eattr;
- uint32_t i_atime_nsec;
- uint32_t i_mtime_nsec;
- uint32_t i_ctime_nsec;
+ union {
+ struct { /* gfs2 */
+ uint64_t i_goal_meta;
+ uint64_t i_goal_data;
+ uint64_t i_generation;
+ uint32_t i_atime_nsec;
+ uint32_t i_mtime_nsec;
+ uint32_t i_ctime_nsec;
+ };
+ struct { /* gfs */
+ uint64_t i_rgrp;
+ uint32_t i_goal_rgrp;
+ uint32_t i_goal_dblk;
+ uint32_t i_goal_mblk;
+ uint16_t i_di_type;
+ uint32_t i_incarn;
+ struct lgfs2_inum i_next_unused;
+ };
+ };
};
struct master_dir
@@ -307,15 +320,12 @@ struct gfs2_sbd {
uint32_t sd_fs_format;
uint32_t sd_multihost_format;
uint32_t sd_flags; /* gfs1 */
- struct {
- uint64_t no_formal_ino;
- uint64_t no_addr;
- } sd_meta_dir,
- sd_root_dir,
- sd_rindex_di, /* gfs1 */
- sd_jindex_di, /* gfs1 */
- sd_quota_di, /* gfs1 */
- sd_license_di; /* gfs1 */
+ struct lgfs2_inum sd_meta_dir;
+ struct lgfs2_inum sd_root_dir;
+ struct lgfs2_inum sd_rindex_di; /* gfs1 */
+ struct lgfs2_inum sd_jindex_di; /* gfs1 */
+ struct lgfs2_inum sd_quota_di; /* gfs1 */
+ struct lgfs2_inum sd_license_di; /* gfs1 */
uint32_t sd_bsize_shift;
uint32_t sd_seg_size;
char sd_lockproto[GFS2_LOCKNAME_LEN];
@@ -370,11 +380,6 @@ struct gfs2_sbd {
int gfs1;
};
-struct lgfs2_inum {
- uint64_t in_formal_ino;
- uint64_t in_addr;
-};
-
struct lgfs2_log_header {
uint64_t lh_sequence;
uint32_t lh_flags;
@@ -803,7 +808,7 @@ extern void print_it(const char *label, const char *fmt, const char *fmt2, ...)
/* Translation functions */
extern void lgfs2_inum_in(struct lgfs2_inum *i, void *inp);
-extern void lgfs2_inum_out(struct lgfs2_inum *i, void *inp);
+extern void lgfs2_inum_out(const struct lgfs2_inum *i, void *inp);
extern void lgfs2_sb_in(struct gfs2_sbd *sdp, void *buf);
extern void lgfs2_sb_out(const struct gfs2_sbd *sdp, void *buf);
extern void lgfs2_rindex_in(lgfs2_rgrp_t rg, void *buf);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 2f09713c..3dea69ce 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -30,7 +30,7 @@ void lgfs2_inum_in(struct lgfs2_inum *i, void *inp)
i->in_addr = be64_to_cpu(in->no_addr);
}
-void lgfs2_inum_out(struct lgfs2_inum *i, void *inp)
+void lgfs2_inum_out(const struct lgfs2_inum *i, void *inp)
{
struct gfs2_inum *in = inp;
@@ -66,18 +66,13 @@ void lgfs2_sb_in(struct gfs2_sbd *sdp, void *buf)
sdp->sd_bsize = be32_to_cpu(sb->sb_bsize);
sdp->sd_bsize_shift = be32_to_cpu(sb->sb_bsize_shift);
sdp->sd_seg_size = be32_to_cpu(sb1->sb_seg_size);
- sdp->sd_meta_dir.no_formal_ino = be64_to_cpu(sb->sb_master_dir.no_formal_ino);
- sdp->sd_meta_dir.no_addr = be64_to_cpu(sb->sb_master_dir.no_addr);
- sdp->sd_root_dir.no_formal_ino = be64_to_cpu(sb->sb_root_dir.no_formal_ino);
- sdp->sd_root_dir.no_addr = be64_to_cpu(sb->sb_root_dir.no_addr);
+ lgfs2_inum_in(&sdp->sd_meta_dir, &sb->sb_master_dir);
+ lgfs2_inum_in(&sdp->sd_root_dir, &sb->sb_root_dir);
memcpy(sdp->sd_lockproto, sb->sb_lockproto, GFS2_LOCKNAME_LEN);
memcpy(sdp->sd_locktable, sb->sb_locktable, GFS2_LOCKNAME_LEN);
- sdp->sd_rindex_di.no_formal_ino = be64_to_cpu(sb1->sb_rindex_di.no_formal_ino);
- sdp->sd_rindex_di.no_addr = be64_to_cpu(sb1->sb_rindex_di.no_addr);
- sdp->sd_quota_di.no_formal_ino = be64_to_cpu(sb1->sb_quota_di.no_formal_ino);
- sdp->sd_quota_di.no_addr = be64_to_cpu(sb1->sb_quota_di.no_addr);
- sdp->sd_license_di.no_formal_ino = be64_to_cpu(sb1->sb_license_di.no_formal_ino);
- sdp->sd_license_di.no_addr = be64_to_cpu(sb1->sb_license_di.no_addr);
+ lgfs2_inum_in(&sdp->sd_rindex_di, &sb1->sb_rindex_di);
+ lgfs2_inum_in(&sdp->sd_quota_di, &sb1->sb_quota_di);
+ lgfs2_inum_in(&sdp->sd_license_di, &sb1->sb_license_di);
memcpy(sdp->sd_uuid, sb->sb_uuid, sizeof(sdp->sd_uuid));
}
@@ -95,18 +90,13 @@ void lgfs2_sb_out(const struct gfs2_sbd *sdp, void *buf)
sb->sb_bsize = cpu_to_be32(sdp->sd_bsize);
sb->sb_bsize_shift = cpu_to_be32(sdp->sd_bsize_shift);
sb1->sb_seg_size = cpu_to_be32(sdp->sd_seg_size);
- sb->sb_master_dir.no_formal_ino = cpu_to_be64(sdp->sd_meta_dir.no_formal_ino);
- sb->sb_master_dir.no_addr = cpu_to_be64(sdp->sd_meta_dir.no_addr);
- sb->sb_root_dir.no_formal_ino = cpu_to_be64(sdp->sd_root_dir.no_formal_ino);
- sb->sb_root_dir.no_addr = cpu_to_be64(sdp->sd_root_dir.no_addr);
+ lgfs2_inum_out(&sdp->sd_meta_dir, &sb->sb_master_dir);
+ lgfs2_inum_out(&sdp->sd_root_dir, &sb->sb_root_dir);
memcpy(sb->sb_lockproto, sdp->sd_lockproto, GFS2_LOCKNAME_LEN);
memcpy(sb->sb_locktable, sdp->sd_locktable, GFS2_LOCKNAME_LEN);
- sb1->sb_rindex_di.no_formal_ino = cpu_to_be64(sdp->sd_rindex_di.no_formal_ino);
- sb1->sb_rindex_di.no_addr = cpu_to_be64(sdp->sd_rindex_di.no_addr);
- sb1->sb_quota_di.no_formal_ino = cpu_to_be64(sdp->sd_quota_di.no_formal_ino);
- sb1->sb_quota_di.no_addr = cpu_to_be64(sdp->sd_quota_di.no_addr);
- sb1->sb_license_di.no_formal_ino = cpu_to_be64(sdp->sd_license_di.no_formal_ino);
- sb1->sb_license_di.no_addr = cpu_to_be64(sdp->sd_license_di.no_addr);
+ lgfs2_inum_out(&sdp->sd_rindex_di, &sb1->sb_rindex_di);
+ lgfs2_inum_out(&sdp->sd_quota_di, &sb1->sb_quota_di);
+ lgfs2_inum_out(&sdp->sd_license_di, &sb1->sb_license_di);
memcpy(sb->sb_uuid, sdp->sd_uuid, 16);
}
@@ -223,10 +213,9 @@ void lgfs2_dinode_in(struct gfs2_inode *ip, char *buf)
struct gfs2_dinode *di = (struct gfs2_dinode *)buf;
ip->i_magic = be32_to_cpu(di->di_header.mh_magic);
- ip->i_type = be32_to_cpu(di->di_header.mh_type);
+ ip->i_mh_type = be32_to_cpu(di->di_header.mh_type);
ip->i_format = be32_to_cpu(di->di_header.mh_format);
- ip->i_formal_ino = be64_to_cpu(di->di_num.no_formal_ino);
- ip->i_addr = be64_to_cpu(di->di_num.no_addr);
+ lgfs2_inum_in(&ip->i_num, &di->di_num);
ip->i_mode = be32_to_cpu(di->di_mode);
ip->i_uid = be32_to_cpu(di->di_uid);
ip->i_gid = be32_to_cpu(di->di_gid);
@@ -243,14 +232,9 @@ void lgfs2_dinode_in(struct gfs2_inode *ip, char *buf)
ip->i_generation = be64_to_cpu(di->di_generation);
ip->i_flags = be32_to_cpu(di->di_flags);
ip->i_payload_format = be32_to_cpu(di->di_payload_format);
- ip->i_pad1 = be16_to_cpu(di->__pad1);
ip->i_height = be16_to_cpu(di->di_height);
- ip->i_pad2 = be32_to_cpu(di->__pad2);
- ip->i_pad3 = be16_to_cpu(di->__pad3);
ip->i_depth = be16_to_cpu(di->di_depth);
ip->i_entries = be32_to_cpu(di->di_entries);
- ip->i_pad4_addr = be64_to_cpu(di->__pad4.no_addr);
- ip->i_pad4_formal_ino = be64_to_cpu(di->__pad4.no_formal_ino);
ip->i_eattr = be64_to_cpu(di->di_eattr);
ip->i_atime_nsec = be32_to_cpu(di->di_atime_nsec);
ip->i_mtime_nsec = be32_to_cpu(di->di_mtime_nsec);
@@ -262,10 +246,9 @@ void lgfs2_dinode_out(struct gfs2_inode *ip, char *buf)
struct gfs2_dinode *di = (struct gfs2_dinode *)buf;
di->di_header.mh_magic = cpu_to_be32(ip->i_magic);
- di->di_header.mh_type = cpu_to_be32(ip->i_type);
+ di->di_header.mh_type = cpu_to_be32(ip->i_mh_type);
di->di_header.mh_format = cpu_to_be32(ip->i_format);
- di->di_num.no_formal_ino = cpu_to_be64(ip->i_formal_ino);
- di->di_num.no_addr = cpu_to_be64(ip->i_addr);
+ lgfs2_inum_out(&ip->i_num, &di->di_num);
di->di_mode = cpu_to_be32(ip->i_mode);
di->di_uid = cpu_to_be32(ip->i_uid);
di->di_gid = cpu_to_be32(ip->i_gid);
@@ -277,23 +260,14 @@ void lgfs2_dinode_out(struct gfs2_inode *ip, char *buf)
di->di_ctime = cpu_to_be64(ip->i_ctime);
di->di_major = cpu_to_be32(ip->i_major);
di->di_minor = cpu_to_be32(ip->i_minor);
-
di->di_goal_meta = cpu_to_be64(ip->i_goal_meta);
di->di_goal_data = cpu_to_be64(ip->i_goal_data);
di->di_generation = cpu_to_be64(ip->i_generation);
-
di->di_flags = cpu_to_be32(ip->i_flags);
di->di_payload_format = cpu_to_be32(ip->i_payload_format);
- di->__pad1 = cpu_to_be16(ip->i_pad1);
di->di_height = cpu_to_be16(ip->i_height);
- di->__pad2 = cpu_to_be32(ip->i_pad2);
- di->__pad3 = cpu_to_be16(ip->i_pad3);
di->di_depth = cpu_to_be16(ip->i_depth);
di->di_entries = cpu_to_be32(ip->i_entries);
-
- di->__pad4.no_addr = cpu_to_be64(ip->i_pad4_addr);
- di->__pad4.no_formal_ino = cpu_to_be64(ip->i_pad4_formal_ino);
-
di->di_eattr = cpu_to_be64(ip->i_eattr);
di->di_atime_nsec = cpu_to_be32(ip->i_atime_nsec);
di->di_mtime_nsec = cpu_to_be32(ip->i_mtime_nsec);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 9dcf237f..ae5de7e1 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -110,7 +110,7 @@ int lgfs2_write_journal_data(struct gfs2_inode *ip)
{
struct gfs2_sbd *sdp = ip->i_sbd;
unsigned blocks = (ip->i_size + sdp->sd_bsize - 1) / sdp->sd_bsize;
- uint64_t jext0 = ip->i_addr + ip->i_blocks - blocks;
+ uint64_t jext0 = ip->i_num.in_addr + ip->i_blocks - blocks;
uint64_t seq = ((blocks) * (random() / (RAND_MAX + 1.0)));
struct gfs2_log_header *lh;
uint64_t jblk = jext0;
@@ -125,7 +125,7 @@ int lgfs2_write_journal_data(struct gfs2_inode *ip)
lh->lh_header.mh_type = cpu_to_be32(GFS2_METATYPE_LH);
lh->lh_header.mh_format = cpu_to_be32(GFS2_FORMAT_LH);
lh->lh_flags = cpu_to_be32(GFS2_LOG_HEAD_UNMOUNT | GFS2_LOG_HEAD_USERSPACE);
- lh->lh_jinode = cpu_to_be64(ip->i_addr);
+ lh->lh_jinode = cpu_to_be64(ip->i_num.in_addr);
crc32c_optimization_init();
do {
@@ -174,7 +174,7 @@ static struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn
bmodified(ip->i_bh);
ip->i_size = (lbn + 1) << sdp->sd_bsize_shift;
}
- if (dbn == ip->i_addr)
+ if (dbn == ip->i_num.in_addr)
return ip->i_bh;
else
return bread(sdp, dbn);
@@ -212,7 +212,7 @@ int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned int blocks)
lh->lh_header.mh_type = cpu_to_be32(GFS2_METATYPE_LH);
lh->lh_header.mh_format = cpu_to_be32(GFS2_FORMAT_LH);
lh->lh_flags = cpu_to_be32(GFS2_LOG_HEAD_UNMOUNT | GFS2_LOG_HEAD_USERSPACE);
- lh->lh_jinode = cpu_to_be64(jnl->i_addr);
+ lh->lh_jinode = cpu_to_be64(jnl->i_num.in_addr);
lh->lh_sequence = cpu_to_be64(seq);
lh->lh_blkno = cpu_to_be32(x);
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 8204d263..0f8e7d9e 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -421,7 +421,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
/* Get master dinode */
- sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.no_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.in_addr);
if (sdp->master_dir == NULL) {
perror(_("Could not read master directory"));
exit(EXIT_FAILURE);
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 551261b9..bca7b9d1 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -874,7 +874,7 @@ static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_o
}
/* Allocate at the beginning of the rgrp, bypassing extent search */
lgfs2_rindex_out(rg, &ri);
- in.i_addr = be64_to_cpu(ri.ri_data0);
+ in.i_num.in_addr = be64_to_cpu(ri.ri_data0);
/* In order to keep writes sequential here, we have to allocate
the journal, then write the rgrp header (which is now in its
final form) and then write the journal out */
@@ -901,8 +901,7 @@ static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_o
fprintf(stderr, _("Failed to write data blocks for journal %u\n"), j);
return result;
}
- mkfs_journals[j].in_addr = in.i_addr;
- mkfs_journals[j].in_formal_ino = in.i_formal_ino;
+ mkfs_journals[j] = in.i_num;
}
gfs2_progress_close(&progress, _("Done\n"));
@@ -1207,8 +1206,7 @@ int main(int argc, char *argv[])
fprintf(stderr, _("Error building '%s': %s\n"), "master", strerror(errno));
exit(EXIT_FAILURE);
}
- sbd.sd_meta_dir.no_addr = sbd.master_dir->i_addr;
- sbd.sd_meta_dir.no_formal_ino = sbd.master_dir->i_formal_ino;
+ sbd.sd_meta_dir = sbd.master_dir->i_num;
error = lgfs2_build_jindex(sbd.master_dir, mkfs_journals, opts.journals);
if (error) {
@@ -1251,8 +1249,7 @@ int main(int argc, char *argv[])
printf("%s", _("Done\n"));
build_root(&sbd);
- sbd.sd_root_dir.no_addr = sbd.md.rooti->i_addr;
- sbd.sd_root_dir.no_formal_ino = sbd.md.rooti->i_formal_ino;
+ sbd.sd_root_dir = sbd.md.rooti->i_num;
strncpy(sbd.sd_lockproto, opts.lockproto, GFS2_LOCKNAME_LEN - 1);
strncpy(sbd.sd_locktable, opts.locktable, GFS2_LOCKNAME_LEN - 1);
diff --git a/tests/nukerg.c b/tests/nukerg.c
index b5ddeb0b..399f7373 100644
--- a/tests/nukerg.c
+++ b/tests/nukerg.c
@@ -288,7 +288,7 @@ static int fill_super_block(struct gfs2_sbd *sdp)
perror("Failed to read superblock\n");
return 1;
}
- sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.no_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.in_addr);
if (sdp->master_dir == NULL) {
fprintf(stderr, "Failed to read master directory inode.\n");
return 1;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 30/40: libgfs2: Don't parse/write de_cookie
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 8bd2adc673d96061aeddafaded7e17509cdf0227
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Jun 10 10:39:42 2021 +0100
libgfs2: Don't parse/write de_cookie
It's really just an ephemeral placeholder.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/libgfs2.h | 1 -
gfs2/libgfs2/ondisk.c | 2 --
2 files changed, 3 deletions(-)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index ed643a09..ad9b5651 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -394,7 +394,6 @@ struct lgfs2_dirent {
uint16_t dr_name_len;
uint16_t dr_type;
uint16_t dr_rahead;
- uint32_t dr_cookie;
};
struct lgfs2_leaf {
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 4c0d65da..2f09713c 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -338,7 +338,6 @@ void lgfs2_dirent_in(struct lgfs2_dirent *d, void *dep)
d->dr_name_len = be16_to_cpu(de->de_name_len);
d->dr_type = be16_to_cpu(de->de_type);
d->dr_rahead = be16_to_cpu(de->de_rahead);
- d->dr_cookie = be32_to_cpu(de->de_cookie);
}
void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep)
@@ -351,7 +350,6 @@ void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep)
de->de_name_len = cpu_to_be16(d->dr_name_len);
de->de_type = cpu_to_be16(d->dr_type);
de->de_rahead = cpu_to_be16(d->dr_rahead);
- de->de_cookie = cpu_to_be32(d->dr_cookie);
}
void lgfs2_leaf_in(struct lgfs2_leaf *lf, void *lfp)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 29/40: libgfs2: Print di_size with the correct size
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit e11a74d95e3bb90398cc9e5f77660fbdac793b09
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Jun 10 09:56:05 2021 +0100
libgfs2: Print di_size with the correct size
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/ondisk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index ef6ae90a..4c0d65da 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -311,7 +311,7 @@ void lgfs2_dinode_print(void *dip)
printbe32(di, di_uid);
printbe32(di, di_gid);
printbe32(di, di_nlink);
- printbe32(di, di_size);
+ printbe64(di, di_size);
printbe64(di, di_blocks);
printbe64(di, di_atime);
printbe64(di, di_mtime);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 28/40: libgfs2: Fix endianness conversions for
superblock padding fields
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 540aa6450eed4fd2bec42edf1050adf202e1df9b
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jun 9 17:45:50 2021 +0100
libgfs2: Fix endianness conversions for superblock padding fields
Padding fields in struct gfs2_sb aren't bitwise-tagged so parse them
through a struct gfs_sb pointer.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/ondisk.c | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 21f6115e..ef6ae90a 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -58,53 +58,55 @@ void lgfs2_meta_header_print(void *mhp)
void lgfs2_sb_in(struct gfs2_sbd *sdp, void *buf)
{
struct gfs2_sb *sb = buf;
+ struct gfs_sb *sb1 = buf;
sdp->sd_fs_format = be32_to_cpu(sb->sb_fs_format);
sdp->sd_multihost_format = be32_to_cpu(sb->sb_multihost_format);
- sdp->sd_flags = be32_to_cpu(sb->__pad0);
+ sdp->sd_flags = be32_to_cpu(sb1->sb_flags);
sdp->sd_bsize = be32_to_cpu(sb->sb_bsize);
sdp->sd_bsize_shift = be32_to_cpu(sb->sb_bsize_shift);
- sdp->sd_seg_size = be32_to_cpu(sb->__pad1);
+ sdp->sd_seg_size = be32_to_cpu(sb1->sb_seg_size);
sdp->sd_meta_dir.no_formal_ino = be64_to_cpu(sb->sb_master_dir.no_formal_ino);
sdp->sd_meta_dir.no_addr = be64_to_cpu(sb->sb_master_dir.no_addr);
sdp->sd_root_dir.no_formal_ino = be64_to_cpu(sb->sb_root_dir.no_formal_ino);
sdp->sd_root_dir.no_addr = be64_to_cpu(sb->sb_root_dir.no_addr);
memcpy(sdp->sd_lockproto, sb->sb_lockproto, GFS2_LOCKNAME_LEN);
memcpy(sdp->sd_locktable, sb->sb_locktable, GFS2_LOCKNAME_LEN);
- sdp->sd_rindex_di.no_formal_ino = be64_to_cpu(sb->__pad2.no_formal_ino);
- sdp->sd_rindex_di.no_addr = be64_to_cpu(sb->__pad2.no_addr);
- sdp->sd_quota_di.no_formal_ino = be64_to_cpu(sb->__pad3.no_formal_ino);
- sdp->sd_quota_di.no_addr = be64_to_cpu(sb->__pad3.no_addr);
- sdp->sd_license_di.no_formal_ino = be64_to_cpu(sb->__pad4.no_formal_ino);
- sdp->sd_license_di.no_addr = be64_to_cpu(sb->__pad4.no_addr);
+ sdp->sd_rindex_di.no_formal_ino = be64_to_cpu(sb1->sb_rindex_di.no_formal_ino);
+ sdp->sd_rindex_di.no_addr = be64_to_cpu(sb1->sb_rindex_di.no_addr);
+ sdp->sd_quota_di.no_formal_ino = be64_to_cpu(sb1->sb_quota_di.no_formal_ino);
+ sdp->sd_quota_di.no_addr = be64_to_cpu(sb1->sb_quota_di.no_addr);
+ sdp->sd_license_di.no_formal_ino = be64_to_cpu(sb1->sb_license_di.no_formal_ino);
+ sdp->sd_license_di.no_addr = be64_to_cpu(sb1->sb_license_di.no_addr);
memcpy(sdp->sd_uuid, sb->sb_uuid, sizeof(sdp->sd_uuid));
}
void lgfs2_sb_out(const struct gfs2_sbd *sdp, void *buf)
{
struct gfs2_sb *sb = buf;
+ struct gfs_sb *sb1 = buf;
sb->sb_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
sb->sb_header.mh_type = cpu_to_be32(GFS2_METATYPE_SB);
sb->sb_header.mh_format = cpu_to_be32(GFS2_FORMAT_SB);
sb->sb_fs_format = cpu_to_be32(sdp->sd_fs_format);
sb->sb_multihost_format = cpu_to_be32(sdp->sd_multihost_format);
- sb->__pad0 = cpu_to_be32(sdp->sd_flags);
+ sb1->sb_flags = cpu_to_be32(sdp->sd_flags);
sb->sb_bsize = cpu_to_be32(sdp->sd_bsize);
sb->sb_bsize_shift = cpu_to_be32(sdp->sd_bsize_shift);
- sb->__pad1 = cpu_to_be32(sdp->sd_seg_size);
+ sb1->sb_seg_size = cpu_to_be32(sdp->sd_seg_size);
sb->sb_master_dir.no_formal_ino = cpu_to_be64(sdp->sd_meta_dir.no_formal_ino);
sb->sb_master_dir.no_addr = cpu_to_be64(sdp->sd_meta_dir.no_addr);
sb->sb_root_dir.no_formal_ino = cpu_to_be64(sdp->sd_root_dir.no_formal_ino);
sb->sb_root_dir.no_addr = cpu_to_be64(sdp->sd_root_dir.no_addr);
memcpy(sb->sb_lockproto, sdp->sd_lockproto, GFS2_LOCKNAME_LEN);
memcpy(sb->sb_locktable, sdp->sd_locktable, GFS2_LOCKNAME_LEN);
- sb->__pad2.no_formal_ino = cpu_to_be64(sdp->sd_rindex_di.no_formal_ino);
- sb->__pad2.no_addr = cpu_to_be64(sdp->sd_rindex_di.no_addr);
- sb->__pad3.no_formal_ino = cpu_to_be64(sdp->sd_quota_di.no_formal_ino);
- sb->__pad3.no_addr = cpu_to_be64(sdp->sd_quota_di.no_addr);
- sb->__pad4.no_formal_ino = cpu_to_be64(sdp->sd_license_di.no_formal_ino);
- sb->__pad4.no_addr = cpu_to_be64(sdp->sd_license_di.no_addr);
+ sb1->sb_rindex_di.no_formal_ino = cpu_to_be64(sdp->sd_rindex_di.no_formal_ino);
+ sb1->sb_rindex_di.no_addr = cpu_to_be64(sdp->sd_rindex_di.no_addr);
+ sb1->sb_quota_di.no_formal_ino = cpu_to_be64(sdp->sd_quota_di.no_formal_ino);
+ sb1->sb_quota_di.no_addr = cpu_to_be64(sdp->sd_quota_di.no_addr);
+ sb1->sb_license_di.no_formal_ino = cpu_to_be64(sdp->sd_license_di.no_formal_ino);
+ sb1->sb_license_di.no_addr = cpu_to_be64(sdp->sd_license_di.no_addr);
memcpy(sb->sb_uuid, sdp->sd_uuid, 16);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 27/40: libgfs2: Remove gfs2_meta_header_{in,out}
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 0c03f1c5d6e452e965038be32908006d049774d8
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jun 9 17:18:40 2021 +0100
libgfs2: Remove gfs2_meta_header_{in,out}
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 30 ++++++++--------
gfs2/fsck/initialize.c | 11 +++---
gfs2/fsck/pass1.c | 16 +++++----
gfs2/fsck/rgrepair.c | 56 ++++++++++++++++-------------
gfs2/libgfs2/fs_ops.c | 87 ++++++++++++++++++++++++---------------------
gfs2/libgfs2/gfs1.c | 24 ++++++-------
gfs2/libgfs2/lang.c | 8 ++---
gfs2/libgfs2/libgfs2.h | 2 --
gfs2/libgfs2/ondisk.c | 36 -------------------
gfs2/libgfs2/structures.c | 8 ++---
gfs2/mkfs/main_jadd.c | 8 ++---
11 files changed, 132 insertions(+), 154 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 32f32064..4439b77a 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -278,12 +278,12 @@ static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
struct gfs2_buffer_head *bh;
unsigned int amount, ptramt;
int hdrsize, h, copied = 0, new;
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header mh = {0};
char *srcptr = (char *)first_nonzero_ptr;
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_IN;
- mh.mh_format = GFS2_FORMAT_IN;
+ mh.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ mh.mh_type = cpu_to_be32(GFS2_METATYPE_IN);
+ mh.mh_format = cpu_to_be32(GFS2_FORMAT_IN);
if (!ip->i_height)
unstuff_dinode(ip);
@@ -304,7 +304,7 @@ static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
bh = bread(sbp, block);
if (new)
memset(bh->b_data, 0, sbp->sd_bsize);
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
}
@@ -436,11 +436,11 @@ static uint64_t fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
struct gfs2_buffer_head *bh;
unsigned int amount, ptramt;
int h, copied = 0, new = 0;
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header mh = {0};
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_IN;
- mh.mh_format = GFS2_FORMAT_IN;
+ mh.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ mh.mh_type = cpu_to_be32(GFS2_METATYPE_IN);
+ mh.mh_format = cpu_to_be32(GFS2_FORMAT_IN);
if (!ip->i_height)
unstuff_dinode(ip);
@@ -463,7 +463,7 @@ static uint64_t fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
if (new)
memset(bh->b_data, 0, sbp->sd_bsize);
if (h < (blk->height - 1)) {
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
}
}
@@ -1835,12 +1835,12 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
struct gfs_jindex *jndx;
struct rgrp_tree *rgd, *rgdhigh;
struct osi_node *n, *next = NULL;
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header mh = {0};
uint64_t ri_addr;
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_RB;
- mh.mh_format = GFS2_FORMAT_RB;
+ mh.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ mh.mh_type = cpu_to_be32(GFS2_METATYPE_RB);
+ mh.mh_format = cpu_to_be32(GFS2_FORMAT_RB);
log_notice(_("Converting journal space to rg space.\n"));
/* Go through each journal, converting them one by one */
for (j = 0; j < orig_journals; j++) { /* for each journal */
@@ -1907,7 +1907,7 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
rgd->bits[0].bi_modified = 1;
for (unsigned i = 1; i < rgd->rt_length; i++) {
- gfs2_meta_header_out(&mh, rgd->bits[i].bi_data);
+ memcpy(rgd->bits[i].bi_data, &mh, sizeof(mh));
rgd->bits[i].bi_modified = 1;
}
} /* for each journal */
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index c2a8029d..9d661dce 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -1147,7 +1147,6 @@ static int find_rgs_for_bsize(struct gfs2_sbd *sdp, uint64_t startblock,
uint32_t chk;
char *p;
int found_rg;
- struct gfs2_meta_header mh;
sdp->sd_bsize = GFS2_DEFAULT_BSIZE;
max_rg_size = 524288;
@@ -1173,15 +1172,19 @@ static int find_rgs_for_bsize(struct gfs2_sbd *sdp, uint64_t startblock,
/* Try all the block sizes in 512 byte multiples */
for (bsize2 = GFS2_BASIC_BLOCK; bsize2 <= GFS2_DEFAULT_BSIZE;
bsize2 += GFS2_BASIC_BLOCK) {
+ struct gfs2_meta_header *mh;
+ int is_rb;
+
rb_addr = (bh->b_blocknr *
(GFS2_DEFAULT_BSIZE / bsize2)) +
(bsize / bsize2) + 1;
sdp->sd_bsize = bsize2; /* temporarily */
rb_bh = bread(sdp, rb_addr);
- gfs2_meta_header_in(&mh, rb_bh->b_data);
+ mh = (struct gfs2_meta_header *)rb_bh->b_data;
+ is_rb = (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC &&
+ be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RB);
brelse(rb_bh);
- if (mh.mh_magic == GFS2_MAGIC &&
- mh.mh_type == GFS2_METATYPE_RB) {
+ if (is_rb) {
log_debug(_("boff:%d bsize2:%d rg:0x%llx, "
"rb:0x%llx\n"), bsize, bsize2,
(unsigned long long)blk,
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index bd3c360a..9526aed2 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -522,7 +522,8 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
q = block_type(bl, block);
if (q != GFS2_BLKST_FREE) {
struct gfs2_buffer_head *bh;
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header *mh;
+ uint32_t mh_type;
log_err(_("Found duplicate %s block %"PRIu64" (0x%"PRIx64") "
"referenced as data by dinode %"PRIu64" (0x%"PRIx64") "),
@@ -548,13 +549,14 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
return 1;
case GFS2_BLKST_USED: /* tough decision: May be data or meta */
bh = bread(ip->i_sbd, block);
- gfs2_meta_header_in(&mh, bh->b_data);
+ mh = (struct gfs2_meta_header *)bh->b_data;
+ mh_type = be32_to_cpu(mh->mh_type);
brelse(bh);
- if (mh.mh_magic == GFS2_MAGIC &&
- mh.mh_type >= GFS2_METATYPE_RG &&
- mh.mh_type <= GFS2_METATYPE_QC &&
- mh.mh_type != GFS2_METATYPE_DI &&
- mh.mh_format % 100 == 0) {
+ if (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC &&
+ mh_type >= GFS2_METATYPE_RG &&
+ mh_type <= GFS2_METATYPE_QC &&
+ mh_type != GFS2_METATYPE_DI &&
+ be32_to_cpu(mh->mh_format) % 100 == 0) {
log_info(_("The block was processed earlier "
"as valid metadata, so it can't "
"possibly be data.\n"));
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index fbdc4f34..9d165083 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -319,7 +319,6 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
uint64_t rgrp_dist = 0, used_blocks, block, next_block, twogigs;
struct rgrp_tree *rgd = NULL, *next_rgd;
struct gfs2_buffer_head *bh;
- struct gfs2_meta_header mh;
int first, length, b, found;
uint64_t mega_in_blocks;
uint32_t free_blocks;
@@ -353,15 +352,17 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
first = 1;
found = 0;
while (1) {
+ struct gfs2_meta_header *mh;
+
if (block >= sdp->device.length)
break;
if (block >= prevrgd->rt_addr + twogigs)
break;
bh = bread(sdp, block);
- gfs2_meta_header_in(&mh, bh->b_data);
- if ((mh.mh_magic != GFS2_MAGIC) ||
- (first && mh.mh_type != GFS2_METATYPE_RG) ||
- (!first && mh.mh_type != GFS2_METATYPE_RB)) {
+ mh = (struct gfs2_meta_header *)bh->b_data;
+ if ((be32_to_cpu(mh->mh_magic) != GFS2_MAGIC) ||
+ (first && be32_to_cpu(mh->mh_type) != GFS2_METATYPE_RG) ||
+ (!first && be32_to_cpu(mh->mh_type) != GFS2_METATYPE_RB)) {
brelse(bh);
break;
}
@@ -391,22 +392,21 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
if (next_block + b >= sdp->device.length)
break;
bh = bread(sdp, next_block + b);
- gfs2_meta_header_in(&mh, bh->b_data);
- brelse(bh);
- if (mh.mh_magic == GFS2_MAGIC) {
- if (mh.mh_type == GFS2_METATYPE_RG) {
+ mh = (struct gfs2_meta_header *)bh->b_data;
+ if (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC) {
+ if (be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RG)
found = 1;
- break;
- }
/* if the first thing we find is a bitmap,
there must be a damaged rgrp on the
previous block. */
- if (mh.mh_type == GFS2_METATYPE_RB) {
+ if (be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RB) {
found = 1;
rgrp_dist--;
- break;
}
}
+ brelse(bh);
+ if (found)
+ break;
rgrp_dist++;
}
if (found) {
@@ -429,7 +429,7 @@ static uint64_t hunt_and_peck(struct gfs2_sbd *sdp, uint64_t blk,
{
uint64_t rgrp_dist = 0, block, twogigs, last_block, last_meg;
struct gfs2_buffer_head *bh;
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header *mh;
int b, mega_in_blocks;
/* Skip ahead the previous amount: we might get lucky.
@@ -438,14 +438,16 @@ static uint64_t hunt_and_peck(struct gfs2_sbd *sdp, uint64_t blk,
return sdp->fssize - blk;
bh = bread(sdp, blk + last_bump);
- gfs2_meta_header_in(&mh, bh->b_data);
- brelse(bh);
- if (mh.mh_magic == GFS2_MAGIC && mh.mh_type == GFS2_METATYPE_RG) {
+ mh = (struct gfs2_meta_header *)bh->b_data;
+ if (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC &&
+ be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RG) {
log_info( _("rgrp found at 0x%llx, length=%lld\n"),
(unsigned long long)blk + last_bump,
(unsigned long long)last_bump);
+ brelse(bh);
return last_bump;
}
+ brelse(bh);
rgrp_dist = AWAY_FROM_BITMAPS; /* Get away from any bitmaps
associated with the previous rgrp */
@@ -464,15 +466,19 @@ static uint64_t hunt_and_peck(struct gfs2_sbd *sdp, uint64_t blk,
last_meg = mega_in_blocks;
}
for (b = AWAY_FROM_BITMAPS; b < last_block; b++) {
+ uint32_t magic, type;
+
bh = bread(sdp, block + b);
- gfs2_meta_header_in(&mh, bh->b_data);
+ mh = (struct gfs2_meta_header *)bh->b_data;
+ magic = be32_to_cpu(mh->mh_magic);
+ type = be32_to_cpu(mh->mh_type);
brelse(bh);
- if (mh.mh_magic == GFS2_MAGIC) {
- if (mh.mh_type == GFS2_METATYPE_RG)
+ if (magic == GFS2_MAGIC) {
+ if (type == GFS2_METATYPE_RG)
break;
/* if the first thing we find is a bitmap, there must
be a damaged rgrp on the previous block. */
- if (mh.mh_type == GFS2_METATYPE_RB) {
+ if (type == GFS2_METATYPE_RB) {
rgrp_dist--;
break;
}
@@ -923,11 +929,11 @@ static int rewrite_rg_block(struct gfs2_sbd *sdp, struct rgrp_tree *rg,
}
if (x) {
struct gfs2_meta_header mh = {
- .mh_magic = GFS2_MAGIC,
- .mh_type = GFS2_METATYPE_RB,
- .mh_format = GFS2_FORMAT_RB
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_RB),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_RB)
};
- gfs2_meta_header_out(&mh, buf);
+ memcpy(buf, &mh, sizeof(mh));
} else {
rg->rt_free = rg->rt_data;
if (sdp->gfs1)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 4cc9b275..dae6d1b7 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -246,14 +246,14 @@ void unstuff_dinode(struct gfs2_inode *ip)
if (lgfs2_meta_alloc(ip, &block))
exit(1);
if (isdir) {
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_JD),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_JD)
+ };
bh = bget(sdp, block);
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_JD;
- mh.mh_format = GFS2_FORMAT_JD;
- gfs2_meta_header_out(&mh, bh->b_data);
-
+ memcpy(bh->b_data, &mh, sizeof(mh));
buffer_copy_tail(sdp, bh,
sizeof(struct gfs2_meta_header),
ip->i_bh, sizeof(struct gfs2_dinode));
@@ -399,15 +399,16 @@ void build_height(struct gfs2_inode *ip, int height)
}
if (new_block) {
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_IN),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_IN)
+ };
if (lgfs2_meta_alloc(ip, &block))
exit(1);
bh = bget(sdp, block);
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_IN;
- mh.mh_format = GFS2_FORMAT_IN;
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
buffer_copy_tail(sdp, bh,
sizeof(struct gfs2_meta_header),
ip->i_bh, sizeof(struct gfs2_dinode));
@@ -514,12 +515,13 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
return;
if (*new) {
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_IN),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_IN)
+ };
bh = bget(sdp, *dblock);
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_IN;
- mh.mh_format = GFS2_FORMAT_IN;
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
} else {
if (*dblock == ip->i_addr)
@@ -707,11 +709,12 @@ int __gfs2_writei(struct gfs2_inode *ip, void *buf,
if (new) {
bh = bget(sdp, dblock);
if (isdir) {
- struct gfs2_meta_header mh;
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_JD;
- mh.mh_format = GFS2_FORMAT_JD;
- gfs2_meta_header_out(&mh, bh->b_data);
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_JD),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_JD),
+ };
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
}
} else {
@@ -907,11 +910,12 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
exit(1);
nbh = bget(dip->i_sbd, bn);
{
- struct gfs2_meta_header mh;
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_LF;
- mh.mh_format = GFS2_FORMAT_LF;
- gfs2_meta_header_out(&mh, nbh->b_data);
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_LF),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_LF)
+ };
+ memcpy(nbh->b_data, &mh, sizeof(mh));
bmodified(nbh);
buffer_clear_tail(dip->i_sbd, nbh,
sizeof(struct gfs2_meta_header));
@@ -1182,15 +1186,15 @@ restart:
continue;
} else {
- struct gfs2_meta_header mh;
-
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_LF),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_LF)
+ };
if (lgfs2_meta_alloc(dip, &bn))
exit(1);
nbh = bget(dip->i_sbd, bn);
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_LF;
- mh.mh_format = GFS2_FORMAT_LF;
- gfs2_meta_header_out(&mh, nbh->b_data);
+ memcpy(nbh->b_data, &mh, sizeof(mh));
bmodified(nbh);
leaf->lf_next = cpu_to_be64(bn);
@@ -1239,11 +1243,12 @@ static void dir_make_exhash(struct gfs2_inode *dip)
exit(1);
bh = bget(sdp, bn);
{
- struct gfs2_meta_header mh;
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_LF;
- mh.mh_format = GFS2_FORMAT_LF;
- gfs2_meta_header_out(&mh, bh->b_data);
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_LF),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_LF)
+ };
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
}
@@ -1434,9 +1439,9 @@ int lgfs2_write_filemeta(struct gfs2_inode *ip)
uint64_t ptr0 = ip->i_addr + 1;
unsigned ptrs = 1;
struct gfs2_meta_header mh = {
- .mh_magic = GFS2_MAGIC,
- .mh_type = GFS2_METATYPE_IN,
- .mh_format = GFS2_FORMAT_IN,
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_IN),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_IN)
};
struct gfs2_buffer_head *bh = bget(sdp, ip->i_addr);
if (bh == NULL)
@@ -1462,7 +1467,7 @@ int lgfs2_write_filemeta(struct gfs2_inode *ip)
lgfs2_dinode_out(ip, bh->b_data);
} else {
start += sizeof(struct gfs2_meta_header);
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
}
lgfs2_fill_indir(start, bh->b_data + sdp->sd_bsize, ptr0, ptrs, &p);
if (bwrite(bh)) {
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 97fa32a5..10a196df 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -116,13 +116,13 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
return;
if (*new) {
- struct gfs2_meta_header mh;
-
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_IN),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_IN)
+ };
bh = bget(sdp, *dblock);
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_IN;
- mh.mh_format = GFS2_FORMAT_IN;
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
} else {
if (*dblock == ip->i_addr)
@@ -214,12 +214,12 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
bh = bread(sdp, dblock);
if (journaled && dblock != ip->i_addr ) {
- struct gfs2_meta_header mh;
-
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_JD;
- mh.mh_format = GFS2_FORMAT_JD;
- gfs2_meta_header_out(&mh, bh->b_data);
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_JD),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_JD)
+ };
+ memcpy(bh->b_data, &mh, sizeof(mh));
}
memcpy(bh->b_data + offset, buf + copied, amount);
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index 3633c7a7..f0870457 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -551,11 +551,11 @@ static struct lgfs2_lang_result *ast_interp_set(struct lgfs2_lang_state *state,
if (lookup->ast_right->ast_type == AST_EX_TYPESPEC) {
struct gfs2_meta_header mh = {
- .mh_magic = GFS2_MAGIC,
- .mh_type = result->lr_mtype->mh_type,
- .mh_format = result->lr_mtype->mh_format,
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(result->lr_mtype->mh_type),
+ .mh_format = cpu_to_be32(result->lr_mtype->mh_format),
};
- gfs2_meta_header_out(&mh, result->lr_buf);
+ memcpy(result->lr_buf, &mh, sizeof(mh));
lookup = lookup->ast_right;
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index da61f8d0..ed643a09 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -805,8 +805,6 @@ extern void print_it(const char *label, const char *fmt, const char *fmt2, ...)
extern void lgfs2_inum_in(struct lgfs2_inum *i, void *inp);
extern void lgfs2_inum_out(struct lgfs2_inum *i, void *inp);
-extern void gfs2_meta_header_in(struct gfs2_meta_header *mh, const char *buf);
-extern void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf);
extern void lgfs2_sb_in(struct gfs2_sbd *sdp, void *buf);
extern void lgfs2_sb_out(const struct gfs2_sbd *sdp, void *buf);
extern void lgfs2_rindex_in(lgfs2_rgrp_t rg, void *buf);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index fa1f9db6..21f6115e 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -9,13 +9,6 @@
#include <uuid.h>
#include "libgfs2.h"
-#define pv(struct, member, fmt, fmt2) do { \
- print_it(" "#member, fmt, fmt2, struct->member); \
- } while (0);
-#define pv2(struct, member, fmt, fmt2) do { \
- print_it(" ", fmt, fmt2, struct->member); \
- } while (0);
-
#define printbe16(struct, member) do { \
print_it(" "#member, "%"PRIu16, "0x%"PRIx16, be16_to_cpu(struct->member)); \
} while(0)
@@ -29,15 +22,6 @@
print_it(" "#member, "%"PRIu8, "0x%"PRIx8, struct->member); \
} while(0)
-#define CPIN_08(s1, s2, member, count) {memcpy((s1->member), (s2->member), (count));}
-#define CPOUT_08(s1, s2, member, count) {memcpy((s2->member), (s1->member), (count));}
-#define CPIN_16(s1, s2, member) {(s1->member) = be16_to_cpu((s2->member));}
-#define CPOUT_16(s1, s2, member) {(s2->member) = cpu_to_be16((s1->member));}
-#define CPIN_32(s1, s2, member) {(s1->member) = be32_to_cpu((s2->member));}
-#define CPOUT_32(s1, s2, member) {(s2->member) = cpu_to_be32((s1->member));}
-#define CPIN_64(s1, s2, member) {(s1->member) = be64_to_cpu((s2->member));}
-#define CPOUT_64(s1, s2, member) {(s2->member) = cpu_to_be64((s1->member));}
-
void lgfs2_inum_in(struct lgfs2_inum *i, void *inp)
{
struct gfs2_inum *in = inp;
@@ -62,26 +46,6 @@ void lgfs2_inum_print(void *nop)
printbe64(no, no_addr);
}
-void gfs2_meta_header_in(struct gfs2_meta_header *mh, const char *buf)
-{
- const struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf;
-
- CPIN_32(mh, str, mh_magic);
- CPIN_32(mh, str, mh_type);
- CPIN_32(mh, str, mh_format);
-}
-
-void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf)
-{
- struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf;
-
- CPOUT_32(mh, str, mh_magic);
- CPOUT_32(mh, str, mh_type);
- CPOUT_32(mh, str, mh_format);
- str->__pad0 = 0;
- str->__pad1 = 0;
-}
-
void lgfs2_meta_header_print(void *mhp)
{
struct gfs2_meta_header *mh = mhp;
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index f0eb8832..9dcf237f 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -377,9 +377,9 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
struct gfs2_buffer_head *bh;
memset(&mh, 0, sizeof(struct gfs2_meta_header));
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_QC;
- mh.mh_format = GFS2_FORMAT_QC;
+ mh.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ mh.mh_type = cpu_to_be32(GFS2_METATYPE_QC);
+ mh.mh_format = cpu_to_be32(GFS2_FORMAT_QC);
sprintf(name, "quota_change%u", j);
ip = createi(per_node, name, S_IFREG | 0600, GFS2_DIF_SYSTEM);
@@ -396,7 +396,7 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
return -1;
memset(bh->b_data, 0, sdp->sd_bsize);
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
brelse(bh);
}
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index 66d9e293..8feb201c 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -377,10 +377,10 @@ static int add_qc(struct gfs2_sbd *sdp, struct jadd_opts *opts)
}
memset(&mh, 0, sizeof(struct gfs2_meta_header));
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_QC;
- mh.mh_format = GFS2_FORMAT_QC;
- gfs2_meta_header_out(&mh, buf);
+ mh.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ mh.mh_type = cpu_to_be32(GFS2_METATYPE_QC);
+ mh.mh_format = cpu_to_be32(GFS2_FORMAT_QC);
+ memcpy(buf, &mh, sizeof(mh));
for (x=0; x<blocks; x++) {
if (write(fd, buf, sdp->sd_bsize) != sdp->sd_bsize) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 26/40: libgfs2: Endianness improvements for gfs2_leaf
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 2ee34808ed12d933cdbf917d8be92ebf306b2817
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jun 9 16:17:51 2021 +0100
libgfs2: Endianness improvements for gfs2_leaf
Introduce a lgfs2_leaf native-endian struct and convert the
gfs2_leaf_{in,out} functions to work with it.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/metawalk.c | 16 +++++++++-------
gfs2/fsck/metawalk.h | 2 +-
gfs2/fsck/pass2.c | 10 +++++-----
gfs2/libgfs2/libgfs2.h | 15 +++++++++++++--
gfs2/libgfs2/ondisk.c | 48 ++++++++++++++++++++++--------------------------
5 files changed, 50 insertions(+), 41 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index d915b085..7b5bd873 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -515,10 +515,11 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
* Leaves the buffer around for further analysis (caller must brelse)
*/
int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
- uint64_t *leaf_no, struct gfs2_leaf *leaf, int *ref_count)
+ uint64_t *leaf_no, struct lgfs2_leaf *leaf, int *ref_count)
{
int error = 0, fix;
struct gfs2_buffer_head *lbh = NULL;
+ struct gfs2_leaf *lfp;
uint32_t count = 0;
struct gfs2_sbd *sdp = ip->i_sbd;
const char *msg;
@@ -560,18 +561,19 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
to use cpu_to_be32(), but we should check for incorrect values and
replace them with the correct value. */
- gfs2_leaf_in(leaf, lbh->b_data);
+ lgfs2_leaf_in(leaf, lbh->b_data);
if (leaf->lf_dirent_format == (GFS2_FORMAT_DE << 16)) {
log_debug( _("incorrect lf_dirent_format at leaf #%" PRIu64
"\n"), *leaf_no);
leaf->lf_dirent_format = GFS2_FORMAT_DE;
- gfs2_leaf_out(leaf, lbh->b_data);
+ lgfs2_leaf_out(leaf, lbh->b_data);
bmodified(lbh);
log_debug( _("Fixing lf_dirent_format.\n"));
}
+ lfp = (struct gfs2_leaf *)lbh->b_data;
/* Make sure it's really a leaf. */
- if (leaf->lf_header.mh_type != GFS2_METATYPE_LF) {
+ if (be32_to_cpu(lfp->lf_header.mh_type) != GFS2_METATYPE_LF) {
log_err(_("Inode %"PRIu64" (0x%"PRIx64") points to bad leaf %"PRIu64
" (0x%"PRIx64").\n"),
ip->i_addr, ip->i_addr, *leaf_no, *leaf_no);
@@ -598,7 +600,7 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
changed it. */
brelse(lbh);
lbh = bread(sdp, *leaf_no);
- gfs2_leaf_in(leaf, lbh->b_data);
+ lgfs2_leaf_in(leaf, lbh->b_data);
if (count != leaf->lf_entries) {
log_err(_("Leaf %"PRIu64" (0x%"PRIx64") entry count in "
"directory %"PRIu64" (0x%"PRIx64") does not match "
@@ -607,7 +609,7 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
leaf->lf_entries, count);
if (query( _("Update leaf entry count? (y/n) "))) {
leaf->lf_entries = count;
- gfs2_leaf_out(leaf, lbh->b_data);
+ lgfs2_leaf_out(leaf, lbh->b_data);
bmodified(lbh);
log_warn( _("Leaf entry count updated\n"));
} else
@@ -789,7 +791,7 @@ int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
chained_leaf = 0;
do {
- struct gfs2_leaf leaf;
+ struct lgfs2_leaf leaf;
if (fsck_abort) {
free(tbl);
posix_fadvise(sdp->device_fd, 0, 0, POSIX_FADV_NORMAL);
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index f6c6bc31..a1038854 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -18,7 +18,7 @@ extern int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
struct metawalk_fxns *pass);
extern int check_leaf(struct gfs2_inode *ip, int lindex,
struct metawalk_fxns *pass, uint64_t *leaf_no,
- struct gfs2_leaf *leaf, int *ref_count);
+ struct lgfs2_leaf *leaf, int *ref_count);
extern int _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
const char *btype, int mark, int error_on_dinode,
const char *caller, int line);
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index f3fdd4cb..c7adc16c 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -1310,7 +1310,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
{
struct gfs2_buffer_head *lbh;
struct lgfs2_dirent dentry;
- struct gfs2_leaf leaf;
+ struct lgfs2_leaf leaf;
struct gfs2_dirent *de;
int changes = 0, error, i, extras, hash_index;
uint64_t new_leaf_blk;
@@ -1421,7 +1421,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
new_leaf_blk = find_free_blk(ip->i_sbd);
dir_split_leaf(ip, lindex, leafblk, lbh);
/* re-read the leaf to pick up dir_split_leaf's changes */
- gfs2_leaf_in(&leaf, lbh->b_data);
+ lgfs2_leaf_in(&leaf, lbh->b_data);
*proper_len = 1 << (ip->i_depth - leaf.lf_depth);
log_err(_("Leaf block %llu (0x%llx) was split from length "
"%d to %d\n"), (unsigned long long)leafblk,
@@ -1608,7 +1608,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
int error = 0;
int lindex, len, proper_len, i, changes = 0;
uint64_t leafblk;
- struct gfs2_leaf leaf;
+ struct lgfs2_leaf leaf;
struct gfs2_buffer_head *lbh;
int factor;
uint32_t proper_start;
@@ -1713,7 +1713,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
(unsigned long long)leafblk,
proper_len, proper_len);
lbh = bread(ip->i_sbd, leafblk);
- gfs2_leaf_in(&leaf, lbh->b_data);
+ lgfs2_leaf_in(&leaf, lbh->b_data);
if (gfs2_check_meta(lbh->b_data, GFS2_METATYPE_LF) ||
leaf.lf_depth > ip->i_depth)
leaf.lf_depth = factor;
@@ -1752,7 +1752,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
/* Now we have to determine if the hash table is
corrupt, or if the leaf has the wrong depth. */
lbh = bread(ip->i_sbd, leafblk);
- gfs2_leaf_in(&leaf, lbh->b_data);
+ lgfs2_leaf_in(&leaf, lbh->b_data);
brelse(lbh);
/* Calculate the expected pointer count based on the
leaf depth. */
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 6e5172cd..da61f8d0 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -397,6 +397,17 @@ struct lgfs2_dirent {
uint32_t dr_cookie;
};
+struct lgfs2_leaf {
+ uint16_t lf_depth;
+ uint16_t lf_entries;
+ uint32_t lf_dirent_format;
+ uint64_t lf_next;
+ uint64_t lf_inode;
+ uint32_t lf_dist;
+ uint32_t lf_nsec;
+ uint64_t lf_sec;
+};
+
struct metapath {
unsigned int mp_list[GFS2_MAX_META_HEIGHT];
};
@@ -806,8 +817,8 @@ extern void lgfs2_dinode_in(struct gfs2_inode *ip, char *buf);
extern void lgfs2_dinode_out(struct gfs2_inode *ip, char *buf);
extern void lgfs2_dirent_in(struct lgfs2_dirent *d, void *dep);
extern void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep);
-extern void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf);
-extern void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf);
+extern void lgfs2_leaf_in(struct lgfs2_leaf *lf, void *lfp);
+extern void lgfs2_leaf_out(struct lgfs2_leaf *lf, void *lfp);
/* Printing functions. These expect on-disk data */
extern void lgfs2_inum_print(void *nop);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 4526fa20..fa1f9db6 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -388,36 +388,32 @@ void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep)
de->de_cookie = cpu_to_be32(d->dr_cookie);
}
-void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf)
+void lgfs2_leaf_in(struct lgfs2_leaf *lf, void *lfp)
{
- struct gfs2_leaf *str = (struct gfs2_leaf *)buf;
-
- gfs2_meta_header_in(&lf->lf_header, buf);
- CPIN_16(lf, str, lf_depth);
- CPIN_16(lf, str, lf_entries);
- CPIN_32(lf, str, lf_dirent_format);
- CPIN_64(lf, str, lf_next);
- CPIN_64(lf, str, lf_inode);
- CPIN_32(lf, str, lf_dist);
- CPIN_32(lf, str, lf_nsec);
- CPIN_64(lf, str, lf_sec);
- CPIN_08(lf, str, lf_reserved2, 40);
+ struct gfs2_leaf *l = lfp;
+
+ lf->lf_depth = be16_to_cpu(l->lf_depth);
+ lf->lf_entries = be16_to_cpu(l->lf_entries);
+ lf->lf_dirent_format = be32_to_cpu(l->lf_dirent_format);
+ lf->lf_next = be64_to_cpu(l->lf_next);
+ lf->lf_inode = be64_to_cpu(l->lf_inode);
+ lf->lf_dist = be32_to_cpu(l->lf_dist);
+ lf->lf_nsec = be32_to_cpu(l->lf_nsec);
+ lf->lf_sec = be64_to_cpu(l->lf_sec);
}
-void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf)
+void lgfs2_leaf_out(struct lgfs2_leaf *lf, void *lfp)
{
- struct gfs2_leaf *str = (struct gfs2_leaf *)buf;
-
- gfs2_meta_header_out(&lf->lf_header, buf);
- CPOUT_16(lf, str, lf_depth);
- CPOUT_16(lf, str, lf_entries);
- CPOUT_32(lf, str, lf_dirent_format);
- CPOUT_64(lf, str, lf_next);
- CPOUT_64(lf, str, lf_inode);
- CPOUT_32(lf, str, lf_dist);
- CPOUT_32(lf, str, lf_nsec);
- CPOUT_64(lf, str, lf_sec);
- CPOUT_08(lf, str, lf_reserved2, 40);
+ struct gfs2_leaf *l = lfp;
+
+ l->lf_depth = cpu_to_be16(lf->lf_depth);
+ l->lf_entries = cpu_to_be16(lf->lf_entries);
+ l->lf_dirent_format = cpu_to_be32(lf->lf_dirent_format);
+ l->lf_next = cpu_to_be64(lf->lf_next);
+ l->lf_inode = cpu_to_be64(lf->lf_inode);
+ l->lf_dist = cpu_to_be32(lf->lf_dist);
+ l->lf_nsec = cpu_to_be32(lf->lf_nsec);
+ l->lf_sec = cpu_to_be64(lf->lf_sec);
}
void lgfs2_leaf_print(void *lfp)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 25/40: Remove some users of gfs2_leaf_in()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 19d95b5b22c88572db9189f54109176abc4f0cf8
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jun 9 15:48:33 2021 +0100
Remove some users of gfs2_leaf_in()
Just interpret the data through a gfs2_leaf pointer instead.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 10 +++++-----
gfs2/edit/extended.c | 14 ++++++--------
gfs2/edit/gfs2hex.c | 6 ++----
gfs2/edit/savemeta.c | 19 ++++++++-----------
4 files changed, 21 insertions(+), 28 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 9c703e4c..32f32064 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1266,7 +1266,7 @@ static int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip
/* for all the leafs, get the leaf block and process the dirents inside */
for (leaf_num = 0; ; leaf_num++) {
uint64_t buf;
- struct gfs2_leaf leaf;
+ struct gfs2_leaf *leaf;
error = gfs2_readi(dip, (char *)&buf, leaf_num * sizeof(uint64_t),
sizeof(uint64_t));
@@ -1293,14 +1293,14 @@ static int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip
(unsigned long long)leaf_block);
break;
}
- gfs2_leaf_in(&leaf, bh_leaf->b_data);
- error = process_dirent_info(dip, sbp, bh_leaf, leaf.lf_entries, dentmod);
+ leaf = (struct gfs2_leaf *)bh_leaf->b_data;
+ error = process_dirent_info(dip, sbp, bh_leaf, be16_to_cpu(leaf->lf_entries), dentmod);
bmodified(bh_leaf);
brelse(bh_leaf);
if (dentmod && error == -EISDIR) /* dentmod was marked DT_DIR, break out */
break;
- if (leaf.lf_next) { /* leaf has a leaf chain, process leaves in chain */
- leaf_block = leaf.lf_next;
+ if (leaf->lf_next) { /* leaf has a leaf chain, process leaves in chain */
+ leaf_block = be64_to_cpu(leaf->lf_next);
error = 0;
goto leaf_chain;
}
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index d2ac8507..58cc2134 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -295,10 +295,6 @@ static void print_inode_type(__be16 de_type)
}
}
-#define LEAF_HINT_FMTS "lf_inode: 0x%"PRIx64", lf_dist: %"PRIu32", " \
- "lf_nsec: %"PRIu32", lf_sec: %"PRIu64", "
-#define LEAF_HINT_FIELDS(lp) lp->lf_inode, lp->lf_dist, lp->lf_nsec, lp->lf_sec,
-
static int display_leaf(struct iinfo *ind)
{
struct gfs2_leaf *leaf = &ind->ii[0].lf;
@@ -309,11 +305,13 @@ static int display_leaf(struct iinfo *ind)
if (gfs2_struct_type == GFS2_METATYPE_SB)
print_gfs2("The superblock has 2 directories");
else
- print_gfs2("Directory block: lf_depth:%"PRIu16", lf_entries:%"PRIu16", "
- LEAF_HINT_FMTS
+ print_gfs2("Directory block: "
+ "lf_depth:%"PRIu16", lf_entries:%"PRIu16", lf_inode: 0x%"PRIx64", "
+ "lf_dist: %"PRIu32", lf_nsec: %"PRIu32", lf_sec: %"PRIu64", "
"fmt:%"PRIu32" next=0x%"PRIx64" (%d dirents).",
- leaf->lf_depth, leaf->lf_entries,
- LEAF_HINT_FIELDS(leaf)
+ be16_to_cpu(leaf->lf_depth), be16_to_cpu(leaf->lf_entries),
+ be64_to_cpu(leaf->lf_inode), be32_to_cpu(leaf->lf_dist),
+ be32_to_cpu(leaf->lf_nsec), be64_to_cpu(leaf->lf_sec),
leaf->lf_dirent_format,
leaf->lf_next,
ind->ii[0].dirents);
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 5a1f9b7f..a18df909 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -300,13 +300,11 @@ void do_dinode_extended(char *buf)
if (p != last || ((y + 1) * sizeof(uint64_t) == be64_to_cpu(dip->di_size))) {
struct gfs2_buffer_head *tmp_bh;
int skip = 0, direntcount = 0;
- struct gfs2_leaf leaf;
unsigned int bufoffset;
if (last >= max_block)
break;
tmp_bh = bread(&sbd, last);
- gfs2_leaf_in(&leaf, tmp_bh->b_data);
indirect->ii[indirect_blocks].dirents = 0;
for (direntcount = 0, bufoffset = sizeof(struct gfs2_leaf);
bufoffset < sbd.sd_bsize;
@@ -336,7 +334,7 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
x = 0;
memset(indir, 0, sizeof(*indir));
- gfs2_leaf_in(&indir->ii[0].lf, dlebuf);
+ memcpy(&indir->ii[0].lf, dlebuf, sizeof(struct gfs2_leaf));
/* Directory Entries: */
for (i = sizeof(struct gfs2_leaf); i < sbd.sd_bsize; i += be16_to_cpu(de->de_rec_len)) {
de = (struct gfs2_dirent *)(dlebuf + i);
@@ -350,7 +348,7 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
if (be16_to_cpu(de->de_rec_len) <= sizeof(struct gfs2_dirent))
break;
}
- return indir->ii[0].lf.lf_next;
+ return be64_to_cpu(indir->ii[0].lf.lf_next);
}
static void do_eattr_extended(char *buf)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 5d51ea1f..09761fe2 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -329,7 +329,7 @@ static size_t di_save_len(const char *buf, uint64_t owner)
static int get_gfs_struct_info(const char *buf, uint64_t owner, unsigned *block_type,
unsigned *gstruct_len)
{
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header *mh = (struct gfs2_meta_header *)buf;
if (block_type != NULL)
*block_type = 0;
@@ -337,17 +337,16 @@ static int get_gfs_struct_info(const char *buf, uint64_t owner, unsigned *block_
if (gstruct_len != NULL)
*gstruct_len = sbd.sd_bsize;
- gfs2_meta_header_in(&mh, buf);
- if (mh.mh_magic != GFS2_MAGIC)
+ if (be32_to_cpu(mh->mh_magic) != GFS2_MAGIC)
return -1;
if (block_type != NULL)
- *block_type = mh.mh_type;
+ *block_type = be32_to_cpu(mh->mh_type);
if (gstruct_len == NULL)
return 0;
- switch (mh.mh_type) {
+ switch (be32_to_cpu(mh->mh_type)) {
case GFS2_METATYPE_SB: /* 1 (superblock) */
if (sbd.gfs1)
*gstruct_len = sizeof(struct gfs_sb);
@@ -791,12 +790,10 @@ new_range:
static int save_leaf_chain(struct metafd *mfd, struct gfs2_sbd *sdp, char *buf)
{
- struct gfs2_leaf leaf;
+ struct gfs2_leaf *leaf = (struct gfs2_leaf *)buf;
- gfs2_leaf_in(&leaf, buf);
-
- while (leaf.lf_next != 0) {
- uint64_t blk = leaf.lf_next;
+ while (leaf->lf_next != 0) {
+ uint64_t blk = be64_to_cpu(leaf->lf_next);
ssize_t r;
if (gfs2_check_range(sdp, blk) != 0)
@@ -817,7 +814,7 @@ static int save_leaf_chain(struct metafd *mfd, struct gfs2_sbd *sdp, char *buf)
return ret;
}
}
- gfs2_leaf_in(&leaf, buf);
+ leaf = (struct gfs2_leaf *)buf;
}
return 0;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 24/40: libgfs2: Endianness improvements for gfs2_inum
and gfs2_dirent
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 113aed8a17295837b0576bcb0e86226ecaf4d065
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jun 9 14:19:09 2021 +0100
libgfs2: Endianness improvements for gfs2_inum and gfs2_dirent
The uses of structs gfs2_inum and gfs2_dirent are tightly coupled so
these changes had to be made at the same time. Introduce native-endian
structs lgfs2_inum and lgfs2_dirent and conversion functions for them.
Convert users as appropriate.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 64 +++----
gfs2/fsck/afterpass1_common.c | 8 +-
gfs2/fsck/fs_recovery.c | 20 +--
gfs2/fsck/fsck.h | 8 +-
gfs2/fsck/initialize.c | 51 +++---
gfs2/fsck/inode_hash.c | 12 +-
gfs2/fsck/inode_hash.h | 2 +-
gfs2/fsck/link.c | 43 +++--
gfs2/fsck/link.h | 3 +-
gfs2/fsck/lost_n_found.c | 46 ++---
gfs2/fsck/metawalk.c | 61 ++++---
gfs2/fsck/pass1.c | 48 +++--
gfs2/fsck/pass2.c | 407 +++++++++++++++++++-----------------------
gfs2/fsck/pass3.c | 115 +++++-------
gfs2/fsck/pass4.c | 25 ++-
gfs2/fsck/util.c | 14 +-
gfs2/libgfs2/fs_ops.c | 56 +++---
gfs2/libgfs2/libgfs2.h | 33 +++-
gfs2/libgfs2/ondisk.c | 71 +++-----
gfs2/libgfs2/structures.c | 14 +-
gfs2/mkfs/main_mkfs.c | 6 +-
21 files changed, 522 insertions(+), 585 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index c8ebfe3b..9c703e4c 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1106,19 +1106,19 @@ static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr, osi_li
return 0;
}/* inode_renumber */
-/* ------------------------------------------------------------------------- */
-/* fetch_inum - fetch an inum entry from disk, given its block */
-/* ------------------------------------------------------------------------- */
+/**
+ * fetch_inum - fetch an inum entry from disk, given its block
+ */
static int fetch_inum(struct gfs2_sbd *sbp, uint64_t iblock,
- struct gfs2_inum *inum, uint64_t *eablk)
+ struct lgfs2_inum *inum, uint64_t *eablk)
{
struct gfs2_inode *fix_inode;
fix_inode = lgfs2_inode_read(sbp, iblock);
if (fix_inode == NULL)
return 1;
- inum->no_formal_ino = fix_inode->i_formal_ino;
- inum->no_addr = fix_inode->i_addr;
+ inum->in_formal_ino = fix_inode->i_formal_ino;
+ inum->in_addr = fix_inode->i_addr;
if (eablk)
*eablk = fix_inode->i_eattr;
@@ -1150,7 +1150,7 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
/* Go through every dirent in the buffer and process it. */
/* Turns out you can't trust dir_entries is correct. */
for (de = 0; ; de++) {
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
int dent_was_gfs1;
if (dentmod) {
@@ -1174,17 +1174,17 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
fflush(stdout);
}
/* fix the dirent's inode number based on the inode */
- gfs2_inum_in(&inum, (char *)&dent->de_inum);
+ lgfs2_inum_in(&inum, &dent->de_inum);
dent_was_gfs1 = (dent->de_inum.no_addr == dent->de_inum.no_formal_ino);
- if (inum.no_formal_ino) { /* if not a sentinel (placeholder) */
- error = fetch_inum(sbp, inum.no_addr, &inum, NULL);
+ if (inum.in_formal_ino) { /* if not a sentinel (placeholder) */
+ error = fetch_inum(sbp, inum.in_addr, &inum, NULL);
if (error) {
- log_crit(_("Error retrieving inode 0x%llx\n"),
- (unsigned long long)inum.no_addr);
+ log_crit(_("Error retrieving inode 0x%"PRIx64"\n"),
+ inum.in_addr);
break;
}
/* fix the dirent's inode number from the fetched inum. */
- dent->de_inum.no_formal_ino = cpu_to_be64(inum.no_formal_ino);
+ dent->de_inum.no_formal_ino = cpu_to_be64(inum.in_formal_ino);
}
/* Fix the dirent's filename hash: They are the same as gfs1 */
/* dent->de_hash = cpu_to_be32(gfs2_disk_hash((char *)(dent + 1), */
@@ -1231,7 +1231,7 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
struct inode_dir_block *fix;
osi_list_foreach(tmp, &cdpns_to_fix.list) {
fix = osi_list_entry(tmp, struct inode_dir_block, list);
- if (fix->di_addr == inum.no_addr)
+ if (fix->di_addr == inum.in_addr)
fix->di_paddr = dip->i_addr;
}
}
@@ -1392,7 +1392,7 @@ static int fix_cdpn_symlinks(struct gfs2_sbd *sbp, osi_list_t *cdpn_to_fix)
cdpns_fixed = 0;
osi_list_foreach_safe(tmp, cdpn_to_fix, x) {
- struct gfs2_inum fix, dir;
+ struct lgfs2_inum fix, dir;
struct inode_dir_block *l_fix;
struct gfs2_buffer_head *bh = NULL;
struct gfs2_inode *fix_inode;
@@ -1588,7 +1588,7 @@ static int init(struct gfs2_sbd *sbp, struct gfs2_options *opts)
{
struct gfs2_buffer_head *bh;
int rgcount;
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
memset(sbp, 0, sizeof(struct gfs2_sbd));
if ((sbp->device_fd = open(opts->device, O_RDWR)) < 0) {
@@ -1667,15 +1667,15 @@ static int init(struct gfs2_sbd *sbp, struct gfs2_options *opts)
exit(-1);
}
/* get gfs1 rindex inode - gfs1's rindex inode ptr became __pad2 */
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_rindex_di);
- sbp->md.riinode = lgfs2_gfs_inode_read(sbp, inum.no_addr);
+ lgfs2_inum_in(&inum, &gfs1_sb.sb_rindex_di);
+ sbp->md.riinode = lgfs2_gfs_inode_read(sbp, inum.in_addr);
if (sbp->md.riinode == NULL) {
log_crit(_("Could not read resource group index: %s\n"), strerror(errno));
exit(-1);
}
/* get gfs1 jindex inode - gfs1's journal index inode ptr became master */
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_jindex_di);
- sbp->md.jiinode = lgfs2_inode_read(sbp, inum.no_addr);
+ lgfs2_inum_in(&inum, &gfs1_sb.sb_jindex_di);
+ sbp->md.jiinode = lgfs2_inode_read(sbp, inum.in_addr);
if (sbp->md.jiinode == NULL) {
log_crit(_("Could not read journal index: %s\n"), strerror(errno));
exit(-1);
@@ -1958,25 +1958,25 @@ static void write_statfs_file(struct gfs2_sbd *sdp)
/* ------------------------------------------------------------------------- */
static void remove_obsolete_gfs1(struct gfs2_sbd *sbp)
{
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
log_notice(_("Removing obsolete GFS1 file system structures.\n"));
fflush(stdout);
/* Delete the old gfs1 Journal index: */
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_jindex_di);
- gfs2_freedi(sbp, inum.no_addr);
+ lgfs2_inum_in(&inum, &gfs1_sb.sb_jindex_di);
+ gfs2_freedi(sbp, inum.in_addr);
/* Delete the old gfs1 rgindex: */
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_rindex_di);
- gfs2_freedi(sbp, inum.no_addr);
+ lgfs2_inum_in(&inum, &gfs1_sb.sb_rindex_di);
+ gfs2_freedi(sbp, inum.in_addr);
/* Delete the old gfs1 Quota file: */
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_quota_di);
- gfs2_freedi(sbp, inum.no_addr);
+ lgfs2_inum_in(&inum, &gfs1_sb.sb_quota_di);
+ gfs2_freedi(sbp, inum.in_addr);
/* Delete the old gfs1 License file: */
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_license_di);
- gfs2_freedi(sbp, inum.no_addr);
+ lgfs2_inum_in(&inum, &gfs1_sb.sb_license_di);
+ gfs2_freedi(sbp, inum.in_addr);
}
/* ------------------------------------------------------------------------- */
@@ -2116,7 +2116,7 @@ static int check_fit(struct gfs2_sbd *sdp)
*/
static void copy_quotas(struct gfs2_sbd *sdp)
{
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
struct gfs2_inode *oq_ip, *nq_ip;
int err;
@@ -2126,8 +2126,8 @@ static void copy_quotas(struct gfs2_sbd *sdp)
exit(1);
}
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_quota_di);
- oq_ip = lgfs2_inode_read(sdp, inum.no_addr);
+ lgfs2_inum_in(&inum, (char *)&gfs1_sb.sb_quota_di);
+ oq_ip = lgfs2_inode_read(sdp, inum.in_addr);
if (oq_ip == NULL) {
fprintf(stderr, _("Couldn't lookup old quota file: %s\n"), strerror(errno));
exit(1);
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c
index 301986f0..c216a5da 100644
--- a/gfs2/fsck/afterpass1_common.c
+++ b/gfs2/fsck/afterpass1_common.c
@@ -118,13 +118,11 @@ static int remove_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* the metawalk_fxn's private field must be set to the dentry
* block we want to clear */
uint64_t *dentryblock = (uint64_t *) private;
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_dirent d;
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&dentry, (char *)dent);
- de = &dentry;
+ lgfs2_dirent_in(&d, dent);
- if (de->de_inum.no_addr == *dentryblock)
+ if (d.dr_inum.in_addr == *dentryblock)
dirent2_del(ip, bh, prev_de, dent);
else
(*count)++;
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index e9d3c849..130e9854 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -823,27 +823,25 @@ static int check_jindex_dent(struct gfs2_inode *ip, struct gfs2_dirent *dent,
struct gfs2_buffer_head *bh, char *filename,
uint32_t *count, int *lindex, void *priv)
{
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_dirent d;
int i;
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&dentry, (char *)dent);
- de = &dentry;
+ lgfs2_dirent_in(&d, dent);
- if (de->de_name_len == 1 && filename[0] == '.')
+ if (d.dr_name_len == 1 && filename[0] == '.')
goto dirent_good;
- if (de->de_name_len == 2 && filename[0] == '.' && filename[1] == '.')
+ if (d.dr_name_len == 2 && filename[0] == '.' && filename[1] == '.')
goto dirent_good;
- if ((de->de_name_len >= 11) || /* "journal9999" */
- (de->de_name_len <= 7) ||
+ if ((d.dr_name_len >= 11) || /* "journal9999" */
+ (d.dr_name_len <= 7) ||
(strncmp(filename, "journal", 7))) {
- bad_journalname(filename, de->de_name_len);
+ bad_journalname(filename, d.dr_name_len);
return -1;
}
- for (i = 7; i < de->de_name_len; i++) {
+ for (i = 7; i < d.dr_name_len; i++) {
if (filename[i] < '0' || filename[i] > '9') {
- bad_journalname(filename, de->de_name_len);
+ bad_journalname(filename, d.dr_name_len);
return -2;
}
}
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index bc706860..55f5abe8 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -36,7 +36,7 @@ struct gfs2_bmap {
struct inode_info
{
struct osi_node node;
- struct gfs2_inum di_num;
+ struct lgfs2_inum num;
uint32_t di_nlink; /* the number of links the inode
* thinks it has */
uint32_t counted_links; /* the number of links we've found */
@@ -45,9 +45,9 @@ struct inode_info
struct dir_info
{
struct osi_node node;
- struct gfs2_inum dinode;
+ struct lgfs2_inum dinode;
uint64_t treewalk_parent;
- struct gfs2_inum dotdot_parent;
+ struct lgfs2_inum dotdot_parent;
uint32_t di_nlink;
uint32_t counted_links;
uint8_t checked:1;
@@ -133,7 +133,7 @@ extern void dirtree_delete(struct dir_info *b);
/* FIXME: Hack to get this going for pass2 - this should be pulled out
* of pass1 and put somewhere else... */
-struct dir_info *dirtree_insert(struct gfs2_inum inum);
+struct dir_info *dirtree_insert(struct lgfs2_inum inum);
struct gfs2_options {
char *device;
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 35599fb4..c2a8029d 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -453,7 +453,7 @@ static void check_rgrps_integrity(struct gfs2_sbd *sdp)
*/
static int rebuild_master(struct gfs2_sbd *sdp)
{
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
struct gfs2_buffer_head *bh = NULL;
int err = 0;
@@ -463,8 +463,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
return -1;
}
log_err(_("Trying to rebuild the master directory.\n"));
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = sdp->sd_meta_dir.no_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = sdp->sd_meta_dir.no_addr;
err = init_dinode(sdp, &bh, &inum, S_IFDIR | 0755, GFS2_DIF_SYSTEM, &inum);
if (err != 0)
return -1;
@@ -476,8 +476,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
sdp->master_dir->bh_owned = 1;
if (fix_md.jiinode) {
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.jiinode->i_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = fix_md.jiinode->i_addr;
err = dir_add(sdp->master_dir, "jindex", 6, &inum,
IF2DT(S_IFDIR | 0700));
if (err) {
@@ -494,8 +494,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
}
if (fix_md.pinode) {
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.pinode->i_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = fix_md.pinode->i_addr;
err = dir_add(sdp->master_dir, "per_node", 8, &inum,
IF2DT(S_IFDIR | 0700));
if (err) {
@@ -514,8 +514,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
}
if (fix_md.inum) {
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.inum->i_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = fix_md.inum->i_addr;
err = dir_add(sdp->master_dir, "inum", 4, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -532,8 +532,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
}
if (fix_md.statfs) {
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.statfs->i_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = fix_md.statfs->i_addr;
err = dir_add(sdp->master_dir, "statfs", 6, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -550,8 +550,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
}
if (fix_md.riinode) {
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.riinode->i_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = fix_md.riinode->i_addr;
err = dir_add(sdp->master_dir, "rindex", 6, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -567,8 +567,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
}
if (fix_md.qinode) {
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.qinode->i_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = fix_md.qinode->i_addr;
err = dir_add(sdp->master_dir, "quota", 5, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -987,7 +987,7 @@ static int is_journal_copy(struct gfs2_inode *ip)
static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
{
struct gfs2_inode *child_ip;
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
int error;
if (ip->i_formal_ino == 2) {
@@ -1032,10 +1032,10 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
ip->i_addr);
fix_md.pinode = ip;
error = dir_search(ip, "..", 2, NULL, &inum);
- if (!error && inum.no_addr) {
- sdp->sd_meta_dir.no_addr = inum.no_addr;
+ if (!error && inum.in_addr) {
+ sdp->sd_meta_dir.no_addr = inum.in_addr;
log_warn(_("From per_node's '..' master directory backtracked to: "
- "0x%"PRIx64"\n"), inum.no_addr);
+ "0x%"PRIx64"\n"), inum.in_addr);
}
return;
}
@@ -1076,7 +1076,7 @@ out_discard_ip:
static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
{
struct gfs2_inode *parent_ip;
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
int error;
if (sdp->sd_root_dir.no_addr) /* if we know the root dinode */
@@ -1126,8 +1126,8 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
ip = parent_ip;
}
error = dir_search(ip, "..", 2, NULL, &inum);
- if (!error && inum.no_addr && inum.no_addr < possible_root) {
- possible_root = inum.no_addr;
+ if (!error && inum.in_addr && inum.in_addr < possible_root) {
+ possible_root = inum.in_addr;
log_debug(_("Found a possible root at: 0x%"PRIx64"\n"),
possible_root);
}
@@ -1278,8 +1278,6 @@ static int sb_repair(struct gfs2_sbd *sdp)
return -1;
}
if (!sdp->sd_root_dir.no_addr) {
- struct gfs2_inum inum;
-
log_err(_("Unable to locate the root directory.\n"));
if (possible_root == HIGHEST_BLOCK) {
/* Take advantage of the fact that mkfs.gfs2
@@ -1294,6 +1292,7 @@ static int sb_repair(struct gfs2_sbd *sdp)
sdp->md.rooti = lgfs2_inode_read(sdp, possible_root);
if (!sdp->md.rooti || sdp->md.rooti->i_magic != GFS2_MAGIC) {
struct gfs2_buffer_head *bh = NULL;
+ struct lgfs2_inum inum;
log_err(_("The root dinode block is destroyed.\n"));
log_err(_("At this point I recommend "
@@ -1306,8 +1305,8 @@ static int sb_repair(struct gfs2_sbd *sdp)
"reinitialized; aborting.\n"));
return -1;
}
- inum.no_formal_ino = 1;
- inum.no_addr = possible_root;
+ inum.in_formal_ino = 1;
+ inum.in_addr = possible_root;
error = init_dinode(sdp, &bh, &inum, S_IFDIR | 0755, 0, &inum);
if (error != 0)
return -1;
diff --git a/gfs2/fsck/inode_hash.c b/gfs2/fsck/inode_hash.c
index 09303d73..a1e67b23 100644
--- a/gfs2/fsck/inode_hash.c
+++ b/gfs2/fsck/inode_hash.c
@@ -19,9 +19,9 @@ struct inode_info *inodetree_find(uint64_t block)
while (node) {
struct inode_info *data = (struct inode_info *)node;
- if (block < data->di_num.no_addr)
+ if (block < data->num.in_addr)
node = node->osi_left;
- else if (block > data->di_num.no_addr)
+ else if (block > data->num.in_addr)
node = node->osi_right;
else
return data;
@@ -29,7 +29,7 @@ struct inode_info *inodetree_find(uint64_t block)
return NULL;
}
-struct inode_info *inodetree_insert(struct gfs2_inum di_num)
+struct inode_info *inodetree_insert(struct lgfs2_inum no)
{
struct osi_node **newn = &inodetree.osi_node, *parent = NULL;
struct inode_info *data;
@@ -39,9 +39,9 @@ struct inode_info *inodetree_insert(struct gfs2_inum di_num)
struct inode_info *cur = (struct inode_info *)*newn;
parent = *newn;
- if (di_num.no_addr < cur->di_num.no_addr)
+ if (no.in_addr < cur->num.in_addr)
newn = &((*newn)->osi_left);
- else if (di_num.no_addr > cur->di_num.no_addr)
+ else if (no.in_addr > cur->num.in_addr)
newn = &((*newn)->osi_right);
else
return cur;
@@ -53,7 +53,7 @@ struct inode_info *inodetree_insert(struct gfs2_inum di_num)
return NULL;
}
/* Add new node and rebalance tree. */
- data->di_num = di_num;
+ data->num = no;
osi_link_node(&data->node, parent, newn);
osi_insert_color(&data->node, &inodetree);
diff --git a/gfs2/fsck/inode_hash.h b/gfs2/fsck/inode_hash.h
index ba18ab22..da9d15ce 100644
--- a/gfs2/fsck/inode_hash.h
+++ b/gfs2/fsck/inode_hash.h
@@ -4,7 +4,7 @@
struct inode_info;
extern struct inode_info *inodetree_find(uint64_t block);
-extern struct inode_info *inodetree_insert(struct gfs2_inum di_num);
+extern struct inode_info *inodetree_insert(struct lgfs2_inum no);
extern void inodetree_delete(struct inode_info *b);
#endif /* _INODE_HASH_H */
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index 1c5ec3d2..43dd6df4 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -60,9 +60,9 @@ int set_di_nlink(struct gfs2_inode *ip)
/* If the list has entries, look for one that matches inode_no */
ii = inodetree_find(ip->i_addr);
if (!ii) {
- struct gfs2_inum no = {
- .no_addr = ip->i_addr,
- .no_formal_ino = ip->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = ip->i_addr,
+ .in_formal_ino = ip->i_formal_ino
};
ii = inodetree_insert(no);
}
@@ -81,48 +81,47 @@ int set_di_nlink(struct gfs2_inode *ip)
(unsigned long long)referenced_from, counted_links, \
(unsigned long long)no_addr, why);
-int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip,
- const char *why)
+int incr_link_count(struct lgfs2_inum no, struct gfs2_inode *ip, const char *why)
{
struct inode_info *ii = NULL;
uint64_t referenced_from = ip ? ip->i_addr : 0;
struct dir_info *di;
struct gfs2_inode *link_ip;
- di = dirtree_find(no.no_addr);
+ di = dirtree_find(no.in_addr);
if (di) {
- if (di->dinode.no_formal_ino != no.no_formal_ino)
+ if (di->dinode.in_formal_ino != no.in_formal_ino)
return INCR_LINK_INO_MISMATCH;
di->counted_links++;
- whyincr(no.no_addr, why, referenced_from, di->counted_links);
+ whyincr(no.in_addr, why, referenced_from, di->counted_links);
return INCR_LINK_GOOD;
}
- ii = inodetree_find(no.no_addr);
+ ii = inodetree_find(no.in_addr);
/* If the list has entries, look for one that matches inode_no */
if (ii) {
- if (ii->di_num.no_formal_ino != no.no_formal_ino)
+ if (ii->num.in_formal_ino != no.in_formal_ino)
return INCR_LINK_INO_MISMATCH;
ii->counted_links++;
- whyincr(no.no_addr, why, referenced_from, ii->counted_links);
+ whyincr(no.in_addr, why, referenced_from, ii->counted_links);
return INCR_LINK_GOOD;
}
- if (link1_type(&clink1map, no.no_addr) != 1) {
- link1_set(&clink1map, no.no_addr, 1);
- whyincr(no.no_addr, why, referenced_from, 1);
+ if (link1_type(&clink1map, no.in_addr) != 1) {
+ link1_set(&clink1map, no.in_addr, 1);
+ whyincr(no.in_addr, why, referenced_from, 1);
return INCR_LINK_GOOD;
}
- link_ip = fsck_load_inode(ip->i_sbd, no.no_addr);
+ link_ip = fsck_load_inode(ip->i_sbd, no.in_addr);
/* Check formal ino against dinode before adding to inode tree. */
- if (no.no_formal_ino != link_ip->i_formal_ino) {
+ if (no.in_formal_ino != link_ip->i_formal_ino) {
fsck_inode_put(&link_ip);
return INCR_LINK_INO_MISMATCH; /* inode mismatch */
}
/* Move it from the link1 maps to a real inode tree entry */
- link1_set(&nlink1map, no.no_addr, 0);
- link1_set(&clink1map, no.no_addr, 0);
+ link1_set(&nlink1map, no.in_addr, 0);
+ link1_set(&clink1map, no.in_addr, 0);
/* If no match was found, it must be a hard link. In theory, it can't
be a duplicate because those were resolved in pass1b. Add a new
@@ -132,17 +131,17 @@ int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip,
log_debug( _("Ref: (0x%llx) Error incrementing link for "
"(0x%llx)!\n"),
(unsigned long long)referenced_from,
- (unsigned long long)no.no_addr);
+ (unsigned long long)no.in_addr);
fsck_inode_put(&link_ip);
return INCR_LINK_BAD;
}
- ii->di_num.no_addr = link_ip->i_addr;
- ii->di_num.no_formal_ino = link_ip->i_formal_ino;
+ ii->num.in_addr = link_ip->i_addr;
+ ii->num.in_formal_ino = link_ip->i_formal_ino;
fsck_inode_put(&link_ip);
ii->di_nlink = 1; /* Must be 1 or it wouldn't have gotten into the
nlink1map */
ii->counted_links = 2;
- whyincr(no.no_addr, why, referenced_from, ii->counted_links);
+ whyincr(no.in_addr, why, referenced_from, ii->counted_links);
/* We transitioned a dentry link count from 1 to 2, and we know it's
not a directory. But the new reference has the correct formal
inode number, so the first reference is suspect: we need to
diff --git a/gfs2/fsck/link.h b/gfs2/fsck/link.h
index 0b300225..98872d7b 100644
--- a/gfs2/fsck/link.h
+++ b/gfs2/fsck/link.h
@@ -13,8 +13,7 @@ enum {
int link1_set(struct gfs2_bmap *bmap, uint64_t bblock, int mark);
int set_di_nlink(struct gfs2_inode *ip);
-int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip,
- const char *why);
+int incr_link_count(struct lgfs2_inum no, struct gfs2_inode *ip, const char *why);
int decr_link_count(uint64_t inode_no, uint64_t referenced_from, int gfs1,
const char *why);
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 59df4c05..4e543fb1 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -22,7 +22,7 @@ static void add_dotdot(struct gfs2_inode *ip)
{
struct gfs2_sbd *sdp = ip->i_sbd;
struct dir_info *di;
- struct gfs2_inum no;
+ struct lgfs2_inum no;
int err;
log_info(_("Adding .. entry to directory %"PRIu64" (0x%"PRIx64") pointing back to lost+found\n"),
@@ -31,14 +31,14 @@ static void add_dotdot(struct gfs2_inode *ip)
/* If there's a pre-existing .. directory entry, we have to
back out the links. */
di = dirtree_find(ip->i_addr);
- if (di && valid_block(sdp, di->dotdot_parent.no_addr)) {
+ if (di && valid_block(sdp, di->dotdot_parent.in_addr)) {
struct gfs2_inode *dip;
log_debug(_("Directory (0x%"PRIx64") already had a '..' link to (0x%"PRIx64").\n"),
- ip->i_addr, di->dotdot_parent.no_addr);
- dip = fsck_load_inode(sdp, di->dotdot_parent.no_addr);
- if (dip->i_formal_ino == di->dotdot_parent.no_formal_ino) {
- decr_link_count(di->dotdot_parent.no_addr, ip->i_addr, sdp->gfs1,
+ ip->i_addr, di->dotdot_parent.in_addr);
+ dip = fsck_load_inode(sdp, di->dotdot_parent.in_addr);
+ if (dip->i_formal_ino == di->dotdot_parent.in_formal_ino) {
+ decr_link_count(di->dotdot_parent.in_addr, ip->i_addr, sdp->gfs1,
_(".. unlinked, moving to lost+found"));
if (dip->i_nlink > 0) {
dip->i_nlink--;
@@ -59,8 +59,8 @@ static void add_dotdot(struct gfs2_inode *ip)
log_debug(_("Directory (0x%"PRIx64")'s link to parent "
"(0x%"PRIx64") had a formal inode discrepancy: "
"was 0x%"PRIx64", expected 0x%"PRIx64"\n"),
- ip->i_addr, di->dotdot_parent.no_addr,
- di->dotdot_parent.no_formal_ino,
+ ip->i_addr, di->dotdot_parent.in_addr,
+ di->dotdot_parent.in_formal_ino,
dip->i_formal_ino);
log_debug(_("The parent directory was not changed.\n"));
}
@@ -71,7 +71,7 @@ static void add_dotdot(struct gfs2_inode *ip)
log_debug(_("Couldn't find a valid '..' entry "
"for orphan directory (0x%"PRIx64"): "
"'..' = 0x%"PRIx64"\n"),
- ip->i_addr, di->dotdot_parent.no_addr);
+ ip->i_addr, di->dotdot_parent.in_addr);
else
log_debug(_("Couldn't find directory (0x%"PRIx64") "
"in directory tree.\n"),
@@ -81,8 +81,8 @@ static void add_dotdot(struct gfs2_inode *ip)
log_warn( _("add_inode_to_lf: Unable to remove "
"\"..\" directory entry.\n"));
- no.no_addr = lf_dip->i_addr;
- no.no_formal_ino = lf_dip->i_formal_ino;
+ no.in_addr = lf_dip->i_addr;
+ no.in_formal_ino = lf_dip->i_formal_ino;
err = dir_add(ip, "..", 2, &no, (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
if (err) {
log_crit(_("Error adding .. directory: %s\n"),
@@ -127,9 +127,9 @@ void make_sure_lf_exists(struct gfs2_inode *ip)
set_di_nlink(sdp->md.rooti);
if (sdp->md.rooti->i_entries > root_entries) {
- struct gfs2_inum no = {
- .no_addr = lf_dip->i_addr,
- .no_formal_ino = lf_dip->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = lf_dip->i_addr,
+ .in_formal_ino = lf_dip->i_formal_ino
};
lf_was_created = 1;
/* This is a new lost+found directory, so set its block type
@@ -143,12 +143,12 @@ void make_sure_lf_exists(struct gfs2_inode *ip)
the rgrp counts properly. */
fsck_bitmap_set(ip, lf_dip->i_addr, _("lost+found dinode"), GFS2_BLKST_DINODE);
/* root inode links to lost+found */
- no.no_addr = sdp->md.rooti->i_addr;
- no.no_formal_ino = sdp->md.rooti->i_formal_ino;
+ no.in_addr = sdp->md.rooti->i_addr;
+ no.in_formal_ino = sdp->md.rooti->i_formal_ino;
incr_link_count(no, lf_dip, _("root"));
/* lost+found link for '.' from itself */
- no.no_addr = lf_dip->i_addr;
- no.no_formal_ino = lf_dip->i_formal_ino;
+ no.in_addr = lf_dip->i_addr;
+ no.in_formal_ino = lf_dip->i_formal_ino;
incr_link_count(no, lf_dip, "\".\"");
/* lost+found link for '..' back to root */
incr_link_count(no, sdp->md.rooti, "\"..\"");
@@ -178,7 +178,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
char tmp_name[256];
__be32 inode_type;
struct gfs2_sbd *sdp = ip->i_sbd;
- struct gfs2_inum no;
+ struct lgfs2_inum no;
int err = 0;
uint32_t mode;
@@ -229,8 +229,8 @@ int add_inode_to_lf(struct gfs2_inode *ip){
break;
}
- no.no_addr = ip->i_addr;
- no.no_formal_ino = ip->i_formal_ino;
+ no.in_addr = ip->i_addr;
+ no.in_formal_ino = ip->i_formal_ino;
err = dir_add(lf_dip, tmp_name, strlen(tmp_name), &no, inode_type);
if (err) {
log_crit(_("Error adding directory %s: %s\n"),
@@ -242,8 +242,8 @@ int add_inode_to_lf(struct gfs2_inode *ip){
incr_link_count(no, lf_dip, _("from lost+found"));
/* If it's a directory, lost+found is back-linked to it via .. */
if (mode == S_IFDIR) {
- no.no_addr = lf_dip->i_addr;
- no.no_formal_ino = lf_dip->i_formal_ino;
+ no.in_addr = lf_dip->i_addr;
+ no.in_formal_ino = lf_dip->i_formal_ino;
incr_link_count(no, ip, _("to lost+found"));
}
log_notice(_("Added inode #%"PRIu64" (0x%"PRIx64") to lost+found\n"),
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index b699ca8d..d915b085 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -304,7 +304,7 @@ void fsck_inode_put(struct gfs2_inode **ip_in)
/**
* dirent_repair - attempt to repair a corrupt directory entry.
* @bh - The buffer header that contains the bad dirent
- * @de - The directory entry in native format
+ * @dh - The directory entry in native format
* @dent - The directory entry in on-disk format
* @type - Type of directory (DIR_LINEAR or DIR_EXHASH)
* @first - TRUE if this is the first dirent in the buffer
@@ -313,19 +313,19 @@ void fsck_inode_put(struct gfs2_inode **ip_in)
* know at this point is that the length field is wrong.
*/
static int dirent_repair(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
- struct gfs2_dirent *de, struct gfs2_dirent *dent,
+ struct lgfs2_dirent *d, struct gfs2_dirent *dent,
int type, int first)
{
char *bh_end, *p;
int calc_de_name_len = 0;
-
+
/* If this is a sentinel, just fix the length and move on */
- if (first && !de->de_inum.no_formal_ino) { /* Is it a sentinel? */
+ if (first && !d->dr_inum.in_formal_ino) { /* Is it a sentinel? */
if (type == DIR_LINEAR)
- de->de_rec_len = ip->i_sbd->sd_bsize -
+ d->dr_rec_len = ip->i_sbd->sd_bsize -
sizeof(struct gfs2_dinode);
else
- de->de_rec_len = ip->i_sbd->sd_bsize -
+ d->dr_rec_len = ip->i_sbd->sd_bsize -
sizeof(struct gfs2_leaf);
} else {
bh_end = bh->b_data + ip->i_sbd->sd_bsize;
@@ -342,12 +342,12 @@ static int dirent_repair(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
/* There can often be noise at the end, so only */
/* Trust the shorter of the two in case we have too much */
/* Or rather, only trust ours if it's shorter. */
- if (!de->de_name_len || de->de_name_len > NAME_MAX ||
- calc_de_name_len < de->de_name_len) /* if dent is hosed */
- de->de_name_len = calc_de_name_len; /* use ours */
- de->de_rec_len = GFS2_DIRENT_SIZE(de->de_name_len);
+ if (!d->dr_name_len || d->dr_name_len > NAME_MAX ||
+ calc_de_name_len < d->dr_name_len) /* if dent is hosed */
+ d->dr_name_len = calc_de_name_len; /* use ours */
+ d->dr_rec_len = GFS2_DIRENT_SIZE(d->dr_name_len);
}
- gfs2_dirent_out(de, (char *)dent);
+ lgfs2_dirent_out(d, dent);
bmodified(bh);
return 0;
}
@@ -359,14 +359,14 @@ static void dirblk_truncate(struct gfs2_inode *ip, struct gfs2_dirent *fixb,
struct gfs2_buffer_head *bh)
{
char *bh_end;
- struct gfs2_dirent de;
+ struct lgfs2_dirent d;
bh_end = bh->b_data + ip->i_sbd->sd_bsize;
/* truncate the block to save the most dentries. To do this we
have to patch the previous dent. */
- gfs2_dirent_in(&de, (char *)fixb);
- de.de_rec_len = bh_end - (char *)fixb;
- gfs2_dirent_out(&de, (char *)fixb);
+ lgfs2_dirent_in(&d, fixb);
+ d.dr_rec_len = bh_end - (char *)fixb;
+ lgfs2_dirent_out(&d, fixb);
bmodified(bh);
}
@@ -387,8 +387,8 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
int type, uint32_t *count, int lindex,
struct metawalk_fxns *pass)
{
- struct gfs2_dirent *dent;
- struct gfs2_dirent de, *prev;
+ struct gfs2_dirent *dent, *prev;
+ struct lgfs2_dirent d;
int error = 0;
char *bh_end;
char *filename;
@@ -412,20 +412,19 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
while (1) {
if (skip_this_pass || fsck_abort)
return FSCK_OK;
- memset(&de, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&de, (char *)dent);
+ lgfs2_dirent_in(&d, dent);
filename = (char *)dent + sizeof(struct gfs2_dirent);
- if (de.de_rec_len < sizeof(struct gfs2_dirent) +
- de.de_name_len ||
- (de.de_inum.no_formal_ino && !de.de_name_len && !first)) {
+ if (d.dr_rec_len < sizeof(struct gfs2_dirent) +
+ d.dr_name_len ||
+ (d.dr_inum.in_formal_ino && !d.dr_name_len && !first)) {
log_err(_("Directory block %"PRIu64" (0x%"PRIx64"), "
"entry %d of directory %"PRIu64" (0x%"PRIx64") "
"is corrupt.\n"),
bh->b_blocknr, bh->b_blocknr, (*count) + 1,
ip->i_addr, ip->i_addr);
if (query( _("Attempt to repair it? (y/n) "))) {
- if (dirent_repair(ip, bh, &de, dent, type,
+ if (dirent_repair(ip, bh, &d, dent, type,
first)) {
if (first) /* make a new sentinel */
dirblk_truncate(ip, dent, bh);
@@ -448,8 +447,8 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
return 0;
}
}
- if (!de.de_inum.no_formal_ino){
- if (first){
+ if (!d.dr_inum.in_formal_ino) {
+ if (first) {
log_debug( _("First dirent is a sentinel (place holder).\n"));
first = 0;
} else {
@@ -471,12 +470,12 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
return 0;
}
} else {
- if (!de.de_inum.no_addr && first) { /* reverse sentinel */
+ if (!d.dr_inum.in_addr && first) { /* reverse sentinel */
log_debug( _("First dirent is a Sentinel (place holder).\n"));
/* Swap the two to silently make it a proper sentinel */
- de.de_inum.no_addr = de.de_inum.no_formal_ino;
- de.de_inum.no_formal_ino = 0;
- gfs2_dirent_out(&de, (char *)dent);
+ d.dr_inum.in_addr = d.dr_inum.in_formal_ino;
+ d.dr_inum.in_formal_ino = 0;
+ lgfs2_dirent_out(&d, dent);
bmodified(bh);
/* Mark dirent buffer as modified */
first = 0;
@@ -492,7 +491,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
}
}
- if ((char *)dent + de.de_rec_len >= bh_end){
+ if ((char *)dent + d.dr_rec_len >= bh_end){
log_debug(_("Last entry processed for %"PRIu64"->%"PRIu64
"(0x%"PRIx64"->0x%"PRIx64"), di_blocks=%"PRIu64".\n"),
ip->i_addr, bh->b_blocknr, ip->i_addr,
@@ -505,7 +504,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
if (!error || first)
prev = dent;
first = 0;
- dent = (struct gfs2_dirent *)((char *)dent + de.de_rec_len);
+ dent = (struct gfs2_dirent *)((char *)dent + d.dr_rec_len);
}
return 0;
}
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 047a96b0..bd3c360a 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -231,18 +231,16 @@ static int resuscitate_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
uint32_t *count, int *lindex, void *priv)
{
struct gfs2_sbd *sdp = ip->i_sbd;
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_dirent d;
char tmp_name[PATH_MAX];
uint64_t block;
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&dentry, (char *)dent);
- de = &dentry;
- block = de->de_inum.no_addr;
+ lgfs2_dirent_in(&d, dent);
+ block = d.dr_inum.in_addr;
/* Start of checks */
memset(tmp_name, 0, sizeof(tmp_name));
- if (de->de_name_len < sizeof(tmp_name))
- strncpy(tmp_name, filename, de->de_name_len);
+ if (d.dr_name_len < sizeof(tmp_name))
+ strncpy(tmp_name, filename, d.dr_name_len);
else
strncpy(tmp_name, filename, sizeof(tmp_name) - 1);
if (!valid_block_ip(ip, block)) {
@@ -1214,7 +1212,7 @@ struct metawalk_fxns eattr_undo_fxns = {
static int set_ip_blockmap(struct gfs2_inode *ip)
{
uint64_t block = ip->i_bh->b_blocknr;
- struct gfs2_inum no;
+ struct lgfs2_inum no;
uint32_t mode;
const char *ty;
@@ -1248,8 +1246,8 @@ static int set_ip_blockmap(struct gfs2_inode *ip)
default:
return -EINVAL;
}
- no.no_addr = ip->i_addr;
- no.no_formal_ino = ip->i_formal_ino;
+ no.in_addr = ip->i_addr;
+ no.in_formal_ino = ip->i_formal_ino;
if (fsck_blockmap_set(ip, block, ty, GFS2_BLKST_DINODE) ||
(mode == S_IFDIR && !dirtree_insert(no))) {
stack;
@@ -1599,9 +1597,9 @@ static int check_system_inode(struct gfs2_sbd *sdp,
filename, GFS2_BLKST_DINODE);
ds.q = GFS2_BLKST_DINODE;
if (isdir) {
- struct gfs2_inum no = {
- .no_addr = (*sysinode)->i_addr,
- .no_formal_ino = (*sysinode)->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = (*sysinode)->i_addr,
+ .in_formal_ino = (*sysinode)->i_formal_ino
};
dirtree_insert(no);
}
@@ -1652,9 +1650,9 @@ static int check_system_inode(struct gfs2_sbd *sdp,
filename, GFS2_BLKST_DINODE);
ds.q = GFS2_BLKST_DINODE;
if (isdir) {
- struct gfs2_inum no = {
- .no_addr = (*sysinode)->i_addr,
- .no_formal_ino = (*sysinode)->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = (*sysinode)->i_addr,
+ .in_formal_ino = (*sysinode)->i_formal_ino
};
dirtree_insert(no);
}
@@ -1769,21 +1767,21 @@ static int check_system_inodes(struct gfs2_sbd *sdp)
journal_count = sdp->md.journals;
/* gfs1's journals aren't dinode, they're just a bunch of blocks. */
if (sdp->gfs1) {
- struct gfs2_inum no;
+ struct lgfs2_inum no;
/* gfs1 has four dinodes that are set in the superblock and
therefore not linked to anything else. We need to adjust
the link counts so pass4 doesn't get confused. */
- no.no_addr = sdp->md.statfs->i_addr;
- no.no_formal_ino = sdp->md.statfs->i_formal_ino;
+ no.in_addr = sdp->md.statfs->i_addr;
+ no.in_formal_ino = sdp->md.statfs->i_formal_ino;
incr_link_count(no, NULL, _("gfs1 statfs inode"));
- no.no_addr = sdp->md.jiinode->i_addr;
- no.no_formal_ino = sdp->md.jiinode->i_formal_ino;
+ no.in_addr = sdp->md.jiinode->i_addr;
+ no.in_formal_ino = sdp->md.jiinode->i_formal_ino;
incr_link_count(no, NULL, _("gfs1 jindex inode"));
- no.no_addr = sdp->md.riinode->i_addr;
- no.no_formal_ino = sdp->md.riinode->i_formal_ino;
+ no.in_addr = sdp->md.riinode->i_addr;
+ no.in_formal_ino = sdp->md.riinode->i_formal_ino;
incr_link_count(no, NULL, _("gfs1 rindex inode"));
- no.no_addr = sdp->md.qinode->i_addr;
- no.no_formal_ino = sdp->md.qinode->i_formal_ino;
+ no.in_addr = sdp->md.qinode->i_addr;
+ no.in_formal_ino = sdp->md.qinode->i_formal_ino;
incr_link_count(no, NULL, _("gfs1 quota inode"));
return 0;
}
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index d8d08056..f3fdd4cb 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -32,48 +32,37 @@ struct metawalk_fxns delete_eattrs = {
/* Set children's parent inode in dir_info structure - ext2 does not set
* dotdot inode here, but instead in pass3 - should we? */
-static int set_parent_dir(struct gfs2_sbd *sdp, struct gfs2_inum child,
- struct gfs2_inum parent)
+static int set_parent_dir(struct gfs2_sbd *sdp, struct lgfs2_inum child, struct lgfs2_inum parent)
{
struct dir_info *di;
- di = dirtree_find(child.no_addr);
+ di = dirtree_find(child.in_addr);
if (!di) {
- log_err( _("Unable to find block %llu (0x%llx"
- ") in dir_info list\n"),
- (unsigned long long)child.no_addr,
- (unsigned long long)child.no_addr);
+ log_err(_("Unable to find block %"PRIu64" (0x%"PRIx64") in dir_info list\n"),
+ child.in_addr, child.in_addr);
return -1;
}
- if (di->dinode.no_addr == child.no_addr &&
- di->dinode.no_formal_ino == child.no_formal_ino) {
+ if (di->dinode.in_addr == child.in_addr &&
+ di->dinode.in_formal_ino == child.in_formal_ino) {
if (di->treewalk_parent) {
- log_err( _("Another directory at block %lld (0x%llx) "
- "already contains this child %lld (0x%llx)"
- " - checking parent %lld (0x%llx)\n"),
- (unsigned long long)di->treewalk_parent,
- (unsigned long long)di->treewalk_parent,
- (unsigned long long)child.no_addr,
- (unsigned long long)child.no_addr,
- (unsigned long long)parent.no_addr,
- (unsigned long long)parent.no_addr);
+ log_err(_("Another directory at block %"PRIu64" (0x%"PRIx64") "
+ "already contains this child %"PRIu64" (0x%"PRIx64")"
+ " - checking parent %"PRIu64" (0x%"PRIx64")\n"),
+ di->treewalk_parent, di->treewalk_parent, child.in_addr,
+ child.in_addr, parent.in_addr, parent.in_addr);
return 1;
}
- log_debug( _("Child %lld (0x%llx) has parent %lld (0x%llx)\n"),
- (unsigned long long)child.no_addr,
- (unsigned long long)child.no_addr,
- (unsigned long long)parent.no_addr,
- (unsigned long long)parent.no_addr);
- di->treewalk_parent = parent.no_addr;
+ log_debug(_("Child %"PRIu64" (0x%"PRIx64") has parent %"PRIu64" (0x%"PRIx64")\n"),
+ child.in_addr, child.in_addr, parent.in_addr, parent.in_addr);
+ di->treewalk_parent = parent.in_addr;
}
return 0;
}
/* Set's the child's '..' directory inode number in dir_info structure */
-static int set_dotdot_dir(struct gfs2_sbd *sdp, uint64_t childblock,
- struct gfs2_inum parent)
+static int set_dotdot_dir(struct gfs2_sbd *sdp, uint64_t childblock, struct lgfs2_inum parent)
{
struct dir_info *di;
@@ -83,30 +72,25 @@ static int set_dotdot_dir(struct gfs2_sbd *sdp, uint64_t childblock,
") in dir_info tree\n"), childblock, childblock);
return -1;
}
- if (di->dinode.no_addr != childblock) {
+ if (di->dinode.in_addr != childblock) {
log_debug("'..' doesn't point to what we found: childblock "
- "(0x%llx) != dinode (0x%llx)\n",
- (unsigned long long)childblock,
- (unsigned long long)di->dinode.no_addr);
+ "(0x%"PRIx64") != dinode (0x%"PRIx64")\n",
+ childblock, di->dinode.in_addr);
return -1;
}
/* Special case for root inode because we set it earlier */
- if (di->dotdot_parent.no_addr &&
- sdp->md.rooti->i_addr != di->dinode.no_addr) {
+ if (di->dotdot_parent.in_addr &&
+ sdp->md.rooti->i_addr != di->dinode.in_addr) {
/* This should never happen */
- log_crit( _("Dotdot parent already set for block %llu (0x%llx)"
- "-> %llu (0x%llx)\n"),
- (unsigned long long)childblock,
- (unsigned long long)childblock,
- (unsigned long long)di->dotdot_parent.no_addr,
- (unsigned long long)di->dotdot_parent.no_addr);
+ log_crit(_("Dotdot parent already set for block %"PRIu64" (0x%"PRIx64") "
+ "-> %"PRIu64" (0x%"PRIx64")\n"),
+ childblock, childblock, di->dotdot_parent.in_addr, di->dotdot_parent.in_addr);
return -1;
}
- log_debug("Setting '..' for directory block (0x%llx) to parent "
- "(0x%llx)\n", (unsigned long long)childblock,
- (unsigned long long)parent.no_addr);
- di->dotdot_parent.no_addr = parent.no_addr;
- di->dotdot_parent.no_formal_ino = parent.no_formal_ino;
+ log_debug("Setting '..' for directory block (0x%"PRIx64") to parent (0x%"PRIx64")\n",
+ childblock, parent.in_addr);
+ di->dotdot_parent.in_addr = parent.in_addr;
+ di->dotdot_parent.in_formal_ino = parent.in_formal_ino;
return 0;
}
@@ -176,42 +160,41 @@ struct metawalk_fxns pass2_fxns_delete = {
* 1 if the caller should delete the dirent
*/
static int bad_formal_ino(struct gfs2_inode *ip, struct gfs2_dirent *dent,
- struct gfs2_inum entry, const char *tmp_name,
- int q, struct gfs2_dirent *de,
+ struct lgfs2_inum entry, const char *tmp_name,
+ int q, struct lgfs2_dirent *d,
struct gfs2_buffer_head *bh)
{
struct inode_info *ii;
struct dir_info *di = NULL;
struct gfs2_inode *child_ip;
- struct gfs2_inum childs_dotdot;
+ struct lgfs2_inum childs_dotdot;
struct gfs2_sbd *sdp = ip->i_sbd;
int error;
- struct gfs2_inum inum = { 0 };
+ struct lgfs2_inum inum = {0};
- ii = inodetree_find(entry.no_addr);
+ ii = inodetree_find(entry.in_addr);
if (ii)
- inum = ii->di_num;
+ inum = ii->num;
else {
- di = dirtree_find(entry.no_addr);
+ di = dirtree_find(entry.in_addr);
if (di)
inum = di->dinode;
- else if (link1_type(&clink1map, entry.no_addr) == 1) {
+ else if (link1_type(&clink1map, entry.in_addr) == 1) {
struct gfs2_inode *dent_ip;
- dent_ip = fsck_load_inode(ip->i_sbd, entry.no_addr);
- inum.no_addr = dent_ip->i_addr;
- inum.no_formal_ino = dent_ip->i_formal_ino;
+ dent_ip = fsck_load_inode(ip->i_sbd, entry.in_addr);
+ inum.in_addr = dent_ip->i_addr;
+ inum.in_formal_ino = dent_ip->i_formal_ino;
fsck_inode_put(&dent_ip);
}
}
log_err(_("Directory entry '%s' pointing to block %"PRIu64" (0x%"PRIx64") in "
"directory %"PRIu64" (0x%"PRIx64") has the wrong 'formal' inode number.\n"),
- tmp_name, entry.no_addr, entry.no_addr, ip->i_addr, ip->i_addr);
- log_err(_("The directory entry has %llu (0x%llx) but the inode has "
- "%llu (0x%llx)\n"), (unsigned long long)entry.no_formal_ino,
- (unsigned long long)entry.no_formal_ino,
- (unsigned long long)inum.no_formal_ino,
- (unsigned long long)inum.no_formal_ino);
+ tmp_name, entry.in_addr, entry.in_addr, ip->i_addr, ip->i_addr);
+ log_err(_("The directory entry has %"PRIu64" (0x%"PRIx64") "
+ "but the inode has %"PRIu64" (0x%"PRIx64")\n"),
+ entry.in_formal_ino, entry.in_formal_ino,
+ inum.in_formal_ino, inum.in_formal_ino);
if (q != GFS2_BLKST_DINODE || !strcmp("..", tmp_name)) {
if (query( _("Remove the corrupt directory entry? (y/n) ")))
return 1;
@@ -221,21 +204,21 @@ static int bad_formal_ino(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* We have a directory pointing to another directory, but the
formal inode number still doesn't match. If that directory
has a '..' pointing back, just fix up the no_formal_ino. */
- child_ip = lgfs2_inode_read(sdp, entry.no_addr);
+ child_ip = lgfs2_inode_read(sdp, entry.in_addr);
error = dir_search(child_ip, "..", 2, NULL, &childs_dotdot);
- if (!error && childs_dotdot.no_addr == ip->i_addr) {
+ if (!error && childs_dotdot.in_addr == ip->i_addr) {
log_err( _("The entry points to another directory with intact "
"linkage.\n"));
if (query( _("Fix the bad directory entry? (y/n) "))) {
- struct gfs2_inum no;
+ struct lgfs2_inum no;
log_err( _("Fixing the corrupt directory entry.\n"));
- entry.no_formal_ino = inum.no_formal_ino;
- de->de_inum.no_formal_ino = entry.no_formal_ino;
- gfs2_dirent_out(de, (char *)dent);
+ entry.in_formal_ino = inum.in_formal_ino;
+ d->dr_inum.in_formal_ino = entry.in_formal_ino;
+ lgfs2_dirent_out(d, dent);
bmodified(bh);
incr_link_count(entry, ip, _("fixed reference"));
- no.no_addr = ip->i_addr;
- no.no_formal_ino = ip->i_formal_ino;
+ no.in_addr = ip->i_addr;
+ no.in_formal_ino = ip->i_formal_ino;
set_parent_dir(sdp, entry, no);
} else {
log_err( _("Directory entry not fixed.\n"));
@@ -309,11 +292,11 @@ static int check_leaf_depth(struct gfs2_inode *ip, uint64_t leaf_no,
* Returns: 1 if the dirent is to be removed, 0 if it needs to be kept,
* or -1 on error
*/
-static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
+static int wrong_leaf(struct gfs2_inode *ip, struct lgfs2_inum *entry,
const char *tmp_name, int *lindex, int lindex_max,
int hash_index, struct gfs2_buffer_head *bh,
struct dir_status *ds, struct gfs2_dirent *dent,
- struct gfs2_dirent *de, struct gfs2_dirent *prev_de,
+ struct lgfs2_dirent *d, struct gfs2_dirent *prev_de,
uint32_t *count, int q)
{
struct gfs2_sbd *sdp = ip->i_sbd;
@@ -323,10 +306,8 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
uint64_t *tbl;
int di_depth;
- log_err(_("Directory entry '%s' at block %lld (0x%llx) is on the "
- "wrong leaf block.\n"), tmp_name,
- (unsigned long long)entry->no_addr,
- (unsigned long long)entry->no_addr);
+ log_err(_("Directory entry '%s' at block %"PRIu64" (0x%"PRIx64") is on the wrong leaf block.\n"),
+ tmp_name, entry->in_addr, entry->in_addr);
log_err(_("Leaf index is: 0x%x. The range for this leaf block is "
"0x%x - 0x%x\n"), hash_index, *lindex, lindex_max);
if (!query( _("Move the misplaced directory entry to "
@@ -361,7 +342,7 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
free(tbl);
/* check if it's already on the correct leaf block */
- error = dir_search(ip, tmp_name, de->de_name_len, NULL, &de->de_inum);
+ error = dir_search(ip, tmp_name, d->dr_name_len, NULL, &d->dr_inum);
if (!error) {
log_err(_("The misplaced directory entry already appears on "
"the correct leaf block.\n"));
@@ -371,8 +352,7 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
}
di_depth = ip->i_depth;
- if (dir_add(ip, tmp_name, de->de_name_len, &de->de_inum,
- de->de_type) == 0) {
+ if (dir_add(ip, tmp_name, d->dr_name_len, &d->dr_inum, d->dr_type) == 0) {
log_err(_("The misplaced directory entry was moved to a "
"valid leaf block.\n"));
if (ip->i_depth > di_depth) {
@@ -406,12 +386,12 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
leaf, but that leaf has already been processed. So we have
to nuke the dent from this leaf when we return, but we
still need to do the "good dent" accounting. */
- if (de->de_type == (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR)) {
- struct gfs2_inum no = {
- .no_addr = ip->i_addr,
- .no_formal_ino = ip->i_formal_ino
+ if (d->dr_type == (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR)) {
+ struct lgfs2_inum no = {
+ .in_addr = ip->i_addr,
+ .in_formal_ino = ip->i_formal_ino
};
- error = set_parent_dir(sdp, de->de_inum, no);
+ error = set_parent_dir(sdp, d->dr_inum, no);
if (error > 0)
/* This is a bit of a kludge, but returning 0
in this case causes the caller to go through
@@ -419,10 +399,9 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
deal properly with the hard link. */
return 0;
}
- error = incr_link_count(*entry, ip,
- _("moved valid reference"));
+ error = incr_link_count(*entry, ip, _("moved valid reference"));
if (error > 0 &&
- bad_formal_ino(ip, dent, *entry, tmp_name, q, de, bh) == 1)
+ bad_formal_ino(ip, dent, *entry, tmp_name, q, d, bh) == 1)
return 1; /* nuke it */
/* You cannot do this:
@@ -451,8 +430,8 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
* Returns: 1 means corruption, nuke the dentry, 0 means checks pass
*/
static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
- struct gfs2_inum *entry, const char *tmp_name,
- uint32_t *count, struct gfs2_dirent *de,
+ struct lgfs2_inum *entry, const char *tmp_name,
+ uint32_t *count, struct lgfs2_dirent *d,
struct dir_status *ds, int *q,
struct gfs2_buffer_head *bh, int *isdir)
{
@@ -462,10 +441,10 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
int error;
struct inode_info *ii;
struct dir_info *di = NULL;
- struct gfs2_inum inum = { 0 };
+ struct lgfs2_inum inum = {0};
*isdir = 0;
- if (!valid_block_ip(ip, entry->no_addr)) {
+ if (!valid_block_ip(ip, entry->in_addr)) {
log_err(_("Block # referenced by directory entry %s in inode %"PRIu64
" (0x%"PRIx64") is invalid\n"),
tmp_name, ip->i_addr, ip->i_addr);
@@ -481,11 +460,11 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
}
- if (de->de_rec_len < GFS2_DIRENT_SIZE(de->de_name_len) ||
- de->de_name_len > GFS2_FNAMESIZE) {
+ if (d->dr_rec_len < GFS2_DIRENT_SIZE(d->dr_name_len) ||
+ d->dr_name_len > GFS2_FNAMESIZE) {
log_err( _("Dir entry with bad record or name length\n"
"\tRecord length = %u\n\tName length = %u\n"),
- de->de_rec_len, de->de_name_len);
+ d->dr_rec_len, d->dr_name_len);
if (!query( _("Clear the directory entry? (y/n) "))) {
log_err( _("Directory entry not fixed.\n"));
return 0;
@@ -500,29 +479,29 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
return 1;
}
- calculated_hash = gfs2_disk_hash(tmp_name, de->de_name_len);
- if (de->de_hash != calculated_hash){
+ calculated_hash = gfs2_disk_hash(tmp_name, d->dr_name_len);
+ if (d->dr_hash != calculated_hash){
log_err( _("Dir entry with bad hash or name length\n"
"\tHash found = %u (0x%x)\n"
"\tFilename = %s\n"),
- de->de_hash, de->de_hash, tmp_name);
+ d->dr_hash, d->dr_hash, tmp_name);
log_err( _("\tName length found = %u\n"
"\tHash expected = %u (0x%x)\n"),
- de->de_name_len, calculated_hash, calculated_hash);
+ d->dr_name_len, calculated_hash, calculated_hash);
if (!query( _("Fix directory hash for %s? (y/n) "),
tmp_name)) {
log_err( _("Directory entry hash for %s not "
"fixed.\n"), tmp_name);
return 0;
}
- de->de_hash = calculated_hash;
- gfs2_dirent_out(de, (char *)dent);
+ d->dr_hash = calculated_hash;
+ lgfs2_dirent_out(d, dent);
bmodified(bh);
log_err( _("Directory entry hash for %s fixed.\n"),
tmp_name);
}
- *q = bitmap_type(sdp, entry->no_addr);
+ *q = bitmap_type(sdp, entry->in_addr);
/* Get the status of the directory inode */
/**
* 1. Blocks marked "invalid" were invalidated due to duplicate
@@ -539,7 +518,7 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (*q != GFS2_BLKST_DINODE) {
log_err(_("Directory entry '%s' referencing inode %"PRIu64" (0x%"PRIx64") "
"in dir inode %"PRIu64" (0x%"PRIx64") block type %d: %s.\n"),
- tmp_name, entry->no_addr, entry->no_addr, ip->i_addr, ip->i_addr,
+ tmp_name, entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr,
*q, *q == GFS2_BLKST_FREE ?
_("was previously marked invalid") :
_("was deleted or is not an inode"));
@@ -568,32 +547,30 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
return 1;
}
- error = check_file_type(entry->no_addr, de->de_type, *q, sdp->gfs1,
- isdir);
+ error = check_file_type(entry->in_addr, d->dr_type, *q, sdp->gfs1, isdir);
if (error < 0) {
log_err(_("Error: directory entry type is incompatible with block type at block %"PRIu64
" (0x%"PRIx64") in directory inode %"PRIu64" (0x%"PRIx64").\n"),
- entry->no_addr, entry->no_addr, ip->i_addr, ip->i_addr);
+ entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr);
log_err( _("Directory entry type is %d, block type is %d.\n"),
- de->de_type, *q);
+ d->dr_type, *q);
stack;
return -1;
}
if (error > 0) {
- log_err( _("Type '%s' in dir entry (%s, %llu/0x%llx) conflicts"
+ log_err( _("Type '%s' in dir entry (%s, %"PRIu64"/0x%"PRIx64") conflicts"
" with type '%s' in dinode. (Dir entry is stale.)\n"),
- de_type_string(de->de_type), tmp_name,
- (unsigned long long)entry->no_addr,
- (unsigned long long)entry->no_addr,
+ de_type_string(d->dr_type), tmp_name,
+ entry->in_addr, entry->in_addr,
block_type_string(*q));
if (!query( _("Clear stale directory entry? (y/n) "))) {
log_err( _("Stale directory entry remains\n"));
return 0;
}
- if (ip->i_addr == entry->no_addr)
+ if (ip->i_addr == entry->in_addr)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sdp, entry->no_addr);
+ entry_ip = fsck_load_inode(sdp, entry->in_addr);
check_inode_eattr(entry_ip, &delete_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -601,28 +578,28 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
/* We need to verify the formal inode number matches. If it doesn't,
it needs to be deleted. */
- ii = inodetree_find(entry->no_addr);
+ ii = inodetree_find(entry->in_addr);
if (ii)
- inum = ii->di_num;
+ inum = ii->num;
else {
- di = dirtree_find(entry->no_addr);
+ di = dirtree_find(entry->in_addr);
if (di)
inum = di->dinode;
- else if (link1_type(&nlink1map, entry->no_addr) == 1) {
+ else if (link1_type(&nlink1map, entry->in_addr) == 1) {
/* Since we don't have ii or di, the only way to
validate formal_ino is to read in the inode, which
would kill performance. So skip it for now. */
return 0;
}
}
- if (inum.no_formal_ino != entry->no_formal_ino) {
+ if (inum.in_formal_ino != entry->in_formal_ino) {
log_err(_("Directory entry '%s' pointing to block %"PRIu64" (0x%"PRIx64") "
"in directory %"PRIu64" (0x%"PRIx64") has the wrong 'formal' inode number.\n"),
- tmp_name, entry->no_addr, entry->no_addr, ip->i_addr, ip->i_addr);
+ tmp_name, entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr);
log_err(_("The directory entry has %"PRIu64" (0x%"PRIx64") but the "
"inode has %"PRIu64" (0x%"PRIx64")\n"),
- entry->no_formal_ino, entry->no_formal_ino,
- inum.no_formal_ino, inum.no_formal_ino);
+ entry->in_formal_ino, entry->in_formal_ino,
+ inum.in_formal_ino, inum.in_formal_ino);
return 1;
}
/* Check for a special case where a (bad) GFS1 dirent points to what
@@ -632,12 +609,12 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (ii == NULL && di == NULL && sdp->gfs1) {
struct gfs2_buffer_head *tbh;
- tbh = bread(sdp, entry->no_addr);
+ tbh = bread(sdp, entry->in_addr);
if (gfs2_check_meta(tbh->b_data, GFS2_METATYPE_DI)) { /* not dinode */
log_err(_("Directory entry '%s' pointing to block %"PRIu64
" (0x%"PRIx64") in directory %"PRIu64" (0x%"PRIx64") "
"is not really a GFS1 dinode.\n"), tmp_name,
- entry->no_addr, entry->no_addr, ip->i_addr, ip->i_addr);
+ entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr);
brelse(tbh);
return 1;
}
@@ -653,42 +630,40 @@ static int dirref_find(struct gfs2_inode *ip, struct gfs2_dirent *dent,
{
/* the metawalk_fxn's private field must be set to the dentry
* block we want to clear */
- struct gfs2_inum *entry = (struct gfs2_inum *)private;
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_inum *entry = private;
+ struct lgfs2_dirent dentry, *de;
char fn[MAX_FILENAME];
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&dentry, (char *)dent);
+ memset(&dentry, 0, sizeof(dentry));
+ lgfs2_dirent_in(&dentry, dent);
de = &dentry;
- if (de->de_inum.no_addr != entry->no_addr) {
+ if (de->dr_inum.in_addr != entry->in_addr) {
(*count)++;
return 0;
}
- if (de->de_inum.no_formal_ino == dent->de_inum.no_formal_ino) {
+ if (de->dr_inum.in_formal_ino == be64_to_cpu(dent->de_inum.no_formal_ino)) {
log_debug("Formal inode number matches; must be a hard "
"link.\n");
goto out;
}
log_err(_("The original reference to inode %"PRIu64" (0x%"PRIx64") from "
"directory %"PRIu64" (0x%"PRIx64") has the wrong 'formal' inode "
- "number.\n"), entry->no_addr, entry->no_addr, ip->i_addr, ip->i_addr);
+ "number.\n"), entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr);
memset(fn, 0, sizeof(fn));
- if (de->de_name_len < MAX_FILENAME)
- strncpy(fn, filename, de->de_name_len);
+ if (de->dr_name_len < MAX_FILENAME)
+ strncpy(fn, filename, de->dr_name_len);
else
strncpy(fn, filename, MAX_FILENAME - 1);
- log_err(_("The bad reference '%s' had formal inode number: %lld "
- "(0x%llx) but the correct value is: %lld (0x%llx)\n"),
- fn, (unsigned long long)de->de_inum.no_formal_ino,
- (unsigned long long)de->de_inum.no_formal_ino,
- (unsigned long long)entry->no_formal_ino,
- (unsigned long long)entry->no_formal_ino);
+ log_err(_("The bad reference '%s' had formal inode number: %"PRIu64
+ " (0x%"PRIx64") but the correct value is: %"PRIu64" (0x%"PRIx64")\n"),
+ fn, de->dr_inum.in_formal_ino, de->dr_inum.in_formal_ino,
+ entry->in_formal_ino, entry->in_formal_ino);
if (!query(_("Delete the bad directory entry? (y/n) "))) {
log_err(_("The corrupt directory entry was not fixed.\n"));
goto out;
}
- decr_link_count(entry->no_addr, ip->i_addr, ip->i_sbd->gfs1,
+ decr_link_count(entry->in_addr, ip->i_addr, ip->i_sbd->gfs1,
_("bad original reference"));
dirent2_del(ip, bh, prev, dent);
log_err(_("The corrupt directory entry '%s' was deleted.\n"), fn);
@@ -713,7 +688,7 @@ out:
* dentry, since we failed to detect the problem earlier.
*/
static int check_suspicious_dirref(struct gfs2_sbd *sdp,
- struct gfs2_inum *entry)
+ struct lgfs2_inum *entry)
{
struct osi_node *tmp, *next = NULL;
struct dir_info *dt;
@@ -721,17 +696,17 @@ static int check_suspicious_dirref(struct gfs2_sbd *sdp,
uint64_t dirblk;
int error = FSCK_OK;
struct metawalk_fxns dirref_hunt = {
- .private = (void *)entry,
+ .private = entry,
.check_dentry = dirref_find,
};
log_debug("This dentry is good, but since this is a second "
- "reference to block 0x%llx, we need to check the "
- "original.\n", (unsigned long long)entry->no_addr);
+ "reference to block 0x%"PRIx64", we need to check the "
+ "original.\n", entry->in_addr);
for (tmp = osi_first(&dirtree); tmp; tmp = next) {
next = osi_next(tmp);
dt = (struct dir_info *)tmp;
- dirblk = dt->dinode.no_addr;
+ dirblk = dt->dinode.in_addr;
if (skip_this_pass || fsck_abort) /* asked to skip the rest */
break;
ip = fsck_load_inode(sdp, dirblk);
@@ -760,30 +735,28 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
struct gfs2_sbd *sdp = ip->i_sbd;
int q = 0;
char tmp_name[MAX_FILENAME];
- struct gfs2_inum entry, no;
+ struct lgfs2_inum entry, no;
struct dir_status *ds = (struct dir_status *) priv;
int error;
struct gfs2_inode *entry_ip = NULL;
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_dirent d;
int hash_index; /* index into the hash table based on the hash */
int lindex_max; /* largest acceptable hash table index for hash */
int isdir;
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&dentry, (char *)dent);
- de = &dentry;
+ lgfs2_dirent_in(&d, dent);
- entry.no_addr = de->de_inum.no_addr;
- entry.no_formal_ino = de->de_inum.no_formal_ino;
+ entry.in_addr = d.dr_inum.in_addr;
+ entry.in_formal_ino = d.dr_inum.in_formal_ino;
/* Start of checks */
memset(tmp_name, 0, MAX_FILENAME);
- if (de->de_name_len < MAX_FILENAME)
- strncpy(tmp_name, filename, de->de_name_len);
+ if (d.dr_name_len < MAX_FILENAME)
+ strncpy(tmp_name, filename, d.dr_name_len);
else
strncpy(tmp_name, filename, MAX_FILENAME - 1);
- error = basic_dentry_checks(ip, dent, &entry, tmp_name, count, de,
+ error = basic_dentry_checks(ip, dent, &entry, tmp_name, count, &d,
ds, &q, bh, &isdir);
if (error)
goto nuke_dentry;
@@ -801,10 +774,10 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
* and check the rest of the '.' entry? */
goto dentry_is_valid;
}
- if (ip->i_addr == entry.no_addr)
+ if (ip->i_addr == entry.in_addr)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sdp, entry.no_addr);
+ entry_ip = fsck_load_inode(sdp, entry.in_addr);
check_inode_eattr(entry_ip, &delete_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -815,11 +788,11 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
* location */
/* check that '.' refers to this inode */
- if (entry.no_addr != ip->i_addr) {
+ if (entry.in_addr != ip->i_addr) {
log_err(_("'.' entry's value incorrect in directory %"PRIu64" (0x%"PRIx64")."
" Points to %"PRIu64" (0x%"PRIx64") when it should point to %"PRIu64
" (0x%"PRIx64").\n"),
- entry.no_addr, entry.no_addr, entry.no_addr, entry.no_addr,
+ entry.in_addr, entry.in_addr, entry.in_addr, entry.in_addr,
ip->i_addr, ip->i_addr);
if (!query( _("Remove '.' reference? (y/n) "))) {
log_err( _("Invalid '.' reference remains\n"));
@@ -827,10 +800,10 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
* this '.' entry is invalid */
goto dentry_is_valid;
}
- if (ip->i_addr == entry.no_addr)
+ if (ip->i_addr == entry.in_addr)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sdp, entry.no_addr);
+ entry_ip = fsck_load_inode(sdp, entry.in_addr);
check_inode_eattr(entry_ip, &delete_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -854,10 +827,10 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
goto dentry_is_valid;
}
- if (ip->i_addr == entry.no_addr)
+ if (ip->i_addr == entry.in_addr)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sdp, entry.no_addr);
+ entry_ip = fsck_load_inode(sdp, entry.in_addr);
check_inode_eattr(entry_ip, &delete_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -872,10 +845,10 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
log_err( _("Bad '..' directory entry remains\n"));
goto dentry_is_valid;
}
- if (ip->i_addr == entry.no_addr)
+ if (ip->i_addr == entry.in_addr)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sdp, entry.no_addr);
+ entry_ip = fsck_load_inode(sdp, entry.in_addr);
check_inode_eattr(entry_ip, &delete_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -898,14 +871,14 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* If this is an exhash directory, make sure the dentries in the leaf
block have a hash table index that fits */
if (ip->i_flags & GFS2_DIF_EXHASH) {
- hash_index = hash_table_index(de->de_hash, ip);
+ hash_index = hash_table_index(d.dr_hash, ip);
lindex_max = hash_table_max(*lindex, ip, bh);
if (hash_index < *lindex || hash_index > lindex_max) {
int nuke_dent;
nuke_dent = wrong_leaf(ip, &entry, tmp_name, lindex,
lindex_max, hash_index, bh, ds,
- dent, de, prev_de, count, q);
+ dent, &d, prev_de, count, q);
if (nuke_dent)
goto nuke_dentry;
}
@@ -913,22 +886,18 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* After this point we're only concerned with directories */
if (!isdir) {
- log_debug( _("Found non-dir inode dentry pointing to %lld "
- "(0x%llx)\n"),
- (unsigned long long)entry.no_addr,
- (unsigned long long)entry.no_addr);
+ log_debug(_("Found non-dir inode dentry pointing to %"PRIu64" (0x%"PRIx64")\n"),
+ entry.in_addr, entry.in_addr);
goto dentry_is_valid;
}
/*log_debug( _("Found plain directory dentry\n"));*/
- no.no_addr = ip->i_addr;
- no.no_formal_ino = ip->i_formal_ino;
+ no.in_addr = ip->i_addr;
+ no.in_formal_ino = ip->i_formal_ino;
error = set_parent_dir(sdp, entry, no);
if (error > 0) {
- log_err( _("%s: Hard link to block %llu (0x%llx"
- ") detected.\n"), tmp_name,
- (unsigned long long)entry.no_addr,
- (unsigned long long)entry.no_addr);
+ log_err(_("%s: Hard link to block %"PRIu64" (0x%"PRIx64") detected.\n"),
+ tmp_name, entry.in_addr, entry.in_addr);
if (query( _("Clear hard link to directory? (y/n) ")))
goto nuke_dentry;
@@ -947,7 +916,7 @@ dentry_is_valid:
error = check_suspicious_dirref(sdp, &entry);
} else if (error == INCR_LINK_INO_MISMATCH) {
log_err("incr_link_count err=%d.\n", error);
- if (bad_formal_ino(ip, dent, entry, tmp_name, q, de, bh) == 1)
+ if (bad_formal_ino(ip, dent, entry, tmp_name, q, &d, bh) == 1)
goto nuke_dentry;
}
(*count)++;
@@ -1120,7 +1089,8 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
{
char *filename;
char *bh_end = bh->b_data + ip->i_sbd->sd_bsize;
- struct gfs2_dirent de, *dent;
+ struct gfs2_dirent *dent;
+ struct lgfs2_dirent de;
int error;
int isdir = 0;
@@ -1138,28 +1108,28 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
char tmp_name[PATH_MAX];
memset(&de, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&de, (char *)dent);
+ lgfs2_dirent_in(&de, dent);
filename = (char *)dent + sizeof(struct gfs2_dirent);
memset(tmp_name, 0, sizeof(tmp_name));
- if (de.de_name_len > sizeof(filename)) {
+ if (de.dr_name_len > sizeof(filename)) {
log_debug(_("Encountered bad filename length; "
"stopped processing.\n"));
break;
}
- memcpy(tmp_name, filename, de.de_name_len);
- if ((de.de_name_len == 1 && filename[0] == '.')) {
+ memcpy(tmp_name, filename, de.dr_name_len);
+ if ((de.dr_name_len == 1 && filename[0] == '.')) {
log_debug(_("Skipping entry '.'\n"));
- } else if (de.de_name_len == 2 && filename[0] == '.' &&
+ } else if (de.dr_name_len == 2 && filename[0] == '.' &&
filename[1] == '.') {
log_debug(_("Skipping entry '..'\n"));
- } else if (!de.de_inum.no_formal_ino) { /* sentinel */
+ } else if (!de.dr_inum.in_formal_ino) { /* sentinel */
log_debug(_("Skipping sentinel '%s'\n"), tmp_name);
} else {
uint32_t count;
struct dir_status ds = {0};
int q = 0;
- error = basic_dentry_checks(ip, dent, &de.de_inum,
+ error = basic_dentry_checks(ip, dent, &de.dr_inum,
tmp_name, &count, &de,
&ds, &q, bh, &isdir);
if (error) {
@@ -1168,8 +1138,8 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
} else {
error = dir_add(lf_dip, filename,
- de.de_name_len, &de.de_inum,
- de.de_type);
+ de.dr_name_len, &de.dr_inum,
+ de.dr_type);
if (error && error != -EEXIST) {
log_err(_("Error %d encountered while "
"trying to relocate \"%s\" "
@@ -1178,27 +1148,24 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
return error;
}
/* This inode is linked from lost+found */
- incr_link_count(de.de_inum, lf_dip,
+ incr_link_count(de.dr_inum, lf_dip,
_("from lost+found"));
/* If it's a directory, lost+found is
back-linked to it via .. */
if (isdir) {
- struct gfs2_inum no = {
- .no_addr = lf_dip->i_addr,
- .no_formal_ino = lf_dip->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = lf_dip->i_addr,
+ .in_formal_ino = lf_dip->i_formal_ino
};
incr_link_count(no, NULL, _("to lost+found"));
}
- log_err(_("Relocated \"%s\", block %llu "
- "(0x%llx) to lost+found.\n"),
- tmp_name,
- (unsigned long long)de.de_inum.no_addr,
- (unsigned long long)de.de_inum.no_addr);
+ log_err(_("Relocated \"%s\", block %"PRIu64" (0x%"PRIx64") to lost+found.\n"),
+ tmp_name, de.dr_inum.in_addr, de.dr_inum.in_addr);
}
}
- if ((char *)dent + de.de_rec_len >= bh_end)
+ if ((char *)dent + de.dr_rec_len >= bh_end)
break;
- dent = (struct gfs2_dirent *)((char *)dent + de.de_rec_len);
+ dent = (struct gfs2_dirent *)((char *)dent + de.dr_rec_len);
}
log_err(_("Directory entries from misplaced leaf block were relocated "
"to lost+found.\n"));
@@ -1221,23 +1188,23 @@ static int basic_check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
{
int q = 0;
char tmp_name[MAX_FILENAME];
- struct gfs2_inum entry;
+ struct lgfs2_inum entry;
struct dir_status *ds = (struct dir_status *) priv;
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_dirent dentry, *de;
int error;
int isdir;
memset(&dentry, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&dentry, (char *)dent);
+ lgfs2_dirent_in(&dentry, dent);
de = &dentry;
- entry.no_addr = de->de_inum.no_addr;
- entry.no_formal_ino = de->de_inum.no_formal_ino;
+ entry.in_addr = de->dr_inum.in_addr;
+ entry.in_formal_ino = de->dr_inum.in_formal_ino;
/* Start of checks */
memset(tmp_name, 0, MAX_FILENAME);
- if (de->de_name_len < MAX_FILENAME)
- strncpy(tmp_name, filename, de->de_name_len);
+ if (de->dr_name_len < MAX_FILENAME)
+ strncpy(tmp_name, filename, de->dr_name_len);
else
strncpy(tmp_name, filename, MAX_FILENAME - 1);
@@ -1342,8 +1309,9 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
int len, int *proper_len, int factor)
{
struct gfs2_buffer_head *lbh;
+ struct lgfs2_dirent dentry;
struct gfs2_leaf leaf;
- struct gfs2_dirent dentry, *de;
+ struct gfs2_dirent *de;
int changes = 0, error, i, extras, hash_index;
uint64_t new_leaf_blk;
uint64_t leaf_no;
@@ -1379,12 +1347,11 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
memset(&dentry, 0, sizeof(struct gfs2_dirent));
de = (struct gfs2_dirent *)(lbh->b_data + sizeof(struct gfs2_leaf));
- gfs2_dirent_in(&dentry, (char *)de);
+ lgfs2_dirent_in(&dentry, de);
/* If this is an empty leaf, we can just delete it and pad. */
- if ((dentry.de_rec_len == cpu_to_be16(ip->i_sbd->sd_bsize -
- sizeof(struct gfs2_leaf))) &&
- (dentry.de_inum.no_formal_ino == 0)) {
+ if ((dentry.dr_rec_len == ip->i_sbd->sd_bsize - sizeof(struct gfs2_leaf)) &&
+ (dentry.dr_inum.in_formal_ino == 0)) {
brelse(lbh);
gfs2_free_block(ip->i_sbd, leafblk);
log_err(_("Out of place leaf block %llu (0x%llx) had no "
@@ -1401,7 +1368,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
/* Look at the first dirent and check its hash value to see if it's
at the proper starting offset. */
- hash_index = hash_table_index(dentry.de_hash, ip);
+ hash_index = hash_table_index(dentry.dr_hash, ip);
/* Need to use len here, not *proper_len because the leaf block may
be valid within the range, but starts too soon in the hash table. */
if (hash_index < lindex || hash_index > lindex + len) {
@@ -1523,7 +1490,8 @@ static int check_hash_tbl_dups(struct gfs2_inode *ip, uint64_t *tbl,
uint64_t leafblk, leaf_no;
struct gfs2_buffer_head *lbh;
struct gfs2_leaf leaf;
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_dirent dentry;
+ struct gfs2_dirent *de;
int hash_index; /* index into the hash table based on the hash */
leafblk = be64_to_cpu(tbl[lindex]);
@@ -1561,10 +1529,9 @@ static int check_hash_tbl_dups(struct gfs2_inode *ip, uint64_t *tbl,
}
memset(&dentry, 0, sizeof(struct gfs2_dirent));
- de = (struct gfs2_dirent *)(lbh->b_data +
- sizeof(struct gfs2_leaf));
- gfs2_dirent_in(&dentry, (char *)de);
- hash_index = hash_table_index(dentry.de_hash, ip);
+ de = (struct gfs2_dirent *)(lbh->b_data + sizeof(struct gfs2_leaf));
+ lgfs2_dirent_in(&dentry, de);
+ hash_index = hash_table_index(dentry.dr_hash, ip);
brelse(lbh);
/* check the duplicate ref first */
if (hash_index < l || hash_index > l + len2) {
@@ -1983,9 +1950,9 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
if (!ds.dotdir) {
log_err( _("No '.' entry found for %s directory.\n"), dirname);
if (query( _("Is it okay to add '.' entry? (y/n) "))) {
- struct gfs2_inum no = {
- .no_addr = sysinode->i_addr,
- .no_formal_ino = sysinode->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = sysinode->i_addr,
+ .in_formal_ino = sysinode->i_formal_ino
};
log_warn( _("Adding '.' entry\n"));
error = dir_add(sysinode, ".", 1, &no,
@@ -2108,9 +2075,9 @@ static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
(unsigned long long)dirblk, (unsigned long long)dirblk);
if (query( _("Is it okay to add '.' entry? (y/n) "))) {
- struct gfs2_inum no = {
- .no_addr = ip->i_addr,
- .no_formal_ino = ip->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = ip->i_addr,
+ .in_formal_ino = ip->i_formal_ino
};
error = dir_add(ip, ".", 1, &no,
(sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
@@ -2194,7 +2161,7 @@ int pass2(struct gfs2_sbd *sdp)
next = osi_next(tmp);
dt = (struct dir_info *)tmp;
- dirblk = dt->dinode.no_addr;
+ dirblk = dt->dinode.in_addr;
warm_fuzzy_stuff(dirblk);
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index 8b8b19bc..f96881f5 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -25,7 +25,7 @@ static int attach_dotdot_to(struct gfs2_sbd *sdp, uint64_t newdotdot,
int filename_len = 2;
int err;
struct gfs2_inode *ip, *pip;
- struct gfs2_inum no;
+ struct lgfs2_inum no;
ip = fsck_load_inode(sdp, block);
pip = fsck_load_inode(sdp, newdotdot);
@@ -40,8 +40,8 @@ static int attach_dotdot_to(struct gfs2_sbd *sdp, uint64_t newdotdot,
log_warn( _("Unable to remove \"..\" directory entry.\n"));
else
decr_link_count(olddotdot, block, sdp->gfs1, _("old \"..\""));
- no.no_addr = pip->i_addr;
- no.no_formal_ino = pip->i_formal_ino;
+ no.in_addr = pip->i_addr;
+ no.in_formal_ino = pip->i_formal_ino;
err = dir_add(ip, filename, filename_len, &no,
(sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
if (err) {
@@ -68,29 +68,23 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
if (!di->treewalk_parent)
return NULL;
- if (di->dotdot_parent.no_addr == di->treewalk_parent) {
- q_dotdot = bitmap_type(sdp, di->dotdot_parent.no_addr);
+ if (di->dotdot_parent.in_addr == di->treewalk_parent) {
+ q_dotdot = bitmap_type(sdp, di->dotdot_parent.in_addr);
if (q_dotdot != GFS2_BLKST_DINODE) {
- log_err( _("Orphaned directory at block %llu (0x%llx) "
- "moved to lost+found\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr);
+ log_err(_("Orphaned directory at block %"PRIu64" (0x%"PRIx64") "
+ "moved to lost+found\n"),
+ di->dinode.in_addr, di->dinode.in_addr);
return NULL;
}
goto out;
}
- log_warn( _("Directory '..' and treewalk connections disagree for "
- "inode %llu (0x%llx)\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr);
- log_notice( _("'..' has %llu (0x%llx), treewalk has %llu (0x%llx)\n"),
- (unsigned long long)di->dotdot_parent.no_addr,
- (unsigned long long)di->dotdot_parent.no_addr,
- (unsigned long long)di->treewalk_parent,
- (unsigned long long)di->treewalk_parent);
- q_dotdot = bitmap_type(sdp, di->dotdot_parent.no_addr);
- dt_dotdot = dirtree_find(di->dotdot_parent.no_addr);
+ log_warn(_("Directory '..' and treewalk connections disagree for inode %"PRIu64" (0x%"PRIx64")\n"),
+ di->dinode.in_addr, di->dinode.in_addr);
+ log_notice(_("'..' has %"PRIu64" (0x%"PRIx64"), treewalk has %"PRIu64" (0x%"PRIx64")\n"),
+ di->dotdot_parent.in_addr, di->dotdot_parent.in_addr, di->treewalk_parent, di->treewalk_parent);
+ q_dotdot = bitmap_type(sdp, di->dotdot_parent.in_addr);
+ dt_dotdot = dirtree_find(di->dotdot_parent.in_addr);
q_treewalk = bitmap_type(sdp, di->treewalk_parent);
dt_treewalk = dirtree_find(di->treewalk_parent);
/* if the dotdot entry isn't a directory, but the
@@ -111,9 +105,9 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
(unsigned long long)di->treewalk_parent,
(unsigned long long)di->treewalk_parent);
attach_dotdot_to(sdp, di->treewalk_parent,
- di->dotdot_parent.no_addr,
- di->dinode.no_addr);
- di->dotdot_parent.no_addr = di->treewalk_parent;
+ di->dotdot_parent.in_addr,
+ di->dinode.in_addr);
+ di->dotdot_parent.in_addr = di->treewalk_parent;
}
goto out;
}
@@ -121,9 +115,9 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
log_err( _("Both .. and treewalk parents are directories, "
"going with treewalk...\n"));
attach_dotdot_to(sdp, di->treewalk_parent,
- di->dotdot_parent.no_addr,
- di->dinode.no_addr);
- di->dotdot_parent.no_addr = di->treewalk_parent;
+ di->dotdot_parent.in_addr,
+ di->dinode.in_addr);
+ di->dotdot_parent.in_addr = di->treewalk_parent;
goto out;
}
log_warn( _(".. parent is valid, but treewalk is bad - reattaching to "
@@ -131,35 +125,30 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
/* FIXME: add a dinode for this entry instead? */
- if (!query( _("Remove directory entry for bad inode %llu (0x%llx) in "
- "%llu (0x%llx)? (y/n)"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->treewalk_parent,
- (unsigned long long)di->treewalk_parent)) {
+ if (!query(_("Remove directory entry for bad inode %"PRIu64" (0x%"PRIx64") "
+ "in %"PRIu64" (0x%"PRIx64")? (y/n)"),
+ di->dinode.in_addr, di->dinode.in_addr,
+ di->treewalk_parent, di->treewalk_parent)) {
log_err( _("Directory entry to invalid inode remains\n"));
return NULL;
}
- error = remove_dentry_from_dir(sdp, di->treewalk_parent,
- di->dinode.no_addr);
+ error = remove_dentry_from_dir(sdp, di->treewalk_parent, di->dinode.in_addr);
if (error < 0) {
stack;
return NULL;
}
if (error > 0)
- log_warn( _("Unable to find dentry for block %llu"
- " (0x%llx) in %llu (0x%llx)\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->treewalk_parent,
- (unsigned long long)di->treewalk_parent);
+ log_warn(_("Unable to find dentry for block %"PRIu64" (0x%"PRIx64") "
+ "in %"PRIu64" (0x%"PRIx64")\n"),
+ di->dinode.in_addr, di->dinode.in_addr,
+ di->treewalk_parent, di->treewalk_parent);
log_warn( _("Directory entry removed\n"));
log_info( _("Marking directory unlinked\n"));
return NULL;
out:
- pdi = dirtree_find(di->dotdot_parent.no_addr);
+ pdi = dirtree_find(di->dotdot_parent.in_addr);
return pdi;
}
@@ -233,31 +222,26 @@ int pass3(struct gfs2_sbd *sdp)
tdi = mark_and_return_parent(sdp, di);
if (tdi) {
- log_debug( _("Directory at block %llu "
- "(0x%llx) connected\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr);
+ log_debug(_("Directory at block %"PRIu64" (0x%"PRIx64") connected\n"),
+ di->dinode.in_addr, di->dinode.in_addr);
di = tdi;
continue;
}
- q = bitmap_type(sdp, di->dinode.no_addr);
- ip = fsck_load_inode(sdp, di->dinode.no_addr);
+ q = bitmap_type(sdp, di->dinode.in_addr);
+ ip = fsck_load_inode(sdp, di->dinode.in_addr);
if (q == GFS2_BLKST_FREE) {
log_err( _("Found unlinked directory "
- "containing bad block at block %llu"
- " (0x%llx)\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr);
+ "containing bad block at block %"PRIu64
+ " (0x%"PRIx64")\n"),
+ di->dinode.in_addr, di->dinode.in_addr);
if (query(_("Clear unlinked directory "
"with bad blocks? (y/n) "))) {
- log_warn( _("inode %lld (0x%llx) is "
- "now marked as free\n"),
- (unsigned long long)
- di->dinode.no_addr,
- (unsigned long long)
- di->dinode.no_addr);
+ log_warn(_("inode %"PRIu64" (0x%"PRIx64") is "
+ "now marked as free\n"),
+ di->dinode.in_addr,
+ di->dinode.in_addr);
check_n_fix_bitmap(sdp, ip->i_rgd,
- di->dinode.no_addr,
+ di->dinode.in_addr,
0, GFS2_BLKST_FREE);
fsck_inode_put(&ip);
break;
@@ -274,29 +258,26 @@ int pass3(struct gfs2_sbd *sdp)
fsck_inode_put(&ip);
break;
}
- log_warn( _("inode %lld (0x%llx) is now "
+ log_warn( _("inode %"PRIu64" (0x%"PRIx64") is now "
"marked as free\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr);
+ di->dinode.in_addr, di->dinode.in_addr);
check_n_fix_bitmap(sdp, ip->i_rgd,
- di->dinode.no_addr, 0,
+ di->dinode.in_addr, 0,
GFS2_BLKST_FREE);
log_err( _("The block was cleared\n"));
fsck_inode_put(&ip);
break;
}
- log_err( _("Found unlinked directory at block %llu"
- " (0x%llx)\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr);
+ log_err(_("Found unlinked directory at block %"PRIu64" (0x%"PRIx64")\n"),
+ di->dinode.in_addr, di->dinode.in_addr);
/* Don't skip zero size directories with eattrs */
if (!ip->i_size && !ip->i_eattr){
log_err( _("Unlinked directory has zero "
"size.\n"));
if (query( _("Remove zero-size unlinked "
"directory? (y/n) "))) {
- fsck_bitmap_set(ip, di->dinode.no_addr,
+ fsck_bitmap_set(ip, di->dinode.in_addr,
_("zero-sized unlinked inode"),
GFS2_BLKST_FREE);
fsck_inode_put(&ip);
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index 42892da1..4deac26c 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -186,22 +186,22 @@ static int scan_inode_list(struct gfs2_sbd *sdp)
ii = (struct inode_info *)tmp;
/* Don't check reference counts on the special gfs files */
if (sdp->gfs1 &&
- ((ii->di_num.no_addr == sdp->md.riinode->i_addr) ||
- (ii->di_num.no_addr == sdp->md.qinode->i_addr) ||
- (ii->di_num.no_addr == sdp->md.statfs->i_addr)))
+ ((ii->num.in_addr == sdp->md.riinode->i_addr) ||
+ (ii->num.in_addr == sdp->md.qinode->i_addr) ||
+ (ii->num.in_addr == sdp->md.statfs->i_addr)))
continue;
if (ii->counted_links == 0) {
- if (handle_unlinked(sdp, ii->di_num.no_addr,
+ if (handle_unlinked(sdp, ii->num.in_addr,
&ii->counted_links, &lf_addition))
continue;
} /* if (ii->counted_links == 0) */
else if (ii->di_nlink != ii->counted_links) {
- handle_inconsist(sdp, ii->di_num.no_addr,
+ handle_inconsist(sdp, ii->num.in_addr,
&ii->di_nlink, ii->counted_links);
}
log_debug( _("block %llu (0x%llx) has link count %d\n"),
- (unsigned long long)ii->di_num.no_addr,
- (unsigned long long)ii->di_num.no_addr, ii->di_nlink);
+ (unsigned long long)ii->num.in_addr,
+ (unsigned long long)ii->num.in_addr, ii->di_nlink);
} /* osi_list_foreach(tmp, list) */
return adjust_lf_links(lf_addition);
@@ -222,19 +222,18 @@ static int scan_dir_list(struct gfs2_sbd *sdp)
di = (struct dir_info *)tmp;
/* Don't check reference counts on the special gfs files */
if (sdp->gfs1 &&
- di->dinode.no_addr == sdp->md.jiinode->i_addr)
+ di->dinode.in_addr == sdp->md.jiinode->i_addr)
continue;
if (di->counted_links == 0) {
- if (handle_unlinked(sdp, di->dinode.no_addr,
+ if (handle_unlinked(sdp, di->dinode.in_addr,
&di->counted_links, &lf_addition))
continue;
} else if (di->di_nlink != di->counted_links) {
- handle_inconsist(sdp, di->dinode.no_addr,
+ handle_inconsist(sdp, di->dinode.in_addr,
&di->di_nlink, di->counted_links);
}
- log_debug( _("block %llu (0x%llx) has link count %d\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr, di->di_nlink);
+ log_debug(_("block %"PRIu64" (0x%"PRIx64") has link count %d\n"),
+ di->dinode.in_addr, di->dinode.in_addr, di->di_nlink);
} /* osi_list_foreach(tmp, list) */
return adjust_lf_links(lf_addition);
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 962ec1e0..29b3ce81 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -427,7 +427,7 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
return META_IS_GOOD;
}
-struct dir_info *dirtree_insert(struct gfs2_inum inum)
+struct dir_info *dirtree_insert(struct lgfs2_inum inum)
{
struct osi_node **newn = &dirtree.osi_node, *parent = NULL;
struct dir_info *data;
@@ -437,9 +437,9 @@ struct dir_info *dirtree_insert(struct gfs2_inum inum)
struct dir_info *cur = (struct dir_info *)*newn;
parent = *newn;
- if (inum.no_addr < cur->dinode.no_addr)
+ if (inum.in_addr < cur->dinode.in_addr)
newn = &((*newn)->osi_left);
- else if (inum.no_addr > cur->dinode.no_addr)
+ else if (inum.in_addr > cur->dinode.in_addr)
newn = &((*newn)->osi_right);
else
return cur;
@@ -451,8 +451,8 @@ struct dir_info *dirtree_insert(struct gfs2_inum inum)
return NULL;
}
/* Add new node and rebalance tree. */
- data->dinode.no_addr = inum.no_addr;
- data->dinode.no_formal_ino = inum.no_formal_ino;
+ data->dinode.in_addr = inum.in_addr;
+ data->dinode.in_formal_ino = inum.in_formal_ino;
osi_link_node(&data->node, parent, newn);
osi_insert_color(&data->node, &dirtree);
@@ -466,9 +466,9 @@ struct dir_info *dirtree_find(uint64_t block)
while (node) {
struct dir_info *data = (struct dir_info *)node;
- if (block < data->dinode.no_addr)
+ if (block < data->dinode.in_addr)
node = node->osi_left;
- else if (block > data->dinode.no_addr)
+ else if (block > data->dinode.in_addr)
node = node->osi_right;
else
return data;
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index f7205393..4cc9b275 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1135,7 +1135,7 @@ static int get_next_leaf(struct gfs2_inode *dip,struct gfs2_buffer_head *bh_in,
}
static int dir_e_add(struct gfs2_inode *dip, const char *filename, int len,
- struct gfs2_inum *inum, unsigned int type)
+ struct lgfs2_inum *inum, unsigned int type)
{
struct gfs2_buffer_head *bh, *nbh;
struct gfs2_leaf *leaf, *nleaf;
@@ -1211,7 +1211,7 @@ restart:
}
}
- gfs2_inum_out(inum, (char *)&dent->de_inum);
+ lgfs2_inum_out(inum, &dent->de_inum);
dent->de_hash = cpu_to_be32(hash);
dent->de_type = cpu_to_be16(type);
memcpy((char *)(dent + 1), filename, len);
@@ -1292,7 +1292,7 @@ static void dir_make_exhash(struct gfs2_inode *dip)
}
static int dir_l_add(struct gfs2_inode *dip, const char *filename, int len,
- struct gfs2_inum *inum, unsigned int type)
+ struct lgfs2_inum *inum, unsigned int type)
{
struct gfs2_dirent *dent;
int err = 0;
@@ -1303,7 +1303,7 @@ static int dir_l_add(struct gfs2_inode *dip, const char *filename, int len,
return err;
}
- gfs2_inum_out(inum, (char *)&dent->de_inum);
+ lgfs2_inum_out(inum, &dent->de_inum);
dent->de_hash = gfs2_disk_hash(filename, len);
dent->de_hash = cpu_to_be32(dent->de_hash);
dent->de_type = cpu_to_be16(type);
@@ -1313,7 +1313,7 @@ static int dir_l_add(struct gfs2_inode *dip, const char *filename, int len,
}
int dir_add(struct gfs2_inode *dip, const char *filename, int len,
- struct gfs2_inum *inum, unsigned int type)
+ struct lgfs2_inum *inum, unsigned int type)
{
int err = 0;
if (dip->i_flags & GFS2_DIF_EXHASH)
@@ -1323,8 +1323,8 @@ int dir_add(struct gfs2_inode *dip, const char *filename, int len,
return err;
}
-static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct gfs2_inum *inum,
- unsigned int mode, uint32_t flags, struct gfs2_inum *parent, int gfs1)
+static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct lgfs2_inum *inum,
+ unsigned int mode, uint32_t flags, struct lgfs2_inum *parent, int gfs1)
{
struct gfs2_buffer_head *bh;
struct gfs2_dinode *di;
@@ -1340,7 +1340,7 @@ static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, st
return 1;
if (*bhp == NULL) {
- *bhp = bget(sdp, inum->no_addr);
+ *bhp = bget(sdp, inum->in_addr);
if (*bhp == NULL)
return 1;
}
@@ -1352,8 +1352,8 @@ static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, st
di->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
di->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI);
di->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI);
- di->di_num.no_formal_ino = cpu_to_be64(inum->no_formal_ino);
- di->di_num.no_addr = cpu_to_be64(inum->no_addr);
+ di->di_num.no_formal_ino = cpu_to_be64(inum->in_formal_ino);
+ di->di_num.no_addr = cpu_to_be64(inum->in_addr);
di->di_mode = cpu_to_be32(mode);
di->di_nlink = cpu_to_be32(1);
di->di_blocks = cpu_to_be64(1);
@@ -1380,8 +1380,8 @@ static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, st
hash = gfs2_disk_hash("..", 2);
len = sdp->sd_bsize - (p - bh->b_data);
- de.de_inum.no_formal_ino = cpu_to_be64(parent->no_formal_ino);
- de.de_inum.no_addr = cpu_to_be64(parent->no_addr);
+ de.de_inum.no_formal_ino = cpu_to_be64(parent->in_formal_ino);
+ de.de_inum.no_addr = cpu_to_be64(parent->in_addr);
de.de_hash = cpu_to_be32(hash);
de.de_rec_len = cpu_to_be16(len);
de.de_name_len = cpu_to_be16(2);
@@ -1401,8 +1401,8 @@ static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, st
return 0;
}
-int init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct gfs2_inum *inum,
- unsigned int mode, uint32_t flags, struct gfs2_inum *parent)
+int init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct lgfs2_inum *inum,
+ unsigned int mode, uint32_t flags, struct lgfs2_inum *parent)
{
return __init_dinode(sdp, bhp, inum, mode, flags, parent, 0);
}
@@ -1482,7 +1482,7 @@ static struct gfs2_inode *__createi(struct gfs2_inode *dip,
{
struct gfs2_sbd *sdp = dip->i_sbd;
uint64_t bn;
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
struct gfs2_buffer_head *bh = NULL;
struct gfs2_inode *ip;
int err = 0;
@@ -1490,19 +1490,19 @@ static struct gfs2_inode *__createi(struct gfs2_inode *dip,
gfs2_lookupi(dip, filename, strlen(filename), &ip);
if (!ip) {
- struct gfs2_inum parent = {
- .no_formal_ino = dip->i_formal_ino,
- .no_addr = dip->i_addr,
+ struct lgfs2_inum parent = {
+ .in_formal_ino = dip->i_formal_ino,
+ .in_addr = dip->i_addr,
};
err = lgfs2_dinode_alloc(sdp, 1, &bn);
if (err != 0)
return NULL;
if (if_gfs1)
- inum.no_formal_ino = bn;
+ inum.in_formal_ino = bn;
else
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = bn;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = bn;
err = dir_add(dip, filename, strlen(filename), &inum, IF2DT(mode));
if (err)
@@ -1692,7 +1692,7 @@ static int linked_leaf_search(struct gfs2_inode *dip, const char *filename,
* Returns:
*/
static int dir_e_search(struct gfs2_inode *dip, const char *filename,
- int len, unsigned int *type, struct gfs2_inum *inum)
+ int len, unsigned int *type, struct lgfs2_inum *inum)
{
struct gfs2_buffer_head *bh = NULL;
struct gfs2_dirent *dent;
@@ -1702,7 +1702,7 @@ static int dir_e_search(struct gfs2_inode *dip, const char *filename,
if (error)
return error;
- gfs2_inum_in(inum, (char *)&dent->de_inum);
+ lgfs2_inum_in(inum, &dent->de_inum);
if (type)
*type = be16_to_cpu(dent->de_type);
@@ -1721,7 +1721,7 @@ static int dir_e_search(struct gfs2_inode *dip, const char *filename,
* Returns:
*/
static int dir_l_search(struct gfs2_inode *dip, const char *filename,
- int len, unsigned int *type, struct gfs2_inum *inum)
+ int len, unsigned int *type, struct lgfs2_inum *inum)
{
struct gfs2_dirent *dent;
int error;
@@ -1731,7 +1731,7 @@ static int dir_l_search(struct gfs2_inode *dip, const char *filename,
error = leaf_search(dip, dip->i_bh, filename, len, &dent, NULL);
if (!error) {
- gfs2_inum_in(inum, (char *)&dent->de_inum);
+ lgfs2_inum_in(inum, &dent->de_inum);
if(type)
*type = be16_to_cpu(dent->de_type);
}
@@ -1752,7 +1752,7 @@ static int dir_l_search(struct gfs2_inode *dip, const char *filename,
* Returns: 0 if found, -1 on failure, -ENOENT if not found.
*/
int dir_search(struct gfs2_inode *dip, const char *filename, int len,
- unsigned int *type, struct gfs2_inum *inum)
+ unsigned int *type, struct lgfs2_inum *inum)
{
int error;
@@ -1868,7 +1868,7 @@ int gfs2_lookupi(struct gfs2_inode *dip, const char *filename, int len,
{
struct gfs2_sbd *sdp = dip->i_sbd;
int error = 0;
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
*ipp = NULL;
@@ -1880,7 +1880,7 @@ int gfs2_lookupi(struct gfs2_inode *dip, const char *filename, int len,
}
error = dir_search(dip, filename, len, NULL, &inum);
if (!error)
- *ipp = lgfs2_inode_read(sdp, inum.no_addr);
+ *ipp = lgfs2_inode_read(sdp, inum.in_addr);
return error;
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 7fae35c3..6e5172cd 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -370,6 +370,11 @@ struct gfs2_sbd {
int gfs1;
};
+struct lgfs2_inum {
+ uint64_t in_formal_ino;
+ uint64_t in_addr;
+};
+
struct lgfs2_log_header {
uint64_t lh_sequence;
uint32_t lh_flags;
@@ -382,6 +387,16 @@ struct lgfs2_log_header {
int64_t lh_local_dinodes;
};
+struct lgfs2_dirent {
+ struct lgfs2_inum dr_inum;
+ uint32_t dr_hash;
+ uint16_t dr_rec_len;
+ uint16_t dr_name_len;
+ uint16_t dr_type;
+ uint16_t dr_rahead;
+ uint32_t dr_cookie;
+};
+
struct metapath {
unsigned int mp_list[GFS2_MAX_META_HEIGHT];
};
@@ -495,8 +510,8 @@ extern int gfs2_readi(struct gfs2_inode *ip, void *buf, uint64_t offset,
__gfs2_writei(ip, buf, offset, size, 1)
extern int __gfs2_writei(struct gfs2_inode *ip, void *buf, uint64_t offset,
unsigned int size, int resize);
-extern int init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct gfs2_inum *inum,
- unsigned int mode, uint32_t flags, struct gfs2_inum *parent);
+extern int init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct lgfs2_inum *inum,
+ unsigned int mode, uint32_t flags, struct lgfs2_inum *parent);
extern struct gfs2_inode *createi(struct gfs2_inode *dip, const char *filename,
unsigned int mode, uint32_t flags);
extern struct gfs2_inode *gfs_createi(struct gfs2_inode *dip,
@@ -505,11 +520,11 @@ extern struct gfs2_inode *gfs_createi(struct gfs2_inode *dip,
extern void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
struct gfs2_dirent *prev, struct gfs2_dirent *cur);
extern int dir_search(struct gfs2_inode *dip, const char *filename, int len,
- unsigned int *type, struct gfs2_inum *inum);
+ unsigned int *type, struct lgfs2_inum *inum);
extern int gfs2_lookupi(struct gfs2_inode *dip, const char *filename, int len,
struct gfs2_inode **ipp);
extern int dir_add(struct gfs2_inode *dip, const char *filename, int len,
- struct gfs2_inum *inum, unsigned int type);
+ struct lgfs2_inum *inum, unsigned int type);
extern int gfs2_dirent_del(struct gfs2_inode *dip, const char *filename,
int filename_len);
extern void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
@@ -748,7 +763,7 @@ extern int lgfs2_sb_write(const struct gfs2_sbd *sdp, int fd);
extern int build_journal(struct gfs2_sbd *sdp, int j,
struct gfs2_inode *jindex);
extern int build_jindex(struct gfs2_sbd *sdp);
-extern int lgfs2_build_jindex(struct gfs2_inode *master, struct gfs2_inum *jnls, size_t nmemb);
+extern int lgfs2_build_jindex(struct gfs2_inode *master, struct lgfs2_inum *jnls, size_t nmemb);
extern int build_per_node(struct gfs2_sbd *sdp);
extern int build_inum(struct gfs2_sbd *sdp);
extern int build_statfs(struct gfs2_sbd *sdp);
@@ -777,8 +792,8 @@ extern void print_it(const char *label, const char *fmt, const char *fmt2, ...)
/* Translation functions */
-extern void gfs2_inum_in(struct gfs2_inum *no, char *buf);
-extern void gfs2_inum_out(const struct gfs2_inum *no, char *buf);
+extern void lgfs2_inum_in(struct lgfs2_inum *i, void *inp);
+extern void lgfs2_inum_out(struct lgfs2_inum *i, void *inp);
extern void gfs2_meta_header_in(struct gfs2_meta_header *mh, const char *buf);
extern void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf);
extern void lgfs2_sb_in(struct gfs2_sbd *sdp, void *buf);
@@ -789,8 +804,8 @@ extern void lgfs2_rgrp_in(lgfs2_rgrp_t rg, void *buf);
extern void lgfs2_rgrp_out(const lgfs2_rgrp_t rg, void *buf);
extern void lgfs2_dinode_in(struct gfs2_inode *ip, char *buf);
extern void lgfs2_dinode_out(struct gfs2_inode *ip, char *buf);
-extern void gfs2_dirent_in(struct gfs2_dirent *de, char *buf);
-extern void gfs2_dirent_out(struct gfs2_dirent *de, char *buf);
+extern void lgfs2_dirent_in(struct lgfs2_dirent *d, void *dep);
+extern void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep);
extern void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf);
extern void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 77798993..4526fa20 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -38,33 +38,20 @@
#define CPIN_64(s1, s2, member) {(s1->member) = be64_to_cpu((s2->member));}
#define CPOUT_64(s1, s2, member) {(s2->member) = cpu_to_be64((s1->member));}
-/*
- * gfs2_xxx_in - read in an xxx struct
- * first arg: the cpu-order structure
- * buf: the disk-order block data
- *
- * gfs2_xxx_out - write out an xxx struct
- * first arg: the cpu-order structure
- * buf: the disk-order block data
- *
- * gfs2_xxx_print - print out an xxx struct
- * first arg: the cpu-order structure
- */
-
-void gfs2_inum_in(struct gfs2_inum *no, char *buf)
+void lgfs2_inum_in(struct lgfs2_inum *i, void *inp)
{
- struct gfs2_inum *str = (struct gfs2_inum *)buf;
+ struct gfs2_inum *in = inp;
- CPIN_64(no, str, no_formal_ino);
- CPIN_64(no, str, no_addr);
+ i->in_formal_ino = be64_to_cpu(in->no_formal_ino);
+ i->in_addr = be64_to_cpu(in->no_addr);
}
-void gfs2_inum_out(const struct gfs2_inum *no, char *buf)
+void lgfs2_inum_out(struct lgfs2_inum *i, void *inp)
{
- struct gfs2_inum *str = (struct gfs2_inum *)buf;
+ struct gfs2_inum *in = inp;
- CPOUT_64(no, str, no_formal_ino);
- CPOUT_64(no, str, no_addr);
+ in->no_formal_ino = cpu_to_be64(i->in_formal_ino);
+ in->no_addr = cpu_to_be64(i->in_addr);
}
void lgfs2_inum_print(void *nop)
@@ -375,32 +362,30 @@ void lgfs2_dinode_print(void *dip)
printbe64(di, di_eattr);
}
-void gfs2_dirent_in(struct gfs2_dirent *de, char *buf)
+void lgfs2_dirent_in(struct lgfs2_dirent *d, void *dep)
{
- struct gfs2_dirent *str = (struct gfs2_dirent *)buf;
-
- gfs2_inum_in(&de->de_inum, buf);
- CPIN_32(de, str, de_hash);
- CPIN_16(de, str, de_rec_len);
- CPIN_16(de, str, de_name_len);
- CPIN_16(de, str, de_type);
- CPIN_16(de, str, de_rahead);
- CPIN_32(de, str, de_cookie);
- CPIN_08(de, str, pad3, 8);
+ struct gfs2_dirent *de = dep;
+
+ lgfs2_inum_in(&d->dr_inum, &de->de_inum);
+ d->dr_hash = be32_to_cpu(de->de_hash);
+ d->dr_rec_len = be16_to_cpu(de->de_rec_len);
+ d->dr_name_len = be16_to_cpu(de->de_name_len);
+ d->dr_type = be16_to_cpu(de->de_type);
+ d->dr_rahead = be16_to_cpu(de->de_rahead);
+ d->dr_cookie = be32_to_cpu(de->de_cookie);
}
-void gfs2_dirent_out(struct gfs2_dirent *de, char *buf)
+void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep)
{
- struct gfs2_dirent *str = (struct gfs2_dirent *)buf;
-
- gfs2_inum_out(&de->de_inum, buf);
- CPOUT_32(de, str, de_hash);
- CPOUT_16(de, str, de_rec_len);
- CPOUT_16(de, str, de_name_len);
- CPOUT_16(de, str, de_type);
- CPOUT_16(de, str, de_rahead);
- CPOUT_32(de, str, de_cookie);
- CPOUT_08(de, str, pad3, 8);
+ struct gfs2_dirent *de = dep;
+
+ lgfs2_inum_out(&d->dr_inum, &de->de_inum);
+ de->de_hash = cpu_to_be32(d->dr_hash);
+ de->de_rec_len = cpu_to_be16(d->dr_rec_len);
+ de->de_name_len = cpu_to_be16(d->dr_name_len);
+ de->de_type = cpu_to_be16(d->dr_type);
+ de->de_rahead = cpu_to_be16(d->dr_rahead);
+ de->de_cookie = cpu_to_be32(d->dr_cookie);
}
void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf)
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 0957e5ad..f0eb8832 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -19,7 +19,7 @@
int build_master(struct gfs2_sbd *sdp)
{
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
uint64_t bn;
struct gfs2_buffer_head *bh = NULL;
int err = lgfs2_dinode_alloc(sdp, 1, &bn);
@@ -27,8 +27,8 @@ int build_master(struct gfs2_sbd *sdp)
if (err != 0)
return -1;
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = bn;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = bn;
err = init_dinode(sdp, &bh, &inum, S_IFDIR | 0755, GFS2_DIF_SYSTEM, &inum);
if (err != 0)
@@ -255,7 +255,7 @@ int build_journal(struct gfs2_sbd *sdp, int j, struct gfs2_inode *jindex)
* nmemb: The number of entries in the list (number of journals).
* Returns 0 on success or non-zero on error with errno set.
*/
-int lgfs2_build_jindex(struct gfs2_inode *master, struct gfs2_inum *jnls, size_t nmemb)
+int lgfs2_build_jindex(struct gfs2_inode *master, struct lgfs2_inum *jnls, size_t nmemb)
{
char fname[GFS2_FNAMESIZE + 1];
struct gfs2_inode *jindex;
@@ -559,7 +559,7 @@ int build_quota(struct gfs2_sbd *sdp)
int build_root(struct gfs2_sbd *sdp)
{
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
uint64_t bn;
struct gfs2_buffer_head *bh = NULL;
int err = lgfs2_dinode_alloc(sdp, 1, &bn);
@@ -567,8 +567,8 @@ int build_root(struct gfs2_sbd *sdp)
if (err != 0)
return -1;
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = bn;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = bn;
err = init_dinode(sdp, &bh, &inum, S_IFDIR | 0755, 0, &inum);
if (err != 0)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index bf9e0d6d..551261b9 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -160,7 +160,7 @@ static void opts_init(struct mkfs_opts *opts)
opts->format = GFS2_FORMAT_FS;
}
-struct gfs2_inum *mkfs_journals = NULL;
+struct lgfs2_inum *mkfs_journals = NULL;
#ifndef BLKDISCARD
#define BLKDISCARD _IO(0x12,119)
@@ -901,8 +901,8 @@ static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_o
fprintf(stderr, _("Failed to write data blocks for journal %u\n"), j);
return result;
}
- mkfs_journals[j].no_addr = in.i_addr;
- mkfs_journals[j].no_formal_ino = in.i_formal_ino;
+ mkfs_journals[j].in_addr = in.i_addr;
+ mkfs_journals[j].in_formal_ino = in.i_formal_ino;
}
gfs2_progress_close(&progress, _("Done\n"));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 23/40: gfs2_edit: Use native-endian types for dirent
processing
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 717c5a1157b13e7e95c2d93f506c304f3410af73
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Jun 4 11:10:31 2021 +0100
gfs2_edit: Use native-endian types for dirent processing
Replace gfs2_edit's 'struct gfs2_dirents' with a new 'struct idirent'
that doesn't use the big-endian 'struct gfs2_dirent'.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/extended.c | 22 ++++++++++----------
gfs2/edit/gfs2hex.c | 59 ++++++++++++++++++++++++++++------------------------
gfs2/edit/hexedit.c | 41 ++++++++++++++++++------------------
gfs2/edit/hexedit.h | 17 +++++++++++----
gfs2/edit/journal.c | 2 +-
gfs2/edit/savemeta.c | 4 ++--
6 files changed, 79 insertions(+), 66 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 4d6b7496..d2ac8507 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -59,7 +59,7 @@ static int _do_indirect_extended(char *diebuf, struct iinfo *iinf, int hgt)
iinf->ii[x].height = 0;
iinf->ii[x].block = 0;
iinf->ii[x].dirents = 0;
- memset(&iinf->ii[x].dirent, 0, sizeof(struct gfs2_dirents));
+ memset(&iinf->ii[x].dirent, 0, sizeof(struct idirent));
}
headoff = sbd.gfs1 ? sizeof(struct gfs_indirect) : sizeof(struct gfs2_meta_header);
for (x = headoff, y = 0; x < sbd.sd_bsize; x += sizeof(uint64_t), y++) {
@@ -331,21 +331,21 @@ static int display_leaf(struct iinfo *ind)
line - start_line - 1 ==
edit_row[dmode] - start_row[dmode]) {
COLORS_HIGHLIGHT;
- sprintf(estring, "%"PRIx64, ind->ii[0].dirent[d].block);
+ sprintf(estring, "%"PRIx64, ind->ii[0].dirent[d].inum.addr);
strcpy(edit_fmt, "%llx");
}
}
print_gfs2("%d/%d [%08"PRIX32"] %"PRIu64"/%"PRIu64" (0x%"PRIx64"/0x%"PRIx64") +%"PRIu16": ",
total_dirents, d + 1,
- ind->ii[0].dirent[d].dirent.de_hash,
- ind->ii[0].dirent[d].dirent.de_inum.no_formal_ino,
- ind->ii[0].dirent[d].block,
- ind->ii[0].dirent[d].dirent.de_inum.no_formal_ino,
- ind->ii[0].dirent[d].block,
- ind->ii[0].dirent[d].dirent.de_rahead
+ ind->ii[0].dirent[d].hash,
+ ind->ii[0].dirent[d].inum.formal_ino,
+ ind->ii[0].dirent[d].inum.addr,
+ ind->ii[0].dirent[d].inum.formal_ino,
+ ind->ii[0].dirent[d].inum.addr,
+ ind->ii[0].dirent[d].rahead
);
}
- print_inode_type(ind->ii[0].dirent[d].dirent.de_type);
+ print_inode_type(ind->ii[0].dirent[d].type);
print_gfs2(" %s", ind->ii[0].dirent[d].filename);
if (termlines) {
if (edit_row[dmode] >= 0 &&
@@ -479,10 +479,10 @@ static int print_gfs2_jindex(void)
for (d = 0; d < indirect->ii[0].dirents; d++) {
if (strncmp(indirect->ii[0].dirent[d].filename, "journal", 7))
continue;
- ip = lgfs2_inode_read(&sbd, indirect->ii[0].dirent[d].block);
+ ip = lgfs2_inode_read(&sbd, indirect->ii[0].dirent[d].inum.addr);
print_gfs2("%s: 0x%-5"PRIx64" %"PRIu64"MB ",
indirect->ii[0].dirent[d].filename,
- indirect->ii[0].dirent[d].block,
+ indirect->ii[0].dirent[d].inum.addr,
ip->i_size / 1048576);
error = lgfs2_find_jhead(ip, &head);
if (error) {
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index f0c409b5..5a1f9b7f 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -209,25 +209,37 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)
}
}
-static int indirect_dirent(struct indirect_info *indir, char *ptr, int d)
+void idirent_in(struct idirent *id, void *dep)
{
- struct gfs2_dirent de;
+ struct gfs2_dirent *de = dep;
+
+ id->inum.formal_ino = be64_to_cpu(de->de_inum.no_formal_ino);
+ id->inum.addr = be64_to_cpu(de->de_inum.no_addr);
+ id->hash = be32_to_cpu(de->de_hash);
+ id->rec_len = be16_to_cpu(de->de_rec_len);
+ id->name_len = be16_to_cpu(de->de_name_len);
+ id->type = be16_to_cpu(de->de_type);
+ id->rahead = be16_to_cpu(de->de_rahead);
+ memcpy(id->filename, (char *)de + sizeof(*de), id->name_len);
+ id->filename[id->name_len] = '\0';
+}
+
+static int indirect_dirent(struct indirect_info *indir, void *ptr, int d)
+{
+ struct gfs2_dirent *de = ptr;
+ int ret = 0;
- gfs2_dirent_in(&de, ptr);
- if (de.de_rec_len < sizeof(struct gfs2_dirent) ||
- de.de_rec_len > 4096 - sizeof(struct gfs2_dirent))
+ if (be16_to_cpu(de->de_rec_len) < sizeof(struct gfs2_dirent) ||
+ be16_to_cpu(de->de_rec_len) > 4096 - sizeof(struct gfs2_dirent))
return -1;
- if (de.de_inum.no_addr) {
- indir->block = de.de_inum.no_addr;
- memcpy(&indir->dirent[d].dirent, &de, sizeof(struct gfs2_dirent));
- memcpy(&indir->dirent[d].filename,
- ptr + sizeof(struct gfs2_dirent), de.de_name_len);
- indir->dirent[d].filename[de.de_name_len] = '\0';
- indir->dirent[d].block = de.de_inum.no_addr;
+ if (de->de_inum.no_addr) {
+ idirent_in(&indir->dirent[d], ptr);
+ indir->block = be64_to_cpu(de->de_inum.no_addr);
indir->is_dir = TRUE;
indir->dirents++;
+ ret = indir->dirent[d].rec_len;
}
- return de.de_rec_len;
+ return ret;
}
void do_dinode_extended(char *buf)
@@ -320,29 +332,22 @@ void do_dinode_extended(char *buf)
uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
{
int x, i;
- struct gfs2_dirent de;
+ struct gfs2_dirent *de;
x = 0;
memset(indir, 0, sizeof(*indir));
gfs2_leaf_in(&indir->ii[0].lf, dlebuf);
/* Directory Entries: */
- for (i = sizeof(struct gfs2_leaf); i < sbd.sd_bsize;
- i += de.de_rec_len) {
- gfs2_dirent_in(&de, dlebuf + i);
- if (de.de_inum.no_addr) {
- indir->ii[0].block = de.de_inum.no_addr;
- indir->ii[0].dirent[x].block = de.de_inum.no_addr;
- memcpy(&indir->ii[0].dirent[x].dirent,
- &de, sizeof(struct gfs2_dirent));
- memcpy(&indir->ii[0].dirent[x].filename,
- dlebuf + i + sizeof(struct gfs2_dirent),
- de.de_name_len);
- indir->ii[0].dirent[x].filename[de.de_name_len] = '\0';
+ for (i = sizeof(struct gfs2_leaf); i < sbd.sd_bsize; i += be16_to_cpu(de->de_rec_len)) {
+ de = (struct gfs2_dirent *)(dlebuf + i);
+ if (de->de_inum.no_addr) {
+ idirent_in(&indir->ii[0].dirent[x], de);
+ indir->ii[0].block = be64_to_cpu(de->de_inum.no_addr);
indir->ii[0].is_dir = TRUE;
indir->ii[0].dirents++;
x++;
}
- if (de.de_rec_len <= sizeof(struct gfs2_dirent))
+ if (be16_to_cpu(de->de_rec_len) <= sizeof(struct gfs2_dirent))
break;
}
return indir->ii[0].lf.lf_next;
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 2843262b..fb643ac3 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -462,7 +462,7 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
int d;
for (d = 2; d < 8; d++) {
- if (block == masterdir.dirent[d].block) {
+ if (block == masterdir.dirent[d].inum.addr) {
if (!strncmp(masterdir.dirent[d].filename, "jindex", 6))
print_gfs2("--------------- Journal Index ------------------");
else if (!strncmp(masterdir.dirent[d].filename, "per_node", 8))
@@ -687,7 +687,7 @@ uint64_t masterblock(const char *fn)
for (d = 2; d < 8; d++)
if (!strncmp(masterdir.dirent[d].filename, fn, strlen(fn)))
- return (masterdir.dirent[d].block);
+ return (masterdir.dirent[d].inum.addr);
return 0;
}
@@ -1024,27 +1024,26 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
indirect_blocks = 0;
lines_per_row[dmode] = 1;
if (gfs2_struct_type == GFS2_METATYPE_SB || blk == 0x10 * (4096 / sbd.sd_bsize)) {
+ struct indirect_info *ii = &indirect->ii[0];
+ struct idirent *id;
+
lgfs2_sb_in(&sbd, bh->b_data);
memset(indirect, 0, sizeof(struct iinfo));
- indirect->ii[0].block = sbd.sd_meta_dir.no_addr;
- indirect->ii[0].is_dir = TRUE;
- indirect->ii[0].dirents = 2;
-
- memcpy(&indirect->ii[0].dirent[0].filename, "root", 4);
- indirect->ii[0].dirent[0].dirent.de_inum.no_formal_ino =
- sbd.sd_root_dir.no_formal_ino;
- indirect->ii[0].dirent[0].dirent.de_inum.no_addr =
- sbd.sd_root_dir.no_addr;
- indirect->ii[0].dirent[0].block = sbd.sd_root_dir.no_addr;
- indirect->ii[0].dirent[0].dirent.de_type = DT_DIR;
-
- memcpy(&indirect->ii[0].dirent[1].filename, "master", 7);
- indirect->ii[0].dirent[1].dirent.de_inum.no_formal_ino =
- sbd.sd_meta_dir.no_formal_ino;
- indirect->ii[0].dirent[1].dirent.de_inum.no_addr =
- sbd.sd_meta_dir.no_addr;
- indirect->ii[0].dirent[1].block = sbd.sd_meta_dir.no_addr;
- indirect->ii[0].dirent[1].dirent.de_type = DT_DIR;
+ ii->block = sbd.sd_meta_dir.no_addr;
+ ii->is_dir = TRUE;
+ ii->dirents = 2;
+
+ id = &ii->dirent[0];
+ memcpy(id->filename, "root", 4);
+ id->inum.formal_ino = sbd.sd_root_dir.no_formal_ino;
+ id->inum.addr = sbd.sd_root_dir.no_addr;
+ id->type = DT_DIR;
+
+ id = &ii->dirent[1];
+ memcpy(id->filename, "master", 7);
+ id->inum.formal_ino = sbd.sd_meta_dir.no_formal_ino;
+ id->inum.addr = sbd.sd_meta_dir.no_addr;
+ id->type = DT_DIR;
}
else if (gfs2_struct_type == GFS2_METATYPE_DI) {
di = (struct gfs2_dinode *)bh->b_data;
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index fb060089..f60d836d 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -63,12 +63,21 @@ extern int combined_display;
extern int details;
extern const char *allocdesc[2][5];
-struct gfs2_dirents {
- uint64_t block;
- struct gfs2_dirent dirent;
+struct idirent {
+ struct {
+ uint64_t formal_ino;
+ uint64_t addr;
+ } inum;
+ uint32_t hash;
+ uint16_t rec_len;
+ uint16_t name_len;
+ uint16_t type;
+ uint16_t rahead;
char filename[NAME_MAX];
};
+extern void idirent_in(struct idirent *id, void *de);
+
struct indirect_info {
int is_dir;
int height;
@@ -76,7 +85,7 @@ struct indirect_info {
uint32_t dirents;
struct gfs2_leaf lf;
struct metapath mp;
- struct gfs2_dirents dirent[64];
+ struct idirent dirent[64];
uint64_t ptroff;
};
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index eb8fb4f6..b3333861 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -77,7 +77,7 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
if (journal_num > indirect->ii[0].dirents - 2)
return 0;
- jblock = indirect->ii[0].dirent[journal_num + 2].block;
+ jblock = indirect->ii[0].dirent[journal_num + 2].inum.addr;
j_bh = bread(&sbd, jblock);
jdi = (struct gfs2_dinode *)j_bh->b_data;
*j_size = be64_to_cpu(jdi->di_size);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index b4706248..5d51ea1f 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -278,7 +278,7 @@ static int init_per_node_lookup(void)
for (i = 0; i < indirect_blocks; i++) {
int d;
for (d = 0; d < indirect->ii[i].dirents; d++) {
- int ret = insert_per_node_lookup(indirect->ii[i].dirent[d].block);
+ int ret = insert_per_node_lookup(indirect->ii[i].dirent[d].inum.addr);
if (ret != 0)
return ret;
}
@@ -966,7 +966,7 @@ static void get_journal_inode_blocks(void)
} else {
if (journal + 3 > indirect->ii[0].dirents)
break;
- jblock = indirect->ii[0].dirent[journal + 2].block;
+ jblock = indirect->ii[0].dirent[journal + 2].inum.addr;
}
journal_blocks[journals_found++] = jblock;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months