[gfs2-utils] 07/27: libgfs2: Remove i_di from struct gfs2_inode
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 e5bc9656575b19e0177a8a0ee548053bb35d0912
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri May 14 15:42:30 2021 +0100
libgfs2: Remove i_di from struct gfs2_inode
To stop storing native-endian data in a struct gfs2_dinode, its fields
are duplicated into struct gfs2_inode using uint*_t types and the
in/out/print functions updated to work directly with the struct
gfs2_inode. This requires a few intermediate gfs2_inums to be used in
places that previously used i_di.di_num as a whole. They will be
resolved once a native-endian replacement for gfs2_inums is added.
Unfortunately the large size of this patch is necessary as the switch is
an all-or-nothing deal, but most of it is fairly mechanical.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 154 +++++++-------
gfs2/edit/extended.c | 10 +-
gfs2/edit/hexedit.c | 12 +-
gfs2/edit/journal.c | 16 +-
gfs2/fsck/afterpass1_common.c | 29 ++-
gfs2/fsck/fs_recovery.c | 29 ++-
gfs2/fsck/initialize.c | 185 ++++++++---------
gfs2/fsck/link.c | 35 ++--
gfs2/fsck/lost_n_found.c | 143 +++++++------
gfs2/fsck/main.c | 7 +-
gfs2/fsck/metawalk.c | 286 +++++++++++---------------
gfs2/fsck/pass1.c | 453 +++++++++++++++++-------------------------
gfs2/fsck/pass1b.c | 62 +++---
gfs2/fsck/pass2.c | 390 ++++++++++++++++--------------------
gfs2/fsck/pass3.c | 23 ++-
gfs2/fsck/pass4.c | 31 ++-
gfs2/fsck/rgrepair.c | 25 +--
gfs2/fsck/util.c | 47 ++---
gfs2/fsck/util.h | 12 +-
gfs2/glocktop/glocktop.c | 19 +-
gfs2/libgfs2/fs_ops.c | 215 ++++++++++----------
gfs2/libgfs2/gfs1.c | 122 +++++-------
gfs2/libgfs2/lang.c | 4 +-
gfs2/libgfs2/libgfs2.h | 42 +++-
gfs2/libgfs2/ondisk.c | 140 +++++++------
gfs2/libgfs2/recovery.c | 8 +-
gfs2/libgfs2/structures.c | 38 ++--
gfs2/libgfs2/super.c | 2 +-
gfs2/mkfs/main_mkfs.c | 11 +-
tests/nukerg.c | 2 +-
30 files changed, 1164 insertions(+), 1388 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index cca60598..d1cccd59 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -209,10 +209,10 @@ static unsigned int calc_gfs2_tree_height(struct gfs2_inode *ip, uint64_t size)
uint64_t *arr;
unsigned int max, height;
- if (ip->i_di.di_size > size)
- size = ip->i_di.di_size;
+ if (ip->i_size > size)
+ size = ip->i_size;
- if (S_ISDIR(ip->i_di.di_mode)) {
+ if (S_ISDIR(ip->i_mode)) {
arr = gfs2_jheightsize;
max = gfs2_max_jheight;
} else {
@@ -290,7 +290,7 @@ static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
mh.mh_magic = GFS2_MAGIC;
mh.mh_type = GFS2_METATYPE_IN;
mh.mh_format = GFS2_FORMAT_IN;
- if (!ip->i_di.di_height)
+ if (!ip->i_height)
unstuff_dinode(ip);
ptramt = blk->mp.mp_list[blk->height] * sizeof(uint64_t);
@@ -448,7 +448,7 @@ static uint64_t fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
mh.mh_type = GFS2_METATYPE_IN;
mh.mh_format = GFS2_FORMAT_IN;
- if (!ip->i_di.di_height)
+ if (!ip->i_height)
unstuff_dinode(ip);
ptramt = blk->mp.mp_list[blk->height];
@@ -540,7 +540,7 @@ static int get_inode_metablocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip, str
osi_list_foreach(tmp, &blocks->list) {
blk = osi_list_entry(tmp, struct blocklist, list);
- if (blk->height >= ip->i_di.di_height - 1)
+ if (blk->height >= ip->i_height - 1)
continue;
for (ptr1 = (uint64_t *)blk->ptrbuf, ptrnum = 0;
ptrnum < sbp->sd_inptrs; ptr1++, ptrnum++) {
@@ -579,7 +579,7 @@ static int get_inode_metablocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip, str
brelse(bh);
/* Free the block so we can reuse it. This allows us to
convert a "full" file system. */
- ip->i_di.di_blocks--;
+ ip->i_blocks--;
gfs2_free_block(sbp, block);
}
}
@@ -622,7 +622,7 @@ static int fix_ind_reg_or_dir(struct gfs2_sbd *sbp, struct gfs2_inode *ip, uint3
blk->height -= di_height - gfs2_hgt;
if (len) {
fix_metatree(sbp, ip, blk, ptr1, len);
- ip->i_di.di_goal_meta = be64_to_cpu(*ptr2);
+ ip->i_goal_meta = be64_to_cpu(*ptr2);
}
return 0;
@@ -671,7 +671,7 @@ static int fix_ind_jdata(struct gfs2_sbd *sbp, struct gfs2_inode *ip, uint32_t d
newblk->mp.mp_list[h] = blk->mp.mp_list[h];
newblk->mp.mp_list[h] = ptrnum;
bh = bread(sbp, block);
- /* This is a data block. i.e newblk->height == ip->i_di.di_height */
+ /* This is a data block. i.e newblk->height == ip->i_height */
/* read in the jdata block */
memcpy(newblk->ptrbuf, bh->b_data +
sizeof(struct gfs2_meta_header), bufsize);
@@ -680,7 +680,7 @@ static int fix_ind_jdata(struct gfs2_sbd *sbp, struct gfs2_inode *ip, uint32_t d
brelse(bh);
/* Free the block so we can reuse it. This allows us to
convert a "full" file system */
- ip->i_di.di_blocks--;
+ ip->i_blocks--;
gfs2_free_block(sbp, block);
len = bufsize;
@@ -689,7 +689,7 @@ static int fix_ind_jdata(struct gfs2_sbd *sbp, struct gfs2_inode *ip, uint32_t d
memcpy(&newblk->mp, &gfs2mp, sizeof(struct metapath));
newblk->height -= di_height - gfs2_hgt;
if (len)
- ip->i_di.di_goal_meta = fix_jdatatree(sbp, ip, newblk,
+ ip->i_goal_meta = fix_jdatatree(sbp, ip, newblk,
newblk->ptrbuf, len);
free(newblk->ptrbuf);
free(newblk);
@@ -705,17 +705,17 @@ static int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip)
struct blocklist blocks, *blk;
int error = 0;
- int isdir = S_ISDIR(ip->i_di.di_mode); /* is always jdata */
- int isjdata = ((GFS2_DIF_JDATA & ip->i_di.di_flags) && !isdir);
+ int isdir = S_ISDIR(ip->i_mode); /* is always jdata */
+ int isjdata = ((GFS2_DIF_JDATA & ip->i_flags) && !isdir);
int isreg = (!isjdata && !isdir);
- int issys = (GFS2_DIF_SYSTEM & ip->i_di.di_flags);
+ int issys = (GFS2_DIF_SYSTEM & ip->i_flags);
/* regular files and dirs are same upto height=2
jdata files (not dirs) are same only when height=0 */
- if (((isreg||isdir) && ip->i_di.di_height <= 1) ||
- (isjdata && ip->i_di.di_height == 0)) {
+ if (((isreg||isdir) && ip->i_height <= 1) ||
+ (isjdata && ip->i_height == 0)) {
if (!issys)
- ip->i_di.di_goal_meta = ip->i_di.di_num.no_addr;
+ ip->i_goal_meta = ip->i_addr;
return 0; /* nothing to do */
}
@@ -727,13 +727,13 @@ static int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip)
/* The gfs2 height may be different. We need to rebuild the
metadata tree to the gfs2 height. */
- gfs2_hgt = calc_gfs2_tree_height(ip, ip->i_di.di_size);
+ gfs2_hgt = calc_gfs2_tree_height(ip, ip->i_size);
/* Save off the size because we're going to empty the contents
and add the data blocks back in later. */
- dinode_size = ip->i_di.di_size;
- ip->i_di.di_size = 0ULL;
- di_height = ip->i_di.di_height;
- ip->i_di.di_height = 0;
+ dinode_size = ip->i_size;
+ ip->i_size = 0ULL;
+ di_height = ip->i_height;
+ ip->i_height = 0;
/* Now run through the block list a second time. If the block
is a data block, rewrite the data to the gfs2 offset. */
@@ -762,11 +762,11 @@ static int adjust_indirect_blocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip)
free(blk);
}
- ip->i_di.di_size = dinode_size;
+ ip->i_size = dinode_size;
/* Set the new dinode height, which may or may not have changed. */
/* The caller will take it from the ip and write it to the buffer */
- ip->i_di.di_height = gfs2_hgt;
+ ip->i_height = gfs2_hgt;
return error;
out:
@@ -794,7 +794,7 @@ static int fix_cdpn_symlink(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, s
{
char *linkptr = NULL;
- if (ip->i_di.di_height != 0)
+ if (ip->i_height != 0)
return 0;
linkptr = bh->b_data + sizeof(struct gfs_dinode);
@@ -807,7 +807,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_di.di_num.no_addr;
+ fix->di_addr = ip->i_addr;
osi_list_add_prev((osi_list_t *)&fix->list,
(osi_list_t *)&cdpns_to_fix);
}
@@ -817,7 +817,7 @@ static int fix_cdpn_symlink(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, s
/*
* fix_xattr -
- * Extended attributes can be either direct (in the ip->i_di.di_eattr block) or
+ * Extended attributes can be either direct (in the ip->i_eattr block) or
* then can be at a maximum of 1 indirect level. Multiple levels of indirection
* are not supported. If the di_eattr block contains extended attribute data,
* i.e block type = GFS_METATYPE_EA, we ignore it.
@@ -831,8 +831,8 @@ static int fix_xattr(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, struct g
struct gfs2_buffer_head *eabh;
char *buf;
- /* Read in the i_di.di_eattr block */
- eabh = bread(sbp, ip->i_di.di_eattr);
+ /* Read in the i_eattr block */
+ eabh = bread(sbp, ip->i_eattr);
if (!gfs2_check_meta(eabh->b_data, GFS_METATYPE_IN)) {/* if it is an indirect block */
len = sbp->bsize - sizeof(struct gfs_indirect);
buf = malloc(len);
@@ -871,16 +871,15 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
return -1;
}
- inode_was_gfs1 = (inode->i_di.di_num.no_formal_ino ==
- inode->i_di.di_num.no_addr);
+ inode_was_gfs1 = (inode->i_formal_ino == inode->i_addr);
/* Fix the inode number: */
- inode->i_di.di_num.no_formal_ino = sbp->md.next_inum;
+ inode->i_formal_ino = sbp->md.next_inum;
/* Fix the inode type: gfs1 uses di_type, gfs2 uses di_mode. */
- inode->i_di.di_mode &= ~S_IFMT;
- switch (inode->i_di.__pad1) { /* formerly di_type */
+ inode->i_mode &= ~S_IFMT;
+ switch (inode->i_pad1) { /* formerly di_type */
case GFS_FILE_DIR: /* directory */
- inode->i_di.di_mode |= S_IFDIR;
+ inode->i_mode |= S_IFDIR;
/* Add this directory to the list of dirs to fix later. */
fixdir = malloc(sizeof(struct inode_block));
if (!fixdir) {
@@ -889,27 +888,27 @@ 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_di.di_num.no_addr;
+ fixdir->di_addr = inode->i_addr;
osi_list_add_prev((osi_list_t *)&fixdir->list,
(osi_list_t *)&dirs_to_fix);
break;
case GFS_FILE_REG: /* regular file */
- inode->i_di.di_mode |= S_IFREG;
+ inode->i_mode |= S_IFREG;
break;
case GFS_FILE_LNK: /* symlink */
- inode->i_di.di_mode |= S_IFLNK;
+ inode->i_mode |= S_IFLNK;
break;
case GFS_FILE_BLK: /* block device */
- inode->i_di.di_mode |= S_IFBLK;
+ inode->i_mode |= S_IFBLK;
break;
case GFS_FILE_CHR: /* character device */
- inode->i_di.di_mode |= S_IFCHR;
+ inode->i_mode |= S_IFCHR;
break;
case GFS_FILE_FIFO: /* fifo / pipe */
- inode->i_di.di_mode |= S_IFIFO;
+ inode->i_mode |= S_IFIFO;
break;
case GFS_FILE_SOCK: /* socket */
- inode->i_di.di_mode |= S_IFSOCK;
+ inode->i_mode |= S_IFSOCK;
break;
}
@@ -930,25 +929,26 @@ static int adjust_inode(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh)
/* don't want to shift the data around. */
/* ----------------------------------------------------------- */
if (inode_was_gfs1) {
- struct gfs_dinode *gfs1_dinode_struct;
+ struct {
+ uint32_t dblk;
+ uint32_t mblk;
+ } *gfs1_goals = (void *)&inode->i_generation;
int ret = 0;
- gfs1_dinode_struct = (struct gfs_dinode *)&inode->i_di;
- inode->i_di.di_goal_meta = inode->i_di.di_goal_data;
- inode->i_di.di_goal_data = 0; /* make sure the upper 32b are 0 */
- inode->i_di.di_goal_data = gfs1_dinode_struct->di_goal_dblk;
- inode->i_di.di_generation = 0;
+ inode->i_goal_meta = inode->i_goal_data;
+ inode->i_goal_data = (uint64_t)gfs1_goals->dblk;
+ inode->i_generation = 0;
if (adjust_indirect_blocks(sbp, inode))
goto err_freei;
/* Check for cdpns */
- if (S_ISLNK(inode->i_di.di_mode)) {
+ if (S_ISLNK(inode->i_mode)) {
ret = fix_cdpn_symlink(sbp, bh, inode);
if (ret)
goto err_freei;
}
/* Check for extended attributes */
- if (inode->i_di.di_eattr) {
+ if (inode->i_eattr) {
ret = fix_xattr(sbp, bh, inode);
if (ret)
goto err_freei;
@@ -1124,10 +1124,10 @@ 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->no_formal_ino = fix_inode->i_di.di_num.no_formal_ino;
- inum->no_addr = fix_inode->i_di.di_num.no_addr;
+ inum->no_formal_ino = fix_inode->i_formal_ino;
+ inum->no_addr = fix_inode->i_addr;
if (eablk)
- *eablk = fix_inode->i_di.di_eattr;
+ *eablk = fix_inode->i_eattr;
inode_put(&fix_inode);
return 0;
@@ -1239,7 +1239,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.no_addr)
- fix->di_paddr = dip->i_di.di_num.no_addr;
+ fix->di_paddr = dip->i_addr;
}
}
@@ -1324,14 +1324,14 @@ static int process_directory(struct gfs2_sbd *sbp, uint64_t dirblock, uint64_t d
if (dip == NULL)
return -1;
/* fix the directory: either exhash (leaves) or linear (stuffed) */
- if (dip->i_di.di_flags & GFS2_DIF_EXHASH) {
+ if (dip->i_flags & GFS2_DIF_EXHASH) {
if (fix_one_directory_exhash(sbp, dip, dentmod)) {
log_crit(_("Error fixing exhash directory.\n"));
inode_put(&dip);
return -1;
}
} else {
- error = process_dirent_info(dip, sbp, dip->i_bh, dip->i_di.di_entries, dentmod);
+ error = process_dirent_info(dip, sbp, dip->i_bh, dip->i_entries, dentmod);
if (error && error != -EISDIR) {
log_crit(_("Error fixing linear directory.\n"));
inode_put(&dip);
@@ -1430,7 +1430,7 @@ static int fix_cdpn_symlinks(struct gfs2_sbd *sbp, osi_list_t *cdpn_to_fix)
fix_inode = lgfs2_inode_get(sbp, bh);
if (fix_inode == NULL)
return -1;
- fix_inode->i_di.di_eattr = eablk; /*fix extended attribute */
+ fix_inode->i_eattr = eablk; /*fix extended attribute */
inode_put(&fix_inode);
bmodified(bh);
brelse(bh);
@@ -1471,17 +1471,17 @@ static int read_gfs1_jiindex(struct gfs2_sbd *sdp)
int error=0;
unsigned int tmp_mode = 0;
- if(ip->i_di.di_size % sizeof(struct gfs_jindex) != 0){
+ if(ip->i_size % sizeof(struct gfs_jindex) != 0){
log_crit(_("The size reported in the journal index"
" inode is not a\n"
"\tmultiple of the size of a journal index.\n"));
return -1;
}
- if(!(sd_jindex = (struct gfs_jindex *)malloc(ip->i_di.di_size))) {
+ if(!(sd_jindex = (struct gfs_jindex *)malloc(ip->i_size))) {
log_crit(_("Unable to allocate journal index\n"));
return -1;
}
- if(!memset(sd_jindex, 0, ip->i_di.di_size)) {
+ if(!memset(sd_jindex, 0, ip->i_size)) {
log_crit(_("Unable to zero journal index\n"));
return -1;
}
@@ -1490,9 +1490,9 @@ static int read_gfs1_jiindex(struct gfs2_sbd *sdp)
* so it skips the metaheader struct in the data blocks
* in the inode. gfs2_jindex inode doesn't have metaheaders
* in the data blocks */
- tmp_mode = ip->i_di.di_mode;
- ip->i_di.di_mode &= ~S_IFMT;
- ip->i_di.di_mode |= S_IFDIR;
+ tmp_mode = ip->i_mode;
+ ip->i_mode &= ~S_IFMT;
+ ip->i_mode |= S_IFDIR;
for (j = 0; ; j++) {
struct gfs_jindex *journ;
@@ -1509,8 +1509,8 @@ static int read_gfs1_jiindex(struct gfs2_sbd *sdp)
gfs1_jindex_in(journ, buf);
sdp->jsize = (journ->ji_nsegment * 16 * sdp->bsize) >> 20;
}
- ip->i_di.di_mode = tmp_mode;
- if(j * sizeof(struct gfs_jindex) != ip->i_di.di_size){
+ ip->i_mode = tmp_mode;
+ if(j * sizeof(struct gfs_jindex) != ip->i_size){
log_crit(_("journal inode size invalid\n"));
goto fail;
}
@@ -1710,8 +1710,8 @@ static int init(struct gfs2_sbd *sbp, struct gfs2_options *opts)
/* apparently only for directories. So we need to fake out libgfs2 */
/* so that it adjusts for the metaheader by faking out the inode to */
/* look like a directory, temporarily. */
- sbp->md.riinode->i_di.di_mode &= ~S_IFMT;
- sbp->md.riinode->i_di.di_mode |= S_IFDIR;
+ sbp->md.riinode->i_mode &= ~S_IFMT;
+ sbp->md.riinode->i_mode |= S_IFDIR;
printf(_("Examining file system"));
if (gfs1_ri_update(sbp, &rgcount, 0)){
log_crit(_("Unable to fill in resource group information.\n"));
@@ -2158,15 +2158,15 @@ static void copy_quotas(struct gfs2_sbd *sdp)
exit(1);
}
- nq_ip->i_di.di_height = oq_ip->i_di.di_height;
- nq_ip->i_di.di_size = oq_ip->i_di.di_size;
- nq_ip->i_di.di_blocks = oq_ip->i_di.di_blocks;
+ nq_ip->i_height = oq_ip->i_height;
+ nq_ip->i_size = oq_ip->i_size;
+ nq_ip->i_blocks = oq_ip->i_blocks;
memcpy(nq_ip->i_bh->b_data + sizeof(struct gfs2_dinode),
oq_ip->i_bh->b_data + sizeof(struct gfs2_dinode),
sdp->bsize - sizeof(struct gfs2_dinode));
- oq_ip->i_di.di_height = 0;
- oq_ip->i_di.di_size = 0;
+ oq_ip->i_height = 0;
+ oq_ip->i_size = 0;
bmodified(nq_ip->i_bh);
inode_put(&nq_ip);
@@ -2321,7 +2321,8 @@ 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_sb.sb_master_dir = sb2.master_dir->i_di.di_num;
+ sb2.sd_sb.sb_master_dir.no_addr = sb2.master_dir->i_addr;
+ sb2.sd_sb.sb_master_dir.no_formal_ino = sb2.master_dir->i_formal_ino;
/* Build empty journal index file. */
error = conv_build_jindex(&sb2);
if (error) {
@@ -2370,11 +2371,8 @@ int main(int argc, char **argv)
}
/* Copy out the master dinode */
- {
- struct gfs2_inode *ip = sb2.master_dir;
- if (ip->i_bh->b_modified)
- gfs2_dinode_out(&ip->i_di, ip->i_bh->b_data);
- }
+ if (sb2.master_dir->i_bh->b_modified)
+ lgfs2_dinode_out(sb2.master_dir, sb2.master_dir->i_bh->b_data);
/* Copy old quotas */
copy_quotas(&sb2);
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index c977b6e1..f3b1bba0 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -439,7 +439,7 @@ static int print_gfs_jindex(struct gfs2_inode *dij)
start_line = line;
print_gfs2("Journal index entries found: %"PRIu64".",
- dij->i_di.di_size / sizeof(struct gfs_jindex));
+ dij->i_size / sizeof(struct gfs_jindex));
eol(0);
lines_per_row[dmode] = 4;
for (print_entry_ndx=0; ; print_entry_ndx++) {
@@ -483,7 +483,7 @@ static int print_gfs2_jindex(void)
print_gfs2("%s: 0x%-5"PRIx64" %"PRIu64"MB ",
indirect->ii[0].dirent[d].filename,
indirect->ii[0].dirent[d].block,
- ip->i_di.di_size / 1048576);
+ ip->i_size / 1048576);
error = lgfs2_find_jhead(ip, &head);
if (error) {
print_gfs2("corrupt.");
@@ -507,8 +507,8 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
char highlighted_addr[32];
start_line = line;
- print_gfs2("RG index entries found: %"PRIu64".", dip->i_di.di_size /
- sizeof(struct gfs2_rindex));
+ print_gfs2("RG index entries found: %"PRIu64".",
+ dip->i_size / sizeof(struct gfs2_rindex));
eol(0);
lines_per_row[dmode] = 6;
memset(highlighted_addr, 0, sizeof(highlighted_addr));
@@ -612,7 +612,7 @@ static int print_quota(struct gfs2_inode *diq)
print_gfs2("quota file contents:");
eol(0);
- print_gfs2("quota entries found: %"PRIu64".", diq->i_di.di_size / sizeof(q));
+ print_gfs2("quota entries found: %"PRIu64".", diq->i_size / sizeof(q));
eol(0);
for (i=0; ; i++) {
error = gfs2_readi(diq, &q, i * sizeof(q), sizeof(q));
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 2e647211..4fbe071d 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -696,9 +696,8 @@ uint64_t masterblock(const char *fn)
/* ------------------------------------------------------------------------ */
static void rgcount(void)
{
- printf("%lld RGs in this file system.\n",
- (unsigned long long)sbd.md.riinode->i_di.di_size /
- sizeof(struct gfs2_rindex));
+ printf("%"PRId64" RGs in this file system.\n",
+ sbd.md.riinode->i_size / sizeof(struct gfs2_rindex));
inode_put(&sbd.md.riinode);
gfs2_rgrp_free(&sbd, &sbd.rgtree);
exit(EXIT_SUCCESS);
@@ -762,12 +761,11 @@ static uint64_t get_rg_addr(int rgnum)
riinode = lgfs2_inode_read(&sbd, gblock);
if (riinode == NULL)
return 0;
- if (rgnum < riinode->i_di.di_size / sizeof(struct gfs2_rindex))
+ if (rgnum < riinode->i_size / sizeof(struct gfs2_rindex))
rgblk = find_rgrp_block(riinode, rgnum);
else
- fprintf(stderr, "Error: File system only has %lld RGs.\n",
- (unsigned long long)riinode->i_di.di_size /
- sizeof(struct gfs2_rindex));
+ fprintf(stderr, "Error: File system only has %"PRId64" RGs.\n",
+ riinode->i_size / sizeof(struct gfs2_rindex));
inode_put(&riinode);
return rgblk;
}
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index 607f65e5..13b8c121 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -73,14 +73,14 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
}
inode_put(&jiinode);
} else {
- struct gfs2_dinode jdi;
+ struct gfs2_dinode *jdi;
if (journal_num > indirect->ii[0].dirents - 2)
return 0;
jblock = indirect->ii[0].dirent[journal_num + 2].block;
j_bh = bread(&sbd, jblock);
- gfs2_dinode_in(&jdi, j_bh->b_data);
- *j_size = jdi.di_size;
+ jdi = (struct gfs2_dinode *)j_bh->b_data;
+ *j_size = be64_to_cpu(jdi->di_size);
brelse(j_bh);
}
brelse(jindex_bh);
@@ -122,12 +122,12 @@ static int fsck_readi(struct gfs2_inode *ip, void *rbuf, uint64_t roffset,
if (ip == NULL)
return 0;
sdp = ip->i_sbd;
- isdir = !!(S_ISDIR(ip->i_di.di_mode));
+ isdir = !!(S_ISDIR(ip->i_mode));
*abs_block = 0;
- if (roffset >= ip->i_di.di_size)
+ if (roffset >= ip->i_size)
return 0;
- if ((roffset + size) > ip->i_di.di_size)
- size = ip->i_di.di_size - roffset;
+ if ((roffset + size) > ip->i_size)
+ size = ip->i_size - roffset;
if (!size)
return 0;
if (isdir) {
@@ -138,7 +138,7 @@ static int fsck_readi(struct gfs2_inode *ip, void *rbuf, uint64_t roffset,
o = roffset & (sdp->bsize - 1);
}
- if (!ip->i_di.di_height) /* inode_is_stuffed */
+ if (!ip->i_height) /* inode_is_stuffed */
o += sizeof(struct gfs2_dinode);
else if (isdir)
o += sizeof(struct gfs2_meta_header);
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c
index 82b9a54c..35029202 100644
--- a/gfs2/fsck/afterpass1_common.c
+++ b/gfs2/fsck/afterpass1_common.c
@@ -86,12 +86,9 @@ static int delete_block_if_notdup(struct gfs2_inode *ip, uint64_t block,
q = bitmap_type(ip->i_sbd, block);
if (q == GFS2_BLKST_FREE) {
- log_info( _("%s block %lld (0x%llx), part of inode "
- "%lld (0x%llx), was already free.\n"),
- btype, (unsigned long long)block,
- (unsigned long long)block,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ 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);
return META_IS_GOOD;
}
if (find_remove_dup(ip, block, btype, &removed_lastmeta)) { /* a dup */
@@ -101,12 +98,10 @@ static int delete_block_if_notdup(struct gfs2_inode *ip, uint64_t block,
else
*was_duplicate = 1;
}
- log_err( _("Not clearing duplicate reference in inode "
- "at block #%llu (0x%llx) to block #%llu (0x%llx) "
- "because it's referenced by another inode.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)block, (unsigned long long)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);
} else {
check_n_fix_bitmap(ip->i_sbd, ip->i_rgd, block, 0,
GFS2_BLKST_FREE);
@@ -218,15 +213,15 @@ static int del_eattr_generic(struct gfs2_inode *ip, uint64_t block,
if (!ret) {
*bh = bread(ip->i_sbd, block);
if (!was_free)
- ip->i_di.di_blocks--;
+ ip->i_blocks--;
bmodified(ip->i_bh);
}
}
/* Even if it's a duplicate reference, we want to eliminate the
reference itself, and adjust di_blocks accordingly. */
- if (ip->i_di.di_eattr) {
- if (block == ip->i_di.di_eattr)
- ip->i_di.di_eattr = 0;
+ if (ip->i_eattr) {
+ if (block == ip->i_eattr)
+ ip->i_eattr = 0;
bmodified(ip->i_bh);
}
return ret;
@@ -308,7 +303,7 @@ int delete_eattr_extentry(struct gfs2_inode *ip, int i, uint64_t *ea_data_ptr,
bmodified(leaf_bh);
/* Endianness doesn't matter in this case because it's
a single byte. */
- fsck_bitmap_set(ip, ip->i_di.di_eattr,
+ fsck_bitmap_set(ip, ip->i_eattr,
_("extended attribute"),
ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE :
GFS2_BLKST_USED);
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index ac187853..e481c88a 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -399,7 +399,7 @@ static int foreach_descriptor(struct gfs2_inode *ip, unsigned int start,
static int check_journal_seq_no(struct gfs2_inode *ip, int fix)
{
int error = 0, wrapped = 0;
- uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
+ uint32_t jd_blocks = ip->i_size / ip->i_sbd->sd_sb.sb_bsize;
uint32_t blk;
struct lgfs2_log_header lh;
uint64_t highest_seq = 0, lowest_seq = 0, prev_seq = 0;
@@ -609,7 +609,7 @@ out:
reinit:
if (query( _("Do you want to clear the journal instead? (y/n)"))) {
error = write_journal(sdp->md.journal[j], sdp->bsize,
- sdp->md.journal[j]->i_di.di_size /
+ sdp->md.journal[j]->i_size /
sdp->sd_sb.sb_bsize);
log_err(_("jid=%u: journal was cleared.\n"), j);
} else {
@@ -624,9 +624,8 @@ 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 %lld (0x%llx).\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ "journal inode %"PRIu64" (0x%"PRIx64").\n"),
+ ip->i_addr, ip->i_addr);
return META_ERROR; /* Exits check_metatree quicker */
}
return META_IS_GOOD;
@@ -647,14 +646,11 @@ static int rangecheck_jmeta(struct iptr iptr, struct gfs2_buffer_head **bh, int
*bh = bread(ip->i_sbd, block);
*is_valid = (gfs2_check_meta((*bh)->b_data, GFS2_METATYPE_IN) == 0);
if (!(*is_valid)) {
- log_err( _("Journal at block %lld (0x%llx) has a bad "
- "indirect block pointer %lld (0x%llx) "
+ log_err( _("Journal at block %"PRIu64" (0x%"PRIx64") has a bad "
+ "indirect block pointer %"PRIu64" (0x%"PRIx64") "
"(points to something that is not an "
"indirect block).\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)block,
- (unsigned long long)block);
+ ip->i_addr, ip->i_addr, block, block);
brelse(*bh);
*bh = NULL;
return META_SKIP_FURTHER;
@@ -717,8 +713,7 @@ int replay_journals(struct gfs2_sbd *sdp, int preen, int force_check,
continue;
}
if (!error) {
- uint64_t jsize = sdp->md.journal[i]->i_di.di_size /
- (1024 * 1024);
+ uint64_t jsize = sdp->md.journal[i]->i_size / (1024 * 1024);
if (sdp->jsize == GFS2_DEFAULT_JSIZE && jsize &&
jsize != sdp->jsize)
@@ -769,11 +764,11 @@ int ji_update(struct gfs2_sbd *sdp)
If per_node is missing or damaged, we have to trust jindex has
the correct number of entries. */
if (sdp->gfs1)
- sdp->md.journals = ip->i_di.di_size / sizeof(struct gfs_jindex);
+ sdp->md.journals = ip->i_size / sizeof(struct gfs_jindex);
else if (sdp->md.pinode) /* if per_node was read in properly */
- sdp->md.journals = (sdp->md.pinode->i_di.di_entries - 2) / 3;
+ sdp->md.journals = (sdp->md.pinode->i_entries - 2) / 3;
else
- sdp->md.journals = ip->i_di.di_entries - 2;
+ sdp->md.journals = ip->i_entries - 2;
if (!(sdp->md.journal = calloc(sdp->md.journals,
sizeof(struct gfs2_inode *)))) {
@@ -911,7 +906,7 @@ int init_jindex(struct gfs2_sbd *sdp, int allow_ji_rebuild)
int error;
log_debug(_("Checking the integrity of the journal index.\n"));
- if (sdp->md.jiinode->i_di.di_flags & GFS2_DIF_EXHASH)
+ if (sdp->md.jiinode->i_flags & GFS2_DIF_EXHASH)
error = check_leaf_blks(sdp->md.jiinode,
&jindex_check_fxns);
else
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 1a6db6ec..3f2c088b 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -301,10 +301,9 @@ static void check_rgrp_integrity(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
if (!gfs2_check_meta(bh->b_data, GFS2_METATYPE_DI)) {
struct gfs2_inode *ip =
fsck_inode_get(sdp, rgd, bh);
- if (ip->i_di.di_blocks > 1) {
- blks_2free +=
- ip->i_di.di_blocks - 1;
- log_info(_("%lld blocks "
+ if (ip->i_blocks > 1) {
+ blks_2free += ip->i_blocks - 1;
+ log_info(_("%llu blocks "
"(total) may need "
"to be freed in "
"pass 5.\n"),
@@ -492,14 +491,14 @@ static int rebuild_master(struct gfs2_sbd *sdp)
if (fix_md.jiinode) {
inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.jiinode->i_di.di_num.no_addr;
+ inum.no_addr = fix_md.jiinode->i_addr;
err = dir_add(sdp->master_dir, "jindex", 6, &inum,
IF2DT(S_IFDIR | 0700));
if (err) {
log_crit(_("Error %d adding jindex directory\n"), errno);
exit(FSCK_ERROR);
}
- sdp->master_dir->i_di.di_nlink++;
+ sdp->master_dir->i_nlink++;
} else {
err = build_jindex(sdp);
if (err) {
@@ -510,7 +509,7 @@ 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_di.di_num.no_addr;
+ inum.no_addr = fix_md.pinode->i_addr;
err = dir_add(sdp->master_dir, "per_node", 8, &inum,
IF2DT(S_IFDIR | 0700));
if (err) {
@@ -518,7 +517,7 @@ static int rebuild_master(struct gfs2_sbd *sdp)
errno);
exit(FSCK_ERROR);
}
- sdp->master_dir->i_di.di_nlink++;
+ sdp->master_dir->i_nlink++;
} else {
err = build_per_node(sdp);
if (err) {
@@ -530,7 +529,7 @@ 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_di.di_num.no_addr;
+ inum.no_addr = fix_md.inum->i_addr;
err = dir_add(sdp->master_dir, "inum", 4, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -548,7 +547,7 @@ 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_di.di_num.no_addr;
+ inum.no_addr = fix_md.statfs->i_addr;
err = dir_add(sdp->master_dir, "statfs", 6, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -566,7 +565,7 @@ 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_di.di_num.no_addr;
+ inum.no_addr = fix_md.riinode->i_addr;
err = dir_add(sdp->master_dir, "rindex", 6, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -583,7 +582,7 @@ 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_di.di_num.no_addr;
+ inum.no_addr = fix_md.qinode->i_addr;
err = dir_add(sdp->master_dir, "quota", 5, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -850,8 +849,8 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
}
/* Read inum entry into buffer */
err = gfs2_readi(sdp->md.inum, &inumbuf, 0,
- sdp->md.inum->i_di.di_size);
- if (err != sdp->md.inum->i_di.di_size) {
+ sdp->md.inum->i_size);
+ if (err != sdp->md.inum->i_size) {
log_crit(_("Error %d reading system inum inode. "
"Aborting.\n"), err);
goto fail;
@@ -902,12 +901,12 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
}
do_init_statfs(sdp);
}
- if (sdp->md.statfs->i_di.di_size) {
- buf = malloc(sdp->md.statfs->i_di.di_size);
+ if (sdp->md.statfs->i_size) {
+ buf = malloc(sdp->md.statfs->i_size);
if (buf) {
err = gfs2_readi(sdp->md.statfs, buf, 0,
- sdp->md.statfs->i_di.di_size);
- if (err != sdp->md.statfs->i_di.di_size) {
+ sdp->md.statfs->i_size);
+ if (err != sdp->md.statfs->i_size) {
log_crit(_("Error %d reading statfs file. "
"Aborting.\n"), err);
free(buf);
@@ -984,9 +983,9 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
* A real dinode will be located at the block number in its no_addr.
* A journal-copy will be at a different block (inside the journal).
*/
-static int is_journal_copy(struct gfs2_inode *ip, struct gfs2_buffer_head *bh)
+static int is_journal_copy(struct gfs2_inode *ip)
{
- if (ip->i_di.di_num.no_addr == bh->b_blocknr)
+ if (ip->i_addr == ip->i_bh->b_blocknr)
return 0;
return 1; /* journal copy */
}
@@ -1001,47 +1000,40 @@ static int is_journal_copy(struct gfs2_inode *ip, struct gfs2_buffer_head *bh)
* the per_node directory will have a ".." entry that will lead us to
* the master dinode if it's been destroyed.
*/
-static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
- struct gfs2_buffer_head *bh)
+static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
{
- struct gfs2_inode *ip, *child_ip;
+ struct gfs2_inode *child_ip;
struct gfs2_inum inum;
int error;
- if (di->di_num.no_formal_ino == 2) {
+ if (ip->i_formal_ino == 2) {
if (sdp->sd_sb.sb_master_dir.no_addr)
return;
log_warn(_("Found system master directory at: 0x%"PRIx64".\n"),
- di->di_num.no_addr);
- sdp->sd_sb.sb_master_dir.no_addr = di->di_num.no_addr;
+ ip->i_addr);
+ sdp->sd_sb.sb_master_dir.no_addr = ip->i_addr;
return;
}
- ip = lgfs2_inode_read(sdp, di->di_num.no_addr);
- if (ip == NULL) {
- log_crit(_("Error reading inode: %s\n"), strerror(errno));
- return;
- }
- if ((!sdp->gfs1 && di->di_num.no_formal_ino == 3) ||
- (sdp->gfs1 && (di->di_flags & GFS2_DIF_JDATA) &&
- (di->di_size % sizeof(struct gfs_jindex) == 0))) {
- if (fix_md.jiinode || is_journal_copy(ip, bh))
+ if ((!sdp->gfs1 && ip->i_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"),
- di->di_num.no_addr);
+ log_warn(_("Found system jindex file at: 0x%"PRIx64"\n"), ip->i_addr);
fix_md.jiinode = ip;
- } else if (!sdp->gfs1 && is_dir(di, sdp->gfs1)) {
+ } else if (!sdp->gfs1 && is_dir(ip, sdp->gfs1)) {
/* Check for a jindex dir entry. Only one system dir has a
jindex: master */
gfs2_lookupi(ip, "jindex", 6, &child_ip);
if (child_ip) {
- if (fix_md.jiinode || is_journal_copy(ip, bh)) {
+ if (fix_md.jiinode || is_journal_copy(ip)) {
inode_put(&child_ip);
goto out_discard_ip;
}
fix_md.jiinode = child_ip;
- sdp->sd_sb.sb_master_dir.no_addr = di->di_num.no_addr;
+ sdp->sd_sb.sb_master_dir.no_addr = ip->i_addr;
log_warn(_("Found system master directory at: 0x%"PRIx64"\n"),
- di->di_num.no_addr);
+ ip->i_addr);
return;
}
@@ -1050,10 +1042,10 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
gfs2_lookupi(ip, "statfs_change0", 14, &child_ip);
if (child_ip) {
inode_put(&child_ip);
- if (fix_md.pinode || is_journal_copy(ip, bh))
+ 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_di.di_num.no_addr);
+ ip->i_addr);
fix_md.pinode = ip;
error = dir_search(ip, "..", 2, NULL, &inum);
if (!error && inum.no_addr) {
@@ -1064,35 +1056,30 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
}
return;
}
- log_debug(_("Unknown system directory at block 0x%"PRIx64"\n"),
- di->di_num.no_addr);
+ log_debug(_("Unknown system directory at block 0x%"PRIx64"\n"), ip->i_addr);
goto out_discard_ip;
- } else if (!sdp->gfs1 && di->di_size == 8) {
- if (fix_md.inum || is_journal_copy(ip, bh))
+ } 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"),
- di->di_num.no_addr);
- } else if (di->di_size == 24) {
- if (fix_md.statfs || is_journal_copy(ip, bh))
+ log_warn(_("Found system inum file at: 0x%"PRIx64"\n"), ip->i_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"),
- di->di_num.no_addr);
- } else if ((di->di_size % 96) == 0) {
- if (fix_md.riinode || is_journal_copy(ip, bh))
+ log_warn(_("Found system statfs file at: 0x%"PRIx64"\n"), ip->i_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"),
- di->di_num.no_addr);
- } else if (!fix_md.qinode && di->di_size >= 176 &&
- di->di_num.no_formal_ino >= 12 &&
- di->di_num.no_formal_ino <= 100) {
- if (is_journal_copy(ip, bh))
+ log_warn(_("Found system rindex file at: 0x%"PRIx64"\n"), ip->i_addr);
+ } else if (!fix_md.qinode && ip->i_size >= 176 &&
+ ip->i_formal_ino >= 12 &&
+ ip->i_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"),
- di->di_num.no_addr);
+ log_warn(_("Found system quota file at: 0x%"PRIx64"\n"), ip->i_addr);
} else {
out_discard_ip:
inode_put(&ip);
@@ -1103,58 +1090,49 @@ out_discard_ip:
* peruse_user_dinode - process a user dinode trying to find the root directory
*
*/
-static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_dinode *di,
- struct gfs2_buffer_head *bh)
+static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
{
- struct gfs2_inode *ip, *parent_ip;
+ struct gfs2_inode *parent_ip;
struct gfs2_inum inum;
int error;
if (sdp->sd_sb.sb_root_dir.no_addr) /* if we know the root dinode */
return; /* we don't need to find the root */
- if (!is_dir(di, sdp->gfs1)) /* if this isn't a directory */
+ if (!is_dir(ip, sdp->gfs1)) /* if this isn't a directory */
return; /* it can't lead us to the root anyway */
- if (di->di_num.no_formal_ino == 1) {
+ if (ip->i_formal_ino == 1) {
struct gfs2_buffer_head *root_bh;
- if (di->di_num.no_addr == bh->b_blocknr) {
+ if (ip->i_addr == ip->i_bh->b_blocknr) {
log_warn(_("Found the root directory at: 0x%"PRIx64".\n"),
- di->di_num.no_addr);
- sdp->sd_sb.sb_root_dir.no_addr = di->di_num.no_addr;
+ ip->i_addr);
+ sdp->sd_sb.sb_root_dir.no_addr = ip->i_addr;
return;
}
log_warn(_("The root dinode should be at block 0x%"PRIx64" but it "
"seems to be destroyed.\n"),
- di->di_num.no_addr);
+ ip->i_addr);
log_warn(_("Found a copy of the root directory in a journal "
"at block: 0x%"PRIx64".\n"),
- bh->b_blocknr);
- if (!query(_("Do you want to replace the root dinode from the "
- "copy? (y/n)"))) {
+ ip->i_bh->b_blocknr);
+ if (!query(_("Do you want to replace the root dinode from the copy? (y/n)"))) {
log_err(_("Damaged root dinode not fixed.\n"));
return;
}
- root_bh = bread(sdp, di->di_num.no_addr);
- memcpy(root_bh->b_data, bh->b_data, sdp->bsize);
+ root_bh = bread(sdp, ip->i_addr);
+ memcpy(root_bh->b_data, ip->i_bh->b_data, sdp->bsize);
bmodified(root_bh);
brelse(root_bh);
log_warn(_("Root directory copied from the journal.\n"));
return;
}
- ip = lgfs2_inode_read(sdp, di->di_num.no_addr);
- if (ip == NULL) {
- log_crit(_("Error reading inode: %s\n"), strerror(errno));
- return;
- }
while (ip) {
gfs2_lookupi(ip, "..", 2, &parent_ip);
- if (parent_ip && parent_ip->i_di.di_num.no_addr ==
- ip->i_di.di_num.no_addr) {
+ if (parent_ip && parent_ip->i_addr == ip->i_addr) {
log_warn(_("Found the root directory at: 0x%"PRIx64"\n"),
- ip->i_di.di_num.no_addr);
- sdp->sd_sb.sb_root_dir.no_addr =
- ip->i_di.di_num.no_addr;
+ ip->i_addr);
+ sdp->sd_sb.sb_root_dir.no_addr = ip->i_addr;
inode_put(&parent_ip);
inode_put(&ip);
return;
@@ -1250,7 +1228,7 @@ static int peruse_metadata(struct gfs2_sbd *sdp, uint64_t startblock)
{
uint64_t blk, max_rg_size;
struct gfs2_buffer_head *bh;
- struct gfs2_dinode di;
+ struct gfs2_inode *ip;
max_rg_size = 2147483648ull / sdp->bsize;
/* Max RG size is 2GB. 2G / bsize. */
@@ -1260,12 +1238,12 @@ static int peruse_metadata(struct gfs2_sbd *sdp, uint64_t startblock)
brelse(bh);
continue;
}
- gfs2_dinode_in(&di, bh->b_data);
- if (di.di_flags & GFS2_DIF_SYSTEM)
- peruse_system_dinode(sdp, &di, bh);
+ ip = lgfs2_inode_get(sdp, bh);
+ ip->bh_owned = 1; /* inode_put() will free the bh */
+ if (ip->i_flags & GFS2_DIF_SYSTEM)
+ peruse_system_dinode(sdp, ip);
else
- peruse_user_dinode(sdp, &di, bh);
- brelse(bh);
+ peruse_user_dinode(sdp, ip);
}
return 0;
}
@@ -1331,8 +1309,7 @@ static int sb_repair(struct gfs2_sbd *sdp)
(unsigned long long)possible_root);
sdp->sd_sb.sb_root_dir.no_addr = possible_root;
sdp->md.rooti = lgfs2_inode_read(sdp, possible_root);
- if (!sdp->md.rooti ||
- sdp->md.rooti->i_di.di_header.mh_magic != GFS2_MAGIC) {
+ if (!sdp->md.rooti || sdp->md.rooti->i_magic != GFS2_MAGIC) {
struct gfs2_buffer_head *bh = NULL;
log_err(_("The root dinode block is destroyed.\n"));
@@ -1365,8 +1342,7 @@ static int sb_repair(struct gfs2_sbd *sdp)
log_crit(_("Error reading master inode: %s\n"), strerror(errno));
return -1;
}
- sdp->master_dir->i_di.di_num.no_addr =
- sdp->sd_sb.sb_master_dir.no_addr;
+ sdp->master_dir->i_addr = sdp->sd_sb.sb_master_dir.no_addr;
log_info(_("Found the root directory at: 0x%"PRIx64"\n"),
sdp->sd_sb.sb_root_dir.no_addr);
sdp->md.rooti = lgfs2_inode_read(sdp,
@@ -1378,8 +1354,10 @@ static int sb_repair(struct gfs2_sbd *sdp)
lgfs2_sb_init(&sb, sdp->bsize, GFS2_FORMAT_FS);
strcpy(sb.sb_lockproto, GFS2_DEFAULT_LOCKPROTO);
strcpy(sb.sb_locktable, "unknown");
- sb.sb_master_dir = sdp->master_dir->i_di.di_num;
- sb.sb_root_dir = sdp->md.rooti->i_di.di_num;
+ sb.sb_master_dir.no_addr = sdp->master_dir->i_addr;
+ sb.sb_master_dir.no_formal_ino = sdp->master_dir->i_formal_ino;
+ sb.sb_root_dir.no_addr = sdp->md.rooti->i_addr;
+ sb.sb_root_dir.no_formal_ino = sdp->md.rooti->i_formal_ino;
lgfs2_sb_write(&sb, sdp->device_fd, sdp->bsize);
inode_put(&sdp->md.rooti);
inode_put(&sdp->master_dir);
@@ -1493,8 +1471,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_di.di_num.no_addr +
- (seg * sbd1->sb_seg_size);
+ lh.lh_first = sdp->md.journal[jnum]->i_addr + (seg * sbd1->sb_seg_size);
lh.lh_sequence = sequence;
bh = bget(sdp, lh.lh_first * sdp->bsize);
@@ -1711,9 +1688,9 @@ int initialize(struct gfs2_sbd *sdp, int force_check, int preen,
sdp->master_dir = lgfs2_inode_read(sdp,
sdp->sd_sb.sb_master_dir.no_addr);
if (!sdp->gfs1 &&
- (sdp->master_dir->i_di.di_header.mh_magic != GFS2_MAGIC ||
- sdp->master_dir->i_di.di_header.mh_type != GFS2_METATYPE_DI ||
- !sdp->master_dir->i_di.di_size)) {
+ (sdp->master_dir->i_magic != GFS2_MAGIC ||
+ sdp->master_dir->i_type != GFS2_METATYPE_DI ||
+ !sdp->master_dir->i_size)) {
inode_put(&sdp->master_dir);
rebuild_master(sdp);
sdp->master_dir = lgfs2_inode_read(sdp,
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index 08118e8a..1c5ec3d2 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -40,30 +40,34 @@ int set_di_nlink(struct gfs2_inode *ip)
struct inode_info *ii;
struct dir_info *di;
- if (is_dir(&ip->i_di, ip->i_sbd->gfs1)) {
- di = dirtree_find(ip->i_di.di_num.no_addr);
+ if (is_dir(ip, ip->i_sbd->gfs1)) {
+ di = dirtree_find(ip->i_addr);
if (di == NULL) {
- log_err(_("Error: directory %lld (0x%llx) is not "
+ log_err(_("Error: directory %"PRIu64" (0x%"PRIx64") is not "
"in the dir_tree (set).\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ ip->i_addr, ip->i_addr);
return -1;
}
- di->di_nlink = ip->i_di.di_nlink;
+ di->di_nlink = ip->i_nlink;
return 0;
}
- if (ip->i_di.di_nlink == 1) {
- link1_set(&nlink1map, ip->i_di.di_num.no_addr, 1);
+ if (ip->i_nlink == 1) {
+ link1_set(&nlink1map, ip->i_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_di.di_num.no_addr);
- if (!ii)
- ii = inodetree_insert(ip->i_di.di_num);
+ ii = inodetree_find(ip->i_addr);
+ if (!ii) {
+ struct gfs2_inum no = {
+ .no_addr = ip->i_addr,
+ .no_formal_ino = ip->i_formal_ino
+ };
+ ii = inodetree_insert(no);
+ }
if (ii)
- ii->di_nlink = ip->i_di.di_nlink;
+ ii->di_nlink = ip->i_nlink;
else
return -1;
return 0;
@@ -81,7 +85,7 @@ int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip,
const char *why)
{
struct inode_info *ii = NULL;
- uint64_t referenced_from = ip ? ip->i_di.di_num.no_addr : 0;
+ uint64_t referenced_from = ip ? ip->i_addr : 0;
struct dir_info *di;
struct gfs2_inode *link_ip;
@@ -112,7 +116,7 @@ int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip,
link_ip = fsck_load_inode(ip->i_sbd, no.no_addr);
/* Check formal ino against dinode before adding to inode tree. */
- if (no.no_formal_ino != link_ip->i_di.di_num.no_formal_ino) {
+ if (no.no_formal_ino != link_ip->i_formal_ino) {
fsck_inode_put(&link_ip);
return INCR_LINK_INO_MISMATCH; /* inode mismatch */
}
@@ -132,7 +136,8 @@ int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip,
fsck_inode_put(&link_ip);
return INCR_LINK_BAD;
}
- ii->di_num = link_ip->i_di.di_num;
+ ii->di_num.no_addr = link_ip->i_addr;
+ ii->di_num.no_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 */
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index ebe616af..59df4c05 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -20,43 +20,38 @@
static void add_dotdot(struct gfs2_inode *ip)
{
- struct dir_info *di;
struct gfs2_sbd *sdp = ip->i_sbd;
+ struct dir_info *di;
+ struct gfs2_inum no;
int err;
- log_info( _("Adding .. entry to directory %llu (0x%llx) pointing back "
- "to lost+found\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_info(_("Adding .. entry to directory %"PRIu64" (0x%"PRIx64") pointing back to lost+found\n"),
+ ip->i_addr, ip->i_addr);
/* If there's a pre-existing .. directory entry, we have to
back out the links. */
- di = dirtree_find(ip->i_di.di_num.no_addr);
+ di = dirtree_find(ip->i_addr);
if (di && valid_block(sdp, di->dotdot_parent.no_addr)) {
struct gfs2_inode *dip;
- log_debug(_("Directory (0x%llx) already had a "
- "\"..\" link to (0x%llx).\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)di->dotdot_parent.no_addr);
+ 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_di.di_num.no_formal_ino ==
- di->dotdot_parent.no_formal_ino) {
- decr_link_count(di->dotdot_parent.no_addr,
- ip->i_di.di_num.no_addr, sdp->gfs1,
+ if (dip->i_formal_ino == di->dotdot_parent.no_formal_ino) {
+ decr_link_count(di->dotdot_parent.no_addr, ip->i_addr, sdp->gfs1,
_(".. unlinked, moving to lost+found"));
- if (dip->i_di.di_nlink > 0) {
- dip->i_di.di_nlink--;
+ if (dip->i_nlink > 0) {
+ dip->i_nlink--;
set_di_nlink(dip); /* keep inode tree in sync */
log_debug(_("Decrementing its links to %d\n"),
- dip->i_di.di_nlink);
+ dip->i_nlink);
bmodified(dip->i_bh);
- } else if (!dip->i_di.di_nlink) {
+ } else if (!dip->i_nlink) {
log_debug(_("Its link count is zero.\n"));
} else {
- log_debug(_("Its link count is %d! Changing "
- "it to 0.\n"), dip->i_di.di_nlink);
- dip->i_di.di_nlink = 0;
+ log_debug(_("Its link count is %d! Changing it to 0.\n"),
+ dip->i_nlink);
+ dip->i_nlink = 0;
set_di_nlink(dip); /* keep inode tree in sync */
bmodified(dip->i_bh);
}
@@ -64,32 +59,31 @@ 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_di.di_num.no_addr,
- di->dotdot_parent.no_addr,
+ ip->i_addr, di->dotdot_parent.no_addr,
di->dotdot_parent.no_formal_ino,
- dip->i_di.di_num.no_formal_ino);
+ dip->i_formal_ino);
log_debug(_("The parent directory was not changed.\n"));
}
fsck_inode_put(&dip);
di = NULL;
} else {
if (di)
- log_debug(_("Couldn't find a valid \"..\" entry "
- "for orphan directory (0x%llx): "
- "'..' = 0x%llx\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)di->dotdot_parent.no_addr);
+ log_debug(_("Couldn't find a valid '..' entry "
+ "for orphan directory (0x%"PRIx64"): "
+ "'..' = 0x%"PRIx64"\n"),
+ ip->i_addr, di->dotdot_parent.no_addr);
else
- log_debug(_("Couldn't find directory (0x%llx) "
+ log_debug(_("Couldn't find directory (0x%"PRIx64") "
"in directory tree.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr);
+ ip->i_addr);
}
if (gfs2_dirent_del(ip, "..", 2))
log_warn( _("add_inode_to_lf: Unable to remove "
"\"..\" directory entry.\n"));
- err = dir_add(ip, "..", 2, &(lf_dip->i_di.di_num),
- (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
+ no.no_addr = lf_dip->i_addr;
+ no.no_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"),
strerror(errno));
@@ -107,7 +101,7 @@ void make_sure_lf_exists(struct gfs2_inode *ip)
if (lf_dip)
return;
- root_entries = sdp->md.rooti->i_di.di_entries;
+ root_entries = sdp->md.rooti->i_entries;
log_info( _("Locating/Creating lost+found directory\n"));
/* if this is gfs1, we have to trick createi into using
@@ -132,32 +126,38 @@ void make_sure_lf_exists(struct gfs2_inode *ip)
them in sync so that pass4 can detect and fix any descrepancies. */
set_di_nlink(sdp->md.rooti);
- if (sdp->md.rooti->i_di.di_entries > root_entries) {
+ 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
+ };
lf_was_created = 1;
/* This is a new lost+found directory, so set its block type
and increment link counts for the directories */
/* FIXME: i'd feel better about this if fs_mkdir returned
whether it created a new directory or just found an old one,
and we used that instead of the bitmap_type to run this */
- dirtree_insert(lf_dip->i_di.di_num);
+ dirtree_insert(no);
/* 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_di.di_num.no_addr,
- _("lost+found dinode"), GFS2_BLKST_DINODE);
+ fsck_bitmap_set(ip, lf_dip->i_addr, _("lost+found dinode"), GFS2_BLKST_DINODE);
/* root inode links to lost+found */
- incr_link_count(sdp->md.rooti->i_di.di_num, lf_dip, _("root"));
+ no.no_addr = sdp->md.rooti->i_addr;
+ no.no_formal_ino = sdp->md.rooti->i_formal_ino;
+ incr_link_count(no, lf_dip, _("root"));
/* lost+found link for '.' from itself */
- incr_link_count(lf_dip->i_di.di_num, lf_dip, "\".\"");
+ no.no_addr = lf_dip->i_addr;
+ no.no_formal_ino = lf_dip->i_formal_ino;
+ incr_link_count(no, lf_dip, "\".\"");
/* lost+found link for '..' back to root */
- incr_link_count(lf_dip->i_di.di_num, sdp->md.rooti, "\"..\"");
+ incr_link_count(no, sdp->md.rooti, "\"..\"");
if (sdp->gfs1)
- lf_dip->i_di.__pad1 = GFS_FILE_DIR;
+ lf_dip->i_pad1 = GFS_FILE_DIR;
}
- log_info( _("lost+found directory is dinode %lld (0x%llx)\n"),
- (unsigned long long)lf_dip->i_di.di_num.no_addr,
- (unsigned long long)lf_dip->i_di.di_num.no_addr);
- di = dirtree_find(lf_dip->i_di.di_num.no_addr);
+ 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);
if (di) {
log_info( _("Marking lost+found inode connected\n"));
di->checked = 1;
@@ -178,11 +178,12 @@ 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;
int err = 0;
uint32_t mode;
make_sure_lf_exists(ip);
- if (ip->i_di.di_num.no_addr == lf_dip->i_di.di_num.no_addr) {
+ if (ip->i_addr == lf_dip->i_addr) {
log_err( _("Trying to add lost+found to itself...skipping"));
return 0;
}
@@ -190,54 +191,47 @@ int add_inode_to_lf(struct gfs2_inode *ip){
if (sdp->gfs1)
mode = gfs_to_gfs2_mode(ip);
else
- mode = ip->i_di.di_mode & S_IFMT;
+ mode = ip->i_mode & S_IFMT;
switch (mode) {
case S_IFDIR:
add_dotdot(ip);
- sprintf(tmp_name, "lost_dir_%llu",
- (unsigned long long)ip->i_di.di_num.no_addr);
+ sprintf(tmp_name, "lost_dir_%"PRIu64, ip->i_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR);
break;
case S_IFREG:
- sprintf(tmp_name, "lost_file_%llu",
- (unsigned long long)ip->i_di.di_num.no_addr);
+ sprintf(tmp_name, "lost_file_%"PRIu64, ip->i_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_REG : DT_REG);
break;
case S_IFLNK:
- sprintf(tmp_name, "lost_link_%llu",
- (unsigned long long)ip->i_di.di_num.no_addr);
+ sprintf(tmp_name, "lost_link_%"PRIu64, ip->i_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_LNK : DT_LNK);
break;
case S_IFBLK:
- sprintf(tmp_name, "lost_blkdev_%llu",
- (unsigned long long)ip->i_di.di_num.no_addr);
+ sprintf(tmp_name, "lost_blkdev_%"PRIu64, ip->i_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_BLK : DT_BLK);
break;
case S_IFCHR:
- sprintf(tmp_name, "lost_chrdev_%llu",
- (unsigned long long)ip->i_di.di_num.no_addr);
+ sprintf(tmp_name, "lost_chrdev_%"PRIu64, ip->i_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_CHR : DT_CHR);
break;
case S_IFIFO:
- sprintf(tmp_name, "lost_fifo_%llu",
- (unsigned long long)ip->i_di.di_num.no_addr);
+ sprintf(tmp_name, "lost_fifo_%"PRIu64, ip->i_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_FIFO : DT_FIFO);
break;
case S_IFSOCK:
- sprintf(tmp_name, "lost_socket_%llu",
- (unsigned long long)ip->i_di.di_num.no_addr);
+ sprintf(tmp_name, "lost_socket_%"PRIu64, ip->i_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_SOCK : DT_SOCK);
break;
default:
- sprintf(tmp_name, "lost_%llu",
- (unsigned long long)ip->i_di.di_num.no_addr);
+ sprintf(tmp_name, "lost_%"PRIu64, ip->i_addr);
inode_type = (sdp->gfs1 ? GFS_FILE_REG : DT_REG);
break;
}
- err = dir_add(lf_dip, tmp_name, strlen(tmp_name), &(ip->i_di.di_num),
- inode_type);
+ no.no_addr = ip->i_addr;
+ no.no_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"),
tmp_name, strerror(errno));
@@ -245,15 +239,16 @@ int add_inode_to_lf(struct gfs2_inode *ip){
}
/* This inode is linked from lost+found */
- incr_link_count(ip->i_di.di_num, lf_dip, _("from lost+found"));
+ 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)
- incr_link_count(lf_dip->i_di.di_num, ip, _("to lost+found"));
-
- log_notice( _("Added inode #%llu (0x%llx) to lost+found\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
- gfs2_dinode_out(&lf_dip->i_di, lf_dip->i_bh->b_data);
+ if (mode == S_IFDIR) {
+ no.no_addr = lf_dip->i_addr;
+ no.no_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"),
+ ip->i_addr, ip->i_addr);
+ lgfs2_dinode_out(lf_dip, lf_dip->i_bh->b_data);
bwrite(lf_dip->i_bh);
return 0;
}
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index d424e075..e322b395 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -174,16 +174,15 @@ static int check_statfs(struct gfs2_sbd *sdp)
uint64_t sc_dinodes;
int count;
- if (sdp->gfs1 && !sdp->md.statfs->i_di.di_size) {
+ if (sdp->gfs1 && !sdp->md.statfs->i_size) {
log_info("This GFS1 file system is not using fast_statfs.\n");
return 0;
}
/* Read the current statfs values */
- count = gfs2_readi(sdp->md.statfs, &sc, 0,
- sdp->md.statfs->i_di.di_size);
+ count = gfs2_readi(sdp->md.statfs, &sc, 0, sdp->md.statfs->i_size);
if (count != sizeof(struct gfs2_statfs_change)) {
log_err(_("Failed to read statfs values (%d of %"PRIu64" read)\n"),
- count, (uint64_t)sdp->md.statfs->i_di.di_size);
+ count, sdp->md.statfs->i_size);
return FSCK_ERROR;
}
sc_total = be64_to_cpu(sc.sc_total);
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 8b721015..991f1175 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -178,9 +178,9 @@ 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_di.di_num.no_addr == prev_ino_addr) &&
+ if ((ip->i_addr == prev_ino_addr) &&
(mark == prev_mark) && caller == prev_caller) {
- log_info("(0x%llx) ", (unsigned long long)bblock);
+ log_info("(0x%"PRIx64") ", bblock);
prevcount++;
if (prevcount > 10) {
log_info("\n");
@@ -188,30 +188,23 @@ 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_di.di_num.no_addr == bblock) {
+ } else if (ip->i_addr == bblock) {
if (prevcount) {
log_info("\n");
prevcount = 0;
}
- printf( _("(%s:%d) %s inode found at block "
- "(0x%llx): marking as '%s'\n"), caller, fline,
- btype,
- (unsigned long long)ip->i_di.di_num.no_addr,
- block_type_string(mark));
-
+ printf(_("(%s:%d) %s inode found at block (0x%"PRIx64"): marking as '%s'\n"),
+ caller, fline, btype, ip->i_addr, block_type_string(mark));
} else {
if (prevcount) {
log_info("\n");
prevcount = 0;
}
- printf( _("(%s:%d) inode (0x%llx) references %s block"
- " (0x%llx): marking as '%s'\n"),
- caller, fline,
- (unsigned long long)ip->i_di.di_num.no_addr,
- btype, (unsigned long long)bblock,
- block_type_string(mark));
+ 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));
}
- prev_ino_addr = ip->i_di.di_num.no_addr;
+ prev_ino_addr = ip->i_addr;
prev_mark = mark;
prev_caller = caller;
}
@@ -243,24 +236,24 @@ struct gfs2_inode *fsck_system_inode(struct gfs2_sbd *sdp, uint64_t block)
{
int j;
- if (lf_dip && lf_dip->i_di.di_num.no_addr == block)
+ if (lf_dip && lf_dip->i_addr == block)
return lf_dip;
if (!sdp->gfs1)
return is_system_inode(sdp, block);
- if (sdp->md.statfs && block == sdp->md.statfs->i_di.di_num.no_addr)
+ if (sdp->md.statfs && block == sdp->md.statfs->i_addr)
return sdp->md.statfs;
- if (sdp->md.jiinode && block == sdp->md.jiinode->i_di.di_num.no_addr)
+ if (sdp->md.jiinode && block == sdp->md.jiinode->i_addr)
return sdp->md.jiinode;
- if (sdp->md.riinode && block == sdp->md.riinode->i_di.di_num.no_addr)
+ if (sdp->md.riinode && block == sdp->md.riinode->i_addr)
return sdp->md.riinode;
- if (sdp->md.qinode && block == sdp->md.qinode->i_di.di_num.no_addr)
+ if (sdp->md.qinode && block == sdp->md.qinode->i_addr)
return sdp->md.qinode;
- if (sdp->md.rooti && block == sdp->md.rooti->i_di.di_num.no_addr)
+ if (sdp->md.rooti && block == sdp->md.rooti->i_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_di.di_num.no_addr)
+ block == sdp->md.journal[j]->i_addr)
return sdp->md.journal[j];
return NULL;
}
@@ -307,7 +300,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_di.di_num.no_addr);
+ sysip = fsck_system_inode(ip->i_sbd, ip->i_addr);
if (!sysip)
inode_put(ip_in);
}
@@ -430,14 +423,11 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
if (de.de_rec_len < sizeof(struct gfs2_dirent) +
de.de_name_len ||
(de.de_inum.no_formal_ino && !de.de_name_len && !first)) {
- log_err( _("Directory block %llu (0x%llx"
- "), entry %d of directory %llu "
- "(0x%llx) is corrupt.\n"),
- (unsigned long long)bh->b_blocknr,
- (unsigned long long)bh->b_blocknr,
- (*count) + 1,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ 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,
first)) {
@@ -467,13 +457,11 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
log_debug( _("First dirent is a sentinel (place holder).\n"));
first = 0;
} else {
- log_err( _("Directory entry with inode number of "
- "zero in leaf %llu (0x%llx) of "
- "directory %llu (0x%llx)!\n"),
- (unsigned long long)bh->b_blocknr,
- (unsigned long long)bh->b_blocknr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err(_("Directory entry with inode number of "
+ "zero in leaf %"PRIu64" (0x%"PRIx64") of "
+ "directory %"PRIu64" (0x%"PRIx64")!\n"),
+ bh->b_blocknr, bh->b_blocknr,
+ ip->i_addr, ip->i_addr);
if (query(_("Attempt to remove it? (y/n) "))) {
dirblk_truncate(ip, prev, bh);
log_err(_("The corrupt directory "
@@ -509,13 +497,10 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
}
if ((char *)dent + de.de_rec_len >= bh_end){
- log_debug( _("Last entry processed for %lld->%lld "
- "(0x%llx->0x%llx), di_blocks=%llu.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)bh->b_blocknr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)bh->b_blocknr,
- (unsigned long long)ip->i_di.di_blocks);
+ 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,
+ bh->b_blocknr, ip->i_blocks);
break;
}
@@ -542,16 +527,13 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
uint32_t count = 0;
struct gfs2_sbd *sdp = ip->i_sbd;
const char *msg;
- int di_depth = ip->i_di.di_depth;
+ int di_depth = ip->i_depth;
/* Make sure the block number is in range. */
if (!valid_block_ip(ip, *leaf_no)) {
- log_err( _("Leaf block #%llu (0x%llx) is out of range for "
- "directory #%llu (0x%llx) at index %d (0x%x).\n"),
- (unsigned long long)*leaf_no,
- (unsigned long long)*leaf_no,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
+ 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,
lindex, lindex);
msg = _("that is out of range");
goto bad_leaf;
@@ -595,17 +577,14 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
/* Make sure it's really a leaf. */
if (leaf->lf_header.mh_type != GFS2_METATYPE_LF) {
- log_err( _("Inode %llu (0x%llx) points to bad leaf %llu"
- " (0x%llx).\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)*leaf_no,
- (unsigned long long)*leaf_no);
+ log_err(_("Inode %"PRIu64" (0x%"PRIx64") points to bad leaf %"PRIu64
+ " (0x%"PRIx64").\n"),
+ ip->i_addr, ip->i_addr, *leaf_no, *leaf_no);
msg = _("that is not a leaf");
goto bad_leaf;
}
- if (pass->check_dentry && is_dir(&ip->i_di, sdp->gfs1)) {
+ if (pass->check_dentry && is_dir(ip, sdp->gfs1)) {
error = check_entries(ip, lbh, DIR_EXHASH, &count, lindex,
pass);
@@ -626,14 +605,11 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
lbh = bread(sdp, *leaf_no);
gfs2_leaf_in(leaf, lbh->b_data);
if (count != leaf->lf_entries) {
- log_err( _("Leaf %llu (0x%llx) entry count in "
- "directory %llu (0x%llx) does not match "
+ 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"),
- (unsigned long long)*leaf_no,
- (unsigned long long)*leaf_no,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- leaf->lf_entries, count);
+ *leaf_no, *leaf_no, ip->i_addr, ip->i_addr,
+ leaf->lf_entries, count);
if (query( _("Update leaf entry count? (y/n) "))) {
leaf->lf_entries = count;
gfs2_leaf_out(leaf, lbh->b_data);
@@ -645,15 +621,12 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
}
}
out:
- if (di_depth < ip->i_di.di_depth) {
- log_debug(_("Depth of directory %lld (0x%llx) changed from "
+ 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"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- di_depth, ip->i_di.di_depth,
- *ref_count,
- (*ref_count) << (ip->i_di.di_depth - di_depth));
- (*ref_count) <<= (ip->i_di.di_depth - di_depth);
+ ip->i_addr, ip->i_addr, di_depth, ip->i_depth,
+ *ref_count, (*ref_count) << (ip->i_depth - di_depth));
+ (*ref_count) <<= (ip->i_depth - di_depth);
}
brelse(lbh);
if (error < 0)
@@ -670,15 +643,12 @@ bad_leaf:
return fix;
}
- if (di_depth < ip->i_di.di_depth) {
- log_debug(_("Depth of directory %lld (0x%llx) changed from "
+ 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"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- di_depth, ip->i_di.di_depth,
- *ref_count,
- (*ref_count) << (ip->i_di.di_depth - di_depth));
- (*ref_count) <<= (ip->i_di.di_depth - di_depth);
+ ip->i_addr, ip->i_addr, di_depth, ip->i_depth,
+ *ref_count, (*ref_count) << (ip->i_depth - di_depth));
+ (*ref_count) <<= (ip->i_depth - di_depth);
}
return 1;
}
@@ -718,7 +688,7 @@ static void dir_leaf_reada(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize)
int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
{
int error = 0;
- unsigned hsize = (1 << ip->i_di.di_depth);
+ unsigned hsize = (1 << ip->i_depth);
uint64_t leaf_no, leaf_next;
uint64_t first_ok_leaf, orig_di_blocks;
struct gfs2_buffer_head *lbh;
@@ -734,9 +704,9 @@ int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
return -1;
}
tbl_valid = 1;
- orig_di_depth = ip->i_di.di_depth;
- orig_di_height = ip->i_di.di_height;
- orig_di_blocks = ip->i_di.di_blocks;
+ orig_di_depth = ip->i_depth;
+ orig_di_height = ip->i_height;
+ orig_di_blocks = ip->i_blocks;
/* Turn off system readahead */
posix_fadvise(sdp->device_fd, 0, 0, POSIX_FADV_RANDOM);
@@ -780,10 +750,8 @@ int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
}
}
if (first_ok_leaf == -1) { /* no valid leaf found */
- log_err( _("Directory #%llu (0x%llx) has no valid leaf "
- "blocks\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err(_("Directory #%"PRIu64" (0x%"PRIx64") has no valid leaf blocks\n"),
+ ip->i_addr, ip->i_addr);
free(tbl);
posix_fadvise(sdp->device_fd, 0, 0, POSIX_FADV_NORMAL);
return 1;
@@ -798,17 +766,16 @@ int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
if (!tbl_valid) {
free(tbl);
- log_debug(_("Re-reading 0x%llx hash table.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_debug(_("Re-reading 0x%"PRIx64" hash table.\n"), ip->i_addr);
tbl = get_dir_hash(ip);
if (tbl == NULL) {
perror("get_dir_hash");
return -1;
}
tbl_valid = 1;
- orig_di_depth = ip->i_di.di_depth;
- orig_di_height = ip->i_di.di_height;
- orig_di_blocks = ip->i_di.di_blocks;
+ orig_di_depth = ip->i_depth;
+ orig_di_height = ip->i_height;
+ orig_di_blocks = ip->i_blocks;
}
leaf_no = be64_to_cpu(tbl[lindex]);
@@ -853,27 +820,21 @@ int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
log_debug( _("Leaf chain #%d (0x%llx) detected.\n"),
chained_leaf, (unsigned long long)leaf_no);
} while (1); /* while we have chained leaf blocks */
- if (orig_di_depth != ip->i_di.di_depth) {
- log_debug(_("Depth of 0x%llx changed from %d to %d\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- orig_di_depth, ip->i_di.di_depth);
+ 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);
tbl_valid = 0;
- lindex <<= (ip->i_di.di_depth - orig_di_depth);
- hsize = (1 << ip->i_di.di_depth);
+ lindex <<= (ip->i_depth - orig_di_depth);
+ hsize = (1 << ip->i_depth);
}
- if (orig_di_height != ip->i_di.di_height) {
- log_debug(_("Height of 0x%llx changed from %d to "
- "%d\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- orig_di_height, ip->i_di.di_height);
+ 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);
tbl_valid = 0;
}
- if (orig_di_blocks != ip->i_di.di_blocks) {
- log_debug(_("Block count of 0x%llx changed from %llu "
- "to %llu\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)orig_di_blocks,
- (unsigned long long)ip->i_di.di_blocks);
+ 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);
tbl_valid = 0;
}
lindex += ref_count;
@@ -967,12 +928,9 @@ static int check_leaf_eattr(struct gfs2_inode *ip, uint64_t block,
if (pass->check_eattr_leaf) {
int error = 0;
- log_debug( _("Checking EA leaf block #%llu (0x%llx) for "
- "inode #%llu (0x%llx).\n"),
- (unsigned long long)block,
- (unsigned long long)block,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_debug(_("Checking EA leaf block #%"PRIu64" (0x%"PRIx64") for "
+ "inode #%"PRIu64" (0x%"PRIx64").\n"),
+ block, block, ip->i_addr, ip->i_addr);
error = pass->check_eattr_leaf(ip, block, parent, &bh,
pass->private);
@@ -1011,7 +969,7 @@ static int check_indirect_eattr(struct gfs2_inode *ip, uint64_t indirect,
uint64_t block;
struct gfs2_sbd *sdp = ip->i_sbd;
int first_ea_is_bad = 0;
- uint64_t di_eattr_save = ip->i_di.di_eattr;
+ uint64_t di_eattr_save = ip->i_eattr;
uint64_t offset = ip->i_sbd->gfs1 ? sizeof(struct gfs_indirect) : sizeof(struct gfs2_meta_header);
int leaf_pointers = 0, leaf_pointer_errors = 0;
@@ -1064,7 +1022,7 @@ static int check_indirect_eattr(struct gfs2_inode *ip, uint64_t indirect,
check_leaf_eattr to delete all eattrs after the bad
one. So we want: GGGG when we finish. To do that,
we set di_eattr to 0 temporarily. */
- ip->i_di.di_eattr = 0;
+ ip->i_eattr = 0;
bmodified(ip->i_bh);
}
ea_leaf_ptr++;
@@ -1072,7 +1030,7 @@ static int check_indirect_eattr(struct gfs2_inode *ip, uint64_t indirect,
/* If we temporarily nuked the ea block to prevent checking past
a corrupt ea leaf, we need to restore the saved di_eattr block. */
if (di_eattr_save != 0)
- ip->i_di.di_eattr = di_eattr_save;
+ ip->i_eattr = di_eattr_save;
if (pass->finish_eattr_indir) {
if (!first_ea_is_bad) {
pass->finish_eattr_indir(ip, leaf_pointers,
@@ -1100,24 +1058,20 @@ int check_inode_eattr(struct gfs2_inode *ip, struct metawalk_fxns *pass)
int error = 0;
struct gfs2_buffer_head *indirect_buf = NULL;
- if (!ip->i_di.di_eattr)
+ if (!ip->i_eattr)
return 0;
- if (ip->i_di.di_flags & GFS2_DIF_EA_INDIRECT){
+ if (ip->i_flags & GFS2_DIF_EA_INDIRECT){
if (!pass->check_eattr_indir)
return 0;
- log_debug( _("Checking EA indirect block #%llu (0x%llx) for "
- "inode #%llu (0x%llx)..\n"),
- (unsigned long long)ip->i_di.di_eattr,
- (unsigned long long)ip->i_di.di_eattr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
- error = pass->check_eattr_indir(ip, ip->i_di.di_eattr,
- ip->i_di.di_num.no_addr,
+ 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,
&indirect_buf, pass->private);
if (!error) {
- error = check_indirect_eattr(ip, ip->i_di.di_eattr,
+ error = check_indirect_eattr(ip, ip->i_eattr,
indirect_buf, pass);
if (error)
stack;
@@ -1126,8 +1080,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_di.di_eattr,
- ip->i_di.di_num.no_addr, pass);
+ error = check_leaf_eattr(ip, ip->i_eattr, ip->i_addr, pass);
if (error)
stack;
@@ -1139,7 +1092,7 @@ int check_inode_eattr(struct gfs2_inode *ip, struct metawalk_fxns *pass)
*/
static void free_metalist(struct gfs2_inode *ip, osi_list_t *mlp)
{
- unsigned int height = ip->i_di.di_height;
+ unsigned int height = ip->i_height;
unsigned int i;
struct gfs2_buffer_head *nbh;
@@ -1165,7 +1118,7 @@ static void file_ra(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
uint64_t *p, sblock = 0, block;
int extlen = 0;
- if (h + 2 == ip->i_di.di_height) {
+ if (h + 2 == ip->i_height) {
p = (uint64_t *)(bh->b_data + head_size);
if (*p && *(p + 1)) {
sblock = be64_to_cpu(*p);
@@ -1272,7 +1225,7 @@ static int do_check_metalist(struct iptr iptr, int height, struct gfs2_buffer_he
static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
struct metawalk_fxns *pass)
{
- uint32_t height = ip->i_di.di_height;
+ uint32_t height = ip->i_height;
struct gfs2_buffer_head *metabh = ip->i_bh;
osi_list_t *prev_list, *cur_list, *tmp;
struct iptr iptr = { .ipt_ip = ip, 0};
@@ -1288,7 +1241,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
because it checks everything through the hash table using
"depth" field calculations. However, we still have to check the
indirect blocks, even if the height == 1. */
- if (is_dir(&ip->i_di, ip->i_sbd->gfs1))
+ if (is_dir(ip, ip->i_sbd->gfs1))
height++;
/* if (<there are no indirect blocks to check>) */
@@ -1296,8 +1249,8 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
return META_IS_GOOD;
for (h = 1; h < height; h++) {
if (h > 1) {
- if (is_dir(&ip->i_di, ip->i_sbd->gfs1) &&
- h == ip->i_di.di_height + 1)
+ if (is_dir(ip, ip->i_sbd->gfs1) &&
+ h == ip->i_height + 1)
iblk_type = GFS2_METATYPE_JD;
else
iblk_type = GFS2_METATYPE_IN;
@@ -1454,9 +1407,8 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
uint64_t metablock = bh->b_blocknr;
/* If there isn't much pointer corruption check the pointers */
- log_debug("Processing data blocks for inode 0x%llx, metadata block 0x%llx.\n",
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)metablock);
+ log_debug("Processing data blocks for inode 0x%"PRIx64", metadata block 0x%"PRIx64".\n",
+ ip->i_addr, metablock);
for (ptr = ptr_start ; ptr < ptr_end && !fsck_abort; ptr++) {
if (!*ptr)
continue;
@@ -1556,7 +1508,7 @@ static unsigned int should_check(struct gfs2_buffer_head *bh, unsigned int heigh
*/
int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
{
- unsigned int height = ip->i_di.di_height;
+ unsigned int height = ip->i_height;
osi_list_t *metalist = alloca((height + 1) * sizeof(*metalist));
osi_list_t *list, *tmp;
struct gfs2_buffer_head *bh;
@@ -1567,7 +1519,7 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
struct error_block error_blk = {0, 0, 0};
int hit_error_blk = 0;
- if (!height && !is_dir(&ip->i_di, ip->i_sbd->gfs1))
+ if (!height && !is_dir(ip, ip->i_sbd->gfs1))
return 0;
/* metalist has one extra element for directories (see build_and_check_metalist). */
@@ -1585,8 +1537,8 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
/* For directories, we've already checked the "data" blocks which
* comprise the directory hash table, so we perform the directory
* checks and exit. */
- if (is_dir(&ip->i_di, ip->i_sbd->gfs1)) {
- if (!(ip->i_di.di_flags & GFS2_DIF_EXHASH))
+ if (is_dir(ip, ip->i_sbd->gfs1)) {
+ if (!(ip->i_flags & GFS2_DIF_EXHASH))
goto out;
/* check validity of leaf blocks and leaf chains */
error = check_leaf_blks(ip, pass);
@@ -1597,7 +1549,7 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
/* check data blocks */
list = &metalist[height - 1];
- if (ip->i_di.di_blocks > COMFORTABLE_BLKS)
+ if (ip->i_blocks > COMFORTABLE_BLKS)
last_reported_fblock = -10000000;
for (tmp = list->next; !error && tmp != list; tmp = tmp->next) {
@@ -1612,30 +1564,24 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
if (pass->check_data)
error = metawalk_check_data(ip, pass, bh, height,
&blks_checked, &error_blk);
- if (pass->big_file_msg && ip->i_di.di_blocks > COMFORTABLE_BLKS)
+ if (pass->big_file_msg && ip->i_blocks > COMFORTABLE_BLKS)
pass->big_file_msg(ip, blks_checked);
}
- if (pass->big_file_msg && ip->i_di.di_blocks > COMFORTABLE_BLKS) {
- log_notice( _("\rLarge file at %lld (0x%llx) - 100 percent "
+ if (pass->big_file_msg && ip->i_blocks > COMFORTABLE_BLKS) {
+ log_notice( _("\rLarge file at %"PRIu64" (0x%"PRIx64") - 100 percent "
"complete. "
"\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ ip->i_addr, ip->i_addr);
fflush(stdout);
}
undo_metalist:
if (!error)
goto out;
- log_err( _("Error: inode %llu (0x%llx) had unrecoverable errors at "
- "metadata block %lld (0x%llx), offset %d (0x%x), block "
- "%lld (0x%llx).\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)error_blk.metablk,
- (unsigned long long)error_blk.metablk,
- error_blk.metaoff, error_blk.metaoff,
- (unsigned long long)error_blk.errblk,
- (unsigned long long)error_blk.errblk);
+ 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,
+ error_blk.metaoff, error_blk.metaoff, error_blk.errblk, error_blk.errblk);
if (!query( _("Remove the invalid inode? (y/n) "))) {
free_metalist(ip, metalist);
log_err(_("Invalid inode not deleted.\n"));
@@ -1668,10 +1614,9 @@ undo_metalist:
hit_error_blk = 1;
log_err("Reached the error "
"block undoing work "
- "for inode %lld "
- "(0x%llx).\n",
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ "for inode %"PRIu64" "
+ "(0x%"PRIx64").\n",
+ ip->i_addr, ip->i_addr);
rc = 0;
}
}
@@ -1688,8 +1633,7 @@ undo_metalist:
to undo. */
delete_all_dups(ip);
/* Set the dinode as "bad" so it gets deleted */
- fsck_bitmap_set(ip, ip->i_di.di_num.no_addr, "corrupt",
- GFS2_BLKST_FREE);
+ fsck_bitmap_set(ip, ip->i_addr, "corrupt", GFS2_BLKST_FREE);
log_err(_("The corrupt inode was invalidated.\n"));
out:
free_metalist(ip, metalist);
@@ -1716,7 +1660,7 @@ int check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip, struct metawalk_fxns
{
int error = 0;
- if (ip->i_di.di_flags & GFS2_DIF_EXHASH)
+ if (ip->i_flags & GFS2_DIF_EXHASH)
error = check_leaf_blks(ip, pass);
else
error = check_linear_dir(ip, ip->i_bh, pass);
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 0cd9b274..3454fd56 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -134,12 +134,8 @@ static int pass1_repair_leaf(struct gfs2_inode *ip, uint64_t *leaf_no,
char *padbuf;
int pad_size, i;
- log_err( _("Directory Inode %llu (0x%llx) points to leaf %llu"
- " (0x%llx) %s.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)*leaf_no,
- (unsigned long long)*leaf_no, msg);
+ 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);
if (!query( _("Attempt to patch around it? (y/n) "))) {
log_err( _("Bad leaf left in place.\n"));
goto out;
@@ -152,19 +148,16 @@ static int pass1_repair_leaf(struct gfs2_inode *ip, uint64_t *leaf_no,
cpyptr++;
}
pad_size = ref_count * sizeof(uint64_t);
- log_err(_("Writing zeros to the hash table of directory %lld "
- "(0x%llx) at index: 0x%x for 0x%x pointers.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr, lindex,
- ref_count);
+ 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);
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 %llu (0x%llx) patched.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err(_("Directory Inode %"PRIu64" (0x%"PRIx64") patched.\n"),
+ ip->i_addr, ip->i_addr);
out:
*leaf_no = 0;
@@ -207,12 +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_di.di_num.no_addr,
- _("itself"), GFS2_BLKST_UNLINKED);
- log_err( _("Bad indirect block pointer (invalid or out of "
- "range) found in system inode %lld (0x%llx).\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ fsck_blockmap_set(ip, ip->i_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);
*is_valid = 0;
return META_IS_GOOD;
}
@@ -255,11 +246,9 @@ static int resuscitate_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
else
strncpy(tmp_name, filename, sizeof(tmp_name) - 1);
if (!valid_block_ip(ip, block)) {
- log_err( _("Block # referenced by system directory entry %s "
- "in inode %lld (0x%llx) is invalid or out of range;"
- " ignored.\n"),
- tmp_name, (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ 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);
return 0;
}
/* If this is a system dinode, we'll handle it later in
@@ -296,14 +285,11 @@ static int p1check_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
bc->indir_count++;
q = block_type(bl, block);
if (q != GFS2_BLKST_FREE) {
- log_err( _("Found duplicate block #%llu (0x%llx) referenced "
- "as a directory leaf in dinode "
- "%llu (0x%llx) - was marked %d (%s)\n"),
- (unsigned long long)block,
- (unsigned long long)block,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr, q,
- block_type_string(q));
+ 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_type_string(q));
add_duplicate_ref(ip, block, REF_AS_META, 0, INODE_VALID);
if (q == (ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE :
GFS2_BLKST_USED))
@@ -337,16 +323,15 @@ 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_di.di_num.no_addr,
+ fsck_blockmap_set(ip, ip->i_addr,
_("bad block referencing"), GFS2_BLKST_UNLINKED);
- log_debug( _("Bad indirect block (invalid/out of range) "
- "found in inode %lld (0x%llx).\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_debug(_("Bad indirect block (invalid/out of range) "
+ "found in inode %"PRIu64" (0x%"PRIx64").\n"),
+ ip->i_addr, ip->i_addr);
return META_SKIP_FURTHER;
}
- if (is_dir(&ip->i_di, ip->i_sbd->gfs1) && h == ip->i_di.di_height) {
+ if (is_dir(ip, ip->i_sbd->gfs1) && h == ip->i_height) {
iblk_type = GFS2_METATYPE_JD;
blktypedesc = _("a directory hash table block");
} else {
@@ -355,13 +340,10 @@ static int pass1_check_metalist(struct iptr iptr, struct gfs2_buffer_head **bh,
}
q = block_type(bl, block);
if (q != GFS2_BLKST_FREE) {
- log_err( _("Found duplicate block #%llu (0x%llx) referenced "
- "as metadata in indirect block for dinode "
- "%llu (0x%llx) - was marked %d (%s)\n"),
- (unsigned long long)block,
- (unsigned long long)block,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr, q,
+ 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_type_string(q));
*was_duplicate = 1;
}
@@ -370,13 +352,10 @@ static int pass1_check_metalist(struct iptr iptr, struct gfs2_buffer_head **bh,
*is_valid = (gfs2_check_meta(nbh->b_data, iblk_type) == 0);
if (!(*is_valid)) {
- log_err( _("Inode %lld (0x%llx) has a bad indirect block "
- "pointer %lld (0x%llx) (points to something "
- "that is not %s).\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)block,
- (unsigned long long)block, blktypedesc);
+ 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);
if (query(_("Zero the indirect block pointer? (y/n) "))){
*iptr_ptr(iptr) = 0;
bmodified(iptr.ipt_bh);
@@ -423,8 +402,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_di.di_num.no_addr,
- _("bad block referencing"), GFS2_BLKST_FREE);
+ fsck_blockmap_set(ip, ip->i_addr, _("bad block referencing"), GFS2_BLKST_FREE);
return 1;
}
@@ -509,12 +487,9 @@ static int blockmap_set_as_data(struct gfs2_inode *ip, uint64_t block)
if (be64_to_cpu(di->di_num.no_addr) != block)
goto out;
- log_err(_("Inode %lld (0x%llx) has a reference to block %lld (0x%llx) "
- "as a data block, but it appears to be a dinode we "
- "haven't checked yet.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)block, (unsigned long long)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);
error = -1;
out:
if (!error)
@@ -531,23 +506,18 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
struct block_count *bc = (struct block_count *) private;
if (!valid_block_ip(ip, block)) {
- log_err( _("inode %lld (0x%llx) has a bad data block pointer "
- "%lld (0x%llx) (invalid or out of range) "),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)block, (unsigned long long)block);
- if (metablock == ip->i_di.di_num.no_addr)
+ 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)
log_err("\n");
else
- log_err(_("from metadata block %llu (0x%llx)\n"),
- (unsigned long long)metablock,
- (unsigned long long)metablock);
+ log_err(_("from metadata block %"PRIu64" (0x%"PRIx64")\n"),
+ metablock, 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_di.di_num.no_addr,
- _("bad (out of range) data"),
- GFS2_BLKST_UNLINKED);
+ fsck_blockmap_set(ip, ip->i_addr, _("bad (out of range) data"), GFS2_BLKST_UNLINKED);
return -1;
}
bc->data_count++; /* keep the count sane anyway */
@@ -556,14 +526,11 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
struct gfs2_buffer_head *bh;
struct gfs2_meta_header mh;
- log_err( _("Found duplicate %s block %llu (0x%llx) "
- "referenced as data by dinode %llu (0x%llx) "),
- block_type_string(q),
- (unsigned long long)block,
- (unsigned long long)block,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
- if (metablock == ip->i_di.di_num.no_addr)
+ 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)
log_err("\n");
else
log_err(_("from metadata block %llu (0x%llx)\n"),
@@ -625,7 +592,7 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
gfs2_special_set(&gfs1_rindex_blks, block);
fsck_blockmap_set(ip, block, "rgrp", GFS2_BLKST_DINODE);
/*gfs2_meta_rgrp);*/
- } else if (ip->i_sbd->gfs1 && ip->i_di.di_flags & GFS2_DIF_JDATA) {
+ } else if (ip->i_sbd->gfs1 && ip->i_flags & GFS2_DIF_JDATA) {
log_info(_("Block %lld (0x%llx) is a GFS1 journaled data "
"block\n"),
(unsigned long long)block, (unsigned long long)block);
@@ -638,17 +605,16 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
static int ask_remove_inode_eattr(struct gfs2_inode *ip,
struct block_count *bc)
{
- if (ip->i_di.di_eattr == 0)
+ if (ip->i_eattr == 0)
return 0; /* eattr was removed prior to this call */
- log_err( _("Inode %lld (0x%llx) has unrecoverable Extended Attribute "
- "errors.\n"), (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err(_("Inode %"PRIu64" (0x%"PRIx64") has unrecoverable Extended Attribute errors.\n"),
+ ip->i_addr, ip->i_addr);
if (query( _("Clear all Extended Attributes from the inode? (y/n) "))){
- undo_reference(ip, ip->i_di.di_eattr, 0, bc);
- ip->i_di.di_eattr = 0;
+ undo_reference(ip, ip->i_eattr, 0, bc);
+ ip->i_eattr = 0;
bc->ea_count = 0;
- ip->i_di.di_blocks = 1 + bc->indir_count + bc->data_count;
- ip->i_di.di_flags &= ~GFS2_DIF_EA_INDIRECT;
+ ip->i_blocks = 1 + bc->indir_count + bc->data_count;
+ ip->i_flags &= ~GFS2_DIF_EA_INDIRECT;
bmodified(ip->i_bh);
log_err( _("Extended attributes were removed.\n"));
} else {
@@ -698,11 +664,8 @@ 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 #%llu (0x%llx): %s"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr, emsg);
- log_err(_(" at block #%lld (0x%llx).\n"),
- (unsigned long long)block, (unsigned long long)block);
+ log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): %s"), ip->i_addr, ip->i_addr, emsg);
+ log_err(_(" at block #%"PRIu64" (0x%"PRIx64").\n"), block, block);
}
static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
@@ -769,25 +732,17 @@ 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 #%llu (0x%llx) with extended "
- "attribute block\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_debug(_("Marking inode #%"PRIu64" (0x%"PRIx64") with extended attribute block\n"),
+ ip->i_addr, ip->i_addr);
if (!leaf_pointer_errors)
return 0;
- log_err( _("Inode %lld (0x%llx) has recoverable indirect "
- "Extended Attribute errors.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err(_("Inode %"PRIu64" (0x%"PRIx64") has recoverable indirect extended attribute errors.\n"),
+ ip->i_addr, ip->i_addr);
if (query( _("Okay to fix the block count for the inode? (y/n) "))) {
- ip->i_di.di_blocks = 1 + bc->indir_count +
- bc->data_count + bc->ea_count;
+ ip->i_blocks = 1 + bc->indir_count + bc->data_count + bc->ea_count;
bmodified(ip->i_bh);
- log_err(_("Block count fixed: 1+%lld+%lld+%lld = %lld.\n"),
- (unsigned long long)bc->indir_count,
- (unsigned long long)bc->data_count,
- (unsigned long long)bc->ea_count,
- (unsigned long long)ip->i_di.di_blocks);
+ log_err(_("Block count fixed: 1+%"PRIu64"+%"PRIu64"+%"PRIu64" = %"PRIu64".\n"),
+ bc->indir_count, bc->data_count, bc->ea_count, ip->i_blocks);
return 1;
}
log_err( _("Block count not fixed.\n"));
@@ -875,18 +830,12 @@ static int check_extended_leaf_eattr(struct gfs2_inode *ip, int i,
int error = 0;
if (!valid_block_ip(ip, el_blk)) {
- log_err( _("Inode #%llu (0x%llx): Extended Attribute block "
- "%llu (0x%llx) has an extended leaf block #%llu "
- "(0x%llx) that is invalid or out of range.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_eattr,
- (unsigned long long)ip->i_di.di_eattr,
- (unsigned long long)el_blk,
- (unsigned long long)el_blk);
- fsck_blockmap_set(ip, ip->i_di.di_eattr,
- _("bad (out of range) Extended Attribute "),
- GFS2_BLKST_UNLINKED);
+ 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);
+ fsck_blockmap_set(ip, ip->i_eattr, _("bad (out of range) Extended Attribute "),
+ GFS2_BLKST_UNLINKED);
error = 1;
} else {
error = check_ealeaf_block(ip, el_blk, GFS2_METATYPE_ED, &bh,
@@ -906,7 +855,7 @@ static int check_extended_leaf_eattr(struct gfs2_inode *ip, int i,
bmodified(leaf_bh);
/* Endianness doesn't matter in this case because it's
a single byte. */
- fsck_blockmap_set(ip, ip->i_di.di_eattr,
+ fsck_blockmap_set(ip, ip->i_eattr,
_("extended attribute"),
sdp->gfs1 ? GFS2_BLKST_DINODE :
GFS2_BLKST_USED);
@@ -925,15 +874,12 @@ static int check_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
void *private)
{
if (!valid_block_ip(ip, block)) {
- log_warn( _("Inode #%llu (0x%llx): Extended Attribute leaf "
- "block #%llu (0x%llx) is invalid or out of "
- "range.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)block, (unsigned long long)block);
- fsck_blockmap_set(ip, ip->i_di.di_eattr,
- _("bad (out of range) Extended "
- "Attribute leaf"), GFS2_BLKST_UNLINKED);
+ 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);
+ fsck_blockmap_set(ip, ip->i_eattr, _("bad (out of range) extended attribute leaf"),
+ GFS2_BLKST_UNLINKED);
return 1;
}
return check_ealeaf_block(ip, block, GFS2_METATYPE_EA, bh, private);
@@ -1087,13 +1033,10 @@ static int mark_block_invalid(struct gfs2_inode *ip, uint64_t block,
if (was_duplicate)
*was_duplicate = 1;
add_duplicate_ref(ip, block, reftype, 0, INODE_INVALID);
- log_info( _("%s block %lld (0x%llx), part of inode "
- "%lld (0x%llx), was previously referenced so "
- "the invalid reference is ignored.\n"),
- btype, (unsigned long long)block,
- (unsigned long long)block,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ 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);
return META_IS_GOOD;
}
fsck_blockmap_set(ip, block, btype, GFS2_BLKST_UNLINKED);
@@ -1181,11 +1124,9 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block,
if (!valid_block_ip(ip, block)) {
(*bad_pointers)++;
- log_info( _("Bad %s block pointer (invalid or out of range "
- "#%ld) found in inode %lld (0x%llx).\n"),
- btypes[btype], *bad_pointers,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ 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);
if ((*bad_pointers) <= BAD_POINTER_TOLERANCE)
return META_IS_GOOD;
else
@@ -1195,19 +1136,15 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block,
q = block_type(bl, block);
if (q != GFS2_BLKST_FREE) {
(*bad_pointers)++;
- log_info( _("Duplicated %s block pointer (violation %ld, block"
- " %lld (0x%llx)) found in inode %lld (0x%llx).\n"),
- btypes[btype], *bad_pointers,
- (unsigned long long)block, (unsigned long long)block,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ 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);
if ((*bad_pointers) <= BAD_POINTER_TOLERANCE)
return META_IS_GOOD;
else {
- log_debug(_("Inode 0x%llx bad pointer tolerance "
- "exceeded: block 0x%llx.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)block);
+ log_debug(_("Inode 0x%"PRIx64" bad pointer tolerance "
+ "exceeded: block 0x%"PRIx64".\n"),
+ ip->i_addr, block);
return META_ERROR; /* Exits check_metatree quicker */
}
}
@@ -1277,13 +1214,14 @@ 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;
uint32_t mode;
const char *ty;
if (ip->i_sbd->gfs1)
mode = gfs_to_gfs2_mode(ip);
else
- mode = ip->i_di.di_mode & S_IFMT;
+ mode = ip->i_mode & S_IFMT;
switch (mode) {
case S_IFDIR:
@@ -1310,8 +1248,10 @@ 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;
if (fsck_blockmap_set(ip, block, ty, GFS2_BLKST_DINODE) ||
- (mode == S_IFDIR && !dirtree_insert(ip->i_di.di_num))) {
+ (mode == S_IFDIR && !dirtree_insert(no))) {
stack;
return -EPERM;
}
@@ -1409,8 +1349,7 @@ static int pass1_check_metatree(struct gfs2_inode *ip,
error = check_metatree(ip, pass);
if (error)
- gfs2_blockmap_set(bl, ip->i_di.di_num.no_addr,
- GFS2_BLKST_FREE);
+ gfs2_blockmap_set(bl, ip->i_addr, GFS2_BLKST_FREE);
return error;
}
@@ -1436,11 +1375,9 @@ static void reprocess_inode(struct gfs2_inode *ip, const char *desc)
int error;
alloc_fxns.private = (void *)desc;
- log_info( _("%s inode %llu (0x%llx) had blocks added; reprocessing "
- "its metadata tree at height=%d.\n"), desc,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- ip->i_di.di_height);
+ 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);
error = pass1_check_metatree(ip, &alloc_fxns);
if (error)
log_err( _("Error %d reprocessing the %s metadata tree.\n"),
@@ -1466,13 +1403,9 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
rangecheck_fxns.private = &bad_pointers;
error = pass1_check_metatree(ip, &rangecheck_fxns);
if (bad_pointers > BAD_POINTER_TOLERANCE) {
- log_err( _("Error: inode %llu (0x%llx) has more than "
- "%d bad pointers.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- BAD_POINTER_TOLERANCE);
- fsck_blockmap_set(ip, ip->i_di.di_num.no_addr,
- _("badly corrupt"), GFS2_BLKST_FREE);
+ 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);
return 0;
}
@@ -1484,8 +1417,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_di.di_num.no_addr,
- _("invalid mode"), GFS2_BLKST_FREE);
+ fsck_blockmap_set(ip, ip->i_addr, _("invalid mode"), GFS2_BLKST_FREE);
return 0;
} else if (error)
goto bad_dinode;
@@ -1494,7 +1426,7 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
goto bad_dinode;
if (lf_dip)
- lf_blks = lf_dip->i_di.di_blocks;
+ lf_blks = lf_dip->i_blocks;
pass1_fxns.private = &bc;
error = pass1_check_metatree(ip, &pass1_fxns);
@@ -1502,7 +1434,7 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
/* Pass1 may have added some blocks to lost+found by virtue of leafs
that were misplaced. If it did, we need to reprocess lost+found
to correctly account for its blocks. */
- if (lf_dip && lf_dip->i_di.di_blocks != lf_blks)
+ if (lf_dip && lf_dip->i_blocks != lf_blks)
reprocess_inode(lf_dip, "lost+found");
/* We there was an error, we return 0 because we want fsck to continue
@@ -1521,9 +1453,8 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
return 0;
}
log_err(_("Clearing the bad Extended Attributes in "
- "inode %lld (0x%llx).\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ "inode %"PRIu64" (0x%"PRIx64").\n"),
+ ip->i_addr, ip->i_addr);
eattr_undo_fxns.private = &bc;
check_inode_eattr(ip, &eattr_undo_fxns);
ask_remove_inode_eattr(ip, &bc);
@@ -1531,33 +1462,22 @@ static int handle_ip(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
}
}
- if (ip->i_di.di_blocks !=
- (1 + bc.indir_count + bc.data_count + bc.ea_count)) {
- log_err( _("Inode #%llu (0x%llx): Ondisk block count (%llu"
- ") does not match what fsck found (%llu)\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_blocks,
- (unsigned long long)1 + bc.indir_count +
- bc.data_count + bc.ea_count);
- log_info( _("inode has: %lld, but fsck counts: Dinode:1 + "
- "indir:%lld + data: %lld + ea: %lld\n"),
- (unsigned long long)ip->i_di.di_blocks,
- (unsigned long long)bc.indir_count,
- (unsigned long long)bc.data_count,
- (unsigned long long)bc.ea_count);
+ 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 +
+ bc.data_count + bc.ea_count);
+ log_info(_("inode has: %"PRIu64", but fsck counts: Dinode:1 + "
+ "indir:%"PRIu64" + data: %"PRIu64" + ea: %"PRIu64"\n"),
+ ip->i_blocks, bc.indir_count, bc.data_count, bc.ea_count);
if (query( _("Fix ondisk block count? (y/n) "))) {
- ip->i_di.di_blocks = 1 + bc.indir_count + bc.data_count +
- bc.ea_count;
+ ip->i_blocks = 1 + bc.indir_count + bc.data_count + bc.ea_count;
bmodified(ip->i_bh);
- log_err( _("Block count for #%llu (0x%llx) fixed\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err(_("Block count for #%"PRIu64" (0x%"PRIx64") fixed\n"),
+ ip->i_addr, ip->i_addr);
} else
- log_err( _("Bad block count for #%llu (0x%llx"
- ") not fixed\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err(_("Bad block count for #%"PRIu64" (0x%"PRIx64") not fixed\n"),
+ ip->i_addr, ip->i_addr);
}
return 0;
@@ -1568,27 +1488,22 @@ bad_dinode:
static void check_i_goal(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
{
- if (sdp->gfs1 || ip->i_di.di_flags & GFS2_DIF_SYSTEM)
+ if (sdp->gfs1 || ip->i_flags & GFS2_DIF_SYSTEM)
return;
- if (ip->i_di.di_goal_meta <= LGFS2_SB_ADDR(sdp) ||
- ip->i_di.di_goal_meta > sdp->fssize) {
- log_err(_("Inode #%llu (0x%llx): Bad allocation goal block "
- "found: %llu (0x%llx)\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_goal_meta,
- (unsigned long long)ip->i_di.di_goal_meta);
- if (query( _("Fix goal block in inode #%llu (0x%llx)? (y/n) "),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr)) {
- ip->i_di.di_goal_meta = ip->i_di.di_num.no_addr;
+ if (ip->i_goal_meta <= LGFS2_SB_ADDR(sdp) ||
+ 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);
+ 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;
bmodified(ip->i_bh);
} else
- log_err(_("Allocation goal block in inode #%lld "
- "(0x%llx) not fixed\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err(_("Allocation goal block in inode #%"PRIu64
+ " (0x%"PRIx64") not fixed\n"),
+ ip->i_addr, ip->i_addr);
}
}
@@ -1605,33 +1520,25 @@ static int handle_di(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
ip = fsck_inode_get(sdp, rgd, bh);
- if (ip->i_di.di_num.no_addr != block) {
- log_err( _("Inode #%llu (0x%llx): Bad inode address found: %llu "
- "(0x%llx)\n"), (unsigned long long)block,
- (unsigned long long)block,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
- if (query( _("Fix address in inode at block #%llu"
- " (0x%llx)? (y/n) "),
- (unsigned long long)block, (unsigned long long)block)) {
- ip->i_di.di_num.no_addr = ip->i_di.di_num.no_formal_ino = block;
+ if (ip->i_addr != block) {
+ log_err(_("Inode #%"PRIu64" (0x%"PRIx64"): Bad inode address found: %"PRIu64
+ " (0x%"PRIx64")\n"),
+ block, block, ip->i_addr, ip->i_addr);
+ if (query(_("Fix address in inode at block #%"PRIu64" (0x%"PRIx64")? (y/n) "),
+ block, block)) {
+ ip->i_addr = ip->i_formal_ino = block;
bmodified(ip->i_bh);
} else
- log_err( _("Address in inode at block #%llu"
- " (0x%llx) not fixed\n"),
- (unsigned long long)block,
- (unsigned long long)block);
- }
- if (sdp->gfs1 && ip->i_di.di_num.no_formal_ino != block) {
- log_err( _("Inode #%llu (0x%llx): GFS1 formal inode number "
- "mismatch: was %llu (0x%llx)\n"),
- (unsigned long long)block, (unsigned long long)block,
- (unsigned long long)ip->i_di.di_num.no_formal_ino,
- (unsigned long long)ip->i_di.di_num.no_formal_ino);
- if (query( _("Fix formal inode number in inode #%llu"
- " (0x%llx)? (y/n) "), (unsigned long long)block,
- (unsigned long long)block)) {
- ip->i_di.di_num.no_formal_ino = block;
+ log_err(_("Address in inode at block #%"PRIu64" (0x%"PRIx64" not fixed\n"),
+ block, block);
+ }
+ if (sdp->gfs1 && ip->i_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);
+ if (query(_("Fix formal inode number in inode #%"PRIu64" (0x%"PRIx64")? (y/n) "),
+ block, block)) {
+ ip->i_formal_ino = block;
bmodified(ip->i_bh);
} else
log_err( _("Inode number in inode at block #%lld "
@@ -1663,7 +1570,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_di.di_num.no_addr;
+ iblock = (*sysinode)->i_addr;
log_info( _("System inode for '%s' is located at block %llu"
" (0x%llx)\n"), filename,
(unsigned long long)iblock,
@@ -1688,16 +1595,20 @@ 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_di.di_num.no_addr,
+ fsck_blockmap_set(*sysinode, (*sysinode)->i_addr,
filename, GFS2_BLKST_DINODE);
ds.q = GFS2_BLKST_DINODE;
- if (isdir)
- dirtree_insert((*sysinode)->i_di.di_num);
+ if (isdir) {
+ struct gfs2_inum no = {
+ .no_addr = (*sysinode)->i_addr,
+ .no_formal_ino = (*sysinode)->i_formal_ino
+ };
+ dirtree_insert(no);
+ }
}
/* Make sure it's marked as a system file/directory */
if (needs_sysbit &&
- !((*sysinode)->i_di.di_flags & GFS2_DIF_SYSTEM)) {
+ !((*sysinode)->i_flags & GFS2_DIF_SYSTEM)) {
log_err( _("System inode %s is missing the 'system' "
"flag. It should be rebuilt.\n"), filename);
if (sysdir && query(_("Delete the corrupt %s system "
@@ -1737,23 +1648,27 @@ static int check_system_inode(struct gfs2_sbd *sdp,
}
if (*sysinode == sdp->md.jiinode)
ji_update(sdp);
- fsck_blockmap_set(*sysinode,
- (*sysinode)->i_di.di_num.no_addr,
+ fsck_blockmap_set(*sysinode, (*sysinode)->i_addr,
filename, GFS2_BLKST_DINODE);
ds.q = GFS2_BLKST_DINODE;
- if (isdir)
- dirtree_insert((*sysinode)->i_di.di_num);
+ if (isdir) {
+ struct gfs2_inum no = {
+ .no_addr = (*sysinode)->i_addr,
+ .no_formal_ino = (*sysinode)->i_formal_ino
+ };
+ dirtree_insert(no);
+ }
} else {
log_err( _("Cannot continue without valid %s inode\n"),
filename);
return -1;
}
}
- if (is_dir(&(*sysinode)->i_di, sdp->gfs1)) {
+ if (is_dir(*sysinode, sdp->gfs1)) {
struct block_count bc = {0};
sysdir_fxns.private = &bc;
- if ((*sysinode)->i_di.di_flags & GFS2_DIF_EXHASH)
+ if ((*sysinode)->i_flags & GFS2_DIF_EXHASH)
pass1_check_metatree(*sysinode, &sysdir_fxns);
else {
err = check_linear_dir(*sysinode, (*sysinode)->i_bh,
@@ -1799,8 +1714,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_di.di_num.no_addr,
+ fsck_blockmap_set(sdp->master_dir, sdp->master_dir->i_addr,
"master", GFS2_BLKST_DINODE);
if (check_system_inode(sdp, &sdp->master_dir, "master",
build_master, 1, NULL, 1)) {
@@ -1810,7 +1724,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_di.di_num.no_addr,
+ fsck_blockmap_set(sdp->md.rooti, sdp->md.rooti->i_addr,
"root", GFS2_BLKST_DINODE);
if (check_system_inode(sdp, &sdp->md.rooti, "root", build_root, 1,
NULL, 0)) {
@@ -1855,17 +1769,22 @@ 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;
/* 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. */
- incr_link_count(sdp->md.statfs->i_di.di_num, NULL,
- _("gfs1 statfs inode"));
- incr_link_count(sdp->md.jiinode->i_di.di_num, NULL,
- _("gfs1 jindex inode"));
- incr_link_count(sdp->md.riinode->i_di.di_num, NULL,
- _("gfs1 rindex inode"));
- incr_link_count(sdp->md.qinode->i_di.di_num, NULL,
- _("gfs1 quota inode"));
+ no.no_addr = sdp->md.statfs->i_addr;
+ no.no_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;
+ 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;
+ 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;
+ incr_link_count(no, NULL, _("gfs1 quota inode"));
return 0;
}
for (sdp->md.journals = 0; sdp->md.journals < journal_count;
@@ -1960,7 +1879,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_di.di_num.no_addr == block)
+ if (is_inode && ip->i_addr == block)
add_duplicate_ref(ip, block, REF_IS_INODE, 0,
INODE_VALID);
else
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index a6f06ade..8d702959 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -328,11 +328,11 @@ static void resolve_dup_references(struct gfs2_sbd *sdp, struct duptree *dt,
because it IS ours, and we need to remove all the
eattr leaf blocks: they do belong to us (except for
the duplicate referenced one, which is handled). */
- if (ip->i_di.di_eattr == dt->block) {
- ip->i_di.di_eattr = 0;
- if (ip->i_di.di_blocks > 0)
- ip->i_di.di_blocks--;
- ip->i_di.di_flags &= ~GFS2_DIF_EA_INDIRECT;
+ if (ip->i_eattr == dt->block) {
+ ip->i_eattr = 0;
+ if (ip->i_blocks > 0)
+ ip->i_blocks--;
+ ip->i_flags &= ~GFS2_DIF_EA_INDIRECT;
bmodified(ip->i_bh);
dup_listent_delete(dt, id);
(dh->ref_inode_count)--;
@@ -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_di.di_num.no_addr,
+ fsck_bitmap_set(ip, ip->i_addr,
_("duplicate referencing bad"),
GFS2_BLKST_FREE);
/* Remove the inode from the inode tree */
- ii = inodetree_find(ip->i_di.di_num.no_addr);
+ ii = inodetree_find(ip->i_addr);
if (ii)
inodetree_delete(ii);
- di = dirtree_find(ip->i_di.di_num.no_addr);
+ di = dirtree_find(ip->i_addr);
if (di)
dirtree_delete(di);
- link1_set(&nlink1map, ip->i_di.di_num.no_addr,
+ link1_set(&nlink1map, ip->i_addr,
0);
/* We delete the dup_handler inode count and
duplicate id BEFORE clearing the metadata,
@@ -422,20 +422,15 @@ static int clone_data(struct gfs2_inode *ip, uint64_t metablock,
return 0;
if (clonet->first) {
- log_debug(_("Inode %lld (0x%llx)'s first reference to "
- "block %lld (0x%llx) is targeted for cloning.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)block,
- (unsigned long long)block);
+ 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);
clonet->first = 0;
return 0;
}
- log_err(_("Error: Inode %lld (0x%llx)'s reference to block %lld "
- "(0x%llx) should be replaced with a clone.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)block, (unsigned long long)block);
+ 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);
if (query( _("Okay to clone the duplicated reference? (y/n) "))) {
error = lgfs2_meta_alloc(ip, &cloneblock);
if (!error) {
@@ -496,16 +491,13 @@ static void clone_dup_ref_in_inode(struct gfs2_inode *ip, struct duptree *dt)
.check_data = clone_data,
};
- log_err(_("There are multiple references to block %lld (0x%llx) in "
- "inode %lld (0x%llx)\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)dt->block, (unsigned long long)dt->block);
+ 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);
error = check_metatree(ip, &pass1b_fxns_clone);
if (error) {
- log_err(_("Error cloning duplicate reference(s) to block %lld "
- "(0x%llx).\n"), (unsigned long long)dt->block,
- (unsigned long long)dt->block);
+ log_err(_("Error cloning duplicate reference(s) to block %"PRIu64
+ " (0x%"PRIx64").\n"), dt->block, dt->block);
}
}
@@ -518,7 +510,7 @@ static int set_ip_bitmap(struct gfs2_inode *ip)
if (ip->i_sbd->gfs1)
mode = gfs_to_gfs2_mode(ip);
else
- mode = ip->i_di.di_mode & S_IFMT;
+ mode = ip->i_mode & S_IFMT;
switch (mode) {
case S_IFDIR:
@@ -590,7 +582,7 @@ static void resolve_last_reference(struct gfs2_sbd *sdp, struct duptree *dt,
fsck_bitmap_set(ip, dt->block, _("reference-repaired data"),
GFS2_BLKST_USED);
} else if (id->reftypecount[REF_AS_META]) {
- if (is_dir(&ip->i_di, sdp->gfs1))
+ if (is_dir(ip, sdp->gfs1))
fsck_bitmap_set(ip, dt->block,
_("reference-repaired leaf"),
sdp->gfs1 ? GFS2_BLKST_DINODE :
@@ -621,9 +613,9 @@ static void resolve_last_reference(struct gfs2_sbd *sdp, struct duptree *dt,
"(y/n) "),
(unsigned long long)id->block_no,
(unsigned long long)id->block_no)) {
- ip->i_di.di_eattr = 0;
- ip->i_di.di_flags &= ~GFS2_DIF_EA_INDIRECT;
- ip->i_di.di_blocks--;
+ ip->i_eattr = 0;
+ ip->i_flags &= ~GFS2_DIF_EA_INDIRECT;
+ ip->i_blocks--;
bmodified(ip->i_bh);
fsck_bitmap_set(ip, dt->block,
_("reference-repaired EA"),
@@ -882,8 +874,8 @@ static int find_block_ref(struct gfs2_sbd *sdp, uint64_t inode)
ip = fsck_load_inode(sdp, inode); /* bread, inode_get */
/* double-check the meta header just to be sure it's metadata */
- if (ip->i_di.di_header.mh_magic != GFS2_MAGIC ||
- ip->i_di.di_header.mh_type != GFS2_METATYPE_DI) {
+ if (ip->i_magic != GFS2_MAGIC ||
+ ip->i_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 e595051d..d5fe61b3 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -92,7 +92,7 @@ static int set_dotdot_dir(struct gfs2_sbd *sdp, uint64_t childblock,
}
/* Special case for root inode because we set it earlier */
if (di->dotdot_parent.no_addr &&
- sdp->md.rooti->i_di.di_num.no_addr != di->dinode.no_addr) {
+ sdp->md.rooti->i_addr != di->dinode.no_addr) {
/* This should never happen */
log_crit( _("Dotdot parent already set for block %llu (0x%llx)"
"-> %llu (0x%llx)\n"),
@@ -199,17 +199,15 @@ 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.no_addr);
- inum = dent_ip->i_di.di_num;
+ inum.no_addr = dent_ip->i_addr;
+ inum.no_formal_ino = dent_ip->i_formal_ino;
fsck_inode_put(&dent_ip);
}
}
- log_err( _("Directory entry '%s' pointing to block %llu (0x%llx) in "
- "directory %llu (0x%llx) has the wrong 'formal' inode "
- "number.\n"), tmp_name, (unsigned long long)entry.no_addr,
- (unsigned long long)entry.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
- log_err( _("The directory entry has %llu (0x%llx) but the inode has "
+ 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,
@@ -225,17 +223,20 @@ 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.no_addr);
error = dir_search(child_ip, "..", 2, NULL, &childs_dotdot);
- if (!error && childs_dotdot.no_addr == ip->i_di.di_num.no_addr) {
+ if (!error && childs_dotdot.no_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;
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);
bmodified(bh);
incr_link_count(entry, ip, _("fixed reference"));
- set_parent_dir(sdp, entry, ip->i_di.di_num);
+ no.no_addr = ip->i_addr;
+ no.no_formal_ino = ip->i_formal_ino;
+ set_parent_dir(sdp, entry, no);
} else {
log_err( _("Directory entry not fixed.\n"));
}
@@ -252,14 +253,14 @@ static int bad_formal_ino(struct gfs2_inode *ip, struct gfs2_dirent *dent,
static int hash_table_index(uint32_t hash, struct gfs2_inode *ip)
{
- return hash >> (32 - ip->i_di.di_depth);
+ return hash >> (32 - ip->i_depth);
}
static int hash_table_max(int lindex, struct gfs2_inode *ip,
struct gfs2_buffer_head *bh)
{
struct gfs2_leaf *leaf = (struct gfs2_leaf *)bh->b_data;
- return (1 << (ip->i_di.di_depth - be16_to_cpu(leaf->lf_depth))) +
+ return (1 << (ip->i_depth - be16_to_cpu(leaf->lf_depth))) +
lindex - 1;
}
@@ -268,7 +269,7 @@ static int check_leaf_depth(struct gfs2_inode *ip, uint64_t leaf_no,
{
struct gfs2_leaf *leaf = (struct gfs2_leaf *)lbh->b_data;
int cur_depth = be16_to_cpu(leaf->lf_depth);
- int exp_count = 1 << (ip->i_di.di_depth - cur_depth);
+ int exp_count = 1 << (ip->i_depth - cur_depth);
int divisor;
int factor, correct_depth;
@@ -281,20 +282,17 @@ static int check_leaf_depth(struct gfs2_inode *ip, uint64_t leaf_no,
factor++;
divisor >>= 1;
}
- if (ip->i_di.di_depth < factor) /* can't be fixed--leaf must be on the
+ if (ip->i_depth < factor) /* can't be fixed--leaf must be on the
wrong dinode. */
return -1;
- correct_depth = ip->i_di.di_depth - factor;
+ correct_depth = ip->i_depth - factor;
if (cur_depth == correct_depth)
return 0;
- log_err(_("Leaf block %llu (0x%llx) in dinode %llu (0x%llx) has the "
- "wrong depth: is %d (length %d), should be %d (length "
- "%d).\n"),
- (unsigned long long)leaf_no, (unsigned long long)leaf_no,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- cur_depth, ref_count, correct_depth, exp_count);
+ 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,
+ 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"));
return 0;
@@ -351,7 +349,7 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
(unsigned long long)planned_leaf);
/* Can't trust lf_depth; we have to count */
dest_ref = 0;
- for (li = 0; li < (1 << ip->i_di.di_depth); li++) {
+ for (li = 0; li < (1 << ip->i_depth); li++) {
if (be64_to_cpu(tbl[li]) == planned_leaf)
dest_ref++;
else if (dest_ref)
@@ -372,26 +370,24 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
return 1; /* nuke the dent upon return */
}
- di_depth = ip->i_di.di_depth;
+ di_depth = ip->i_depth;
if (dir_add(ip, tmp_name, de->de_name_len, &de->de_inum,
de->de_type) == 0) {
log_err(_("The misplaced directory entry was moved to a "
"valid leaf block.\n"));
- if (ip->i_di.di_depth > di_depth) {
+ if (ip->i_depth > di_depth) {
log_err(_("Directory hash table was doubled.\n"));
- hash_index <<= (ip->i_di.di_depth - di_depth);
- (*lindex) <<= (ip->i_di.di_depth - di_depth);
+ hash_index <<= (ip->i_depth - di_depth);
+ (*lindex) <<= (ip->i_depth - di_depth);
}
if (lgfs2_get_leaf_ptr(ip, hash_index, &real_leaf)) {
log_err(_("Could not read leaf %d in dinode %"PRIu64": %s\n"), hash_index,
- (uint64_t)ip->i_di.di_num.no_addr, strerror(errno));
+ ip->i_addr, strerror(errno));
}
if (real_leaf != planned_leaf) {
log_err(_("The planned leaf was split. The new leaf "
- "is: %llu (0x%llx). di_blocks=%llu\n"),
- (unsigned long long)real_leaf,
- (unsigned long long)real_leaf,
- (unsigned long long)ip->i_di.di_blocks);
+ "is: %"PRIu64" (0x%"PRIx64"). di_blocks=%"PRIu64"\n"),
+ real_leaf, real_leaf, ip->i_blocks);
fsck_bitmap_set(ip, real_leaf, _("split leaf"),
sdp->gfs1 ? GFS2_BLKST_DINODE :
GFS2_BLKST_USED);
@@ -411,8 +407,11 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
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)) {
- error = set_parent_dir(sdp, de->de_inum,
- ip->i_di.di_num);
+ struct gfs2_inum no = {
+ .no_addr = ip->i_addr,
+ .no_formal_ino = ip->i_formal_ino
+ };
+ error = set_parent_dir(sdp, de->de_inum, no);
if (error > 0)
/* This is a bit of a kludge, but returning 0
in this case causes the caller to go through
@@ -467,12 +466,10 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
*isdir = 0;
if (!valid_block_ip(ip, entry->no_addr)) {
- log_err( _("Block # referenced by directory entry %s in inode "
- "%lld (0x%llx) is invalid\n"),
- tmp_name, (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
- if (query( _("Clear directory entry to out of range block? "
- "(y/n) "))) {
+ log_err(_("Block # referenced by directory entry %s in inode %"PRIu64
+ " (0x%"PRIx64") is invalid\n"),
+ tmp_name, ip->i_addr, ip->i_addr);
+ if (query( _("Clear directory entry to out of range block? (y/n) "))) {
return 1;
} else {
log_err( _("Directory entry to out of range block remains\n"));
@@ -540,19 +537,14 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
* metadata tree deleted.
*/
if (*q != GFS2_BLKST_DINODE) {
- log_err( _("Directory entry '%s' referencing inode %llu "
- "(0x%llx) in dir inode %llu (0x%llx) block type "
- "%d: %s.\n"), tmp_name,
- (unsigned long long)entry->no_addr,
- (unsigned long long)entry->no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
+ 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,
*q, *q == GFS2_BLKST_FREE ?
_("was previously marked invalid") :
_("was deleted or is not an inode"));
- if (!query( _("Clear directory entry to non-inode block? "
- "(y/n) "))) {
+ if (!query(_("Clear directory entry to non-inode block? (y/n) "))) {
log_err( _("Directory entry to non-inode block remains\n"));
return 0;
}
@@ -579,13 +571,9 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
error = check_file_type(entry->no_addr, de->de_type, *q, sdp->gfs1,
isdir);
if (error < 0) {
- log_err( _("Error: directory entry type is "
- "incompatible with block type at block %lld "
- "(0x%llx) in directory inode %llu (0x%llx).\n"),
- (unsigned long long)entry->no_addr,
- (unsigned long long)entry->no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ 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);
log_err( _("Directory entry type is %d, block type is %d.\n"),
de->de_type, *q);
stack;
@@ -602,7 +590,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_di.di_num.no_addr == entry->no_addr)
+ if (ip->i_addr == entry->no_addr)
entry_ip = ip;
else
entry_ip = fsck_load_inode(sdp, entry->no_addr);
@@ -628,19 +616,13 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
}
if (inum.no_formal_ino != entry->no_formal_ino) {
- log_err( _("Directory entry '%s' pointing to block %llu "
- "(0x%llx) in directory %llu (0x%llx) has the "
- "wrong 'formal' inode number.\n"), tmp_name,
- (unsigned long long)entry->no_addr,
- (unsigned long long)entry->no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_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);
+ 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 %"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);
return 1;
}
/* Check for a special case where a (bad) GFS1 dirent points to what
@@ -652,13 +634,10 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
tbh = bread(sdp, entry->no_addr);
if (gfs2_check_meta(tbh->b_data, GFS2_METATYPE_DI)) { /* not dinode */
- log_err( _("Directory entry '%s' pointing to block "
- "%llu (0x%llx) in directory %llu (0x%llx) "
+ 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,
- (unsigned long long)entry->no_addr,
- (unsigned long long)entry->no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ entry->no_addr, entry->no_addr, ip->i_addr, ip->i_addr);
brelse(tbh);
return 1;
}
@@ -691,12 +670,9 @@ static int dirref_find(struct gfs2_inode *ip, struct gfs2_dirent *dent,
"link.\n");
goto out;
}
- log_err(_("The original reference to inode %lld (0x%llx) from "
- "directory %lld (0x%llx) has the wrong 'formal' inode "
- "number.\n"), (unsigned long long)entry->no_addr,
- (unsigned long long)entry->no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ 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);
memset(fn, 0, sizeof(fn));
if (de->de_name_len < MAX_FILENAME)
strncpy(fn, filename, de->de_name_len);
@@ -712,8 +688,8 @@ 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->no_addr, ip->i_di.di_num.no_addr,
- ip->i_sbd->gfs1, _("bad original reference"));
+ decr_link_count(entry->no_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);
out:
@@ -784,7 +760,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 gfs2_inum entry;
+ struct gfs2_inum entry, no;
struct dir_status *ds = (struct dir_status *) priv;
int error;
struct gfs2_inode *entry_ip = NULL;
@@ -813,22 +789,19 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
goto nuke_dentry;
if (!strcmp(".", tmp_name)) {
- log_debug( _("Found . dentry in directory %lld (0x%llx)\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_debug(_("Found . dentry in directory %"PRIu64" (0x%"PRIx64")\n"),
+ ip->i_addr, ip->i_addr);
if (ds->dotdir) {
- log_err( _("Already found '.' entry in directory %llu"
- " (0x%llx)\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err(_("Already found '.' entry in directory %"PRIu64" (0x%"PRIx64")\n"),
+ ip->i_addr, ip->i_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_di.di_num.no_addr == entry.no_addr)
+ if (ip->i_addr == entry.no_addr)
entry_ip = ip;
else
entry_ip = fsck_load_inode(sdp, entry.no_addr);
@@ -842,24 +815,19 @@ 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_di.di_num.no_addr) {
- log_err( _("'.' entry's value incorrect in directory %llu"
- " (0x%llx). Points to %llu"
- " (0x%llx) when it should point to %llu"
- " (0x%llx).\n"),
- (unsigned long long)entry.no_addr,
- (unsigned long long)entry.no_addr,
- (unsigned long long)entry.no_addr,
- (unsigned long long)entry.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ if (entry.no_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,
+ ip->i_addr, ip->i_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_di.di_num.no_addr == entry.no_addr)
+ if (ip->i_addr == entry.no_addr)
entry_ip = ip;
else
entry_ip = fsck_load_inode(sdp, entry.no_addr);
@@ -873,14 +841,11 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
goto dentry_is_valid;
}
if (!strcmp("..", tmp_name)) {
- log_debug( _("Found '..' dentry in directory %lld (0x%llx)\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_debug(_("Found '..' dentry in directory %"PRIu64" (0x%"PRIx64")\n"),
+ ip->i_addr, ip->i_addr);
if (ds->dotdotdir) {
- log_err( _("Already had a '..' entry in directory %llu"
- "(0x%llx)\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err(_("Already had a '..' entry in directory %"PRIu64" (0x%"PRIx64")\n"),
+ ip->i_addr, ip->i_addr);
if (!query( _("Clear duplicate '..' entry? (y/n) "))) {
log_err( _("Duplicate '..' entry remains\n"));
/* FIXME: Should we continue on here
@@ -889,7 +854,7 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
goto dentry_is_valid;
}
- if (ip->i_di.di_num.no_addr == entry.no_addr)
+ if (ip->i_addr == entry.no_addr)
entry_ip = ip;
else
entry_ip = fsck_load_inode(sdp, entry.no_addr);
@@ -900,15 +865,14 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
goto nuke_dentry;
}
if (!isdir) {
- log_err( _("Found '..' entry in directory %llu (0x%llx) "
+ log_err(_("Found '..' entry in directory %"PRIu64" (0x%"PRIx64") "
"pointing to something that's not a directory"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ ip->i_addr, ip->i_addr);
if (!query( _("Clear bad '..' directory entry? (y/n) "))) {
log_err( _("Bad '..' directory entry remains\n"));
goto dentry_is_valid;
}
- if (ip->i_di.di_num.no_addr == entry.no_addr)
+ if (ip->i_addr == entry.no_addr)
entry_ip = ip;
else
entry_ip = fsck_load_inode(sdp, entry.no_addr);
@@ -923,7 +887,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_di.di_num.no_addr, entry)) {
+ if (set_dotdot_dir(sdp, ip->i_addr, entry)) {
stack;
return -1;
}
@@ -933,7 +897,7 @@ 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_di.di_flags & GFS2_DIF_EXHASH) {
+ if (ip->i_flags & GFS2_DIF_EXHASH) {
hash_index = hash_table_index(de->de_hash, ip);
lindex_max = hash_table_max(*lindex, ip, bh);
if (hash_index < *lindex || hash_index > lindex_max) {
@@ -957,7 +921,9 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
/*log_debug( _("Found plain directory dentry\n"));*/
- error = set_parent_dir(sdp, entry, ip->i_di.di_num);
+ no.no_addr = ip->i_addr;
+ no.no_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,
@@ -1026,10 +992,8 @@ static int write_new_leaf(struct gfs2_inode *dip, int start_lindex,
/* Make sure the number of copies is properly a factor of 2 */
if ((1 << factor) != num_copies) {
log_err(_("Program error: num_copies not a factor of 2.\n"));
- log_err(_("num_copies=%d, dinode = %lld (0x%llx)\n"),
- num_copies,
- (unsigned long long)dip->i_di.di_num.no_addr,
- (unsigned long long)dip->i_di.di_num.no_addr);
+ log_err(_("num_copies=%d, dinode = %"PRIu64" (0x%"PRIx64")\n"),
+ num_copies, dip->i_addr, dip->i_addr);
log_err(_("lindex = %d (0x%x)\n"), start_lindex, start_lindex);
stack;
free(padbuf);
@@ -1050,7 +1014,7 @@ static int write_new_leaf(struct gfs2_inode *dip, int start_lindex,
"pointer at index %d (0x%x).\n"), (unsigned long long)*bn,
(unsigned long long)*bn, num_copies, num_copies,
before_or_after, start_lindex, start_lindex);
- dip->i_di.di_blocks++;
+ dip->i_blocks++;
bmodified(dip->i_bh);
nbh = bget(dip->i_sbd, *bn);
memset(nbh->b_data, 0, dip->i_sbd->bsize);
@@ -1058,7 +1022,7 @@ static int write_new_leaf(struct gfs2_inode *dip, int start_lindex,
leaf->lf_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
leaf->lf_header.mh_type = cpu_to_be32(GFS2_METATYPE_LF);
leaf->lf_header.mh_format = cpu_to_be32(GFS2_FORMAT_LF);
- leaf->lf_depth = cpu_to_be16(dip->i_di.di_depth - factor);
+ leaf->lf_depth = cpu_to_be16(dip->i_depth - factor);
/* initialize the first dirent on the new leaf block */
dent = (struct gfs2_dirent *)(nbh->b_data + sizeof(struct gfs2_leaf));
@@ -1074,10 +1038,9 @@ static int write_new_leaf(struct gfs2_inode *dip, int start_lindex,
cpyptr++;
}
pad_size = num_copies * sizeof(uint64_t);
- log_err(_("Writing to the hash table of directory %lld "
- "(0x%llx) at index: 0x%x for 0x%lx pointers.\n"),
- (unsigned long long)dip->i_di.di_num.no_addr,
- (unsigned long long)dip->i_di.di_num.no_addr,
+ 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,
start_lindex, (unsigned long)pad_size / sizeof(uint64_t));
if (dip->i_sbd->gfs1)
count = gfs1_writei(dip, padbuf, start_lindex *
@@ -1108,11 +1071,9 @@ static void pad_with_leafblks(struct gfs2_inode *ip, uint64_t *tbl,
uint32_t proper_start = lindex;
uint64_t new_leaf_blk;
- log_err(_("Padding inode %llu (0x%llx) hash table at offset %d (0x%x) "
- "for %d pointers.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr, lindex, lindex,
- len);
+ 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);
while (len) {
new_len = 1;
/* Determine the next factor of 2 down from extras. We can't
@@ -1205,6 +1166,7 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
log_err(_("Not relocating corrupt entry "
"\"%s\".\n"), tmp_name);
} else {
+
error = dir_add(lf_dip, filename,
de.de_name_len, &de.de_inum,
de.de_type);
@@ -1220,10 +1182,13 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
_("from lost+found"));
/* If it's a directory, lost+found is
back-linked to it via .. */
- if (isdir)
- incr_link_count(lf_dip->i_di.di_num,
- NULL,
- _("to lost+found"));
+ if (isdir) {
+ struct gfs2_inum no = {
+ .no_addr = lf_dip->i_addr,
+ .no_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,
@@ -1239,7 +1204,7 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
"to lost+found.\n"));
/* Free the lost leaf. */
fsck_bitmap_set(ip, leafno, _("lost leaf"), GFS2_BLKST_FREE);
- ip->i_di.di_blocks--;
+ ip->i_blocks--;
bmodified(ip->i_bh);
/* Now we have to deal with the bad hash table entries pointing to the
misplaced leaf block. But we can't just fill the gap with a single
@@ -1300,12 +1265,8 @@ static int pass2_repair_leaf(struct gfs2_inode *ip, uint64_t *leaf_no,
int new_leaf_blks = 0, error, refs;
uint64_t bn = 0;
- log_err( _("Directory Inode %llu (0x%llx) points to leaf %llu"
- " (0x%llx) %s.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)*leaf_no,
- (unsigned long long)*leaf_no, msg);
+ 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);
if (!query( _("Attempt to patch around it? (y/n) "))) {
log_err( _("Bad leaf left in place.\n"));
goto out;
@@ -1329,9 +1290,8 @@ static int pass2_repair_leaf(struct gfs2_inode *ip, uint64_t *leaf_no,
lindex += refs;
ref_count -= refs;
}
- log_err( _("Directory Inode %llu (0x%llx) repaired.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_err(_("Directory Inode %"PRIu64" (0x%"PRIx64") repaired.\n"),
+ ip->i_addr, ip->i_addr);
out:
*leaf_no = bn;
return new_leaf_blks;
@@ -1390,11 +1350,9 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
uint32_t leaf_proper_start;
*proper_len = len;
- log_err(_("Dinode %llu (0x%llx) has a hash table error at index "
- "0x%x, length 0x%x: leaf block %llu (0x%llx)\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr, lindex, len,
- (unsigned long long)leafblk, (unsigned long long)leafblk);
+ 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);
if (!query( _("Fix the hash table? (y/n) "))) {
log_err(_("Hash table not fixed.\n"));
return 0;
@@ -1410,10 +1368,10 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
lbh = bread(ip->i_sbd, leafblk);
/* If the leaf's depth is out of range for this dinode, it's obviously
attached to the wrong dinode. Move the dirents to lost+found. */
- if (leaf.lf_depth > ip->i_di.di_depth) {
+ if (leaf.lf_depth > ip->i_depth) {
log_err(_("This leaf block's depth (%d) is too big for this "
"dinode's depth (%d)\n"),
- leaf.lf_depth, ip->i_di.di_depth);
+ leaf.lf_depth, ip->i_depth);
error = lost_leaf(ip, tbl, leafblk, len, lindex, lbh);
brelse(lbh);
return error;
@@ -1439,7 +1397,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
}
/* Calculate the proper number of pointers based on the leaf depth. */
- *proper_len = 1 << (ip->i_di.di_depth - leaf.lf_depth);
+ *proper_len = 1 << (ip->i_depth - leaf.lf_depth);
/* Look at the first dirent and check its hash value to see if it's
at the proper starting offset. */
@@ -1474,7 +1432,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
already at its maximum depth. */
if ((leaf_proper_start < proper_start) ||
((*proper_len > len || lindex > leaf_proper_start) &&
- leaf.lf_depth == ip->i_di.di_depth)) {
+ leaf.lf_depth == ip->i_depth)) {
log_err(_("Leaf block should start at 0x%x, but it appears at "
"0x%x in the hash table.\n"), leaf_proper_start,
proper_start);
@@ -1489,7 +1447,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
later than they should, we can split the leaf to give it a smaller
footprint in the hash table. */
if ((*proper_len > len || lindex > leaf_proper_start) &&
- ip->i_di.di_depth > leaf.lf_depth) {
+ ip->i_depth > leaf.lf_depth) {
log_err(_("For depth %d, length %d, the proper start is: "
"0x%x.\n"), factor, len, proper_start);
changes++;
@@ -1497,14 +1455,14 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
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);
- *proper_len = 1 << (ip->i_di.di_depth - leaf.lf_depth);
+ *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,
(unsigned long long)leafblk, len, *proper_len);
if (*proper_len < 0) {
log_err(_("Programming error: proper_len=%d, "
"di_depth = %d, lf_depth = %d.\n"),
- *proper_len, ip->i_di.di_depth, leaf.lf_depth);
+ *proper_len, ip->i_depth, leaf.lf_depth);
exit(FSCK_ERROR);
}
log_err(_("New split-off leaf block was allocated at %lld "
@@ -1583,14 +1541,11 @@ static int check_hash_tbl_dups(struct gfs2_inode *ip, uint64_t *tbl,
if (be64_to_cpu(tbl[l + len2]) != leafblk)
break;
}
- log_err(_("Dinode %llu (0x%llx) has duplicate leaf pointers "
- "to block %llu (0x%llx) at offsets %u (0x%x) "
+ 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"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)leafblk,
- (unsigned long long)leafblk, lindex, lindex, len,
- l, l, len2);
+ ip->i_addr, ip->i_addr, leafblk, leafblk, lindex, lindex,
+ len, l, l, len2);
/* See which set of references is valid: the one passed in
or the duplicate we found. */
@@ -1624,7 +1579,7 @@ static int check_hash_tbl_dups(struct gfs2_inode *ip, uint64_t *tbl,
may have been correct without the duplicates but
pass1 would have counted them and adjusted the
count to include them. So we must subtract them. */
- ip->i_di.di_blocks--;
+ ip->i_blocks--;
bmodified(ip->i_bh);
pad_with_leafblks(ip, tbl, l, len2);
} else {
@@ -1644,7 +1599,7 @@ static int check_hash_tbl_dups(struct gfs2_inode *ip, uint64_t *tbl,
log_err(_("Hash table not fixed.\n"));
return 0;
}
- ip->i_di.di_blocks--;
+ ip->i_blocks--;
bmodified(ip->i_bh);
pad_with_leafblks(ip, tbl, lindex, len);
/* At this point we know both copies are bad, so we
@@ -1732,11 +1687,9 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
if (!valid_block_ip(ip, leafblk)) {
uint64_t new_leafblk;
- log_err(_("Dinode %llu (0x%llx) has bad leaf pointers "
+ log_err(_("Dinode %"PRIu64" (0x%"PRIx64") has bad leaf pointers "
"at offset %d for %d\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- lindex, len);
+ ip->i_addr, ip->i_addr, lindex, len);
if (!query( _("Fix the hash table? (y/n) "))) {
log_err(_("Hash table not fixed.\n"));
lindex += len;
@@ -1795,7 +1748,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
lbh = bread(ip->i_sbd, leafblk);
gfs2_leaf_in(&leaf, lbh->b_data);
if (gfs2_check_meta(lbh->b_data, GFS2_METATYPE_LF) ||
- leaf.lf_depth > ip->i_di.di_depth)
+ leaf.lf_depth > ip->i_depth)
leaf.lf_depth = factor;
brelse(lbh);
changes = fix_hashtable(ip, tbl, hsize, leafblk,
@@ -1820,10 +1773,9 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
if (be64_to_cpu(tbl[i]) == leafblk) /* No problem */
continue;
- log_err(_("Dinode %llu (0x%llx) has a hash table "
+ log_err(_("Dinode %"PRIu64" (0x%"PRIx64") has a hash table "
"inconsistency at index %d (0x%x) for %d\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
+ ip->i_addr, ip->i_addr,
i, i, len);
if (!query( _("Fix the hash table? (y/n) "))) {
log_err(_("Hash table not fixed.\n"));
@@ -1837,7 +1789,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
brelse(lbh);
/* Calculate the expected pointer count based on the
leaf depth. */
- proper_len = 1 << (ip->i_di.di_depth - leaf.lf_depth);
+ proper_len = 1 << (ip->i_depth - leaf.lf_depth);
if (proper_len != len) {
log_debug(_("Length 0x%x is not proper for "
"leaf %llu (0x%llx): 0x%x\n"),
@@ -1940,15 +1892,15 @@ static int check_pernode_for(int x, struct gfs2_inode *pernode, const char *fn,
return 0;
goto build_it;
}
- if (!ip->i_di.di_size)
+ if (!ip->i_size)
valid_size = 0;
- else if (!multiple && ip->i_di.di_size != filelen)
+ else if (!multiple && ip->i_size != filelen)
valid_size = 0;
- else if (multiple && (ip->i_di.di_size % filelen))
+ else if (multiple && (ip->i_size % filelen))
valid_size = 0;
if (!valid_size) {
log_err(_("System file %s has an invalid size. Is %"PRIu64", "
- "should be %llu.\n"), fn, ip->i_di.di_size, filelen);
+ "should be %llu.\n"), fn, ip->i_size, filelen);
if (!query( _("Rebuild the system file? (y/n) ")))
goto out_good;
fsck_inode_put(&ip);
@@ -1980,7 +1932,7 @@ build_it:
log_err(_("Error rebuilding %s.\n"), fn);
return -1;
}
- fsck_bitmap_set(ip, ip->i_di.di_num.no_addr, fn, GFS2_BLKST_DINODE);
+ fsck_bitmap_set(ip, ip->i_addr, fn, GFS2_BLKST_DINODE);
log_err(_("System file %s rebuilt.\n"), fn);
goto out_good;
}
@@ -2002,7 +1954,7 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
return -1;
}
- iblock = sysinode->i_di.di_num.no_addr;
+ iblock = sysinode->i_addr;
ds.q = bitmap_type(sysinode->i_sbd, iblock);
pass2_fxns.private = (void *) &ds;
@@ -2031,8 +1983,12 @@ 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
+ };
log_warn( _("Adding '.' entry\n"));
- error = dir_add(sysinode, ".", 1, &(sysinode->i_di.di_num),
+ error = dir_add(sysinode, ".", 1, &no,
(sysinode->i_sbd->gfs1 ? GFS_FILE_DIR : DT_DIR));
if (error) {
log_err(_("Error adding directory %s: %s\n"), "'.'",
@@ -2040,32 +1996,23 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
return -errno;
}
/* This system inode is linked to itself via '.' */
- incr_link_count(sysinode->i_di.di_num, sysinode,
- "sysinode \".\"");
+ incr_link_count(no, sysinode, "sysinode \".\"");
ds.entry_count++;
} else
log_err( _("The directory was not fixed.\n"));
}
- if (sysinode->i_di.di_entries != ds.entry_count) {
- log_err( _("%s inode %llu (0x%llx"
- "): Entries is %d - should be %d\n"), dirname,
- (unsigned long long)sysinode->i_di.di_num.no_addr,
- (unsigned long long)sysinode->i_di.di_num.no_addr,
- sysinode->i_di.di_entries, ds.entry_count);
- if (query( _("Fix entries for %s inode %llu (0x%llx)? (y/n) "),
- dirname,
- (unsigned long long)sysinode->i_di.di_num.no_addr,
- (unsigned long long)sysinode->i_di.di_num.no_addr)) {
- sysinode->i_di.di_entries = ds.entry_count;
+ 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,
+ ds.entry_count);
+ if (query( _("Fix entries for %s inode %"PRIu64" (0x%"PRIx64")? (y/n) "),
+ dirname, sysinode->i_addr, sysinode->i_addr)) {
+ sysinode->i_entries = ds.entry_count;
bmodified(sysinode->i_bh);
log_warn( _("Entries updated\n"));
} else {
- log_err( _("Entries for inode %llu (0x%llx"
- ") left out of sync\n"),
- (unsigned long long)
- sysinode->i_di.di_num.no_addr,
- (unsigned long long)
- sysinode->i_di.di_num.no_addr);
+ log_err(_("Entries for inode %"PRIu64" (0x%"PRIx64") left out of sync\n"),
+ sysinode->i_addr, sysinode->i_addr);
}
}
error = 0;
@@ -2095,20 +2042,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_di.di_num.no_addr)
+ if (block == sdp->md.rooti->i_addr)
return 1;
if (sdp->gfs1)
return 0;
- if (block == sdp->md.jiinode->i_di.di_num.no_addr ||
- block == sdp->md.pinode->i_di.di_num.no_addr ||
- block == sdp->master_dir->i_di.di_num.no_addr)
+ if (block == sdp->md.jiinode->i_addr ||
+ block == sdp->md.pinode->i_addr ||
+ block == sdp->master_dir->i_addr)
return 1;
return 0;
}
static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
{
- uint64_t dirblk = ip->i_di.di_num.no_addr;
+ uint64_t dirblk = ip->i_addr;
struct dir_status ds = {0};
int error;
@@ -2161,7 +2108,11 @@ 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) "))) {
- error = dir_add(ip, ".", 1, &(ip->i_di.di_num),
+ struct gfs2_inum no = {
+ .no_addr = ip->i_addr,
+ .no_formal_ino = ip->i_formal_ino
+ };
+ error = dir_add(ip, ".", 1, &no,
(sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
if (error) {
log_err(_("Error adding directory %s: %s\n"), "'.'",
@@ -2169,7 +2120,7 @@ static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
return -errno;
}
/* directory links to itself via '.' */
- incr_link_count(ip->i_di.di_num, ip, _("\". (itself)\""));
+ incr_link_count(no, ip, _("\". (itself)\""));
ds.entry_count++;
log_err(_("The directory was fixed.\n"));
} else {
@@ -2177,13 +2128,11 @@ static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
}
}
- if (!fsck_abort && ip->i_di.di_entries != ds.entry_count) {
- log_err(_("Entries is %d - should be %d for inode block %llu (0x%llx)\n"),
- ip->i_di.di_entries, ds.entry_count,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ 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);
if (query(_("Fix the entry count? (y/n) "))) {
- ip->i_di.di_entries = ds.entry_count;
+ ip->i_entries = ds.entry_count;
bmodified(ip->i_bh);
} else {
log_err(_("The entry count was not fixed.\n"));
@@ -2256,8 +2205,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_di.di_num.no_addr)) {
+ if (lf_was_created && (dirblk == lf_dip->i_addr)) {
log_debug(_("Pass2 skipping the new lost+found.\n"));
continue;
}
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index 4b9c54d8..8b8b19bc 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -25,6 +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;
ip = fsck_load_inode(sdp, block);
pip = fsck_load_inode(sdp, newdotdot);
@@ -39,14 +40,16 @@ 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 \"..\""));
- err = dir_add(ip, filename, filename_len, &pip->i_di.di_num,
+ no.no_addr = pip->i_addr;
+ no.no_formal_ino = pip->i_formal_ino;
+ err = dir_add(ip, filename, filename_len, &no,
(sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
if (err) {
log_err(_("Error adding directory %s: %s\n"),
filename, strerror(errno));
exit(FSCK_ERROR);
}
- incr_link_count(pip->i_di.di_num, ip, _("new \"..\""));
+ incr_link_count(no, ip, _("new \"..\""));
fsck_inode_put(&ip);
fsck_inode_put(&pip);
return 0;
@@ -174,38 +177,38 @@ int pass3(struct gfs2_sbd *sdp)
struct gfs2_inode *ip;
int q;
- di = dirtree_find(sdp->md.rooti->i_di.di_num.no_addr);
+ di = dirtree_find(sdp->md.rooti->i_addr);
if (di) {
log_info( _("Marking root inode connected\n"));
di->checked = 1;
}
if (sdp->gfs1) {
- di = dirtree_find(sdp->md.statfs->i_di.di_num.no_addr);
+ di = dirtree_find(sdp->md.statfs->i_addr);
if (di) {
log_info( _("Marking GFS1 statfs file inode "
"connected\n"));
di->checked = 1;
}
- di = dirtree_find(sdp->md.jiinode->i_di.di_num.no_addr);
+ di = dirtree_find(sdp->md.jiinode->i_addr);
if (di) {
log_info( _("Marking GFS1 jindex file inode "
"connected\n"));
di->checked = 1;
}
- di = dirtree_find(sdp->md.riinode->i_di.di_num.no_addr);
+ di = dirtree_find(sdp->md.riinode->i_addr);
if (di) {
log_info( _("Marking GFS1 rindex file inode "
"connected\n"));
di->checked = 1;
}
- di = dirtree_find(sdp->md.qinode->i_di.di_num.no_addr);
+ di = dirtree_find(sdp->md.qinode->i_addr);
if (di) {
log_info( _("Marking GFS1 quota file inode "
"connected\n"));
di->checked = 1;
}
} else {
- di = dirtree_find(sdp->master_dir->i_di.di_num.no_addr);
+ di = dirtree_find(sdp->master_dir->i_addr);
if (di) {
log_info( _("Marking master directory inode "
"connected\n"));
@@ -288,7 +291,7 @@ int pass3(struct gfs2_sbd *sdp)
(unsigned long long)di->dinode.no_addr,
(unsigned long long)di->dinode.no_addr);
/* Don't skip zero size directories with eattrs */
- if (!ip->i_di.di_size && !ip->i_di.di_eattr){
+ if (!ip->i_size && !ip->i_eattr){
log_err( _("Unlinked directory has zero "
"size.\n"));
if (query( _("Remove zero-size unlinked "
@@ -320,7 +323,7 @@ int pass3(struct gfs2_sbd *sdp)
}
if (lf_dip) {
log_debug( _("At end of pass3, lost+found entries is %u\n"),
- lf_dip->i_di.di_entries);
+ lf_dip->i_entries);
}
return FSCK_OK;
}
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index 313ff0fb..42892da1 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -28,18 +28,15 @@ struct metawalk_fxns pass4_fxns_delete = {
* link count */
static int fix_link_count(uint32_t counted_links, struct gfs2_inode *ip)
{
- log_info( _("Fixing inode link count (%d->%d) for %llu (0x%llx) \n"),
- ip->i_di.di_nlink, counted_links,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
- if (ip->i_di.di_nlink == counted_links)
+ log_info(_("Fixing inode link count (%d->%d) for %"PRIu64" (0x%"PRIx64") \n"),
+ ip->i_nlink, counted_links, ip->i_addr, ip->i_addr);
+ if (ip->i_nlink == counted_links)
return 0;
- ip->i_di.di_nlink = counted_links;
+ ip->i_nlink = counted_links;
bmodified(ip->i_bh);
- log_debug( _("Changing inode %llu (0x%llx) to have %u links\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr, counted_links);
+ log_debug(_("Changing inode %"PRIu64" (0x%"PRIx64") to have %u links\n"),
+ ip->i_addr, ip->i_addr, counted_links);
return 0;
}
@@ -102,7 +99,7 @@ static int handle_unlinked(struct gfs2_sbd *sdp, uint64_t no_addr,
/* We don't want to clear zero-size files with eattrs - there might be
relevent info in them. */
- if (!ip->i_di.di_size && !ip->i_di.di_eattr){
+ if (!ip->i_size && !ip->i_eattr){
log_err( _("Unlinked inode has zero size\n"));
if (query(_("Clear zero-size unlinked inode? (y/n) "))) {
fsck_bitmap_set(ip, no_addr, _("unlinked zero-length"),
@@ -164,7 +161,7 @@ static int adjust_lf_links(int lf_addition)
if (!lf_addition)
return 0;
- if (!(lf_di = dirtree_find(lf_dip->i_di.di_num.no_addr))) {
+ if (!(lf_di = dirtree_find(lf_dip->i_addr))) {
log_crit(_("Unable to find lost+found inode in "
"inode_hash!!\n"));
return -1;
@@ -189,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->di_num.no_addr == sdp->md.riinode->i_di.di_num.no_addr) ||
- (ii->di_num.no_addr == sdp->md.qinode->i_di.di_num.no_addr) ||
- (ii->di_num.no_addr == sdp->md.statfs->i_di.di_num.no_addr)))
+ ((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)))
continue;
if (ii->counted_links == 0) {
if (handle_unlinked(sdp, ii->di_num.no_addr,
@@ -225,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.no_addr == sdp->md.jiinode->i_di.di_num.no_addr)
+ di->dinode.no_addr == sdp->md.jiinode->i_addr)
continue;
if (di->counted_links == 0) {
if (handle_unlinked(sdp, di->dinode.no_addr,
@@ -282,7 +279,7 @@ int pass4(struct gfs2_sbd *sdp)
{
if (lf_dip)
log_debug( _("At beginning of pass4, lost+found entries is %u\n"),
- lf_dip->i_di.di_entries);
+ lf_dip->i_entries);
log_info( _("Checking inode reference counts: multi-links.\n"));
if (scan_inode_list(sdp)) {
stack;
@@ -301,6 +298,6 @@ int pass4(struct gfs2_sbd *sdp)
if (lf_dip)
log_debug( _("At end of pass4, lost+found entries is %u\n"),
- lf_dip->i_di.di_entries);
+ lf_dip->i_entries);
return FSCK_OK;
}
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index bf1641e8..316be67c 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -60,10 +60,9 @@ static void find_journaled_rgs(struct gfs2_sbd *sdp)
osi_list_init(&false_rgrps.list);
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%llx.\n"), j,
- (unsigned long long)ip->i_di.di_num.no_addr);
- jblocks = ip->i_di.di_size / sdp->sd_sb.sb_bsize;
+ log_debug(_("Checking for rgrps in journal%d which starts at block 0x%"PRIx64".\n"),
+ j, ip->i_addr);
+ jblocks = ip->i_size / sdp->sd_sb.sb_bsize;
false_count = 0;
for (b = 0; b < jblocks; b++) {
block_map(ip, b, &new, &dblock, NULL, 0);
@@ -876,7 +875,7 @@ static int gfs2_rindex_calculate(struct gfs2_sbd *sdp, int *num_rgs)
/* our rindex structures, then something's wrong and we can't trust */
/* the index. */
/* ----------------------------------------------------------------- */
- *num_rgs = sdp->md.riinode->i_di.di_size / sizeof(struct gfs2_rindex);
+ *num_rgs = sdp->md.riinode->i_size / sizeof(struct gfs2_rindex);
sdp->rgcalc.osi_node = NULL;
fix_device_geometry(sdp);
@@ -979,7 +978,7 @@ static int expect_rindex_sanity(struct gfs2_sbd *sdp, int *num_rgs)
struct osi_node *n, *next = NULL;
struct rgrp_tree *rgd, *exp;
- *num_rgs = sdp->md.riinode->i_di.di_size / sizeof(struct gfs2_rindex) ;
+ *num_rgs = sdp->md.riinode->i_size / sizeof(struct gfs2_rindex) ;
for (n = osi_first(&sdp->rgtree); n; n = next) {
next = osi_next(n);
rgd = (struct rgrp_tree *)n;
@@ -1067,7 +1066,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
/* Read in the rindex */
sdp->rgtree.osi_node = NULL; /* Just to be safe */
rindex_read(sdp, &sdp->rgrps, ok);
- if (sdp->md.riinode->i_di.di_size % sizeof(struct gfs2_rindex)) {
+ if (sdp->md.riinode->i_size % sizeof(struct gfs2_rindex)) {
log_warn( _("WARNING: rindex file has an invalid size.\n"));
if (!query( _("Truncate the rindex size? (y/n)"))) {
log_err(_("The rindex was not repaired.\n"));
@@ -1075,11 +1074,10 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
gfs2_rgrp_free(sdp, &sdp->rgtree);
return -1;
}
- sdp->md.riinode->i_di.di_size /= sizeof(struct gfs2_rindex);
- sdp->md.riinode->i_di.di_size *= sizeof(struct gfs2_rindex);
+ sdp->md.riinode->i_size /= sizeof(struct gfs2_rindex);
+ sdp->md.riinode->i_size *= sizeof(struct gfs2_rindex);
bmodified(sdp->md.riinode->i_bh);
- log_err(_("Changing rindex size to %lld.\n"),
- (unsigned long long)sdp->md.riinode->i_di.di_size);
+ log_err(_("Changing rindex size to %"PRIu64".\n"), sdp->md.riinode->i_size);
}
log_warn( _("L%d: number of rgs expected = %lld.\n"), trust_lvl + 1,
(unsigned long long)sdp->rgrps);
@@ -1104,8 +1102,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
/* We cannot grow rindex at this point. Since pass1 has not
yet run, we can't allocate blocks. Therefore we must use
whatever will fix in the space given. */
- most_that_fit = sdp->md.riinode->i_di.di_size /
- sizeof(struct gfs2_rindex);
+ most_that_fit = sdp->md.riinode->i_size / sizeof(struct gfs2_rindex);
log_debug(_("The most we can fit is %d rgrps\n"),
most_that_fit);
if (most_that_fit < calc_rg_count)
@@ -1281,7 +1278,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
permission. */
if (sdp->md.riinode->i_bh->b_modified) {
log_debug("Syncing rindex inode changes to disk.\n");
- gfs2_dinode_out(&sdp->md.riinode->i_di, sdp->md.riinode->i_bh->b_data);
+ lgfs2_dinode_out(sdp->md.riinode, sdp->md.riinode->i_bh->b_data);
bwrite(sdp->md.riinode->i_bh);
}
return 0;
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 26170fa5..84022814 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -30,7 +30,7 @@ void big_file_comfort(struct gfs2_inode *ip, uint64_t blks_checked)
int i, cs;
const char *human_abbrev = " KMGTPE";
- one_percent = ip->i_di.di_blocks / 100;
+ one_percent = ip->i_blocks / 100;
if (blks_checked - last_reported_fblock < one_percent)
return;
@@ -41,21 +41,17 @@ void big_file_comfort(struct gfs2_inode *ip, uint64_t blks_checked)
if (tv.tv_sec == seconds)
return;
- fsize = ip->i_di.di_size;
+ fsize = ip->i_size;
for (i = 0; i < 6 && fsize > 1024; i++)
fsize /= 1024;
chksize = blks_checked * ip->i_sbd->bsize;
for (cs = 0; cs < 6 && chksize > 1024; cs++)
chksize /= 1024;
seconds = tv.tv_sec;
- percent = (blks_checked * 100) / ip->i_di.di_blocks;
- log_notice( _("\rChecking %lld%c of %lld%c of file at %lld (0x%llx)"
- "- %llu percent complete. \r"),
- (long long)chksize, human_abbrev[cs],
- (unsigned long long)fsize, human_abbrev[i],
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)percent);
+ 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);
fflush(stdout);
}
@@ -281,13 +277,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_di.di_num.no_addr)
+ if (id->block_no == ip->i_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_di.di_num.no_addr)
+ if (id->block_no == ip->i_addr)
return id;
}
return NULL;
@@ -365,10 +361,9 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
"a duplicate within the same inode.\n"),
(unsigned long long)block,
(unsigned long long)block);
- log_info(_("I'll consider the reference from inode %llu "
- "(0x%llx) the first reference.\n"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ log_info(_("I'll consider the reference from inode %"PRIu64
+ " (0x%"PRIx64") the first reference.\n"),
+ ip->i_addr, ip->i_addr);
dt->dup_flags |= DUPFLAG_REF1_IS_DUPL;
dt->refs++;
}
@@ -393,8 +388,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_di.di_num.no_addr;
- q = bitmap_type(ip->i_sbd, ip->i_di.di_num.no_addr);
+ id->block_no = ip->i_addr;
+ q = bitmap_type(ip->i_sbd, ip->i_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)
@@ -414,13 +409,11 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
}
id->reftypecount[reftype]++;
id->dup_count++;
- log_info( _("Found %d reference(s) to block %llu"
- " (0x%llx) as %s in %s inode #%llu (0x%llx)\n"),
- id->dup_count, (unsigned long long)block,
- (unsigned long long)block, reftypes[reftype],
+ log_info(_("Found %d reference(s) to block %"PRIu64" (0x%"PRIx64") "
+ "as %s in %s inode #%"PRIu64" (0x%"PRIx64")\n"),
+ id->dup_count, block, block, reftypes[reftype],
inode_valid ? _("valid") : _("invalid"),
- (unsigned long long)ip->i_di.di_num.no_addr,
- (unsigned long long)ip->i_di.di_num.no_addr);
+ ip->i_addr, ip->i_addr);
if (first)
log_info( _("This is the original reference.\n"));
else {
@@ -587,7 +580,7 @@ uint64_t find_free_blk(struct gfs2_sbd *sdp)
uint64_t *get_dir_hash(struct gfs2_inode *ip)
{
- unsigned hsize = (1 << ip->i_di.di_depth) * sizeof(uint64_t);
+ unsigned hsize = (1 << ip->i_depth) * sizeof(uint64_t);
int ret;
uint64_t *tbl = malloc(hsize);
@@ -620,14 +613,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_di.di_num.no_addr) {
+ if (id->block_no == ip->i_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_di.di_num.no_addr) {
+ if (id->block_no == ip->i_addr) {
dup_listent_delete(dt, id);
found = 1;
}
diff --git a/gfs2/fsck/util.h b/gfs2/fsck/util.h
index d8767247..182868a6 100644
--- a/gfs2/fsck/util.h
+++ b/gfs2/fsck/util.h
@@ -83,11 +83,11 @@ static const inline char *block_type_string(int q)
return blktyp[4];
}
-static inline int is_dir(struct gfs2_dinode *dinode, int gfs1)
+static inline int is_dir(struct gfs2_inode *ip, int gfs1)
{
- if (gfs1 && is_gfs_dir(dinode))
+ if (gfs1 && is_gfs_dir(ip))
return 1;
- if (S_ISDIR(dinode->di_mode))
+ if (S_ISDIR(ip->i_mode))
return 1;
return 0;
@@ -95,7 +95,7 @@ static inline int is_dir(struct gfs2_dinode *dinode, int gfs1)
static inline uint32_t gfs_to_gfs2_mode(struct gfs2_inode *ip)
{
- uint16_t gfs1mode = ip->i_di.__pad1;
+ uint16_t gfs1mode = ip->i_pad1;
switch (gfs1mode) {
case GFS_FILE_DIR:
@@ -114,8 +114,8 @@ static inline uint32_t gfs_to_gfs2_mode(struct gfs2_inode *ip)
return S_IFSOCK;
default:
/* This could be an aborted gfs2_convert so look for both. */
- if (ip->i_di.di_entries ||
- (ip->i_di.di_mode & S_IFMT) == S_IFDIR)
+ if (ip->i_entries ||
+ (ip->i_mode & S_IFMT) == S_IFDIR)
return S_IFDIR;
else
return S_IFREG;
diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
index 0096a2a5..c0fc0ceb 100644
--- a/gfs2/glocktop/glocktop.c
+++ b/gfs2/glocktop/glocktop.c
@@ -621,7 +621,7 @@ static const char *show_inode(const char *id, int fd, unsigned long long block)
struct gfs2_sbd sbd = { .device_fd = fd, .bsize = bsize };
ip = lgfs2_inode_read(&sbd, block);
- if (S_ISDIR(ip->i_di.di_mode)) {
+ if (S_ISDIR(ip->i_mode)) {
struct gfs2_inode *parent;
unsigned long long dirarray[256];
int subdepth = 0, error;
@@ -635,27 +635,26 @@ 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_di.di_num.no_addr ==
- parent->i_di.di_num.no_addr) {
+ if (ip->i_addr == parent->i_addr) {
inode_put(&parent);
break;
}
inode_put(&ip);
ip = parent;
- dirarray[subdepth++] = parent->i_di.di_num.no_addr;
+ dirarray[subdepth++] = parent->i_addr;
}
display_filename(fd, block, dirarray, subdepth);
- } else if (S_ISREG(ip->i_di.di_mode)) {
+ } else if (S_ISREG(ip->i_mode)) {
inode_type = "file ";
- } else if (S_ISLNK(ip->i_di.di_mode)) {
+ } else if (S_ISLNK(ip->i_mode)) {
inode_type = "link ";
- } else if (S_ISCHR(ip->i_di.di_mode)) {
+ } else if (S_ISCHR(ip->i_mode)) {
inode_type = "char device ";
- } else if (S_ISBLK(ip->i_di.di_mode)) {
+ } else if (S_ISBLK(ip->i_mode)) {
inode_type = "block device ";
- } else if (S_ISFIFO(ip->i_di.di_mode)) {
+ } else if (S_ISFIFO(ip->i_mode)) {
inode_type = "fifo ";
- } else if (S_ISSOCK(ip->i_di.di_mode)) {
+ } else if (S_ISSOCK(ip->i_mode)) {
inode_type = "socket ";
} else
inode_type = "file? ";
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 12d845f1..ccb75df3 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -27,7 +27,7 @@ static __inline__ uint64_t *metapointer(char *buf,
/* Detect directory is a stuffed inode */
static int inode_is_stuffed(const struct gfs2_inode *ip)
{
- return !ip->i_di.di_height;
+ return !ip->i_height;
}
struct gfs2_inode *lgfs2_inode_get(struct gfs2_sbd *sdp, struct gfs2_buffer_head *bh)
@@ -38,7 +38,7 @@ struct gfs2_inode *lgfs2_inode_get(struct gfs2_sbd *sdp, struct gfs2_buffer_head
if (ip == NULL) {
return NULL;
}
- gfs2_dinode_in(&ip->i_di, bh->b_data);
+ lgfs2_dinode_in(ip, bh->b_data);
ip->i_bh = bh;
ip->i_sbd = sdp;
return ip;
@@ -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_di.di_num.no_addr)
+ if (sdp->md.inum && block == sdp->md.inum->i_addr)
return sdp->md.inum;
- if (sdp->md.statfs && block == sdp->md.statfs->i_di.di_num.no_addr)
+ if (sdp->md.statfs && block == sdp->md.statfs->i_addr)
return sdp->md.statfs;
- if (sdp->md.jiinode && block == sdp->md.jiinode->i_di.di_num.no_addr)
+ if (sdp->md.jiinode && block == sdp->md.jiinode->i_addr)
return sdp->md.jiinode;
- if (sdp->md.riinode && block == sdp->md.riinode->i_di.di_num.no_addr)
+ if (sdp->md.riinode && block == sdp->md.riinode->i_addr)
return sdp->md.riinode;
- if (sdp->md.qinode && block == sdp->md.qinode->i_di.di_num.no_addr)
+ if (sdp->md.qinode && block == sdp->md.qinode->i_addr)
return sdp->md.qinode;
- if (sdp->md.pinode && block == sdp->md.pinode->i_di.di_num.no_addr)
+ if (sdp->md.pinode && block == sdp->md.pinode->i_addr)
return sdp->md.pinode;
- if (sdp->md.rooti && block == sdp->md.rooti->i_di.di_num.no_addr)
+ if (sdp->md.rooti && block == sdp->md.rooti->i_addr)
return sdp->md.rooti;
- if (sdp->master_dir && block == sdp->master_dir->i_di.di_num.no_addr)
+ if (sdp->master_dir && block == sdp->master_dir->i_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_di.di_num.no_addr)
+ block == sdp->md.journal[j]->i_addr)
return sdp->md.journal[j];
return NULL;
}
@@ -90,11 +90,11 @@ 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_di.di_num.no_addr;
+ uint64_t block = ip->i_addr;
struct gfs2_sbd *sdp = ip->i_sbd;
if (ip->i_bh->b_modified) {
- gfs2_dinode_out(&ip->i_di, ip->i_bh->b_data);
+ lgfs2_dinode_out(ip, ip->i_bh->b_data);
if (!ip->bh_owned && is_system_inode(sdp, block))
fprintf(stderr, "Warning: Change made to inode "
"were discarded.\n");
@@ -212,7 +212,7 @@ int lgfs2_meta_alloc(struct gfs2_inode *ip, uint64_t *blkno)
ip->i_sbd->gfs1 ? GFS2_BLKST_DINODE :
GFS2_BLKST_USED, blkno, 0);
if (ret == 0) {
- ip->i_di.di_goal_meta = *blkno;
+ ip->i_goal_meta = *blkno;
bmodified(ip->i_bh);
}
return ret;
@@ -242,9 +242,9 @@ void unstuff_dinode(struct gfs2_inode *ip)
struct gfs2_sbd *sdp = ip->i_sbd;
struct gfs2_buffer_head *bh;
uint64_t block = 0;
- int isdir = S_ISDIR(ip->i_di.di_mode) || is_gfs_dir(&ip->i_di);
+ int isdir = S_ISDIR(ip->i_mode) || is_gfs_dir(ip);
- if (ip->i_di.di_size) {
+ if (ip->i_size) {
if (lgfs2_meta_alloc(ip, &block))
exit(1);
if (isdir) {
@@ -273,13 +273,13 @@ void unstuff_dinode(struct gfs2_inode *ip)
buffer_clear_tail(sdp, ip->i_bh, sizeof(struct gfs2_dinode));
- if (ip->i_di.di_size) {
+ if (ip->i_size) {
*(uint64_t *)(ip->i_bh->b_data + sizeof(struct gfs2_dinode)) = cpu_to_be64(block);
/* no need: bmodified(ip->i_bh); buffer_clear_tail does it */
- ip->i_di.di_blocks++;
+ ip->i_blocks++;
}
- ip->i_di.di_height = 1;
+ ip->i_height = 1;
}
/**
@@ -305,7 +305,7 @@ uint64_t lgfs2_space_for_data(const struct gfs2_sbd *sdp, const unsigned bsize,
* rg: The resource group in which to allocate the extent
* di_size: The size of the file in bytes
* ip: A pointer to the inode structure, whose fields will be set appropriately.
- * If ip->i_di.di_num.no_addr is not 0, the extent search will be skipped and
+ * If ip->i_num.no_addr is not 0, the extent search will be skipped and
* the file allocated from that address.
* flags: GFS2_DIF_* flags
* mode: File mode flags, see creat(2)
@@ -316,13 +316,12 @@ uint64_t lgfs2_space_for_data(const struct gfs2_sbd *sdp, const unsigned bsize,
int lgfs2_file_alloc(lgfs2_rgrp_t rg, uint64_t di_size, struct gfs2_inode *ip, uint32_t flags, unsigned mode)
{
unsigned extlen;
- struct gfs2_dinode *di = &ip->i_di;
struct gfs2_sbd *sdp = rg->rgrps->sdp;
struct lgfs2_rbm rbm = { .rgd = rg, .offset = 0, .bii = 0 };
uint32_t blocks = lgfs2_space_for_data(sdp, sdp->bsize, di_size);
- if (ip->i_di.di_num.no_addr != 0) {
- if (lgfs2_rbm_from_block(&rbm, ip->i_di.di_num.no_addr) != 0)
+ if (ip->i_addr != 0) {
+ if (lgfs2_rbm_from_block(&rbm, ip->i_addr) != 0)
return 1;
} else if (lgfs2_rbm_find(&rbm, GFS2_BLKST_FREE, &blocks) != 0) {
return 1;
@@ -336,20 +335,20 @@ int lgfs2_file_alloc(lgfs2_rgrp_t rg, uint64_t di_size, struct gfs2_inode *ip, u
ip->i_sbd = sdp;
- di->di_header.mh_magic = GFS2_MAGIC;
- di->di_header.mh_type = GFS2_METATYPE_DI;
- di->di_header.mh_format = GFS2_FORMAT_DI;
- di->di_size = di_size;
- di->di_num.no_addr = lgfs2_rbm_to_block(&rbm);
- di->di_num.no_formal_ino = sdp->md.next_inum++;
- di->di_mode = mode;
- di->di_nlink = 1;
- di->di_blocks = blocks;
- di->di_atime = di->di_mtime = di->di_ctime = sdp->time;
- di->di_goal_data = di->di_num.no_addr + di->di_blocks - 1;
- di->di_goal_meta = di->di_goal_data - ((di_size + sdp->bsize - 1) / sdp->bsize);
- di->di_height = calc_tree_height(ip, di_size);
- di->di_flags = flags;
+ ip->i_magic = GFS2_MAGIC;
+ ip->i_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_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_meta = ip->i_goal_data - ((di_size + sdp->bsize - 1) / sdp->bsize);
+ ip->i_height = calc_tree_height(ip, di_size);
+ ip->i_flags = flags;
rg->rg.rg_free -= blocks;
rg->rg.rg_dinodes += 1;
@@ -366,10 +365,10 @@ unsigned int calc_tree_height(struct gfs2_inode *ip, uint64_t size)
uint64_t *arr;
unsigned int max, height;
- if (ip->i_di.di_size > size)
- size = ip->i_di.di_size;
+ if (ip->i_size > size)
+ size = ip->i_size;
- if (S_ISDIR(ip->i_di.di_mode)) {
+ if (S_ISDIR(ip->i_mode)) {
arr = sdp->sd_jheightsize;
max = sdp->sd_max_jheight;
} else {
@@ -392,7 +391,7 @@ void build_height(struct gfs2_inode *ip, int height)
unsigned int x;
int new_block;
- while (ip->i_di.di_height < height) {
+ while (ip->i_height < height) {
new_block = 0;
bp = (uint64_t *)(ip->i_bh->b_data + sizeof(struct gfs2_dinode));
for (x = 0; x < sdp->sd_diptrs; x++, bp++)
@@ -423,17 +422,17 @@ void build_height(struct gfs2_inode *ip, int height)
if (new_block) {
*(uint64_t *)(ip->i_bh->b_data + sizeof(struct gfs2_dinode)) = cpu_to_be64(block);
/* no need: bmodified(ip->i_bh);*/
- ip->i_di.di_blocks++;
+ ip->i_blocks++;
}
- ip->i_di.di_height++;
+ ip->i_height++;
}
}
void find_metapath(struct gfs2_inode *ip, uint64_t block, struct metapath *mp)
{
const uint32_t inptrs = ip->i_sbd->sd_inptrs;
- unsigned int i = ip->i_di.di_height;
+ unsigned int i = ip->i_height;
memset(mp, 0, sizeof(struct metapath));
while (i--) {
@@ -462,7 +461,7 @@ void lookup_block(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
return;
*ptr = cpu_to_be64(*block);
bmodified(bh);
- ip->i_di.di_blocks++;
+ ip->i_blocks++;
bmodified(ip->i_bh);
*new = 1;
@@ -487,17 +486,17 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
if (inode_is_stuffed(ip)) {
if (!lblock) {
- *dblock = ip->i_di.di_num.no_addr;
+ *dblock = ip->i_addr;
if (extlen)
*extlen = 1;
}
return;
}
- bsize = (S_ISDIR(ip->i_di.di_mode)) ? sdp->sd_jbsize : sdp->bsize;
+ bsize = (S_ISDIR(ip->i_mode)) ? sdp->sd_jbsize : sdp->bsize;
height = calc_tree_height(ip, (lblock + 1) * bsize);
- if (ip->i_di.di_height < height) {
+ if (ip->i_height < height) {
if (!create)
return;
@@ -505,7 +504,7 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
}
find_metapath(ip, lblock, &mp);
- end_of_metadata = ip->i_di.di_height - 1;
+ end_of_metadata = ip->i_height - 1;
bh = ip->i_bh;
@@ -525,7 +524,7 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
gfs2_meta_header_out(&mh, bh->b_data);
bmodified(bh);
} else {
- if (*dblock == ip->i_di.di_num.no_addr)
+ if (*dblock == ip->i_addr)
bh = ip->i_bh;
else
bh = bread(sdp, *dblock);
@@ -585,15 +584,15 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
uint32_t extlen = 0;
unsigned int amount;
int not_new = 0;
- int isdir = !!(S_ISDIR(ip->i_di.di_mode));
- int journaled = ip->i_di.di_flags & GFS2_DIF_JDATA;
+ int isdir = !!(S_ISDIR(ip->i_mode));
+ int journaled = ip->i_flags & GFS2_DIF_JDATA;
int copied = 0;
- if (offset >= ip->i_di.di_size)
+ if (offset >= ip->i_size)
return 0;
- if ((offset + size) > ip->i_di.di_size)
- size = ip->i_di.di_size - offset;
+ if ((offset + size) > ip->i_size)
+ size = ip->i_size - offset;
if (!size)
return 0;
@@ -627,7 +626,7 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
}
if (dblock) {
- if (dblock == ip->i_di.di_num.no_addr)
+ if (dblock == ip->i_addr)
bh = ip->i_bh;
else
bh = bread(sdp, dblock);
@@ -672,7 +671,7 @@ int __gfs2_writei(struct gfs2_inode *ip, void *buf,
uint32_t extlen = 0;
unsigned int amount;
int new;
- int isdir = !!(S_ISDIR(ip->i_di.di_mode));
+ int isdir = !!(S_ISDIR(ip->i_mode));
const uint64_t start = offset;
int copied = 0;
@@ -718,7 +717,7 @@ int __gfs2_writei(struct gfs2_inode *ip, void *buf,
bmodified(bh);
}
} else {
- if (dblock == ip->i_di.di_num.no_addr)
+ if (dblock == ip->i_addr)
bh = ip->i_bh;
else
bh = bread(sdp, dblock);
@@ -735,9 +734,9 @@ int __gfs2_writei(struct gfs2_inode *ip, void *buf,
o = (isdir) ? sizeof(struct gfs2_meta_header) : 0;
}
- if (resize && ip->i_di.di_size < start + copied) {
+ if (resize && ip->i_size < start + copied) {
bmodified(ip->i_bh);
- ip->i_di.di_size = start + copied;
+ ip->i_size = start + copied;
}
return copied;
@@ -804,7 +803,7 @@ static int dirent_alloc(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
dent->de_name_len = cpu_to_be16(name_len);
bmodified(bh);
*dent_out = dent;
- dip->i_di.di_entries++;
+ dip->i_entries++;
bmodified(dip->i_bh);
return 0;
}
@@ -834,7 +833,7 @@ static int dirent_alloc(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
*dent_out = new;
bmodified(bh);
- dip->i_di.di_entries++;
+ dip->i_entries++;
bmodified(dip->i_bh);
return 0;
}
@@ -843,7 +842,7 @@ static int dirent_alloc(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
*dent_out = dent;
bmodified(bh);
- dip->i_di.di_entries++;
+ dip->i_entries++;
bmodified(dip->i_bh);
return 0;
}
@@ -866,9 +865,9 @@ void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
lf->lf_entries = cpu_to_be16(lf->lf_entries);
}
- if (dip->i_di.di_entries) {
+ if (dip->i_entries) {
bmodified(dip->i_bh);
- dip->i_di.di_entries--;
+ dip->i_entries--;
}
if (!prev) {
cur->de_inum.no_addr = 0;
@@ -925,7 +924,7 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
oleaf = (struct gfs2_leaf *)obh->b_data;
- len = 1 << (dip->i_di.di_depth - be16_to_cpu(oleaf->lf_depth));
+ len = 1 << (dip->i_depth - be16_to_cpu(oleaf->lf_depth));
half_len = len >> 1;
lp = calloc(1, half_len * sizeof(uint64_t));
@@ -949,7 +948,7 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
free(lp);
- divider = (start + half_len) << (32 - dip->i_di.di_depth);
+ divider = (start + half_len) << (32 - dip->i_depth);
gfs2_dirent_first(dip, obh, &dent);
@@ -994,15 +993,15 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
}
new->de_inum.no_formal_ino = 0;
/* Don't count the sentinel dirent as an entry */
- dip->i_di.di_entries--;
+ dip->i_entries--;
}
oleaf->lf_depth = be16_to_cpu(oleaf->lf_depth) + 1;
oleaf->lf_depth = cpu_to_be16(oleaf->lf_depth);
nleaf->lf_depth = oleaf->lf_depth;
- nleaf->lf_inode = cpu_to_be64(dip->i_di.di_num.no_addr);
- dip->i_di.di_blocks++;
+ nleaf->lf_inode = cpu_to_be64(dip->i_addr);
+ dip->i_blocks++;
bmodified(dip->i_bh);
bmodified(obh); /* Need to do this in case nothing was moved */
@@ -1025,7 +1024,7 @@ static void dir_double_exhash(struct gfs2_inode *dip)
exit(-1);
}
- for (block = dip->i_di.di_size >> sdp->sd_hash_bsize_shift; block--;) {
+ for (block = dip->i_size >> sdp->sd_hash_bsize_shift; block--;) {
count = gfs2_readi(dip, (char *)buf,
block * sdp->sd_hash_bsize,
sdp->sd_hash_bsize);
@@ -1058,7 +1057,7 @@ static void dir_double_exhash(struct gfs2_inode *dip)
free(buf);
- dip->i_di.di_depth++;
+ dip->i_depth++;
bmodified(dip->i_bh);
}
@@ -1151,8 +1150,8 @@ static int dir_e_add(struct gfs2_inode *dip, const char *filename, int len,
hash = gfs2_disk_hash(filename, len);
restart:
/* Have to kludge because (hash >> 32) gives hash for some reason. */
- if (dip->i_di.di_depth)
- lindex = hash >> (32 - dip->i_di.di_depth);
+ if (dip->i_depth)
+ lindex = hash >> (32 - dip->i_depth);
else
lindex = 0;
@@ -1166,15 +1165,15 @@ restart:
if (dirent_alloc(dip, bh, len, &dent)) {
- if (be16_to_cpu(leaf->lf_depth) < dip->i_di.di_depth) {
- llen = 1 << (dip->i_di.di_depth -
+ if (be16_to_cpu(leaf->lf_depth) < dip->i_depth) {
+ llen = 1 << (dip->i_depth -
be16_to_cpu(leaf->lf_depth));
dir_split_leaf(dip, lindex & ~(llen - 1),
leaf_no, bh);
brelse(bh);
goto restart;
- } else if (dip->i_di.di_depth < GFS2_DIR_MAX_DEPTH) {
+ } else if (dip->i_depth < GFS2_DIR_MAX_DEPTH) {
brelse(bh);
dir_double_exhash(dip);
goto restart;
@@ -1201,11 +1200,11 @@ 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_di.di_num.no_addr);
+ nleaf->lf_inode = cpu_to_be64(dip->i_addr);
err = dirent_alloc(dip, nbh, len, &dent);
if (err)
return err;
- dip->i_di.di_blocks++;
+ dip->i_blocks++;
bmodified(dip->i_bh);
bmodified(bh);
brelse(bh);
@@ -1252,8 +1251,8 @@ 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_di.di_entries);
- leaf->lf_inode = cpu_to_be64(dip->i_di.di_num.no_addr);
+ leaf->lf_entries = cpu_to_be16(dip->i_entries);
+ leaf->lf_inode = cpu_to_be64(dip->i_addr);
buffer_copy_tail(sdp, bh, sizeof(struct gfs2_leaf),
dip->i_bh, sizeof(struct gfs2_dinode));
@@ -1263,7 +1262,7 @@ static void dir_make_exhash(struct gfs2_inode *dip)
do {
if (!dent->de_inum.no_formal_ino)
continue;
- if (++x == dip->i_di.di_entries)
+ if (++x == dip->i_entries)
break;
} while (gfs2_dirent_next(dip, bh, &dent) == 0);
@@ -1281,16 +1280,16 @@ static void dir_make_exhash(struct gfs2_inode *dip)
for (x = sdp->sd_hash_ptrs; x--; lp++)
*lp = cpu_to_be64(bn);
- dip->i_di.di_size = sdp->bsize / 2;
- dip->i_di.di_blocks++;
- dip->i_di.di_flags |= GFS2_DIF_EXHASH;
- dip->i_di.di_payload_format = 0;
+ dip->i_size = sdp->bsize / 2;
+ dip->i_blocks++;
+ dip->i_flags |= GFS2_DIF_EXHASH;
+ dip->i_payload_format = 0;
/* no need: bmodified(dip->i_bh); buffer_clear_tail does it. */
for (x = sdp->sd_hash_ptrs, y = -1; x; x >>= 1, y++) ;
- dip->i_di.di_depth = y;
+ dip->i_depth = y;
- gfs2_dinode_out(&dip->i_di, dip->i_bh->b_data);
+ lgfs2_dinode_out(dip, dip->i_bh->b_data);
bwrite(dip->i_bh);
}
@@ -1319,7 +1318,7 @@ int dir_add(struct gfs2_inode *dip, const char *filename, int len,
struct gfs2_inum *inum, unsigned int type)
{
int err = 0;
- if (dip->i_di.di_flags & GFS2_DIF_EXHASH)
+ if (dip->i_flags & GFS2_DIF_EXHASH)
err = dir_e_add(dip, filename, len, inum, type);
else
err = dir_l_add(dip, filename, len, inum, type);
@@ -1433,15 +1432,15 @@ int lgfs2_write_filemeta(struct gfs2_inode *ip)
unsigned height = 0;
struct metapath mp;
struct gfs2_sbd *sdp = ip->i_sbd;
- uint64_t dblocks = (ip->i_di.di_size + sdp->bsize - 1) / sdp->bsize;
- uint64_t ptr0 = ip->i_di.di_num.no_addr + 1;
+ uint64_t dblocks = (ip->i_size + sdp->bsize - 1) / sdp->bsize;
+ 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,
};
- struct gfs2_buffer_head *bh = bget(sdp, ip->i_di.di_num.no_addr);
+ struct gfs2_buffer_head *bh = bget(sdp, ip->i_addr);
if (bh == NULL)
return 1;
@@ -1450,7 +1449,7 @@ int lgfs2_write_filemeta(struct gfs2_inode *ip)
height. Just need to add 1 to convert ptr index to quantity later. */
find_metapath(ip, dblocks - 1, &mp);
- for (height = 0; height < ip->i_di.di_height; height++) {
+ for (height = 0; height < ip->i_height; height++) {
unsigned p;
/* The number of pointers in this height will be the number of
full indirect blocks pointed to by the previous height
@@ -1462,7 +1461,7 @@ int lgfs2_write_filemeta(struct gfs2_inode *ip)
char *start = bh->b_data;
if (height == 0) {
start += sizeof(struct gfs2_dinode);
- gfs2_dinode_out(&ip->i_di, bh->b_data);
+ lgfs2_dinode_out(ip, bh->b_data);
} else {
start += sizeof(struct gfs2_meta_header);
gfs2_meta_header_out(&mh, bh->b_data);
@@ -1493,6 +1492,10 @@ 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,
+ };
err = lgfs2_dinode_alloc(sdp, 1, &bn);
if (err != 0)
return NULL;
@@ -1513,10 +1516,10 @@ static struct gfs2_inode *__createi(struct gfs2_inode *dip,
is_dir = S_ISDIR(mode);
if (is_dir) {
bmodified(dip->i_bh);
- dip->i_di.di_nlink++;
+ dip->i_nlink++;
}
- err = __init_dinode(sdp, &bh, &inum, mode, flags, &dip->i_di.di_num, if_gfs1);
+ err = __init_dinode(sdp, &bh, &inum, mode, flags, &parent, if_gfs1);
if (err != 0)
return NULL;
@@ -1586,7 +1589,7 @@ static int leaf_search(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
struct gfs2_leaf *leaf = (struct gfs2_leaf *)bh->b_data;
entries = be16_to_cpu(leaf->lf_entries);
} else if (type == IS_DINODE)
- entries = dip->i_di.di_entries;
+ entries = dip->i_entries;
else
return -1;
@@ -1636,14 +1639,14 @@ static int linked_leaf_search(struct gfs2_inode *dip, const char *filename,
uint32_t hash;
int error = 0;
- hsize = 1 << dip->i_di.di_depth;
- if(hsize * sizeof(uint64_t) != dip->i_di.di_size)
+ hsize = 1 << dip->i_depth;
+ if(hsize * sizeof(uint64_t) != dip->i_size)
return -1;
/* Figure out the address of the leaf node. */
hash = gfs2_disk_hash(filename, len);
- lindex = hash >> (32 - dip->i_di.di_depth);
+ lindex = hash >> (32 - dip->i_depth);
error = get_first_leaf(dip, lindex, &bh_next);
if (error)
@@ -1755,10 +1758,10 @@ int dir_search(struct gfs2_inode *dip, const char *filename, int len,
{
int error;
- if(!S_ISDIR(dip->i_di.di_mode) && !is_gfs_dir(&dip->i_di))
+ if(!S_ISDIR(dip->i_mode) && !is_gfs_dir(dip))
return -1;
- if (dip->i_di.di_flags & GFS2_DIF_EXHASH)
+ if (dip->i_flags & GFS2_DIF_EXHASH)
error = dir_e_search(dip, filename, len, type, inum);
else
error = dir_l_search(dip, filename, len, type, inum);
@@ -1775,7 +1778,7 @@ static int dir_e_del(struct gfs2_inode *dip, const char *filename, int len)
struct gfs2_buffer_head *bh = NULL;
struct gfs2_dirent *cur, *prev;
- lindex = (1 << (dip->i_di.di_depth))-1;
+ lindex = (1 << (dip->i_depth))-1;
for(; (lindex >= 0) && !found; lindex--){
error = lgfs2_get_leaf_ptr(dip, lindex, &leaf_no);
@@ -1843,10 +1846,10 @@ int gfs2_dirent_del(struct gfs2_inode *dip, const char *filename, int len)
{
int error;
- if(!S_ISDIR(dip->i_di.di_mode) && !is_gfs_dir(&dip->i_di))
+ if(!S_ISDIR(dip->i_mode) && !is_gfs_dir(dip))
return -1;
- if (dip->i_di.di_flags & GFS2_DIF_EXHASH)
+ if (dip->i_flags & GFS2_DIF_EXHASH)
error = dir_e_del(dip, filename, len);
else
error = dir_l_del(dip, filename, len);
@@ -1929,7 +1932,7 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
ip = lgfs2_inode_get(sdp, bh);
if (ip == NULL)
return -1;
- height = ip->i_di.di_height;
+ height = ip->i_height;
osi_list_add(&bh->b_altlist, &metalist[0]);
for (h = 0; h < height; h++){
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index b2294a8b..6f74ce4d 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -19,7 +19,7 @@
static __inline__ int fs_is_jdata(struct gfs2_inode *ip)
{
- return ip->i_di.di_flags & GFS2_DIF_JDATA;
+ return ip->i_flags & GFS2_DIF_JDATA;
}
static __inline__ uint64_t *
@@ -31,9 +31,9 @@ gfs1_metapointer(char *buf, unsigned int height, struct metapath *mp)
return ((uint64_t *)(buf + head_size)) + mp->mp_list[height];
}
-int is_gfs_dir(struct gfs2_dinode *dinode)
+int is_gfs_dir(struct gfs2_inode *ip)
{
- if (dinode->__pad1 == GFS_FILE_DIR)
+ if (ip->i_pad1 == GFS_FILE_DIR)
return 1;
return 0;
}
@@ -61,7 +61,7 @@ void gfs1_lookup_block(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
*ptr = cpu_to_be64(*block);
bmodified(bh);
- ip->i_di.di_blocks++;
+ ip->i_blocks++;
bmodified(ip->i_bh);
*new = 1;
@@ -84,9 +84,9 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
if (extlen)
*extlen = 0;
- if (!ip->i_di.di_height) { /* stuffed */
+ if (!ip->i_height) { /* stuffed */
if (!lblock) {
- *dblock = ip->i_di.di_num.no_addr;
+ *dblock = ip->i_addr;
if (extlen)
*extlen = 1;
}
@@ -96,7 +96,7 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
bsize = (fs_is_jdata(ip)) ? sdp->sd_jbsize : sdp->bsize;
height = calc_tree_height(ip, (lblock + 1) * bsize);
- if (ip->i_di.di_height < height) {
+ if (ip->i_height < height) {
if (!create)
return;
@@ -104,7 +104,7 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
}
find_metapath(ip, lblock, &mp);
- end_of_metadata = ip->i_di.di_height - 1;
+ end_of_metadata = ip->i_height - 1;
bh = ip->i_bh;
@@ -125,7 +125,7 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
gfs2_meta_header_out(&mh, bh->b_data);
bmodified(bh);
} else {
- if (*dblock == ip->i_di.di_num.no_addr)
+ if (*dblock == ip->i_addr)
bh = ip->i_bh;
else
bh = bread(sdp, *dblock);
@@ -179,7 +179,7 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
if (!size)
return 0;
- if (!ip->i_di.di_height && /* stuffed */
+ if (!ip->i_height && /* stuffed */
((start + size) > (sdp->bsize - sizeof(struct gfs_dinode))))
unstuff_dinode(ip);
@@ -191,7 +191,7 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
offset &= sdp->bsize - 1;
}
- if (!ip->i_di.di_height) /* stuffed */
+ if (!ip->i_height) /* stuffed */
offset += sizeof(struct gfs_dinode);
else if (journaled)
offset += sizeof(struct gfs2_meta_header);
@@ -208,12 +208,12 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
return -1;
}
- if (dblock == ip->i_di.di_num.no_addr)
+ if (dblock == ip->i_addr)
bh = ip->i_bh;
else
bh = bread(sdp, dblock);
- if (journaled && dblock != ip->i_di.di_num.no_addr ) {
+ if (journaled && dblock != ip->i_addr ) {
struct gfs2_meta_header mh;
mh.mh_magic = GFS2_MAGIC;
@@ -235,86 +235,58 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
offset = (journaled) ? sizeof(struct gfs2_meta_header) : 0;
}
- if (ip->i_di.di_size < start + copied) {
+ if (ip->i_size < start + copied) {
bmodified(ip->i_bh);
- ip->i_di.di_size = start + copied;
+ ip->i_size = start + copied;
}
- ip->i_di.di_mtime = ip->i_di.di_ctime = time(NULL);
- gfs2_dinode_out(&ip->i_di, ip->i_bh->b_data);
+ ip->i_mtime = ip->i_ctime = time(NULL);
+ lgfs2_dinode_out(ip, ip->i_bh->b_data);
bmodified(ip->i_bh);
return copied;
}
-static void gfs_dinode_in(struct gfs_dinode *di, char *buf)
+static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp, char *buf)
{
- struct gfs_dinode *str = (struct gfs_dinode *)buf;
-
- gfs2_meta_header_in(&di->di_header, buf);
- gfs2_inum_in(&di->di_num, (char *)&str->di_num);
-
- di->di_mode = be32_to_cpu(str->di_mode);
- di->di_uid = be32_to_cpu(str->di_uid);
- di->di_gid = be32_to_cpu(str->di_gid);
- di->di_nlink = be32_to_cpu(str->di_nlink);
- di->di_size = be64_to_cpu(str->di_size);
- di->di_blocks = be64_to_cpu(str->di_blocks);
- di->di_atime = be64_to_cpu(str->di_atime);
- di->di_mtime = be64_to_cpu(str->di_mtime);
- di->di_ctime = be64_to_cpu(str->di_ctime);
- di->di_major = be32_to_cpu(str->di_major);
- di->di_minor = be32_to_cpu(str->di_minor);
- di->di_goal_dblk = be64_to_cpu(str->di_goal_dblk);
- di->di_goal_mblk = be64_to_cpu(str->di_goal_mblk);
- di->di_flags = be32_to_cpu(str->di_flags);
- di->di_payload_format = be32_to_cpu(str->di_payload_format);
- di->di_type = be16_to_cpu(str->di_type);
- di->di_height = be16_to_cpu(str->di_height);
- di->di_depth = be16_to_cpu(str->di_depth);
- di->di_entries = be32_to_cpu(str->di_entries);
- di->di_eattr = be64_to_cpu(str->di_eattr);
-}
-
-static struct gfs2_inode *__gfs_inode_get(struct gfs2_sbd *sdp, char *buf, uint64_t di_addr)
-{
- struct gfs_dinode gfs1_dinode;
+ struct gfs_dinode *di;
struct gfs2_inode *ip;
ip = calloc(1, sizeof(struct gfs2_inode));
if (ip == NULL) {
return NULL;
}
- gfs_dinode_in(&gfs1_dinode, buf);
- memcpy(&ip->i_di.di_header, &gfs1_dinode.di_header,
- sizeof(struct gfs2_meta_header));
- memcpy(&ip->i_di.di_num, &gfs1_dinode.di_num,
- sizeof(struct gfs2_inum));
- ip->i_di.di_mode = gfs1_dinode.di_mode;
- ip->i_di.di_uid = gfs1_dinode.di_uid;
- ip->i_di.di_gid = gfs1_dinode.di_gid;
- ip->i_di.di_nlink = gfs1_dinode.di_nlink;
- ip->i_di.di_size = gfs1_dinode.di_size;
- ip->i_di.di_blocks = gfs1_dinode.di_blocks;
- ip->i_di.di_atime = gfs1_dinode.di_atime;
- ip->i_di.di_mtime = gfs1_dinode.di_mtime;
- ip->i_di.di_ctime = gfs1_dinode.di_ctime;
- ip->i_di.di_major = gfs1_dinode.di_major;
- ip->i_di.di_minor = gfs1_dinode.di_minor;
- ip->i_di.di_goal_data = gfs1_dinode.di_goal_dblk;
- ip->i_di.di_goal_meta = gfs1_dinode.di_goal_mblk;
- ip->i_di.di_flags = gfs1_dinode.di_flags;
- ip->i_di.di_payload_format = gfs1_dinode.di_payload_format;
- ip->i_di.__pad1 = gfs1_dinode.di_type;
- ip->i_di.di_height = gfs1_dinode.di_height;
- ip->i_di.di_depth = gfs1_dinode.di_depth;
- ip->i_di.di_entries = gfs1_dinode.di_entries;
- ip->i_di.di_eattr = gfs1_dinode.di_eattr;
+ 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_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_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);
+ ip->i_nlink = be32_to_cpu(di->di_nlink);
+ ip->i_size = be64_to_cpu(di->di_size);
+ ip->i_blocks = be64_to_cpu(di->di_blocks);
+ ip->i_atime = be64_to_cpu(di->di_atime);
+ ip->i_mtime = be64_to_cpu(di->di_mtime);
+ ip->i_ctime = be64_to_cpu(di->di_ctime);
+ ip->i_major = be32_to_cpu(di->di_major);
+ ip->i_minor = be32_to_cpu(di->di_minor);
+ ip->i_goal_data = (uint64_t)be32_to_cpu(di->di_goal_dblk);
+ 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_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);
+ ip->i_eattr = be64_to_cpu(di->di_eattr);
ip->i_sbd = sdp;
return ip;
}
struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp, char *buf)
{
- return __gfs_inode_get(sdp, buf, 0);
+ return __gfs_inode_get(sdp, buf);
}
struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
@@ -329,7 +301,7 @@ struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
brelse(bh);
return NULL;
}
- ip = __gfs_inode_get(sdp, bh->b_data, di_addr);
+ ip = __gfs_inode_get(sdp, bh->b_data);
ip->i_bh = bh;
ip->bh_owned = 1;
return ip;
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index 3faa5abd..da35b990 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -162,7 +162,7 @@ static uint64_t ast_lookup_path(char *path, struct gfs2_sbd *sbd)
while (ip != NULL) {
if (segment == NULL) { // No more segments
- bn = ip->i_di.di_num.no_addr;
+ bn = ip->i_addr;
inode_put(&ip);
return bn;
}
@@ -221,7 +221,7 @@ static uint64_t ast_lookup_id(const char *id, struct gfs2_sbd *sbd)
bn = sbd->sd_sb.sb_root_dir.no_addr;
break;
case ID_RINDEX:
- bn = sbd->md.riinode->i_di.di_num.no_addr;
+ bn = sbd->md.riinode->i_addr;
break;
default:
return 0;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index feace819..cefb60c8 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -221,11 +221,45 @@ struct gfs2_buffer_head {
};
struct gfs2_inode {
- struct gfs2_dinode i_di;
struct gfs2_buffer_head *i_bh;
struct gfs2_sbd *i_sbd;
struct rgrp_tree *i_rgd; /* performance hint */
int bh_owned; /* Is this bh owned, iow, should we release it later? */
+
+ /* Native-endian versions of the dinode fields */
+ uint32_t i_magic;
+ uint32_t i_type;
+ uint32_t i_format;
+ uint64_t i_formal_ino;
+ uint64_t i_addr;
+ uint32_t i_mode;
+ uint32_t i_uid;
+ uint32_t i_gid;
+ uint32_t i_nlink;
+ uint64_t i_size;
+ uint64_t i_blocks;
+ uint64_t i_atime;
+ uint64_t i_mtime;
+ 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;
};
struct master_dir
@@ -619,7 +653,7 @@ struct gfs_log_descriptor {
uint8_t ld_reserved[64];
};
-extern int is_gfs_dir(struct gfs2_dinode *dinode);
+extern int is_gfs_dir(struct gfs2_inode *ip);
extern void gfs1_lookup_block(struct gfs2_inode *ip,
struct gfs2_buffer_head *bh,
unsigned int height, struct metapath *mp,
@@ -717,8 +751,8 @@ extern void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf);
extern void gfs2_rindex_out(const struct gfs2_rindex *ri, char *buf);
extern void gfs2_rgrp_in(struct gfs2_rgrp *rg, char *buf);
extern void gfs2_rgrp_out(const struct gfs2_rgrp *rg, char *buf);
-extern void gfs2_dinode_in(struct gfs2_dinode *di, char *buf);
-extern void gfs2_dinode_out(struct gfs2_dinode *di, char *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 gfs2_leaf_in(struct gfs2_leaf *lf, char *buf);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 1dcfd7c4..59b78c3c 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -284,74 +284,86 @@ void lgfs2_quota_print(void *qp)
printbe64(q, qu_value);
}
-void gfs2_dinode_in(struct gfs2_dinode *di, char *buf)
+void lgfs2_dinode_in(struct gfs2_inode *ip, char *buf)
{
- struct gfs2_dinode *str = (struct gfs2_dinode *)buf;
-
- gfs2_meta_header_in(&di->di_header, buf);
- gfs2_inum_in(&di->di_num, (char *)&str->di_num);
-
- CPIN_32(di, str, di_mode);
- CPIN_32(di, str, di_uid);
- CPIN_32(di, str, di_gid);
- CPIN_32(di, str, di_nlink);
- CPIN_64(di, str, di_size);
- CPIN_64(di, str, di_blocks);
- CPIN_64(di, str, di_atime);
- CPIN_64(di, str, di_mtime);
- CPIN_64(di, str, di_ctime);
- CPIN_32(di, str, di_major);
- CPIN_32(di, str, di_minor);
-
- CPIN_64(di, str, di_goal_meta);
- CPIN_64(di, str, di_goal_data);
-
- CPIN_32(di, str, di_flags);
- CPIN_32(di, str, di_payload_format);
- CPIN_16(di, str, __pad1);
- CPIN_16(di, str, di_height);
-
- CPIN_16(di, str, di_depth);
- CPIN_32(di, str, di_entries);
-
- CPIN_64(di, str, di_eattr);
-
- CPIN_08(di, str, di_reserved, 32);
+ 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_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_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);
+ ip->i_nlink = be32_to_cpu(di->di_nlink);
+ ip->i_size = be64_to_cpu(di->di_size);
+ ip->i_blocks = be64_to_cpu(di->di_blocks);
+ ip->i_atime = be64_to_cpu(di->di_atime);
+ ip->i_mtime = be64_to_cpu(di->di_mtime);
+ ip->i_ctime = be64_to_cpu(di->di_ctime);
+ ip->i_major = be32_to_cpu(di->di_major);
+ ip->i_minor = be32_to_cpu(di->di_minor);
+ ip->i_goal_meta = be64_to_cpu(di->di_goal_meta);
+ ip->i_goal_data = be64_to_cpu(di->di_goal_data);
+ 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);
+ ip->i_ctime_nsec = be32_to_cpu(di->di_ctime_nsec);
}
-void gfs2_dinode_out(struct gfs2_dinode *di, char *buf)
+void lgfs2_dinode_out(struct gfs2_inode *ip, char *buf)
{
- struct gfs2_dinode *str = (struct gfs2_dinode *)buf;
-
- gfs2_meta_header_out(&di->di_header, buf);
- gfs2_inum_out(&di->di_num, (char *)&str->di_num);
-
- CPOUT_32(di, str, di_mode);
- CPOUT_32(di, str, di_uid);
- CPOUT_32(di, str, di_gid);
- CPOUT_32(di, str, di_nlink);
- CPOUT_64(di, str, di_size);
- CPOUT_64(di, str, di_blocks);
- CPOUT_64(di, str, di_atime);
- CPOUT_64(di, str, di_mtime);
- CPOUT_64(di, str, di_ctime);
- CPOUT_32(di, str, di_major);
- CPOUT_32(di, str, di_minor);
-
- CPOUT_64(di, str, di_goal_meta);
- CPOUT_64(di, str, di_goal_data);
-
- CPOUT_32(di, str, di_flags);
- CPOUT_32(di, str, di_payload_format);
- CPOUT_16(di, str, __pad1);
- CPOUT_16(di, str, di_height);
-
- CPOUT_16(di, str, di_depth);
- CPOUT_32(di, str, di_entries);
-
- CPOUT_64(di, str, di_eattr);
-
- CPOUT_08(di, str, di_reserved, 32);
+ 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_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);
+ 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);
+ di->di_nlink = cpu_to_be32(ip->i_nlink);
+ di->di_size = cpu_to_be64(ip->i_size);
+ di->di_blocks = cpu_to_be64(ip->i_blocks);
+ di->di_atime = cpu_to_be64(ip->i_atime);
+ di->di_mtime = cpu_to_be64(ip->i_mtime);
+ 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);
+ di->di_ctime_nsec = cpu_to_be32(ip->i_ctime_nsec);
}
void lgfs2_dinode_print(void *dip)
diff --git a/gfs2/libgfs2/recovery.c b/gfs2/libgfs2/recovery.c
index 429b222b..7c445f15 100644
--- a/gfs2/libgfs2/recovery.c
+++ b/gfs2/libgfs2/recovery.c
@@ -16,7 +16,7 @@
void gfs2_replay_incr_blk(struct gfs2_inode *ip, unsigned int *blk)
{
- uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
+ uint32_t jd_blocks = ip->i_size / ip->i_sbd->sd_sb.sb_bsize;
if (++*blk == jd_blocks)
*blk = 0;
@@ -116,7 +116,7 @@ static int find_good_lh(struct gfs2_inode *ip, unsigned int *blk, struct lgfs2_l
{
unsigned int orig_blk = *blk;
int error;
- uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
+ uint32_t jd_blocks = ip->i_size / ip->i_sbd->sd_sb.sb_bsize;
for (;;) {
error = lgfs2_get_log_header(ip, *blk, head);
@@ -145,7 +145,7 @@ static int find_good_lh(struct gfs2_inode *ip, unsigned int *blk, struct lgfs2_l
static int jhead_scan(struct gfs2_inode *ip, struct lgfs2_log_header *head)
{
unsigned int blk = head->lh_blkno;
- uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
+ uint32_t jd_blocks = ip->i_size / ip->i_sbd->sd_sb.sb_bsize;
struct lgfs2_log_header lh;
int error;
@@ -185,7 +185,7 @@ int lgfs2_find_jhead(struct gfs2_inode *ip, struct lgfs2_log_header *head)
{
struct lgfs2_log_header lh_1, lh_m;
uint32_t blk_1, blk_2, blk_m;
- uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
+ uint32_t jd_blocks = ip->i_size / ip->i_sbd->sd_sb.sb_bsize;
int error;
blk_1 = 0;
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index d70aeaef..562640f7 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -125,8 +125,8 @@ uint32_t lgfs2_log_header_crc(char *buf, unsigned bsize)
int lgfs2_write_journal_data(struct gfs2_inode *ip)
{
struct gfs2_sbd *sdp = ip->i_sbd;
- unsigned blocks = (ip->i_di.di_size + sdp->bsize - 1) / sdp->bsize;
- uint64_t jext0 = ip->i_di.di_num.no_addr + ip->i_di.di_blocks - blocks;
+ unsigned blocks = (ip->i_size + sdp->bsize - 1) / sdp->bsize;
+ uint64_t jext0 = ip->i_addr + ip->i_blocks - blocks;
uint64_t seq = ((blocks) * (random() / (RAND_MAX + 1.0)));
struct gfs2_log_header *lh;
uint64_t jblk = jext0;
@@ -141,7 +141,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_di.di_num.no_addr);
+ lh->lh_jinode = cpu_to_be64(ip->i_addr);
crc32c_optimization_init();
do {
@@ -178,7 +178,7 @@ static struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn
uint64_t dbn;
int new = 1;
- if (ip->i_di.di_height == 0)
+ if (ip->i_height == 0)
unstuff_dinode(ip);
block_map(ip, lbn, &new, &dbn, NULL, prealloc);
@@ -186,11 +186,11 @@ static struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn
return NULL;
if (!prealloc && new &&
- ip->i_di.di_size < (lbn + 1) << sdp->sd_sb.sb_bsize_shift) {
+ ip->i_size < (lbn + 1) << sdp->sd_sb.sb_bsize_shift) {
bmodified(ip->i_bh);
- ip->i_di.di_size = (lbn + 1) << sdp->sd_sb.sb_bsize_shift;
+ ip->i_size = (lbn + 1) << sdp->sd_sb.sb_bsize_shift;
}
- if (dbn == ip->i_di.di_num.no_addr)
+ if (dbn == ip->i_addr)
return ip->i_bh;
else
return bread(sdp, dbn);
@@ -228,7 +228,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_di.di_num.no_addr);
+ lh->lh_jinode = cpu_to_be64(jnl->i_addr);
lh->lh_sequence = cpu_to_be64(seq);
lh->lh_blkno = cpu_to_be32(x);
@@ -346,8 +346,8 @@ int build_inum_range(struct gfs2_inode *per_node, unsigned int j)
if (ip == NULL) {
return errno;
}
- ip->i_di.di_size = sizeof(struct gfs2_inum_range);
- gfs2_dinode_out(&ip->i_di, ip->i_bh->b_data);
+ ip->i_size = sizeof(struct gfs2_inum_range);
+ lgfs2_dinode_out(ip, ip->i_bh->b_data);
bmodified(ip->i_bh);
if (cfg_debug) {
printf("\nInum Range %u:\n", j);
@@ -369,8 +369,8 @@ int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
if (ip == NULL) {
return errno;
}
- ip->i_di.di_size = sizeof(struct gfs2_statfs_change);
- gfs2_dinode_out(&ip->i_di, ip->i_bh->b_data);
+ ip->i_size = sizeof(struct gfs2_statfs_change);
+ lgfs2_dinode_out(ip, ip->i_bh->b_data);
bmodified(ip->i_bh);
if (cfg_debug) {
printf("\nStatFS Change %u:\n", j);
@@ -513,7 +513,7 @@ int build_rindex(struct gfs2_sbd *sdp)
if (ip == NULL) {
return errno;
}
- ip->i_di.di_payload_format = GFS2_FORMAT_RI;
+ ip->i_payload_format = GFS2_FORMAT_RI;
bmodified(ip->i_bh);
for (n = osi_first(&sdp->rgtree); n; n = next) {
@@ -522,14 +522,12 @@ int build_rindex(struct gfs2_sbd *sdp)
gfs2_rindex_out(&rl->ri, buf);
- count = gfs2_writei(ip, buf, ip->i_di.di_size,
- sizeof(struct gfs2_rindex));
+ count = gfs2_writei(ip, buf, ip->i_size, sizeof(struct gfs2_rindex));
if (count != sizeof(struct gfs2_rindex))
return -1;
}
memset(buf, 0, sizeof(struct gfs2_rindex));
- count = __gfs2_writei(ip, buf, ip->i_di.di_size,
- sizeof(struct gfs2_rindex), 0);
+ count = __gfs2_writei(ip, buf, ip->i_size, sizeof(struct gfs2_rindex), 0);
if (count != sizeof(struct gfs2_rindex))
return -1;
@@ -553,16 +551,16 @@ int build_quota(struct gfs2_sbd *sdp)
if (ip == NULL) {
return errno;
}
- ip->i_di.di_payload_format = GFS2_FORMAT_QU;
+ ip->i_payload_format = GFS2_FORMAT_QU;
bmodified(ip->i_bh);
memset(&qu, 0, sizeof(struct gfs2_quota));
qu.qu_value = cpu_to_be64(1);
- count = gfs2_writei(ip, &qu, ip->i_di.di_size, sizeof(struct gfs2_quota));
+ count = gfs2_writei(ip, &qu, ip->i_size, sizeof(struct gfs2_quota));
if (count != sizeof(struct gfs2_quota))
return -1;
- count = gfs2_writei(ip, &qu, ip->i_di.di_size, sizeof(struct gfs2_quota));
+ count = gfs2_writei(ip, &qu, ip->i_size, sizeof(struct gfs2_quota));
if (count != sizeof(struct gfs2_quota))
return -1;
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index bf65b127..e8ade2e2 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -207,7 +207,7 @@ int rindex_read(struct gfs2_sbd *sdp, uint64_t *rgcount, int *ok)
*ok = 1;
*rgcount = 0;
- if (sdp->md.riinode->i_di.di_size % sizeof(struct gfs2_rindex))
+ if (sdp->md.riinode->i_size % sizeof(struct gfs2_rindex))
*ok = 0; /* rindex file size must be a multiple of 96 */
for (rg = 0; ; rg++) {
error = gfs2_readi(sdp->md.riinode, (char *)&buf.bufgfs2,
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 19b248d2..32211db7 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -867,7 +867,7 @@ static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_o
return result;
}
/* Allocate at the beginning of the rgrp, bypassing extent search */
- in.i_di.di_num.no_addr = lgfs2_rgrp_index(rg)->ri_data0;
+ in.i_addr = lgfs2_rgrp_index(rg)->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 */
@@ -894,7 +894,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] = in.i_di.di_num;
+ mkfs_journals[j].no_addr = in.i_addr;
+ mkfs_journals[j].no_formal_ino = in.i_formal_ino;
}
gfs2_progress_close(&progress, _("Done\n"));
@@ -1197,7 +1198,8 @@ int main(int argc, char *argv[])
fprintf(stderr, _("Error building '%s': %s\n"), "master", strerror(errno));
exit(EXIT_FAILURE);
}
- sb.sb_master_dir = sbd.master_dir->i_di.di_num;
+ sb.sb_master_dir.no_addr = sbd.master_dir->i_addr;
+ sb.sb_master_dir.no_formal_ino = sbd.master_dir->i_formal_ino;
error = lgfs2_build_jindex(sbd.master_dir, mkfs_journals, opts.journals);
if (error) {
@@ -1240,7 +1242,8 @@ int main(int argc, char *argv[])
printf("%s", _("Done\n"));
build_root(&sbd);
- sb.sb_root_dir = sbd.md.rooti->i_di.di_num;
+ sb.sb_root_dir.no_addr = sbd.md.rooti->i_addr;
+ sb.sb_root_dir.no_formal_ino = sbd.md.rooti->i_formal_ino;
strncpy(sb.sb_lockproto, opts.lockproto, GFS2_LOCKNAME_LEN - 1);
strncpy(sb.sb_locktable, opts.locktable, GFS2_LOCKNAME_LEN - 1);
diff --git a/tests/nukerg.c b/tests/nukerg.c
index f2018fbf..f323d643 100644
--- a/tests/nukerg.c
+++ b/tests/nukerg.c
@@ -260,7 +260,7 @@ static lgfs2_rgrps_t read_rindex(struct gfs2_sbd *sdp)
strerror(errno));
return NULL;
}
- rgcount = sdp->md.riinode->i_di.di_size / sizeof(struct gfs2_rindex);
+ rgcount = sdp->md.riinode->i_size / sizeof(struct gfs2_rindex);
for (i = 0; i < rgcount; i++) {
const struct gfs2_rindex *ri;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 06/27: libgfs2: Remove gfs2_dinode_print()
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 708154bf81a7cc557a0779db8c2432677a703ad3
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon May 10 14:28:15 2021 +0100
libgfs2: Remove gfs2_dinode_print()
Convert users to lgfs2_dinode_print() except the one in mkfs.gfs2 as we
don't have a big-endian dinode easily available. That one will be added
back once ip.i_di endianness mismatches have been resolved.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/libgfs2.h | 1 -
gfs2/libgfs2/ondisk.c | 30 ------------------------------
gfs2/libgfs2/structures.c | 22 +++++++++++-----------
gfs2/mkfs/main_mkfs.c | 3 ---
4 files changed, 11 insertions(+), 45 deletions(-)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 2c4b856e..feace819 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -729,7 +729,6 @@ extern void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf);
extern void gfs2_inum_print(const struct gfs2_inum *no);
extern void gfs2_meta_header_print(const struct gfs2_meta_header *mh);
extern void gfs2_rindex_print(const struct gfs2_rindex *ri);
-extern void gfs2_dinode_print(const struct gfs2_dinode *di);
/* These expect on-disk data instead of native-endian structs */
extern void lgfs2_inum_print(void *nop);
extern void lgfs2_meta_header_print(void *mhp);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 0387f196..1dcfd7c4 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -354,36 +354,6 @@ void gfs2_dinode_out(struct gfs2_dinode *di, char *buf)
CPOUT_08(di, str, di_reserved, 32);
}
-void gfs2_dinode_print(const struct gfs2_dinode *di)
-{
- gfs2_meta_header_print(&di->di_header);
- gfs2_inum_print(&di->di_num);
-
- pv(di, di_mode, "0%"PRIo32, NULL);
- pv(di, di_uid, "%"PRIu32, "0x%"PRIx32);
- pv(di, di_gid, "%"PRIu32, "0x%"PRIx32);
- pv(di, di_nlink, "%"PRIu32, "0x%"PRIx32);
- pv(di, di_size, "%"PRIu64, "0x%"PRIx64);
- pv(di, di_blocks, "%"PRIu64, "0x%"PRIx64);
- pv(di, di_atime, "%"PRIu64, "0x%"PRIx64);
- pv(di, di_mtime, "%"PRIu64, "0x%"PRIx64);
- pv(di, di_ctime, "%"PRIu64, "0x%"PRIx64);
- pv(di, di_major, "%"PRIu32, "0x%"PRIx32);
- pv(di, di_minor, "%"PRIu32, "0x%"PRIx32);
-
- pv(di, di_goal_meta, "%"PRIu64, "0x%"PRIx64);
- pv(di, di_goal_data, "%"PRIu64, "0x%"PRIx64);
-
- pv(di, di_flags, "0x%.8"PRIX32, NULL);
- pv(di, di_payload_format, "%"PRIu32, "0x%"PRIx32);
- pv(di, di_height, "%"PRIu16, "0x%"PRIx16);
-
- pv(di, di_depth, "%"PRIu16, "0x%"PRIx16);
- pv(di, di_entries, "%"PRIu32, "0x%"PRIx32);
-
- pv(di, di_eattr, "%"PRIu64, "0x%"PRIx64);
-}
-
void lgfs2_dinode_print(void *dip)
{
struct gfs2_dinode *di = dip;
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 4ef4e685..d70aeaef 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -40,7 +40,7 @@ int build_master(struct gfs2_sbd *sdp)
if (cfg_debug) {
printf("\nMaster dir:\n");
- gfs2_dinode_print(&sdp->master_dir->i_di);
+ lgfs2_dinode_print(bh->b_data);
}
sdp->master_dir->bh_owned = 1;
return 0;
@@ -299,7 +299,7 @@ int lgfs2_build_jindex(struct gfs2_inode *master, struct gfs2_inum *jnls, size_t
if (cfg_debug) {
printf("\nJindex:\n");
- gfs2_dinode_print(&jindex->i_di);
+ lgfs2_dinode_print(jindex->i_bh->b_data);
}
inode_put(&jindex);
@@ -327,7 +327,7 @@ int build_jindex(struct gfs2_sbd *sdp)
}
if (cfg_debug) {
printf("\nJindex:\n");
- gfs2_dinode_print(&jindex->i_di);
+ lgfs2_dinode_print(jindex->i_bh->b_data);
}
free(sdp->md.journal);
@@ -351,7 +351,7 @@ int build_inum_range(struct gfs2_inode *per_node, unsigned int j)
bmodified(ip->i_bh);
if (cfg_debug) {
printf("\nInum Range %u:\n", j);
- gfs2_dinode_print(&ip->i_di);
+ lgfs2_dinode_print(ip->i_bh->b_data);
}
inode_put(&ip);
@@ -374,7 +374,7 @@ int build_statfs_change(struct gfs2_inode *per_node, unsigned int j)
bmodified(ip->i_bh);
if (cfg_debug) {
printf("\nStatFS Change %u:\n", j);
- gfs2_dinode_print(&ip->i_di);
+ lgfs2_dinode_print(ip->i_bh->b_data);
}
inode_put(&ip);
@@ -419,7 +419,7 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
if (cfg_debug) {
printf("\nQuota Change %u:\n", j);
- gfs2_dinode_print(&ip->i_di);
+ lgfs2_dinode_print(ip->i_bh->b_data);
}
inode_put(&ip);
@@ -455,7 +455,7 @@ int build_per_node(struct gfs2_sbd *sdp)
if (cfg_debug) {
printf("\nper_node:\n");
- gfs2_dinode_print(&per_node->i_di);
+ lgfs2_dinode_print(per_node->i_bh->b_data);
}
inode_put(&per_node);
@@ -474,7 +474,7 @@ int build_inum(struct gfs2_sbd *sdp)
if (cfg_debug) {
printf("\nInum Inode:\n");
- gfs2_dinode_print(&ip->i_di);
+ lgfs2_dinode_print(ip->i_bh->b_data);
}
inode_put(&ip);
@@ -493,7 +493,7 @@ int build_statfs(struct gfs2_sbd *sdp)
if (cfg_debug) {
printf("\nStatFS Inode:\n");
- gfs2_dinode_print(&ip->i_di);
+ lgfs2_dinode_print(ip->i_bh->b_data);
}
inode_put(&ip);
@@ -535,7 +535,7 @@ int build_rindex(struct gfs2_sbd *sdp)
if (cfg_debug) {
printf("\nResource Index:\n");
- gfs2_dinode_print(&ip->i_di);
+ lgfs2_dinode_print(ip->i_bh->b_data);
}
inode_put(&ip);
@@ -598,7 +598,7 @@ int build_root(struct gfs2_sbd *sdp)
if (cfg_debug) {
printf("\nRoot directory:\n");
- gfs2_dinode_print(&sdp->md.rooti->i_di);
+ lgfs2_dinode_print(bh->b_data);
}
sdp->md.rooti->bh_owned = 1;
return 0;
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 2400cc8e..19b248d2 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -877,9 +877,6 @@ static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_o
return result;
}
- if (opts->debug)
- gfs2_dinode_print(&in.i_di);
-
result = place_rgrp(sdp, rg, opts->debug);
if (result != 0)
return result;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 05/27: libgfs2: Add a cpu-endian log header struct
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 9402792a83efa505e573e1ada9ec96258a12e1ca
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon May 10 10:32:44 2021 +0100
libgfs2: Add a cpu-endian log header struct
This allows gfs2_log_header_{in,out} to be removed and replaced with a
smaller, static log_header_in() function.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/extended.c | 4 ++--
gfs2/fsck/fs_recovery.c | 23 +++++++++++------------
gfs2/libgfs2/libgfs2.h | 22 ++++++++++++++++------
gfs2/libgfs2/ondisk.c | 44 --------------------------------------------
gfs2/libgfs2/recovery.c | 40 ++++++++++++++++++++++++++++------------
5 files changed, 57 insertions(+), 76 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 4e8a003d..c977b6e1 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -473,7 +473,7 @@ static int print_gfs_jindex(struct gfs2_inode *dij)
static int print_gfs2_jindex(void)
{
int d, error;
- struct gfs2_log_header head;
+ struct lgfs2_log_header head;
struct gfs2_inode *ip;
for (d = 0; d < indirect->ii[0].dirents; d++) {
@@ -484,7 +484,7 @@ static int print_gfs2_jindex(void)
indirect->ii[0].dirent[d].filename,
indirect->ii[0].dirent[d].block,
ip->i_di.di_size / 1048576);
- error = gfs2_find_jhead(ip, &head);
+ error = lgfs2_find_jhead(ip, &head);
if (error) {
print_gfs2("corrupt.");
} else {
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index c7704b0e..ac187853 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -337,9 +337,9 @@ static int foreach_descriptor(struct gfs2_inode *ip, unsigned int start,
length = be32_to_cpu(ld->ld_length);
if (be32_to_cpu(ld->ld_header.mh_type) == GFS2_METATYPE_LH) {
- struct gfs2_log_header lh;
+ struct lgfs2_log_header lh;
- error = get_log_header(ip, start, &lh);
+ error = lgfs2_get_log_header(ip, start, &lh);
if (!error) {
gfs2_replay_incr_blk(ip, &start);
bmodified(bh);
@@ -401,7 +401,7 @@ static int check_journal_seq_no(struct gfs2_inode *ip, int fix)
int error = 0, wrapped = 0;
uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
uint32_t blk;
- struct gfs2_log_header lh;
+ struct lgfs2_log_header lh;
uint64_t highest_seq = 0, lowest_seq = 0, prev_seq = 0;
int new = 0;
uint64_t dblock;
@@ -410,7 +410,7 @@ static int check_journal_seq_no(struct gfs2_inode *ip, int fix)
memset(&lh, 0, sizeof(lh));
for (blk = 0; blk < jd_blocks; blk++) {
- error = get_log_header(ip, blk, &lh);
+ error = lgfs2_get_log_header(ip, blk, &lh);
if (error == 1) /* if not a log header */
continue; /* just journal data--ignore it */
if (!lowest_seq || lh.lh_sequence < lowest_seq)
@@ -436,12 +436,11 @@ static int check_journal_seq_no(struct gfs2_inode *ip, int fix)
if (!fix)
continue;
highest_seq++;
- lh.lh_sequence = highest_seq;
- prev_seq = lh.lh_sequence;
- log_warn(_("Renumbering it as 0x%"PRIx64"\n"), lh.lh_sequence);
+ prev_seq = highest_seq;
+ log_warn(_("Renumbering it as 0x%"PRIx64"\n"), highest_seq);
block_map(ip, blk, &new, &dblock, NULL, 0);
bh = bread(ip->i_sbd, dblock);
- gfs2_log_header_out(&lh, bh->b_data);
+ ((struct gfs2_log_header *)bh->b_data)->lh_sequence = cpu_to_be64(highest_seq);
bmodified(bh);
brelse(bh);
}
@@ -492,7 +491,7 @@ static int gfs2_recover_journal(struct gfs2_inode *ip, int j, int preen,
int force_check, int *was_clean)
{
struct gfs2_sbd *sdp = ip->i_sbd;
- struct gfs2_log_header head;
+ struct lgfs2_log_header head;
unsigned int pass;
int error;
@@ -500,7 +499,7 @@ static int gfs2_recover_journal(struct gfs2_inode *ip, int j, int preen,
log_info( _("jid=%u: Looking at journal...\n"), j);
osi_list_init(&sd_revoke_list);
- error = gfs2_find_jhead(ip, &head);
+ error = lgfs2_find_jhead(ip, &head);
if (!error) {
error = check_journal_seq_no(ip, 0);
if (error > JOURNAL_SEQ_TOLERANCE) {
@@ -541,7 +540,7 @@ static int gfs2_recover_journal(struct gfs2_inode *ip, int j, int preen,
j);
goto out;
}
- error = gfs2_find_jhead(ip, &head);
+ error = lgfs2_find_jhead(ip, &head);
if (error) {
log_err( _("jid=%u: Unable to fix the bad journal.\n"),
j);
@@ -591,7 +590,7 @@ static int gfs2_recover_journal(struct gfs2_inode *ip, int j, int preen,
}
log_info( _("jid=%u: Found %u revoke tags\n"), j, sd_found_revokes);
gfs2_revoke_clean(sdp);
- error = clean_journal(ip, &head);
+ error = lgfs2_clean_journal(ip, &head);
if (error)
goto out;
log_err( _("jid=%u: Replayed %u of %u journaled data blocks\n"),
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 922d35f8..2c4b856e 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -299,6 +299,18 @@ struct gfs2_sbd {
int gfs1;
};
+struct lgfs2_log_header {
+ uint64_t lh_sequence;
+ uint32_t lh_flags;
+ uint32_t lh_tail;
+ uint32_t lh_blkno;
+ uint32_t lh_hash;
+ uint32_t lh_crc;
+ int64_t lh_local_total;
+ int64_t lh_local_free;
+ int64_t lh_local_dinodes;
+};
+
struct metapath {
unsigned int mp_list[GFS2_MAX_META_HEIGHT];
};
@@ -638,10 +650,10 @@ extern int gfs2_revoke_add(struct gfs2_sbd *sdp, uint64_t blkno, unsigned int wh
extern int gfs2_revoke_check(struct gfs2_sbd *sdp, uint64_t blkno,
unsigned int where);
extern void gfs2_revoke_clean(struct gfs2_sbd *sdp);
-extern int get_log_header(struct gfs2_inode *ip, unsigned int blk,
- struct gfs2_log_header *head);
-extern int gfs2_find_jhead(struct gfs2_inode *ip, struct gfs2_log_header *head);
-extern int clean_journal(struct gfs2_inode *ip, struct gfs2_log_header *head);
+extern int lgfs2_get_log_header(struct gfs2_inode *ip, unsigned int blk,
+ struct lgfs2_log_header *head);
+extern int lgfs2_find_jhead(struct gfs2_inode *ip, struct lgfs2_log_header *head);
+extern int lgfs2_clean_journal(struct gfs2_inode *ip, struct lgfs2_log_header *head);
/* rgrp.c */
extern int gfs2_compute_bitstructs(const uint32_t bsize, struct rgrp_tree *rgd);
@@ -711,8 +723,6 @@ extern void gfs2_dirent_in(struct gfs2_dirent *de, char *buf);
extern void gfs2_dirent_out(struct gfs2_dirent *de, char *buf);
extern void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf);
extern void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf);
-extern void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf);
-extern void gfs2_log_header_out(struct gfs2_log_header *lh, char *buf);
/* Printing functions */
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 286f55ac..0387f196 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -507,50 +507,6 @@ void lgfs2_ea_header_print(void *eap)
print_it(" name", "%s", NULL, buf);
}
-void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf)
-{
- struct gfs2_log_header *str = (struct gfs2_log_header *)buf;
-
- gfs2_meta_header_in(&lh->lh_header, buf);
- CPIN_64(lh, str, lh_sequence);
- CPIN_32(lh, str, lh_flags);
- CPIN_32(lh, str, lh_tail);
- CPIN_32(lh, str, lh_blkno);
- CPIN_32(lh, str, lh_hash);
- CPIN_32(lh, str, lh_crc);
- CPIN_32(lh, str, lh_nsec);
- CPIN_64(lh, str, lh_sec);
- CPIN_64(lh, str, lh_addr);
- CPIN_64(lh, str, lh_jinode);
- CPIN_64(lh, str, lh_statfs_addr);
- CPIN_64(lh, str, lh_quota_addr);
- CPIN_64(lh, str, lh_local_total);
- CPIN_64(lh, str, lh_local_free);
- CPIN_64(lh, str, lh_local_dinodes);
-}
-
-void gfs2_log_header_out(struct gfs2_log_header *lh, char *buf)
-{
- struct gfs2_log_header *str = (struct gfs2_log_header *)buf;
-
- gfs2_meta_header_out(&lh->lh_header, buf);
- CPOUT_64(lh, str, lh_sequence);
- CPOUT_32(lh, str, lh_flags);
- CPOUT_32(lh, str, lh_tail);
- CPOUT_32(lh, str, lh_blkno);
- CPOUT_32(lh, str, lh_hash);
- CPOUT_32(lh, str, lh_crc);
- CPOUT_32(lh, str, lh_nsec);
- CPOUT_64(lh, str, lh_sec);
- CPOUT_64(lh, str, lh_addr);
- CPOUT_64(lh, str, lh_jinode);
- CPOUT_64(lh, str, lh_statfs_addr);
- CPOUT_64(lh, str, lh_quota_addr);
- CPOUT_64(lh, str, lh_local_total);
- CPOUT_64(lh, str, lh_local_free);
- CPOUT_64(lh, str, lh_local_dinodes);
-}
-
void lgfs2_log_header_print(void *lhp)
{
struct gfs2_log_header *lh = lhp;
diff --git a/gfs2/libgfs2/recovery.c b/gfs2/libgfs2/recovery.c
index 78136ac2..429b222b 100644
--- a/gfs2/libgfs2/recovery.c
+++ b/gfs2/libgfs2/recovery.c
@@ -36,6 +36,21 @@ int gfs2_replay_read_block(struct gfs2_inode *ip, unsigned int blk,
return 0;
}
+static void log_header_in(struct lgfs2_log_header *lh, char *buf)
+{
+ struct gfs2_log_header *lhd = (struct gfs2_log_header *)buf;
+
+ lh->lh_sequence = be64_to_cpu(lhd->lh_sequence);
+ lh->lh_flags = be32_to_cpu(lhd->lh_flags);
+ lh->lh_tail = be32_to_cpu(lhd->lh_tail);
+ lh->lh_blkno = be32_to_cpu(lhd->lh_blkno);
+ lh->lh_hash = be32_to_cpu(lhd->lh_hash);
+ lh->lh_crc = be32_to_cpu(lhd->lh_crc);
+ lh->lh_local_total = be64_to_cpu(lhd->lh_local_total);
+ lh->lh_local_free = be64_to_cpu(lhd->lh_local_free);
+ lh->lh_local_dinodes = be64_to_cpu(lhd->lh_local_dinodes);
+}
+
/**
* get_log_header - read the log header for a given segment
* @ip: the journal incore inode
@@ -50,11 +65,12 @@ int gfs2_replay_read_block(struct gfs2_inode *ip, unsigned int blk,
* errno on error
*/
-int get_log_header(struct gfs2_inode *ip, unsigned int blk,
- struct gfs2_log_header *head)
+int lgfs2_get_log_header(struct gfs2_inode *ip, unsigned int blk,
+ struct lgfs2_log_header *head)
{
struct gfs2_buffer_head *bh;
- struct gfs2_log_header lh, *tmp;
+ struct lgfs2_log_header lh;
+ struct gfs2_log_header *tmp;
uint32_t hash, saved_hash;
uint32_t lh_crc = 0;
uint32_t crc;
@@ -70,7 +86,7 @@ int get_log_header(struct gfs2_inode *ip, unsigned int blk,
hash = lgfs2_log_header_hash(bh->b_data);
tmp->lh_hash = saved_hash;
crc = lgfs2_log_header_crc(bh->b_data, ip->i_sbd->bsize);
- gfs2_log_header_in(&lh, bh->b_data);
+ log_header_in(&lh, bh->b_data);
brelse(bh);
lh_crc = lh.lh_crc;
if (error || lh.lh_blkno != blk || lh.lh_hash != hash)
@@ -96,14 +112,14 @@ int get_log_header(struct gfs2_inode *ip, unsigned int blk,
*
* Returns: errno
*/
-static int find_good_lh(struct gfs2_inode *ip, unsigned int *blk, struct gfs2_log_header *head)
+static int find_good_lh(struct gfs2_inode *ip, unsigned int *blk, struct lgfs2_log_header *head)
{
unsigned int orig_blk = *blk;
int error;
uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
for (;;) {
- error = get_log_header(ip, *blk, head);
+ error = lgfs2_get_log_header(ip, *blk, head);
if (error <= 0)
return error;
@@ -126,18 +142,18 @@ static int find_good_lh(struct gfs2_inode *ip, unsigned int *blk, struct gfs2_lo
* Returns: errno
*/
-static int jhead_scan(struct gfs2_inode *ip, struct gfs2_log_header *head)
+static int jhead_scan(struct gfs2_inode *ip, struct lgfs2_log_header *head)
{
unsigned int blk = head->lh_blkno;
uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
- struct gfs2_log_header lh;
+ struct lgfs2_log_header lh;
int error;
for (;;) {
if (++blk == jd_blocks)
blk = 0;
- error = get_log_header(ip, blk, &lh);
+ error = lgfs2_get_log_header(ip, blk, &lh);
if (error < 0)
return error;
if (error == 1)
@@ -165,9 +181,9 @@ static int jhead_scan(struct gfs2_inode *ip, struct gfs2_log_header *head)
* Returns: errno
*/
-int gfs2_find_jhead(struct gfs2_inode *ip, struct gfs2_log_header *head)
+int lgfs2_find_jhead(struct gfs2_inode *ip, struct lgfs2_log_header *head)
{
- struct gfs2_log_header lh_1, lh_m;
+ struct lgfs2_log_header lh_1, lh_m;
uint32_t blk_1, blk_2, blk_m;
uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
int error;
@@ -213,7 +229,7 @@ int gfs2_find_jhead(struct gfs2_inode *ip, struct gfs2_log_header *head)
* Returns: errno
*/
-int clean_journal(struct gfs2_inode *ip, struct gfs2_log_header *head)
+int lgfs2_clean_journal(struct gfs2_inode *ip, struct lgfs2_log_header *head)
{
unsigned int lblock;
struct gfs2_log_header *lh;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 04/27: gfs2_edit: Clean up display_gfs2()
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 f061b55fbcc3e7d829fca00b28eb21a2897655f6
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon May 10 09:35:36 2021 +0100
gfs2_edit: Clean up display_gfs2()
Now that we have big endian printing functions the gfs2_meta_header_in()
call in display_gfs2() can be removed. Rearrange the function to remove
a level of nesting and an unnecessary switch statement and group the
cases that all call lgfs2_meta_header_print().
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/gfs2hex.c | 132 +++++++++++++++++++++-------------------------------
gfs2/edit/gfs2hex.h | 2 +-
gfs2/edit/hexedit.h | 1 -
3 files changed, 55 insertions(+), 80 deletions(-)
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 4c3426db..092b35b6 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -393,94 +393,70 @@ static void gfs_sb_print(void *sbp)
lgfs2_inum_print(&sb->sb_license_di);
}
-int display_gfs2(char *buf)
+void display_gfs2(void *buf)
{
- struct gfs2_meta_header mh;
-
+ struct gfs2_meta_header *mh = buf;
uint32_t magic;
+ uint32_t type;
- magic = be32_to_cpu(*(uint32_t *)buf);
+ magic = be32_to_cpu(mh->mh_magic);
+ type = be32_to_cpu(mh->mh_type);
- switch (magic)
- {
- case GFS2_MAGIC:
- gfs2_meta_header_in(&mh, buf);
- if (mh.mh_type > GFS2_METATYPE_QC)
- print_gfs2("Unknown metadata type");
- else
- print_gfs2("%s:", block_type_str[mh.mh_type]);
+ if (magic != GFS2_MAGIC) {
+ print_gfs2("Unknown block type");
eol(0);
+ return;
+ }
- switch (mh.mh_type)
- {
- case GFS2_METATYPE_SB:
- if (sbd.gfs1)
- gfs_sb_print(buf);
- else
- lgfs2_sb_print(buf);
- break;
- case GFS2_METATYPE_RG:
- if (sbd.gfs1)
- gfs_rgrp_print(buf);
- else
- lgfs2_rgrp_print(buf);
- break;
-
- case GFS2_METATYPE_RB:
- gfs2_meta_header_print(&mh);
- break;
-
- case GFS2_METATYPE_DI:
- lgfs2_dinode_print(di);
- break;
- case GFS2_METATYPE_IN:
- gfs2_meta_header_print(&mh);
- break;
-
- case GFS2_METATYPE_LF:
- lgfs2_leaf_print(buf);
- break;
-
- case GFS2_METATYPE_JD:
- gfs2_meta_header_print(&mh);
- break;
-
- case GFS2_METATYPE_LH:
- if (sbd.gfs1)
- gfs_log_header_print(buf);
- else
- lgfs2_log_header_print(buf);
- break;
-
- case GFS2_METATYPE_LD:
- lgfs2_log_descriptor_print(buf);
- break;
-
- case GFS2_METATYPE_EA:
- do_eattr_extended(buf);
- break;
-
- case GFS2_METATYPE_ED:
- gfs2_meta_header_print(&mh);
- break;
-
- case GFS2_METATYPE_LB:
- gfs2_meta_header_print(&mh);
- break;
-
- case GFS2_METATYPE_QC:
- lgfs2_quota_change_print(buf);
- break;
+ if (type <= GFS2_METATYPE_QC)
+ print_gfs2("%s:", block_type_str[type]);
+ eol(0);
- default:
- break;
- }
+ switch (type)
+ {
+ case GFS2_METATYPE_SB:
+ if (sbd.gfs1)
+ gfs_sb_print(buf);
+ else
+ lgfs2_sb_print(buf);
+ break;
+ case GFS2_METATYPE_RG:
+ if (sbd.gfs1)
+ gfs_rgrp_print(buf);
+ else
+ lgfs2_rgrp_print(buf);
+ break;
+ case GFS2_METATYPE_DI:
+ lgfs2_dinode_print(di);
+ break;
+ case GFS2_METATYPE_LF:
+ lgfs2_leaf_print(buf);
+ break;
+ case GFS2_METATYPE_LH:
+ if (sbd.gfs1)
+ gfs_log_header_print(buf);
+ else
+ lgfs2_log_header_print(buf);
+ break;
+ case GFS2_METATYPE_LD:
+ lgfs2_log_descriptor_print(buf);
+ break;
+ case GFS2_METATYPE_EA:
+ do_eattr_extended(buf);
+ break;
+ case GFS2_METATYPE_QC:
+ lgfs2_quota_change_print(buf);
+ break;
+ case GFS2_METATYPE_RB:
+ case GFS2_METATYPE_IN:
+ case GFS2_METATYPE_JD:
+ case GFS2_METATYPE_ED:
+ case GFS2_METATYPE_LB:
+ lgfs2_meta_header_print(mh);
break;
-
default:
print_gfs2("Unknown block type");
eol(0);
break;
- };
- return(0);
+ }
}
diff --git a/gfs2/edit/gfs2hex.h b/gfs2/edit/gfs2hex.h
index 23b1fc60..a86e3a4c 100644
--- a/gfs2/edit/gfs2hex.h
+++ b/gfs2/edit/gfs2hex.h
@@ -3,7 +3,7 @@
#include "hexedit.h"
-extern int display_gfs2(char *buf);
+extern void display_gfs2(void *buf);
extern int edit_gfs2(void);
extern void do_dinode_extended(char *buf);
extern void print_gfs2(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index cb3343d0..b0ca1fba 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -58,7 +58,6 @@ extern WINDOW *wind;
extern int editing;
extern uint64_t temp_blk;
extern uint64_t starting_blk;
-extern const char *block_type_str[15];
extern int dsplines;
extern int dsp_lines[DMODES];
extern int combined_display;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 03/27: libgfs2: Fix endianness mismatches for struct
gfs2_log_header
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 0ea3292679a2991c6407d46d94c38a374cccd330
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon May 10 08:41:13 2021 +0100
libgfs2: Fix endianness mismatches for struct gfs2_log_header
Convert gfs2_log_header_print to accept big-endian data and remove a
bunch of uses of gfs2_log_header_{in,out}. Not all of them can be
removed as some the journal recovery deeply depends on it so that will
require a different approach.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/gfs2hex.c | 13 +++-----
gfs2/edit/hexedit.c | 40 ++++++------------------
gfs2/edit/hexedit.h | 3 +-
gfs2/edit/journal.c | 77 +++++++++++++++++++++++------------------------
gfs2/edit/savemeta.c | 31 ++++++++++---------
gfs2/libgfs2/libgfs2.h | 2 +-
gfs2/libgfs2/ondisk.c | 38 ++++++++++++-----------
gfs2/libgfs2/structures.c | 76 +++++++++++++++++++++-------------------------
gfs2/mkfs/main_jadd.c | 43 ++++++++++++++------------
9 files changed, 149 insertions(+), 174 deletions(-)
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 9d5eff71..4c3426db 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -396,8 +396,6 @@ static void gfs_sb_print(void *sbp)
int display_gfs2(char *buf)
{
struct gfs2_meta_header mh;
- struct gfs_log_header lh1;
- struct gfs2_log_header lh;
uint32_t magic;
@@ -448,13 +446,10 @@ int display_gfs2(char *buf)
break;
case GFS2_METATYPE_LH:
- if (sbd.gfs1) {
- gfs_log_header_in(&lh1, buf);
- gfs_log_header_print(&lh1);
- } else {
- gfs2_log_header_in(&lh, buf);
- gfs2_log_header_print(&lh);
- }
+ if (sbd.gfs1)
+ gfs_log_header_print(buf);
+ else
+ lgfs2_log_header_print(buf);
break;
case GFS2_METATYPE_LD:
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index f63dc3ec..2e647211 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -2043,40 +2043,20 @@ static void interactive_mode(void)
endwin();
}/* interactive_mode */
-/* ------------------------------------------------------------------------ */
-/* gfs_log_header_in - read in a gfs1-style log header */
-/* ------------------------------------------------------------------------ */
-void gfs_log_header_in(struct gfs_log_header *head, const char *buf)
-{
- const struct gfs_log_header *str = (void *)buf;
-
- gfs2_meta_header_in(&head->lh_header, buf);
-
- head->lh_flags = be32_to_cpu(str->lh_flags);
- head->lh_pad = be32_to_cpu(str->lh_pad);
-
- head->lh_first = be64_to_cpu(str->lh_first);
- head->lh_sequence = be64_to_cpu(str->lh_sequence);
-
- head->lh_tail = be64_to_cpu(str->lh_tail);
- head->lh_last_dump = be64_to_cpu(str->lh_last_dump);
-
- memcpy(head->lh_reserved, str->lh_reserved, 64);
-}
-
-
/* ------------------------------------------------------------------------ */
/* gfs_log_header_print - print a gfs1-style log header */
/* ------------------------------------------------------------------------ */
-void gfs_log_header_print(struct gfs_log_header *lh)
+void gfs_log_header_print(void *lhp)
{
- gfs2_meta_header_print(&lh->lh_header);
- pv(lh, lh_flags, "%u", "0x%.8x");
- pv(lh, lh_pad, "%u", "%x");
- pv((unsigned long long)lh, lh_first, "%llu", "%llx");
- pv((unsigned long long)lh, lh_sequence, "%llu", "%llx");
- pv((unsigned long long)lh, lh_tail, "%llu", "%llx");
- pv((unsigned long long)lh, lh_last_dump, "%llu", "%llx");
+ struct gfs_log_header *lh = lhp;
+
+ lgfs2_meta_header_print(&lh->lh_header);
+ print_it(" lh_flags", "%"PRIu32, "0x%.8"PRIx32, be32_to_cpu(lh->lh_flags));
+ print_it(" lh_pad", "%"PRIu32, "0x%"PRIx32, be32_to_cpu(lh->lh_pad));
+ print_it(" lh_first", "%"PRIu64, "0x%"PRIx64, be64_to_cpu(lh->lh_first));
+ print_it(" lh_sequence", "%"PRIu64, "0x%"PRIx64, be64_to_cpu(lh->lh_sequence));
+ print_it(" lh_tail", "%"PRIu64, "0x%"PRIx64, be64_to_cpu(lh->lh_tail));
+ print_it(" lh_last_dump", "%"PRIu64, "0x%"PRIx64, be64_to_cpu(lh->lh_last_dump));
}
/* ------------------------------------------------------------------------ */
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 11e6f105..cb3343d0 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -222,8 +222,7 @@ extern int block_is_quota_file(uint64_t blk);
extern int block_is_per_node(uint64_t blk);
extern int display_block_type(char *buf, uint64_t addr, int from_restore);
extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
-extern void gfs_log_header_in(struct gfs_log_header *head, const char *buf);
-extern void gfs_log_header_print(struct gfs_log_header *lh);
+extern void gfs_log_header_print(void *lhp);
extern void savemeta(char *out_fn, int saveoption, int gziplevel);
extern void restoremeta(const char *in_fn, const char *out_device,
uint64_t printblocksonly);
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index 7f27109a..607f65e5 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -301,7 +301,7 @@ static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
return bcount;
}
-static int is_wrap_pt(char *buf, uint64_t *highest_seq)
+static int is_wrap_pt(void *buf, uint64_t *highest_seq)
{
const struct lgfs2_metadata *mtype = get_block_type(buf);
@@ -309,13 +309,11 @@ static int is_wrap_pt(char *buf, uint64_t *highest_seq)
uint64_t seq;
if (sbd.gfs1) {
- struct gfs_log_header lh;
- gfs_log_header_in(&lh, buf);
- seq = lh.lh_sequence;
+ struct gfs_log_header *lh = buf;
+ seq = be64_to_cpu(lh->lh_sequence);
} else {
- struct gfs2_log_header lh;
- gfs2_log_header_in(&lh, buf);
- seq = lh.lh_sequence;
+ struct gfs2_log_header *lh = buf;
+ seq = be64_to_cpu(lh->lh_sequence);
}
if (seq < *highest_seq)
return 1;
@@ -467,6 +465,38 @@ static uint64_t get_ldref(uint64_t abs_ld, int offset_from_ld)
return refblk;
}
+static void display_log_header(void *buf, uint64_t *highest_seq, uint64_t abs_block, uint64_t jb, uint64_t j_size)
+{
+ const struct lgfs2_metafield *lh_flags_field;
+ const struct lgfs2_metadata *mtype;
+ struct gfs2_log_header *lh = buf;
+ struct gfs_log_header *lh1 = buf;
+ char flags_str[256];
+
+ if (sbd.gfs1) {
+ mtype = &lgfs2_metadata[LGFS2_MT_GFS_LOG_HEADER];
+ lh_flags_field = &mtype->fields[7]; /* lh_flags is the 8th field in the struct */
+ check_journal_wrap(be64_to_cpu(lh1->lh_sequence), highest_seq);
+ } else {
+ mtype = &lgfs2_metadata[LGFS2_MT_GFS2_LOG_HEADER];
+ lh_flags_field = &mtype->fields[6]; /* lh_flags is the 7th field in the struct */
+ check_journal_wrap(be64_to_cpu(lh->lh_sequence), highest_seq);
+ }
+ lgfs2_field_str(flags_str, sizeof(flags_str), buf, lh_flags_field, (dmode == HEX_MODE));
+ if (sbd.gfs1) {
+ print_gfs2("0x%"PRIx64" (j+%4"PRIx64"): Log header: Seq: 0x%"PRIx64", "
+ "1st: 0x%"PRIx64", tail: 0x%"PRIx64", last: 0x%"PRIx64" [%s]",
+ abs_block, jb, be64_to_cpu(lh1->lh_sequence),
+ be64_to_cpu(lh1->lh_first), be64_to_cpu(lh1->lh_tail),
+ be64_to_cpu(lh1->lh_last_dump), flags_str);
+ } else {
+ print_gfs2("0x%"PRIx64" (j+%4"PRIx64"): Log header: Seq: 0x%"PRIx64", "
+ "tail: 0x%"PRIx32", blk: 0x%"PRIx32" [%s]",
+ abs_block, (jb % j_size) / sbd.bsize, be64_to_cpu(lh->lh_sequence),
+ be32_to_cpu(lh->lh_tail), be32_to_cpu(lh->lh_blkno), flags_str);
+ }
+}
+
/**
* dump_journal - dump a journal file's contents.
* @journal: name of the journal to dump
@@ -480,7 +510,6 @@ static uint64_t get_ldref(uint64_t abs_ld, int offset_from_ld)
void dump_journal(const char *journal, int tblk)
{
const struct lgfs2_metadata *mtype;
- const struct lgfs2_metafield *lh_flags_field;
struct gfs2_buffer_head *j_bh = NULL;
uint64_t jblock, j_size, jb, abs_block, saveblk, wrappt = 0;
int start_line, journal_num;
@@ -494,7 +523,6 @@ void dump_journal(const char *journal, int tblk)
uint64_t abs_ld = 0;
mtype = lgfs2_find_mtype(GFS2_METATYPE_LH, sbd.gfs1 ? LGFS2_MD_GFS1 : LGFS2_MD_GFS2);
- lh_flags_field = lgfs2_find_mfield_name("lh_flags", mtype);
start_line = line;
lines_per_row[dmode] = 1;
@@ -589,36 +617,7 @@ void dump_journal(const char *journal, int tblk)
offset_from_ld = 0;
abs_ld = abs_block;
} else if (!tblk && block_type == GFS2_METATYPE_LH) {
- struct gfs2_log_header lh;
- struct gfs_log_header lh1;
-
- if (sbd.gfs1) {
- gfs_log_header_in(&lh1, buf);
- check_journal_wrap(lh1.lh_sequence,
- &highest_seq);
- print_gfs2("0x%"PRIx64" (j+%4"PRIx64"): Log header: "
- "Flags:%"PRIx32", Seq: 0x%"PRIx64", 1st: 0x%"PRIx64", "
- "tail: 0x%"PRIx64", last: 0x%"PRIx64,
- abs_block, jb + wrappt,
- lh1.lh_flags, lh1.lh_sequence,
- lh1.lh_first, lh1.lh_tail,
- lh1.lh_last_dump);
- } else {
- char flags_str[256];
-
- gfs2_log_header_in(&lh, buf);
- check_journal_wrap(lh.lh_sequence,
- &highest_seq);
- lgfs2_field_str(flags_str, sizeof(flags_str),
- buf, lh_flags_field,
- (dmode == HEX_MODE));
- print_gfs2("0x%"PRIx64" (j+%4"PRIx64"): Log header: Seq: "
- "0x%"PRIx64", tail: 0x%"PRIx32", blk: 0x%"PRIx32" [%s]",
- abs_block, ((jb + wrappt) % j_size)
- / sbd.bsize, lh.lh_sequence,
- lh.lh_tail, lh.lh_blkno,
- flags_str);
- }
+ display_log_header(buf, &highest_seq, abs_block, jb + wrappt, j_size);
eol(0);
} else if ((ld_blocks > 0) &&
(sbd.gfs1 || block_type == GFS2_METATYPE_LB)) {
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 664c92d6..9c003e68 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -857,15 +857,14 @@ static void save_leaf_blocks(struct metafd *mfd, struct block_range_queue *q)
static void save_inode_data(struct metafd *mfd, char *ibuf, uint64_t iblk)
{
struct block_range_queue indq[GFS2_MAX_META_HEIGHT] = {{NULL}};
- uint32_t height;
- struct gfs2_dinode _di = {0};
+ struct gfs2_dinode *dip = (struct gfs2_dinode *)ibuf;
+ uint16_t height;
int is_exhash;
for (unsigned i = 0; i < GFS2_MAX_META_HEIGHT; i++)
block_range_queue_init(&indq[i]);
- gfs2_dinode_in(&_di, ibuf);
- height = _di.di_height;
+ height = be16_to_cpu(dip->di_height);
/* If this is a user inode, we don't follow to the file height.
We stop one level less. That way we save off the indirect
@@ -873,16 +872,20 @@ static void save_inode_data(struct metafd *mfd, char *ibuf, uint64_t iblk)
is directories, where the height represents the level at which
the hash table exists, and we have to save the directory data. */
- is_exhash = (S_ISDIR(_di.di_mode) || (sbd.gfs1 && _di.__pad1 == GFS_FILE_DIR)) &&
- _di.di_flags & GFS2_DIF_EXHASH;
+ is_exhash = (S_ISDIR(be32_to_cpu(dip->di_mode)) ||
+ (sbd.gfs1 && be16_to_cpu(dip->__pad1) == GFS_FILE_DIR)) &&
+ be32_to_cpu(dip->di_flags) & GFS2_DIF_EXHASH;
if (is_exhash)
height++;
- else if (height > 0 && !(_di.di_flags & GFS2_DIF_SYSTEM) &&
- !block_is_systemfile(iblk) && !S_ISDIR(_di.di_mode))
+ else if (height > 0 && !(be32_to_cpu(dip->di_flags) & GFS2_DIF_SYSTEM) &&
+ !block_is_systemfile(iblk) && !S_ISDIR(be32_to_cpu(dip->di_mode)))
height--;
- if (height > 0)
- save_indirect_blocks(mfd, ibuf, iblk, height == 1 ? NULL : &indq[0], sizeof(_di));
+ if (height == 1)
+ save_indirect_blocks(mfd, ibuf, iblk, NULL, sizeof(*dip));
+ else if (height > 1)
+ save_indirect_blocks(mfd, ibuf, iblk, &indq[0], sizeof(*dip));
+
for (unsigned i = 1; i < height; i++) {
struct block_range_queue *nextq = &indq[i];
@@ -895,7 +898,7 @@ static void save_inode_data(struct metafd *mfd, char *ibuf, uint64_t iblk)
for (unsigned j = 0; j < q->len; j++) {
char *_buf = q->buf + (j * sbd.bsize);
- save_indirect_blocks(mfd, _buf, iblk, nextq, sizeof(_di.di_header));
+ save_indirect_blocks(mfd, _buf, iblk, nextq, sizeof(dip->di_header));
}
report_progress(q->start + q->len, 0);
block_range_free(&q);
@@ -903,20 +906,20 @@ static void save_inode_data(struct metafd *mfd, char *ibuf, uint64_t iblk)
}
if (is_exhash)
save_leaf_blocks(mfd, &indq[height - 1]);
- if (_di.di_eattr) { /* if this inode has extended attributes */
+ if (dip->di_eattr) { /* if this inode has extended attributes */
size_t blklen;
uint64_t blk;
int mhtype;
char *buf;
- blk = _di.di_eattr;
+ blk = be64_to_cpu(dip->di_eattr);
buf = check_read_block(sbd.device_fd, blk, iblk, &mhtype, &blklen);
if (buf != NULL) {
save_buf(mfd, buf, blk, blklen);
if (mhtype == GFS2_METATYPE_EA)
save_ea_block(mfd, buf, iblk);
else if (mhtype == GFS2_METATYPE_IN)
- save_indirect_blocks(mfd, buf, iblk, NULL, sizeof(_di.di_header));
+ save_indirect_blocks(mfd, buf, iblk, NULL, sizeof(dip->di_header));
free(buf);
}
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 594db181..922d35f8 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -720,12 +720,12 @@ extern void gfs2_inum_print(const struct gfs2_inum *no);
extern void gfs2_meta_header_print(const struct gfs2_meta_header *mh);
extern void gfs2_rindex_print(const struct gfs2_rindex *ri);
extern void gfs2_dinode_print(const struct gfs2_dinode *di);
-extern void gfs2_log_header_print(const struct gfs2_log_header *lh);
/* These expect on-disk data instead of native-endian structs */
extern void lgfs2_inum_print(void *nop);
extern void lgfs2_meta_header_print(void *mhp);
extern void lgfs2_sb_print(void *sbp);
extern void lgfs2_dinode_print(void *dip);
+extern void lgfs2_log_header_print(void *lhp);
extern void lgfs2_log_descriptor_print(void *ldp);
extern void lgfs2_quota_print(void *qp);
extern void lgfs2_quota_change_print(void *qcp);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index a47cf178..286f55ac 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -551,24 +551,26 @@ void gfs2_log_header_out(struct gfs2_log_header *lh, char *buf)
CPOUT_64(lh, str, lh_local_dinodes);
}
-void gfs2_log_header_print(const struct gfs2_log_header *lh)
-{
- gfs2_meta_header_print(&lh->lh_header);
- pv(lh, lh_sequence, "%"PRIu64, "0x%"PRIx64);
- pv(lh, lh_flags, "0x%.8"PRIX32, NULL);
- pv(lh, lh_tail, "%"PRIu32, "0x%"PRIx32);
- pv(lh, lh_blkno, "%"PRIu32, "0x%"PRIx32);
- pv(lh, lh_hash, "0x%.8"PRIX32, NULL);
- pv(lh, lh_crc, "0x%.8"PRIX32, NULL);
- pv(lh, lh_nsec, "%"PRIu32, "0x%"PRIx32);
- pv(lh, lh_sec, "%"PRIu64, "0x%"PRIx64);
- pv(lh, lh_addr, "%"PRIu64, "0x%"PRIx64);
- pv(lh, lh_jinode, "%"PRIu64, "0x%"PRIx64);
- pv(lh, lh_statfs_addr, "%"PRIu64, "0x%"PRIx64);
- pv(lh, lh_quota_addr, "%"PRIu64, "0x%"PRIx64);
- pv(lh, lh_local_total, "%"PRId64, "0x%"PRIx64);
- pv(lh, lh_local_free, "%"PRId64, "0x%"PRIx64);
- pv(lh, lh_local_dinodes, "%"PRId64, "0x%"PRIx64);
+void lgfs2_log_header_print(void *lhp)
+{
+ struct gfs2_log_header *lh = lhp;
+
+ lgfs2_meta_header_print(&lh->lh_header);
+ printbe64(lh, lh_sequence);
+ print_it(" lh_flags", "0x%.8"PRIX32, NULL, be32_to_cpu(lh->lh_flags));
+ printbe32(lh, lh_tail);
+ printbe32(lh, lh_blkno);
+ print_it(" lh_hash", "0x%.8"PRIX32, NULL, be32_to_cpu(lh->lh_hash));
+ print_it(" lh_crc", "0x%.8"PRIX32, NULL, be32_to_cpu(lh->lh_crc));
+ printbe32(lh, lh_nsec);
+ printbe64(lh, lh_sec);
+ printbe64(lh, lh_addr);
+ printbe64(lh, lh_jinode);
+ printbe64(lh, lh_statfs_addr);
+ printbe64(lh, lh_quota_addr);
+ print_it(" lh_local_total", "%"PRId64, "0x%"PRIx64, be64_to_cpu(lh->lh_local_total));
+ print_it(" lh_local_free", "%"PRId64, "0x%"PRIx64, be64_to_cpu(lh->lh_local_free));
+ print_it(" lh_local_dinodes", "%"PRId64, "0x%"PRIx64, be64_to_cpu(lh->lh_local_dinodes));
}
void lgfs2_log_descriptor_print(void *ldp)
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 79d99ba1..4ef4e685 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -124,28 +124,11 @@ uint32_t lgfs2_log_header_crc(char *buf, unsigned bsize)
*/
int lgfs2_write_journal_data(struct gfs2_inode *ip)
{
- struct gfs2_log_header lh = {
- .lh_header.mh_magic = GFS2_MAGIC,
- .lh_header.mh_type = GFS2_METATYPE_LH,
- .lh_header.mh_format = GFS2_FORMAT_LH,
- .lh_tail = 0,
- .lh_blkno = 0,
- .lh_hash = 0,
- .lh_flags = GFS2_LOG_HEAD_UNMOUNT | GFS2_LOG_HEAD_USERSPACE,
- .lh_crc = 0,
- .lh_nsec = 0,
- .lh_sec = 0,
- .lh_jinode = ip->i_di.di_num.no_addr,
- .lh_statfs_addr = 0,
- .lh_quota_addr = 0,
- .lh_local_total = 0,
- .lh_local_free = 0,
- .lh_local_dinodes = 0,
- };
struct gfs2_sbd *sdp = ip->i_sbd;
unsigned blocks = (ip->i_di.di_size + sdp->bsize - 1) / sdp->bsize;
uint64_t jext0 = ip->i_di.di_num.no_addr + ip->i_di.di_blocks - blocks;
uint64_t seq = ((blocks) * (random() / (RAND_MAX + 1.0)));
+ struct gfs2_log_header *lh;
uint64_t jblk = jext0;
char *buf;
@@ -153,23 +136,33 @@ int lgfs2_write_journal_data(struct gfs2_inode *ip)
if (buf == NULL)
return -1;
+ lh = (void *)buf;
+ lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ 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_di.di_num.no_addr);
+
crc32c_optimization_init();
do {
- struct gfs2_log_header *buflh = (struct gfs2_log_header *)buf;
-
- lh.lh_sequence = seq;
- lh.lh_blkno = jblk - jext0;
- gfs2_log_header_out(&lh, buf);
+ uint32_t hash;
- buflh->lh_hash = cpu_to_be32(lgfs2_log_header_hash(buf));
- buflh->lh_addr = cpu_to_be64(jblk);
- buflh->lh_crc = cpu_to_be32(lgfs2_log_header_crc(buf, sdp->bsize));
+ lh->lh_sequence = cpu_to_be64(seq);
+ lh->lh_blkno = cpu_to_be32(jblk - jext0);
+ hash = lgfs2_log_header_hash(buf);
+ lh->lh_hash = cpu_to_be32(hash);
+ lh->lh_addr = cpu_to_be64(jblk);
+ hash = lgfs2_log_header_crc(buf, sdp->bsize);
+ lh->lh_crc = cpu_to_be32(hash);
if (pwrite(sdp->device_fd, buf, sdp->bsize, jblk * sdp->bsize) != sdp->bsize) {
free(buf);
return -1;
}
+ lh->lh_crc = 0;
+ lh->lh_hash = 0;
+
if (++seq == blocks)
seq = 0;
@@ -205,8 +198,8 @@ static struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn
int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned int blocks)
{
- struct gfs2_log_header lh;
- unsigned int x;
+ struct gfs2_log_header *lh;
+ uint32_t x;
uint64_t seq = ((blocks) * (random() / (RAND_MAX + 1.0)));
uint32_t hash;
unsigned int height;
@@ -216,14 +209,6 @@ int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned int blocks)
height = calc_tree_height(jnl, (blocks + 1) * bsize);
build_height(jnl, height);
- memset(&lh, 0, sizeof(struct gfs2_log_header));
- lh.lh_header.mh_magic = GFS2_MAGIC;
- lh.lh_header.mh_type = GFS2_METATYPE_LH;
- lh.lh_header.mh_format = GFS2_FORMAT_LH;
- lh.lh_flags = GFS2_LOG_HEAD_UNMOUNT;
- lh.lh_flags |= GFS2_LOG_HEAD_USERSPACE;
- lh.lh_jinode = jnl->i_di.di_num.no_addr;
-
for (x = 0; x < blocks; x++) {
struct gfs2_buffer_head *bh = get_file_buf(jnl, x, 1);
if (!bh)
@@ -238,14 +223,21 @@ int write_journal(struct gfs2_inode *jnl, unsigned bsize, unsigned int blocks)
return -1;
memset(bh->b_data, 0, bsize);
- lh.lh_sequence = seq;
- lh.lh_blkno = x;
- gfs2_log_header_out(&lh, bh->b_data);
+ lh = (void *)bh->b_data;
+ lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ 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_di.di_num.no_addr);
+ lh->lh_sequence = cpu_to_be64(seq);
+ lh->lh_blkno = cpu_to_be32(x);
+
hash = lgfs2_log_header_hash(bh->b_data);
- ((struct gfs2_log_header *)bh->b_data)->lh_hash = cpu_to_be32(hash);
- ((struct gfs2_log_header *)bh->b_data)->lh_addr = cpu_to_be64(bh->b_blocknr);
+ lh->lh_hash = cpu_to_be32(hash);
+ lh->lh_addr = cpu_to_be64(bh->b_blocknr);
+
hash = lgfs2_log_header_crc(bh->b_data, bsize);
- ((struct gfs2_log_header *)bh->b_data)->lh_crc = cpu_to_be32(hash);
+ lh->lh_crc = cpu_to_be32(hash);
bmodified(bh);
brelse(bh);
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index bad7db25..8e349c9c 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -517,16 +517,20 @@ out_errno:
static int add_j(struct gfs2_sbd *sdp, struct jadd_opts *opts)
{
int fd, error = 0;
- char new_name[256], buf[sdp->bsize];
- unsigned int x, blocks =
- sdp->jsize << (20 - sdp->sd_sb.sb_bsize_shift);
- struct gfs2_log_header lh;
+ char new_name[256], *buf;
+ uint32_t x, blocks = sdp->jsize << (20 - sdp->sd_sb.sb_bsize_shift);
+ struct gfs2_log_header *lh;
uint64_t seq = RANDOM(blocks), addr = 0;
off_t off = 0;
- if ((fd = create_new_inode(opts, &addr)) < 0)
- return fd;
+ buf = calloc(1, sdp->bsize);
+ if (buf == NULL)
+ return -1;
+ if ((fd = create_new_inode(opts, &addr)) < 0) {
+ free(buf);
+ return fd;
+ }
if ((error = set_flags(fd, JA_FL_CLEAR, FS_JOURNAL_DATA_FL)))
goto close_fd;
@@ -544,34 +548,34 @@ static int add_j(struct gfs2_sbd *sdp, struct jadd_opts *opts)
goto close_fd;
}
- memset(&lh, 0, sizeof(struct gfs2_log_header));
- lh.lh_header.mh_magic = GFS2_MAGIC;
- lh.lh_header.mh_type = GFS2_METATYPE_LH;
- lh.lh_header.mh_format = GFS2_FORMAT_LH;
- lh.lh_flags = GFS2_LOG_HEAD_UNMOUNT;
- lh.lh_flags |= GFS2_LOG_HEAD_USERSPACE;
- lh.lh_jinode = addr;
+ lh = (void *)buf;
+ lh->lh_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ 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(addr);
for (x=0; x<blocks; x++) {
uint32_t hash;
uint64_t blk_addr = 0;
- lh.lh_sequence = seq;
- lh.lh_blkno = x;
- gfs2_log_header_out(&lh, buf);
+ lh->lh_sequence = cpu_to_be64(seq);
+ lh->lh_blkno = cpu_to_be32(x);
hash = lgfs2_log_header_hash(buf);
- ((struct gfs2_log_header *)buf)->lh_hash = cpu_to_be32(hash);
+ lh->lh_hash = cpu_to_be32(hash);
if (!(blk_addr = find_block_address(fd, off, sdp->bsize))) {
error = -1;
goto close_fd;
}
- ((struct gfs2_log_header *)buf)->lh_addr = cpu_to_be64(blk_addr);
+ lh->lh_addr = cpu_to_be64(blk_addr);
hash = lgfs2_log_header_crc(buf, sdp->bsize);
- ((struct gfs2_log_header *)buf)->lh_crc = cpu_to_be32(hash);
+ lh->lh_crc = cpu_to_be32(hash);
if (write(fd, buf, sdp->bsize) != sdp->bsize) {
perror("add_j write");
error = -1;
goto close_fd;
}
+ lh->lh_crc = 0;
+ lh->lh_hash = 0;
if (++seq == blocks)
seq = 0;
@@ -590,6 +594,7 @@ static int add_j(struct gfs2_sbd *sdp, struct jadd_opts *opts)
goto close_fd;
}
close_fd:
+ free(buf);
return close(fd) || error;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 02/27: libgfs2: Don't use on-disk structs with
cpu-endian data in __init_dinode
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 99eeaec8d1d1336ea7d8339f3b67dd168c5178be
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Apr 28 20:45:17 2021 +0100
libgfs2: Don't use on-disk structs with cpu-endian data in __init_dinode
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_ops.c | 93 ++++++++++++++++++++++++++-------------------------
1 file changed, 48 insertions(+), 45 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 27fb43cb..12d845f1 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1330,7 +1330,7 @@ static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, st
unsigned int mode, uint32_t flags, struct gfs2_inum *parent, int gfs1)
{
struct gfs2_buffer_head *bh;
- struct gfs2_dinode di = {{0}};
+ struct gfs2_dinode *di;
int is_dir;
if (gfs1)
@@ -1350,53 +1350,56 @@ static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, st
bh = *bhp;
- di.di_header.mh_magic = GFS2_MAGIC;
- di.di_header.mh_type = GFS2_METATYPE_DI;
- di.di_header.mh_format = GFS2_FORMAT_DI;
- di.di_num = *inum;
- di.di_mode = mode;
- di.di_nlink = 1;
- di.di_blocks = 1;
- di.di_atime = di.di_mtime = di.di_ctime = sdp->time;
- di.di_goal_meta = di.di_goal_data = bh->b_blocknr;
- di.di_flags = flags;
+ di = (struct gfs2_dinode *)bh->b_data;
+
+ 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_mode = cpu_to_be32(mode);
+ di->di_nlink = cpu_to_be32(1);
+ di->di_blocks = cpu_to_be64(1);
+ di->di_atime = di->di_mtime = di->di_ctime = cpu_to_be64(sdp->time);
+ di->di_goal_meta = di->di_goal_data = cpu_to_be64(bh->b_blocknr);
+ di->di_flags = cpu_to_be32(flags);
if (is_dir) {
- struct gfs2_dirent de1, de2;
-
- memset(&de1, 0, sizeof(struct gfs2_dirent));
- de1.de_inum = di.di_num;
- de1.de_hash = gfs2_disk_hash(".", 1);
- de1.de_rec_len = GFS2_DIRENT_SIZE(1);
- de1.de_name_len = 1;
- de1.de_type = (gfs1 ? GFS_FILE_DIR : IF2DT(S_IFDIR));
-
- memset(&de2, 0, sizeof(struct gfs2_dirent));
- de2.de_inum = *parent;
- de2.de_hash = gfs2_disk_hash("..", 2);
- de2.de_rec_len = sdp->bsize - sizeof(struct gfs2_dinode) - de1.de_rec_len;
- de2.de_name_len = 2;
- de2.de_type = (gfs1 ? GFS_FILE_DIR : IF2DT(S_IFDIR));
-
- gfs2_dirent_out(&de1, bh->b_data + sizeof(struct gfs2_dinode));
- memcpy(bh->b_data +
- sizeof(struct gfs2_dinode) +
- sizeof(struct gfs2_dirent),
- ".", 1);
- gfs2_dirent_out(&de2, bh->b_data + sizeof(struct gfs2_dinode) + de1.de_rec_len);
- memcpy(bh->b_data +
- sizeof(struct gfs2_dinode) +
- de1.de_rec_len +
- sizeof(struct gfs2_dirent),
- "..", 2);
-
- di.di_nlink = 2;
- di.di_size = sdp->bsize - sizeof(struct gfs2_dinode);
- di.di_flags |= GFS2_DIF_JDATA;
- di.di_payload_format = GFS2_FORMAT_DE;
- di.di_entries = 2;
+ char *p = bh->b_data + sizeof(*di);
+ struct gfs2_dirent de = {0};
+ uint32_t hash;
+ uint16_t len;
+
+ hash = gfs2_disk_hash(".", 1);
+ len = GFS2_DIRENT_SIZE(1);
+ de.de_inum = di->di_num;
+ de.de_hash = cpu_to_be32(hash);
+ de.de_rec_len = cpu_to_be16(len);
+ de.de_name_len = cpu_to_be16(1);
+ de.de_type = cpu_to_be16(gfs1 ? GFS_FILE_DIR : IF2DT(S_IFDIR));
+ memcpy(p, &de, sizeof(de));
+ p[sizeof(de)] = '.';
+ p += len;
+
+ hash = gfs2_disk_hash("..", 2);
+ len = sdp->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_hash = cpu_to_be32(hash);
+ de.de_rec_len = cpu_to_be16(len);
+ de.de_name_len = cpu_to_be16(2);
+ de.de_type = cpu_to_be16(gfs1 ? GFS_FILE_DIR : IF2DT(S_IFDIR));
+ memcpy(p, &de, sizeof(de));
+ p += sizeof(de);
+ *p++ = '.';
+ *p = '.';
+
+ di->di_nlink = cpu_to_be32(2);
+ di->di_size = cpu_to_be64(sdp->bsize - sizeof(struct gfs2_dinode));
+ di->di_flags = cpu_to_be32(flags | GFS2_DIF_JDATA);
+ di->di_payload_format = cpu_to_be32(GFS2_FORMAT_DE);
+ di->di_entries = cpu_to_be32(2);
}
- gfs2_dinode_out(&di, bh->b_data);
bmodified(bh);
return 0;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 01/27: gfs2_edit: Store big-endian data in the global
dinode
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 f1d10e69a84837413882d5462295c04c18925ec6
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Apr 28 12:42:53 2021 +0100
gfs2_edit: Store big-endian data in the global dinode
Add a big-endian lgfs2_dinode_print() function to libgfs2 to enable
that.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/extended.c | 21 +++++++++++----------
gfs2/edit/gfs2hex.c | 30 ++++++++++++++++--------------
gfs2/edit/gfs2hex.h | 2 +-
gfs2/edit/hexedit.c | 41 +++++++++++++++++++++++------------------
gfs2/edit/hexedit.h | 2 +-
gfs2/edit/journal.c | 5 ++---
gfs2/edit/savemeta.c | 2 +-
gfs2/libgfs2/libgfs2.h | 1 +
gfs2/libgfs2/ondisk.c | 28 ++++++++++++++++++++++++++++
9 files changed, 84 insertions(+), 48 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 7050a36a..4e8a003d 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -103,13 +103,14 @@ static uint64_t metapath_to_lblock(struct metapath *mp, int hgt)
int h;
uint64_t lblock = 0;
uint64_t factor[GFS2_MAX_META_HEIGHT];
+ uint16_t height = be16_to_cpu(di->di_height);
- if (di.di_height < 2)
+ if (height < 2)
return mp->mp_list[0];
/* figure out multiplication factors for each height */
memset(&factor, 0, sizeof(factor));
- factor[di.di_height - 1] = 1ull;
- for (h = di.di_height - 2; h >= 0; h--)
+ factor[height - 1] = 1ull;
+ for (h = height - 2; h >= 0; h--)
factor[h] = factor[h + 1] * sbd.sd_inptrs;
for (h = 0; h <= hgt; h++)
lblock += (mp->mp_list[h] * factor[h]);
@@ -127,7 +128,7 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level,
return -1;
if (!level) {
if (gfs2_struct_type == GFS2_METATYPE_DI) {
- if (S_ISDIR(di.di_mode))
+ if (S_ISDIR(be32_to_cpu(di->di_mode)))
print_gfs2("This directory contains %d indirect blocks",
indblocks);
else
@@ -137,14 +138,14 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level,
print_gfs2("This indirect block contains %d indirect blocks",
indblocks);
}
- if (dinode_valid() && !S_ISDIR(di.di_mode)) {
+ if (dinode_valid() && !S_ISDIR(be32_to_cpu(di->di_mode))) {
/* See if we are on an inode or have one in history. */
if (level)
cur_height = level;
else {
cur_height = get_height();
print_gfs2(" (at height %d of %d)",
- cur_height, di.di_height);
+ cur_height, be16_to_cpu(di->di_height));
}
}
eol(0);
@@ -189,7 +190,7 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level,
COLORS_NORMAL;
}
}
- if (dinode_valid() && !S_ISDIR(di.di_mode)) {
+ if (dinode_valid() && !S_ISDIR(be32_to_cpu(di->di_mode))) {
float human_off;
char h;
@@ -211,8 +212,8 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level,
else
file_offset = 0;
if (dinode_valid() && !termlines &&
- ((level + 1 < di.di_height) ||
- (S_ISDIR(di.di_mode) && level <= di.di_height))) {
+ ((level + 1 < be16_to_cpu(di->di_height)) ||
+ (S_ISDIR(be32_to_cpu(di->di_mode)) && level <= be16_to_cpu(di->di_height)))) {
print_block_details(ind, level, cur_height, pndx,
file_offset);
}
@@ -394,7 +395,7 @@ static void print_block_details(struct iinfo *ind, int level, int cur_height,
}
thisblk = 0;
memset(more_indir, 0, sizeof(struct iinfo));
- if (S_ISDIR(di.di_mode) && level == di.di_height) {
+ if (S_ISDIR(be32_to_cpu(di->di_mode)) && level == be16_to_cpu(di->di_height)) {
thisblk = do_leaf_extended(tmpbuf, more_indir);
display_leaf(more_indir);
} else {
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 021c7308..9d5eff71 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -27,7 +27,7 @@
print_it(" "#member, "%"PRIu32, "0x%"PRIx32, be32_to_cpu(struct->member)); \
} while(0)
-struct gfs2_dinode di;
+struct gfs2_dinode *di;
int line, termlines, modelines[DMODES];
char edit_fmt[80];
char estring[1024];
@@ -231,16 +231,20 @@ static int indirect_dirent(struct indirect_info *indir, char *ptr, int d)
return de.de_rec_len;
}
-void do_dinode_extended(struct gfs2_dinode *dine, char *buf)
+void do_dinode_extended(char *buf)
{
+ struct gfs2_dinode *dip = (void *)buf;
unsigned int x, y, ptroff = 0;
uint64_t p, last;
- int isdir = !!(S_ISDIR(dine->di_mode)) ||
- (sbd.gfs1 && dine->__pad1 == GFS_FILE_DIR);
+ int isdir = 0;
+
+ if (S_ISDIR(be32_to_cpu(dip->di_mode)) ||
+ (sbd.gfs1 && be16_to_cpu(dip->__pad1) == GFS_FILE_DIR))
+ isdir = 1;
indirect_blocks = 0;
memset(indirect, 0, sizeof(struct iinfo));
- if (dine->di_height > 0) {
+ if (be16_to_cpu(dip->di_height) > 0) {
/* Indirect pointers */
for (x = sizeof(struct gfs2_dinode); x < sbd.bsize;
x += sizeof(uint64_t)) {
@@ -251,13 +255,13 @@ void do_dinode_extended(struct gfs2_dinode *dine, char *buf)
ptroff;
indirect->ii[indirect_blocks].is_dir = FALSE;
indirect->ii[indirect_blocks].ptroff =
- (x - sizeof(*dine)) / sizeof(uint64_t);
+ (x - sizeof(*dip)) / sizeof(uint64_t);
indirect_blocks++;
}
ptroff++;
}
}
- else if (isdir && !(dine->di_flags & GFS2_DIF_EXHASH)) {
+ else if (isdir && !(be32_to_cpu(dip->di_flags) & GFS2_DIF_EXHASH)) {
int skip = 0;
/* Directory Entries: */
@@ -271,19 +275,18 @@ void do_dinode_extended(struct gfs2_dinode *dine, char *buf)
break;
}
}
- else if (isdir &&
- (dine->di_flags & GFS2_DIF_EXHASH) &&
- dine->di_height == 0) {
+ else if (isdir && (be32_to_cpu(dip->di_flags) & GFS2_DIF_EXHASH) &&
+ dip->di_height == 0) {
/* Leaf Pointers: */
last = be64_to_cpu(*(uint64_t *)(buf + sizeof(struct gfs2_dinode)));
for (x = sizeof(struct gfs2_dinode), y = 0;
- y < (1 << dine->di_depth);
+ y < (1 << be16_to_cpu(dip->di_depth));
x += sizeof(uint64_t), y++) {
p = be64_to_cpu(*(uint64_t *)(buf + x));
- if (p != last || ((y + 1) * sizeof(uint64_t) == dine->di_size)) {
+ 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;
@@ -430,9 +433,8 @@ int display_gfs2(char *buf)
break;
case GFS2_METATYPE_DI:
- gfs2_dinode_print(&di);
+ lgfs2_dinode_print(di);
break;
-
case GFS2_METATYPE_IN:
gfs2_meta_header_print(&mh);
break;
diff --git a/gfs2/edit/gfs2hex.h b/gfs2/edit/gfs2hex.h
index 878ab801..23b1fc60 100644
--- a/gfs2/edit/gfs2hex.h
+++ b/gfs2/edit/gfs2hex.h
@@ -5,7 +5,7 @@
extern int display_gfs2(char *buf);
extern int edit_gfs2(void);
-extern void do_dinode_extended(struct gfs2_dinode *di, char *buf);
+extern void do_dinode_extended(char *buf);
extern void print_gfs2(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
extern uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir);
extern void eol(int col);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index c497c748..f63dc3ec 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -497,7 +497,7 @@ static int get_pnum(int ptroffset)
/* ------------------------------------------------------------------------ */
/* hexdump - hex dump the filesystem block to the screen */
/* ------------------------------------------------------------------------ */
-static int hexdump(uint64_t startaddr, int len, int trunc_zeros,
+static int hexdump(uint64_t startaddr, uint64_t len, int trunc_zeros,
uint64_t flagref, uint64_t ref_blk)
{
const unsigned char *pointer, *ptr2;
@@ -537,7 +537,7 @@ static int hexdump(uint64_t startaddr, int len, int trunc_zeros,
if (l < struct_len)
COLORS_NORMAL; /* normal part of structure */
else if (gfs2_struct_type == GFS2_METATYPE_DI &&
- l < struct_len + di.di_size)
+ l < struct_len + be64_to_cpu(di->di_size))
COLORS_CONTENTS; /* after struct but not eof */
else
COLORS_SPECIAL; /* beyond end of the struct */
@@ -548,8 +548,9 @@ static int hexdump(uint64_t startaddr, int len, int trunc_zeros,
/* Figure out if we have a null pointer--for colors */
if (((gfs2_struct_type == GFS2_METATYPE_IN) ||
(gfs2_struct_type == GFS2_METATYPE_DI &&
- l < struct_len + di.di_size &&
- (di.di_height > 0 || !S_ISREG(di.di_mode)))) &&
+ l < struct_len + be64_to_cpu(di->di_size) &&
+ (be16_to_cpu(di->di_height) > 0 ||
+ !S_ISREG(be32_to_cpu(di->di_mode))))) &&
(i==0 || i==8)) {
int j;
@@ -565,9 +566,9 @@ static int hexdump(uint64_t startaddr, int len, int trunc_zeros,
if (l + i < struct_len)
COLORS_NORMAL; /* in the structure */
else if (gfs2_struct_type == GFS2_METATYPE_DI
- && l + i < struct_len + di.di_size) {
- if ((!di.di_height &&
- S_ISREG(di.di_mode)) ||
+ && l + i < struct_len + be64_to_cpu(di->di_size)) {
+ if ((!di->di_height &&
+ S_ISREG(be32_to_cpu(di->di_mode))) ||
!ptr_not_null)
COLORS_CONTENTS;/*stuff data */
else
@@ -632,7 +633,7 @@ static int hexdump(uint64_t startaddr, int len, int trunc_zeros,
block_type == GFS2_METATYPE_LD ||
((block_type == GFS2_METATYPE_DI) &&
((struct gfs2_dinode*)bh->b_data)->di_height) ||
- S_ISDIR(di.di_mode)) {
+ S_ISDIR(be32_to_cpu(di->di_mode))) {
ptroffset = edit_row[dmode] * 16 +
edit_col[dmode];
@@ -822,7 +823,8 @@ int has_indirect_blocks(void)
if (indirect_blocks || gfs2_struct_type == GFS2_METATYPE_SB ||
gfs2_struct_type == GFS2_METATYPE_LF ||
(gfs2_struct_type == GFS2_METATYPE_DI &&
- (S_ISDIR(di.di_mode) || (sbd.gfs1 && di.__pad1 == GFS_FILE_DIR))))
+ (S_ISDIR(be32_to_cpu(di->di_mode)) ||
+ (sbd.gfs1 && be16_to_cpu(di->__pad1) == GFS_FILE_DIR))))
return TRUE;
return FALSE;
}
@@ -986,8 +988,8 @@ static int read_master_dir(void)
bh = bread(&sbd, sbd.sd_sb.sb_master_dir.no_addr);
if (bh == NULL)
return 1;
- gfs2_dinode_in(&di, bh->b_data);
- do_dinode_extended(&di, bh->b_data); /* get extended data, if any */
+ di = (struct gfs2_dinode *)bh->b_data;
+ do_dinode_extended(bh->b_data); /* get extended data, if any */
memcpy(&masterdir, &indirect[0], sizeof(struct indirect_info));
return 0;
}
@@ -1057,8 +1059,8 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
indirect->ii[0].dirent[1].dirent.de_type = DT_DIR;
}
else if (gfs2_struct_type == GFS2_METATYPE_DI) {
- gfs2_dinode_in(&di, bh->b_data);
- do_dinode_extended(&di, bh->b_data); /* get extended data, if any */
+ di = (struct gfs2_dinode *)bh->b_data;
+ do_dinode_extended(bh->b_data); /* get extended data, if any */
}
else if (gfs2_struct_type == GFS2_METATYPE_IN) { /* indirect block list */
if (blockhist) {
@@ -1087,11 +1089,14 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
"Pointers "));
move(line, 0);
}
- if (dmode == HEX_MODE) /* if hex display mode */
- hexdump(dev_offset, (gfs2_struct_type == GFS2_METATYPE_DI)?
- struct_len + di.di_size:sbd.bsize, trunc_zeros,
- flagref, ref_blk);
- else if (dmode == GFS2_MODE) { /* if structure display */
+ if (dmode == HEX_MODE) { /* if hex display mode */
+ uint64_t len = sbd.bsize;
+
+ if (gfs2_struct_type == GFS2_METATYPE_DI)
+ len = struct_len + be64_to_cpu(di->di_size);
+
+ hexdump(dev_offset, len, trunc_zeros, flagref, ref_blk);
+ } else if (dmode == GFS2_MODE) { /* if structure display */
if (block != JOURNALS_DUMMY_BLOCK)
display_gfs2(bh->b_data);
} else
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index f44ea3b1..11e6f105 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -49,7 +49,7 @@ extern struct gfs2_sbd sbd;
extern struct gfs_sb *sbd1;
extern struct gfs2_inum gfs1_quota_di; /* kludge because gfs2 sb too small */
extern struct gfs2_inum gfs1_license_di; /* kludge because gfs2 sb too small */
-extern struct gfs2_dinode di;
+extern struct gfs2_dinode *di;
extern int screen_chunk_size; /* how much of the 4K can fit on screen */
extern int gfs2_struct_type;
extern int identify;
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index e8b71dc5..7f27109a 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -51,11 +51,10 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
jindex_block = masterblock("jindex");
/* read in the block */
jindex_bh = bread(&sbd, jindex_block);
- /* get the dinode data from it. */
- gfs2_dinode_in(&di, jindex_bh->b_data);
+ di = (struct gfs2_dinode *)jindex_bh->b_data;
if (!sbd.gfs1)
- do_dinode_extended(&di, jindex_bh->b_data); /* parse dir. */
+ do_dinode_extended(jindex_bh->b_data); /* parse dir. */
if (sbd.gfs1) {
struct gfs2_inode *jiinode;
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index e9401e4a..664c92d6 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -272,7 +272,7 @@ static int init_per_node_lookup(void)
return 1;
}
- do_dinode_extended(&per_node_di->i_di, per_node_di->i_bh->b_data);
+ do_dinode_extended(per_node_di->i_bh->b_data);
inode_put(&per_node_di);
for (i = 0; i < indirect_blocks; i++) {
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 19d060f5..594db181 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -725,6 +725,7 @@ extern void gfs2_log_header_print(const struct gfs2_log_header *lh);
extern void lgfs2_inum_print(void *nop);
extern void lgfs2_meta_header_print(void *mhp);
extern void lgfs2_sb_print(void *sbp);
+extern void lgfs2_dinode_print(void *dip);
extern void lgfs2_log_descriptor_print(void *ldp);
extern void lgfs2_quota_print(void *qp);
extern void lgfs2_quota_change_print(void *qcp);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 5e69ee98..a47cf178 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -384,6 +384,34 @@ void gfs2_dinode_print(const struct gfs2_dinode *di)
pv(di, di_eattr, "%"PRIu64, "0x%"PRIx64);
}
+void lgfs2_dinode_print(void *dip)
+{
+ struct gfs2_dinode *di = dip;
+
+ lgfs2_meta_header_print(&di->di_header);
+ lgfs2_inum_print(&di->di_num);
+
+ print_it(" di_mode", "0%"PRIo32, NULL, be32_to_cpu(di->di_mode));
+ printbe32(di, di_uid);
+ printbe32(di, di_gid);
+ printbe32(di, di_nlink);
+ printbe64(di, di_size);
+ printbe64(di, di_blocks);
+ printbe64(di, di_atime);
+ printbe64(di, di_mtime);
+ printbe64(di, di_ctime);
+ printbe32(di, di_major);
+ printbe32(di, di_minor);
+ printbe64(di, di_goal_meta);
+ printbe64(di, di_goal_data);
+ print_it(" di_flags", "0x%.8"PRIX32, NULL, be32_to_cpu(di->di_flags));
+ printbe32(di, di_payload_format);
+ printbe16(di, di_height);
+ printbe16(di, di_depth);
+ printbe32(di, di_entries);
+ printbe64(di, di_eattr);
+}
+
void gfs2_dirent_in(struct gfs2_dirent *de, char *buf)
{
struct gfs2_dirent *str = (struct gfs2_dirent *)buf;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] branch andyp-sparse updated (d50cabcd -> 6206a0b7)
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a change to branch andyp-sparse
in repository gfs2-utils.
discard d50cabcd fsck.gfs2: Set prev_seq to the correct value when renumbering
discard 96063f8e libgfs2: Don't overwrite rt_{data0,data,bitbytes} when reading rgrps
discard 465f107d gfs2_edit: Don't return an invalid pointer from restore_block()
discard 3419bc3a fsck.gfs2: Fix up some memset sizes
discard 6004baa2 fsck.gfs2: Fix remaining endianness sparse warnings
discard b8203e6d gfs2_edit: Fix remaining endianness sparse warnings
discard 78bf04b6 gfs2_convert: Fix the remaining sparse warnings
discard 1da6e760 libgfs2: Fix the remaining sparse warnings
discard 029a4519 fsck.gfs2: Remove unused invalidate_fxns
discard 23738249 Fix sparse warnings about linkage
discard 0f1c60ac libgfs2: Remove gfs_jindex_in
discard b1c1dbb4 libgfs2: Fix endianness tagging for gfs2_bit_search
discard cac95a6a gfs2l: Sparse fixes
discard 95de05e0 libgfs2: Broaden use of struct lgfs2_inum
discard 8bd2adc6 libgfs2: Don't parse/write de_cookie
discard e11a74d9 libgfs2: Print di_size with the correct size
discard 540aa645 libgfs2: Fix endianness conversions for superblock padding fields
discard 0c03f1c5 libgfs2: Remove gfs2_meta_header_{in,out}
discard 2ee34808 libgfs2: Endianness improvements for gfs2_leaf
discard 19d95b5b Remove some users of gfs2_leaf_in()
discard 113aed8a libgfs2: Endianness improvements for gfs2_inum and gfs2_dirent
discard 717c5a11 gfs2_edit: Use native-endian types for dirent processing
discard 454a9e68 libgfs2: Remove some now-unused functions
discard 767016aa libgfs2: Remove sd_sb from struct gfs2_sbd
discard 83d957c1 libgfs2: Remove big-endian structs from struct rgrp_tree
discard fd2951b3 libgfs2: Remove i_di from struct gfs2_inode
discard d2655752 libgfs2: Remove gfs2_dinode_print()
discard 75046254 libgfs2: Add a cpu-endian log header struct
discard fde3c618 gfs2_edit: Clean up display_gfs2()
discard afa1d8df libgfs2: Fix endianness mismatches for struct gfs2_log_header
discard 20490270 libgfs2: Don't use on-disk structs with cpu-endian data in __init_dinode
discard 940a709a gfs2_edit: Store big-endian data in the global dinode
new f1d10e69 gfs2_edit: Store big-endian data in the global dinode
new 99eeaec8 libgfs2: Don't use on-disk structs with cpu-endian data in __init_dinode
new 0ea32926 libgfs2: Fix endianness mismatches for struct gfs2_log_header
new f061b55f gfs2_edit: Clean up display_gfs2()
new 9402792a libgfs2: Add a cpu-endian log header struct
new 708154bf libgfs2: Remove gfs2_dinode_print()
new e5bc9656 libgfs2: Remove i_di from struct gfs2_inode
new d8a351b1 libgfs2: Remove big-endian structs from struct rgrp_tree
new 0489202a libgfs2: Remove sd_sb from struct gfs2_sbd
new 9feafd77 libgfs2: Remove some now-unused functions
new d9e8ae78 gfs2_edit: Use native-endian types for dirent processing
new 259eab1d libgfs2: Endianness improvements for gfs2_inum and gfs2_dirent
new fd1b3810 Remove some users of gfs2_leaf_in()
new ff7332fd libgfs2: Endianness improvements for gfs2_leaf
new 7f49fb53 libgfs2: Remove gfs2_meta_header_{in,out}
new 328230d1 libgfs2: Fix endianness conversions for superblock padding fields
new 028e996c libgfs2: Don't parse/write de_cookie
new c4a50183 libgfs2: Broaden use of struct lgfs2_inum
new 90d0e320 gfs2l: Sparse fixes
new 12a28255 libgfs2: Fix endianness tagging for gfs2_bit_search
new ad63b07a libgfs2: Remove gfs_jindex_in
new e57ccf23 Fix sparse warnings about linkage
new d5e853c9 fsck.gfs2: Remove unused invalidate_fxns
new 58f33f9c libgfs2: Fix the remaining sparse warnings
new fc23b1f6 gfs2_convert: Fix the remaining sparse warnings
new e2d50e60 gfs2_edit: Fix remaining endianness sparse warnings
new 6206a0b7 fsck.gfs2: Fix remaining endianness sparse warnings
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (d50cabcd)
\
N -- N -- N refs/heads/andyp-sparse (6206a0b7)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 27 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] branch andyp-sparse updated: fsck.gfs2: Set prev_seq to
the correct value when renumbering
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.
The following commit(s) were added to refs/heads/andyp-sparse by this push:
new d50cabcd fsck.gfs2: Set prev_seq to the correct value when renumbering
d50cabcd is described below
commit d50cabcd2fa4a37b671ee1d4b24cfd39094dee22
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Jun 17 12:30:05 2021 +0100
fsck.gfs2: Set prev_seq to the correct value when renumbering
An assignment of lh.lh_sequence = highest_seq was removed in an earlier
patch but the prev_seq assignment was not updated to use highest_seq
instead of lh.lh_sequence.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/fs_recovery.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 78bdbd2b..12b8d704 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -434,7 +434,7 @@ static int check_journal_seq_no(struct gfs2_inode *ip, int fix)
if (!fix)
continue;
highest_seq++;
- prev_seq = lh.lh_sequence;
+ prev_seq = highest_seq;
log_warn(_("Renumbering it as 0x%"PRIx64"\n"), highest_seq);
block_map(ip, blk, &new, &dblock, NULL, 0);
bh = bread(ip->i_sbd, dblock);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] branch andyp-sparse updated: libgfs2: Don't overwrite
rt_{data0,data,bitbytes} when reading rgrps
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.
The following commit(s) were added to refs/heads/andyp-sparse by this push:
new 96063f8e libgfs2: Don't overwrite rt_{data0,data,bitbytes} when reading rgrps
96063f8e is described below
commit 96063f8e529a0952eca83f28f1094e946c1adf70
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jun 16 17:58:51 2021 +0100
libgfs2: Don't overwrite rt_{data0,data,bitbytes} when reading rgrps
Older filesystems have invalid data in these new rgrp fields so keep
them separate to the fields initialised from the rindex.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/libgfs2.h | 5 +++++
gfs2/libgfs2/ondisk.c | 12 ++++++------
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 3e186019..41f83b94 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -186,6 +186,11 @@ struct rgrp_tree {
uint32_t rt_data;
uint32_t rt_length;
uint32_t rt_bitbytes;
+ /* These 3 fields are duplicated between the rindex and the rgrp */
+ /* For now, duplicate them here too, until users can be reworked */
+ uint64_t rt_rg_data0;
+ uint32_t rt_rg_data;
+ uint32_t rt_rg_bitbytes;
/* Native-endian counterparts of the on-disk rgrp structs */
uint32_t rt_flags;
uint32_t rt_free;
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 3dea69ce..4daf1be1 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -160,9 +160,9 @@ void lgfs2_rgrp_in(lgfs2_rgrp_t rg, void *buf)
rg->rt_dinodes = be32_to_cpu(r->rg_dinodes);
rg->rt_skip = be32_to_cpu(r->rg_skip);
rg->rt_igeneration = be64_to_cpu(r->rg_igeneration);
- rg->rt_data0 = be64_to_cpu(r->rg_data0);
- rg->rt_data = be32_to_cpu(r->rg_data);
- rg->rt_bitbytes = be32_to_cpu(r->rg_bitbytes);
+ rg->rt_rg_data0 = be64_to_cpu(r->rg_data0);
+ rg->rt_rg_data = be32_to_cpu(r->rg_data);
+ rg->rt_rg_bitbytes = be32_to_cpu(r->rg_bitbytes);
}
void lgfs2_rgrp_out(const lgfs2_rgrp_t rg, void *buf)
@@ -177,9 +177,9 @@ void lgfs2_rgrp_out(const lgfs2_rgrp_t rg, void *buf)
r->rg_dinodes = cpu_to_be32(rg->rt_dinodes);
r->rg_skip = cpu_to_be32(rg->rt_skip);
r->rg_igeneration = cpu_to_be64(rg->rt_igeneration);
- r->rg_data0 = cpu_to_be64(rg->rt_data0);
- r->rg_data = cpu_to_be32(rg->rt_data);
- r->rg_bitbytes = cpu_to_be32(rg->rt_bitbytes);
+ r->rg_data0 = cpu_to_be64(rg->rt_rg_data0);
+ r->rg_data = cpu_to_be32(rg->rt_rg_data);
+ r->rg_bitbytes = cpu_to_be32(rg->rt_rg_bitbytes);
lgfs2_rgrp_crc_set(buf);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months