[gfs2-utils] 17/27: libgfs2: Don't parse/write de_cookie
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 028e996c13c3ebba3dafcdc0a693d9ad221c0f56
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu Jun 10 10:39:42 2021 +0100
libgfs2: Don't parse/write de_cookie
It's really just an ephemeral placeholder.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/libgfs2.h | 1 -
gfs2/libgfs2/ondisk.c | 2 --
2 files changed, 3 deletions(-)
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 7f6988f8..026edb1b 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -399,7 +399,6 @@ struct lgfs2_dirent {
uint16_t dr_name_len;
uint16_t dr_type;
uint16_t dr_rahead;
- uint32_t dr_cookie;
};
struct lgfs2_leaf {
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 734e0b91..5d2f4a6b 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -338,7 +338,6 @@ void lgfs2_dirent_in(struct lgfs2_dirent *d, void *dep)
d->dr_name_len = be16_to_cpu(de->de_name_len);
d->dr_type = be16_to_cpu(de->de_type);
d->dr_rahead = be16_to_cpu(de->de_rahead);
- d->dr_cookie = be32_to_cpu(de->de_cookie);
}
void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep)
@@ -351,7 +350,6 @@ void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep)
de->de_name_len = cpu_to_be16(d->dr_name_len);
de->de_type = cpu_to_be16(d->dr_type);
de->de_rahead = cpu_to_be16(d->dr_rahead);
- de->de_cookie = cpu_to_be32(d->dr_cookie);
}
void lgfs2_leaf_in(struct lgfs2_leaf *lf, void *lfp)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 16/27: libgfs2: Fix endianness conversions for
superblock padding fields
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 328230d17d7edada08c531444d4079885a6853c8
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jun 9 17:45:50 2021 +0100
libgfs2: Fix endianness conversions for superblock padding fields
Padding fields in struct gfs2_sb aren't bitwise-tagged so parse them
through a struct gfs_sb pointer.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/ondisk.c | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 1b6679b5..734e0b91 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -58,53 +58,55 @@ void lgfs2_meta_header_print(void *mhp)
void lgfs2_sb_in(struct gfs2_sbd *sdp, void *buf)
{
struct gfs2_sb *sb = buf;
+ struct gfs_sb *sb1 = buf;
sdp->sd_fs_format = be32_to_cpu(sb->sb_fs_format);
sdp->sd_multihost_format = be32_to_cpu(sb->sb_multihost_format);
- sdp->sd_flags = be32_to_cpu(sb->__pad0);
+ sdp->sd_flags = be32_to_cpu(sb1->sb_flags);
sdp->sd_bsize = be32_to_cpu(sb->sb_bsize);
sdp->sd_bsize_shift = be32_to_cpu(sb->sb_bsize_shift);
- sdp->sd_seg_size = be32_to_cpu(sb->__pad1);
+ sdp->sd_seg_size = be32_to_cpu(sb1->sb_seg_size);
sdp->sd_meta_dir.no_formal_ino = be64_to_cpu(sb->sb_master_dir.no_formal_ino);
sdp->sd_meta_dir.no_addr = be64_to_cpu(sb->sb_master_dir.no_addr);
sdp->sd_root_dir.no_formal_ino = be64_to_cpu(sb->sb_root_dir.no_formal_ino);
sdp->sd_root_dir.no_addr = be64_to_cpu(sb->sb_root_dir.no_addr);
memcpy(sdp->sd_lockproto, sb->sb_lockproto, GFS2_LOCKNAME_LEN);
memcpy(sdp->sd_locktable, sb->sb_locktable, GFS2_LOCKNAME_LEN);
- sdp->sd_rindex_di.no_formal_ino = be64_to_cpu(sb->__pad2.no_formal_ino);
- sdp->sd_rindex_di.no_addr = be64_to_cpu(sb->__pad2.no_addr);
- sdp->sd_quota_di.no_formal_ino = be64_to_cpu(sb->__pad3.no_formal_ino);
- sdp->sd_quota_di.no_addr = be64_to_cpu(sb->__pad3.no_addr);
- sdp->sd_license_di.no_formal_ino = be64_to_cpu(sb->__pad4.no_formal_ino);
- sdp->sd_license_di.no_addr = be64_to_cpu(sb->__pad4.no_addr);
+ sdp->sd_rindex_di.no_formal_ino = be64_to_cpu(sb1->sb_rindex_di.no_formal_ino);
+ sdp->sd_rindex_di.no_addr = be64_to_cpu(sb1->sb_rindex_di.no_addr);
+ sdp->sd_quota_di.no_formal_ino = be64_to_cpu(sb1->sb_quota_di.no_formal_ino);
+ sdp->sd_quota_di.no_addr = be64_to_cpu(sb1->sb_quota_di.no_addr);
+ sdp->sd_license_di.no_formal_ino = be64_to_cpu(sb1->sb_license_di.no_formal_ino);
+ sdp->sd_license_di.no_addr = be64_to_cpu(sb1->sb_license_di.no_addr);
memcpy(sdp->sd_uuid, sb->sb_uuid, sizeof(sdp->sd_uuid));
}
void lgfs2_sb_out(const struct gfs2_sbd *sdp, void *buf)
{
struct gfs2_sb *sb = buf;
+ struct gfs_sb *sb1 = buf;
sb->sb_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
sb->sb_header.mh_type = cpu_to_be32(GFS2_METATYPE_SB);
sb->sb_header.mh_format = cpu_to_be32(GFS2_FORMAT_SB);
sb->sb_fs_format = cpu_to_be32(sdp->sd_fs_format);
sb->sb_multihost_format = cpu_to_be32(sdp->sd_multihost_format);
- sb->__pad0 = cpu_to_be32(sdp->sd_flags);
+ sb1->sb_flags = cpu_to_be32(sdp->sd_flags);
sb->sb_bsize = cpu_to_be32(sdp->sd_bsize);
sb->sb_bsize_shift = cpu_to_be32(sdp->sd_bsize_shift);
- sb->__pad1 = cpu_to_be32(sdp->sd_seg_size);
+ sb1->sb_seg_size = cpu_to_be32(sdp->sd_seg_size);
sb->sb_master_dir.no_formal_ino = cpu_to_be64(sdp->sd_meta_dir.no_formal_ino);
sb->sb_master_dir.no_addr = cpu_to_be64(sdp->sd_meta_dir.no_addr);
sb->sb_root_dir.no_formal_ino = cpu_to_be64(sdp->sd_root_dir.no_formal_ino);
sb->sb_root_dir.no_addr = cpu_to_be64(sdp->sd_root_dir.no_addr);
memcpy(sb->sb_lockproto, sdp->sd_lockproto, GFS2_LOCKNAME_LEN);
memcpy(sb->sb_locktable, sdp->sd_locktable, GFS2_LOCKNAME_LEN);
- sb->__pad2.no_formal_ino = cpu_to_be64(sdp->sd_rindex_di.no_formal_ino);
- sb->__pad2.no_addr = cpu_to_be64(sdp->sd_rindex_di.no_addr);
- sb->__pad3.no_formal_ino = cpu_to_be64(sdp->sd_quota_di.no_formal_ino);
- sb->__pad3.no_addr = cpu_to_be64(sdp->sd_quota_di.no_addr);
- sb->__pad4.no_formal_ino = cpu_to_be64(sdp->sd_license_di.no_formal_ino);
- sb->__pad4.no_addr = cpu_to_be64(sdp->sd_license_di.no_addr);
+ sb1->sb_rindex_di.no_formal_ino = cpu_to_be64(sdp->sd_rindex_di.no_formal_ino);
+ sb1->sb_rindex_di.no_addr = cpu_to_be64(sdp->sd_rindex_di.no_addr);
+ sb1->sb_quota_di.no_formal_ino = cpu_to_be64(sdp->sd_quota_di.no_formal_ino);
+ sb1->sb_quota_di.no_addr = cpu_to_be64(sdp->sd_quota_di.no_addr);
+ sb1->sb_license_di.no_formal_ino = cpu_to_be64(sdp->sd_license_di.no_formal_ino);
+ sb1->sb_license_di.no_addr = cpu_to_be64(sdp->sd_license_di.no_addr);
memcpy(sb->sb_uuid, sdp->sd_uuid, 16);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 15/27: libgfs2: Remove gfs2_meta_header_{in,out}
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 7f49fb53d7ee29ae5a90d5673bc058fce4127b8e
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jun 9 17:18:40 2021 +0100
libgfs2: Remove gfs2_meta_header_{in,out}
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 30 ++++++++--------
gfs2/fsck/initialize.c | 11 +++---
gfs2/fsck/pass1.c | 16 +++++----
gfs2/fsck/rgrepair.c | 56 ++++++++++++++++-------------
gfs2/libgfs2/fs_ops.c | 87 ++++++++++++++++++++++++---------------------
gfs2/libgfs2/gfs1.c | 24 ++++++-------
gfs2/libgfs2/lang.c | 8 ++---
gfs2/libgfs2/libgfs2.h | 2 --
gfs2/libgfs2/ondisk.c | 36 -------------------
gfs2/libgfs2/structures.c | 8 ++---
gfs2/mkfs/main_jadd.c | 8 ++---
11 files changed, 132 insertions(+), 154 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 32f32064..4439b77a 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -278,12 +278,12 @@ static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
struct gfs2_buffer_head *bh;
unsigned int amount, ptramt;
int hdrsize, h, copied = 0, new;
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header mh = {0};
char *srcptr = (char *)first_nonzero_ptr;
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_IN;
- mh.mh_format = GFS2_FORMAT_IN;
+ mh.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ mh.mh_type = cpu_to_be32(GFS2_METATYPE_IN);
+ mh.mh_format = cpu_to_be32(GFS2_FORMAT_IN);
if (!ip->i_height)
unstuff_dinode(ip);
@@ -304,7 +304,7 @@ static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
bh = bread(sbp, block);
if (new)
memset(bh->b_data, 0, sbp->sd_bsize);
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
}
@@ -436,11 +436,11 @@ static uint64_t fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
struct gfs2_buffer_head *bh;
unsigned int amount, ptramt;
int h, copied = 0, new = 0;
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header mh = {0};
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_IN;
- mh.mh_format = GFS2_FORMAT_IN;
+ mh.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ mh.mh_type = cpu_to_be32(GFS2_METATYPE_IN);
+ mh.mh_format = cpu_to_be32(GFS2_FORMAT_IN);
if (!ip->i_height)
unstuff_dinode(ip);
@@ -463,7 +463,7 @@ static uint64_t fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
if (new)
memset(bh->b_data, 0, sbp->sd_bsize);
if (h < (blk->height - 1)) {
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
}
}
@@ -1835,12 +1835,12 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
struct gfs_jindex *jndx;
struct rgrp_tree *rgd, *rgdhigh;
struct osi_node *n, *next = NULL;
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header mh = {0};
uint64_t ri_addr;
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_RB;
- mh.mh_format = GFS2_FORMAT_RB;
+ mh.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ mh.mh_type = cpu_to_be32(GFS2_METATYPE_RB);
+ mh.mh_format = cpu_to_be32(GFS2_FORMAT_RB);
log_notice(_("Converting journal space to rg space.\n"));
/* Go through each journal, converting them one by one */
for (j = 0; j < orig_journals; j++) { /* for each journal */
@@ -1907,7 +1907,7 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
rgd->bits[0].bi_modified = 1;
for (unsigned i = 1; i < rgd->rt_length; i++) {
- gfs2_meta_header_out(&mh, rgd->bits[i].bi_data);
+ memcpy(rgd->bits[i].bi_data, &mh, sizeof(mh));
rgd->bits[i].bi_modified = 1;
}
} /* for each journal */
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index c2a8029d..9d661dce 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -1147,7 +1147,6 @@ static int find_rgs_for_bsize(struct gfs2_sbd *sdp, uint64_t startblock,
uint32_t chk;
char *p;
int found_rg;
- struct gfs2_meta_header mh;
sdp->sd_bsize = GFS2_DEFAULT_BSIZE;
max_rg_size = 524288;
@@ -1173,15 +1172,19 @@ static int find_rgs_for_bsize(struct gfs2_sbd *sdp, uint64_t startblock,
/* Try all the block sizes in 512 byte multiples */
for (bsize2 = GFS2_BASIC_BLOCK; bsize2 <= GFS2_DEFAULT_BSIZE;
bsize2 += GFS2_BASIC_BLOCK) {
+ struct gfs2_meta_header *mh;
+ int is_rb;
+
rb_addr = (bh->b_blocknr *
(GFS2_DEFAULT_BSIZE / bsize2)) +
(bsize / bsize2) + 1;
sdp->sd_bsize = bsize2; /* temporarily */
rb_bh = bread(sdp, rb_addr);
- gfs2_meta_header_in(&mh, rb_bh->b_data);
+ mh = (struct gfs2_meta_header *)rb_bh->b_data;
+ is_rb = (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC &&
+ be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RB);
brelse(rb_bh);
- if (mh.mh_magic == GFS2_MAGIC &&
- mh.mh_type == GFS2_METATYPE_RB) {
+ if (is_rb) {
log_debug(_("boff:%d bsize2:%d rg:0x%llx, "
"rb:0x%llx\n"), bsize, bsize2,
(unsigned long long)blk,
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index bd3c360a..9526aed2 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -522,7 +522,8 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
q = block_type(bl, block);
if (q != GFS2_BLKST_FREE) {
struct gfs2_buffer_head *bh;
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header *mh;
+ uint32_t mh_type;
log_err(_("Found duplicate %s block %"PRIu64" (0x%"PRIx64") "
"referenced as data by dinode %"PRIu64" (0x%"PRIx64") "),
@@ -548,13 +549,14 @@ static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
return 1;
case GFS2_BLKST_USED: /* tough decision: May be data or meta */
bh = bread(ip->i_sbd, block);
- gfs2_meta_header_in(&mh, bh->b_data);
+ mh = (struct gfs2_meta_header *)bh->b_data;
+ mh_type = be32_to_cpu(mh->mh_type);
brelse(bh);
- if (mh.mh_magic == GFS2_MAGIC &&
- mh.mh_type >= GFS2_METATYPE_RG &&
- mh.mh_type <= GFS2_METATYPE_QC &&
- mh.mh_type != GFS2_METATYPE_DI &&
- mh.mh_format % 100 == 0) {
+ if (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC &&
+ mh_type >= GFS2_METATYPE_RG &&
+ mh_type <= GFS2_METATYPE_QC &&
+ mh_type != GFS2_METATYPE_DI &&
+ be32_to_cpu(mh->mh_format) % 100 == 0) {
log_info(_("The block was processed earlier "
"as valid metadata, so it can't "
"possibly be data.\n"));
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index fbdc4f34..9d165083 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -319,7 +319,6 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
uint64_t rgrp_dist = 0, used_blocks, block, next_block, twogigs;
struct rgrp_tree *rgd = NULL, *next_rgd;
struct gfs2_buffer_head *bh;
- struct gfs2_meta_header mh;
int first, length, b, found;
uint64_t mega_in_blocks;
uint32_t free_blocks;
@@ -353,15 +352,17 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
first = 1;
found = 0;
while (1) {
+ struct gfs2_meta_header *mh;
+
if (block >= sdp->device.length)
break;
if (block >= prevrgd->rt_addr + twogigs)
break;
bh = bread(sdp, block);
- gfs2_meta_header_in(&mh, bh->b_data);
- if ((mh.mh_magic != GFS2_MAGIC) ||
- (first && mh.mh_type != GFS2_METATYPE_RG) ||
- (!first && mh.mh_type != GFS2_METATYPE_RB)) {
+ mh = (struct gfs2_meta_header *)bh->b_data;
+ if ((be32_to_cpu(mh->mh_magic) != GFS2_MAGIC) ||
+ (first && be32_to_cpu(mh->mh_type) != GFS2_METATYPE_RG) ||
+ (!first && be32_to_cpu(mh->mh_type) != GFS2_METATYPE_RB)) {
brelse(bh);
break;
}
@@ -391,22 +392,21 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
if (next_block + b >= sdp->device.length)
break;
bh = bread(sdp, next_block + b);
- gfs2_meta_header_in(&mh, bh->b_data);
- brelse(bh);
- if (mh.mh_magic == GFS2_MAGIC) {
- if (mh.mh_type == GFS2_METATYPE_RG) {
+ mh = (struct gfs2_meta_header *)bh->b_data;
+ if (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC) {
+ if (be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RG)
found = 1;
- break;
- }
/* if the first thing we find is a bitmap,
there must be a damaged rgrp on the
previous block. */
- if (mh.mh_type == GFS2_METATYPE_RB) {
+ if (be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RB) {
found = 1;
rgrp_dist--;
- break;
}
}
+ brelse(bh);
+ if (found)
+ break;
rgrp_dist++;
}
if (found) {
@@ -429,7 +429,7 @@ static uint64_t hunt_and_peck(struct gfs2_sbd *sdp, uint64_t blk,
{
uint64_t rgrp_dist = 0, block, twogigs, last_block, last_meg;
struct gfs2_buffer_head *bh;
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header *mh;
int b, mega_in_blocks;
/* Skip ahead the previous amount: we might get lucky.
@@ -438,14 +438,16 @@ static uint64_t hunt_and_peck(struct gfs2_sbd *sdp, uint64_t blk,
return sdp->fssize - blk;
bh = bread(sdp, blk + last_bump);
- gfs2_meta_header_in(&mh, bh->b_data);
- brelse(bh);
- if (mh.mh_magic == GFS2_MAGIC && mh.mh_type == GFS2_METATYPE_RG) {
+ mh = (struct gfs2_meta_header *)bh->b_data;
+ if (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC &&
+ be32_to_cpu(mh->mh_type) == GFS2_METATYPE_RG) {
log_info( _("rgrp found at 0x%llx, length=%lld\n"),
(unsigned long long)blk + last_bump,
(unsigned long long)last_bump);
+ brelse(bh);
return last_bump;
}
+ brelse(bh);
rgrp_dist = AWAY_FROM_BITMAPS; /* Get away from any bitmaps
associated with the previous rgrp */
@@ -464,15 +466,19 @@ static uint64_t hunt_and_peck(struct gfs2_sbd *sdp, uint64_t blk,
last_meg = mega_in_blocks;
}
for (b = AWAY_FROM_BITMAPS; b < last_block; b++) {
+ uint32_t magic, type;
+
bh = bread(sdp, block + b);
- gfs2_meta_header_in(&mh, bh->b_data);
+ mh = (struct gfs2_meta_header *)bh->b_data;
+ magic = be32_to_cpu(mh->mh_magic);
+ type = be32_to_cpu(mh->mh_type);
brelse(bh);
- if (mh.mh_magic == GFS2_MAGIC) {
- if (mh.mh_type == GFS2_METATYPE_RG)
+ if (magic == GFS2_MAGIC) {
+ if (type == GFS2_METATYPE_RG)
break;
/* if the first thing we find is a bitmap, there must
be a damaged rgrp on the previous block. */
- if (mh.mh_type == GFS2_METATYPE_RB) {
+ if (type == GFS2_METATYPE_RB) {
rgrp_dist--;
break;
}
@@ -923,11 +929,11 @@ static int rewrite_rg_block(struct gfs2_sbd *sdp, struct rgrp_tree *rg,
}
if (x) {
struct gfs2_meta_header mh = {
- .mh_magic = GFS2_MAGIC,
- .mh_type = GFS2_METATYPE_RB,
- .mh_format = GFS2_FORMAT_RB
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_RB),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_RB)
};
- gfs2_meta_header_out(&mh, buf);
+ memcpy(buf, &mh, sizeof(mh));
} else {
rg->rt_free = rg->rt_data;
if (sdp->gfs1)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 4cc9b275..dae6d1b7 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -246,14 +246,14 @@ void unstuff_dinode(struct gfs2_inode *ip)
if (lgfs2_meta_alloc(ip, &block))
exit(1);
if (isdir) {
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_JD),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_JD)
+ };
bh = bget(sdp, block);
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_JD;
- mh.mh_format = GFS2_FORMAT_JD;
- gfs2_meta_header_out(&mh, bh->b_data);
-
+ memcpy(bh->b_data, &mh, sizeof(mh));
buffer_copy_tail(sdp, bh,
sizeof(struct gfs2_meta_header),
ip->i_bh, sizeof(struct gfs2_dinode));
@@ -399,15 +399,16 @@ void build_height(struct gfs2_inode *ip, int height)
}
if (new_block) {
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_IN),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_IN)
+ };
if (lgfs2_meta_alloc(ip, &block))
exit(1);
bh = bget(sdp, block);
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_IN;
- mh.mh_format = GFS2_FORMAT_IN;
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
buffer_copy_tail(sdp, bh,
sizeof(struct gfs2_meta_header),
ip->i_bh, sizeof(struct gfs2_dinode));
@@ -514,12 +515,13 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
return;
if (*new) {
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_IN),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_IN)
+ };
bh = bget(sdp, *dblock);
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_IN;
- mh.mh_format = GFS2_FORMAT_IN;
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
} else {
if (*dblock == ip->i_addr)
@@ -707,11 +709,12 @@ int __gfs2_writei(struct gfs2_inode *ip, void *buf,
if (new) {
bh = bget(sdp, dblock);
if (isdir) {
- struct gfs2_meta_header mh;
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_JD;
- mh.mh_format = GFS2_FORMAT_JD;
- gfs2_meta_header_out(&mh, bh->b_data);
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_JD),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_JD),
+ };
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
}
} else {
@@ -907,11 +910,12 @@ void dir_split_leaf(struct gfs2_inode *dip, uint32_t start, uint64_t leaf_no,
exit(1);
nbh = bget(dip->i_sbd, bn);
{
- struct gfs2_meta_header mh;
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_LF;
- mh.mh_format = GFS2_FORMAT_LF;
- gfs2_meta_header_out(&mh, nbh->b_data);
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_LF),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_LF)
+ };
+ memcpy(nbh->b_data, &mh, sizeof(mh));
bmodified(nbh);
buffer_clear_tail(dip->i_sbd, nbh,
sizeof(struct gfs2_meta_header));
@@ -1182,15 +1186,15 @@ restart:
continue;
} else {
- struct gfs2_meta_header mh;
-
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_LF),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_LF)
+ };
if (lgfs2_meta_alloc(dip, &bn))
exit(1);
nbh = bget(dip->i_sbd, bn);
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_LF;
- mh.mh_format = GFS2_FORMAT_LF;
- gfs2_meta_header_out(&mh, nbh->b_data);
+ memcpy(nbh->b_data, &mh, sizeof(mh));
bmodified(nbh);
leaf->lf_next = cpu_to_be64(bn);
@@ -1239,11 +1243,12 @@ static void dir_make_exhash(struct gfs2_inode *dip)
exit(1);
bh = bget(sdp, bn);
{
- struct gfs2_meta_header mh;
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_LF;
- mh.mh_format = GFS2_FORMAT_LF;
- gfs2_meta_header_out(&mh, bh->b_data);
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_LF),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_LF)
+ };
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
}
@@ -1434,9 +1439,9 @@ int lgfs2_write_filemeta(struct gfs2_inode *ip)
uint64_t ptr0 = ip->i_addr + 1;
unsigned ptrs = 1;
struct gfs2_meta_header mh = {
- .mh_magic = GFS2_MAGIC,
- .mh_type = GFS2_METATYPE_IN,
- .mh_format = GFS2_FORMAT_IN,
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_IN),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_IN)
};
struct gfs2_buffer_head *bh = bget(sdp, ip->i_addr);
if (bh == NULL)
@@ -1462,7 +1467,7 @@ int lgfs2_write_filemeta(struct gfs2_inode *ip)
lgfs2_dinode_out(ip, bh->b_data);
} else {
start += sizeof(struct gfs2_meta_header);
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
}
lgfs2_fill_indir(start, bh->b_data + sdp->sd_bsize, ptr0, ptrs, &p);
if (bwrite(bh)) {
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 97fa32a5..10a196df 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -116,13 +116,13 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
return;
if (*new) {
- struct gfs2_meta_header mh;
-
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_IN),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_IN)
+ };
bh = bget(sdp, *dblock);
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_IN;
- mh.mh_format = GFS2_FORMAT_IN;
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
} else {
if (*dblock == ip->i_addr)
@@ -214,12 +214,12 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
bh = bread(sdp, dblock);
if (journaled && dblock != ip->i_addr ) {
- struct gfs2_meta_header mh;
-
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_JD;
- mh.mh_format = GFS2_FORMAT_JD;
- gfs2_meta_header_out(&mh, bh->b_data);
+ struct gfs2_meta_header mh = {
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(GFS2_METATYPE_JD),
+ .mh_format = cpu_to_be32(GFS2_FORMAT_JD)
+ };
+ memcpy(bh->b_data, &mh, sizeof(mh));
}
memcpy(bh->b_data + offset, buf + copied, amount);
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index 3633c7a7..f0870457 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -551,11 +551,11 @@ static struct lgfs2_lang_result *ast_interp_set(struct lgfs2_lang_state *state,
if (lookup->ast_right->ast_type == AST_EX_TYPESPEC) {
struct gfs2_meta_header mh = {
- .mh_magic = GFS2_MAGIC,
- .mh_type = result->lr_mtype->mh_type,
- .mh_format = result->lr_mtype->mh_format,
+ .mh_magic = cpu_to_be32(GFS2_MAGIC),
+ .mh_type = cpu_to_be32(result->lr_mtype->mh_type),
+ .mh_format = cpu_to_be32(result->lr_mtype->mh_format),
};
- gfs2_meta_header_out(&mh, result->lr_buf);
+ memcpy(result->lr_buf, &mh, sizeof(mh));
lookup = lookup->ast_right;
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index ba22f3bb..7f6988f8 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -810,8 +810,6 @@ extern void print_it(const char *label, const char *fmt, const char *fmt2, ...)
extern void lgfs2_inum_in(struct lgfs2_inum *i, void *inp);
extern void lgfs2_inum_out(struct lgfs2_inum *i, void *inp);
-extern void gfs2_meta_header_in(struct gfs2_meta_header *mh, const char *buf);
-extern void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf);
extern void lgfs2_sb_in(struct gfs2_sbd *sdp, void *buf);
extern void lgfs2_sb_out(const struct gfs2_sbd *sdp, void *buf);
extern void lgfs2_rindex_in(lgfs2_rgrp_t rg, void *buf);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index c6d396f5..1b6679b5 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -9,13 +9,6 @@
#include <uuid.h>
#include "libgfs2.h"
-#define pv(struct, member, fmt, fmt2) do { \
- print_it(" "#member, fmt, fmt2, struct->member); \
- } while (0);
-#define pv2(struct, member, fmt, fmt2) do { \
- print_it(" ", fmt, fmt2, struct->member); \
- } while (0);
-
#define printbe16(struct, member) do { \
print_it(" "#member, "%"PRIu16, "0x%"PRIx16, be16_to_cpu(struct->member)); \
} while(0)
@@ -29,15 +22,6 @@
print_it(" "#member, "%"PRIu8, "0x%"PRIx8, struct->member); \
} while(0)
-#define CPIN_08(s1, s2, member, count) {memcpy((s1->member), (s2->member), (count));}
-#define CPOUT_08(s1, s2, member, count) {memcpy((s2->member), (s1->member), (count));}
-#define CPIN_16(s1, s2, member) {(s1->member) = be16_to_cpu((s2->member));}
-#define CPOUT_16(s1, s2, member) {(s2->member) = cpu_to_be16((s1->member));}
-#define CPIN_32(s1, s2, member) {(s1->member) = be32_to_cpu((s2->member));}
-#define CPOUT_32(s1, s2, member) {(s2->member) = cpu_to_be32((s1->member));}
-#define CPIN_64(s1, s2, member) {(s1->member) = be64_to_cpu((s2->member));}
-#define CPOUT_64(s1, s2, member) {(s2->member) = cpu_to_be64((s1->member));}
-
void lgfs2_inum_in(struct lgfs2_inum *i, void *inp)
{
struct gfs2_inum *in = inp;
@@ -62,26 +46,6 @@ void lgfs2_inum_print(void *nop)
printbe64(no, no_addr);
}
-void gfs2_meta_header_in(struct gfs2_meta_header *mh, const char *buf)
-{
- const struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf;
-
- CPIN_32(mh, str, mh_magic);
- CPIN_32(mh, str, mh_type);
- CPIN_32(mh, str, mh_format);
-}
-
-void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf)
-{
- struct gfs2_meta_header *str = (struct gfs2_meta_header *)buf;
-
- CPOUT_32(mh, str, mh_magic);
- CPOUT_32(mh, str, mh_type);
- CPOUT_32(mh, str, mh_format);
- str->__pad0 = 0;
- str->__pad1 = 0;
-}
-
void lgfs2_meta_header_print(void *mhp)
{
struct gfs2_meta_header *mh = mhp;
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index f0eb8832..9dcf237f 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -377,9 +377,9 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
struct gfs2_buffer_head *bh;
memset(&mh, 0, sizeof(struct gfs2_meta_header));
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_QC;
- mh.mh_format = GFS2_FORMAT_QC;
+ mh.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ mh.mh_type = cpu_to_be32(GFS2_METATYPE_QC);
+ mh.mh_format = cpu_to_be32(GFS2_FORMAT_QC);
sprintf(name, "quota_change%u", j);
ip = createi(per_node, name, S_IFREG | 0600, GFS2_DIF_SYSTEM);
@@ -396,7 +396,7 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
return -1;
memset(bh->b_data, 0, sdp->sd_bsize);
- gfs2_meta_header_out(&mh, bh->b_data);
+ memcpy(bh->b_data, &mh, sizeof(mh));
bmodified(bh);
brelse(bh);
}
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index 66d9e293..8feb201c 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -377,10 +377,10 @@ static int add_qc(struct gfs2_sbd *sdp, struct jadd_opts *opts)
}
memset(&mh, 0, sizeof(struct gfs2_meta_header));
- mh.mh_magic = GFS2_MAGIC;
- mh.mh_type = GFS2_METATYPE_QC;
- mh.mh_format = GFS2_FORMAT_QC;
- gfs2_meta_header_out(&mh, buf);
+ mh.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ mh.mh_type = cpu_to_be32(GFS2_METATYPE_QC);
+ mh.mh_format = cpu_to_be32(GFS2_FORMAT_QC);
+ memcpy(buf, &mh, sizeof(mh));
for (x=0; x<blocks; x++) {
if (write(fd, buf, sdp->sd_bsize) != sdp->sd_bsize) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 14/27: libgfs2: Endianness improvements for gfs2_leaf
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit ff7332fd059e87710296c53b1c9712e2e2245c45
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jun 9 16:17:51 2021 +0100
libgfs2: Endianness improvements for gfs2_leaf
Introduce a lgfs2_leaf native-endian struct and convert the
gfs2_leaf_{in,out} functions to work with it.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/metawalk.c | 16 +++++++++-------
gfs2/fsck/metawalk.h | 2 +-
gfs2/fsck/pass2.c | 10 +++++-----
gfs2/libgfs2/libgfs2.h | 15 +++++++++++++--
gfs2/libgfs2/ondisk.c | 48 ++++++++++++++++++++++--------------------------
5 files changed, 50 insertions(+), 41 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index d915b085..7b5bd873 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -515,10 +515,11 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
* Leaves the buffer around for further analysis (caller must brelse)
*/
int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
- uint64_t *leaf_no, struct gfs2_leaf *leaf, int *ref_count)
+ uint64_t *leaf_no, struct lgfs2_leaf *leaf, int *ref_count)
{
int error = 0, fix;
struct gfs2_buffer_head *lbh = NULL;
+ struct gfs2_leaf *lfp;
uint32_t count = 0;
struct gfs2_sbd *sdp = ip->i_sbd;
const char *msg;
@@ -560,18 +561,19 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
to use cpu_to_be32(), but we should check for incorrect values and
replace them with the correct value. */
- gfs2_leaf_in(leaf, lbh->b_data);
+ lgfs2_leaf_in(leaf, lbh->b_data);
if (leaf->lf_dirent_format == (GFS2_FORMAT_DE << 16)) {
log_debug( _("incorrect lf_dirent_format at leaf #%" PRIu64
"\n"), *leaf_no);
leaf->lf_dirent_format = GFS2_FORMAT_DE;
- gfs2_leaf_out(leaf, lbh->b_data);
+ lgfs2_leaf_out(leaf, lbh->b_data);
bmodified(lbh);
log_debug( _("Fixing lf_dirent_format.\n"));
}
+ lfp = (struct gfs2_leaf *)lbh->b_data;
/* Make sure it's really a leaf. */
- if (leaf->lf_header.mh_type != GFS2_METATYPE_LF) {
+ if (be32_to_cpu(lfp->lf_header.mh_type) != GFS2_METATYPE_LF) {
log_err(_("Inode %"PRIu64" (0x%"PRIx64") points to bad leaf %"PRIu64
" (0x%"PRIx64").\n"),
ip->i_addr, ip->i_addr, *leaf_no, *leaf_no);
@@ -598,7 +600,7 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
changed it. */
brelse(lbh);
lbh = bread(sdp, *leaf_no);
- gfs2_leaf_in(leaf, lbh->b_data);
+ lgfs2_leaf_in(leaf, lbh->b_data);
if (count != leaf->lf_entries) {
log_err(_("Leaf %"PRIu64" (0x%"PRIx64") entry count in "
"directory %"PRIu64" (0x%"PRIx64") does not match "
@@ -607,7 +609,7 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
leaf->lf_entries, count);
if (query( _("Update leaf entry count? (y/n) "))) {
leaf->lf_entries = count;
- gfs2_leaf_out(leaf, lbh->b_data);
+ lgfs2_leaf_out(leaf, lbh->b_data);
bmodified(lbh);
log_warn( _("Leaf entry count updated\n"));
} else
@@ -789,7 +791,7 @@ int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
chained_leaf = 0;
do {
- struct gfs2_leaf leaf;
+ struct lgfs2_leaf leaf;
if (fsck_abort) {
free(tbl);
posix_fadvise(sdp->device_fd, 0, 0, POSIX_FADV_NORMAL);
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index f6c6bc31..a1038854 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -18,7 +18,7 @@ extern int check_linear_dir(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
struct metawalk_fxns *pass);
extern int check_leaf(struct gfs2_inode *ip, int lindex,
struct metawalk_fxns *pass, uint64_t *leaf_no,
- struct gfs2_leaf *leaf, int *ref_count);
+ struct lgfs2_leaf *leaf, int *ref_count);
extern int _fsck_bitmap_set(struct gfs2_inode *ip, uint64_t bblock,
const char *btype, int mark, int error_on_dinode,
const char *caller, int line);
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index 137bf042..e06b45a3 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -1310,7 +1310,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
{
struct gfs2_buffer_head *lbh;
struct lgfs2_dirent dentry;
- struct gfs2_leaf leaf;
+ struct lgfs2_leaf leaf;
struct gfs2_dirent *de;
int changes = 0, error, i, extras, hash_index;
uint64_t new_leaf_blk;
@@ -1421,7 +1421,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
new_leaf_blk = find_free_blk(ip->i_sbd);
dir_split_leaf(ip, lindex, leafblk, lbh);
/* re-read the leaf to pick up dir_split_leaf's changes */
- gfs2_leaf_in(&leaf, lbh->b_data);
+ lgfs2_leaf_in(&leaf, lbh->b_data);
*proper_len = 1 << (ip->i_depth - leaf.lf_depth);
log_err(_("Leaf block %llu (0x%llx) was split from length "
"%d to %d\n"), (unsigned long long)leafblk,
@@ -1608,7 +1608,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
int error = 0;
int lindex, len, proper_len, i, changes = 0;
uint64_t leafblk;
- struct gfs2_leaf leaf;
+ struct lgfs2_leaf leaf;
struct gfs2_buffer_head *lbh;
int factor;
uint32_t proper_start;
@@ -1713,7 +1713,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
(unsigned long long)leafblk,
proper_len, proper_len);
lbh = bread(ip->i_sbd, leafblk);
- gfs2_leaf_in(&leaf, lbh->b_data);
+ lgfs2_leaf_in(&leaf, lbh->b_data);
if (gfs2_check_meta(lbh->b_data, GFS2_METATYPE_LF) ||
leaf.lf_depth > ip->i_depth)
leaf.lf_depth = factor;
@@ -1752,7 +1752,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
/* Now we have to determine if the hash table is
corrupt, or if the leaf has the wrong depth. */
lbh = bread(ip->i_sbd, leafblk);
- gfs2_leaf_in(&leaf, lbh->b_data);
+ lgfs2_leaf_in(&leaf, lbh->b_data);
brelse(lbh);
/* Calculate the expected pointer count based on the
leaf depth. */
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 6a7b3097..ba22f3bb 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -402,6 +402,17 @@ struct lgfs2_dirent {
uint32_t dr_cookie;
};
+struct lgfs2_leaf {
+ uint16_t lf_depth;
+ uint16_t lf_entries;
+ uint32_t lf_dirent_format;
+ uint64_t lf_next;
+ uint64_t lf_inode;
+ uint32_t lf_dist;
+ uint32_t lf_nsec;
+ uint64_t lf_sec;
+};
+
struct metapath {
unsigned int mp_list[GFS2_MAX_META_HEIGHT];
};
@@ -811,8 +822,8 @@ extern void lgfs2_dinode_in(struct gfs2_inode *ip, char *buf);
extern void lgfs2_dinode_out(struct gfs2_inode *ip, char *buf);
extern void lgfs2_dirent_in(struct lgfs2_dirent *d, void *dep);
extern void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep);
-extern void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf);
-extern void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf);
+extern void lgfs2_leaf_in(struct lgfs2_leaf *lf, void *lfp);
+extern void lgfs2_leaf_out(struct lgfs2_leaf *lf, void *lfp);
/* Printing functions. These expect on-disk data */
extern void lgfs2_inum_print(void *nop);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 1e7adbeb..c6d396f5 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -388,36 +388,32 @@ void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep)
de->de_cookie = cpu_to_be32(d->dr_cookie);
}
-void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf)
+void lgfs2_leaf_in(struct lgfs2_leaf *lf, void *lfp)
{
- struct gfs2_leaf *str = (struct gfs2_leaf *)buf;
-
- gfs2_meta_header_in(&lf->lf_header, buf);
- CPIN_16(lf, str, lf_depth);
- CPIN_16(lf, str, lf_entries);
- CPIN_32(lf, str, lf_dirent_format);
- CPIN_64(lf, str, lf_next);
- CPIN_64(lf, str, lf_inode);
- CPIN_32(lf, str, lf_dist);
- CPIN_32(lf, str, lf_nsec);
- CPIN_64(lf, str, lf_sec);
- CPIN_08(lf, str, lf_reserved2, 40);
+ struct gfs2_leaf *l = lfp;
+
+ lf->lf_depth = be16_to_cpu(l->lf_depth);
+ lf->lf_entries = be16_to_cpu(l->lf_entries);
+ lf->lf_dirent_format = be32_to_cpu(l->lf_dirent_format);
+ lf->lf_next = be64_to_cpu(l->lf_next);
+ lf->lf_inode = be64_to_cpu(l->lf_inode);
+ lf->lf_dist = be32_to_cpu(l->lf_dist);
+ lf->lf_nsec = be32_to_cpu(l->lf_nsec);
+ lf->lf_sec = be64_to_cpu(l->lf_sec);
}
-void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf)
+void lgfs2_leaf_out(struct lgfs2_leaf *lf, void *lfp)
{
- struct gfs2_leaf *str = (struct gfs2_leaf *)buf;
-
- gfs2_meta_header_out(&lf->lf_header, buf);
- CPOUT_16(lf, str, lf_depth);
- CPOUT_16(lf, str, lf_entries);
- CPOUT_32(lf, str, lf_dirent_format);
- CPOUT_64(lf, str, lf_next);
- CPOUT_64(lf, str, lf_inode);
- CPOUT_32(lf, str, lf_dist);
- CPOUT_32(lf, str, lf_nsec);
- CPOUT_64(lf, str, lf_sec);
- CPOUT_08(lf, str, lf_reserved2, 40);
+ struct gfs2_leaf *l = lfp;
+
+ l->lf_depth = cpu_to_be16(lf->lf_depth);
+ l->lf_entries = cpu_to_be16(lf->lf_entries);
+ l->lf_dirent_format = cpu_to_be32(lf->lf_dirent_format);
+ l->lf_next = cpu_to_be64(lf->lf_next);
+ l->lf_inode = cpu_to_be64(lf->lf_inode);
+ l->lf_dist = cpu_to_be32(lf->lf_dist);
+ l->lf_nsec = cpu_to_be32(lf->lf_nsec);
+ l->lf_sec = cpu_to_be64(lf->lf_sec);
}
void lgfs2_leaf_print(void *lfp)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 13/27: Remove some users of gfs2_leaf_in()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit fd1b381013eed6671a2cdbc2a3c98d313c5befe0
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jun 9 15:48:33 2021 +0100
Remove some users of gfs2_leaf_in()
Just interpret the data through a gfs2_leaf pointer instead.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 10 +++++-----
gfs2/edit/extended.c | 14 ++++++--------
gfs2/edit/gfs2hex.c | 6 ++----
gfs2/edit/savemeta.c | 19 ++++++++-----------
4 files changed, 21 insertions(+), 28 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 9c703e4c..32f32064 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1266,7 +1266,7 @@ static int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip
/* for all the leafs, get the leaf block and process the dirents inside */
for (leaf_num = 0; ; leaf_num++) {
uint64_t buf;
- struct gfs2_leaf leaf;
+ struct gfs2_leaf *leaf;
error = gfs2_readi(dip, (char *)&buf, leaf_num * sizeof(uint64_t),
sizeof(uint64_t));
@@ -1293,14 +1293,14 @@ static int fix_one_directory_exhash(struct gfs2_sbd *sbp, struct gfs2_inode *dip
(unsigned long long)leaf_block);
break;
}
- gfs2_leaf_in(&leaf, bh_leaf->b_data);
- error = process_dirent_info(dip, sbp, bh_leaf, leaf.lf_entries, dentmod);
+ leaf = (struct gfs2_leaf *)bh_leaf->b_data;
+ error = process_dirent_info(dip, sbp, bh_leaf, be16_to_cpu(leaf->lf_entries), dentmod);
bmodified(bh_leaf);
brelse(bh_leaf);
if (dentmod && error == -EISDIR) /* dentmod was marked DT_DIR, break out */
break;
- if (leaf.lf_next) { /* leaf has a leaf chain, process leaves in chain */
- leaf_block = leaf.lf_next;
+ if (leaf->lf_next) { /* leaf has a leaf chain, process leaves in chain */
+ leaf_block = be64_to_cpu(leaf->lf_next);
error = 0;
goto leaf_chain;
}
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index d2ac8507..58cc2134 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -295,10 +295,6 @@ static void print_inode_type(__be16 de_type)
}
}
-#define LEAF_HINT_FMTS "lf_inode: 0x%"PRIx64", lf_dist: %"PRIu32", " \
- "lf_nsec: %"PRIu32", lf_sec: %"PRIu64", "
-#define LEAF_HINT_FIELDS(lp) lp->lf_inode, lp->lf_dist, lp->lf_nsec, lp->lf_sec,
-
static int display_leaf(struct iinfo *ind)
{
struct gfs2_leaf *leaf = &ind->ii[0].lf;
@@ -309,11 +305,13 @@ static int display_leaf(struct iinfo *ind)
if (gfs2_struct_type == GFS2_METATYPE_SB)
print_gfs2("The superblock has 2 directories");
else
- print_gfs2("Directory block: lf_depth:%"PRIu16", lf_entries:%"PRIu16", "
- LEAF_HINT_FMTS
+ print_gfs2("Directory block: "
+ "lf_depth:%"PRIu16", lf_entries:%"PRIu16", lf_inode: 0x%"PRIx64", "
+ "lf_dist: %"PRIu32", lf_nsec: %"PRIu32", lf_sec: %"PRIu64", "
"fmt:%"PRIu32" next=0x%"PRIx64" (%d dirents).",
- leaf->lf_depth, leaf->lf_entries,
- LEAF_HINT_FIELDS(leaf)
+ be16_to_cpu(leaf->lf_depth), be16_to_cpu(leaf->lf_entries),
+ be64_to_cpu(leaf->lf_inode), be32_to_cpu(leaf->lf_dist),
+ be32_to_cpu(leaf->lf_nsec), be64_to_cpu(leaf->lf_sec),
leaf->lf_dirent_format,
leaf->lf_next,
ind->ii[0].dirents);
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 5a1f9b7f..a18df909 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -300,13 +300,11 @@ void do_dinode_extended(char *buf)
if (p != last || ((y + 1) * sizeof(uint64_t) == be64_to_cpu(dip->di_size))) {
struct gfs2_buffer_head *tmp_bh;
int skip = 0, direntcount = 0;
- struct gfs2_leaf leaf;
unsigned int bufoffset;
if (last >= max_block)
break;
tmp_bh = bread(&sbd, last);
- gfs2_leaf_in(&leaf, tmp_bh->b_data);
indirect->ii[indirect_blocks].dirents = 0;
for (direntcount = 0, bufoffset = sizeof(struct gfs2_leaf);
bufoffset < sbd.sd_bsize;
@@ -336,7 +334,7 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
x = 0;
memset(indir, 0, sizeof(*indir));
- gfs2_leaf_in(&indir->ii[0].lf, dlebuf);
+ memcpy(&indir->ii[0].lf, dlebuf, sizeof(struct gfs2_leaf));
/* Directory Entries: */
for (i = sizeof(struct gfs2_leaf); i < sbd.sd_bsize; i += be16_to_cpu(de->de_rec_len)) {
de = (struct gfs2_dirent *)(dlebuf + i);
@@ -350,7 +348,7 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
if (be16_to_cpu(de->de_rec_len) <= sizeof(struct gfs2_dirent))
break;
}
- return indir->ii[0].lf.lf_next;
+ return be64_to_cpu(indir->ii[0].lf.lf_next);
}
static void do_eattr_extended(char *buf)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 5d51ea1f..09761fe2 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -329,7 +329,7 @@ static size_t di_save_len(const char *buf, uint64_t owner)
static int get_gfs_struct_info(const char *buf, uint64_t owner, unsigned *block_type,
unsigned *gstruct_len)
{
- struct gfs2_meta_header mh;
+ struct gfs2_meta_header *mh = (struct gfs2_meta_header *)buf;
if (block_type != NULL)
*block_type = 0;
@@ -337,17 +337,16 @@ static int get_gfs_struct_info(const char *buf, uint64_t owner, unsigned *block_
if (gstruct_len != NULL)
*gstruct_len = sbd.sd_bsize;
- gfs2_meta_header_in(&mh, buf);
- if (mh.mh_magic != GFS2_MAGIC)
+ if (be32_to_cpu(mh->mh_magic) != GFS2_MAGIC)
return -1;
if (block_type != NULL)
- *block_type = mh.mh_type;
+ *block_type = be32_to_cpu(mh->mh_type);
if (gstruct_len == NULL)
return 0;
- switch (mh.mh_type) {
+ switch (be32_to_cpu(mh->mh_type)) {
case GFS2_METATYPE_SB: /* 1 (superblock) */
if (sbd.gfs1)
*gstruct_len = sizeof(struct gfs_sb);
@@ -791,12 +790,10 @@ new_range:
static int save_leaf_chain(struct metafd *mfd, struct gfs2_sbd *sdp, char *buf)
{
- struct gfs2_leaf leaf;
+ struct gfs2_leaf *leaf = (struct gfs2_leaf *)buf;
- gfs2_leaf_in(&leaf, buf);
-
- while (leaf.lf_next != 0) {
- uint64_t blk = leaf.lf_next;
+ while (leaf->lf_next != 0) {
+ uint64_t blk = be64_to_cpu(leaf->lf_next);
ssize_t r;
if (gfs2_check_range(sdp, blk) != 0)
@@ -817,7 +814,7 @@ static int save_leaf_chain(struct metafd *mfd, struct gfs2_sbd *sdp, char *buf)
return ret;
}
}
- gfs2_leaf_in(&leaf, buf);
+ leaf = (struct gfs2_leaf *)buf;
}
return 0;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 12/27: libgfs2: Endianness improvements for gfs2_inum
and gfs2_dirent
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 259eab1d57154933f8a4c2bdbaff14b3ba5b29e0
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jun 9 14:19:09 2021 +0100
libgfs2: Endianness improvements for gfs2_inum and gfs2_dirent
The uses of structs gfs2_inum and gfs2_dirent are tightly coupled so
these changes had to be made at the same time. Introduce native-endian
structs lgfs2_inum and lgfs2_dirent and conversion functions for them.
Convert users as appropriate.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 64 +++----
gfs2/fsck/afterpass1_common.c | 8 +-
gfs2/fsck/fs_recovery.c | 20 +-
gfs2/fsck/fsck.h | 8 +-
gfs2/fsck/initialize.c | 51 +++---
gfs2/fsck/inode_hash.c | 12 +-
gfs2/fsck/inode_hash.h | 2 +-
gfs2/fsck/link.c | 43 +++--
gfs2/fsck/link.h | 3 +-
gfs2/fsck/lost_n_found.c | 46 ++---
gfs2/fsck/metawalk.c | 61 +++----
gfs2/fsck/pass1.c | 48 +++--
gfs2/fsck/pass2.c | 415 +++++++++++++++++++-----------------------
gfs2/fsck/pass3.c | 115 +++++-------
gfs2/fsck/pass4.c | 25 ++-
gfs2/fsck/util.c | 14 +-
gfs2/libgfs2/fs_ops.c | 56 +++---
gfs2/libgfs2/libgfs2.h | 33 +++-
gfs2/libgfs2/ondisk.c | 71 +++-----
gfs2/libgfs2/structures.c | 14 +-
gfs2/mkfs/main_mkfs.c | 6 +-
21 files changed, 526 insertions(+), 589 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index c8ebfe3b..9c703e4c 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1106,19 +1106,19 @@ static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr, osi_li
return 0;
}/* inode_renumber */
-/* ------------------------------------------------------------------------- */
-/* fetch_inum - fetch an inum entry from disk, given its block */
-/* ------------------------------------------------------------------------- */
+/**
+ * fetch_inum - fetch an inum entry from disk, given its block
+ */
static int fetch_inum(struct gfs2_sbd *sbp, uint64_t iblock,
- struct gfs2_inum *inum, uint64_t *eablk)
+ struct lgfs2_inum *inum, uint64_t *eablk)
{
struct gfs2_inode *fix_inode;
fix_inode = lgfs2_inode_read(sbp, iblock);
if (fix_inode == NULL)
return 1;
- inum->no_formal_ino = fix_inode->i_formal_ino;
- inum->no_addr = fix_inode->i_addr;
+ inum->in_formal_ino = fix_inode->i_formal_ino;
+ inum->in_addr = fix_inode->i_addr;
if (eablk)
*eablk = fix_inode->i_eattr;
@@ -1150,7 +1150,7 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
/* Go through every dirent in the buffer and process it. */
/* Turns out you can't trust dir_entries is correct. */
for (de = 0; ; de++) {
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
int dent_was_gfs1;
if (dentmod) {
@@ -1174,17 +1174,17 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
fflush(stdout);
}
/* fix the dirent's inode number based on the inode */
- gfs2_inum_in(&inum, (char *)&dent->de_inum);
+ lgfs2_inum_in(&inum, &dent->de_inum);
dent_was_gfs1 = (dent->de_inum.no_addr == dent->de_inum.no_formal_ino);
- if (inum.no_formal_ino) { /* if not a sentinel (placeholder) */
- error = fetch_inum(sbp, inum.no_addr, &inum, NULL);
+ if (inum.in_formal_ino) { /* if not a sentinel (placeholder) */
+ error = fetch_inum(sbp, inum.in_addr, &inum, NULL);
if (error) {
- log_crit(_("Error retrieving inode 0x%llx\n"),
- (unsigned long long)inum.no_addr);
+ log_crit(_("Error retrieving inode 0x%"PRIx64"\n"),
+ inum.in_addr);
break;
}
/* fix the dirent's inode number from the fetched inum. */
- dent->de_inum.no_formal_ino = cpu_to_be64(inum.no_formal_ino);
+ dent->de_inum.no_formal_ino = cpu_to_be64(inum.in_formal_ino);
}
/* Fix the dirent's filename hash: They are the same as gfs1 */
/* dent->de_hash = cpu_to_be32(gfs2_disk_hash((char *)(dent + 1), */
@@ -1231,7 +1231,7 @@ static int process_dirent_info(struct gfs2_inode *dip, struct gfs2_sbd *sbp,
struct inode_dir_block *fix;
osi_list_foreach(tmp, &cdpns_to_fix.list) {
fix = osi_list_entry(tmp, struct inode_dir_block, list);
- if (fix->di_addr == inum.no_addr)
+ if (fix->di_addr == inum.in_addr)
fix->di_paddr = dip->i_addr;
}
}
@@ -1392,7 +1392,7 @@ static int fix_cdpn_symlinks(struct gfs2_sbd *sbp, osi_list_t *cdpn_to_fix)
cdpns_fixed = 0;
osi_list_foreach_safe(tmp, cdpn_to_fix, x) {
- struct gfs2_inum fix, dir;
+ struct lgfs2_inum fix, dir;
struct inode_dir_block *l_fix;
struct gfs2_buffer_head *bh = NULL;
struct gfs2_inode *fix_inode;
@@ -1588,7 +1588,7 @@ static int init(struct gfs2_sbd *sbp, struct gfs2_options *opts)
{
struct gfs2_buffer_head *bh;
int rgcount;
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
memset(sbp, 0, sizeof(struct gfs2_sbd));
if ((sbp->device_fd = open(opts->device, O_RDWR)) < 0) {
@@ -1667,15 +1667,15 @@ static int init(struct gfs2_sbd *sbp, struct gfs2_options *opts)
exit(-1);
}
/* get gfs1 rindex inode - gfs1's rindex inode ptr became __pad2 */
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_rindex_di);
- sbp->md.riinode = lgfs2_gfs_inode_read(sbp, inum.no_addr);
+ lgfs2_inum_in(&inum, &gfs1_sb.sb_rindex_di);
+ sbp->md.riinode = lgfs2_gfs_inode_read(sbp, inum.in_addr);
if (sbp->md.riinode == NULL) {
log_crit(_("Could not read resource group index: %s\n"), strerror(errno));
exit(-1);
}
/* get gfs1 jindex inode - gfs1's journal index inode ptr became master */
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_jindex_di);
- sbp->md.jiinode = lgfs2_inode_read(sbp, inum.no_addr);
+ lgfs2_inum_in(&inum, &gfs1_sb.sb_jindex_di);
+ sbp->md.jiinode = lgfs2_inode_read(sbp, inum.in_addr);
if (sbp->md.jiinode == NULL) {
log_crit(_("Could not read journal index: %s\n"), strerror(errno));
exit(-1);
@@ -1958,25 +1958,25 @@ static void write_statfs_file(struct gfs2_sbd *sdp)
/* ------------------------------------------------------------------------- */
static void remove_obsolete_gfs1(struct gfs2_sbd *sbp)
{
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
log_notice(_("Removing obsolete GFS1 file system structures.\n"));
fflush(stdout);
/* Delete the old gfs1 Journal index: */
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_jindex_di);
- gfs2_freedi(sbp, inum.no_addr);
+ lgfs2_inum_in(&inum, &gfs1_sb.sb_jindex_di);
+ gfs2_freedi(sbp, inum.in_addr);
/* Delete the old gfs1 rgindex: */
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_rindex_di);
- gfs2_freedi(sbp, inum.no_addr);
+ lgfs2_inum_in(&inum, &gfs1_sb.sb_rindex_di);
+ gfs2_freedi(sbp, inum.in_addr);
/* Delete the old gfs1 Quota file: */
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_quota_di);
- gfs2_freedi(sbp, inum.no_addr);
+ lgfs2_inum_in(&inum, &gfs1_sb.sb_quota_di);
+ gfs2_freedi(sbp, inum.in_addr);
/* Delete the old gfs1 License file: */
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_license_di);
- gfs2_freedi(sbp, inum.no_addr);
+ lgfs2_inum_in(&inum, &gfs1_sb.sb_license_di);
+ gfs2_freedi(sbp, inum.in_addr);
}
/* ------------------------------------------------------------------------- */
@@ -2116,7 +2116,7 @@ static int check_fit(struct gfs2_sbd *sdp)
*/
static void copy_quotas(struct gfs2_sbd *sdp)
{
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
struct gfs2_inode *oq_ip, *nq_ip;
int err;
@@ -2126,8 +2126,8 @@ static void copy_quotas(struct gfs2_sbd *sdp)
exit(1);
}
- gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_quota_di);
- oq_ip = lgfs2_inode_read(sdp, inum.no_addr);
+ lgfs2_inum_in(&inum, (char *)&gfs1_sb.sb_quota_di);
+ oq_ip = lgfs2_inode_read(sdp, inum.in_addr);
if (oq_ip == NULL) {
fprintf(stderr, _("Couldn't lookup old quota file: %s\n"), strerror(errno));
exit(1);
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c
index 301986f0..c216a5da 100644
--- a/gfs2/fsck/afterpass1_common.c
+++ b/gfs2/fsck/afterpass1_common.c
@@ -118,13 +118,11 @@ static int remove_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* the metawalk_fxn's private field must be set to the dentry
* block we want to clear */
uint64_t *dentryblock = (uint64_t *) private;
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_dirent d;
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&dentry, (char *)dent);
- de = &dentry;
+ lgfs2_dirent_in(&d, dent);
- if (de->de_inum.no_addr == *dentryblock)
+ if (d.dr_inum.in_addr == *dentryblock)
dirent2_del(ip, bh, prev_de, dent);
else
(*count)++;
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index f6dab286..9ce6af26 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -823,27 +823,25 @@ static int check_jindex_dent(struct gfs2_inode *ip, struct gfs2_dirent *dent,
struct gfs2_buffer_head *bh, char *filename,
uint32_t *count, int *lindex, void *priv)
{
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_dirent d;
int i;
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&dentry, (char *)dent);
- de = &dentry;
+ lgfs2_dirent_in(&d, dent);
- if (de->de_name_len == 1 && filename[0] == '.')
+ if (d.dr_name_len == 1 && filename[0] == '.')
goto dirent_good;
- if (de->de_name_len == 2 && filename[0] == '.' && filename[1] == '.')
+ if (d.dr_name_len == 2 && filename[0] == '.' && filename[1] == '.')
goto dirent_good;
- if ((de->de_name_len >= 11) || /* "journal9999" */
- (de->de_name_len <= 7) ||
+ if ((d.dr_name_len >= 11) || /* "journal9999" */
+ (d.dr_name_len <= 7) ||
(strncmp(filename, "journal", 7))) {
- bad_journalname(filename, de->de_name_len);
+ bad_journalname(filename, d.dr_name_len);
return -1;
}
- for (i = 7; i < de->de_name_len; i++) {
+ for (i = 7; i < d.dr_name_len; i++) {
if (filename[i] < '0' || filename[i] > '9') {
- bad_journalname(filename, de->de_name_len);
+ bad_journalname(filename, d.dr_name_len);
return -2;
}
}
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index bc706860..55f5abe8 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -36,7 +36,7 @@ struct gfs2_bmap {
struct inode_info
{
struct osi_node node;
- struct gfs2_inum di_num;
+ struct lgfs2_inum num;
uint32_t di_nlink; /* the number of links the inode
* thinks it has */
uint32_t counted_links; /* the number of links we've found */
@@ -45,9 +45,9 @@ struct inode_info
struct dir_info
{
struct osi_node node;
- struct gfs2_inum dinode;
+ struct lgfs2_inum dinode;
uint64_t treewalk_parent;
- struct gfs2_inum dotdot_parent;
+ struct lgfs2_inum dotdot_parent;
uint32_t di_nlink;
uint32_t counted_links;
uint8_t checked:1;
@@ -133,7 +133,7 @@ extern void dirtree_delete(struct dir_info *b);
/* FIXME: Hack to get this going for pass2 - this should be pulled out
* of pass1 and put somewhere else... */
-struct dir_info *dirtree_insert(struct gfs2_inum inum);
+struct dir_info *dirtree_insert(struct lgfs2_inum inum);
struct gfs2_options {
char *device;
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 35599fb4..c2a8029d 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -453,7 +453,7 @@ static void check_rgrps_integrity(struct gfs2_sbd *sdp)
*/
static int rebuild_master(struct gfs2_sbd *sdp)
{
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
struct gfs2_buffer_head *bh = NULL;
int err = 0;
@@ -463,8 +463,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
return -1;
}
log_err(_("Trying to rebuild the master directory.\n"));
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = sdp->sd_meta_dir.no_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = sdp->sd_meta_dir.no_addr;
err = init_dinode(sdp, &bh, &inum, S_IFDIR | 0755, GFS2_DIF_SYSTEM, &inum);
if (err != 0)
return -1;
@@ -476,8 +476,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
sdp->master_dir->bh_owned = 1;
if (fix_md.jiinode) {
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.jiinode->i_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = fix_md.jiinode->i_addr;
err = dir_add(sdp->master_dir, "jindex", 6, &inum,
IF2DT(S_IFDIR | 0700));
if (err) {
@@ -494,8 +494,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
}
if (fix_md.pinode) {
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.pinode->i_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = fix_md.pinode->i_addr;
err = dir_add(sdp->master_dir, "per_node", 8, &inum,
IF2DT(S_IFDIR | 0700));
if (err) {
@@ -514,8 +514,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
}
if (fix_md.inum) {
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.inum->i_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = fix_md.inum->i_addr;
err = dir_add(sdp->master_dir, "inum", 4, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -532,8 +532,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
}
if (fix_md.statfs) {
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.statfs->i_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = fix_md.statfs->i_addr;
err = dir_add(sdp->master_dir, "statfs", 6, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -550,8 +550,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
}
if (fix_md.riinode) {
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.riinode->i_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = fix_md.riinode->i_addr;
err = dir_add(sdp->master_dir, "rindex", 6, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -567,8 +567,8 @@ static int rebuild_master(struct gfs2_sbd *sdp)
}
if (fix_md.qinode) {
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = fix_md.qinode->i_addr;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = fix_md.qinode->i_addr;
err = dir_add(sdp->master_dir, "quota", 5, &inum,
IF2DT(S_IFREG | 0600));
if (err) {
@@ -987,7 +987,7 @@ static int is_journal_copy(struct gfs2_inode *ip)
static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
{
struct gfs2_inode *child_ip;
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
int error;
if (ip->i_formal_ino == 2) {
@@ -1032,10 +1032,10 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
ip->i_addr);
fix_md.pinode = ip;
error = dir_search(ip, "..", 2, NULL, &inum);
- if (!error && inum.no_addr) {
- sdp->sd_meta_dir.no_addr = inum.no_addr;
+ if (!error && inum.in_addr) {
+ sdp->sd_meta_dir.no_addr = inum.in_addr;
log_warn(_("From per_node's '..' master directory backtracked to: "
- "0x%"PRIx64"\n"), inum.no_addr);
+ "0x%"PRIx64"\n"), inum.in_addr);
}
return;
}
@@ -1076,7 +1076,7 @@ out_discard_ip:
static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
{
struct gfs2_inode *parent_ip;
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
int error;
if (sdp->sd_root_dir.no_addr) /* if we know the root dinode */
@@ -1126,8 +1126,8 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
ip = parent_ip;
}
error = dir_search(ip, "..", 2, NULL, &inum);
- if (!error && inum.no_addr && inum.no_addr < possible_root) {
- possible_root = inum.no_addr;
+ if (!error && inum.in_addr && inum.in_addr < possible_root) {
+ possible_root = inum.in_addr;
log_debug(_("Found a possible root at: 0x%"PRIx64"\n"),
possible_root);
}
@@ -1278,8 +1278,6 @@ static int sb_repair(struct gfs2_sbd *sdp)
return -1;
}
if (!sdp->sd_root_dir.no_addr) {
- struct gfs2_inum inum;
-
log_err(_("Unable to locate the root directory.\n"));
if (possible_root == HIGHEST_BLOCK) {
/* Take advantage of the fact that mkfs.gfs2
@@ -1294,6 +1292,7 @@ static int sb_repair(struct gfs2_sbd *sdp)
sdp->md.rooti = lgfs2_inode_read(sdp, possible_root);
if (!sdp->md.rooti || sdp->md.rooti->i_magic != GFS2_MAGIC) {
struct gfs2_buffer_head *bh = NULL;
+ struct lgfs2_inum inum;
log_err(_("The root dinode block is destroyed.\n"));
log_err(_("At this point I recommend "
@@ -1306,8 +1305,8 @@ static int sb_repair(struct gfs2_sbd *sdp)
"reinitialized; aborting.\n"));
return -1;
}
- inum.no_formal_ino = 1;
- inum.no_addr = possible_root;
+ inum.in_formal_ino = 1;
+ inum.in_addr = possible_root;
error = init_dinode(sdp, &bh, &inum, S_IFDIR | 0755, 0, &inum);
if (error != 0)
return -1;
diff --git a/gfs2/fsck/inode_hash.c b/gfs2/fsck/inode_hash.c
index 09303d73..a1e67b23 100644
--- a/gfs2/fsck/inode_hash.c
+++ b/gfs2/fsck/inode_hash.c
@@ -19,9 +19,9 @@ struct inode_info *inodetree_find(uint64_t block)
while (node) {
struct inode_info *data = (struct inode_info *)node;
- if (block < data->di_num.no_addr)
+ if (block < data->num.in_addr)
node = node->osi_left;
- else if (block > data->di_num.no_addr)
+ else if (block > data->num.in_addr)
node = node->osi_right;
else
return data;
@@ -29,7 +29,7 @@ struct inode_info *inodetree_find(uint64_t block)
return NULL;
}
-struct inode_info *inodetree_insert(struct gfs2_inum di_num)
+struct inode_info *inodetree_insert(struct lgfs2_inum no)
{
struct osi_node **newn = &inodetree.osi_node, *parent = NULL;
struct inode_info *data;
@@ -39,9 +39,9 @@ struct inode_info *inodetree_insert(struct gfs2_inum di_num)
struct inode_info *cur = (struct inode_info *)*newn;
parent = *newn;
- if (di_num.no_addr < cur->di_num.no_addr)
+ if (no.in_addr < cur->num.in_addr)
newn = &((*newn)->osi_left);
- else if (di_num.no_addr > cur->di_num.no_addr)
+ else if (no.in_addr > cur->num.in_addr)
newn = &((*newn)->osi_right);
else
return cur;
@@ -53,7 +53,7 @@ struct inode_info *inodetree_insert(struct gfs2_inum di_num)
return NULL;
}
/* Add new node and rebalance tree. */
- data->di_num = di_num;
+ data->num = no;
osi_link_node(&data->node, parent, newn);
osi_insert_color(&data->node, &inodetree);
diff --git a/gfs2/fsck/inode_hash.h b/gfs2/fsck/inode_hash.h
index ba18ab22..da9d15ce 100644
--- a/gfs2/fsck/inode_hash.h
+++ b/gfs2/fsck/inode_hash.h
@@ -4,7 +4,7 @@
struct inode_info;
extern struct inode_info *inodetree_find(uint64_t block);
-extern struct inode_info *inodetree_insert(struct gfs2_inum di_num);
+extern struct inode_info *inodetree_insert(struct lgfs2_inum no);
extern void inodetree_delete(struct inode_info *b);
#endif /* _INODE_HASH_H */
diff --git a/gfs2/fsck/link.c b/gfs2/fsck/link.c
index 1c5ec3d2..43dd6df4 100644
--- a/gfs2/fsck/link.c
+++ b/gfs2/fsck/link.c
@@ -60,9 +60,9 @@ int set_di_nlink(struct gfs2_inode *ip)
/* If the list has entries, look for one that matches inode_no */
ii = inodetree_find(ip->i_addr);
if (!ii) {
- struct gfs2_inum no = {
- .no_addr = ip->i_addr,
- .no_formal_ino = ip->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = ip->i_addr,
+ .in_formal_ino = ip->i_formal_ino
};
ii = inodetree_insert(no);
}
@@ -81,48 +81,47 @@ int set_di_nlink(struct gfs2_inode *ip)
(unsigned long long)referenced_from, counted_links, \
(unsigned long long)no_addr, why);
-int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip,
- const char *why)
+int incr_link_count(struct lgfs2_inum no, struct gfs2_inode *ip, const char *why)
{
struct inode_info *ii = NULL;
uint64_t referenced_from = ip ? ip->i_addr : 0;
struct dir_info *di;
struct gfs2_inode *link_ip;
- di = dirtree_find(no.no_addr);
+ di = dirtree_find(no.in_addr);
if (di) {
- if (di->dinode.no_formal_ino != no.no_formal_ino)
+ if (di->dinode.in_formal_ino != no.in_formal_ino)
return INCR_LINK_INO_MISMATCH;
di->counted_links++;
- whyincr(no.no_addr, why, referenced_from, di->counted_links);
+ whyincr(no.in_addr, why, referenced_from, di->counted_links);
return INCR_LINK_GOOD;
}
- ii = inodetree_find(no.no_addr);
+ ii = inodetree_find(no.in_addr);
/* If the list has entries, look for one that matches inode_no */
if (ii) {
- if (ii->di_num.no_formal_ino != no.no_formal_ino)
+ if (ii->num.in_formal_ino != no.in_formal_ino)
return INCR_LINK_INO_MISMATCH;
ii->counted_links++;
- whyincr(no.no_addr, why, referenced_from, ii->counted_links);
+ whyincr(no.in_addr, why, referenced_from, ii->counted_links);
return INCR_LINK_GOOD;
}
- if (link1_type(&clink1map, no.no_addr) != 1) {
- link1_set(&clink1map, no.no_addr, 1);
- whyincr(no.no_addr, why, referenced_from, 1);
+ if (link1_type(&clink1map, no.in_addr) != 1) {
+ link1_set(&clink1map, no.in_addr, 1);
+ whyincr(no.in_addr, why, referenced_from, 1);
return INCR_LINK_GOOD;
}
- link_ip = fsck_load_inode(ip->i_sbd, no.no_addr);
+ link_ip = fsck_load_inode(ip->i_sbd, no.in_addr);
/* Check formal ino against dinode before adding to inode tree. */
- if (no.no_formal_ino != link_ip->i_formal_ino) {
+ if (no.in_formal_ino != link_ip->i_formal_ino) {
fsck_inode_put(&link_ip);
return INCR_LINK_INO_MISMATCH; /* inode mismatch */
}
/* Move it from the link1 maps to a real inode tree entry */
- link1_set(&nlink1map, no.no_addr, 0);
- link1_set(&clink1map, no.no_addr, 0);
+ link1_set(&nlink1map, no.in_addr, 0);
+ link1_set(&clink1map, no.in_addr, 0);
/* If no match was found, it must be a hard link. In theory, it can't
be a duplicate because those were resolved in pass1b. Add a new
@@ -132,17 +131,17 @@ int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip,
log_debug( _("Ref: (0x%llx) Error incrementing link for "
"(0x%llx)!\n"),
(unsigned long long)referenced_from,
- (unsigned long long)no.no_addr);
+ (unsigned long long)no.in_addr);
fsck_inode_put(&link_ip);
return INCR_LINK_BAD;
}
- ii->di_num.no_addr = link_ip->i_addr;
- ii->di_num.no_formal_ino = link_ip->i_formal_ino;
+ ii->num.in_addr = link_ip->i_addr;
+ ii->num.in_formal_ino = link_ip->i_formal_ino;
fsck_inode_put(&link_ip);
ii->di_nlink = 1; /* Must be 1 or it wouldn't have gotten into the
nlink1map */
ii->counted_links = 2;
- whyincr(no.no_addr, why, referenced_from, ii->counted_links);
+ whyincr(no.in_addr, why, referenced_from, ii->counted_links);
/* We transitioned a dentry link count from 1 to 2, and we know it's
not a directory. But the new reference has the correct formal
inode number, so the first reference is suspect: we need to
diff --git a/gfs2/fsck/link.h b/gfs2/fsck/link.h
index 0b300225..98872d7b 100644
--- a/gfs2/fsck/link.h
+++ b/gfs2/fsck/link.h
@@ -13,8 +13,7 @@ enum {
int link1_set(struct gfs2_bmap *bmap, uint64_t bblock, int mark);
int set_di_nlink(struct gfs2_inode *ip);
-int incr_link_count(struct gfs2_inum no, struct gfs2_inode *ip,
- const char *why);
+int incr_link_count(struct lgfs2_inum no, struct gfs2_inode *ip, const char *why);
int decr_link_count(uint64_t inode_no, uint64_t referenced_from, int gfs1,
const char *why);
diff --git a/gfs2/fsck/lost_n_found.c b/gfs2/fsck/lost_n_found.c
index 59df4c05..4e543fb1 100644
--- a/gfs2/fsck/lost_n_found.c
+++ b/gfs2/fsck/lost_n_found.c
@@ -22,7 +22,7 @@ static void add_dotdot(struct gfs2_inode *ip)
{
struct gfs2_sbd *sdp = ip->i_sbd;
struct dir_info *di;
- struct gfs2_inum no;
+ struct lgfs2_inum no;
int err;
log_info(_("Adding .. entry to directory %"PRIu64" (0x%"PRIx64") pointing back to lost+found\n"),
@@ -31,14 +31,14 @@ static void add_dotdot(struct gfs2_inode *ip)
/* If there's a pre-existing .. directory entry, we have to
back out the links. */
di = dirtree_find(ip->i_addr);
- if (di && valid_block(sdp, di->dotdot_parent.no_addr)) {
+ if (di && valid_block(sdp, di->dotdot_parent.in_addr)) {
struct gfs2_inode *dip;
log_debug(_("Directory (0x%"PRIx64") already had a '..' link to (0x%"PRIx64").\n"),
- ip->i_addr, di->dotdot_parent.no_addr);
- dip = fsck_load_inode(sdp, di->dotdot_parent.no_addr);
- if (dip->i_formal_ino == di->dotdot_parent.no_formal_ino) {
- decr_link_count(di->dotdot_parent.no_addr, ip->i_addr, sdp->gfs1,
+ ip->i_addr, di->dotdot_parent.in_addr);
+ dip = fsck_load_inode(sdp, di->dotdot_parent.in_addr);
+ if (dip->i_formal_ino == di->dotdot_parent.in_formal_ino) {
+ decr_link_count(di->dotdot_parent.in_addr, ip->i_addr, sdp->gfs1,
_(".. unlinked, moving to lost+found"));
if (dip->i_nlink > 0) {
dip->i_nlink--;
@@ -59,8 +59,8 @@ static void add_dotdot(struct gfs2_inode *ip)
log_debug(_("Directory (0x%"PRIx64")'s link to parent "
"(0x%"PRIx64") had a formal inode discrepancy: "
"was 0x%"PRIx64", expected 0x%"PRIx64"\n"),
- ip->i_addr, di->dotdot_parent.no_addr,
- di->dotdot_parent.no_formal_ino,
+ ip->i_addr, di->dotdot_parent.in_addr,
+ di->dotdot_parent.in_formal_ino,
dip->i_formal_ino);
log_debug(_("The parent directory was not changed.\n"));
}
@@ -71,7 +71,7 @@ static void add_dotdot(struct gfs2_inode *ip)
log_debug(_("Couldn't find a valid '..' entry "
"for orphan directory (0x%"PRIx64"): "
"'..' = 0x%"PRIx64"\n"),
- ip->i_addr, di->dotdot_parent.no_addr);
+ ip->i_addr, di->dotdot_parent.in_addr);
else
log_debug(_("Couldn't find directory (0x%"PRIx64") "
"in directory tree.\n"),
@@ -81,8 +81,8 @@ static void add_dotdot(struct gfs2_inode *ip)
log_warn( _("add_inode_to_lf: Unable to remove "
"\"..\" directory entry.\n"));
- no.no_addr = lf_dip->i_addr;
- no.no_formal_ino = lf_dip->i_formal_ino;
+ no.in_addr = lf_dip->i_addr;
+ no.in_formal_ino = lf_dip->i_formal_ino;
err = dir_add(ip, "..", 2, &no, (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
if (err) {
log_crit(_("Error adding .. directory: %s\n"),
@@ -127,9 +127,9 @@ void make_sure_lf_exists(struct gfs2_inode *ip)
set_di_nlink(sdp->md.rooti);
if (sdp->md.rooti->i_entries > root_entries) {
- struct gfs2_inum no = {
- .no_addr = lf_dip->i_addr,
- .no_formal_ino = lf_dip->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = lf_dip->i_addr,
+ .in_formal_ino = lf_dip->i_formal_ino
};
lf_was_created = 1;
/* This is a new lost+found directory, so set its block type
@@ -143,12 +143,12 @@ void make_sure_lf_exists(struct gfs2_inode *ip)
the rgrp counts properly. */
fsck_bitmap_set(ip, lf_dip->i_addr, _("lost+found dinode"), GFS2_BLKST_DINODE);
/* root inode links to lost+found */
- no.no_addr = sdp->md.rooti->i_addr;
- no.no_formal_ino = sdp->md.rooti->i_formal_ino;
+ no.in_addr = sdp->md.rooti->i_addr;
+ no.in_formal_ino = sdp->md.rooti->i_formal_ino;
incr_link_count(no, lf_dip, _("root"));
/* lost+found link for '.' from itself */
- no.no_addr = lf_dip->i_addr;
- no.no_formal_ino = lf_dip->i_formal_ino;
+ no.in_addr = lf_dip->i_addr;
+ no.in_formal_ino = lf_dip->i_formal_ino;
incr_link_count(no, lf_dip, "\".\"");
/* lost+found link for '..' back to root */
incr_link_count(no, sdp->md.rooti, "\"..\"");
@@ -178,7 +178,7 @@ int add_inode_to_lf(struct gfs2_inode *ip){
char tmp_name[256];
__be32 inode_type;
struct gfs2_sbd *sdp = ip->i_sbd;
- struct gfs2_inum no;
+ struct lgfs2_inum no;
int err = 0;
uint32_t mode;
@@ -229,8 +229,8 @@ int add_inode_to_lf(struct gfs2_inode *ip){
break;
}
- no.no_addr = ip->i_addr;
- no.no_formal_ino = ip->i_formal_ino;
+ no.in_addr = ip->i_addr;
+ no.in_formal_ino = ip->i_formal_ino;
err = dir_add(lf_dip, tmp_name, strlen(tmp_name), &no, inode_type);
if (err) {
log_crit(_("Error adding directory %s: %s\n"),
@@ -242,8 +242,8 @@ int add_inode_to_lf(struct gfs2_inode *ip){
incr_link_count(no, lf_dip, _("from lost+found"));
/* If it's a directory, lost+found is back-linked to it via .. */
if (mode == S_IFDIR) {
- no.no_addr = lf_dip->i_addr;
- no.no_formal_ino = lf_dip->i_formal_ino;
+ no.in_addr = lf_dip->i_addr;
+ no.in_formal_ino = lf_dip->i_formal_ino;
incr_link_count(no, ip, _("to lost+found"));
}
log_notice(_("Added inode #%"PRIu64" (0x%"PRIx64") to lost+found\n"),
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index b699ca8d..d915b085 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -304,7 +304,7 @@ void fsck_inode_put(struct gfs2_inode **ip_in)
/**
* dirent_repair - attempt to repair a corrupt directory entry.
* @bh - The buffer header that contains the bad dirent
- * @de - The directory entry in native format
+ * @dh - The directory entry in native format
* @dent - The directory entry in on-disk format
* @type - Type of directory (DIR_LINEAR or DIR_EXHASH)
* @first - TRUE if this is the first dirent in the buffer
@@ -313,19 +313,19 @@ void fsck_inode_put(struct gfs2_inode **ip_in)
* know at this point is that the length field is wrong.
*/
static int dirent_repair(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
- struct gfs2_dirent *de, struct gfs2_dirent *dent,
+ struct lgfs2_dirent *d, struct gfs2_dirent *dent,
int type, int first)
{
char *bh_end, *p;
int calc_de_name_len = 0;
-
+
/* If this is a sentinel, just fix the length and move on */
- if (first && !de->de_inum.no_formal_ino) { /* Is it a sentinel? */
+ if (first && !d->dr_inum.in_formal_ino) { /* Is it a sentinel? */
if (type == DIR_LINEAR)
- de->de_rec_len = ip->i_sbd->sd_bsize -
+ d->dr_rec_len = ip->i_sbd->sd_bsize -
sizeof(struct gfs2_dinode);
else
- de->de_rec_len = ip->i_sbd->sd_bsize -
+ d->dr_rec_len = ip->i_sbd->sd_bsize -
sizeof(struct gfs2_leaf);
} else {
bh_end = bh->b_data + ip->i_sbd->sd_bsize;
@@ -342,12 +342,12 @@ static int dirent_repair(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
/* There can often be noise at the end, so only */
/* Trust the shorter of the two in case we have too much */
/* Or rather, only trust ours if it's shorter. */
- if (!de->de_name_len || de->de_name_len > NAME_MAX ||
- calc_de_name_len < de->de_name_len) /* if dent is hosed */
- de->de_name_len = calc_de_name_len; /* use ours */
- de->de_rec_len = GFS2_DIRENT_SIZE(de->de_name_len);
+ if (!d->dr_name_len || d->dr_name_len > NAME_MAX ||
+ calc_de_name_len < d->dr_name_len) /* if dent is hosed */
+ d->dr_name_len = calc_de_name_len; /* use ours */
+ d->dr_rec_len = GFS2_DIRENT_SIZE(d->dr_name_len);
}
- gfs2_dirent_out(de, (char *)dent);
+ lgfs2_dirent_out(d, dent);
bmodified(bh);
return 0;
}
@@ -359,14 +359,14 @@ static void dirblk_truncate(struct gfs2_inode *ip, struct gfs2_dirent *fixb,
struct gfs2_buffer_head *bh)
{
char *bh_end;
- struct gfs2_dirent de;
+ struct lgfs2_dirent d;
bh_end = bh->b_data + ip->i_sbd->sd_bsize;
/* truncate the block to save the most dentries. To do this we
have to patch the previous dent. */
- gfs2_dirent_in(&de, (char *)fixb);
- de.de_rec_len = bh_end - (char *)fixb;
- gfs2_dirent_out(&de, (char *)fixb);
+ lgfs2_dirent_in(&d, fixb);
+ d.dr_rec_len = bh_end - (char *)fixb;
+ lgfs2_dirent_out(&d, fixb);
bmodified(bh);
}
@@ -387,8 +387,8 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
int type, uint32_t *count, int lindex,
struct metawalk_fxns *pass)
{
- struct gfs2_dirent *dent;
- struct gfs2_dirent de, *prev;
+ struct gfs2_dirent *dent, *prev;
+ struct lgfs2_dirent d;
int error = 0;
char *bh_end;
char *filename;
@@ -412,20 +412,19 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
while (1) {
if (skip_this_pass || fsck_abort)
return FSCK_OK;
- memset(&de, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&de, (char *)dent);
+ lgfs2_dirent_in(&d, dent);
filename = (char *)dent + sizeof(struct gfs2_dirent);
- if (de.de_rec_len < sizeof(struct gfs2_dirent) +
- de.de_name_len ||
- (de.de_inum.no_formal_ino && !de.de_name_len && !first)) {
+ if (d.dr_rec_len < sizeof(struct gfs2_dirent) +
+ d.dr_name_len ||
+ (d.dr_inum.in_formal_ino && !d.dr_name_len && !first)) {
log_err(_("Directory block %"PRIu64" (0x%"PRIx64"), "
"entry %d of directory %"PRIu64" (0x%"PRIx64") "
"is corrupt.\n"),
bh->b_blocknr, bh->b_blocknr, (*count) + 1,
ip->i_addr, ip->i_addr);
if (query( _("Attempt to repair it? (y/n) "))) {
- if (dirent_repair(ip, bh, &de, dent, type,
+ if (dirent_repair(ip, bh, &d, dent, type,
first)) {
if (first) /* make a new sentinel */
dirblk_truncate(ip, dent, bh);
@@ -448,8 +447,8 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
return 0;
}
}
- if (!de.de_inum.no_formal_ino){
- if (first){
+ if (!d.dr_inum.in_formal_ino) {
+ if (first) {
log_debug( _("First dirent is a sentinel (place holder).\n"));
first = 0;
} else {
@@ -471,12 +470,12 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
return 0;
}
} else {
- if (!de.de_inum.no_addr && first) { /* reverse sentinel */
+ if (!d.dr_inum.in_addr && first) { /* reverse sentinel */
log_debug( _("First dirent is a Sentinel (place holder).\n"));
/* Swap the two to silently make it a proper sentinel */
- de.de_inum.no_addr = de.de_inum.no_formal_ino;
- de.de_inum.no_formal_ino = 0;
- gfs2_dirent_out(&de, (char *)dent);
+ d.dr_inum.in_addr = d.dr_inum.in_formal_ino;
+ d.dr_inum.in_formal_ino = 0;
+ lgfs2_dirent_out(&d, dent);
bmodified(bh);
/* Mark dirent buffer as modified */
first = 0;
@@ -492,7 +491,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
}
}
- if ((char *)dent + de.de_rec_len >= bh_end){
+ if ((char *)dent + d.dr_rec_len >= bh_end){
log_debug(_("Last entry processed for %"PRIu64"->%"PRIu64
"(0x%"PRIx64"->0x%"PRIx64"), di_blocks=%"PRIu64".\n"),
ip->i_addr, bh->b_blocknr, ip->i_addr,
@@ -505,7 +504,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
if (!error || first)
prev = dent;
first = 0;
- dent = (struct gfs2_dirent *)((char *)dent + de.de_rec_len);
+ dent = (struct gfs2_dirent *)((char *)dent + d.dr_rec_len);
}
return 0;
}
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 047a96b0..bd3c360a 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -231,18 +231,16 @@ static int resuscitate_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
uint32_t *count, int *lindex, void *priv)
{
struct gfs2_sbd *sdp = ip->i_sbd;
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_dirent d;
char tmp_name[PATH_MAX];
uint64_t block;
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&dentry, (char *)dent);
- de = &dentry;
- block = de->de_inum.no_addr;
+ lgfs2_dirent_in(&d, dent);
+ block = d.dr_inum.in_addr;
/* Start of checks */
memset(tmp_name, 0, sizeof(tmp_name));
- if (de->de_name_len < sizeof(tmp_name))
- strncpy(tmp_name, filename, de->de_name_len);
+ if (d.dr_name_len < sizeof(tmp_name))
+ strncpy(tmp_name, filename, d.dr_name_len);
else
strncpy(tmp_name, filename, sizeof(tmp_name) - 1);
if (!valid_block_ip(ip, block)) {
@@ -1214,7 +1212,7 @@ struct metawalk_fxns eattr_undo_fxns = {
static int set_ip_blockmap(struct gfs2_inode *ip)
{
uint64_t block = ip->i_bh->b_blocknr;
- struct gfs2_inum no;
+ struct lgfs2_inum no;
uint32_t mode;
const char *ty;
@@ -1248,8 +1246,8 @@ static int set_ip_blockmap(struct gfs2_inode *ip)
default:
return -EINVAL;
}
- no.no_addr = ip->i_addr;
- no.no_formal_ino = ip->i_formal_ino;
+ no.in_addr = ip->i_addr;
+ no.in_formal_ino = ip->i_formal_ino;
if (fsck_blockmap_set(ip, block, ty, GFS2_BLKST_DINODE) ||
(mode == S_IFDIR && !dirtree_insert(no))) {
stack;
@@ -1599,9 +1597,9 @@ static int check_system_inode(struct gfs2_sbd *sdp,
filename, GFS2_BLKST_DINODE);
ds.q = GFS2_BLKST_DINODE;
if (isdir) {
- struct gfs2_inum no = {
- .no_addr = (*sysinode)->i_addr,
- .no_formal_ino = (*sysinode)->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = (*sysinode)->i_addr,
+ .in_formal_ino = (*sysinode)->i_formal_ino
};
dirtree_insert(no);
}
@@ -1652,9 +1650,9 @@ static int check_system_inode(struct gfs2_sbd *sdp,
filename, GFS2_BLKST_DINODE);
ds.q = GFS2_BLKST_DINODE;
if (isdir) {
- struct gfs2_inum no = {
- .no_addr = (*sysinode)->i_addr,
- .no_formal_ino = (*sysinode)->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = (*sysinode)->i_addr,
+ .in_formal_ino = (*sysinode)->i_formal_ino
};
dirtree_insert(no);
}
@@ -1769,21 +1767,21 @@ static int check_system_inodes(struct gfs2_sbd *sdp)
journal_count = sdp->md.journals;
/* gfs1's journals aren't dinode, they're just a bunch of blocks. */
if (sdp->gfs1) {
- struct gfs2_inum no;
+ struct lgfs2_inum no;
/* gfs1 has four dinodes that are set in the superblock and
therefore not linked to anything else. We need to adjust
the link counts so pass4 doesn't get confused. */
- no.no_addr = sdp->md.statfs->i_addr;
- no.no_formal_ino = sdp->md.statfs->i_formal_ino;
+ no.in_addr = sdp->md.statfs->i_addr;
+ no.in_formal_ino = sdp->md.statfs->i_formal_ino;
incr_link_count(no, NULL, _("gfs1 statfs inode"));
- no.no_addr = sdp->md.jiinode->i_addr;
- no.no_formal_ino = sdp->md.jiinode->i_formal_ino;
+ no.in_addr = sdp->md.jiinode->i_addr;
+ no.in_formal_ino = sdp->md.jiinode->i_formal_ino;
incr_link_count(no, NULL, _("gfs1 jindex inode"));
- no.no_addr = sdp->md.riinode->i_addr;
- no.no_formal_ino = sdp->md.riinode->i_formal_ino;
+ no.in_addr = sdp->md.riinode->i_addr;
+ no.in_formal_ino = sdp->md.riinode->i_formal_ino;
incr_link_count(no, NULL, _("gfs1 rindex inode"));
- no.no_addr = sdp->md.qinode->i_addr;
- no.no_formal_ino = sdp->md.qinode->i_formal_ino;
+ no.in_addr = sdp->md.qinode->i_addr;
+ no.in_formal_ino = sdp->md.qinode->i_formal_ino;
incr_link_count(no, NULL, _("gfs1 quota inode"));
return 0;
}
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index d8d08056..137bf042 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -32,48 +32,37 @@ struct metawalk_fxns delete_eattrs = {
/* Set children's parent inode in dir_info structure - ext2 does not set
* dotdot inode here, but instead in pass3 - should we? */
-static int set_parent_dir(struct gfs2_sbd *sdp, struct gfs2_inum child,
- struct gfs2_inum parent)
+static int set_parent_dir(struct gfs2_sbd *sdp, struct lgfs2_inum child, struct lgfs2_inum parent)
{
struct dir_info *di;
- di = dirtree_find(child.no_addr);
+ di = dirtree_find(child.in_addr);
if (!di) {
- log_err( _("Unable to find block %llu (0x%llx"
- ") in dir_info list\n"),
- (unsigned long long)child.no_addr,
- (unsigned long long)child.no_addr);
+ log_err(_("Unable to find block %"PRIu64" (0x%"PRIx64") in dir_info list\n"),
+ child.in_addr, child.in_addr);
return -1;
}
- if (di->dinode.no_addr == child.no_addr &&
- di->dinode.no_formal_ino == child.no_formal_ino) {
+ if (di->dinode.in_addr == child.in_addr &&
+ di->dinode.in_formal_ino == child.in_formal_ino) {
if (di->treewalk_parent) {
- log_err( _("Another directory at block %lld (0x%llx) "
- "already contains this child %lld (0x%llx)"
- " - checking parent %lld (0x%llx)\n"),
- (unsigned long long)di->treewalk_parent,
- (unsigned long long)di->treewalk_parent,
- (unsigned long long)child.no_addr,
- (unsigned long long)child.no_addr,
- (unsigned long long)parent.no_addr,
- (unsigned long long)parent.no_addr);
+ log_err(_("Another directory at block %"PRIu64" (0x%"PRIx64") "
+ "already contains this child %"PRIu64" (0x%"PRIx64")"
+ " - checking parent %"PRIu64" (0x%"PRIx64")\n"),
+ di->treewalk_parent, di->treewalk_parent, child.in_addr,
+ child.in_addr, parent.in_addr, parent.in_addr);
return 1;
}
- log_debug( _("Child %lld (0x%llx) has parent %lld (0x%llx)\n"),
- (unsigned long long)child.no_addr,
- (unsigned long long)child.no_addr,
- (unsigned long long)parent.no_addr,
- (unsigned long long)parent.no_addr);
- di->treewalk_parent = parent.no_addr;
+ log_debug(_("Child %"PRIu64" (0x%"PRIx64") has parent %"PRIu64" (0x%"PRIx64")\n"),
+ child.in_addr, child.in_addr, parent.in_addr, parent.in_addr);
+ di->treewalk_parent = parent.in_addr;
}
return 0;
}
/* Set's the child's '..' directory inode number in dir_info structure */
-static int set_dotdot_dir(struct gfs2_sbd *sdp, uint64_t childblock,
- struct gfs2_inum parent)
+static int set_dotdot_dir(struct gfs2_sbd *sdp, uint64_t childblock, struct lgfs2_inum parent)
{
struct dir_info *di;
@@ -83,30 +72,25 @@ static int set_dotdot_dir(struct gfs2_sbd *sdp, uint64_t childblock,
") in dir_info tree\n"), childblock, childblock);
return -1;
}
- if (di->dinode.no_addr != childblock) {
+ if (di->dinode.in_addr != childblock) {
log_debug("'..' doesn't point to what we found: childblock "
- "(0x%llx) != dinode (0x%llx)\n",
- (unsigned long long)childblock,
- (unsigned long long)di->dinode.no_addr);
+ "(0x%"PRIx64") != dinode (0x%"PRIx64")\n",
+ childblock, di->dinode.in_addr);
return -1;
}
/* Special case for root inode because we set it earlier */
- if (di->dotdot_parent.no_addr &&
- sdp->md.rooti->i_addr != di->dinode.no_addr) {
+ if (di->dotdot_parent.in_addr &&
+ sdp->md.rooti->i_addr != di->dinode.in_addr) {
/* This should never happen */
- log_crit( _("Dotdot parent already set for block %llu (0x%llx)"
- "-> %llu (0x%llx)\n"),
- (unsigned long long)childblock,
- (unsigned long long)childblock,
- (unsigned long long)di->dotdot_parent.no_addr,
- (unsigned long long)di->dotdot_parent.no_addr);
+ log_crit(_("Dotdot parent already set for block %"PRIu64" (0x%"PRIx64") "
+ "-> %"PRIu64" (0x%"PRIx64")\n"),
+ childblock, childblock, di->dotdot_parent.in_addr, di->dotdot_parent.in_addr);
return -1;
}
- log_debug("Setting '..' for directory block (0x%llx) to parent "
- "(0x%llx)\n", (unsigned long long)childblock,
- (unsigned long long)parent.no_addr);
- di->dotdot_parent.no_addr = parent.no_addr;
- di->dotdot_parent.no_formal_ino = parent.no_formal_ino;
+ log_debug("Setting '..' for directory block (0x%"PRIx64") to parent (0x%"PRIx64")\n",
+ childblock, parent.in_addr);
+ di->dotdot_parent.in_addr = parent.in_addr;
+ di->dotdot_parent.in_formal_ino = parent.in_formal_ino;
return 0;
}
@@ -176,42 +160,41 @@ struct metawalk_fxns pass2_fxns_delete = {
* 1 if the caller should delete the dirent
*/
static int bad_formal_ino(struct gfs2_inode *ip, struct gfs2_dirent *dent,
- struct gfs2_inum entry, const char *tmp_name,
- int q, struct gfs2_dirent *de,
+ struct lgfs2_inum entry, const char *tmp_name,
+ int q, struct lgfs2_dirent *d,
struct gfs2_buffer_head *bh)
{
struct inode_info *ii;
struct dir_info *di = NULL;
struct gfs2_inode *child_ip;
- struct gfs2_inum childs_dotdot;
+ struct lgfs2_inum childs_dotdot;
struct gfs2_sbd *sdp = ip->i_sbd;
int error;
- struct gfs2_inum inum = { 0 };
+ struct lgfs2_inum inum = {0};
- ii = inodetree_find(entry.no_addr);
+ ii = inodetree_find(entry.in_addr);
if (ii)
- inum = ii->di_num;
+ inum = ii->num;
else {
- di = dirtree_find(entry.no_addr);
+ di = dirtree_find(entry.in_addr);
if (di)
inum = di->dinode;
- else if (link1_type(&clink1map, entry.no_addr) == 1) {
+ else if (link1_type(&clink1map, entry.in_addr) == 1) {
struct gfs2_inode *dent_ip;
- dent_ip = fsck_load_inode(ip->i_sbd, entry.no_addr);
- inum.no_addr = dent_ip->i_addr;
- inum.no_formal_ino = dent_ip->i_formal_ino;
+ dent_ip = fsck_load_inode(ip->i_sbd, entry.in_addr);
+ inum.in_addr = dent_ip->i_addr;
+ inum.in_formal_ino = dent_ip->i_formal_ino;
fsck_inode_put(&dent_ip);
}
}
log_err(_("Directory entry '%s' pointing to block %"PRIu64" (0x%"PRIx64") in "
"directory %"PRIu64" (0x%"PRIx64") has the wrong 'formal' inode number.\n"),
- tmp_name, entry.no_addr, entry.no_addr, ip->i_addr, ip->i_addr);
- log_err(_("The directory entry has %llu (0x%llx) but the inode has "
- "%llu (0x%llx)\n"), (unsigned long long)entry.no_formal_ino,
- (unsigned long long)entry.no_formal_ino,
- (unsigned long long)inum.no_formal_ino,
- (unsigned long long)inum.no_formal_ino);
+ tmp_name, entry.in_addr, entry.in_addr, ip->i_addr, ip->i_addr);
+ log_err(_("The directory entry has %"PRIu64" (0x%"PRIx64") "
+ "but the inode has %"PRIu64" (0x%"PRIx64")\n"),
+ entry.in_formal_ino, entry.in_formal_ino,
+ inum.in_formal_ino, inum.in_formal_ino);
if (q != GFS2_BLKST_DINODE || !strcmp("..", tmp_name)) {
if (query( _("Remove the corrupt directory entry? (y/n) ")))
return 1;
@@ -221,21 +204,21 @@ static int bad_formal_ino(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* We have a directory pointing to another directory, but the
formal inode number still doesn't match. If that directory
has a '..' pointing back, just fix up the no_formal_ino. */
- child_ip = lgfs2_inode_read(sdp, entry.no_addr);
+ child_ip = lgfs2_inode_read(sdp, entry.in_addr);
error = dir_search(child_ip, "..", 2, NULL, &childs_dotdot);
- if (!error && childs_dotdot.no_addr == ip->i_addr) {
+ if (!error && childs_dotdot.in_addr == ip->i_addr) {
log_err( _("The entry points to another directory with intact "
"linkage.\n"));
if (query( _("Fix the bad directory entry? (y/n) "))) {
- struct gfs2_inum no;
+ struct lgfs2_inum no;
log_err( _("Fixing the corrupt directory entry.\n"));
- entry.no_formal_ino = inum.no_formal_ino;
- de->de_inum.no_formal_ino = entry.no_formal_ino;
- gfs2_dirent_out(de, (char *)dent);
+ entry.in_formal_ino = inum.in_formal_ino;
+ d->dr_inum.in_formal_ino = entry.in_formal_ino;
+ lgfs2_dirent_out(d, dent);
bmodified(bh);
incr_link_count(entry, ip, _("fixed reference"));
- no.no_addr = ip->i_addr;
- no.no_formal_ino = ip->i_formal_ino;
+ no.in_addr = ip->i_addr;
+ no.in_formal_ino = ip->i_formal_ino;
set_parent_dir(sdp, entry, no);
} else {
log_err( _("Directory entry not fixed.\n"));
@@ -309,11 +292,11 @@ static int check_leaf_depth(struct gfs2_inode *ip, uint64_t leaf_no,
* Returns: 1 if the dirent is to be removed, 0 if it needs to be kept,
* or -1 on error
*/
-static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
+static int wrong_leaf(struct gfs2_inode *ip, struct lgfs2_inum *entry,
const char *tmp_name, int *lindex, int lindex_max,
int hash_index, struct gfs2_buffer_head *bh,
struct dir_status *ds, struct gfs2_dirent *dent,
- struct gfs2_dirent *de, struct gfs2_dirent *prev_de,
+ struct lgfs2_dirent *d, struct gfs2_dirent *prev_de,
uint32_t *count, int q)
{
struct gfs2_sbd *sdp = ip->i_sbd;
@@ -323,10 +306,8 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
uint64_t *tbl;
int di_depth;
- log_err(_("Directory entry '%s' at block %lld (0x%llx) is on the "
- "wrong leaf block.\n"), tmp_name,
- (unsigned long long)entry->no_addr,
- (unsigned long long)entry->no_addr);
+ log_err(_("Directory entry '%s' at block %"PRIu64" (0x%"PRIx64") is on the wrong leaf block.\n"),
+ tmp_name, entry->in_addr, entry->in_addr);
log_err(_("Leaf index is: 0x%x. The range for this leaf block is "
"0x%x - 0x%x\n"), hash_index, *lindex, lindex_max);
if (!query( _("Move the misplaced directory entry to "
@@ -361,7 +342,7 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
free(tbl);
/* check if it's already on the correct leaf block */
- error = dir_search(ip, tmp_name, de->de_name_len, NULL, &de->de_inum);
+ error = dir_search(ip, tmp_name, d->dr_name_len, NULL, &d->dr_inum);
if (!error) {
log_err(_("The misplaced directory entry already appears on "
"the correct leaf block.\n"));
@@ -371,8 +352,7 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
}
di_depth = ip->i_depth;
- if (dir_add(ip, tmp_name, de->de_name_len, &de->de_inum,
- de->de_type) == 0) {
+ if (dir_add(ip, tmp_name, d->dr_name_len, &d->dr_inum, d->dr_type) == 0) {
log_err(_("The misplaced directory entry was moved to a "
"valid leaf block.\n"));
if (ip->i_depth > di_depth) {
@@ -406,12 +386,12 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
leaf, but that leaf has already been processed. So we have
to nuke the dent from this leaf when we return, but we
still need to do the "good dent" accounting. */
- if (de->de_type == (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR)) {
- struct gfs2_inum no = {
- .no_addr = ip->i_addr,
- .no_formal_ino = ip->i_formal_ino
+ if (d->dr_type == (sdp->gfs1 ? GFS_FILE_DIR : DT_DIR)) {
+ struct lgfs2_inum no = {
+ .in_addr = ip->i_addr,
+ .in_formal_ino = ip->i_formal_ino
};
- error = set_parent_dir(sdp, de->de_inum, no);
+ error = set_parent_dir(sdp, d->dr_inum, no);
if (error > 0)
/* This is a bit of a kludge, but returning 0
in this case causes the caller to go through
@@ -419,10 +399,9 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
deal properly with the hard link. */
return 0;
}
- error = incr_link_count(*entry, ip,
- _("moved valid reference"));
+ error = incr_link_count(*entry, ip, _("moved valid reference"));
if (error > 0 &&
- bad_formal_ino(ip, dent, *entry, tmp_name, q, de, bh) == 1)
+ bad_formal_ino(ip, dent, *entry, tmp_name, q, d, bh) == 1)
return 1; /* nuke it */
/* You cannot do this:
@@ -451,8 +430,8 @@ static int wrong_leaf(struct gfs2_inode *ip, struct gfs2_inum *entry,
* Returns: 1 means corruption, nuke the dentry, 0 means checks pass
*/
static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
- struct gfs2_inum *entry, const char *tmp_name,
- uint32_t *count, struct gfs2_dirent *de,
+ struct lgfs2_inum *entry, const char *tmp_name,
+ uint32_t *count, struct lgfs2_dirent *d,
struct dir_status *ds, int *q,
struct gfs2_buffer_head *bh, int *isdir)
{
@@ -462,10 +441,10 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
int error;
struct inode_info *ii;
struct dir_info *di = NULL;
- struct gfs2_inum inum = { 0 };
+ struct lgfs2_inum inum = {0};
*isdir = 0;
- if (!valid_block_ip(ip, entry->no_addr)) {
+ if (!valid_block_ip(ip, entry->in_addr)) {
log_err(_("Block # referenced by directory entry %s in inode %"PRIu64
" (0x%"PRIx64") is invalid\n"),
tmp_name, ip->i_addr, ip->i_addr);
@@ -481,11 +460,11 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
}
- if (de->de_rec_len < GFS2_DIRENT_SIZE(de->de_name_len) ||
- de->de_name_len > GFS2_FNAMESIZE) {
+ if (d->dr_rec_len < GFS2_DIRENT_SIZE(d->dr_name_len) ||
+ d->dr_name_len > GFS2_FNAMESIZE) {
log_err( _("Dir entry with bad record or name length\n"
"\tRecord length = %u\n\tName length = %u\n"),
- de->de_rec_len, de->de_name_len);
+ d->dr_rec_len, d->dr_name_len);
if (!query( _("Clear the directory entry? (y/n) "))) {
log_err( _("Directory entry not fixed.\n"));
return 0;
@@ -500,29 +479,29 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
return 1;
}
- calculated_hash = gfs2_disk_hash(tmp_name, de->de_name_len);
- if (de->de_hash != calculated_hash){
+ calculated_hash = gfs2_disk_hash(tmp_name, d->dr_name_len);
+ if (d->dr_hash != calculated_hash){
log_err( _("Dir entry with bad hash or name length\n"
"\tHash found = %u (0x%x)\n"
"\tFilename = %s\n"),
- de->de_hash, de->de_hash, tmp_name);
+ d->dr_hash, d->dr_hash, tmp_name);
log_err( _("\tName length found = %u\n"
"\tHash expected = %u (0x%x)\n"),
- de->de_name_len, calculated_hash, calculated_hash);
+ d->dr_name_len, calculated_hash, calculated_hash);
if (!query( _("Fix directory hash for %s? (y/n) "),
tmp_name)) {
log_err( _("Directory entry hash for %s not "
"fixed.\n"), tmp_name);
return 0;
}
- de->de_hash = calculated_hash;
- gfs2_dirent_out(de, (char *)dent);
+ d->dr_hash = calculated_hash;
+ lgfs2_dirent_out(d, dent);
bmodified(bh);
log_err( _("Directory entry hash for %s fixed.\n"),
tmp_name);
}
- *q = bitmap_type(sdp, entry->no_addr);
+ *q = bitmap_type(sdp, entry->in_addr);
/* Get the status of the directory inode */
/**
* 1. Blocks marked "invalid" were invalidated due to duplicate
@@ -539,7 +518,7 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (*q != GFS2_BLKST_DINODE) {
log_err(_("Directory entry '%s' referencing inode %"PRIu64" (0x%"PRIx64") "
"in dir inode %"PRIu64" (0x%"PRIx64") block type %d: %s.\n"),
- tmp_name, entry->no_addr, entry->no_addr, ip->i_addr, ip->i_addr,
+ tmp_name, entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr,
*q, *q == GFS2_BLKST_FREE ?
_("was previously marked invalid") :
_("was deleted or is not an inode"));
@@ -568,32 +547,30 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
return 1;
}
- error = check_file_type(entry->no_addr, de->de_type, *q, sdp->gfs1,
- isdir);
+ error = check_file_type(entry->in_addr, d->dr_type, *q, sdp->gfs1, isdir);
if (error < 0) {
log_err(_("Error: directory entry type is incompatible with block type at block %"PRIu64
" (0x%"PRIx64") in directory inode %"PRIu64" (0x%"PRIx64").\n"),
- entry->no_addr, entry->no_addr, ip->i_addr, ip->i_addr);
+ entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr);
log_err( _("Directory entry type is %d, block type is %d.\n"),
- de->de_type, *q);
+ d->dr_type, *q);
stack;
return -1;
}
if (error > 0) {
- log_err( _("Type '%s' in dir entry (%s, %llu/0x%llx) conflicts"
+ log_err( _("Type '%s' in dir entry (%s, %"PRIu64"/0x%"PRIx64") conflicts"
" with type '%s' in dinode. (Dir entry is stale.)\n"),
- de_type_string(de->de_type), tmp_name,
- (unsigned long long)entry->no_addr,
- (unsigned long long)entry->no_addr,
+ de_type_string(d->dr_type), tmp_name,
+ entry->in_addr, entry->in_addr,
block_type_string(*q));
if (!query( _("Clear stale directory entry? (y/n) "))) {
log_err( _("Stale directory entry remains\n"));
return 0;
}
- if (ip->i_addr == entry->no_addr)
+ if (ip->i_addr == entry->in_addr)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sdp, entry->no_addr);
+ entry_ip = fsck_load_inode(sdp, entry->in_addr);
check_inode_eattr(entry_ip, &delete_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -601,28 +578,28 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
}
/* We need to verify the formal inode number matches. If it doesn't,
it needs to be deleted. */
- ii = inodetree_find(entry->no_addr);
+ ii = inodetree_find(entry->in_addr);
if (ii)
- inum = ii->di_num;
+ inum = ii->num;
else {
- di = dirtree_find(entry->no_addr);
+ di = dirtree_find(entry->in_addr);
if (di)
inum = di->dinode;
- else if (link1_type(&nlink1map, entry->no_addr) == 1) {
+ else if (link1_type(&nlink1map, entry->in_addr) == 1) {
/* Since we don't have ii or di, the only way to
validate formal_ino is to read in the inode, which
would kill performance. So skip it for now. */
return 0;
}
}
- if (inum.no_formal_ino != entry->no_formal_ino) {
+ if (inum.in_formal_ino != entry->in_formal_ino) {
log_err(_("Directory entry '%s' pointing to block %"PRIu64" (0x%"PRIx64") "
"in directory %"PRIu64" (0x%"PRIx64") has the wrong 'formal' inode number.\n"),
- tmp_name, entry->no_addr, entry->no_addr, ip->i_addr, ip->i_addr);
+ tmp_name, entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr);
log_err(_("The directory entry has %"PRIu64" (0x%"PRIx64") but the "
"inode has %"PRIu64" (0x%"PRIx64")\n"),
- entry->no_formal_ino, entry->no_formal_ino,
- inum.no_formal_ino, inum.no_formal_ino);
+ entry->in_formal_ino, entry->in_formal_ino,
+ inum.in_formal_ino, inum.in_formal_ino);
return 1;
}
/* Check for a special case where a (bad) GFS1 dirent points to what
@@ -632,12 +609,12 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
if (ii == NULL && di == NULL && sdp->gfs1) {
struct gfs2_buffer_head *tbh;
- tbh = bread(sdp, entry->no_addr);
+ tbh = bread(sdp, entry->in_addr);
if (gfs2_check_meta(tbh->b_data, GFS2_METATYPE_DI)) { /* not dinode */
log_err(_("Directory entry '%s' pointing to block %"PRIu64
" (0x%"PRIx64") in directory %"PRIu64" (0x%"PRIx64") "
"is not really a GFS1 dinode.\n"), tmp_name,
- entry->no_addr, entry->no_addr, ip->i_addr, ip->i_addr);
+ entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr);
brelse(tbh);
return 1;
}
@@ -653,42 +630,40 @@ static int dirref_find(struct gfs2_inode *ip, struct gfs2_dirent *dent,
{
/* the metawalk_fxn's private field must be set to the dentry
* block we want to clear */
- struct gfs2_inum *entry = (struct gfs2_inum *)private;
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_inum *entry = private;
+ struct lgfs2_dirent dentry, *de;
char fn[MAX_FILENAME];
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&dentry, (char *)dent);
+ memset(&dentry, 0, sizeof(dentry));
+ lgfs2_dirent_in(&dentry, dent);
de = &dentry;
- if (de->de_inum.no_addr != entry->no_addr) {
+ if (de->dr_inum.in_addr != entry->in_addr) {
(*count)++;
return 0;
}
- if (de->de_inum.no_formal_ino == dent->de_inum.no_formal_ino) {
+ if (de->dr_inum.in_formal_ino == be64_to_cpu(dent->de_inum.no_formal_ino)) {
log_debug("Formal inode number matches; must be a hard "
"link.\n");
goto out;
}
log_err(_("The original reference to inode %"PRIu64" (0x%"PRIx64") from "
"directory %"PRIu64" (0x%"PRIx64") has the wrong 'formal' inode "
- "number.\n"), entry->no_addr, entry->no_addr, ip->i_addr, ip->i_addr);
+ "number.\n"), entry->in_addr, entry->in_addr, ip->i_addr, ip->i_addr);
memset(fn, 0, sizeof(fn));
- if (de->de_name_len < MAX_FILENAME)
- strncpy(fn, filename, de->de_name_len);
+ if (de->dr_name_len < MAX_FILENAME)
+ strncpy(fn, filename, de->dr_name_len);
else
strncpy(fn, filename, MAX_FILENAME - 1);
- log_err(_("The bad reference '%s' had formal inode number: %lld "
- "(0x%llx) but the correct value is: %lld (0x%llx)\n"),
- fn, (unsigned long long)de->de_inum.no_formal_ino,
- (unsigned long long)de->de_inum.no_formal_ino,
- (unsigned long long)entry->no_formal_ino,
- (unsigned long long)entry->no_formal_ino);
+ log_err(_("The bad reference '%s' had formal inode number: %"PRIu64
+ " (0x%"PRIx64") but the correct value is: %"PRIu64" (0x%"PRIx64")\n"),
+ fn, de->dr_inum.in_formal_ino, de->dr_inum.in_formal_ino,
+ entry->in_formal_ino, entry->in_formal_ino);
if (!query(_("Delete the bad directory entry? (y/n) "))) {
log_err(_("The corrupt directory entry was not fixed.\n"));
goto out;
}
- decr_link_count(entry->no_addr, ip->i_addr, ip->i_sbd->gfs1,
+ decr_link_count(entry->in_addr, ip->i_addr, ip->i_sbd->gfs1,
_("bad original reference"));
dirent2_del(ip, bh, prev, dent);
log_err(_("The corrupt directory entry '%s' was deleted.\n"), fn);
@@ -713,7 +688,7 @@ out:
* dentry, since we failed to detect the problem earlier.
*/
static int check_suspicious_dirref(struct gfs2_sbd *sdp,
- struct gfs2_inum *entry)
+ struct lgfs2_inum *entry)
{
struct osi_node *tmp, *next = NULL;
struct dir_info *dt;
@@ -721,17 +696,17 @@ static int check_suspicious_dirref(struct gfs2_sbd *sdp,
uint64_t dirblk;
int error = FSCK_OK;
struct metawalk_fxns dirref_hunt = {
- .private = (void *)entry,
+ .private = entry,
.check_dentry = dirref_find,
};
log_debug("This dentry is good, but since this is a second "
- "reference to block 0x%llx, we need to check the "
- "original.\n", (unsigned long long)entry->no_addr);
+ "reference to block 0x%"PRIx64", we need to check the "
+ "original.\n", entry->in_addr);
for (tmp = osi_first(&dirtree); tmp; tmp = next) {
next = osi_next(tmp);
dt = (struct dir_info *)tmp;
- dirblk = dt->dinode.no_addr;
+ dirblk = dt->dinode.in_addr;
if (skip_this_pass || fsck_abort) /* asked to skip the rest */
break;
ip = fsck_load_inode(sdp, dirblk);
@@ -760,30 +735,28 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
struct gfs2_sbd *sdp = ip->i_sbd;
int q = 0;
char tmp_name[MAX_FILENAME];
- struct gfs2_inum entry, no;
+ struct lgfs2_inum entry, no;
struct dir_status *ds = (struct dir_status *) priv;
int error;
struct gfs2_inode *entry_ip = NULL;
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_dirent d;
int hash_index; /* index into the hash table based on the hash */
int lindex_max; /* largest acceptable hash table index for hash */
int isdir;
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&dentry, (char *)dent);
- de = &dentry;
+ lgfs2_dirent_in(&d, dent);
- entry.no_addr = de->de_inum.no_addr;
- entry.no_formal_ino = de->de_inum.no_formal_ino;
+ entry.in_addr = d.dr_inum.in_addr;
+ entry.in_formal_ino = d.dr_inum.in_formal_ino;
/* Start of checks */
memset(tmp_name, 0, MAX_FILENAME);
- if (de->de_name_len < MAX_FILENAME)
- strncpy(tmp_name, filename, de->de_name_len);
+ if (d.dr_name_len < MAX_FILENAME)
+ strncpy(tmp_name, filename, d.dr_name_len);
else
strncpy(tmp_name, filename, MAX_FILENAME - 1);
- error = basic_dentry_checks(ip, dent, &entry, tmp_name, count, de,
+ error = basic_dentry_checks(ip, dent, &entry, tmp_name, count, &d,
ds, &q, bh, &isdir);
if (error)
goto nuke_dentry;
@@ -801,10 +774,10 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
* and check the rest of the '.' entry? */
goto dentry_is_valid;
}
- if (ip->i_addr == entry.no_addr)
+ if (ip->i_addr == entry.in_addr)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sdp, entry.no_addr);
+ entry_ip = fsck_load_inode(sdp, entry.in_addr);
check_inode_eattr(entry_ip, &delete_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -815,11 +788,11 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
* location */
/* check that '.' refers to this inode */
- if (entry.no_addr != ip->i_addr) {
+ if (entry.in_addr != ip->i_addr) {
log_err(_("'.' entry's value incorrect in directory %"PRIu64" (0x%"PRIx64")."
" Points to %"PRIu64" (0x%"PRIx64") when it should point to %"PRIu64
" (0x%"PRIx64").\n"),
- entry.no_addr, entry.no_addr, entry.no_addr, entry.no_addr,
+ entry.in_addr, entry.in_addr, entry.in_addr, entry.in_addr,
ip->i_addr, ip->i_addr);
if (!query( _("Remove '.' reference? (y/n) "))) {
log_err( _("Invalid '.' reference remains\n"));
@@ -827,10 +800,10 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
* this '.' entry is invalid */
goto dentry_is_valid;
}
- if (ip->i_addr == entry.no_addr)
+ if (ip->i_addr == entry.in_addr)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sdp, entry.no_addr);
+ entry_ip = fsck_load_inode(sdp, entry.in_addr);
check_inode_eattr(entry_ip, &delete_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -854,10 +827,10 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
goto dentry_is_valid;
}
- if (ip->i_addr == entry.no_addr)
+ if (ip->i_addr == entry.in_addr)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sdp, entry.no_addr);
+ entry_ip = fsck_load_inode(sdp, entry.in_addr);
check_inode_eattr(entry_ip, &delete_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -872,10 +845,10 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
log_err( _("Bad '..' directory entry remains\n"));
goto dentry_is_valid;
}
- if (ip->i_addr == entry.no_addr)
+ if (ip->i_addr == entry.in_addr)
entry_ip = ip;
else
- entry_ip = fsck_load_inode(sdp, entry.no_addr);
+ entry_ip = fsck_load_inode(sdp, entry.in_addr);
check_inode_eattr(entry_ip, &delete_eattrs);
if (entry_ip != ip)
fsck_inode_put(&entry_ip);
@@ -898,14 +871,14 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* If this is an exhash directory, make sure the dentries in the leaf
block have a hash table index that fits */
if (ip->i_flags & GFS2_DIF_EXHASH) {
- hash_index = hash_table_index(de->de_hash, ip);
+ hash_index = hash_table_index(d.dr_hash, ip);
lindex_max = hash_table_max(*lindex, ip, bh);
if (hash_index < *lindex || hash_index > lindex_max) {
int nuke_dent;
nuke_dent = wrong_leaf(ip, &entry, tmp_name, lindex,
lindex_max, hash_index, bh, ds,
- dent, de, prev_de, count, q);
+ dent, &d, prev_de, count, q);
if (nuke_dent)
goto nuke_dentry;
}
@@ -913,22 +886,18 @@ static int check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
/* After this point we're only concerned with directories */
if (!isdir) {
- log_debug( _("Found non-dir inode dentry pointing to %lld "
- "(0x%llx)\n"),
- (unsigned long long)entry.no_addr,
- (unsigned long long)entry.no_addr);
+ log_debug(_("Found non-dir inode dentry pointing to %"PRIu64" (0x%"PRIx64")\n"),
+ entry.in_addr, entry.in_addr);
goto dentry_is_valid;
}
/*log_debug( _("Found plain directory dentry\n"));*/
- no.no_addr = ip->i_addr;
- no.no_formal_ino = ip->i_formal_ino;
+ no.in_addr = ip->i_addr;
+ no.in_formal_ino = ip->i_formal_ino;
error = set_parent_dir(sdp, entry, no);
if (error > 0) {
- log_err( _("%s: Hard link to block %llu (0x%llx"
- ") detected.\n"), tmp_name,
- (unsigned long long)entry.no_addr,
- (unsigned long long)entry.no_addr);
+ log_err(_("%s: Hard link to block %"PRIu64" (0x%"PRIx64") detected.\n"),
+ tmp_name, entry.in_addr, entry.in_addr);
if (query( _("Clear hard link to directory? (y/n) ")))
goto nuke_dentry;
@@ -947,7 +916,7 @@ dentry_is_valid:
error = check_suspicious_dirref(sdp, &entry);
} else if (error == INCR_LINK_INO_MISMATCH) {
log_err("incr_link_count err=%d.\n", error);
- if (bad_formal_ino(ip, dent, entry, tmp_name, q, de, bh) == 1)
+ if (bad_formal_ino(ip, dent, entry, tmp_name, q, &d, bh) == 1)
goto nuke_dentry;
}
(*count)++;
@@ -1120,7 +1089,8 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
{
char *filename;
char *bh_end = bh->b_data + ip->i_sbd->sd_bsize;
- struct gfs2_dirent de, *dent;
+ struct gfs2_dirent *dent;
+ struct lgfs2_dirent de;
int error;
int isdir = 0;
@@ -1137,29 +1107,29 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
while (1) {
char tmp_name[PATH_MAX];
- memset(&de, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&de, (char *)dent);
+ memset(&de, 0, sizeof(de));
+ lgfs2_dirent_in(&de, dent);
filename = (char *)dent + sizeof(struct gfs2_dirent);
memset(tmp_name, 0, sizeof(tmp_name));
- if (de.de_name_len > sizeof(filename)) {
+ if (de.dr_name_len > sizeof(filename)) {
log_debug(_("Encountered bad filename length; "
"stopped processing.\n"));
break;
}
- memcpy(tmp_name, filename, de.de_name_len);
- if ((de.de_name_len == 1 && filename[0] == '.')) {
+ memcpy(tmp_name, filename, de.dr_name_len);
+ if ((de.dr_name_len == 1 && filename[0] == '.')) {
log_debug(_("Skipping entry '.'\n"));
- } else if (de.de_name_len == 2 && filename[0] == '.' &&
+ } else if (de.dr_name_len == 2 && filename[0] == '.' &&
filename[1] == '.') {
log_debug(_("Skipping entry '..'\n"));
- } else if (!de.de_inum.no_formal_ino) { /* sentinel */
+ } else if (!de.dr_inum.in_formal_ino) { /* sentinel */
log_debug(_("Skipping sentinel '%s'\n"), tmp_name);
} else {
uint32_t count;
struct dir_status ds = {0};
int q = 0;
- error = basic_dentry_checks(ip, dent, &de.de_inum,
+ error = basic_dentry_checks(ip, dent, &de.dr_inum,
tmp_name, &count, &de,
&ds, &q, bh, &isdir);
if (error) {
@@ -1168,8 +1138,8 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
} else {
error = dir_add(lf_dip, filename,
- de.de_name_len, &de.de_inum,
- de.de_type);
+ de.dr_name_len, &de.dr_inum,
+ de.dr_type);
if (error && error != -EEXIST) {
log_err(_("Error %d encountered while "
"trying to relocate \"%s\" "
@@ -1178,27 +1148,24 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
return error;
}
/* This inode is linked from lost+found */
- incr_link_count(de.de_inum, lf_dip,
+ incr_link_count(de.dr_inum, lf_dip,
_("from lost+found"));
/* If it's a directory, lost+found is
back-linked to it via .. */
if (isdir) {
- struct gfs2_inum no = {
- .no_addr = lf_dip->i_addr,
- .no_formal_ino = lf_dip->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = lf_dip->i_addr,
+ .in_formal_ino = lf_dip->i_formal_ino
};
incr_link_count(no, NULL, _("to lost+found"));
}
- log_err(_("Relocated \"%s\", block %llu "
- "(0x%llx) to lost+found.\n"),
- tmp_name,
- (unsigned long long)de.de_inum.no_addr,
- (unsigned long long)de.de_inum.no_addr);
+ log_err(_("Relocated \"%s\", block %"PRIu64" (0x%"PRIx64") to lost+found.\n"),
+ tmp_name, de.dr_inum.in_addr, de.dr_inum.in_addr);
}
}
- if ((char *)dent + de.de_rec_len >= bh_end)
+ if ((char *)dent + de.dr_rec_len >= bh_end)
break;
- dent = (struct gfs2_dirent *)((char *)dent + de.de_rec_len);
+ dent = (struct gfs2_dirent *)((char *)dent + de.dr_rec_len);
}
log_err(_("Directory entries from misplaced leaf block were relocated "
"to lost+found.\n"));
@@ -1221,23 +1188,23 @@ static int basic_check_dentry(struct gfs2_inode *ip, struct gfs2_dirent *dent,
{
int q = 0;
char tmp_name[MAX_FILENAME];
- struct gfs2_inum entry;
+ struct lgfs2_inum entry;
struct dir_status *ds = (struct dir_status *) priv;
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_dirent dentry, *de;
int error;
int isdir;
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
- gfs2_dirent_in(&dentry, (char *)dent);
+ memset(&dentry, 0, sizeof(dentry));
+ lgfs2_dirent_in(&dentry, dent);
de = &dentry;
- entry.no_addr = de->de_inum.no_addr;
- entry.no_formal_ino = de->de_inum.no_formal_ino;
+ entry.in_addr = de->dr_inum.in_addr;
+ entry.in_formal_ino = de->dr_inum.in_formal_ino;
/* Start of checks */
memset(tmp_name, 0, MAX_FILENAME);
- if (de->de_name_len < MAX_FILENAME)
- strncpy(tmp_name, filename, de->de_name_len);
+ if (de->dr_name_len < MAX_FILENAME)
+ strncpy(tmp_name, filename, de->dr_name_len);
else
strncpy(tmp_name, filename, MAX_FILENAME - 1);
@@ -1342,8 +1309,9 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
int len, int *proper_len, int factor)
{
struct gfs2_buffer_head *lbh;
+ struct lgfs2_dirent dentry;
struct gfs2_leaf leaf;
- struct gfs2_dirent dentry, *de;
+ struct gfs2_dirent *de;
int changes = 0, error, i, extras, hash_index;
uint64_t new_leaf_blk;
uint64_t leaf_no;
@@ -1377,14 +1345,13 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
return error;
}
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
+ memset(&dentry, 0, sizeof(dentry));
de = (struct gfs2_dirent *)(lbh->b_data + sizeof(struct gfs2_leaf));
- gfs2_dirent_in(&dentry, (char *)de);
+ lgfs2_dirent_in(&dentry, de);
/* If this is an empty leaf, we can just delete it and pad. */
- if ((dentry.de_rec_len == cpu_to_be16(ip->i_sbd->sd_bsize -
- sizeof(struct gfs2_leaf))) &&
- (dentry.de_inum.no_formal_ino == 0)) {
+ if ((dentry.dr_rec_len == ip->i_sbd->sd_bsize - sizeof(struct gfs2_leaf)) &&
+ (dentry.dr_inum.in_formal_ino == 0)) {
brelse(lbh);
gfs2_free_block(ip->i_sbd, leafblk);
log_err(_("Out of place leaf block %llu (0x%llx) had no "
@@ -1401,7 +1368,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
/* Look at the first dirent and check its hash value to see if it's
at the proper starting offset. */
- hash_index = hash_table_index(dentry.de_hash, ip);
+ hash_index = hash_table_index(dentry.dr_hash, ip);
/* Need to use len here, not *proper_len because the leaf block may
be valid within the range, but starts too soon in the hash table. */
if (hash_index < lindex || hash_index > lindex + len) {
@@ -1523,7 +1490,8 @@ static int check_hash_tbl_dups(struct gfs2_inode *ip, uint64_t *tbl,
uint64_t leafblk, leaf_no;
struct gfs2_buffer_head *lbh;
struct gfs2_leaf leaf;
- struct gfs2_dirent dentry, *de;
+ struct lgfs2_dirent dentry;
+ struct gfs2_dirent *de;
int hash_index; /* index into the hash table based on the hash */
leafblk = be64_to_cpu(tbl[lindex]);
@@ -1560,11 +1528,10 @@ static int check_hash_tbl_dups(struct gfs2_inode *ip, uint64_t *tbl,
continue;
}
- memset(&dentry, 0, sizeof(struct gfs2_dirent));
- de = (struct gfs2_dirent *)(lbh->b_data +
- sizeof(struct gfs2_leaf));
- gfs2_dirent_in(&dentry, (char *)de);
- hash_index = hash_table_index(dentry.de_hash, ip);
+ memset(&dentry, 0, sizeof(dentry));
+ de = (struct gfs2_dirent *)(lbh->b_data + sizeof(struct gfs2_leaf));
+ lgfs2_dirent_in(&dentry, de);
+ hash_index = hash_table_index(dentry.dr_hash, ip);
brelse(lbh);
/* check the duplicate ref first */
if (hash_index < l || hash_index > l + len2) {
@@ -1983,9 +1950,9 @@ static int check_system_dir(struct gfs2_inode *sysinode, const char *dirname,
if (!ds.dotdir) {
log_err( _("No '.' entry found for %s directory.\n"), dirname);
if (query( _("Is it okay to add '.' entry? (y/n) "))) {
- struct gfs2_inum no = {
- .no_addr = sysinode->i_addr,
- .no_formal_ino = sysinode->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = sysinode->i_addr,
+ .in_formal_ino = sysinode->i_formal_ino
};
log_warn( _("Adding '.' entry\n"));
error = dir_add(sysinode, ".", 1, &no,
@@ -2108,9 +2075,9 @@ static int pass2_check_dir(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
(unsigned long long)dirblk, (unsigned long long)dirblk);
if (query( _("Is it okay to add '.' entry? (y/n) "))) {
- struct gfs2_inum no = {
- .no_addr = ip->i_addr,
- .no_formal_ino = ip->i_formal_ino
+ struct lgfs2_inum no = {
+ .in_addr = ip->i_addr,
+ .in_formal_ino = ip->i_formal_ino
};
error = dir_add(ip, ".", 1, &no,
(sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
@@ -2194,7 +2161,7 @@ int pass2(struct gfs2_sbd *sdp)
next = osi_next(tmp);
dt = (struct dir_info *)tmp;
- dirblk = dt->dinode.no_addr;
+ dirblk = dt->dinode.in_addr;
warm_fuzzy_stuff(dirblk);
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return FSCK_OK;
diff --git a/gfs2/fsck/pass3.c b/gfs2/fsck/pass3.c
index 8b8b19bc..f96881f5 100644
--- a/gfs2/fsck/pass3.c
+++ b/gfs2/fsck/pass3.c
@@ -25,7 +25,7 @@ static int attach_dotdot_to(struct gfs2_sbd *sdp, uint64_t newdotdot,
int filename_len = 2;
int err;
struct gfs2_inode *ip, *pip;
- struct gfs2_inum no;
+ struct lgfs2_inum no;
ip = fsck_load_inode(sdp, block);
pip = fsck_load_inode(sdp, newdotdot);
@@ -40,8 +40,8 @@ static int attach_dotdot_to(struct gfs2_sbd *sdp, uint64_t newdotdot,
log_warn( _("Unable to remove \"..\" directory entry.\n"));
else
decr_link_count(olddotdot, block, sdp->gfs1, _("old \"..\""));
- no.no_addr = pip->i_addr;
- no.no_formal_ino = pip->i_formal_ino;
+ no.in_addr = pip->i_addr;
+ no.in_formal_ino = pip->i_formal_ino;
err = dir_add(ip, filename, filename_len, &no,
(sdp->gfs1 ? GFS_FILE_DIR : DT_DIR));
if (err) {
@@ -68,29 +68,23 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
if (!di->treewalk_parent)
return NULL;
- if (di->dotdot_parent.no_addr == di->treewalk_parent) {
- q_dotdot = bitmap_type(sdp, di->dotdot_parent.no_addr);
+ if (di->dotdot_parent.in_addr == di->treewalk_parent) {
+ q_dotdot = bitmap_type(sdp, di->dotdot_parent.in_addr);
if (q_dotdot != GFS2_BLKST_DINODE) {
- log_err( _("Orphaned directory at block %llu (0x%llx) "
- "moved to lost+found\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr);
+ log_err(_("Orphaned directory at block %"PRIu64" (0x%"PRIx64") "
+ "moved to lost+found\n"),
+ di->dinode.in_addr, di->dinode.in_addr);
return NULL;
}
goto out;
}
- log_warn( _("Directory '..' and treewalk connections disagree for "
- "inode %llu (0x%llx)\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr);
- log_notice( _("'..' has %llu (0x%llx), treewalk has %llu (0x%llx)\n"),
- (unsigned long long)di->dotdot_parent.no_addr,
- (unsigned long long)di->dotdot_parent.no_addr,
- (unsigned long long)di->treewalk_parent,
- (unsigned long long)di->treewalk_parent);
- q_dotdot = bitmap_type(sdp, di->dotdot_parent.no_addr);
- dt_dotdot = dirtree_find(di->dotdot_parent.no_addr);
+ log_warn(_("Directory '..' and treewalk connections disagree for inode %"PRIu64" (0x%"PRIx64")\n"),
+ di->dinode.in_addr, di->dinode.in_addr);
+ log_notice(_("'..' has %"PRIu64" (0x%"PRIx64"), treewalk has %"PRIu64" (0x%"PRIx64")\n"),
+ di->dotdot_parent.in_addr, di->dotdot_parent.in_addr, di->treewalk_parent, di->treewalk_parent);
+ q_dotdot = bitmap_type(sdp, di->dotdot_parent.in_addr);
+ dt_dotdot = dirtree_find(di->dotdot_parent.in_addr);
q_treewalk = bitmap_type(sdp, di->treewalk_parent);
dt_treewalk = dirtree_find(di->treewalk_parent);
/* if the dotdot entry isn't a directory, but the
@@ -111,9 +105,9 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
(unsigned long long)di->treewalk_parent,
(unsigned long long)di->treewalk_parent);
attach_dotdot_to(sdp, di->treewalk_parent,
- di->dotdot_parent.no_addr,
- di->dinode.no_addr);
- di->dotdot_parent.no_addr = di->treewalk_parent;
+ di->dotdot_parent.in_addr,
+ di->dinode.in_addr);
+ di->dotdot_parent.in_addr = di->treewalk_parent;
}
goto out;
}
@@ -121,9 +115,9 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
log_err( _("Both .. and treewalk parents are directories, "
"going with treewalk...\n"));
attach_dotdot_to(sdp, di->treewalk_parent,
- di->dotdot_parent.no_addr,
- di->dinode.no_addr);
- di->dotdot_parent.no_addr = di->treewalk_parent;
+ di->dotdot_parent.in_addr,
+ di->dinode.in_addr);
+ di->dotdot_parent.in_addr = di->treewalk_parent;
goto out;
}
log_warn( _(".. parent is valid, but treewalk is bad - reattaching to "
@@ -131,35 +125,30 @@ static struct dir_info *mark_and_return_parent(struct gfs2_sbd *sdp,
/* FIXME: add a dinode for this entry instead? */
- if (!query( _("Remove directory entry for bad inode %llu (0x%llx) in "
- "%llu (0x%llx)? (y/n)"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->treewalk_parent,
- (unsigned long long)di->treewalk_parent)) {
+ if (!query(_("Remove directory entry for bad inode %"PRIu64" (0x%"PRIx64") "
+ "in %"PRIu64" (0x%"PRIx64")? (y/n)"),
+ di->dinode.in_addr, di->dinode.in_addr,
+ di->treewalk_parent, di->treewalk_parent)) {
log_err( _("Directory entry to invalid inode remains\n"));
return NULL;
}
- error = remove_dentry_from_dir(sdp, di->treewalk_parent,
- di->dinode.no_addr);
+ error = remove_dentry_from_dir(sdp, di->treewalk_parent, di->dinode.in_addr);
if (error < 0) {
stack;
return NULL;
}
if (error > 0)
- log_warn( _("Unable to find dentry for block %llu"
- " (0x%llx) in %llu (0x%llx)\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->treewalk_parent,
- (unsigned long long)di->treewalk_parent);
+ log_warn(_("Unable to find dentry for block %"PRIu64" (0x%"PRIx64") "
+ "in %"PRIu64" (0x%"PRIx64")\n"),
+ di->dinode.in_addr, di->dinode.in_addr,
+ di->treewalk_parent, di->treewalk_parent);
log_warn( _("Directory entry removed\n"));
log_info( _("Marking directory unlinked\n"));
return NULL;
out:
- pdi = dirtree_find(di->dotdot_parent.no_addr);
+ pdi = dirtree_find(di->dotdot_parent.in_addr);
return pdi;
}
@@ -233,31 +222,26 @@ int pass3(struct gfs2_sbd *sdp)
tdi = mark_and_return_parent(sdp, di);
if (tdi) {
- log_debug( _("Directory at block %llu "
- "(0x%llx) connected\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr);
+ log_debug(_("Directory at block %"PRIu64" (0x%"PRIx64") connected\n"),
+ di->dinode.in_addr, di->dinode.in_addr);
di = tdi;
continue;
}
- q = bitmap_type(sdp, di->dinode.no_addr);
- ip = fsck_load_inode(sdp, di->dinode.no_addr);
+ q = bitmap_type(sdp, di->dinode.in_addr);
+ ip = fsck_load_inode(sdp, di->dinode.in_addr);
if (q == GFS2_BLKST_FREE) {
log_err( _("Found unlinked directory "
- "containing bad block at block %llu"
- " (0x%llx)\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr);
+ "containing bad block at block %"PRIu64
+ " (0x%"PRIx64")\n"),
+ di->dinode.in_addr, di->dinode.in_addr);
if (query(_("Clear unlinked directory "
"with bad blocks? (y/n) "))) {
- log_warn( _("inode %lld (0x%llx) is "
- "now marked as free\n"),
- (unsigned long long)
- di->dinode.no_addr,
- (unsigned long long)
- di->dinode.no_addr);
+ log_warn(_("inode %"PRIu64" (0x%"PRIx64") is "
+ "now marked as free\n"),
+ di->dinode.in_addr,
+ di->dinode.in_addr);
check_n_fix_bitmap(sdp, ip->i_rgd,
- di->dinode.no_addr,
+ di->dinode.in_addr,
0, GFS2_BLKST_FREE);
fsck_inode_put(&ip);
break;
@@ -274,29 +258,26 @@ int pass3(struct gfs2_sbd *sdp)
fsck_inode_put(&ip);
break;
}
- log_warn( _("inode %lld (0x%llx) is now "
+ log_warn( _("inode %"PRIu64" (0x%"PRIx64") is now "
"marked as free\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr);
+ di->dinode.in_addr, di->dinode.in_addr);
check_n_fix_bitmap(sdp, ip->i_rgd,
- di->dinode.no_addr, 0,
+ di->dinode.in_addr, 0,
GFS2_BLKST_FREE);
log_err( _("The block was cleared\n"));
fsck_inode_put(&ip);
break;
}
- log_err( _("Found unlinked directory at block %llu"
- " (0x%llx)\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr);
+ log_err(_("Found unlinked directory at block %"PRIu64" (0x%"PRIx64")\n"),
+ di->dinode.in_addr, di->dinode.in_addr);
/* Don't skip zero size directories with eattrs */
if (!ip->i_size && !ip->i_eattr){
log_err( _("Unlinked directory has zero "
"size.\n"));
if (query( _("Remove zero-size unlinked "
"directory? (y/n) "))) {
- fsck_bitmap_set(ip, di->dinode.no_addr,
+ fsck_bitmap_set(ip, di->dinode.in_addr,
_("zero-sized unlinked inode"),
GFS2_BLKST_FREE);
fsck_inode_put(&ip);
diff --git a/gfs2/fsck/pass4.c b/gfs2/fsck/pass4.c
index 42892da1..4deac26c 100644
--- a/gfs2/fsck/pass4.c
+++ b/gfs2/fsck/pass4.c
@@ -186,22 +186,22 @@ static int scan_inode_list(struct gfs2_sbd *sdp)
ii = (struct inode_info *)tmp;
/* Don't check reference counts on the special gfs files */
if (sdp->gfs1 &&
- ((ii->di_num.no_addr == sdp->md.riinode->i_addr) ||
- (ii->di_num.no_addr == sdp->md.qinode->i_addr) ||
- (ii->di_num.no_addr == sdp->md.statfs->i_addr)))
+ ((ii->num.in_addr == sdp->md.riinode->i_addr) ||
+ (ii->num.in_addr == sdp->md.qinode->i_addr) ||
+ (ii->num.in_addr == sdp->md.statfs->i_addr)))
continue;
if (ii->counted_links == 0) {
- if (handle_unlinked(sdp, ii->di_num.no_addr,
+ if (handle_unlinked(sdp, ii->num.in_addr,
&ii->counted_links, &lf_addition))
continue;
} /* if (ii->counted_links == 0) */
else if (ii->di_nlink != ii->counted_links) {
- handle_inconsist(sdp, ii->di_num.no_addr,
+ handle_inconsist(sdp, ii->num.in_addr,
&ii->di_nlink, ii->counted_links);
}
log_debug( _("block %llu (0x%llx) has link count %d\n"),
- (unsigned long long)ii->di_num.no_addr,
- (unsigned long long)ii->di_num.no_addr, ii->di_nlink);
+ (unsigned long long)ii->num.in_addr,
+ (unsigned long long)ii->num.in_addr, ii->di_nlink);
} /* osi_list_foreach(tmp, list) */
return adjust_lf_links(lf_addition);
@@ -222,19 +222,18 @@ static int scan_dir_list(struct gfs2_sbd *sdp)
di = (struct dir_info *)tmp;
/* Don't check reference counts on the special gfs files */
if (sdp->gfs1 &&
- di->dinode.no_addr == sdp->md.jiinode->i_addr)
+ di->dinode.in_addr == sdp->md.jiinode->i_addr)
continue;
if (di->counted_links == 0) {
- if (handle_unlinked(sdp, di->dinode.no_addr,
+ if (handle_unlinked(sdp, di->dinode.in_addr,
&di->counted_links, &lf_addition))
continue;
} else if (di->di_nlink != di->counted_links) {
- handle_inconsist(sdp, di->dinode.no_addr,
+ handle_inconsist(sdp, di->dinode.in_addr,
&di->di_nlink, di->counted_links);
}
- log_debug( _("block %llu (0x%llx) has link count %d\n"),
- (unsigned long long)di->dinode.no_addr,
- (unsigned long long)di->dinode.no_addr, di->di_nlink);
+ log_debug(_("block %"PRIu64" (0x%"PRIx64") has link count %d\n"),
+ di->dinode.in_addr, di->dinode.in_addr, di->di_nlink);
} /* osi_list_foreach(tmp, list) */
return adjust_lf_links(lf_addition);
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 962ec1e0..29b3ce81 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -427,7 +427,7 @@ int add_duplicate_ref(struct gfs2_inode *ip, uint64_t block,
return META_IS_GOOD;
}
-struct dir_info *dirtree_insert(struct gfs2_inum inum)
+struct dir_info *dirtree_insert(struct lgfs2_inum inum)
{
struct osi_node **newn = &dirtree.osi_node, *parent = NULL;
struct dir_info *data;
@@ -437,9 +437,9 @@ struct dir_info *dirtree_insert(struct gfs2_inum inum)
struct dir_info *cur = (struct dir_info *)*newn;
parent = *newn;
- if (inum.no_addr < cur->dinode.no_addr)
+ if (inum.in_addr < cur->dinode.in_addr)
newn = &((*newn)->osi_left);
- else if (inum.no_addr > cur->dinode.no_addr)
+ else if (inum.in_addr > cur->dinode.in_addr)
newn = &((*newn)->osi_right);
else
return cur;
@@ -451,8 +451,8 @@ struct dir_info *dirtree_insert(struct gfs2_inum inum)
return NULL;
}
/* Add new node and rebalance tree. */
- data->dinode.no_addr = inum.no_addr;
- data->dinode.no_formal_ino = inum.no_formal_ino;
+ data->dinode.in_addr = inum.in_addr;
+ data->dinode.in_formal_ino = inum.in_formal_ino;
osi_link_node(&data->node, parent, newn);
osi_insert_color(&data->node, &dirtree);
@@ -466,9 +466,9 @@ struct dir_info *dirtree_find(uint64_t block)
while (node) {
struct dir_info *data = (struct dir_info *)node;
- if (block < data->dinode.no_addr)
+ if (block < data->dinode.in_addr)
node = node->osi_left;
- else if (block > data->dinode.no_addr)
+ else if (block > data->dinode.in_addr)
node = node->osi_right;
else
return data;
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index f7205393..4cc9b275 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1135,7 +1135,7 @@ static int get_next_leaf(struct gfs2_inode *dip,struct gfs2_buffer_head *bh_in,
}
static int dir_e_add(struct gfs2_inode *dip, const char *filename, int len,
- struct gfs2_inum *inum, unsigned int type)
+ struct lgfs2_inum *inum, unsigned int type)
{
struct gfs2_buffer_head *bh, *nbh;
struct gfs2_leaf *leaf, *nleaf;
@@ -1211,7 +1211,7 @@ restart:
}
}
- gfs2_inum_out(inum, (char *)&dent->de_inum);
+ lgfs2_inum_out(inum, &dent->de_inum);
dent->de_hash = cpu_to_be32(hash);
dent->de_type = cpu_to_be16(type);
memcpy((char *)(dent + 1), filename, len);
@@ -1292,7 +1292,7 @@ static void dir_make_exhash(struct gfs2_inode *dip)
}
static int dir_l_add(struct gfs2_inode *dip, const char *filename, int len,
- struct gfs2_inum *inum, unsigned int type)
+ struct lgfs2_inum *inum, unsigned int type)
{
struct gfs2_dirent *dent;
int err = 0;
@@ -1303,7 +1303,7 @@ static int dir_l_add(struct gfs2_inode *dip, const char *filename, int len,
return err;
}
- gfs2_inum_out(inum, (char *)&dent->de_inum);
+ lgfs2_inum_out(inum, &dent->de_inum);
dent->de_hash = gfs2_disk_hash(filename, len);
dent->de_hash = cpu_to_be32(dent->de_hash);
dent->de_type = cpu_to_be16(type);
@@ -1313,7 +1313,7 @@ static int dir_l_add(struct gfs2_inode *dip, const char *filename, int len,
}
int dir_add(struct gfs2_inode *dip, const char *filename, int len,
- struct gfs2_inum *inum, unsigned int type)
+ struct lgfs2_inum *inum, unsigned int type)
{
int err = 0;
if (dip->i_flags & GFS2_DIF_EXHASH)
@@ -1323,8 +1323,8 @@ int dir_add(struct gfs2_inode *dip, const char *filename, int len,
return err;
}
-static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct gfs2_inum *inum,
- unsigned int mode, uint32_t flags, struct gfs2_inum *parent, int gfs1)
+static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct lgfs2_inum *inum,
+ unsigned int mode, uint32_t flags, struct lgfs2_inum *parent, int gfs1)
{
struct gfs2_buffer_head *bh;
struct gfs2_dinode *di;
@@ -1340,7 +1340,7 @@ static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, st
return 1;
if (*bhp == NULL) {
- *bhp = bget(sdp, inum->no_addr);
+ *bhp = bget(sdp, inum->in_addr);
if (*bhp == NULL)
return 1;
}
@@ -1352,8 +1352,8 @@ static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, st
di->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
di->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI);
di->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI);
- di->di_num.no_formal_ino = cpu_to_be64(inum->no_formal_ino);
- di->di_num.no_addr = cpu_to_be64(inum->no_addr);
+ di->di_num.no_formal_ino = cpu_to_be64(inum->in_formal_ino);
+ di->di_num.no_addr = cpu_to_be64(inum->in_addr);
di->di_mode = cpu_to_be32(mode);
di->di_nlink = cpu_to_be32(1);
di->di_blocks = cpu_to_be64(1);
@@ -1380,8 +1380,8 @@ static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, st
hash = gfs2_disk_hash("..", 2);
len = sdp->sd_bsize - (p - bh->b_data);
- de.de_inum.no_formal_ino = cpu_to_be64(parent->no_formal_ino);
- de.de_inum.no_addr = cpu_to_be64(parent->no_addr);
+ de.de_inum.no_formal_ino = cpu_to_be64(parent->in_formal_ino);
+ de.de_inum.no_addr = cpu_to_be64(parent->in_addr);
de.de_hash = cpu_to_be32(hash);
de.de_rec_len = cpu_to_be16(len);
de.de_name_len = cpu_to_be16(2);
@@ -1401,8 +1401,8 @@ static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, st
return 0;
}
-int init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct gfs2_inum *inum,
- unsigned int mode, uint32_t flags, struct gfs2_inum *parent)
+int init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct lgfs2_inum *inum,
+ unsigned int mode, uint32_t flags, struct lgfs2_inum *parent)
{
return __init_dinode(sdp, bhp, inum, mode, flags, parent, 0);
}
@@ -1482,7 +1482,7 @@ static struct gfs2_inode *__createi(struct gfs2_inode *dip,
{
struct gfs2_sbd *sdp = dip->i_sbd;
uint64_t bn;
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
struct gfs2_buffer_head *bh = NULL;
struct gfs2_inode *ip;
int err = 0;
@@ -1490,19 +1490,19 @@ static struct gfs2_inode *__createi(struct gfs2_inode *dip,
gfs2_lookupi(dip, filename, strlen(filename), &ip);
if (!ip) {
- struct gfs2_inum parent = {
- .no_formal_ino = dip->i_formal_ino,
- .no_addr = dip->i_addr,
+ struct lgfs2_inum parent = {
+ .in_formal_ino = dip->i_formal_ino,
+ .in_addr = dip->i_addr,
};
err = lgfs2_dinode_alloc(sdp, 1, &bn);
if (err != 0)
return NULL;
if (if_gfs1)
- inum.no_formal_ino = bn;
+ inum.in_formal_ino = bn;
else
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = bn;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = bn;
err = dir_add(dip, filename, strlen(filename), &inum, IF2DT(mode));
if (err)
@@ -1692,7 +1692,7 @@ static int linked_leaf_search(struct gfs2_inode *dip, const char *filename,
* Returns:
*/
static int dir_e_search(struct gfs2_inode *dip, const char *filename,
- int len, unsigned int *type, struct gfs2_inum *inum)
+ int len, unsigned int *type, struct lgfs2_inum *inum)
{
struct gfs2_buffer_head *bh = NULL;
struct gfs2_dirent *dent;
@@ -1702,7 +1702,7 @@ static int dir_e_search(struct gfs2_inode *dip, const char *filename,
if (error)
return error;
- gfs2_inum_in(inum, (char *)&dent->de_inum);
+ lgfs2_inum_in(inum, &dent->de_inum);
if (type)
*type = be16_to_cpu(dent->de_type);
@@ -1721,7 +1721,7 @@ static int dir_e_search(struct gfs2_inode *dip, const char *filename,
* Returns:
*/
static int dir_l_search(struct gfs2_inode *dip, const char *filename,
- int len, unsigned int *type, struct gfs2_inum *inum)
+ int len, unsigned int *type, struct lgfs2_inum *inum)
{
struct gfs2_dirent *dent;
int error;
@@ -1731,7 +1731,7 @@ static int dir_l_search(struct gfs2_inode *dip, const char *filename,
error = leaf_search(dip, dip->i_bh, filename, len, &dent, NULL);
if (!error) {
- gfs2_inum_in(inum, (char *)&dent->de_inum);
+ lgfs2_inum_in(inum, &dent->de_inum);
if(type)
*type = be16_to_cpu(dent->de_type);
}
@@ -1752,7 +1752,7 @@ static int dir_l_search(struct gfs2_inode *dip, const char *filename,
* Returns: 0 if found, -1 on failure, -ENOENT if not found.
*/
int dir_search(struct gfs2_inode *dip, const char *filename, int len,
- unsigned int *type, struct gfs2_inum *inum)
+ unsigned int *type, struct lgfs2_inum *inum)
{
int error;
@@ -1868,7 +1868,7 @@ int gfs2_lookupi(struct gfs2_inode *dip, const char *filename, int len,
{
struct gfs2_sbd *sdp = dip->i_sbd;
int error = 0;
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
*ipp = NULL;
@@ -1880,7 +1880,7 @@ int gfs2_lookupi(struct gfs2_inode *dip, const char *filename, int len,
}
error = dir_search(dip, filename, len, NULL, &inum);
if (!error)
- *ipp = lgfs2_inode_read(sdp, inum.no_addr);
+ *ipp = lgfs2_inode_read(sdp, inum.in_addr);
return error;
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 361f97e8..6a7b3097 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -375,6 +375,11 @@ struct gfs2_sbd {
int gfs1;
};
+struct lgfs2_inum {
+ uint64_t in_formal_ino;
+ uint64_t in_addr;
+};
+
struct lgfs2_log_header {
uint64_t lh_sequence;
uint32_t lh_flags;
@@ -387,6 +392,16 @@ struct lgfs2_log_header {
int64_t lh_local_dinodes;
};
+struct lgfs2_dirent {
+ struct lgfs2_inum dr_inum;
+ uint32_t dr_hash;
+ uint16_t dr_rec_len;
+ uint16_t dr_name_len;
+ uint16_t dr_type;
+ uint16_t dr_rahead;
+ uint32_t dr_cookie;
+};
+
struct metapath {
unsigned int mp_list[GFS2_MAX_META_HEIGHT];
};
@@ -500,8 +515,8 @@ extern int gfs2_readi(struct gfs2_inode *ip, void *buf, uint64_t offset,
__gfs2_writei(ip, buf, offset, size, 1)
extern int __gfs2_writei(struct gfs2_inode *ip, void *buf, uint64_t offset,
unsigned int size, int resize);
-extern int init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct gfs2_inum *inum,
- unsigned int mode, uint32_t flags, struct gfs2_inum *parent);
+extern int init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, struct lgfs2_inum *inum,
+ unsigned int mode, uint32_t flags, struct lgfs2_inum *parent);
extern struct gfs2_inode *createi(struct gfs2_inode *dip, const char *filename,
unsigned int mode, uint32_t flags);
extern struct gfs2_inode *gfs_createi(struct gfs2_inode *dip,
@@ -510,11 +525,11 @@ extern struct gfs2_inode *gfs_createi(struct gfs2_inode *dip,
extern void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
struct gfs2_dirent *prev, struct gfs2_dirent *cur);
extern int dir_search(struct gfs2_inode *dip, const char *filename, int len,
- unsigned int *type, struct gfs2_inum *inum);
+ unsigned int *type, struct lgfs2_inum *inum);
extern int gfs2_lookupi(struct gfs2_inode *dip, const char *filename, int len,
struct gfs2_inode **ipp);
extern int dir_add(struct gfs2_inode *dip, const char *filename, int len,
- struct gfs2_inum *inum, unsigned int type);
+ struct lgfs2_inum *inum, unsigned int type);
extern int gfs2_dirent_del(struct gfs2_inode *dip, const char *filename,
int filename_len);
extern void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
@@ -753,7 +768,7 @@ extern int lgfs2_sb_write(const struct gfs2_sbd *sdp, int fd);
extern int build_journal(struct gfs2_sbd *sdp, int j,
struct gfs2_inode *jindex);
extern int build_jindex(struct gfs2_sbd *sdp);
-extern int lgfs2_build_jindex(struct gfs2_inode *master, struct gfs2_inum *jnls, size_t nmemb);
+extern int lgfs2_build_jindex(struct gfs2_inode *master, struct lgfs2_inum *jnls, size_t nmemb);
extern int build_per_node(struct gfs2_sbd *sdp);
extern int build_inum(struct gfs2_sbd *sdp);
extern int build_statfs(struct gfs2_sbd *sdp);
@@ -782,8 +797,8 @@ extern void print_it(const char *label, const char *fmt, const char *fmt2, ...)
/* Translation functions */
-extern void gfs2_inum_in(struct gfs2_inum *no, char *buf);
-extern void gfs2_inum_out(const struct gfs2_inum *no, char *buf);
+extern void lgfs2_inum_in(struct lgfs2_inum *i, void *inp);
+extern void lgfs2_inum_out(struct lgfs2_inum *i, void *inp);
extern void gfs2_meta_header_in(struct gfs2_meta_header *mh, const char *buf);
extern void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf);
extern void lgfs2_sb_in(struct gfs2_sbd *sdp, void *buf);
@@ -794,8 +809,8 @@ extern void lgfs2_rgrp_in(lgfs2_rgrp_t rg, void *buf);
extern void lgfs2_rgrp_out(const lgfs2_rgrp_t rg, void *buf);
extern void lgfs2_dinode_in(struct gfs2_inode *ip, char *buf);
extern void lgfs2_dinode_out(struct gfs2_inode *ip, char *buf);
-extern void gfs2_dirent_in(struct gfs2_dirent *de, char *buf);
-extern void gfs2_dirent_out(struct gfs2_dirent *de, char *buf);
+extern void lgfs2_dirent_in(struct lgfs2_dirent *d, void *dep);
+extern void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep);
extern void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf);
extern void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 659f4038..1e7adbeb 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -38,33 +38,20 @@
#define CPIN_64(s1, s2, member) {(s1->member) = be64_to_cpu((s2->member));}
#define CPOUT_64(s1, s2, member) {(s2->member) = cpu_to_be64((s1->member));}
-/*
- * gfs2_xxx_in - read in an xxx struct
- * first arg: the cpu-order structure
- * buf: the disk-order block data
- *
- * gfs2_xxx_out - write out an xxx struct
- * first arg: the cpu-order structure
- * buf: the disk-order block data
- *
- * gfs2_xxx_print - print out an xxx struct
- * first arg: the cpu-order structure
- */
-
-void gfs2_inum_in(struct gfs2_inum *no, char *buf)
+void lgfs2_inum_in(struct lgfs2_inum *i, void *inp)
{
- struct gfs2_inum *str = (struct gfs2_inum *)buf;
+ struct gfs2_inum *in = inp;
- CPIN_64(no, str, no_formal_ino);
- CPIN_64(no, str, no_addr);
+ i->in_formal_ino = be64_to_cpu(in->no_formal_ino);
+ i->in_addr = be64_to_cpu(in->no_addr);
}
-void gfs2_inum_out(const struct gfs2_inum *no, char *buf)
+void lgfs2_inum_out(struct lgfs2_inum *i, void *inp)
{
- struct gfs2_inum *str = (struct gfs2_inum *)buf;
+ struct gfs2_inum *in = inp;
- CPOUT_64(no, str, no_formal_ino);
- CPOUT_64(no, str, no_addr);
+ in->no_formal_ino = cpu_to_be64(i->in_formal_ino);
+ in->no_addr = cpu_to_be64(i->in_addr);
}
void lgfs2_inum_print(void *nop)
@@ -375,32 +362,30 @@ void lgfs2_dinode_print(void *dip)
printbe64(di, di_eattr);
}
-void gfs2_dirent_in(struct gfs2_dirent *de, char *buf)
+void lgfs2_dirent_in(struct lgfs2_dirent *d, void *dep)
{
- struct gfs2_dirent *str = (struct gfs2_dirent *)buf;
-
- gfs2_inum_in(&de->de_inum, buf);
- CPIN_32(de, str, de_hash);
- CPIN_16(de, str, de_rec_len);
- CPIN_16(de, str, de_name_len);
- CPIN_16(de, str, de_type);
- CPIN_16(de, str, de_rahead);
- CPIN_32(de, str, de_cookie);
- CPIN_08(de, str, pad3, 8);
+ struct gfs2_dirent *de = dep;
+
+ lgfs2_inum_in(&d->dr_inum, &de->de_inum);
+ d->dr_hash = be32_to_cpu(de->de_hash);
+ d->dr_rec_len = be16_to_cpu(de->de_rec_len);
+ d->dr_name_len = be16_to_cpu(de->de_name_len);
+ d->dr_type = be16_to_cpu(de->de_type);
+ d->dr_rahead = be16_to_cpu(de->de_rahead);
+ d->dr_cookie = be32_to_cpu(de->de_cookie);
}
-void gfs2_dirent_out(struct gfs2_dirent *de, char *buf)
+void lgfs2_dirent_out(struct lgfs2_dirent *d, void *dep)
{
- struct gfs2_dirent *str = (struct gfs2_dirent *)buf;
-
- gfs2_inum_out(&de->de_inum, buf);
- CPOUT_32(de, str, de_hash);
- CPOUT_16(de, str, de_rec_len);
- CPOUT_16(de, str, de_name_len);
- CPOUT_16(de, str, de_type);
- CPOUT_16(de, str, de_rahead);
- CPOUT_32(de, str, de_cookie);
- CPOUT_08(de, str, pad3, 8);
+ struct gfs2_dirent *de = dep;
+
+ lgfs2_inum_out(&d->dr_inum, &de->de_inum);
+ de->de_hash = cpu_to_be32(d->dr_hash);
+ de->de_rec_len = cpu_to_be16(d->dr_rec_len);
+ de->de_name_len = cpu_to_be16(d->dr_name_len);
+ de->de_type = cpu_to_be16(d->dr_type);
+ de->de_rahead = cpu_to_be16(d->dr_rahead);
+ de->de_cookie = cpu_to_be32(d->dr_cookie);
}
void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf)
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 0957e5ad..f0eb8832 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -19,7 +19,7 @@
int build_master(struct gfs2_sbd *sdp)
{
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
uint64_t bn;
struct gfs2_buffer_head *bh = NULL;
int err = lgfs2_dinode_alloc(sdp, 1, &bn);
@@ -27,8 +27,8 @@ int build_master(struct gfs2_sbd *sdp)
if (err != 0)
return -1;
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = bn;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = bn;
err = init_dinode(sdp, &bh, &inum, S_IFDIR | 0755, GFS2_DIF_SYSTEM, &inum);
if (err != 0)
@@ -255,7 +255,7 @@ int build_journal(struct gfs2_sbd *sdp, int j, struct gfs2_inode *jindex)
* nmemb: The number of entries in the list (number of journals).
* Returns 0 on success or non-zero on error with errno set.
*/
-int lgfs2_build_jindex(struct gfs2_inode *master, struct gfs2_inum *jnls, size_t nmemb)
+int lgfs2_build_jindex(struct gfs2_inode *master, struct lgfs2_inum *jnls, size_t nmemb)
{
char fname[GFS2_FNAMESIZE + 1];
struct gfs2_inode *jindex;
@@ -559,7 +559,7 @@ int build_quota(struct gfs2_sbd *sdp)
int build_root(struct gfs2_sbd *sdp)
{
- struct gfs2_inum inum;
+ struct lgfs2_inum inum;
uint64_t bn;
struct gfs2_buffer_head *bh = NULL;
int err = lgfs2_dinode_alloc(sdp, 1, &bn);
@@ -567,8 +567,8 @@ int build_root(struct gfs2_sbd *sdp)
if (err != 0)
return -1;
- inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = bn;
+ inum.in_formal_ino = sdp->md.next_inum++;
+ inum.in_addr = bn;
err = init_dinode(sdp, &bh, &inum, S_IFDIR | 0755, 0, &inum);
if (err != 0)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index bf9e0d6d..551261b9 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -160,7 +160,7 @@ static void opts_init(struct mkfs_opts *opts)
opts->format = GFS2_FORMAT_FS;
}
-struct gfs2_inum *mkfs_journals = NULL;
+struct lgfs2_inum *mkfs_journals = NULL;
#ifndef BLKDISCARD
#define BLKDISCARD _IO(0x12,119)
@@ -901,8 +901,8 @@ static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_o
fprintf(stderr, _("Failed to write data blocks for journal %u\n"), j);
return result;
}
- mkfs_journals[j].no_addr = in.i_addr;
- mkfs_journals[j].no_formal_ino = in.i_formal_ino;
+ mkfs_journals[j].in_addr = in.i_addr;
+ mkfs_journals[j].in_formal_ino = in.i_formal_ino;
}
gfs2_progress_close(&progress, _("Done\n"));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 11/27: gfs2_edit: Use native-endian types for dirent
processing
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit d9e8ae78b66bd7682c4360964e6e354ac3509276
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Jun 4 11:10:31 2021 +0100
gfs2_edit: Use native-endian types for dirent processing
Replace gfs2_edit's 'struct gfs2_dirents' with a new 'struct idirent'
that doesn't use the big-endian 'struct gfs2_dirent'.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/extended.c | 22 ++++++++++----------
gfs2/edit/gfs2hex.c | 59 ++++++++++++++++++++++++++++------------------------
gfs2/edit/hexedit.c | 41 ++++++++++++++++++------------------
gfs2/edit/hexedit.h | 17 +++++++++++----
gfs2/edit/journal.c | 2 +-
gfs2/edit/savemeta.c | 4 ++--
6 files changed, 79 insertions(+), 66 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 4d6b7496..d2ac8507 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -59,7 +59,7 @@ static int _do_indirect_extended(char *diebuf, struct iinfo *iinf, int hgt)
iinf->ii[x].height = 0;
iinf->ii[x].block = 0;
iinf->ii[x].dirents = 0;
- memset(&iinf->ii[x].dirent, 0, sizeof(struct gfs2_dirents));
+ memset(&iinf->ii[x].dirent, 0, sizeof(struct idirent));
}
headoff = sbd.gfs1 ? sizeof(struct gfs_indirect) : sizeof(struct gfs2_meta_header);
for (x = headoff, y = 0; x < sbd.sd_bsize; x += sizeof(uint64_t), y++) {
@@ -331,21 +331,21 @@ static int display_leaf(struct iinfo *ind)
line - start_line - 1 ==
edit_row[dmode] - start_row[dmode]) {
COLORS_HIGHLIGHT;
- sprintf(estring, "%"PRIx64, ind->ii[0].dirent[d].block);
+ sprintf(estring, "%"PRIx64, ind->ii[0].dirent[d].inum.addr);
strcpy(edit_fmt, "%llx");
}
}
print_gfs2("%d/%d [%08"PRIX32"] %"PRIu64"/%"PRIu64" (0x%"PRIx64"/0x%"PRIx64") +%"PRIu16": ",
total_dirents, d + 1,
- ind->ii[0].dirent[d].dirent.de_hash,
- ind->ii[0].dirent[d].dirent.de_inum.no_formal_ino,
- ind->ii[0].dirent[d].block,
- ind->ii[0].dirent[d].dirent.de_inum.no_formal_ino,
- ind->ii[0].dirent[d].block,
- ind->ii[0].dirent[d].dirent.de_rahead
+ ind->ii[0].dirent[d].hash,
+ ind->ii[0].dirent[d].inum.formal_ino,
+ ind->ii[0].dirent[d].inum.addr,
+ ind->ii[0].dirent[d].inum.formal_ino,
+ ind->ii[0].dirent[d].inum.addr,
+ ind->ii[0].dirent[d].rahead
);
}
- print_inode_type(ind->ii[0].dirent[d].dirent.de_type);
+ print_inode_type(ind->ii[0].dirent[d].type);
print_gfs2(" %s", ind->ii[0].dirent[d].filename);
if (termlines) {
if (edit_row[dmode] >= 0 &&
@@ -479,10 +479,10 @@ static int print_gfs2_jindex(void)
for (d = 0; d < indirect->ii[0].dirents; d++) {
if (strncmp(indirect->ii[0].dirent[d].filename, "journal", 7))
continue;
- ip = lgfs2_inode_read(&sbd, indirect->ii[0].dirent[d].block);
+ ip = lgfs2_inode_read(&sbd, indirect->ii[0].dirent[d].inum.addr);
print_gfs2("%s: 0x%-5"PRIx64" %"PRIu64"MB ",
indirect->ii[0].dirent[d].filename,
- indirect->ii[0].dirent[d].block,
+ indirect->ii[0].dirent[d].inum.addr,
ip->i_size / 1048576);
error = lgfs2_find_jhead(ip, &head);
if (error) {
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index f0c409b5..5a1f9b7f 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -209,25 +209,37 @@ void print_it(const char *label, const char *fmt, const char *fmt2, ...)
}
}
-static int indirect_dirent(struct indirect_info *indir, char *ptr, int d)
+void idirent_in(struct idirent *id, void *dep)
{
- struct gfs2_dirent de;
+ struct gfs2_dirent *de = dep;
+
+ id->inum.formal_ino = be64_to_cpu(de->de_inum.no_formal_ino);
+ id->inum.addr = be64_to_cpu(de->de_inum.no_addr);
+ id->hash = be32_to_cpu(de->de_hash);
+ id->rec_len = be16_to_cpu(de->de_rec_len);
+ id->name_len = be16_to_cpu(de->de_name_len);
+ id->type = be16_to_cpu(de->de_type);
+ id->rahead = be16_to_cpu(de->de_rahead);
+ memcpy(id->filename, (char *)de + sizeof(*de), id->name_len);
+ id->filename[id->name_len] = '\0';
+}
+
+static int indirect_dirent(struct indirect_info *indir, void *ptr, int d)
+{
+ struct gfs2_dirent *de = ptr;
+ int ret = 0;
- gfs2_dirent_in(&de, ptr);
- if (de.de_rec_len < sizeof(struct gfs2_dirent) ||
- de.de_rec_len > 4096 - sizeof(struct gfs2_dirent))
+ if (be16_to_cpu(de->de_rec_len) < sizeof(struct gfs2_dirent) ||
+ be16_to_cpu(de->de_rec_len) > 4096 - sizeof(struct gfs2_dirent))
return -1;
- if (de.de_inum.no_addr) {
- indir->block = de.de_inum.no_addr;
- memcpy(&indir->dirent[d].dirent, &de, sizeof(struct gfs2_dirent));
- memcpy(&indir->dirent[d].filename,
- ptr + sizeof(struct gfs2_dirent), de.de_name_len);
- indir->dirent[d].filename[de.de_name_len] = '\0';
- indir->dirent[d].block = de.de_inum.no_addr;
+ if (de->de_inum.no_addr) {
+ idirent_in(&indir->dirent[d], ptr);
+ indir->block = be64_to_cpu(de->de_inum.no_addr);
indir->is_dir = TRUE;
indir->dirents++;
+ ret = indir->dirent[d].rec_len;
}
- return de.de_rec_len;
+ return ret;
}
void do_dinode_extended(char *buf)
@@ -320,29 +332,22 @@ void do_dinode_extended(char *buf)
uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
{
int x, i;
- struct gfs2_dirent de;
+ struct gfs2_dirent *de;
x = 0;
memset(indir, 0, sizeof(*indir));
gfs2_leaf_in(&indir->ii[0].lf, dlebuf);
/* Directory Entries: */
- for (i = sizeof(struct gfs2_leaf); i < sbd.sd_bsize;
- i += de.de_rec_len) {
- gfs2_dirent_in(&de, dlebuf + i);
- if (de.de_inum.no_addr) {
- indir->ii[0].block = de.de_inum.no_addr;
- indir->ii[0].dirent[x].block = de.de_inum.no_addr;
- memcpy(&indir->ii[0].dirent[x].dirent,
- &de, sizeof(struct gfs2_dirent));
- memcpy(&indir->ii[0].dirent[x].filename,
- dlebuf + i + sizeof(struct gfs2_dirent),
- de.de_name_len);
- indir->ii[0].dirent[x].filename[de.de_name_len] = '\0';
+ for (i = sizeof(struct gfs2_leaf); i < sbd.sd_bsize; i += be16_to_cpu(de->de_rec_len)) {
+ de = (struct gfs2_dirent *)(dlebuf + i);
+ if (de->de_inum.no_addr) {
+ idirent_in(&indir->ii[0].dirent[x], de);
+ indir->ii[0].block = be64_to_cpu(de->de_inum.no_addr);
indir->ii[0].is_dir = TRUE;
indir->ii[0].dirents++;
x++;
}
- if (de.de_rec_len <= sizeof(struct gfs2_dirent))
+ if (be16_to_cpu(de->de_rec_len) <= sizeof(struct gfs2_dirent))
break;
}
return indir->ii[0].lf.lf_next;
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 2843262b..fb643ac3 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -462,7 +462,7 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
int d;
for (d = 2; d < 8; d++) {
- if (block == masterdir.dirent[d].block) {
+ if (block == masterdir.dirent[d].inum.addr) {
if (!strncmp(masterdir.dirent[d].filename, "jindex", 6))
print_gfs2("--------------- Journal Index ------------------");
else if (!strncmp(masterdir.dirent[d].filename, "per_node", 8))
@@ -687,7 +687,7 @@ uint64_t masterblock(const char *fn)
for (d = 2; d < 8; d++)
if (!strncmp(masterdir.dirent[d].filename, fn, strlen(fn)))
- return (masterdir.dirent[d].block);
+ return (masterdir.dirent[d].inum.addr);
return 0;
}
@@ -1024,27 +1024,26 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
indirect_blocks = 0;
lines_per_row[dmode] = 1;
if (gfs2_struct_type == GFS2_METATYPE_SB || blk == 0x10 * (4096 / sbd.sd_bsize)) {
+ struct indirect_info *ii = &indirect->ii[0];
+ struct idirent *id;
+
lgfs2_sb_in(&sbd, bh->b_data);
memset(indirect, 0, sizeof(struct iinfo));
- indirect->ii[0].block = sbd.sd_meta_dir.no_addr;
- indirect->ii[0].is_dir = TRUE;
- indirect->ii[0].dirents = 2;
-
- memcpy(&indirect->ii[0].dirent[0].filename, "root", 4);
- indirect->ii[0].dirent[0].dirent.de_inum.no_formal_ino =
- sbd.sd_root_dir.no_formal_ino;
- indirect->ii[0].dirent[0].dirent.de_inum.no_addr =
- sbd.sd_root_dir.no_addr;
- indirect->ii[0].dirent[0].block = sbd.sd_root_dir.no_addr;
- indirect->ii[0].dirent[0].dirent.de_type = DT_DIR;
-
- memcpy(&indirect->ii[0].dirent[1].filename, "master", 7);
- indirect->ii[0].dirent[1].dirent.de_inum.no_formal_ino =
- sbd.sd_meta_dir.no_formal_ino;
- indirect->ii[0].dirent[1].dirent.de_inum.no_addr =
- sbd.sd_meta_dir.no_addr;
- indirect->ii[0].dirent[1].block = sbd.sd_meta_dir.no_addr;
- indirect->ii[0].dirent[1].dirent.de_type = DT_DIR;
+ ii->block = sbd.sd_meta_dir.no_addr;
+ ii->is_dir = TRUE;
+ ii->dirents = 2;
+
+ id = &ii->dirent[0];
+ memcpy(id->filename, "root", 4);
+ id->inum.formal_ino = sbd.sd_root_dir.no_formal_ino;
+ id->inum.addr = sbd.sd_root_dir.no_addr;
+ id->type = DT_DIR;
+
+ id = &ii->dirent[1];
+ memcpy(id->filename, "master", 7);
+ id->inum.formal_ino = sbd.sd_meta_dir.no_formal_ino;
+ id->inum.addr = sbd.sd_meta_dir.no_addr;
+ id->type = DT_DIR;
}
else if (gfs2_struct_type == GFS2_METATYPE_DI) {
di = (struct gfs2_dinode *)bh->b_data;
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index fb060089..f60d836d 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -63,12 +63,21 @@ extern int combined_display;
extern int details;
extern const char *allocdesc[2][5];
-struct gfs2_dirents {
- uint64_t block;
- struct gfs2_dirent dirent;
+struct idirent {
+ struct {
+ uint64_t formal_ino;
+ uint64_t addr;
+ } inum;
+ uint32_t hash;
+ uint16_t rec_len;
+ uint16_t name_len;
+ uint16_t type;
+ uint16_t rahead;
char filename[NAME_MAX];
};
+extern void idirent_in(struct idirent *id, void *de);
+
struct indirect_info {
int is_dir;
int height;
@@ -76,7 +85,7 @@ struct indirect_info {
uint32_t dirents;
struct gfs2_leaf lf;
struct metapath mp;
- struct gfs2_dirents dirent[64];
+ struct idirent dirent[64];
uint64_t ptroff;
};
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index eb8fb4f6..b3333861 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -77,7 +77,7 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
if (journal_num > indirect->ii[0].dirents - 2)
return 0;
- jblock = indirect->ii[0].dirent[journal_num + 2].block;
+ jblock = indirect->ii[0].dirent[journal_num + 2].inum.addr;
j_bh = bread(&sbd, jblock);
jdi = (struct gfs2_dinode *)j_bh->b_data;
*j_size = be64_to_cpu(jdi->di_size);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index b4706248..5d51ea1f 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -278,7 +278,7 @@ static int init_per_node_lookup(void)
for (i = 0; i < indirect_blocks; i++) {
int d;
for (d = 0; d < indirect->ii[i].dirents; d++) {
- int ret = insert_per_node_lookup(indirect->ii[i].dirent[d].block);
+ int ret = insert_per_node_lookup(indirect->ii[i].dirent[d].inum.addr);
if (ret != 0)
return ret;
}
@@ -966,7 +966,7 @@ static void get_journal_inode_blocks(void)
} else {
if (journal + 3 > indirect->ii[0].dirents)
break;
- jblock = indirect->ii[0].dirent[journal + 2].block;
+ jblock = indirect->ii[0].dirent[journal + 2].inum.addr;
}
journal_blocks[journals_found++] = jblock;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 10/27: libgfs2: Remove some now-unused functions
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 9feafd77ea947cca0b2a09fef113e62e24291212
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu May 20 18:07:29 2021 +0100
libgfs2: Remove some now-unused functions
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/gfs1.c | 32 --------------------------------
gfs2/libgfs2/libgfs2.h | 8 +-------
gfs2/libgfs2/ondisk.c | 13 -------------
3 files changed, 1 insertion(+), 52 deletions(-)
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 4cdf26e5..97fa32a5 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -320,22 +320,6 @@ void gfs_jindex_in(struct gfs_jindex *jindex, char *jbuf)
memcpy(jindex->ji_reserved, str->ji_reserved, 64);
}
-void gfs_rgrp_in(struct gfs_rgrp *rgrp, const char *buf)
-{
- struct gfs_rgrp *str = (struct gfs_rgrp *)buf;
-
- gfs2_meta_header_in(&rgrp->rg_header, buf);
- rgrp->rg_flags = be32_to_cpu(str->rg_flags);
- rgrp->rg_free = be32_to_cpu(str->rg_free);
- rgrp->rg_useddi = be32_to_cpu(str->rg_useddi);
- rgrp->rg_freedi = be32_to_cpu(str->rg_freedi);
- gfs2_inum_in(&rgrp->rg_freedi_list, (char *)&str->rg_freedi_list);
- rgrp->rg_usedmeta = be32_to_cpu(str->rg_usedmeta);
- rgrp->rg_freemeta = be32_to_cpu(str->rg_freemeta);
-
- memcpy(rgrp->rg_reserved, str->rg_reserved, 64);
-}
-
void lgfs2_gfs_rgrp_in(const lgfs2_rgrp_t rg, void *buf)
{
struct gfs_rgrp *r = buf;
@@ -350,22 +334,6 @@ void lgfs2_gfs_rgrp_in(const lgfs2_rgrp_t rg, void *buf)
rg->rt_freemeta = be32_to_cpu(r->rg_freemeta);
}
-void gfs_rgrp_out(const struct gfs_rgrp *rgrp, char *buf)
-{
- struct gfs_rgrp *str = (struct gfs_rgrp *)buf;
-
- gfs2_meta_header_out(&rgrp->rg_header, buf);
- str->rg_flags = cpu_to_be32(rgrp->rg_flags);
- str->rg_free = cpu_to_be32(rgrp->rg_free);
- str->rg_useddi = cpu_to_be32(rgrp->rg_useddi);
- str->rg_freedi = cpu_to_be32(rgrp->rg_freedi);
- gfs2_inum_out(&rgrp->rg_freedi_list, (char *)&str->rg_freedi_list);
- str->rg_usedmeta = cpu_to_be32(rgrp->rg_usedmeta);
- str->rg_freemeta = cpu_to_be32(rgrp->rg_freemeta);
-
- memcpy(str->rg_reserved, rgrp->rg_reserved, 64);
-}
-
void lgfs2_gfs_rgrp_out(const lgfs2_rgrp_t rg, void *buf)
{
struct gfs_rgrp *r = buf;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 09d25ae0..361f97e8 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -707,9 +707,7 @@ extern int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
extern struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp, char *buf);
extern struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr);
extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
-extern void gfs_rgrp_in(struct gfs_rgrp *rg, const char *buf);
extern void lgfs2_gfs_rgrp_in(const lgfs2_rgrp_t rg, void *buf);
-extern void gfs_rgrp_out(const struct gfs_rgrp *rg, char *buf);
extern void lgfs2_gfs_rgrp_out(const lgfs2_rgrp_t rg, void *buf);
/* misc.c */
@@ -801,11 +799,7 @@ 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);
-/* Printing functions */
-
-extern void gfs2_inum_print(const struct gfs2_inum *no);
-extern void gfs2_meta_header_print(const struct gfs2_meta_header *mh);
-/* These expect on-disk data instead of native-endian structs */
+/* Printing functions. These expect on-disk data */
extern void lgfs2_inum_print(void *nop);
extern void lgfs2_meta_header_print(void *mhp);
extern void lgfs2_sb_print(void *sbp);
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index f7d7553f..659f4038 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -67,12 +67,6 @@ void gfs2_inum_out(const struct gfs2_inum *no, char *buf)
CPOUT_64(no, str, no_addr);
}
-void gfs2_inum_print(const struct gfs2_inum *no)
-{
- pv(no, no_formal_ino, "%"PRIu64, "0x%"PRIx64);
- pv(no, no_addr, "%"PRIu64, "0x%"PRIx64);
-}
-
void lgfs2_inum_print(void *nop)
{
struct gfs2_inum *no = nop;
@@ -101,13 +95,6 @@ void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf)
str->__pad1 = 0;
}
-void gfs2_meta_header_print(const struct gfs2_meta_header *mh)
-{
- pv(mh, mh_magic, "0x%08"PRIX32, NULL);
- pv(mh, mh_type, "%"PRIu32, "0x%"PRIx32);
- pv(mh, mh_format, "%"PRIu32, "0x%"PRIx32);
-}
-
void lgfs2_meta_header_print(void *mhp)
{
struct gfs2_meta_header *mh = mhp;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 09/27: libgfs2: Remove sd_sb from struct gfs2_sbd
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 0489202afe6c97f8ae8d99eebf5f1635cb5312a8
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Thu May 20 18:01:10 2021 +0100
libgfs2: Remove sd_sb from struct gfs2_sbd
Replace it with native-endian counterparts of the on-disk structures.
Adding fields for the gfs1-specific fields means that some gfs1-specific
variables can be removed. Update the _in() and _out() functions to work
with a gfs2_sbd instead of the big-endian gfs2_sb.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 166 +++++++++++++++++++---------------------
gfs2/edit/extended.c | 14 ++--
gfs2/edit/gfs2hex.c | 11 ++-
gfs2/edit/hexedit.c | 147 +++++++++++++++++-------------------
gfs2/edit/hexedit.h | 1 -
gfs2/edit/journal.c | 38 +++++-----
gfs2/edit/savemeta.c | 104 +++++++++++++------------
gfs2/fsck/afterpass1_common.c | 2 +-
gfs2/fsck/fs_recovery.c | 18 ++---
gfs2/fsck/fsck.h | 1 -
gfs2/fsck/initialize.c | 167 +++++++++++++++++------------------------
gfs2/fsck/metawalk.c | 42 +++++------
gfs2/fsck/metawalk.h | 2 +-
gfs2/fsck/pass1.c | 16 ++--
gfs2/fsck/pass2.c | 8 +-
gfs2/fsck/rgrepair.c | 38 +++++-----
gfs2/fsck/util.c | 4 +-
gfs2/glocktop/glocktop.c | 14 ++--
gfs2/libgfs2/buf.c | 12 +--
gfs2/libgfs2/check_rgrp.c | 4 +-
gfs2/libgfs2/device_geometry.c | 2 +-
gfs2/libgfs2/fs_ops.c | 52 ++++++-------
gfs2/libgfs2/gfs1.c | 14 ++--
gfs2/libgfs2/gfs2l.c | 4 +-
gfs2/libgfs2/lang.c | 12 +--
gfs2/libgfs2/libgfs2.h | 38 +++++++---
gfs2/libgfs2/misc.c | 22 +++---
gfs2/libgfs2/ondisk.c | 91 +++++++++++-----------
gfs2/libgfs2/recovery.c | 12 +--
gfs2/libgfs2/rgrp.c | 38 +++++-----
gfs2/libgfs2/structures.c | 52 +++++--------
gfs2/libgfs2/super.c | 58 +++++++-------
gfs2/mkfs/main_grow.c | 18 ++---
gfs2/mkfs/main_jadd.c | 28 +++----
gfs2/mkfs/main_mkfs.c | 84 +++++++++++----------
tests/nukerg.c | 7 +-
36 files changed, 646 insertions(+), 695 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 280eac42..c8ebfe3b 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -35,8 +35,8 @@
/* The following declares are needed because gfs2 can't have */
/* dependencies on gfs1: */
-#define RGRP_STUFFED_BLKS(sb) (((sb)->sb_bsize - sizeof(struct gfs2_rgrp)) * GFS2_NBBY)
-#define RGRP_BITMAP_BLKS(sb) (((sb)->sb_bsize - sizeof(struct gfs2_meta_header)) * GFS2_NBBY)
+#define RGRP_STUFFED_BLKS(bsize) (((bsize) - sizeof(struct gfs2_rgrp)) * GFS2_NBBY)
+#define RGRP_BITMAP_BLKS(bsize) (((bsize) - sizeof(struct gfs2_meta_header)) * GFS2_NBBY)
/* Define some gfs1 constants from gfs1's gfs_ondisk.h */
#define GFS_METATYPE_NONE (0)
@@ -94,7 +94,7 @@ struct gfs2_options {
unsigned int query:1;
};
-struct gfs_sb raw_gfs1_ondisk_sb;
+struct gfs_sb gfs1_sb;
struct gfs2_sbd sb2;
struct inode_block dirs_to_fix; /* linked list of directories to fix */
struct inode_dir_block cdpns_to_fix; /* linked list of cdpn symlinks */
@@ -143,7 +143,7 @@ static void convert_bitmaps(struct gfs2_sbd *sdp, struct rgrp_tree *rg)
sizeof(struct gfs2_rgrp);
bi = &rg->bits[blk];
- for (; x < sdp->bsize; x++)
+ for (; x < sdp->sd_bsize; x++)
for (y = 0; y < GFS2_NBBY; y++) {
state = (bi->bi_data[x] >> (GFS2_BIT_SIZE * y)) & 0x03;
if (state == 0x02) {/* unallocated metadata state invalid */
@@ -303,7 +303,7 @@ static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
bh = bread(sbp, block);
if (new)
- memset(bh->b_data, 0, sbp->bsize);
+ memset(bh->b_data, 0, sbp->sd_bsize);
gfs2_meta_header_out(&mh, bh->b_data);
bmodified(bh);
}
@@ -311,8 +311,8 @@ static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
hdrsize = blk->height ? sizeof(struct gfs2_meta_header) :
sizeof(struct gfs2_dinode);
- if (amount > sbp->bsize - hdrsize - ptramt)
- amount = sbp->bsize - hdrsize - ptramt;
+ if (amount > sbp->sd_bsize - hdrsize - ptramt)
+ amount = sbp->sd_bsize - hdrsize - ptramt;
memcpy(bh->b_data + hdrsize + ptramt, (char *)srcptr, amount);
srcptr += amount;
@@ -322,7 +322,7 @@ static void fix_metatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
copied += amount;
- if (hdrsize + ptramt + amount >= sbp->bsize) {
+ if (hdrsize + ptramt + amount >= sbp->sd_bsize) {
/* advance to the next metablock */
blk->mp.mp_list[blk->height] +=
(amount / sizeof(uint64_t));
@@ -400,14 +400,14 @@ static void jdata_mp_gfs1_to_gfs2(struct gfs2_sbd *sbp, int gfs1_h, int gfs2_h,
/* figure out multiplication factors for each height - gfs1 */
memset(&gfs1factor, 0, sizeof(gfs1factor));
- gfs1factor[gfs1_h - 1] = sbp->bsize - sizeof(struct gfs2_meta_header);
+ gfs1factor[gfs1_h - 1] = sbp->sd_bsize - sizeof(struct gfs2_meta_header);
for (h = gfs1_h - 1; h > 0; h--)
gfs1factor[h - 1] = gfs1factor[h] * sbp->sd_inptrs;
/* figure out multiplication factors for each height - gfs2 */
memset(&gfs2factor, 0, sizeof(gfs2factor));
gfs2factor[gfs2_h] = 1ull;
- gfs2factor[gfs2_h - 1] = sbp->bsize;
+ gfs2factor[gfs2_h - 1] = sbp->sd_bsize;
for (h = gfs2_h - 1; h > 0; h--)
gfs2factor[h - 1] = gfs2factor[h] * gfs2_inptrs;
@@ -461,15 +461,15 @@ static uint64_t fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
bh = bread(sbp, block);
if (new)
- memset(bh->b_data, 0, sbp->bsize);
+ memset(bh->b_data, 0, sbp->sd_bsize);
if (h < (blk->height - 1)) {
gfs2_meta_header_out(&mh, bh->b_data);
bmodified(bh);
}
}
- if (amount > sbp->bsize - ptramt)
- amount = sbp->bsize - ptramt;
+ if (amount > sbp->sd_bsize - ptramt)
+ amount = sbp->sd_bsize - ptramt;
memcpy(bh->b_data + ptramt, (char *)srcptr, amount);
srcptr += amount;
@@ -479,7 +479,7 @@ static uint64_t fix_jdatatree(struct gfs2_sbd *sbp, struct gfs2_inode *ip,
copied += amount;
- if (ptramt + amount >= sbp->bsize) {
+ if (ptramt + amount >= sbp->sd_bsize) {
/* advance to the next metablock */
blk->mp.mp_list[blk->height] += amount;
for (h = blk->height; h > 0; h--) {
@@ -504,7 +504,7 @@ static int get_inode_metablocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip, str
osi_list_t *tmp;
uint64_t *ptr1, block;
int h, ptrnum;
- int bufsize = sbp->bsize - sizeof(struct gfs_indirect);
+ int bufsize = sbp->sd_bsize - sizeof(struct gfs_indirect);
/* Add dinode block to the list */
blk = malloc(sizeof(struct blocklist));
@@ -524,10 +524,10 @@ static int get_inode_metablocks(struct gfs2_sbd *sbp, struct gfs2_inode *ip, str
memset(blk->ptrbuf, 0, bufsize);
/* Fill in the pointers from the dinode buffer */
memcpy(blk->ptrbuf, dibh->b_data + sizeof(struct gfs_dinode),
- sbp->bsize - sizeof(struct gfs_dinode));
+ sbp->sd_bsize - sizeof(struct gfs_dinode));
/* Zero out the pointers so we can fill them in later. */
memset(dibh->b_data + sizeof(struct gfs_dinode), 0,
- sbp->bsize - sizeof(struct gfs_dinode));
+ sbp->sd_bsize - sizeof(struct gfs_dinode));
osi_list_add_prev(&blk->list, &blocks->list);
/* Now run the metadata chain and build lists of all metadata blocks */
@@ -588,7 +588,7 @@ static int fix_ind_reg_or_dir(struct gfs2_sbd *sbp, struct gfs2_inode *ip, uint3
int ptrnum;
struct metapath gfs2mp;
- bufsize = sbp->bsize - sizeof(struct gfs_indirect);
+ bufsize = sbp->sd_bsize - sizeof(struct gfs_indirect);
len = bufsize;
/* Skip zero pointers at the start of the buffer. This may
@@ -634,7 +634,7 @@ static int fix_ind_jdata(struct gfs2_sbd *sbp, struct gfs2_inode *ip, uint32_t d
struct metapath gfs2mp;
struct gfs2_buffer_head *bh;
- bufsize = sbp->bsize - sizeof(struct gfs2_meta_header);
+ bufsize = sbp->sd_bsize - sizeof(struct gfs2_meta_header);
/*
* For each metadata block that holds jdata block pointers,
* get the blk pointers and copy them block by block
@@ -828,7 +828,7 @@ static int fix_xattr(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, struct g
/* 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);
+ len = sbp->sd_bsize - sizeof(struct gfs_indirect);
buf = malloc(len);
if (!buf) {
/*FIXME: Same message as fix_cdpn_symlink */
@@ -837,8 +837,8 @@ static int fix_xattr(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, struct g
}
old_hdr_sz = sizeof(struct gfs_indirect);
new_hdr_sz = sizeof(struct gfs2_meta_header);
- memcpy(buf, eabh->b_data + old_hdr_sz, sbp->bsize - old_hdr_sz);
- memset(eabh->b_data + new_hdr_sz, 0, sbp->bsize - new_hdr_sz);
+ memcpy(buf, eabh->b_data + old_hdr_sz, sbp->sd_bsize - old_hdr_sz);
+ memset(eabh->b_data + new_hdr_sz, 0, sbp->sd_bsize - new_hdr_sz);
memcpy(eabh->b_data + new_hdr_sz, buf, len);
free(buf);
bmodified(eabh);
@@ -1058,8 +1058,8 @@ static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr, osi_li
break;
/* If this is the root inode block, remember it for later: */
if (block == root_inode_addr) {
- sbp->sd_sb.sb_root_dir.no_addr = block;
- sbp->sd_sb.sb_root_dir.no_formal_ino = sbp->md.next_inum;
+ sbp->sd_root_dir.no_addr = block;
+ sbp->sd_root_dir.no_formal_ino = sbp->md.next_inum;
}
bh = bread(sbp, block);
if (!gfs2_check_meta(bh->b_data, GFS_METATYPE_DI)) {/* if it is an dinode */
@@ -1085,7 +1085,7 @@ static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr, osi_li
buf_offset = (blk) ? sizeof(struct gfs2_meta_header) :
sizeof(struct gfs2_rgrp);
/* if it's on this page */
- if (buf_offset + bitmap_byte < sbp->bsize) {
+ if (buf_offset + bitmap_byte < sbp->sd_bsize) {
bi->bi_data[buf_offset + bitmap_byte] &=
~(0x03 << (GFS2_BIT_SIZE * byte_bit));
bi->bi_data[buf_offset + bitmap_byte] |=
@@ -1093,7 +1093,7 @@ static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr, osi_li
bi->bi_modified = 1;
break;
}
- bitmap_byte -= (sbp->bsize - buf_offset);
+ bitmap_byte -= (sbp->sd_bsize - buf_offset);
}
}
brelse(bh);
@@ -1346,7 +1346,7 @@ static int fix_directory_info(struct gfs2_sbd *sbp, osi_list_t *dir_to_fix)
uint64_t dirblock;
uint32_t gfs1_inptrs = sbp->sd_inptrs;
/* Directory inodes have been converted to gfs2, use gfs2 inptrs */
- sbp->sd_inptrs = (sbp->bsize - sizeof(struct gfs2_meta_header))
+ sbp->sd_inptrs = (sbp->sd_bsize - sizeof(struct gfs2_meta_header))
/ sizeof(uint64_t);
dirs_fixed = 0;
@@ -1500,7 +1500,7 @@ static int read_gfs1_jiindex(struct gfs2_sbd *sdp)
}
journ = sd_jindex + j;
gfs1_jindex_in(journ, buf);
- sdp->jsize = (journ->ji_nsegment * 16 * sdp->bsize) >> 20;
+ sdp->jsize = (journ->ji_nsegment * 16 * sdp->sd_bsize) >> 20;
}
ip->i_mode = tmp_mode;
if(j * sizeof(struct gfs_jindex) != ip->i_size){
@@ -1518,15 +1518,15 @@ static int read_gfs1_jiindex(struct gfs2_sbd *sdp)
static int sanity_check(struct gfs2_sbd *sdp)
{
int error = 0;
- if (!raw_gfs1_ondisk_sb.sb_quota_di.no_addr) {
+ if (!gfs1_sb.sb_quota_di.no_addr) {
log_crit(_("Error: Superblock Quota inode address is NULL\n"));
error = 1;
}
- if (!raw_gfs1_ondisk_sb.sb_license_di.no_addr) {
+ if (!gfs1_sb.sb_license_di.no_addr) {
log_crit(_("Error: Superblock Statfs inode address is NULL\n"));
error = 1;
}
- if (!raw_gfs1_ondisk_sb.sb_seg_size) {
+ if (!gfs1_sb.sb_seg_size) {
log_crit(_("Error: Superblock segment size is zero\n"));
error = 1;
}
@@ -1595,13 +1595,6 @@ static int init(struct gfs2_sbd *sbp, struct gfs2_options *opts)
perror(opts->device);
exit(-1);
}
- /* --------------------------------- */
- /* initialize the incore superblock */
- /* --------------------------------- */
- sbp->sd_sb.sb_header.mh_magic = GFS2_MAGIC;
- sbp->sd_sb.sb_header.mh_type = GFS2_METATYPE_SB;
- sbp->sd_sb.sb_header.mh_format = GFS2_FORMAT_SB;
-
osi_list_init((osi_list_t *)&dirs_to_fix);
osi_list_init((osi_list_t *)&cdpns_to_fix);
/* ---------------------------------------------- */
@@ -1614,8 +1607,7 @@ static int init(struct gfs2_sbd *sbp, struct gfs2_options *opts)
sbp->blks_total = 0; /* total blocks - total them up later */
sbp->blks_alloced = 0; /* blocks allocated - total them up later */
sbp->dinodes_alloced = 0; /* dinodes allocated - total them up later */
- sbp->sd_sb.sb_bsize = GFS2_DEFAULT_BSIZE;
- sbp->bsize = sbp->sd_sb.sb_bsize;
+ sbp->sd_bsize = GFS2_DEFAULT_BSIZE;
sbp->rgtree.osi_node = NULL;
if (compute_constants(sbp)) {
log_crit("%s\n", _("Failed to compute file system constants"));
@@ -1623,28 +1615,27 @@ static int init(struct gfs2_sbd *sbp, struct gfs2_options *opts)
}
bh = bread(sbp, GFS2_SB_ADDR >> sbp->sd_fsb2bb_shift);
- memcpy(&raw_gfs1_ondisk_sb, (struct gfs_sb *)bh->b_data,
- sizeof(struct gfs_sb));
- gfs2_sb_in(&sbp->sd_sb, bh->b_data);
+ memcpy(&gfs1_sb, bh->b_data, sizeof(struct gfs_sb));
+ lgfs2_sb_in(sbp, bh->b_data);
- jindex_addr = be64_to_cpu(raw_gfs1_ondisk_sb.sb_jindex_di.no_addr);
- rindex_addr = be64_to_cpu(raw_gfs1_ondisk_sb.sb_rindex_di.no_addr);
+ jindex_addr = be64_to_cpu(gfs1_sb.sb_jindex_di.no_addr);
+ rindex_addr = be64_to_cpu(gfs1_sb.sb_rindex_di.no_addr);
- sbp->bsize = sbp->sd_sb.sb_bsize;
- sbp->fssize = lseek(sbp->device_fd, 0, SEEK_END) / sbp->sd_sb.sb_bsize;
- sbp->sd_inptrs = (sbp->bsize - sizeof(struct gfs_indirect)) /
+ sbp->sd_bsize = sbp->sd_bsize;
+ sbp->fssize = lseek(sbp->device_fd, 0, SEEK_END) / sbp->sd_bsize;
+ sbp->sd_inptrs = (sbp->sd_bsize - sizeof(struct gfs_indirect)) /
sizeof(uint64_t);
- sbp->sd_diptrs = (sbp->bsize - sizeof(struct gfs_dinode)) /
+ sbp->sd_diptrs = (sbp->sd_bsize - sizeof(struct gfs_dinode)) /
sizeof(uint64_t);
- sbp->sd_jbsize = sbp->bsize - sizeof(struct gfs2_meta_header);
+ sbp->sd_jbsize = sbp->sd_bsize - sizeof(struct gfs2_meta_header);
brelse(bh);
- if (compute_heightsize(sbp->bsize, sbp->sd_heightsize, &sbp->sd_max_height,
- sbp->bsize, sbp->sd_diptrs, sbp->sd_inptrs)) {
+ if (compute_heightsize(sbp->sd_bsize, sbp->sd_heightsize, &sbp->sd_max_height,
+ sbp->sd_bsize, sbp->sd_diptrs, sbp->sd_inptrs)) {
log_crit("%s\n", _("Failed to compute file system constants"));
exit(-1);
}
- if (compute_heightsize(sbp->bsize, sbp->sd_jheightsize, &sbp->sd_max_jheight,
+ if (compute_heightsize(sbp->sd_bsize, sbp->sd_jheightsize, &sbp->sd_max_jheight,
sbp->sd_jbsize, sbp->sd_diptrs, sbp->sd_inptrs)) {
log_crit("%s\n", _("Failed to compute file system constants"));
exit(-1);
@@ -1652,41 +1643,38 @@ static int init(struct gfs2_sbd *sbp, struct gfs2_options *opts)
/* -------------------------------------------------------- */
/* Our constants are for gfs1. Need some for gfs2 as well. */
/* -------------------------------------------------------- */
- gfs2_inptrs = (sbp->bsize - sizeof(struct gfs2_meta_header)) /
+ gfs2_inptrs = (sbp->sd_bsize - sizeof(struct gfs2_meta_header)) /
sizeof(uint64_t); /* How many ptrs can we fit on a block? */
memset(gfs2_heightsize, 0, sizeof(gfs2_heightsize));
- if (compute_heightsize(sbp->bsize, gfs2_heightsize, &gfs2_max_height,
- sbp->bsize, sbp->sd_diptrs, gfs2_inptrs)) {
+ if (compute_heightsize(sbp->sd_bsize, gfs2_heightsize, &gfs2_max_height,
+ sbp->sd_bsize, sbp->sd_diptrs, gfs2_inptrs)) {
log_crit("%s\n", _("Failed to compute file system constants"));
exit(-1);
}
memset(gfs2_jheightsize, 0, sizeof(gfs2_jheightsize));
- if (compute_heightsize(sbp->bsize, gfs2_jheightsize, &gfs2_max_jheight,
+ if (compute_heightsize(sbp->sd_bsize, gfs2_jheightsize, &gfs2_max_jheight,
sbp->sd_jbsize, sbp->sd_diptrs, gfs2_inptrs)) {
log_crit("%s\n", _("Failed to compute file system constants"));
exit(-1);
}
-
- /* ---------------------------------------------- */
- /* Make sure we're really gfs1 */
- /* ---------------------------------------------- */
- if (sbp->sd_sb.sb_fs_format != GFS_FORMAT_FS ||
- sbp->sd_sb.sb_header.mh_type != GFS_METATYPE_SB ||
- sbp->sd_sb.sb_header.mh_format != GFS_FORMAT_SB ||
- sbp->sd_sb.sb_multihost_format != GFS_FORMAT_MULTI) {
+ /* Make sure we're really gfs1 */
+ if (be32_to_cpu(gfs1_sb.sb_fs_format) != GFS_FORMAT_FS ||
+ be32_to_cpu(gfs1_sb.sb_header.mh_type) != GFS_METATYPE_SB ||
+ be32_to_cpu(gfs1_sb.sb_header.mh_format) != GFS_FORMAT_SB ||
+ be32_to_cpu(gfs1_sb.sb_multihost_format) != GFS_FORMAT_MULTI) {
log_crit(_("Error: %s does not look like a gfs1 filesystem.\n"), opts->device);
close(sbp->device_fd);
exit(-1);
}
/* get gfs1 rindex inode - gfs1's rindex inode ptr became __pad2 */
- gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_rindex_di);
+ gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_rindex_di);
sbp->md.riinode = lgfs2_gfs_inode_read(sbp, inum.no_addr);
if (sbp->md.riinode == NULL) {
log_crit(_("Could not read resource group index: %s\n"), strerror(errno));
exit(-1);
}
/* get gfs1 jindex inode - gfs1's journal index inode ptr became master */
- gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_jindex_di);
+ gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_jindex_di);
sbp->md.jiinode = lgfs2_inode_read(sbp, inum.no_addr);
if (sbp->md.jiinode == NULL) {
log_crit(_("Could not read journal index: %s\n"), strerror(errno));
@@ -1813,8 +1801,8 @@ static void process_parameters(int argc, char **argv, struct gfs2_options *opts)
/* ------------------------------------------------------------------------- */
static uint64_t rgrp_length(uint64_t size, struct gfs2_sbd *sdp)
{
- uint64_t bitbytes = RGRP_BITMAP_BLKS(&sdp->sd_sb) + 1;
- uint64_t stuff = RGRP_STUFFED_BLKS(&sdp->sd_sb) + 1;
+ uint64_t bitbytes = RGRP_BITMAP_BLKS(sdp->sd_bsize) + 1;
+ uint64_t stuff = RGRP_STUFFED_BLKS(sdp->sd_bsize) + 1;
uint64_t blocks = 1;
if (size >= stuff) {
@@ -1885,7 +1873,7 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
rgd = rgrp_insert(&sdp->rgtree, ri_addr);
/* convert the gfs1 rgrp into a new gfs2 rgrp */
size = jndx->ji_nsegment *
- be32_to_cpu(raw_gfs1_ondisk_sb.sb_seg_size);
+ be32_to_cpu(gfs1_sb.sb_seg_size);
rgd->rt_flags = 0;
rgd->rt_dinodes = 0;
@@ -1901,18 +1889,18 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
rgd->rt_free = rgd->rt_data;
rgd->rt_bitbytes = rgd->rt_data / GFS2_NBBY;
- if (gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, rgd)) {
+ if (gfs2_compute_bitstructs(sdp->sd_bsize, rgd)) {
log_crit(_("gfs2_convert: Error converting bitmaps.\n"));
exit(-1);
}
- rgd->bits[0].bi_data = calloc(rgd->rt_length, sdp->bsize);
+ rgd->bits[0].bi_data = calloc(rgd->rt_length, sdp->sd_bsize);
if (rgd->bits[0].bi_data == NULL) {
perror("");
exit(-1);
}
for (unsigned i = 1; i < rgd->rt_length; i++)
- rgd->bits[i].bi_data = rgd->bits[0].bi_data + (i * sdp->bsize);
+ rgd->bits[i].bi_data = rgd->bits[0].bi_data + (i * sdp->sd_bsize);
convert_bitmaps(sdp, rgd);
lgfs2_rgrp_out(rgd, rgd->bits[0].bi_data);
@@ -1975,19 +1963,19 @@ static void remove_obsolete_gfs1(struct gfs2_sbd *sbp)
log_notice(_("Removing obsolete GFS1 file system structures.\n"));
fflush(stdout);
/* Delete the old gfs1 Journal index: */
- gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_jindex_di);
+ gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_jindex_di);
gfs2_freedi(sbp, inum.no_addr);
/* Delete the old gfs1 rgindex: */
- gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_rindex_di);
+ gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_rindex_di);
gfs2_freedi(sbp, inum.no_addr);
/* Delete the old gfs1 Quota file: */
- gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_quota_di);
+ gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_quota_di);
gfs2_freedi(sbp, inum.no_addr);
/* Delete the old gfs1 License file: */
- gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_license_di);
+ gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_license_di);
gfs2_freedi(sbp, inum.no_addr);
}
@@ -2017,8 +2005,8 @@ static int conv_build_jindex(struct gfs2_sbd *sdp)
sprintf(name, "journal%u", j);
sdp->md.journal[j] = createi(sdp->md.jiinode, name, S_IFREG |
0600, GFS2_DIF_SYSTEM);
- write_journal(sdp->md.journal[j], sdp->bsize,
- sdp->jsize << 20 >> sdp->sd_sb.sb_bsize_shift);
+ write_journal(sdp->md.journal[j], sdp->sd_bsize,
+ sdp->jsize << 20 >> sdp->sd_bsize_shift);
inode_put(&sdp->md.journal[j]);
printf(_("done.\n"));
fflush(stdout);
@@ -2037,7 +2025,7 @@ static unsigned int total_file_blocks(struct gfs2_sbd *sdp,
uint64_t *arr;
/* Now find the total meta blocks required for data_blks */
- if (filesize <= sdp->bsize - sizeof(struct gfs2_dinode)) {
+ if (filesize <= sdp->sd_bsize - sizeof(struct gfs2_dinode)) {
goto out;
}
@@ -2048,7 +2036,7 @@ static unsigned int total_file_blocks(struct gfs2_sbd *sdp,
} else {
arr = sdp->sd_heightsize;
max = sdp->sd_max_height;
- bsize = sdp->bsize;
+ bsize = sdp->sd_bsize;
}
data_blks = DIV_RU(filesize, bsize); /* total data blocks reqd */
@@ -2138,7 +2126,7 @@ static void copy_quotas(struct gfs2_sbd *sdp)
exit(1);
}
- gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_quota_di);
+ gfs2_inum_in(&inum, (char *)&gfs1_sb.sb_quota_di);
oq_ip = lgfs2_inode_read(sdp, inum.no_addr);
if (oq_ip == NULL) {
fprintf(stderr, _("Couldn't lookup old quota file: %s\n"), strerror(errno));
@@ -2150,7 +2138,7 @@ static void copy_quotas(struct gfs2_sbd *sdp)
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));
+ sdp->sd_bsize - sizeof(struct gfs2_dinode));
oq_ip->i_height = 0;
oq_ip->i_size = 0;
@@ -2246,7 +2234,7 @@ int main(int argc, char **argv)
/* ---------------------------------------------- */
if (!error) {
/* Add a string notifying inode converstion start? */
- error = inode_renumber(&sb2, sb2.sd_sb.sb_root_dir.no_addr,
+ error = inode_renumber(&sb2, sb2.sd_root_dir.no_addr,
(osi_list_t *)&cdpns_to_fix);
if (error)
log_crit(_("\n%s: Error renumbering inodes.\n"), opts.device);
@@ -2308,8 +2296,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.no_addr = sb2.master_dir->i_addr;
- sb2.sd_sb.sb_master_dir.no_formal_ino = sb2.master_dir->i_formal_ino;
+ sb2.sd_meta_dir.no_addr = sb2.master_dir->i_addr;
+ sb2.sd_meta_dir.no_formal_ino = sb2.master_dir->i_formal_ino;
/* Build empty journal index file. */
error = conv_build_jindex(&sb2);
if (error) {
@@ -2384,9 +2372,9 @@ int main(int argc, char **argv)
/* it to not reject the partially converted fs as already done */
/* when it's run a second time. */
bh = bread(&sb2, LGFS2_SB_ADDR(&sb2));
- sb2.sd_sb.sb_fs_format = GFS2_FORMAT_FS;
- sb2.sd_sb.sb_multihost_format = GFS2_FORMAT_MULTI;
- gfs2_sb_out(&sb2.sd_sb, bh->b_data);
+ sb2.sd_fs_format = GFS2_FORMAT_FS;
+ sb2.sd_multihost_format = GFS2_FORMAT_MULTI;
+ lgfs2_sb_out(&sb2, bh->b_data);
bmodified(bh);
brelse(bh);
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index e9e2a7eb..4d6b7496 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -62,7 +62,7 @@ static int _do_indirect_extended(char *diebuf, struct iinfo *iinf, int hgt)
memset(&iinf->ii[x].dirent, 0, sizeof(struct gfs2_dirents));
}
headoff = sbd.gfs1 ? sizeof(struct gfs_indirect) : sizeof(struct gfs2_meta_header);
- for (x = headoff, y = 0; x < sbd.bsize; x += sizeof(uint64_t), y++) {
+ for (x = headoff, y = 0; x < sbd.sd_bsize; x += sizeof(uint64_t), y++) {
p = be64_to_cpu(*(uint64_t *)(diebuf + x));
if (p) {
iinf->ii[i_blocks].block = p;
@@ -196,7 +196,7 @@ static int display_indirect(struct iinfo *ind, int indblocks, int level,
file_offset = metapath_to_lblock(&ind->ii[pndx].mp,
cur_height) *
- sbd.bsize;
+ sbd.sd_bsize;
print_gfs2(" ");
h = 'K';
human_off = (file_offset / 1024.0);
@@ -378,7 +378,7 @@ static void print_block_details(struct iinfo *ind, int level, int cur_height,
"display_indirect\n");
return;
}
- tmpbuf = malloc(sbd.bsize);
+ tmpbuf = malloc(sbd.sd_bsize);
if (!tmpbuf) {
fprintf(stderr, "Out of memory in function "
"display_indirect\n");
@@ -387,7 +387,7 @@ static void print_block_details(struct iinfo *ind, int level, int cur_height,
}
while (thisblk) {
/* read in the desired block */
- if (pread(sbd.device_fd, tmpbuf, sbd.bsize, thisblk * sbd.bsize) != sbd.bsize) {
+ if (pread(sbd.device_fd, tmpbuf, sbd.sd_bsize, thisblk * sbd.sd_bsize) != sbd.sd_bsize) {
fprintf(stderr, "bad read: %s from %s:%d: block %"PRIu64
" (0x%"PRIx64")\n", strerror(errno), __FUNCTION__,
__LINE__, ind->ii[pndx].block, ind->ii[pndx].block);
@@ -543,7 +543,7 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
struct gfs2_rgrp r = {0};
ssize_t ret;
- ret = pread(sbd.device_fd, &r, sizeof(r), rg.rt_addr * sbd.bsize);
+ ret = pread(sbd.device_fd, &r, sizeof(r), rg.rt_addr * sbd.sd_bsize);
if (ret != sizeof(r)) {
perror("Failed to read resource group");
} else if (sbd.gfs1) {
@@ -646,7 +646,7 @@ int display_extended(void)
brelse(tmp_bh);
} else if (block_is_journals(block)) {
if (sbd.gfs1)
- block = sbd1->sb_jindex_di.no_addr;
+ block = sbd.sd_jindex_di.no_addr;
else
block = masterblock("jindex");
print_gfs2_jindex();
@@ -657,7 +657,7 @@ int display_extended(void)
return -1;
else if (block_is_rgtree(block)) {
if (sbd.gfs1)
- tmp_bh = bread(&sbd, sbd1->sb_rindex_di.no_addr);
+ tmp_bh = bread(&sbd, sbd.sd_rindex_di.no_addr);
else
tmp_bh = bread(&sbd, masterblock("rindex"));
tmp_inode = lgfs2_inode_get(&sbd, tmp_bh);
diff --git a/gfs2/edit/gfs2hex.c b/gfs2/edit/gfs2hex.c
index 092b35b6..f0c409b5 100644
--- a/gfs2/edit/gfs2hex.c
+++ b/gfs2/edit/gfs2hex.c
@@ -46,7 +46,6 @@ struct blkstack_info blockstack[BLOCK_STACK_SIZE];
int identify = FALSE;
uint64_t max_block = 0;
int start_row[DMODES], end_row[DMODES], lines_per_row[DMODES];
-struct gfs_sb *sbd1;
int gfs2_struct_type;
unsigned int offset;
struct indirect_info masterdir;
@@ -246,7 +245,7 @@ void do_dinode_extended(char *buf)
memset(indirect, 0, sizeof(struct iinfo));
if (be16_to_cpu(dip->di_height) > 0) {
/* Indirect pointers */
- for (x = sizeof(struct gfs2_dinode); x < sbd.bsize;
+ for (x = sizeof(struct gfs2_dinode); x < sbd.sd_bsize;
x += sizeof(uint64_t)) {
p = be64_to_cpu(*(uint64_t *)(buf + x));
if (p) {
@@ -268,7 +267,7 @@ void do_dinode_extended(char *buf)
indirect->ii[0].dirents = 0;
indirect->ii[0].block = block;
indirect->ii[0].is_dir = TRUE;
- for (x = sizeof(struct gfs2_dinode); x < sbd.bsize; x += skip) {
+ for (x = sizeof(struct gfs2_dinode); x < sbd.sd_bsize; x += skip) {
skip = indirect_dirent(indirect->ii, buf + x,
indirect->ii[0].dirents);
if (skip <= 0)
@@ -298,7 +297,7 @@ void do_dinode_extended(char *buf)
gfs2_leaf_in(&leaf, tmp_bh->b_data);
indirect->ii[indirect_blocks].dirents = 0;
for (direntcount = 0, bufoffset = sizeof(struct gfs2_leaf);
- bufoffset < sbd.bsize;
+ bufoffset < sbd.sd_bsize;
direntcount++, bufoffset += skip) {
skip = indirect_dirent(&indirect->ii[indirect_blocks],
tmp_bh->b_data + bufoffset,
@@ -327,7 +326,7 @@ uint64_t do_leaf_extended(char *dlebuf, struct iinfo *indir)
memset(indir, 0, sizeof(*indir));
gfs2_leaf_in(&indir->ii[0].lf, dlebuf);
/* Directory Entries: */
- for (i = sizeof(struct gfs2_leaf); i < sbd.bsize;
+ for (i = sizeof(struct gfs2_leaf); i < sbd.sd_bsize;
i += de.de_rec_len) {
gfs2_dirent_in(&de, dlebuf + i);
if (de.de_inum.no_addr) {
@@ -359,7 +358,7 @@ static void do_eattr_extended(char *buf)
print_gfs2("Eattr Entries:");
eol(0);
- for (x = sizeof(struct gfs2_meta_header); x < sbd.bsize; x += rec_len)
+ for (x = sizeof(struct gfs2_meta_header); x < sbd.sd_bsize; x += rec_len)
{
eol(0);
buf += x;
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 18afd0ed..2843262b 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -347,7 +347,7 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
struct_len = mtype->size;
ret_type = mtype->mh_type;
} else {
- struct_len = sbd.bsize;
+ struct_len = sbd.sd_bsize;
ret_type = 0;
}
}
@@ -376,8 +376,8 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
pgnum = (offset / screen_chunk_size);
if (type >= 0) {
print_gfs2("(p.%d of %d--%s)", pgnum + 1,
- (sbd.bsize % screen_chunk_size) > 0 ?
- sbd.bsize / screen_chunk_size + 1 : sbd.bsize /
+ (sbd.sd_bsize % screen_chunk_size) > 0 ?
+ sbd.sd_bsize / screen_chunk_size + 1 : sbd.sd_bsize /
screen_chunk_size, allocdesc[sbd.gfs1][type]);
}
/*eol(9);*/
@@ -415,7 +415,7 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
struct_len = (b ?
sizeof(struct gfs2_meta_header) :
sizeof(struct gfs2_rgrp));
- blknum += (sbd.bsize - struct_len);
+ blknum += (sbd.sd_bsize - struct_len);
}
struct_len = sizeof(struct gfs2_meta_header);
/* add the number of bytes on this screen */
@@ -439,9 +439,9 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
if (rgd)
gfs2_rgrp_relse(&sbd, rgd);
}
- if (block == sbd.sd_sb.sb_root_dir.no_addr)
+ if (block == sbd.sd_root_dir.no_addr)
print_gfs2("--------------- Root directory ------------------");
- else if (!sbd.gfs1 && block == sbd.sd_sb.sb_master_dir.no_addr)
+ else if (!sbd.gfs1 && block == sbd.sd_meta_dir.no_addr)
print_gfs2("-------------- Master directory -----------------");
else if (!sbd.gfs1 && block == RGLIST_DUMMY_BLOCK)
print_gfs2("------------------ RG List ----------------------");
@@ -449,11 +449,11 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
print_gfs2("-------------------- Journal List --------------------");
else {
if (sbd.gfs1) {
- if (block == sbd1->sb_rindex_di.no_addr)
+ if (block == sbd.sd_rindex_di.no_addr)
print_gfs2("---------------- rindex file -------------------");
else if (block == gfs1_quota_di.no_addr)
print_gfs2("---------------- Quota file --------------------");
- else if (block == sbd1->sb_jindex_di.no_addr)
+ else if (block == sbd.sd_jindex_di.no_addr)
print_gfs2("--------------- Journal Index ------------------");
else if (block == gfs1_license_di.no_addr)
print_gfs2("--------------- License file -------------------");
@@ -504,7 +504,7 @@ static int hexdump(uint64_t startaddr, uint64_t len, int trunc_zeros,
int i;
uint64_t l;
const char *lpBuffer = bh->b_data;
- const char *zeros_strt = lpBuffer + sbd.bsize;
+ const char *zeros_strt = lpBuffer + sbd.sd_bsize;
int print_field, cursor_line;
const struct lgfs2_metadata *m = get_block_type(bh->b_data);
uint64_t *ref;
@@ -522,7 +522,7 @@ static int hexdump(uint64_t startaddr, uint64_t len, int trunc_zeros,
print_entry_ndx = 0;
while (((termlines && line < termlines &&
line <= ((screen_chunk_size / 16) + 2)) ||
- (!termlines && l < len)) && l < sbd.bsize) {
+ (!termlines && l < len)) && l < sbd.sd_bsize) {
int ptr_not_null = 0;
if (termlines) {
@@ -715,7 +715,7 @@ static uint64_t find_rgrp_block(struct gfs2_inode *dif, int rg)
foffset = rg * sizeof(struct gfs2_rindex);
if (sbd.gfs1) {
uint64_t sd_jbsize =
- (sbd.bsize - sizeof(struct gfs2_meta_header));
+ (sbd.sd_bsize - sizeof(struct gfs2_meta_header));
gfs1_adj = (foffset / sd_jbsize) *
sizeof(struct gfs2_meta_header);
@@ -753,7 +753,7 @@ static uint64_t get_rg_addr(int rgnum)
struct gfs2_inode *riinode;
if (sbd.gfs1)
- gblock = sbd1->sb_rindex_di.no_addr;
+ gblock = sbd.sd_rindex_di.no_addr;
else
gblock = masterblock("rindex");
riinode = lgfs2_inode_read(&sbd, gblock);
@@ -827,7 +827,7 @@ int has_indirect_blocks(void)
int block_is_rindex(uint64_t blk)
{
- if ((sbd.gfs1 && blk == sbd1->sb_rindex_di.no_addr) ||
+ if ((sbd.gfs1 && blk == sbd.sd_rindex_di.no_addr) ||
(blk == masterblock("rindex")))
return TRUE;
return FALSE;
@@ -835,7 +835,7 @@ int block_is_rindex(uint64_t blk)
int block_is_jindex(uint64_t blk)
{
- if ((sbd.gfs1 && blk == sbd1->sb_jindex_di.no_addr))
+ if ((sbd.gfs1 && blk == sbd.sd_jindex_di.no_addr))
return TRUE;
return FALSE;
}
@@ -891,10 +891,11 @@ static int block_has_extended_info(void)
static void read_superblock(int fd)
{
- sbd1 = (struct gfs_sb *)&sbd.sd_sb;
+ struct gfs2_meta_header *mh;
+
ioctl(fd, BLKFLSBUF, 0);
memset(&sbd, 0, sizeof(struct gfs2_sbd));
- sbd.bsize = GFS2_DEFAULT_BSIZE;
+ sbd.sd_bsize = GFS2_DEFAULT_BSIZE;
sbd.device_fd = fd;
bh = bread(&sbd, 0x10);
sbd.jsize = GFS2_DEFAULT_JSIZE;
@@ -902,26 +903,19 @@ static void read_superblock(int fd)
sbd.qcsize = GFS2_DEFAULT_QCSIZE;
sbd.time = time(NULL);
sbd.rgtree.osi_node = NULL;
- gfs2_sb_in(&sbd.sd_sb, bh->b_data);
+ lgfs2_sb_in(&sbd, bh->b_data);
/* Check to see if this is really gfs1 */
- if (sbd1->sb_fs_format == GFS_FORMAT_FS &&
- sbd1->sb_header.mh_type == GFS_METATYPE_SB &&
- sbd1->sb_header.mh_format == GFS_FORMAT_SB &&
- sbd1->sb_multihost_format == GFS_FORMAT_MULTI) {
- struct gfs_sb *sbbuf = (struct gfs_sb *)bh->b_data;
-
+ mh = (struct gfs2_meta_header *)bh->b_data;
+ if (sbd.sd_fs_format == GFS_FORMAT_FS &&
+ be32_to_cpu(mh->mh_type) == GFS_METATYPE_SB &&
+ be32_to_cpu(mh->mh_format) == GFS_FORMAT_SB &&
+ sbd.sd_multihost_format == GFS_FORMAT_MULTI) {
sbd.gfs1 = TRUE;
- sbd1->sb_flags = be32_to_cpu(sbbuf->sb_flags);
- sbd1->sb_seg_size = be32_to_cpu(sbbuf->sb_seg_size);
- gfs2_inum_in(&sbd1->sb_rindex_di, (void *)&sbbuf->sb_rindex_di);
- gfs2_inum_in(&gfs1_quota_di, (void *)&sbbuf->sb_quota_di);
- gfs2_inum_in(&gfs1_license_di, (void *)&sbbuf->sb_license_di);
}
else
sbd.gfs1 = FALSE;
- sbd.bsize = sbd.sd_sb.sb_bsize;
- if (!sbd.bsize)
- sbd.bsize = GFS2_DEFAULT_BSIZE;
+ if (!sbd.sd_bsize)
+ sbd.sd_bsize = GFS2_DEFAULT_BSIZE;
if (lgfs2_get_dev_info(fd, &sbd.dinfo)) {
perror(device);
exit(-1);
@@ -930,26 +924,25 @@ static void read_superblock(int fd)
fprintf(stderr, "Failed to compute constants.\n");
exit(-1);
}
- if (sbd.gfs1 || (sbd.sd_sb.sb_header.mh_magic == GFS2_MAGIC &&
- sbd.sd_sb.sb_header.mh_type == GFS2_METATYPE_SB))
- block = 0x10 * (GFS2_DEFAULT_BSIZE / sbd.bsize);
+ if (sbd.gfs1 || (be32_to_cpu(mh->mh_magic) == GFS2_MAGIC &&
+ be32_to_cpu(mh->mh_type) == GFS2_METATYPE_SB))
+ block = 0x10 * (GFS2_DEFAULT_BSIZE / sbd.sd_bsize);
else {
block = starting_blk = 0;
}
fix_device_geometry(&sbd);
if(sbd.gfs1) {
- sbd.sd_inptrs = (sbd.bsize - sizeof(struct gfs_indirect)) /
+ sbd.sd_inptrs = (sbd.sd_bsize - sizeof(struct gfs_indirect)) /
sizeof(uint64_t);
- sbd.sd_diptrs = (sbd.bsize - sizeof(struct gfs_dinode)) /
+ sbd.sd_diptrs = (sbd.sd_bsize - sizeof(struct gfs_dinode)) /
sizeof(uint64_t);
- sbd.md.riinode = lgfs2_inode_read(&sbd, sbd1->sb_rindex_di.no_addr);
+ sbd.md.riinode = lgfs2_inode_read(&sbd, sbd.sd_rindex_di.no_addr);
} else {
- sbd.sd_inptrs = (sbd.bsize - sizeof(struct gfs2_meta_header)) /
+ sbd.sd_inptrs = (sbd.sd_bsize - sizeof(struct gfs2_meta_header)) /
sizeof(uint64_t);
- sbd.sd_diptrs = (sbd.bsize - sizeof(struct gfs2_dinode)) /
+ sbd.sd_diptrs = (sbd.sd_bsize - sizeof(struct gfs2_dinode)) /
sizeof(uint64_t);
- sbd.master_dir = lgfs2_inode_read(&sbd,
- sbd.sd_sb.sb_master_dir.no_addr);
+ sbd.master_dir = lgfs2_inode_read(&sbd, sbd.sd_meta_dir.no_addr);
if (sbd.master_dir == NULL) {
sbd.md.riinode = NULL;
} else {
@@ -980,7 +973,7 @@ static int read_master_dir(void)
{
ioctl(sbd.device_fd, BLKFLSBUF, 0);
- bh = bread(&sbd, sbd.sd_sb.sb_master_dir.no_addr);
+ bh = bread(&sbd, sbd.sd_meta_dir.no_addr);
if (bh == NULL)
return 1;
di = (struct gfs2_dinode *)bh->b_data;
@@ -996,12 +989,12 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
if (block == RGLIST_DUMMY_BLOCK) {
if (sbd.gfs1)
- blk = sbd1->sb_rindex_di.no_addr;
+ blk = sbd.sd_rindex_di.no_addr;
else
blk = masterblock("rindex");
} else if (block == JOURNALS_DUMMY_BLOCK) {
if (sbd.gfs1)
- blk = sbd1->sb_jindex_di.no_addr;
+ blk = sbd.sd_jindex_di.no_addr;
else
blk = masterblock("jindex");
} else
@@ -1013,7 +1006,7 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
if (bh == NULL || bh->b_blocknr != blk) { /* If we changed blocks from the last read */
if (bh != NULL)
brelse(bh);
- dev_offset = blk * sbd.bsize;
+ dev_offset = blk * sbd.sd_bsize;
ioctl(sbd.device_fd, BLKFLSBUF, 0);
if (!(bh = bread(&sbd, blk))) {
fprintf(stderr, "read error: %s from %s:%d: "
@@ -1030,27 +1023,27 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
return 0;
indirect_blocks = 0;
lines_per_row[dmode] = 1;
- if (gfs2_struct_type == GFS2_METATYPE_SB || blk == 0x10 * (4096 / sbd.bsize)) {
- gfs2_sb_in(&sbd.sd_sb, bh->b_data);
+ if (gfs2_struct_type == GFS2_METATYPE_SB || blk == 0x10 * (4096 / sbd.sd_bsize)) {
+ lgfs2_sb_in(&sbd, bh->b_data);
memset(indirect, 0, sizeof(struct iinfo));
- indirect->ii[0].block = sbd.sd_sb.sb_master_dir.no_addr;
+ indirect->ii[0].block = sbd.sd_meta_dir.no_addr;
indirect->ii[0].is_dir = TRUE;
indirect->ii[0].dirents = 2;
memcpy(&indirect->ii[0].dirent[0].filename, "root", 4);
indirect->ii[0].dirent[0].dirent.de_inum.no_formal_ino =
- sbd.sd_sb.sb_root_dir.no_formal_ino;
+ sbd.sd_root_dir.no_formal_ino;
indirect->ii[0].dirent[0].dirent.de_inum.no_addr =
- sbd.sd_sb.sb_root_dir.no_addr;
- indirect->ii[0].dirent[0].block = sbd.sd_sb.sb_root_dir.no_addr;
+ sbd.sd_root_dir.no_addr;
+ indirect->ii[0].dirent[0].block = sbd.sd_root_dir.no_addr;
indirect->ii[0].dirent[0].dirent.de_type = DT_DIR;
memcpy(&indirect->ii[0].dirent[1].filename, "master", 7);
indirect->ii[0].dirent[1].dirent.de_inum.no_formal_ino =
- sbd.sd_sb.sb_master_dir.no_formal_ino;
+ sbd.sd_meta_dir.no_formal_ino;
indirect->ii[0].dirent[1].dirent.de_inum.no_addr =
- sbd.sd_sb.sb_master_dir.no_addr;
- indirect->ii[0].dirent[1].block = sbd.sd_sb.sb_master_dir.no_addr;
+ sbd.sd_meta_dir.no_addr;
+ indirect->ii[0].dirent[1].block = sbd.sd_meta_dir.no_addr;
indirect->ii[0].dirent[1].dirent.de_type = DT_DIR;
}
else if (gfs2_struct_type == GFS2_METATYPE_DI) {
@@ -1085,7 +1078,7 @@ int display(int identify_only, int trunc_zeros, uint64_t flagref,
move(line, 0);
}
if (dmode == HEX_MODE) { /* if hex display mode */
- uint64_t len = sbd.bsize;
+ uint64_t len = sbd.sd_bsize;
if (gfs2_struct_type == GFS2_METATYPE_DI)
len = struct_len + be64_to_cpu(di->di_size);
@@ -1164,7 +1157,7 @@ static uint64_t find_metablockoftype_slow(uint64_t startblk, int metatype, int p
int found = 0;
struct gfs2_buffer_head *lbh;
- last_fs_block = lseek(sbd.device_fd, 0, SEEK_END) / sbd.bsize;
+ last_fs_block = lseek(sbd.device_fd, 0, SEEK_END) / sbd.sd_bsize;
for (blk = startblk + 1; blk < last_fs_block; blk++) {
lbh = bread(&sbd, blk);
/* Can't use get_block_type here (returns false "none") */
@@ -1197,7 +1190,7 @@ static int find_rg_metatype(struct rgrp_tree *rgd, uint64_t *blk, uint64_t start
int found;
unsigned i, j, m;
struct gfs2_buffer_head *bhp = NULL;
- uint64_t *ibuf = malloc(sbd.bsize * GFS2_NBBY * sizeof(uint64_t));
+ uint64_t *ibuf = malloc(sbd.sd_bsize * GFS2_NBBY * sizeof(uint64_t));
for (i = 0; i < rgd->rt_length; i++) {
m = lgfs2_bm_scan(rgd, i, ibuf, GFS2_BLKST_DINODE);
@@ -1322,21 +1315,21 @@ uint64_t check_keywords(const char *kword)
unsigned long long blk = 0;
if (!strcmp(kword, "sb") ||!strcmp(kword, "superblock"))
- blk = 0x10 * (4096 / sbd.bsize); /* superblock */
+ blk = 0x10 * (4096 / sbd.sd_bsize); /* superblock */
else if (!strcmp(kword, "root") || !strcmp(kword, "rootdir"))
- blk = sbd.sd_sb.sb_root_dir.no_addr;
+ blk = sbd.sd_root_dir.no_addr;
else if (!strcmp(kword, "master")) {
if (sbd.gfs1)
fprintf(stderr, "This is GFS1; there's no master directory.\n");
- else if (!sbd.sd_sb.sb_master_dir.no_addr) {
+ else if (!sbd.sd_meta_dir.no_addr) {
fprintf(stderr, "GFS2 master directory not found on %s\n", device);
exit(-1);
} else
- blk = sbd.sd_sb.sb_master_dir.no_addr;
+ blk = sbd.sd_meta_dir.no_addr;
}
else if (!strcmp(kword, "jindex")) {
if (sbd.gfs1)
- blk = sbd1->sb_jindex_di.no_addr;
+ blk = sbd.sd_jindex_di.no_addr;
else
blk = masterblock("jindex"); /* journal index */
}
@@ -1352,7 +1345,7 @@ uint64_t check_keywords(const char *kword)
}
else if (!strcmp(kword, "rindex") || !strcmp(kword, "rgindex")) {
if (sbd.gfs1)
- blk = sbd1->sb_rindex_di.no_addr;
+ blk = sbd.sd_rindex_di.no_addr;
else
blk = masterblock("rindex");
} else if (!strcmp(kword, "rgs")) {
@@ -1448,7 +1441,7 @@ static void hex_edit(int *exitch)
int left_off;
int ch;
- left_off = ((block * sbd.bsize) < 0xffffffff) ? 9 : 17;
+ left_off = ((block * sbd.sd_bsize) < 0xffffffff) ? 9 : 17;
/* 8 and 16 char addresses on screen */
if (bobgets(estring, edit_row[HEX_MODE] + 3,
@@ -1480,8 +1473,8 @@ static void hex_edit(int *exitch)
ch += (estring[i+1] - 'A' + 0x0a);
bh->b_data[offset + hexoffset] = ch;
}
- if (pwrite(sbd.device_fd, bh->b_data, sbd.bsize, dev_offset) !=
- sbd.bsize) {
+ if (pwrite(sbd.device_fd, bh->b_data, sbd.sd_bsize, dev_offset) !=
+ sbd.sd_bsize) {
fprintf(stderr, "write error: %s from %s:%d: "
"offset %lld (0x%llx)\n",
strerror(errno),
@@ -1515,10 +1508,10 @@ static void pageup(void)
if (dmode == GFS2_MODE || offset==0) {
block--;
if (dmode == HEX_MODE)
- offset = (sbd.bsize % screen_chunk_size) > 0 ?
+ offset = (sbd.sd_bsize % screen_chunk_size) > 0 ?
screen_chunk_size *
- (sbd.bsize / screen_chunk_size) :
- sbd.bsize - screen_chunk_size;
+ (sbd.sd_bsize / screen_chunk_size) :
+ sbd.sd_bsize - screen_chunk_size;
else
offset = 0;
} else
@@ -1546,7 +1539,7 @@ static void pagedn(void)
else {
start_row[dmode] = edit_row[dmode] = 0;
if (dmode == GFS2_MODE ||
- offset + screen_chunk_size >= sbd.bsize) {
+ offset + screen_chunk_size >= sbd.sd_bsize) {
block++;
offset = 0;
} else
@@ -1844,7 +1837,7 @@ static void interactive_mode(void)
edit_row[dmode] = 0;
}
else {
- block = 0x10 * (4096 / sbd.bsize);
+ block = 0x10 * (4096 / sbd.sd_bsize);
push_block(block);
offset = 0;
}
@@ -2210,7 +2203,7 @@ static int count_dinode_bits(struct gfs2_buffer_head *rbh)
else
blk = sizeof(struct gfs2_meta_header);
- for (; blk < sbd.bsize; blk++) {
+ for (; blk < sbd.sd_bsize; blk++) {
byte = rbh->b_data + (blk / GFS2_NBBY);
bit = (blk % GFS2_NBBY) * GFS2_BIT_SIZE;
if (((*byte >> bit) & GFS2_BIT_MASK) == GFS2_BLKST_DINODE)
@@ -2255,7 +2248,7 @@ static void rg_repair(void)
if (gfs2_check_meta(rbh->b_data, mtype)) { /* wrong type */
printf("Damaged. Repairing...");
/* Fix the meta header */
- memset(rbh->b_data, 0, sbd.bsize);
+ memset(rbh->b_data, 0, sbd.sd_bsize);
mh = (struct gfs2_meta_header *)rbh->b_data;
mh->mh_magic = cpu_to_be32(GFS2_MAGIC);
mh->mh_type = cpu_to_be32(mtype);
@@ -2558,7 +2551,7 @@ int main(int argc, char *argv[])
memset(edit_size, 0, sizeof(edit_size));
memset(last_entry_onscreen, 0, sizeof(last_entry_onscreen));
dmode = INIT_MODE;
- sbd.bsize = 4096;
+ sbd.sd_bsize = 4096;
block = starting_blk = 0x10;
for (i = 0; i < BLOCK_STACK_SIZE; i++) {
blockstack[i].dmode = HEX_MODE;
@@ -2582,12 +2575,12 @@ int main(int argc, char *argv[])
fd = open(device, O_RDWR);
if (fd < 0)
die("can't open %s: %s\n", device, strerror(errno));
- max_block = lseek(fd, 0, SEEK_END) / sbd.bsize;
+ max_block = lseek(fd, 0, SEEK_END) / sbd.sd_bsize;
read_superblock(fd);
if (read_rindex())
exit(-1);
- max_block = lseek(fd, 0, SEEK_END) / sbd.bsize;
+ max_block = lseek(fd, 0, SEEK_END) / sbd.sd_bsize;
if (sbd.gfs1)
edit_row[GFS2_MODE]++;
else if (read_master_dir() != 0)
@@ -2595,7 +2588,7 @@ int main(int argc, char *argv[])
process_parameters(argc, argv, 1); /* get what to print from cmdline */
- block = blockstack[0].block = starting_blk * (4096 / sbd.bsize);
+ block = blockstack[0].block = starting_blk * (4096 / sbd.sd_bsize);
if (termlines)
interactive_mode();
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index b0ca1fba..fb060089 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -46,7 +46,6 @@ extern int start_row[DMODES], end_row[DMODES], lines_per_row[DMODES];
extern int edit_size[DMODES], last_entry_onscreen[DMODES];
extern char edit_fmt[80];
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;
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index 0da00235..eb8fb4f6 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -38,7 +38,7 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
uint64_t jindex_block, jblock = 0;
int amtread;
struct gfs2_buffer_head *jindex_bh, *j_bh;
- char jbuf[sbd.bsize];
+ char jbuf[sbd.sd_bsize];
journal_num = atoi(journal + 7);
if (journal_num < 0)
@@ -46,7 +46,7 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
/* Figure out the block of the jindex file */
if (sbd.gfs1)
- jindex_block = sbd1->sb_jindex_di.no_addr;
+ jindex_block = sbd.sd_jindex_di.no_addr;
else
jindex_block = masterblock("jindex");
/* read in the block */
@@ -134,8 +134,8 @@ static int fsck_readi(struct gfs2_inode *ip, void *rbuf, uint64_t roffset,
o = roffset % sdp->sd_jbsize;
lblock = roffset / sdp->sd_jbsize;
} else {
- lblock = roffset >> sdp->sd_sb.sb_bsize_shift;
- o = roffset & (sdp->bsize - 1);
+ lblock = roffset >> sdp->sd_bsize_shift;
+ o = roffset & (sdp->sd_bsize - 1);
}
if (!ip->i_height) /* inode_is_stuffed */
@@ -145,8 +145,8 @@ static int fsck_readi(struct gfs2_inode *ip, void *rbuf, uint64_t roffset,
while (copied < size) {
amount = size - copied;
- if (amount > sdp->bsize - o)
- amount = sdp->bsize - o;
+ if (amount > sdp->sd_bsize - o)
+ amount = sdp->sd_bsize - o;
if (!extlen)
block_map(ip, lblock, ¬_new, &dblock, &extlen,
FALSE);
@@ -331,7 +331,7 @@ static uint64_t find_wrap_pt(struct gfs2_inode *ji, char *jbuf, uint64_t jblock,
uint64_t jb = 0;
uint64_t highest_seq = 0;
- for (jb = 0; jb < j_size; jb += (sbd.gfs1 ? 1 : sbd.bsize)) {
+ for (jb = 0; jb < j_size; jb += (sbd.gfs1 ? 1 : sbd.sd_bsize)) {
int found = 0;
if (sbd.gfs1) {
@@ -344,7 +344,7 @@ static uint64_t find_wrap_pt(struct gfs2_inode *ji, char *jbuf, uint64_t jblock,
int copied;
uint64_t abs_block;
- copied = fsck_readi(ji, jbuf, jb, sbd.bsize, &abs_block);
+ copied = fsck_readi(ji, jbuf, jb, sbd.sd_bsize, &abs_block);
if (!copied) /* end of file */
break;
found = is_wrap_pt(jbuf, &highest_seq);
@@ -385,11 +385,11 @@ static int process_ld(uint64_t abs_block, uint64_t wrappt, uint64_t j_size,
b = (uint64_t *)(buf + sizeof(struct gfs_log_descriptor));
else
b = (uint64_t *)(buf + sizeof(struct gfs2_log_descriptor));
- *prnt = ld_is_pertinent(b, (buf + sbd.bsize), tblk, rgd, bitblk);
+ *prnt = ld_is_pertinent(b, (buf + sbd.sd_bsize), tblk, rgd, bitblk);
if (*prnt) {
print_gfs2("0x%"PRIx64" (j+%4"PRIx64"): Log descriptor, ",
- abs_block, ((jb + wrappt) % j_size) / sbd.bsize);
+ abs_block, ((jb + wrappt) % j_size) / sbd.sd_bsize);
print_gfs2("type %"PRIu32" ", ld_type);
for (ltndx = 0;; ltndx++) {
@@ -406,7 +406,7 @@ static int process_ld(uint64_t abs_block, uint64_t wrappt, uint64_t j_size,
if (ld_type == GFS2_LOG_DESC_METADATA ||
ld_type == GFS_LOG_DESC_METADATA)
is_meta_ld = 1;
- ld_blocks -= print_ld_blks(b, (buf + sbd.bsize), line, tblk, tblk_off,
+ ld_blocks -= print_ld_blks(b, (buf + sbd.sd_bsize), line, tblk, tblk_off,
bitblk, rgd, abs_block, *prnt, bblk_off,
is_meta_ld);
@@ -435,7 +435,7 @@ static int meta_has_ref(uint64_t abs_block, int tblk)
}
}
b = (uint64_t *)(mbh->b_data + structlen);
- while (!has_ref && mtype && (char *)b < mbh->b_data + sbd.bsize) {
+ while (!has_ref && mtype && (char *)b < mbh->b_data + sbd.sd_bsize) {
if (be64_to_cpu(*b) == tblk)
has_ref = 1;
b++;
@@ -492,7 +492,7 @@ static void display_log_header(void *buf, uint64_t *highest_seq, uint64_t abs_bl
} 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),
+ abs_block, (jb % j_size) / sbd.sd_bsize, be64_to_cpu(lh->lh_sequence),
be32_to_cpu(lh->lh_tail), be32_to_cpu(lh->lh_blkno), flags_str);
}
}
@@ -544,7 +544,7 @@ void dump_journal(const char *journal, int tblk)
fprintf(stderr, "Out of memory\n");
exit(-1);
}
- jbuf = malloc(sbd.bsize);
+ jbuf = malloc(sbd.sd_bsize);
if (jbuf == NULL) {
fprintf(stderr, "Out of memory\n");
exit(-1);
@@ -578,7 +578,7 @@ void dump_journal(const char *journal, int tblk)
}
wrappt = find_wrap_pt(j_inode, jbuf, jblock, j_size);
- wp = wrappt / (sbd.gfs1 ? 1 : sbd.bsize);
+ wp = wrappt / (sbd.gfs1 ? 1 : sbd.sd_bsize);
print_gfs2("Starting at journal wrap block: 0x%llx "
"(j + 0x%llx)",
(unsigned long long)jblock + wp,
@@ -586,7 +586,7 @@ void dump_journal(const char *journal, int tblk)
eol(0);
}
- for (jb = 0; jb < j_size; jb += (sbd.gfs1 ? 1 : sbd.bsize)) {
+ for (jb = 0; jb < j_size; jb += (sbd.gfs1 ? 1 : sbd.sd_bsize)) {
int is_pertinent = 1;
uint32_t block_type = 0;
@@ -599,7 +599,7 @@ void dump_journal(const char *journal, int tblk)
} else {
int error = fsck_readi(j_inode, (void *)jbuf,
((jb + wrappt) % j_size),
- sbd.bsize, &abs_block);
+ sbd.sd_bsize, &abs_block);
if (!error) /* end of file */
break;
buf = jbuf;
@@ -625,10 +625,10 @@ void dump_journal(const char *journal, int tblk)
print_gfs2("0x%"PRIx64" (j+%4"PRIx64"): Log descriptor"
" continuation block", abs_block,
- ((jb + wrappt) % j_size) / sbd.bsize);
+ ((jb + wrappt) % j_size) / sbd.sd_bsize);
eol(0);
print_gfs2(" ");
- ld_blocks -= print_ld_blks(b, (buf + sbd.bsize), start_line,
+ ld_blocks -= print_ld_blks(b, (buf + sbd.sd_bsize), start_line,
tblk, &tblk_off, 0, rgd, 0, 1, NULL, 0);
} else if (block_type == 0) {
continue;
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index e55b66f6..b4706248 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -311,7 +311,7 @@ static size_t di_save_len(const char *buf, uint64_t owner)
indirect pointers, dirents, symlinks or fs internal data */
if (di_height > 0 || S_ISDIR(di_mode) || S_ISLNK(di_mode) || gfs1dir
|| block_is_systemfile(owner))
- return sbd.bsize;
+ return sbd.sd_bsize;
return sizeof(struct gfs2_dinode);
}
@@ -335,7 +335,7 @@ static int get_gfs_struct_info(const char *buf, uint64_t owner, unsigned *block_
*block_type = 0;
if (gstruct_len != NULL)
- *gstruct_len = sbd.bsize;
+ *gstruct_len = sbd.sd_bsize;
gfs2_meta_header_in(&mh, buf);
if (mh.mh_magic != GFS2_MAGIC)
@@ -355,22 +355,22 @@ static int get_gfs_struct_info(const char *buf, uint64_t owner, unsigned *block_
*gstruct_len = sizeof(struct gfs2_sb);
break;
case GFS2_METATYPE_RG: /* 2 (rsrc grp hdr) */
- *gstruct_len = sbd.bsize; /*sizeof(struct gfs_rgrp);*/
+ *gstruct_len = sbd.sd_bsize; /*sizeof(struct gfs_rgrp);*/
break;
case GFS2_METATYPE_RB: /* 3 (rsrc grp bitblk) */
- *gstruct_len = sbd.bsize;
+ *gstruct_len = sbd.sd_bsize;
break;
case GFS2_METATYPE_DI: /* 4 (disk inode) */
*gstruct_len = di_save_len(buf, owner);
break;
case GFS2_METATYPE_IN: /* 5 (indir inode blklst) */
- *gstruct_len = sbd.bsize; /*sizeof(struct gfs_indirect);*/
+ *gstruct_len = sbd.sd_bsize; /*sizeof(struct gfs_indirect);*/
break;
case GFS2_METATYPE_LF: /* 6 (leaf dinode blklst) */
- *gstruct_len = sbd.bsize; /*sizeof(struct gfs_leaf);*/
+ *gstruct_len = sbd.sd_bsize; /*sizeof(struct gfs_leaf);*/
break;
case GFS2_METATYPE_JD: /* 7 (journal data) */
- *gstruct_len = sbd.bsize;
+ *gstruct_len = sbd.sd_bsize;
break;
case GFS2_METATYPE_LH: /* 8 (log header) */
if (sbd.gfs1)
@@ -382,16 +382,16 @@ static int get_gfs_struct_info(const char *buf, uint64_t owner, unsigned *block_
*gstruct_len = sizeof(struct gfs2_log_header);
break;
case GFS2_METATYPE_LD: /* 9 (log descriptor) */
- *gstruct_len = sbd.bsize;
+ *gstruct_len = sbd.sd_bsize;
break;
case GFS2_METATYPE_EA: /* 10 (extended attr hdr) */
- *gstruct_len = sbd.bsize;
+ *gstruct_len = sbd.sd_bsize;
break;
case GFS2_METATYPE_ED: /* 11 (extended attr data) */
- *gstruct_len = sbd.bsize;
+ *gstruct_len = sbd.sd_bsize;
break;
default:
- *gstruct_len = sbd.bsize;
+ *gstruct_len = sbd.sd_bsize;
break;
}
return 0;
@@ -571,12 +571,12 @@ struct block_range {
static int block_range_prepare(struct block_range *br)
{
- br->buf = calloc(br->len, sbd.bsize + sizeof(*br->blktype) + sizeof(*br->blklen));
+ br->buf = calloc(br->len, sbd.sd_bsize + sizeof(*br->blktype) + sizeof(*br->blklen));
if (br->buf == NULL) {
perror("Failed to allocate block range buffer");
return 1;
}
- br->blktype = (unsigned *)(br->buf + (br->len * sbd.bsize));
+ br->blktype = (unsigned *)(br->buf + (br->len * sbd.sd_bsize));
br->blklen = br->blktype + br->len;
return 0;
}
@@ -596,7 +596,7 @@ static int block_range_check(struct block_range *br)
static void block_range_setinfo(struct block_range *br, uint64_t owner)
{
for (unsigned i = 0; i < br->len; i++) {
- char *buf = br->buf + (i * sbd.bsize);
+ char *buf = br->buf + (i * sbd.sd_bsize);
uint64_t addr = br->start + i;
uint64_t _owner = (owner == 0) ? addr : owner;
@@ -644,7 +644,7 @@ static int save_range(struct metafd *mfd, struct block_range *br)
for (unsigned i = 0; i < br->len; i++) {
int err;
- err = save_buf(mfd, br->buf + (i * sbd.bsize), br->start + i, br->blklen[i]);
+ err = save_buf(mfd, br->buf + (i * sbd.sd_bsize), br->start + i, br->blklen[i]);
if (err != 0)
return err;
}
@@ -661,8 +661,8 @@ static int check_read_range(int fd, struct block_range *br, uint64_t owner)
if (block_range_check(br) != 0)
return 1;
- size = br->len * sbd.bsize;
- if (pread(sbd.device_fd, br->buf, size, sbd.bsize * br->start) != size) {
+ size = br->len * sbd.sd_bsize;
+ if (pread(sbd.device_fd, br->buf, size, sbd.sd_bsize * br->start) != size) {
fprintf(stderr, "Failed to read block range 0x%"PRIx64" (%u blocks): %s\n",
br->start, br->len, strerror(errno));
free(br->buf);
@@ -698,7 +698,7 @@ static void save_ea_block(struct metafd *mfd, char *buf, uint64_t owner)
uint32_t rec_len = 0;
int e;
- for (e = sizeof(struct gfs2_meta_header); e < sbd.bsize; e += rec_len) {
+ for (e = sizeof(struct gfs2_meta_header); e < sbd.sd_bsize; e += rec_len) {
uint64_t blk, *b;
int charoff, i;
@@ -716,7 +716,7 @@ static void save_ea_block(struct metafd *mfd, char *buf, uint64_t owner)
blk = be64_to_cpu(*b);
_buf = check_read_block(sbd.device_fd, blk, owner, NULL, NULL);
if (_buf != NULL) {
- save_buf(mfd, _buf, blk, sbd.bsize);
+ save_buf(mfd, _buf, blk, sbd.sd_bsize);
free(_buf);
}
}
@@ -737,7 +737,7 @@ static void save_indirect_range(struct metafd *mfd, struct block_range **brp, ui
save_range(mfd, br);
for (unsigned i = 0; i < br->len; i++) {
if (br->blktype[i] == GFS2_METATYPE_EA)
- save_ea_block(mfd, br->buf + (i * sbd.bsize), owner);
+ save_ea_block(mfd, br->buf + (i * sbd.sd_bsize), owner);
}
if (q) {
block_range_queue_insert(q, br);
@@ -756,7 +756,7 @@ static void save_indirect_blocks(struct metafd *mfd, char *buf, uint64_t owner,
uint64_t *ptr;
for (ptr = (uint64_t *)(buf + headsize);
- (char *)ptr < (buf + sbd.bsize); ptr++) {
+ (char *)ptr < (buf + sbd.sd_bsize); ptr++) {
if (!*ptr)
continue;
@@ -802,8 +802,8 @@ static int save_leaf_chain(struct metafd *mfd, struct gfs2_sbd *sdp, char *buf)
if (gfs2_check_range(sdp, blk) != 0)
return 0;
- r = pread(sdp->device_fd, buf, sdp->bsize, sdp->bsize * blk);
- if (r != sdp->bsize) {
+ r = pread(sdp->device_fd, buf, sdp->sd_bsize, sdp->sd_bsize * blk);
+ if (r != sdp->sd_bsize) {
fprintf(stderr, "Failed to read leaf block %"PRIx64": %s\n",
blk, strerror(errno));
free(buf);
@@ -811,7 +811,7 @@ static int save_leaf_chain(struct metafd *mfd, struct gfs2_sbd *sdp, char *buf)
}
report_progress(blk, 0);
if (gfs2_check_meta(buf, GFS2_METATYPE_LF) == 0) {
- int ret = save_buf(mfd, buf, blk, sdp->bsize);
+ int ret = save_buf(mfd, buf, blk, sdp->sd_bsize);
if (ret != 0) {
free(buf);
return ret;
@@ -828,7 +828,7 @@ static void save_leaf_blocks(struct metafd *mfd, struct block_range_queue *q)
struct block_range *br = q->tail;
for (unsigned i = 0; i < br->len; i++) {
- char *buf = br->buf + (i * sbd.bsize);
+ char *buf = br->buf + (i * sbd.sd_bsize);
save_leaf_chain(mfd, &sbd, buf);
}
@@ -896,7 +896,7 @@ static void save_inode_data(struct metafd *mfd, char *ibuf, uint64_t iblk)
struct block_range *q = block_range_queue_pop(&indq[i - 1]);
for (unsigned j = 0; j < q->len; j++) {
- char *_buf = q->buf + (j * sbd.bsize);
+ char *_buf = q->buf + (j * sbd.sd_bsize);
save_indirect_blocks(mfd, _buf, iblk, nextq, sizeof(dip->di_header));
}
@@ -949,8 +949,7 @@ static void get_journal_inode_blocks(void)
struct gfs_jindex ji;
char jbuf[sizeof(struct gfs_jindex)];
- j_inode = lgfs2_gfs_inode_read(&sbd,
- sbd1->sb_jindex_di.no_addr);
+ j_inode = lgfs2_gfs_inode_read(&sbd, sbd.sd_jindex_di.no_addr);
if (j_inode == NULL) {
fprintf(stderr, "Error reading journal inode: %s\n", strerror(errno));
return;
@@ -980,7 +979,7 @@ static void save_allocated_range(struct metafd *mfd, struct block_range *br)
save_range(mfd, br);
for (unsigned i = 0; i < br->len; i++) {
- char *buf = br->buf + (i * sbd.bsize);
+ char *buf = br->buf + (i * sbd.sd_bsize);
if (br->blktype[i] == GFS2_METATYPE_DI)
save_inode_data(mfd, buf, br->start + i);
@@ -992,7 +991,7 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
{
uint64_t blk = 0;
unsigned i, j, m;
- uint64_t *ibuf = malloc(sbd.bsize * GFS2_NBBY * sizeof(uint64_t));
+ uint64_t *ibuf = malloc(sbd.sd_bsize * GFS2_NBBY * sizeof(uint64_t));
for (i = 0; i < rgd->rt_length; i++) {
struct block_range br = {0};
@@ -1036,8 +1035,8 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
static char *rgrp_read(struct gfs2_sbd *sdp, uint64_t addr, unsigned blocks)
{
- size_t len = blocks * sdp->bsize;
- off_t off = addr * sdp->bsize;
+ size_t len = blocks * sdp->sd_bsize;
+ off_t off = addr * sdp->sd_bsize;
char *buf;
if (blocks == 0 || gfs2_check_range(sdp, addr))
@@ -1064,13 +1063,13 @@ static void save_rgrp(struct gfs2_sbd *sdp, struct metafd *mfd, struct rgrp_tree
return;
for (unsigned i = 0; i < rgd->rt_length; i++)
- rgd->bits[i].bi_data = buf + (i * sdp->bsize);
+ rgd->bits[i].bi_data = buf + (i * sdp->sd_bsize);
log_debug("RG at %"PRIu64" is %"PRIu32" long\n", addr, rgd->rt_length);
/* Save the rg and bitmaps */
for (unsigned i = 0; i < rgd->rt_length; i++) {
report_progress(rgd->rt_addr + i, 0);
- save_buf(mfd, buf + (i * sdp->bsize), rgd->rt_addr + i, sdp->bsize);
+ save_buf(mfd, buf + (i * sdp->sd_bsize), rgd->rt_addr + i, sdp->sd_bsize);
}
/* Save the other metadata: inodes, etc. if mode is not 'savergs' */
if (withcontents)
@@ -1130,11 +1129,11 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
blks_saved = 0;
if (sbd.gfs1)
- sbd.bsize = sbd.sd_sb.sb_bsize;
+ sbd.sd_bsize = sbd.sd_bsize;
printf("There are %llu blocks of %u bytes in the filesystem.\n",
- (unsigned long long)sbd.fssize, sbd.bsize);
+ (unsigned long long)sbd.fssize, sbd.sd_bsize);
- printf("Filesystem size: %.2fGB\n", (sbd.fssize * sbd.bsize) / ((float)(1 << 30)));
+ printf("Filesystem size: %.2fGB\n", (sbd.fssize * sbd.sd_bsize) / ((float)(1 << 30)));
get_journal_inode_blocks();
err = init_per_node_lookup();
@@ -1142,13 +1141,13 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
exit(1);
/* Write the savemeta file header */
- err = save_header(&mfd, sbd.fssize * sbd.bsize);
+ err = save_header(&mfd, sbd.fssize * sbd.sd_bsize);
if (err) {
perror("Failed to write metadata file header");
exit(1);
}
/* Save off the superblock */
- sb_addr = GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sbd.bsize;
+ sb_addr = GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sbd.sd_bsize;
buf = check_read_block(sbd.device_fd, sb_addr, 0, NULL, NULL);
if (buf != NULL) {
if (sbd.gfs1)
@@ -1163,10 +1162,10 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
uint64_t blk;
int j;
- blk = sbd1->sb_rindex_di.no_addr;
+ blk = sbd.sd_rindex_di.no_addr;
buf = check_read_block(sbd.device_fd, blk, blk, NULL, NULL);
if (buf != NULL) {
- save_buf(&mfd, buf, blk, sbd.bsize);
+ save_buf(&mfd, buf, blk, sbd.sd_bsize);
save_inode_data(&mfd, buf, blk);
free(buf);
}
@@ -1230,7 +1229,7 @@ static char *restore_block(struct metafd *mfd, struct saved_metablock *svb)
return NULL;
}
- if (svb->siglen > sbd.bsize) {
+ if (svb->siglen > sbd.sd_bsize) {
fprintf(stderr, "Bad record length: %u for block %"PRIu64" (0x%"PRIx64").\n",
svb->siglen, svb->blk, svb->blk);
return NULL;
@@ -1252,17 +1251,16 @@ static int restore_super(struct metafd *mfd, void *buf, int printonly)
{
int ret;
- gfs2_sb_in(&sbd.sd_sb, buf);
- sbd1 = (struct gfs_sb *)&sbd.sd_sb;
- ret = check_sb(&sbd.sd_sb);
+ lgfs2_sb_in(&sbd, buf);
+ ret = check_sb(buf);
if (ret < 0) {
fprintf(stderr, "Error: Invalid superblock in metadata file.\n");
return -1;
}
if (ret == 1)
sbd.gfs1 = 1;
- sbd.bsize = sbd.sd_sb.sb_bsize;
- if ((!printonly) && lgfs2_sb_write(&sbd.sd_sb, sbd.device_fd, sbd.bsize)) {
+ sbd.sd_bsize = sbd.sd_bsize;
+ if ((!printonly) && lgfs2_sb_write(&sbd, sbd.device_fd)) {
fprintf(stderr, "Failed to write superblock\n");
return -1;
}
@@ -1276,7 +1274,7 @@ static int restore_data(int fd, struct metafd *mfd, int printonly)
uint64_t writes = 0;
char *buf;
- buf = calloc(1, sbd.bsize);
+ buf = calloc(1, sbd.sd_bsize);
if (buf == NULL) {
perror("Failed to restore data");
exit(1);
@@ -1304,8 +1302,8 @@ static int restore_data(int fd, struct metafd *mfd, int printonly)
} else {
report_progress(savedata.blk, 0);
memcpy(buf, bp, savedata.siglen);
- memset(buf + savedata.siglen, 0, sbd.bsize - savedata.siglen);
- if (pwrite(fd, buf, sbd.bsize, savedata.blk * sbd.bsize) != sbd.bsize) {
+ memset(buf + savedata.siglen, 0, sbd.sd_bsize - savedata.siglen);
+ if (pwrite(fd, buf, sbd.sd_bsize, savedata.blk * sbd.sd_bsize) != sbd.sd_bsize) {
fprintf(stderr, "write error: %s from %s:%d: block %lld (0x%llx)\n",
strerror(errno), __FUNCTION__, __LINE__,
(unsigned long long)savedata.blk,
@@ -1388,11 +1386,11 @@ static int restore_init(const char *path, struct metafd *mfd, struct savemeta_he
return ret;
if (smh->sh_fs_bytes > 0) {
- sbd.fssize = smh->sh_fs_bytes / sbd.bsize;
+ sbd.fssize = smh->sh_fs_bytes / sbd.sd_bsize;
printf("Saved file system size is %"PRIu64" blocks, %.2fGB\n",
sbd.fssize, smh->sh_fs_bytes / ((float)(1 << 30)));
}
- printf("Block size is %uB\n", sbd.bsize);
+ printf("Block size is %uB\n", sbd.sd_bsize);
printf("This is gfs%c metadata.\n", sbd.gfs1 ? '1': '2');
if (printonly > 1 && printonly == LGFS2_SB_ADDR(&sbd)) {
display_block_type(bp, LGFS2_SB_ADDR(&sbd), TRUE);
@@ -1433,7 +1431,7 @@ void restoremeta(const char *in_fn, const char *out_device, uint64_t printonly)
exit(error);
if (!printonly) {
- uint64_t space = lseek(sbd.device_fd, 0, SEEK_END) / sbd.bsize;
+ uint64_t space = lseek(sbd.device_fd, 0, SEEK_END) / sbd.sd_bsize;
printf("There are %"PRIu64" free blocks on the destination device.\n", space);
}
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c
index 35029202..301986f0 100644
--- a/gfs2/fsck/afterpass1_common.c
+++ b/gfs2/fsck/afterpass1_common.c
@@ -268,7 +268,7 @@ int delete_eattr_entry(struct gfs2_inode *ip, struct gfs2_buffer_head *leaf_bh,
if (!ea_hdr->ea_num_ptrs)
return 0;
- avail_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
+ avail_size = sdp->sd_bsize - sizeof(struct gfs2_meta_header);
max_ptrs = (be32_to_cpu(ea_hdr->ea_data_len) + avail_size - 1) /
avail_size;
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 61b37b75..f6dab286 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -107,7 +107,7 @@ static void refresh_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
if (rgd->rt_addr + i != blkno)
continue;
- memcpy(rgd->bits[i].bi_data, bh->b_data, sdp->bsize);
+ memcpy(rgd->bits[i].bi_data, bh->b_data, sdp->sd_bsize);
rgd->bits[i].bi_modified = 1;
if (i == 0) { /* this is the rgrp itself */
if (sdp->gfs1)
@@ -158,7 +158,7 @@ static int buf_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
log_err(_("Out of memory when replaying journals.\n"));
return FSCK_ERROR;
}
- memcpy(bh_ip->b_data, bh_log->b_data, sdp->bsize);
+ memcpy(bh_ip->b_data, bh_log->b_data, sdp->sd_bsize);
check_magic = ((struct gfs2_meta_header *)
(bh_ip->b_data))->mh_magic;
@@ -213,7 +213,7 @@ static int revoke_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_LB))
continue;
}
- while (offset + sizeof(uint64_t) <= sdp->sd_sb.sb_bsize) {
+ while (offset + sizeof(uint64_t) <= sdp->sd_bsize) {
blkno = be64_to_cpu(*(__be64 *)(bh->b_data + offset));
log_info( _("Journal replay processing revoke for "
"block #%lld (0x%llx) for journal+0x%x\n"),
@@ -278,7 +278,7 @@ static int databuf_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
log_err(_("Out of memory when replaying journals.\n"));
return FSCK_ERROR;
}
- memcpy(bh_ip->b_data, bh_log->b_data, sdp->bsize);
+ memcpy(bh_ip->b_data, bh_log->b_data, sdp->sd_bsize);
/* Unescape */
if (esc) {
@@ -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_size / ip->i_sbd->sd_sb.sb_bsize;
+ uint32_t jd_blocks = ip->i_size / ip->i_sbd->sd_bsize;
uint32_t blk;
struct lgfs2_log_header lh;
uint64_t highest_seq = 0, lowest_seq = 0, prev_seq = 0;
@@ -467,7 +467,7 @@ int preen_is_safe(struct gfs2_sbd *sdp, int preen, int force_check)
return 1; /* not called by rc.sysinit--we're okay to preen */
if (force_check) /* If check was forced by the user? */
return 1; /* user's responsibility--we're okay to preen */
- if (!memcmp(sdp->sd_sb.sb_lockproto + 5, "nolock", 6))
+ if (!memcmp(sdp->sd_lockproto + 5, "nolock", 6))
return 1; /* local file system--preen is okay */
return 0; /* might be mounted on another node--not guaranteed safe */
}
@@ -608,9 +608,9 @@ out:
log_err( _("jid=%u: Failed\n"), j);
reinit:
if (query( _("Do you want to clear the journal instead? (y/n)"))) {
- error = write_journal(sdp->md.journal[j], sdp->bsize,
+ error = write_journal(sdp->md.journal[j], sdp->sd_bsize,
sdp->md.journal[j]->i_size /
- sdp->sd_sb.sb_bsize);
+ sdp->sd_bsize);
log_err(_("jid=%u: journal was cleared.\n"), j);
} else {
log_err( _("jid=%u: journal not cleared.\n"), j);
@@ -873,7 +873,7 @@ int init_jindex(struct gfs2_sbd *sdp, int allow_ji_rebuild)
/* rgrepair requires the journals be read in in order to distinguish
"real" rgrps from rgrps that are just copies left in journals. */
if (sdp->gfs1)
- sdp->md.jiinode = lgfs2_inode_read(sdp, sbd1->sb_jindex_di.no_addr);
+ sdp->md.jiinode = lgfs2_inode_read(sdp, sdp->sd_jindex_di.no_addr);
else
gfs2_lookupi(sdp->master_dir, "jindex", 6, &sdp->md.jiinode);
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index 8b7ac0a9..bc706860 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -157,7 +157,6 @@ extern struct osi_root inodetree;
extern int dups_found; /* How many duplicate references have we found? */
extern int dups_found_first; /* How many duplicates have we found the original
reference for? */
-extern struct gfs_sb *sbd1;
static inline int valid_block(struct gfs2_sbd *sdp, uint64_t blkno)
{
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 16cc1b49..35599fb4 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -46,22 +46,22 @@ static int block_mounters(struct gfs2_sbd *sdp, int block_em)
{
if (block_em) {
/* verify it starts with lock_ */
- if (!strncmp(sdp->sd_sb.sb_lockproto, "lock_", 5)) {
+ if (!strncmp(sdp->sd_lockproto, "lock_", 5)) {
/* Change lock_ to fsck_ */
- memcpy(sdp->sd_sb.sb_lockproto, "fsck_", 5);
+ memcpy(sdp->sd_lockproto, "fsck_", 5);
}
/* FIXME: Need to do other verification in the else
* case */
} else {
/* verify it starts with fsck_ */
/* verify it starts with lock_ */
- if (!strncmp(sdp->sd_sb.sb_lockproto, "fsck_", 5)) {
+ if (!strncmp(sdp->sd_lockproto, "fsck_", 5)) {
/* Change fsck_ to lock_ */
- memcpy(sdp->sd_sb.sb_lockproto, "lock_", 5);
+ memcpy(sdp->sd_lockproto, "lock_", 5);
}
}
- if (lgfs2_sb_write(&sdp->sd_sb, sdp->device_fd, sdp->bsize)) {
+ if (lgfs2_sb_write(sdp, sdp->device_fd)) {
stack;
return -1;
}
@@ -134,7 +134,7 @@ static int set_block_ranges(struct gfs2_sbd *sdp)
{
struct osi_node *n, *next = NULL;
struct rgrp_tree *rgd;
- char buf[sdp->sd_sb.sb_bsize];
+ char buf[sdp->sd_bsize];
uint64_t rmax = 0;
uint64_t rmin = 0;
int error;
@@ -163,16 +163,16 @@ static int set_block_ranges(struct gfs2_sbd *sdp)
last_data_block = rmax;
first_data_block = rmin;
- if (fsck_lseek(sdp->device_fd, (last_fs_block * sdp->sd_sb.sb_bsize))){
+ if (fsck_lseek(sdp->device_fd, (last_fs_block * sdp->sd_bsize))){
log_crit( _("Can't seek to last block in file system: %llu"
" (0x%llx)\n"), (unsigned long long)last_fs_block,
(unsigned long long)last_fs_block);
goto fail;
}
- memset(buf, 0, sdp->sd_sb.sb_bsize);
- error = read(sdp->device_fd, buf, sdp->sd_sb.sb_bsize);
- if (error != sdp->sd_sb.sb_bsize){
+ memset(buf, 0, sdp->sd_bsize);
+ error = read(sdp->device_fd, buf, sdp->sd_bsize);
+ if (error != sdp->sd_bsize){
log_crit( _("Can't read last block in file system (error %u), "
"last_fs_block: %llu (0x%llx)\n"), error,
(unsigned long long)last_fs_block,
@@ -212,10 +212,10 @@ static void check_rgrp_integrity(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
/* Count up the free blocks in the bitmap */
off = (rgb) ? sizeof(struct gfs2_meta_header) :
sizeof(struct gfs2_rgrp);
- if (total_bytes_to_check <= sdp->bsize - off)
+ if (total_bytes_to_check <= sdp->sd_bsize - off)
bytes_to_check = total_bytes_to_check;
else
- bytes_to_check = sdp->bsize - off;
+ bytes_to_check = sdp->sd_bsize - off;
total_bytes_to_check -= bytes_to_check;
for (x = 0; x < bytes_to_check; x++) {
unsigned char *byte;
@@ -464,7 +464,7 @@ static int rebuild_master(struct gfs2_sbd *sdp)
}
log_err(_("Trying to rebuild the master directory.\n"));
inum.no_formal_ino = sdp->md.next_inum++;
- inum.no_addr = sdp->sd_sb.sb_master_dir.no_addr;
+ inum.no_addr = sdp->sd_meta_dir.no_addr;
err = init_dinode(sdp, &bh, &inum, S_IFDIR | 0755, GFS2_DIF_SYSTEM, &inum);
if (err != 0)
return -1;
@@ -651,8 +651,8 @@ static unsigned gfs2_rgrp_reada(struct gfs2_sbd *sdp, unsigned cur_window,
if (i < cur_window)
continue;
rgd = (struct rgrp_tree *)n;
- start = rgd->rt_addr * sdp->bsize;
- len = rgd->rt_length * sdp->bsize;
+ start = rgd->rt_addr * sdp->sd_bsize;
+ len = rgd->rt_length * sdp->sd_bsize;
posix_fadvise(sdp->device_fd, start, len, POSIX_FADV_WILLNEED);
}
@@ -800,7 +800,7 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
log_info( _("Initializing special inodes...\n"));
/* Get root dinode */
- sdp->md.rooti = lgfs2_inode_read(sdp, sdp->sd_sb.sb_root_dir.no_addr);
+ sdp->md.rooti = lgfs2_inode_read(sdp, sdp->sd_root_dir.no_addr);
if (sdp->md.rooti == NULL)
return -1;
@@ -845,19 +845,19 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
if (sdp->gfs1) {
/* In gfs1, the license_di is always 3 blocks after the jindex_di */
- if ((sbd1->sb_license_di.no_addr != sbd1->sb_jindex_di.no_addr + 3) ||
- (sbd1->sb_license_di.no_formal_ino != sbd1->sb_jindex_di.no_addr + 3)) {
+ if ((sdp->sd_license_di.no_addr != sdp->sd_jindex_di.no_addr + 3) ||
+ (sdp->sd_license_di.no_formal_ino != sdp->sd_jindex_di.no_addr + 3)) {
if (!query( _("The gfs system statfs inode pointer is incorrect. "
"Okay to correct? (y/n) "))) {
log_err( _("fsck.gfs2 cannot continue without a valid "
"statfs file; aborting.\n"));
goto fail;
}
- sbd1->sb_license_di.no_addr = sbd1->sb_license_di.no_formal_ino
- = sbd1->sb_jindex_di.no_addr + 3;
+ sdp->sd_license_di.no_addr = sdp->sd_license_di.no_formal_ino
+ = sdp->sd_jindex_di.no_addr + 3;
}
- sdp->md.statfs = lgfs2_inode_read(sdp, sbd1->sb_license_di.no_addr);
+ sdp->md.statfs = lgfs2_inode_read(sdp, sdp->sd_license_di.no_addr);
if (sdp->md.statfs == NULL) {
log_crit(_("Error reading statfs inode: %s\n"), strerror(errno));
goto fail;
@@ -902,19 +902,19 @@ static int init_system_inodes(struct gfs2_sbd *sdp)
if (sdp->gfs1) {
/* In gfs1, the quota_di is always 2 blocks after the jindex_di */
- if ((sbd1->sb_quota_di.no_addr != sbd1->sb_jindex_di.no_addr + 2) ||
- (sbd1->sb_quota_di.no_formal_ino != sbd1->sb_jindex_di.no_addr + 2)) {
+ if ((sdp->sd_quota_di.no_addr != sdp->sd_jindex_di.no_addr + 2) ||
+ (sdp->sd_quota_di.no_formal_ino != sdp->sd_jindex_di.no_addr + 2)) {
if (!query( _("The gfs system quota inode pointer is incorrect. "
" Okay to correct? (y/n) "))) {
log_err( _("fsck.gfs2 cannot continue without a valid "
"quota file; aborting.\n"));
goto fail;
}
- sbd1->sb_quota_di.no_addr = sbd1->sb_quota_di.no_formal_ino
- = sbd1->sb_jindex_di.no_addr + 2;
+ sdp->sd_quota_di.no_addr = sdp->sd_quota_di.no_formal_ino
+ = sdp->sd_jindex_di.no_addr + 2;
}
- sdp->md.qinode = lgfs2_inode_read(sdp, sbd1->sb_quota_di.no_addr);
+ sdp->md.qinode = lgfs2_inode_read(sdp, sdp->sd_quota_di.no_addr);
if (sdp->md.qinode == NULL) {
log_crit(_("Error reading quota inode: %s\n"), strerror(errno));
goto fail;
@@ -991,11 +991,11 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
int error;
if (ip->i_formal_ino == 2) {
- if (sdp->sd_sb.sb_master_dir.no_addr)
+ if (sdp->sd_meta_dir.no_addr)
return;
log_warn(_("Found system master directory at: 0x%"PRIx64".\n"),
ip->i_addr);
- sdp->sd_sb.sb_master_dir.no_addr = ip->i_addr;
+ sdp->sd_meta_dir.no_addr = ip->i_addr;
return;
}
if ((!sdp->gfs1 && ip->i_formal_ino == 3) ||
@@ -1015,7 +1015,7 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
goto out_discard_ip;
}
fix_md.jiinode = child_ip;
- sdp->sd_sb.sb_master_dir.no_addr = ip->i_addr;
+ sdp->sd_meta_dir.no_addr = ip->i_addr;
log_warn(_("Found system master directory at: 0x%"PRIx64"\n"),
ip->i_addr);
return;
@@ -1033,8 +1033,7 @@ static void peruse_system_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
fix_md.pinode = ip;
error = dir_search(ip, "..", 2, NULL, &inum);
if (!error && inum.no_addr) {
- sdp->sd_sb.sb_master_dir.no_addr =
- inum.no_addr;
+ sdp->sd_meta_dir.no_addr = inum.no_addr;
log_warn(_("From per_node's '..' master directory backtracked to: "
"0x%"PRIx64"\n"), inum.no_addr);
}
@@ -1080,7 +1079,7 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
struct gfs2_inum inum;
int error;
- if (sdp->sd_sb.sb_root_dir.no_addr) /* if we know the root dinode */
+ if (sdp->sd_root_dir.no_addr) /* if we know the root dinode */
return; /* we don't need to find the root */
if (!is_dir(ip, sdp->gfs1)) /* if this isn't a directory */
return; /* it can't lead us to the root anyway */
@@ -1091,7 +1090,7 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
if (ip->i_addr == ip->i_bh->b_blocknr) {
log_warn(_("Found the root directory at: 0x%"PRIx64".\n"),
ip->i_addr);
- sdp->sd_sb.sb_root_dir.no_addr = ip->i_addr;
+ sdp->sd_root_dir.no_addr = ip->i_addr;
return;
}
log_warn(_("The root dinode should be at block 0x%"PRIx64" but it "
@@ -1105,7 +1104,7 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
return;
}
root_bh = bread(sdp, ip->i_addr);
- memcpy(root_bh->b_data, ip->i_bh->b_data, sdp->bsize);
+ memcpy(root_bh->b_data, ip->i_bh->b_data, sdp->sd_bsize);
bmodified(root_bh);
brelse(root_bh);
log_warn(_("Root directory copied from the journal.\n"));
@@ -1116,7 +1115,7 @@ static void peruse_user_dinode(struct gfs2_sbd *sdp, struct gfs2_inode *ip)
if (parent_ip && parent_ip->i_addr == ip->i_addr) {
log_warn(_("Found the root directory at: 0x%"PRIx64"\n"),
ip->i_addr);
- sdp->sd_sb.sb_root_dir.no_addr = ip->i_addr;
+ sdp->sd_root_dir.no_addr = ip->i_addr;
inode_put(&parent_ip);
inode_put(&ip);
return;
@@ -1150,7 +1149,7 @@ static int find_rgs_for_bsize(struct gfs2_sbd *sdp, uint64_t startblock,
int found_rg;
struct gfs2_meta_header mh;
- sdp->bsize = GFS2_DEFAULT_BSIZE;
+ sdp->sd_bsize = GFS2_DEFAULT_BSIZE;
max_rg_size = 524288;
/* Max RG size is 2GB. Max block size is 4K. 2G / 4K blks = 524288,
So this is traversing 2GB in 4K block increments. */
@@ -1177,7 +1176,7 @@ static int find_rgs_for_bsize(struct gfs2_sbd *sdp, uint64_t startblock,
rb_addr = (bh->b_blocknr *
(GFS2_DEFAULT_BSIZE / bsize2)) +
(bsize / bsize2) + 1;
- sdp->bsize = bsize2; /* temporarily */
+ sdp->sd_bsize = bsize2; /* temporarily */
rb_bh = bread(sdp, rb_addr);
gfs2_meta_header_in(&mh, rb_bh->b_data);
brelse(rb_bh);
@@ -1193,11 +1192,11 @@ static int find_rgs_for_bsize(struct gfs2_sbd *sdp, uint64_t startblock,
}
brelse(bh);
if (!(*known_bsize)) {
- sdp->bsize = GFS2_DEFAULT_BSIZE;
+ sdp->sd_bsize = GFS2_DEFAULT_BSIZE;
continue;
}
- sdp->bsize = *known_bsize;
+ sdp->sd_bsize = *known_bsize;
log_warn(_("Block size determined to be: %d\n"), *known_bsize);
return 0;
}
@@ -1214,7 +1213,7 @@ static int peruse_metadata(struct gfs2_sbd *sdp, uint64_t startblock)
struct gfs2_buffer_head *bh;
struct gfs2_inode *ip;
- max_rg_size = 2147483648ull / sdp->bsize;
+ max_rg_size = 2147483648ull / sdp->sd_bsize;
/* Max RG size is 2GB. 2G / bsize. */
for (blk = startblock; blk < startblock + max_rg_size; blk++) {
bh = bread(sdp, blk);
@@ -1245,7 +1244,7 @@ static int sb_repair(struct gfs2_sbd *sdp)
memset(&fix_md, 0, sizeof(fix_md));
/* Step 1 - First we need to determine the correct block size. */
- sdp->bsize = GFS2_DEFAULT_BSIZE;
+ sdp->sd_bsize = GFS2_DEFAULT_BSIZE;
log_warn(_("Gathering information to repair the gfs2 superblock. "
"This may take some time.\n"));
error = find_rgs_for_bsize(sdp, (GFS2_SB_ADDR * GFS2_BASIC_BLOCK) /
@@ -1257,7 +1256,7 @@ static int sb_repair(struct gfs2_sbd *sdp)
/* First, figure out the device size. We need that so we can
find a suitable start point to determine what's what. */
half = sdp->dinfo.size / 2; /* in bytes */
- half /= sdp->bsize;
+ half /= sdp->sd_bsize;
/* Start looking halfway through the device for gfs2
structures. If there aren't any at all, forget it. */
error = find_rgs_for_bsize(sdp, half, &known_bsize);
@@ -1274,11 +1273,11 @@ static int sb_repair(struct gfs2_sbd *sdp)
GFS2_DEFAULT_BSIZE);
if (error)
return error;
- if (!sdp->sd_sb.sb_master_dir.no_addr) {
+ if (!sdp->sd_meta_dir.no_addr) {
log_err(_("Unable to locate the system master directory.\n"));
return -1;
}
- if (!sdp->sd_sb.sb_root_dir.no_addr) {
+ if (!sdp->sd_root_dir.no_addr) {
struct gfs2_inum inum;
log_err(_("Unable to locate the root directory.\n"));
@@ -1287,11 +1286,11 @@ static int sb_repair(struct gfs2_sbd *sdp)
creates master immediately after root. */
log_err(_("Can't find any dinodes that might "
"be the root; using master - 1.\n"));
- possible_root = sdp->sd_sb.sb_master_dir.no_addr - 1;
+ possible_root = sdp->sd_meta_dir.no_addr - 1;
}
log_err(_("Found a possible root at: 0x%llx\n"),
(unsigned long long)possible_root);
- sdp->sd_sb.sb_root_dir.no_addr = possible_root;
+ sdp->sd_root_dir.no_addr = possible_root;
sdp->md.rooti = lgfs2_inode_read(sdp, possible_root);
if (!sdp->md.rooti || sdp->md.rooti->i_magic != GFS2_MAGIC) {
struct gfs2_buffer_head *bh = NULL;
@@ -1317,32 +1316,23 @@ static int sb_repair(struct gfs2_sbd *sdp)
}
/* Step 3 - Rebuild the lock protocol and file system table name */
if (query(_("Okay to fix the GFS2 superblock? (y/n)"))) {
- struct gfs2_sb sb;
log_info(_("Found system master directory at: 0x%"PRIx64"\n"),
- sdp->sd_sb.sb_master_dir.no_addr);
- sdp->master_dir = lgfs2_inode_read(sdp,
- sdp->sd_sb.sb_master_dir.no_addr);
+ sdp->sd_meta_dir.no_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.no_addr);
if (sdp->master_dir == NULL) {
log_crit(_("Error reading master inode: %s\n"), strerror(errno));
return -1;
}
- sdp->master_dir->i_addr = sdp->sd_sb.sb_master_dir.no_addr;
+ sdp->master_dir->i_addr = sdp->sd_meta_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,
- sdp->sd_sb.sb_root_dir.no_addr);
+ sdp->sd_root_dir.no_addr);
+ sdp->md.rooti = lgfs2_inode_read(sdp, sdp->sd_root_dir.no_addr);
if (sdp->md.rooti == NULL) {
log_crit(_("Error reading root inode: %s\n"), strerror(errno));
return -1;
}
- 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.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);
+ sdp->sd_fs_format = GFS2_FORMAT_FS;
+ lgfs2_sb_write(sdp, sdp->device_fd);
inode_put(&sdp->md.rooti);
inode_put(&sdp->master_dir);
sb_fixed = 1;
@@ -1366,24 +1356,10 @@ static int fill_super_block(struct gfs2_sbd *sdp)
sync();
- /********************************************************************
- ***************** First, initialize all lists **********************
- ********************************************************************/
log_info( _("Initializing lists...\n"));
sdp->rgtree.osi_node = NULL;
- /********************************************************************
- ************ next, read in on-disk SB and set constants **********
- ********************************************************************/
- sdp->sd_sb.sb_bsize = GFS2_DEFAULT_BSIZE;
- sdp->bsize = sdp->sd_sb.sb_bsize;
-
- if (sizeof(struct gfs2_sb) > sdp->sd_sb.sb_bsize){
- log_crit( _("GFS superblock is larger than the blocksize!\n"));
- log_debug("sizeof(struct gfs2_sb) > sdp->sd_sb.sb_bsize\n");
- return FSCK_ERROR;
- }
-
+ sdp->sd_bsize = GFS2_DEFAULT_BSIZE;
if (compute_constants(sdp)) {
log_crit("%s\n", _("Failed to compute file system constants"));
return FSCK_ERROR;
@@ -1397,10 +1373,8 @@ static int fill_super_block(struct gfs2_sbd *sdp)
if (ret < 0)
return FSCK_ERROR;
}
- if (sdp->gfs1)
- sbd1 = (struct gfs_sb *)&sdp->sd_sb;
- else if (sdp->sd_sb.sb_fs_format > FSCK_MAX_FORMAT) {
- log_crit(_("Unsupported gfs2 format found: %"PRIu32"\n"), sdp->sd_sb.sb_fs_format);
+ if (!sdp->gfs1 && sdp->sd_fs_format > FSCK_MAX_FORMAT) {
+ log_crit(_("Unsupported gfs2 format found: %"PRIu32"\n"), sdp->sd_fs_format);
log_crit(_("A newer fsck.gfs2 is required to check this file system.\n"));
return FSCK_USAGE;
}
@@ -1455,11 +1429,11 @@ static int reconstruct_single_journal(struct gfs2_sbd *sdp, int jnum,
lh.lh_header.mh_format = GFS2_FORMAT_LH;
lh.lh_header.__pad0 = 0x101674; /* mh_generation */
lh.lh_flags = GFS2_LOG_HEAD_UNMOUNT;
- lh.lh_first = sdp->md.journal[jnum]->i_addr + (seg * sbd1->sb_seg_size);
+ lh.lh_first = sdp->md.journal[jnum]->i_addr + (seg * sdp->sd_seg_size);
lh.lh_sequence = sequence;
- bh = bget(sdp, lh.lh_first * sdp->bsize);
- memset(bh->b_data, 0, sdp->bsize);
+ bh = bget(sdp, lh.lh_first * sdp->sd_bsize);
+ memset(bh->b_data, 0, sdp->sd_bsize);
gfs_log_header_out(&lh, bh->b_data);
gfs_log_header_out(&lh, bh->b_data + GFS2_BASIC_BLOCK -
sizeof(struct gfs_log_header));
@@ -1471,21 +1445,20 @@ static int reconstruct_single_journal(struct gfs2_sbd *sdp, int jnum,
return 0;
}
-static int reset_journal_seg_size(unsigned int jsize, unsigned int nsegs,
- unsigned int bsize)
+static int reset_journal_seg_size(struct gfs2_sbd *sdp, unsigned int jsize, unsigned int nsegs)
{
- unsigned int seg_size = jsize / (nsegs * bsize);
+ unsigned int seg_size = jsize / (nsegs * sdp->sd_bsize);
if (!seg_size)
seg_size = 16; /* The default with 128MB journal and 4K bsize */
- if (seg_size != sbd1->sb_seg_size) {
- sbd1->sb_seg_size = seg_size;
+ if (seg_size != sdp->sd_seg_size) {
+ sdp->sd_seg_size = seg_size;
if (!query(_("Computed correct journal segment size to %u."
" Reset it? (y/n) "), seg_size)) {
log_crit(_("Error: Cannot proceed without a valid journal"
" segment size value.\n"));
return -1;
}
- log_err(_("Resetting journal segment size to %u\n"), sbd1->sb_seg_size);
+ log_err(_("Resetting journal segment size to %u\n"), sdp->sd_seg_size);
}
return 0;
}
@@ -1506,7 +1479,7 @@ static int correct_journal_seg_size(struct gfs2_sbd *sdp)
gfs_jindex_in(&ji_0, buf);
if (sdp->md.journals == 1) {
- if (sbd1->sb_seg_size == 0) {
+ if (sdp->sd_seg_size == 0) {
if (!query(_("The gfs2 journal segment size is 0 and a"
" correct value cannot be determined in a"
" single-journal filesystem.\n"
@@ -1532,9 +1505,9 @@ static int correct_journal_seg_size(struct gfs2_sbd *sdp)
}
gfs_jindex_in(&ji_1, buf);
- jsize = (ji_1.ji_addr - ji_0.ji_addr) * sbd1->sb_bsize;
+ jsize = (ji_1.ji_addr - ji_0.ji_addr) * sdp->sd_bsize;
out:
- return reset_journal_seg_size(jsize, ji_0.ji_nsegment, sbd1->sb_bsize);
+ return reset_journal_seg_size(sdp, jsize, ji_0.ji_nsegment);
}
/*
@@ -1580,7 +1553,7 @@ static int init_rindex(struct gfs2_sbd *sdp)
int err;
if (sdp->gfs1)
- sdp->md.riinode = lgfs2_inode_read(sdp, sbd1->sb_rindex_di.no_addr);
+ sdp->md.riinode = lgfs2_inode_read(sdp, sdp->sd_rindex_di.no_addr);
else
gfs2_lookupi(sdp->master_dir, "rindex", 6, &sdp->md.riinode);
@@ -1669,16 +1642,14 @@ int initialize(struct gfs2_sbd *sdp, int force_check, int preen,
if (sdp->gfs1)
sdp->master_dir = NULL;
else
- sdp->master_dir = lgfs2_inode_read(sdp,
- sdp->sd_sb.sb_master_dir.no_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.no_addr);
if (!sdp->gfs1 &&
(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,
- sdp->sd_sb.sb_master_dir.no_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.no_addr);
if (sdp->master_dir == NULL) {
log_crit(_("Error reading master directory: %s\n"), strerror(errno));
return FSCK_ERROR;
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 2543e2e5..b699ca8d 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -322,13 +322,13 @@ static int dirent_repair(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
/* If this is a sentinel, just fix the length and move on */
if (first && !de->de_inum.no_formal_ino) { /* Is it a sentinel? */
if (type == DIR_LINEAR)
- de->de_rec_len = ip->i_sbd->bsize -
+ de->de_rec_len = ip->i_sbd->sd_bsize -
sizeof(struct gfs2_dinode);
else
- de->de_rec_len = ip->i_sbd->bsize -
+ de->de_rec_len = ip->i_sbd->sd_bsize -
sizeof(struct gfs2_leaf);
} else {
- bh_end = bh->b_data + ip->i_sbd->bsize;
+ bh_end = bh->b_data + ip->i_sbd->sd_bsize;
/* first, figure out a probable name length */
p = (char *)dent + sizeof(struct gfs2_dirent);
while (*p && /* while there's a non-zero char and */
@@ -361,7 +361,7 @@ static void dirblk_truncate(struct gfs2_inode *ip, struct gfs2_dirent *fixb,
char *bh_end;
struct gfs2_dirent de;
- bh_end = bh->b_data + ip->i_sbd->sd_sb.sb_bsize;
+ bh_end = bh->b_data + ip->i_sbd->sd_bsize;
/* truncate the block to save the most dentries. To do this we
have to patch the previous dent. */
gfs2_dirent_in(&de, (char *)fixb);
@@ -394,7 +394,7 @@ static int check_entries(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
char *filename;
int first = 1;
- bh_end = bh->b_data + ip->i_sbd->bsize;
+ bh_end = bh->b_data + ip->i_sbd->sd_bsize;
if (type == DIR_LINEAR) {
dent = (struct gfs2_dirent *)(bh->b_data + sizeof(struct gfs2_dinode));
@@ -673,11 +673,11 @@ static void dir_leaf_reada(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize)
for (i = 0; i < hsize; i++) {
leaf_no = be64_to_cpu(tbl[i]);
if (valid_block_ip(ip, leaf_no))
- t[n++] = leaf_no * sdp->bsize;
+ t[n++] = leaf_no * sdp->sd_bsize;
}
qsort(t, n, sizeof(uint64_t), u64cmp);
for (i = 0; i < n; i++)
- posix_fadvise(sdp->device_fd, t[i], sdp->bsize, POSIX_FADV_WILLNEED);
+ posix_fadvise(sdp->device_fd, t[i], sdp->sd_bsize, POSIX_FADV_WILLNEED);
}
/* Checks exhash directory entries */
@@ -890,14 +890,14 @@ static int check_eattr_entries(struct gfs2_inode *ip,
pass->private);
if (err)
error = err;
- tot_ealen += sdp->sd_sb.sb_bsize -
+ tot_ealen += sdp->sd_bsize -
sizeof(struct gfs2_meta_header);
ea_data_ptr++;
}
}
offset += be32_to_cpu(ea_hdr->ea_rec_len);
if (ea_hdr->ea_flags & GFS2_EAFLAG_LAST ||
- offset >= ip->i_sbd->sd_sb.sb_bsize || ea_hdr->ea_rec_len == 0){
+ offset >= ip->i_sbd->sd_bsize || ea_hdr->ea_rec_len == 0){
break;
}
ea_hdr_prev = ea_hdr;
@@ -970,7 +970,7 @@ static int check_indirect_eattr(struct gfs2_inode *ip, uint64_t indirect,
int leaf_pointers = 0, leaf_pointer_errors = 0;
ea_leaf_ptr = (uint64_t *)(indirect_buf->b_data + offset);
- end = ea_leaf_ptr + ((sdp->sd_sb.sb_bsize - offset) / 8);
+ end = ea_leaf_ptr + ((sdp->sd_bsize - offset) / 8);
while (*ea_leaf_ptr && (ea_leaf_ptr < end)){
block = be64_to_cpu(*ea_leaf_ptr);
@@ -1123,8 +1123,8 @@ static void file_ra(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
extlen = block - sblock;
if (extlen > 1 && extlen <= maxptrs) {
posix_fadvise(sdp->device_fd,
- sblock * sdp->bsize,
- (extlen + 1) * sdp->bsize,
+ sblock * sdp->sd_bsize,
+ (extlen + 1) * sdp->sd_bsize,
POSIX_FADV_WILLNEED);
return;
}
@@ -1132,7 +1132,7 @@ static void file_ra(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
extlen = 0;
}
for (p = (uint64_t *)(bh->b_data + head_size);
- p < (uint64_t *)(bh->b_data + sdp->bsize); p++) {
+ p < (uint64_t *)(bh->b_data + sdp->sd_bsize); p++) {
if (*p) {
if (!sblock) {
sblock = be64_to_cpu(*p);
@@ -1148,16 +1148,16 @@ static void file_ra(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
if (extlen && sblock) {
if (extlen > 1)
extlen--;
- posix_fadvise(sdp->device_fd, sblock * sdp->bsize,
- extlen * sdp->bsize,
+ posix_fadvise(sdp->device_fd, sblock * sdp->sd_bsize,
+ extlen * sdp->sd_bsize,
POSIX_FADV_WILLNEED);
extlen = 0;
p--;
}
}
if (extlen)
- posix_fadvise(sdp->device_fd, sblock * sdp->bsize,
- extlen * sdp->bsize, POSIX_FADV_WILLNEED);
+ posix_fadvise(sdp->device_fd, sblock * sdp->sd_bsize,
+ extlen * sdp->sd_bsize, POSIX_FADV_WILLNEED);
}
static int do_check_metalist(struct iptr iptr, int height, struct gfs2_buffer_head **bhp,
@@ -1252,7 +1252,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
iblk_type = GFS2_METATYPE_IN;
if (ip->i_sbd->gfs1) {
head_size = sizeof(struct gfs_indirect);
- maxptrs = (ip->i_sbd->bsize - head_size) /
+ maxptrs = (ip->i_sbd->sd_bsize - head_size) /
sizeof(uint64_t);
} else {
head_size = sizeof(struct gfs2_meta_header);
@@ -1280,7 +1280,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
file_ra(ip, iptr.ipt_bh, head_size, maxptrs, h);
/* Now check the metadata itself */
- for (; iptr.ipt_off < ip->i_sbd->bsize; iptr.ipt_off += sizeof(uint64_t)) {
+ for (; iptr.ipt_off < ip->i_sbd->sd_bsize; iptr.ipt_off += sizeof(uint64_t)) {
struct gfs2_buffer_head *nbh = NULL;
if (skip_this_pass || fsck_abort)
@@ -1398,7 +1398,7 @@ static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass
int error = 0, rc = 0;
uint64_t block;
__be64 *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
- __be64 *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
+ __be64 *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->sd_bsize);
__be64 *ptr;
uint64_t metablock = bh->b_blocknr;
@@ -1464,7 +1464,7 @@ static int undo_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
struct error_block *error_blk, int error)
{
__be64 *ptr_start = (uint64_t *)(bh->b_data + hdr_size(bh, height));
- __be64 *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->bsize);
+ __be64 *ptr_end = (uint64_t *)(bh->b_data + ip->i_sbd->sd_bsize);
__be64 *ptr;
uint64_t metablock = bh->b_blocknr;
int rc = 0;
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index f63ed5cf..f6c6bc31 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -50,7 +50,7 @@ struct iptr {
#define iptr_ptr(i) ((uint64_t *)(i.ipt_bh->b_data + i.ipt_off))
#define iptr_block(i) be64_to_cpu(*iptr_ptr(i))
-#define iptr_endptr(i) ((uint64_t *)(iptr.ipt_bh->b_data + i.ipt_ip->i_sbd->bsize))
+#define iptr_endptr(i) ((uint64_t *)(iptr.ipt_bh->b_data + i.ipt_ip->i_sbd->sd_bsize))
#define iptr_buf(i) (i.ipt_bh->b_data)
/* metawalk_fxns: function pointers to check various parts of the fs
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index f2ba4235..047a96b0 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -898,7 +898,7 @@ static int ask_remove_eattr_entry(struct gfs2_sbd *sdp,
if (fix_curr)
curr->ea_flags |= GFS2_EAFLAG_LAST;
if (fix_curr_len) {
- uint32_t max_size = sdp->sd_sb.sb_bsize;
+ uint32_t max_size = sdp->sd_bsize;
uint32_t offset = (uint32_t)(((unsigned long)curr) -
((unsigned long)leaf_bh->b_data));
curr->ea_rec_len = cpu_to_be32(max_size - offset);
@@ -938,7 +938,7 @@ static int check_eattr_entries(struct gfs2_inode *ip,
char ea_name[256];
uint32_t offset = (uint32_t)(((unsigned long)ea_hdr) -
((unsigned long)leaf_bh->b_data));
- uint32_t max_size = sdp->sd_sb.sb_bsize;
+ uint32_t max_size = sdp->sd_bsize;
uint32_t avail_size;
int max_ptrs;
@@ -968,11 +968,11 @@ static int check_eattr_entries(struct gfs2_inode *ip,
strncpy(ea_name, (char *)ea_hdr + sizeof(struct gfs2_ea_header),
ea_hdr->ea_name_len);
- if (ea_hdr->ea_type > eatype_max(sdp->sd_sb.sb_fs_format) &&
+ if (ea_hdr->ea_type > eatype_max(sdp->sd_fs_format) &&
((ea_hdr_prev) || (!ea_hdr_prev && ea_hdr->ea_type))){
/* Skip invalid entry */
log_err(_("EA (%s) type is invalid (%d > %d).\n"),
- ea_name, ea_hdr->ea_type, eatype_max(sdp->sd_sb.sb_fs_format));
+ ea_name, ea_hdr->ea_type, eatype_max(sdp->sd_fs_format));
return ask_remove_eattr_entry(sdp, leaf_bh, ea_hdr,
ea_hdr_prev, 0, 0);
}
@@ -980,7 +980,7 @@ static int check_eattr_entries(struct gfs2_inode *ip,
if (!ea_hdr->ea_num_ptrs)
return 0;
- avail_size = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
+ avail_size = sdp->sd_bsize - sizeof(struct gfs2_meta_header);
max_ptrs = (be32_to_cpu(ea_hdr->ea_data_len)+avail_size-1)/avail_size;
if (max_ptrs > ea_hdr->ea_num_ptrs) {
@@ -1812,7 +1812,7 @@ static int pass1_process_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd, uin
int q;
/* Readahead numbers arrived at by experiment */
unsigned rawin = 50;
- unsigned ralen = 100 * sdp->bsize;
+ unsigned ralen = 100 * sdp->sd_bsize;
unsigned r = 0;
for (i = 0; i < n; i++) {
@@ -1822,7 +1822,7 @@ static int pass1_process_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd, uin
block = ibuf[i];
if (r++ == rawin) {
- posix_fadvise(sdp->device_fd, block * sdp->bsize, ralen, POSIX_FADV_WILLNEED);
+ posix_fadvise(sdp->device_fd, block * sdp->sd_bsize, ralen, POSIX_FADV_WILLNEED);
r = 0;
}
@@ -1938,7 +1938,7 @@ static int pass1_process_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd, uin
static int pass1_process_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
{
unsigned k, n, i;
- uint64_t *ibuf = malloc(sdp->bsize * GFS2_NBBY * sizeof(uint64_t));
+ uint64_t *ibuf = malloc(sdp->sd_bsize * GFS2_NBBY * sizeof(uint64_t));
int ret = 0;
if (ibuf == NULL)
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index d5fe61b3..d8d08056 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -1017,7 +1017,7 @@ static int write_new_leaf(struct gfs2_inode *dip, int start_lindex,
dip->i_blocks++;
bmodified(dip->i_bh);
nbh = bget(dip->i_sbd, *bn);
- memset(nbh->b_data, 0, dip->i_sbd->bsize);
+ memset(nbh->b_data, 0, dip->i_sbd->sd_bsize);
leaf = (struct gfs2_leaf *)nbh->b_data;
leaf->lf_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
leaf->lf_header.mh_type = cpu_to_be32(GFS2_METATYPE_LF);
@@ -1026,7 +1026,7 @@ static int write_new_leaf(struct gfs2_inode *dip, int start_lindex,
/* initialize the first dirent on the new leaf block */
dent = (struct gfs2_dirent *)(nbh->b_data + sizeof(struct gfs2_leaf));
- dent->de_rec_len = cpu_to_be16(dip->i_sbd->bsize -
+ dent->de_rec_len = cpu_to_be16(dip->i_sbd->sd_bsize -
sizeof(struct gfs2_leaf));
bmodified(nbh);
brelse(nbh);
@@ -1119,7 +1119,7 @@ static int lost_leaf(struct gfs2_inode *ip, uint64_t *tbl, uint64_t leafno,
int ref_count, int lindex, struct gfs2_buffer_head *bh)
{
char *filename;
- char *bh_end = bh->b_data + ip->i_sbd->bsize;
+ char *bh_end = bh->b_data + ip->i_sbd->sd_bsize;
struct gfs2_dirent de, *dent;
int error;
int isdir = 0;
@@ -1382,7 +1382,7 @@ static int fix_hashtable(struct gfs2_inode *ip, uint64_t *tbl, unsigned hsize,
gfs2_dirent_in(&dentry, (char *)de);
/* If this is an empty leaf, we can just delete it and pad. */
- if ((dentry.de_rec_len == cpu_to_be16(ip->i_sbd->bsize -
+ if ((dentry.de_rec_len == cpu_to_be16(ip->i_sbd->sd_bsize -
sizeof(struct gfs2_leaf))) &&
(dentry.de_inum.no_formal_ino == 0)) {
brelse(lbh);
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 029f0711..fbdc4f34 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -60,7 +60,7 @@ static void find_journaled_rgs(struct gfs2_sbd *sdp)
ip = sdp->md.journal[j];
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;
+ jblocks = ip->i_size / sdp->sd_bsize;
false_count = 0;
for (b = 0; b < jblocks; b++) {
block_map(ip, b, &new, &dblock, NULL, 0);
@@ -276,7 +276,7 @@ static uint64_t count_usedspace(struct gfs2_sbd *sdp, int first,
off = sizeof(struct gfs2_rgrp);
} else
off = sizeof(struct gfs2_meta_header);
- bytes_to_check = sdp->bsize - off;
+ bytes_to_check = sdp->sd_bsize - off;
for (x = 0; x < bytes_to_check; x++) {
unsigned char *byte;
@@ -336,7 +336,7 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
rgrp_dist = next_rgd->rt_addr - rgd->rt_addr;
return rgrp_dist;
}
- mega_in_blocks = (1024 * 1024) / sdp->bsize;
+ mega_in_blocks = (1024 * 1024) / sdp->sd_bsize;
twogigs = (uint64_t)mega_in_blocks * 2048;
/* Unfortunately, if we fall through to here we can't trust the
rindex. So we have to analyze the current rgrp to figure out
@@ -453,7 +453,7 @@ static uint64_t hunt_and_peck(struct gfs2_sbd *sdp, uint64_t blk,
/* Now we account for block rounding done by mkfs.gfs2. A rgrp can
be at most 2GB in size, so that's where we call it. We do somewhat
obscure math here to avoid integer overflows. */
- mega_in_blocks = (1024 * 1024) / sdp->bsize;
+ mega_in_blocks = (1024 * 1024) / sdp->sd_bsize;
twogigs = 2048 * mega_in_blocks;
if (block + twogigs <= sdp->fssize) {
last_block = twogigs;
@@ -599,7 +599,7 @@ static int rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs, int gfs_grow)
if (prev_rgd) {
uint32_t rgblocks;
- prev_rgd->rt_length = rgblocks2bitblocks(sdp->bsize, block_bump, &rgblocks);
+ prev_rgd->rt_length = rgblocks2bitblocks(sdp->sd_bsize, block_bump, &rgblocks);
prev_rgd->rt_data = rgblocks;
prev_rgd->rt_data0 = prev_rgd->rt_addr +
prev_rgd->rt_length;
@@ -661,7 +661,7 @@ static int rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs, int gfs_grow)
if (prev_rgd && !prev_rgd->rt_data) {
uint32_t rgblocks;
- prev_rgd->rt_length = rgblocks2bitblocks(sdp->bsize, block_bump, &rgblocks);
+ prev_rgd->rt_length = rgblocks2bitblocks(sdp->sd_bsize, block_bump, &rgblocks);
prev_rgd->rt_data0 = prev_rgd->rt_addr + prev_rgd->rt_length;
prev_rgd->rt_data = rgblocks;
prev_rgd->rt_data -= prev_rgd->rt_data % GFS2_NBBY;
@@ -707,12 +707,12 @@ static uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev, int rgs
int bitmap_overflow = 0;
while (1) {
- nrgrp = DIV_RU(dev->length, (sdp->rgsize << 20) / sdp->bsize);
+ nrgrp = DIV_RU(dev->length, (sdp->rgsize << 20) / sdp->sd_bsize);
/* check to see if the rg length overflows max # bitblks */
- bitblocksn = rgblocks2bitblocks(sdp->bsize, dev->length / nrgrp, &rgblocksn);
+ bitblocksn = rgblocks2bitblocks(sdp->sd_bsize, dev->length / nrgrp, &rgblocksn);
/* calculate size of the first rgrp */
- bitblocks1 = rgblocks2bitblocks(sdp->bsize, dev->length - (nrgrp - 1) * (dev->length / nrgrp),
+ bitblocks1 = rgblocks2bitblocks(sdp->sd_bsize, dev->length - (nrgrp - 1) * (dev->length / nrgrp),
&rgblocks1);
if (bitblocks1 > 2149 || bitblocksn > 2149) {
bitmap_overflow = 1;
@@ -720,7 +720,7 @@ static uint64_t how_many_rgrps(struct gfs2_sbd *sdp, struct device *dev, int rgs
fprintf(stderr, "error: It is not possible "
"to use the entire device with "
"block size %u bytes.\n",
- sdp->bsize);
+ sdp->sd_bsize);
exit(-1);
}
sdp->rgsize -= GFS2_DEFAULT_RGSIZE; /* smaller rgs */
@@ -820,7 +820,7 @@ static int calc_rgrps(struct gfs2_sbd *sdp)
next = osi_next(n);
rl = (struct rgrp_tree *)n;
- bitblocks = rgblocks2bitblocks(sdp->bsize, rl->length, &rgblocks);
+ bitblocks = rgblocks2bitblocks(sdp->sd_bsize, rl->length, &rgblocks);
rl->rt_addr = rl->start;
rl->rt_length = bitblocks;
@@ -829,7 +829,7 @@ static int calc_rgrps(struct gfs2_sbd *sdp)
rl->rt_bitbytes = rgblocks / GFS2_NBBY;
rl->rt_free = rgblocks;
- if (gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, rl))
+ if (gfs2_compute_bitstructs(sdp->sd_bsize, rl))
return -1;
sdp->blks_total += rgblocks;
@@ -909,13 +909,13 @@ static int rewrite_rg_block(struct gfs2_sbd *sdp, struct rgrp_tree *rg,
log_err(_("Attempting to repair the resource group.\n"));
- buf = calloc(1, sdp->bsize);
+ buf = calloc(1, sdp->sd_bsize);
if (buf == NULL) {
log_err(_("Failed to allocate resource group block: %s"), strerror(errno));
return 1;
}
- ret = pread(sdp->device_fd, buf, sdp->bsize, errblock * sdp->bsize);
- if (ret != sdp->bsize) {
+ ret = pread(sdp->device_fd, buf, sdp->sd_bsize, errblock * sdp->sd_bsize);
+ if (ret != sdp->sd_bsize) {
log_err(_("Failed to read resource group block %"PRIu64": %s\n"),
errblock, strerror(errno));
free(buf);
@@ -935,8 +935,8 @@ static int rewrite_rg_block(struct gfs2_sbd *sdp, struct rgrp_tree *rg,
else
lgfs2_rgrp_out(rg, buf);
}
- ret = pwrite(sdp->device_fd, buf, sdp->bsize, errblock * sdp->bsize);
- if (ret != sdp->bsize) {
+ ret = pwrite(sdp->device_fd, buf, sdp->sd_bsize, errblock * sdp->sd_bsize);
+ if (ret != sdp->sd_bsize) {
log_err(_("Failed to write resource group block %"PRIu64": %s\n"),
errblock, strerror(errno));
free(buf);
@@ -977,7 +977,7 @@ static int expect_rindex_sanity(struct gfs2_sbd *sdp, int *num_rgs)
exp->rt_dinodes = rgd->rt_dinodes;
exp->rt_skip = rgd->rt_skip;
exp->bits = NULL;
- gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, exp);
+ gfs2_compute_bitstructs(sdp->sd_bsize, exp);
}
sdp->rgrps = *num_rgs;
return 0;
@@ -1213,7 +1213,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
}
else
log_err( _("rindex not fixed.\n"));
- gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, actual);
+ gfs2_compute_bitstructs(sdp->sd_bsize, actual);
rindex_modified = 0;
}
e = enext;
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index dfc4512c..962ec1e0 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -44,7 +44,7 @@ void big_file_comfort(struct gfs2_inode *ip, uint64_t blks_checked)
fsize = ip->i_size;
for (i = 0; i < 6 && fsize > 1024; i++)
fsize /= 1024;
- chksize = blks_checked * ip->i_sbd->bsize;
+ chksize = blks_checked * ip->i_sbd->sd_bsize;
for (cs = 0; cs < 6 && chksize > 1024; cs++)
chksize /= 1024;
seconds = tv.tv_sec;
@@ -563,7 +563,7 @@ uint64_t find_free_blk(struct gfs2_sbd *sdp)
char *buf = rl->bits[block].bi_data;
x = (block) ? sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_rgrp);
- for (; x < sdp->bsize; x++)
+ for (; x < sdp->sd_bsize; x++)
for (y = 0; y < GFS2_NBBY; y++) {
state = (buf[x] >> (GFS2_BIT_SIZE * y)) & 0x03;
if (state == GFS2_BLKST_FREE)
diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
index c0fc0ceb..e7282517 100644
--- a/gfs2/glocktop/glocktop.c
+++ b/gfs2/glocktop/glocktop.c
@@ -156,7 +156,7 @@ struct mount_point {
char *device;
char *dir;
int fd;
- struct gfs2_sb sb;
+ struct gfs2_sbd sb;
};
struct mount_point *mounts;
char dlmwlines[MAX_LINES][96]; /* waiters lines */
@@ -223,7 +223,7 @@ static void UpdateSize(int sig)
signal(SIGWINCH, UpdateSize);
}
-static int read_superblock(int fd, struct gfs2_sb *sb)
+static int read_superblock(int fd, struct gfs2_sbd *sdp)
{
ssize_t r;
char *buf;
@@ -240,10 +240,10 @@ static int read_superblock(int fd, struct gfs2_sb *sb)
free(buf);
return -1;
}
- gfs2_sb_in(sb, buf);
+ lgfs2_sb_in(sdp, buf);
free(buf);
- bsize = sb->sb_bsize;
+ bsize = sdp->sd_bsize;
if (!bsize)
bsize = 4096;
return 0;
@@ -618,7 +618,7 @@ static const char *show_inode(const char *id, int fd, unsigned long long block)
{
struct gfs2_inode *ip;
const char *inode_type = NULL;
- struct gfs2_sbd sbd = { .device_fd = fd, .bsize = bsize };
+ struct gfs2_sbd sbd = { .device_fd = fd, .sd_bsize = bsize };
ip = lgfs2_inode_read(&sbd, block);
if (S_ISDIR(ip->i_mode)) {
@@ -674,7 +674,7 @@ static const char *show_details(const char *id, const char *fsname, int btype,
for (mp = mounts; mp != NULL; mp = mp->next) {
char *p;
- p = strchr(mp->sb.sb_locktable, ':');
+ p = strchr(mp->sb.sd_locktable, ':');
if (!p)
continue;
p++;
@@ -686,7 +686,7 @@ static const char *show_details(const char *id, const char *fsname, int btype,
memset(dlm_dirtbl_size, 0, sizeof(dlm_dirtbl_size));
memset(dlm_rsbtbl_size, 0, sizeof(dlm_rsbtbl_size));
memset(dlm_lkbtbl_size, 0, sizeof(dlm_lkbtbl_size));
- if (!strcmp(mp->sb.sb_lockproto, "lock_dlm")) {
+ if (!strcmp(mp->sb.sd_lockproto, "lock_dlm")) {
char *sp;
char *p;
diff --git a/gfs2/libgfs2/buf.c b/gfs2/libgfs2/buf.c
index 22144d68..e317625f 100644
--- a/gfs2/libgfs2/buf.c
+++ b/gfs2/libgfs2/buf.c
@@ -26,14 +26,14 @@ struct gfs2_buffer_head *bget(struct gfs2_sbd *sdp, uint64_t num)
{
struct gfs2_buffer_head *bh;
- bh = calloc(1, sizeof(struct gfs2_buffer_head) + sdp->bsize);
+ bh = calloc(1, sizeof(struct gfs2_buffer_head) + sdp->sd_bsize);
if (bh == NULL)
return NULL;
bh->b_blocknr = num;
bh->sdp = sdp;
bh->iov.iov_base = (char *)bh + sizeof(struct gfs2_buffer_head);
- bh->iov.iov_len = sdp->bsize;
+ bh->iov.iov_len = sdp->sd_bsize;
return bh;
}
@@ -59,7 +59,7 @@ int __breadm(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhs, size_t n,
size += bhs[i + j]->iov.iov_len;
}
- ret = preadv(sdp->device_fd, iovbase, j, (block + i) * sdp->bsize);
+ ret = preadv(sdp->device_fd, iovbase, j, (block + i) * sdp->sd_bsize);
if (ret != size) {
fprintf(stderr, "bad read: %s from %s:%d: block %llu (0x%llx) "
"count: %d size: %zd ret: %zd\n", strerror(errno),
@@ -82,8 +82,8 @@ struct gfs2_buffer_head *__bread(struct gfs2_sbd *sdp, uint64_t num, int line,
if (bh == NULL)
return NULL;
- ret = pread(sdp->device_fd, bh->b_data, sdp->bsize, num * sdp->bsize);
- if (ret != sdp->bsize) {
+ ret = pread(sdp->device_fd, bh->b_data, sdp->sd_bsize, num * sdp->sd_bsize);
+ if (ret != sdp->sd_bsize) {
fprintf(stderr, "%s:%d: Error reading block %"PRIu64": %s\n",
caller, line, num, strerror(errno));
free(bh);
@@ -96,7 +96,7 @@ int bwrite(struct gfs2_buffer_head *bh)
{
struct gfs2_sbd *sdp = bh->sdp;
- if (pwritev(sdp->device_fd, &bh->iov, 1, bh->b_blocknr * sdp->bsize) != bh->iov.iov_len)
+ if (pwritev(sdp->device_fd, &bh->iov, 1, bh->b_blocknr * sdp->sd_bsize) != bh->iov.iov_len)
return -1;
bh->b_modified = 0;
return 0;
diff --git a/gfs2/libgfs2/check_rgrp.c b/gfs2/libgfs2/check_rgrp.c
index dd31a341..5178c7a7 100644
--- a/gfs2/libgfs2/check_rgrp.c
+++ b/gfs2/libgfs2/check_rgrp.c
@@ -34,7 +34,7 @@ static void mockup_rgrps(void)
ck_assert(unlink(tmpnam) == 0);
ck_assert(ftruncate(sdp->device_fd, MOCK_DEV_SIZE) == 0);
- sdp->bsize = sdp->sd_sb.sb_bsize = 4096;
+ sdp->sd_bsize = 4096;
compute_constants(sdp);
rgs = lgfs2_rgrps_init(sdp, 0, 0);
@@ -115,7 +115,7 @@ START_TEST(test_rbm_find_lastblock)
/* Flag all blocks as allocated... */
for (i = 0; i < rg->rt_length; i++)
- memset(rg->bits[i].bi_data, 0xff, rgs->sdp->bsize);
+ memset(rg->bits[i].bi_data, 0xff, rgs->sdp->sd_bsize);
/* ...except the final one */
err = gfs2_set_bitmap(rg, rg->rt_data0 + rg->rt_data - 1, GFS2_BLKST_FREE);
diff --git a/gfs2/libgfs2/device_geometry.c b/gfs2/libgfs2/device_geometry.c
index 72f9c7e4..4a0aeab2 100644
--- a/gfs2/libgfs2/device_geometry.c
+++ b/gfs2/libgfs2/device_geometry.c
@@ -97,7 +97,7 @@ void fix_device_geometry(struct gfs2_sbd *sdp)
{
struct device *device = &sdp->device;
- device->length = sdp->dinfo.size / sdp->bsize;
+ device->length = sdp->dinfo.size / sdp->sd_bsize;
if (cfg_debug) {
printf("\nDevice Geometry: (in FS blocks)\n");
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index c0569257..f7205393 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -219,7 +219,7 @@ int lgfs2_meta_alloc(struct gfs2_inode *ip, uint64_t *blkno)
static __inline__ void buffer_clear_tail(struct gfs2_sbd *sdp,
struct gfs2_buffer_head *bh, int head)
{
- memset(bh->b_data + head, 0, sdp->bsize - head);
+ memset(bh->b_data + head, 0, sdp->sd_bsize - head);
bmodified(bh);
}
@@ -229,8 +229,8 @@ buffer_copy_tail(struct gfs2_sbd *sdp,
struct gfs2_buffer_head *from_bh, int from_head)
{
memcpy(to_bh->b_data + to_head, from_bh->b_data + from_head,
- sdp->bsize - from_head);
- memset(to_bh->b_data + sdp->bsize + to_head - from_head, 0,
+ sdp->sd_bsize - from_head);
+ memset(to_bh->b_data + sdp->sd_bsize + to_head - from_head, 0,
from_head - to_head);
bmodified(to_bh);
}
@@ -316,7 +316,7 @@ int lgfs2_file_alloc(lgfs2_rgrp_t rg, uint64_t di_size, struct gfs2_inode *ip, u
unsigned extlen;
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);
+ uint32_t blocks = lgfs2_space_for_data(sdp, sdp->sd_bsize, di_size);
if (ip->i_addr != 0) {
if (lgfs2_rbm_from_block(&rbm, ip->i_addr) != 0)
@@ -344,7 +344,7 @@ int lgfs2_file_alloc(lgfs2_rgrp_t rg, uint64_t di_size, struct gfs2_inode *ip, u
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_goal_meta = ip->i_goal_data - ((di_size + sdp->sd_bsize - 1) / sdp->sd_bsize);
ip->i_height = calc_tree_height(ip, di_size);
ip->i_flags = flags;
@@ -491,7 +491,7 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
return;
}
- bsize = (S_ISDIR(ip->i_mode)) ? sdp->sd_jbsize : sdp->bsize;
+ bsize = (S_ISDIR(ip->i_mode)) ? sdp->sd_jbsize : sdp->sd_bsize;
height = calc_tree_height(ip, (lblock + 1) * bsize);
if (ip->i_height < height) {
@@ -600,8 +600,8 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
o = lblock % sdp->sd_jbsize;
lblock /= sdp->sd_jbsize;
} else {
- lblock = offset >> sdp->sd_sb.sb_bsize_shift;
- o = offset & (sdp->bsize - 1);
+ lblock = offset >> sdp->sd_bsize_shift;
+ o = offset & (sdp->sd_bsize - 1);
}
if (inode_is_stuffed(ip))
@@ -611,8 +611,8 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
while (copied < size) {
amount = size - copied;
- if (amount > sdp->bsize - o)
- amount = sdp->bsize - o;
+ if (amount > sdp->sd_bsize - o)
+ amount = sdp->sd_bsize - o;
if (!extlen) {
if (sdp->gfs1)
@@ -677,7 +677,7 @@ int __gfs2_writei(struct gfs2_inode *ip, void *buf,
return 0;
if (inode_is_stuffed(ip) &&
- ((start + size) > (sdp->bsize - sizeof(struct gfs2_dinode))))
+ ((start + size) > (sdp->sd_bsize - sizeof(struct gfs2_dinode))))
unstuff_dinode(ip);
if (isdir) {
@@ -685,8 +685,8 @@ int __gfs2_writei(struct gfs2_inode *ip, void *buf,
o = lblock % sdp->sd_jbsize;
lblock /= sdp->sd_jbsize;
} else {
- lblock = offset >> sdp->sd_sb.sb_bsize_shift;
- o = offset & (sdp->bsize - 1);
+ lblock = offset >> sdp->sd_bsize_shift;
+ o = offset & (sdp->sd_bsize - 1);
}
if (inode_is_stuffed(ip))
@@ -696,8 +696,8 @@ int __gfs2_writei(struct gfs2_inode *ip, void *buf,
while (copied < size) {
amount = size - copied;
- if (amount > sdp->bsize - o)
- amount = sdp->bsize - o;
+ if (amount > sdp->sd_bsize - o)
+ amount = sdp->sd_bsize - o;
if (!extlen) {
new = 1;
@@ -760,7 +760,7 @@ int gfs2_dirent_next(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
char *bh_end;
uint16_t cur_rec_len;
- bh_end = bh->b_data + dip->i_sbd->bsize;
+ bh_end = bh->b_data + dip->i_sbd->sd_bsize;
cur_rec_len = be16_to_cpu((*dent)->de_rec_len);
if (cur_rec_len == 0 || (char *)(*dent) + cur_rec_len >= bh_end)
@@ -797,7 +797,7 @@ static int dirent_alloc(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
}
if (!entries) {
- dent->de_rec_len = cpu_to_be16(dip->i_sbd->bsize - offset);
+ dent->de_rec_len = cpu_to_be16(dip->i_sbd->sd_bsize - offset);
dent->de_name_len = cpu_to_be16(name_len);
bmodified(bh);
*dent_out = dent;
@@ -1042,12 +1042,12 @@ static void dir_double_exhash(struct gfs2_inode *dip)
if (sdp->gfs1)
count = gfs1_writei(dip, (char *)buf +
sdp->sd_hash_bsize,
- block * sdp->bsize, sdp->bsize);
+ block * sdp->sd_bsize, sdp->sd_bsize);
else
count = gfs2_writei(dip, (char *)buf +
sdp->sd_hash_bsize,
- block * sdp->bsize, sdp->bsize);
- if (count != sdp->bsize) {
+ block * sdp->sd_bsize, sdp->sd_bsize);
+ if (count != sdp->sd_bsize) {
fprintf(stderr, "dir_double_exhash (2)\n");
exit(1);
}
@@ -1278,7 +1278,7 @@ static void dir_make_exhash(struct gfs2_inode *dip)
for (x = sdp->sd_hash_ptrs; x--; lp++)
*lp = cpu_to_be64(bn);
- dip->i_size = sdp->bsize / 2;
+ dip->i_size = sdp->sd_bsize / 2;
dip->i_blocks++;
dip->i_flags |= GFS2_DIF_EXHASH;
dip->i_payload_format = 0;
@@ -1379,7 +1379,7 @@ static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, st
p += len;
hash = gfs2_disk_hash("..", 2);
- len = sdp->bsize - (p - bh->b_data);
+ len = sdp->sd_bsize - (p - bh->b_data);
de.de_inum.no_formal_ino = cpu_to_be64(parent->no_formal_ino);
de.de_inum.no_addr = cpu_to_be64(parent->no_addr);
de.de_hash = cpu_to_be32(hash);
@@ -1392,7 +1392,7 @@ static int __init_dinode(struct gfs2_sbd *sdp, struct gfs2_buffer_head **bhp, st
*p = '.';
di->di_nlink = cpu_to_be32(2);
- di->di_size = cpu_to_be64(sdp->bsize - sizeof(struct gfs2_dinode));
+ di->di_size = cpu_to_be64(sdp->sd_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);
@@ -1430,7 +1430,7 @@ 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_size + sdp->bsize - 1) / sdp->bsize;
+ uint64_t dblocks = (ip->i_size + sdp->sd_bsize - 1) / sdp->sd_bsize;
uint64_t ptr0 = ip->i_addr + 1;
unsigned ptrs = 1;
struct gfs2_meta_header mh = {
@@ -1464,7 +1464,7 @@ int lgfs2_write_filemeta(struct gfs2_inode *ip)
start += sizeof(struct gfs2_meta_header);
gfs2_meta_header_out(&mh, bh->b_data);
}
- lgfs2_fill_indir(start, bh->b_data + sdp->bsize, ptr0, ptrs, &p);
+ lgfs2_fill_indir(start, bh->b_data + sdp->sd_bsize, ptr0, ptrs, &p);
if (bwrite(bh)) {
free(bh);
return 1;
@@ -1944,7 +1944,7 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
b_altlist);
for (ptr = (uint64_t *)(bh->b_data + head_size);
- (char *)ptr < (bh->b_data + sdp->bsize); ptr++) {
+ (char *)ptr < (bh->b_data + sdp->sd_bsize); ptr++) {
if (!*ptr)
continue;
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index d1b54a92..4cdf26e5 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -93,7 +93,7 @@ void gfs1_block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
return;
}
- bsize = (fs_is_jdata(ip)) ? sdp->sd_jbsize : sdp->bsize;
+ bsize = (fs_is_jdata(ip)) ? sdp->sd_jbsize : sdp->sd_bsize;
height = calc_tree_height(ip, (lblock + 1) * bsize);
if (ip->i_height < height) {
@@ -180,15 +180,15 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
return 0;
if (!ip->i_height && /* stuffed */
- ((start + size) > (sdp->bsize - sizeof(struct gfs_dinode))))
+ ((start + size) > (sdp->sd_bsize - sizeof(struct gfs_dinode))))
unstuff_dinode(ip);
if (journaled) {
lblock = offset / sdp->sd_jbsize;
offset %= sdp->sd_jbsize;
} else {
- lblock = offset >> sdp->sd_sb.sb_bsize_shift;
- offset &= sdp->bsize - 1;
+ lblock = offset >> sdp->sd_bsize_shift;
+ offset &= sdp->sd_bsize - 1;
}
if (!ip->i_height) /* stuffed */
@@ -198,8 +198,8 @@ int gfs1_writei(struct gfs2_inode *ip, char *buf, uint64_t offset,
while (copied < size) {
amount = size - copied;
- if (amount > sdp->bsize - offset)
- amount = sdp->bsize - offset;
+ if (amount > sdp->sd_bsize - offset)
+ amount = sdp->sd_bsize - offset;
if (!extlen){
new = 1;
@@ -297,7 +297,7 @@ struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr)
bh = bget(sdp, di_addr);
if (bh == NULL)
return NULL;
- if (pread(sdp->device_fd, bh->b_data, sdp->bsize, di_addr * sdp->bsize) != sdp->bsize) {
+ if (pread(sdp->device_fd, bh->b_data, sdp->sd_bsize, di_addr * sdp->sd_bsize) != sdp->sd_bsize) {
brelse(bh);
return NULL;
}
diff --git a/gfs2/libgfs2/gfs2l.c b/gfs2/libgfs2/gfs2l.c
index e582a193..2872d70e 100644
--- a/gfs2/libgfs2/gfs2l.c
+++ b/gfs2/libgfs2/gfs2l.c
@@ -111,7 +111,7 @@ static int openfs(const char *path, struct gfs2_sbd *sdp)
}
memset(sdp, 0, sizeof(*sdp));
- sdp->bsize = GFS2_BASIC_BLOCK;
+ sdp->sd_bsize = GFS2_BASIC_BLOCK;
sdp->device_fd = fd;
ret = compute_constants(sdp);
if (ret != 0) {
@@ -131,7 +131,7 @@ static int openfs(const char *path, struct gfs2_sbd *sdp)
return 1;
}
- sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.no_addr);
gfs2_lookupi(sdp->master_dir, "rindex", 6, &sdp->md.riinode);
sdp->fssize = sdp->device.length;
if (sdp->md.riinode) {
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index 3387df57..3633c7a7 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -158,7 +158,7 @@ static uint64_t ast_lookup_path(char *path, struct gfs2_sbd *sbd)
uint64_t bn = 0;
segment = strtok_r(path, "/", &c);
- ip = lgfs2_inode_read(sbd, sbd->sd_sb.sb_root_dir.no_addr);
+ ip = lgfs2_inode_read(sbd, sbd->sd_root_dir.no_addr);
while (ip != NULL) {
if (segment == NULL) { // No more segments
@@ -215,10 +215,10 @@ static uint64_t ast_lookup_id(const char *id, struct gfs2_sbd *sbd)
bn = LGFS2_SB_ADDR(sbd);
break;
case ID_MASTER:
- bn = sbd->sd_sb.sb_master_dir.no_addr;
+ bn = sbd->sd_meta_dir.no_addr;
break;
case ID_ROOT:
- bn = sbd->sd_sb.sb_root_dir.no_addr;
+ bn = sbd->sd_root_dir.no_addr;
break;
case ID_RINDEX:
bn = sbd->md.riinode->i_addr;
@@ -438,7 +438,7 @@ static struct lgfs2_lang_result *ast_interp_get(struct lgfs2_lang_state *state,
free(result);
return NULL;
}
- result->lr_buf = lang_read_block(sbd->device_fd, sbd->bsize, result->lr_blocknr);
+ result->lr_buf = lang_read_block(sbd->device_fd, sbd->sd_bsize, result->lr_blocknr);
if (result->lr_buf == NULL) {
free(result);
return NULL;
@@ -539,7 +539,7 @@ static struct lgfs2_lang_result *ast_interp_set(struct lgfs2_lang_state *state,
result->lr_blocknr = ast_lookup_block(lookup, sbd);
if (result->lr_blocknr == 0)
goto out_err;
- result->lr_buf = lang_read_block(sbd->device_fd, sbd->bsize, result->lr_blocknr);
+ result->lr_buf = lang_read_block(sbd->device_fd, sbd->sd_bsize, result->lr_blocknr);
if (result->lr_buf == NULL)
goto out_err;
@@ -580,7 +580,7 @@ static struct lgfs2_lang_result *ast_interp_set(struct lgfs2_lang_state *state,
}
}
- ret = lang_write_result(sbd->device_fd, sbd->bsize, result);
+ ret = lang_write_result(sbd->device_fd, sbd->sd_bsize, result);
if (ret != 0)
goto out_err;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 91f2dcf6..09d25ae0 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -307,12 +307,25 @@ struct master_dir
#define LGFS2_SB_ADDR(sdp) (GFS2_SB_ADDR >> (sdp)->sd_fsb2bb_shift)
struct gfs2_sbd {
- struct gfs2_sb sd_sb; /* a copy of the ondisk structure */
-
- unsigned int bsize; /* The block size of the FS (in bytes) */
- unsigned int jsize; /* Size of journals (in MB) */
- unsigned int rgsize; /* Size of resource groups (in MB) */
- unsigned int qcsize; /* Size of quota change files (in MB) */
+ /* CPU-endian counterparts to the on-disk superblock fields */
+ uint32_t sd_bsize;
+ uint32_t sd_fs_format;
+ uint32_t sd_multihost_format;
+ uint32_t sd_flags; /* gfs1 */
+ struct {
+ uint64_t no_formal_ino;
+ uint64_t no_addr;
+ } sd_meta_dir,
+ sd_root_dir,
+ sd_rindex_di, /* gfs1 */
+ sd_jindex_di, /* gfs1 */
+ sd_quota_di, /* gfs1 */
+ sd_license_di; /* gfs1 */
+ uint32_t sd_bsize_shift;
+ uint32_t sd_seg_size;
+ char sd_lockproto[GFS2_LOCKNAME_LEN];
+ char sd_locktable[GFS2_LOCKNAME_LEN];
+ uint8_t sd_uuid[16];
/* Constants */
@@ -331,7 +344,9 @@ struct gfs2_sbd {
uint64_t sd_heightsize[GFS2_MAX_META_HEIGHT];
uint64_t sd_jheightsize[GFS2_MAX_META_HEIGHT];
- /* Not specified on the command line, but... */
+ unsigned int jsize; /* Size of journals (in MB) */
+ unsigned int rgsize; /* Size of resource groups (in MB) */
+ unsigned int qcsize; /* Size of quota change files (in MB) */
int64_t time;
@@ -736,8 +751,7 @@ static inline unsigned int rgrp_size(struct rgrp_tree *rgrp)
/* structures.c */
extern int build_master(struct gfs2_sbd *sdp);
-extern void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize, unsigned format);
-extern int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize);
+extern int lgfs2_sb_write(const struct gfs2_sbd *sdp, int fd);
extern int build_journal(struct gfs2_sbd *sdp, int j,
struct gfs2_inode *jindex);
extern int build_jindex(struct gfs2_sbd *sdp);
@@ -758,7 +772,7 @@ extern int build_statfs_change(struct gfs2_inode *per_node, unsigned int j);
extern int build_quota_change(struct gfs2_inode *per_node, unsigned int j);
/* super.c */
-extern int check_sb(struct gfs2_sb *sb);
+extern int check_sb(void *sbp);
extern int read_sb(struct gfs2_sbd *sdp);
extern int rindex_read(struct gfs2_sbd *sdp, uint64_t *rgcount, int *ok);
extern int write_sb(struct gfs2_sbd *sdp);
@@ -774,8 +788,8 @@ extern void gfs2_inum_in(struct gfs2_inum *no, char *buf);
extern void gfs2_inum_out(const struct gfs2_inum *no, char *buf);
extern void gfs2_meta_header_in(struct gfs2_meta_header *mh, const char *buf);
extern void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf);
-extern void gfs2_sb_in(struct gfs2_sb *sb, char *buf);
-extern void gfs2_sb_out(const struct gfs2_sb *sb, char *buf);
+extern void lgfs2_sb_in(struct gfs2_sbd *sdp, void *buf);
+extern void lgfs2_sb_out(const struct gfs2_sbd *sdp, void *buf);
extern void lgfs2_rindex_in(lgfs2_rgrp_t rg, void *buf);
extern void lgfs2_rindex_out(const lgfs2_rgrp_t rg, void *buf);
extern void lgfs2_rgrp_in(lgfs2_rgrp_t rg, void *buf);
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index 6dfd9afb..f2bab8ef 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -43,19 +43,19 @@ int compute_constants(struct gfs2_sbd *sdp)
sdp->md.next_inum = 1;
- sdp->sd_sb.sb_bsize_shift = ffs(sdp->bsize) - 1;
- sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift -
+ sdp->sd_bsize_shift = ffs(sdp->sd_bsize) - 1;
+ sdp->sd_fsb2bb_shift = sdp->sd_bsize_shift -
GFS2_BASIC_BLOCK_SHIFT;
sdp->sd_fsb2bb = 1 << sdp->sd_fsb2bb_shift;
- sdp->sd_diptrs = (sdp->bsize - sizeof(struct gfs2_dinode)) /
+ sdp->sd_diptrs = (sdp->sd_bsize - sizeof(struct gfs2_dinode)) /
sizeof(uint64_t);
- sdp->sd_inptrs = (sdp->bsize - sizeof(struct gfs2_meta_header)) /
+ sdp->sd_inptrs = (sdp->sd_bsize - sizeof(struct gfs2_meta_header)) /
sizeof(uint64_t);
- sdp->sd_jbsize = sdp->bsize - sizeof(struct gfs2_meta_header);
- sdp->sd_hash_bsize = sdp->bsize / 2;
- sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1;
+ sdp->sd_jbsize = sdp->sd_bsize - sizeof(struct gfs2_meta_header);
+ sdp->sd_hash_bsize = sdp->sd_bsize / 2;
+ sdp->sd_hash_bsize_shift = sdp->sd_bsize_shift - 1;
sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64_t);
- sdp->sd_blocks_per_bitmap = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header))
+ sdp->sd_blocks_per_bitmap = (sdp->sd_bsize - sizeof(struct gfs2_meta_header))
* GFS2_NBBY;
/* Compute maximum reservation required to add a entry to a directory */
@@ -73,11 +73,11 @@ int compute_constants(struct gfs2_sbd *sdp)
sdp->sd_max_dirres = hash_blocks + ind_blocks + leaf_blocks;
- if (compute_heightsize(sdp->bsize, sdp->sd_heightsize, &sdp->sd_max_height,
- sdp->bsize, sdp->sd_diptrs, sdp->sd_inptrs)) {
+ if (compute_heightsize(sdp->sd_bsize, sdp->sd_heightsize, &sdp->sd_max_height,
+ sdp->sd_bsize, sdp->sd_diptrs, sdp->sd_inptrs)) {
return -1;
}
- if (compute_heightsize(sdp->bsize, sdp->sd_jheightsize, &sdp->sd_max_jheight,
+ if (compute_heightsize(sdp->sd_bsize, sdp->sd_jheightsize, &sdp->sd_max_jheight,
sdp->sd_jbsize, sdp->sd_diptrs, sdp->sd_inptrs)) {
return -1;
}
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index f44b76ee..f7d7553f 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -117,54 +117,57 @@ void lgfs2_meta_header_print(void *mhp)
printbe32(mh, mh_format);
}
-void gfs2_sb_in(struct gfs2_sb *sb, char *buf)
+void lgfs2_sb_in(struct gfs2_sbd *sdp, void *buf)
{
- struct gfs2_sb *str = (struct gfs2_sb *)buf;
-
- gfs2_meta_header_in(&sb->sb_header, buf);
-
- CPIN_32(sb, str, sb_fs_format);
- CPIN_32(sb, str, sb_multihost_format);
- CPIN_32(sb, str, __pad0); /* gfs sb_flags */
-
- CPIN_32(sb, str, sb_bsize);
- CPIN_32(sb, str, sb_bsize_shift);
- CPIN_32(sb, str, __pad1); /* gfs sb_seg_size */
-
- gfs2_inum_in(&sb->sb_master_dir, (char *)&str->sb_master_dir);
- gfs2_inum_in(&sb->sb_root_dir, (char *)&str->sb_root_dir);
-
- CPIN_08(sb, str, sb_lockproto, GFS2_LOCKNAME_LEN);
- CPIN_08(sb, str, sb_locktable, GFS2_LOCKNAME_LEN);
- gfs2_inum_in(&sb->__pad2, (char *)&str->__pad2); /* gfs rindex */
- gfs2_inum_in(&sb->__pad3, (char *)&str->__pad3); /* gfs quota */
- gfs2_inum_in(&sb->__pad4, (char *)&str->__pad4); /* gfs license */
- CPIN_08(sb, str, sb_uuid, sizeof(sb->sb_uuid));
+ struct gfs2_sb *sb = buf;
+
+ sdp->sd_fs_format = be32_to_cpu(sb->sb_fs_format);
+ sdp->sd_multihost_format = be32_to_cpu(sb->sb_multihost_format);
+ sdp->sd_flags = be32_to_cpu(sb->__pad0);
+ sdp->sd_bsize = be32_to_cpu(sb->sb_bsize);
+ sdp->sd_bsize_shift = be32_to_cpu(sb->sb_bsize_shift);
+ sdp->sd_seg_size = be32_to_cpu(sb->__pad1);
+ sdp->sd_meta_dir.no_formal_ino = be64_to_cpu(sb->sb_master_dir.no_formal_ino);
+ sdp->sd_meta_dir.no_addr = be64_to_cpu(sb->sb_master_dir.no_addr);
+ sdp->sd_root_dir.no_formal_ino = be64_to_cpu(sb->sb_root_dir.no_formal_ino);
+ sdp->sd_root_dir.no_addr = be64_to_cpu(sb->sb_root_dir.no_addr);
+ memcpy(sdp->sd_lockproto, sb->sb_lockproto, GFS2_LOCKNAME_LEN);
+ memcpy(sdp->sd_locktable, sb->sb_locktable, GFS2_LOCKNAME_LEN);
+ sdp->sd_rindex_di.no_formal_ino = be64_to_cpu(sb->__pad2.no_formal_ino);
+ sdp->sd_rindex_di.no_addr = be64_to_cpu(sb->__pad2.no_addr);
+ sdp->sd_quota_di.no_formal_ino = be64_to_cpu(sb->__pad3.no_formal_ino);
+ sdp->sd_quota_di.no_addr = be64_to_cpu(sb->__pad3.no_addr);
+ sdp->sd_license_di.no_formal_ino = be64_to_cpu(sb->__pad4.no_formal_ino);
+ sdp->sd_license_di.no_addr = be64_to_cpu(sb->__pad4.no_addr);
+ memcpy(sdp->sd_uuid, sb->sb_uuid, sizeof(sdp->sd_uuid));
}
-void gfs2_sb_out(const struct gfs2_sb *sb, char *buf)
+void lgfs2_sb_out(const struct gfs2_sbd *sdp, void *buf)
{
- struct gfs2_sb *str = (struct gfs2_sb *)buf;
-
- gfs2_meta_header_out(&sb->sb_header, buf);
-
- CPOUT_32(sb, str, sb_fs_format);
- CPOUT_32(sb, str, sb_multihost_format);
- CPOUT_32(sb, str, __pad0); /* gfs sb_flags */
-
- CPOUT_32(sb, str, sb_bsize);
- CPOUT_32(sb, str, sb_bsize_shift);
- CPOUT_32(sb, str, __pad1); /* gfs sb_seg_size */
-
- gfs2_inum_out(&sb->sb_master_dir, (char *)&str->sb_master_dir);
- gfs2_inum_out(&sb->sb_root_dir, (char *)&str->sb_root_dir);
-
- CPOUT_08(sb, str, sb_lockproto, GFS2_LOCKNAME_LEN);
- CPOUT_08(sb, str, sb_locktable, GFS2_LOCKNAME_LEN);
- gfs2_inum_out(&sb->__pad2, (char *)&str->__pad2); /* gfs rindex */
- gfs2_inum_out(&sb->__pad3, (char *)&str->__pad3); /* gfs quota */
- gfs2_inum_out(&sb->__pad4, (char *)&str->__pad4); /* gfs license */
- memcpy(str->sb_uuid, sb->sb_uuid, 16);
+ struct gfs2_sb *sb = buf;
+
+ sb->sb_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ sb->sb_header.mh_type = cpu_to_be32(GFS2_METATYPE_SB);
+ sb->sb_header.mh_format = cpu_to_be32(GFS2_FORMAT_SB);
+ sb->sb_fs_format = cpu_to_be32(sdp->sd_fs_format);
+ sb->sb_multihost_format = cpu_to_be32(sdp->sd_multihost_format);
+ sb->__pad0 = cpu_to_be32(sdp->sd_flags);
+ sb->sb_bsize = cpu_to_be32(sdp->sd_bsize);
+ sb->sb_bsize_shift = cpu_to_be32(sdp->sd_bsize_shift);
+ sb->__pad1 = cpu_to_be32(sdp->sd_seg_size);
+ sb->sb_master_dir.no_formal_ino = cpu_to_be64(sdp->sd_meta_dir.no_formal_ino);
+ sb->sb_master_dir.no_addr = cpu_to_be64(sdp->sd_meta_dir.no_addr);
+ sb->sb_root_dir.no_formal_ino = cpu_to_be64(sdp->sd_root_dir.no_formal_ino);
+ sb->sb_root_dir.no_addr = cpu_to_be64(sdp->sd_root_dir.no_addr);
+ memcpy(sb->sb_lockproto, sdp->sd_lockproto, GFS2_LOCKNAME_LEN);
+ memcpy(sb->sb_locktable, sdp->sd_locktable, GFS2_LOCKNAME_LEN);
+ sb->__pad2.no_formal_ino = cpu_to_be64(sdp->sd_rindex_di.no_formal_ino);
+ sb->__pad2.no_addr = cpu_to_be64(sdp->sd_rindex_di.no_addr);
+ sb->__pad3.no_formal_ino = cpu_to_be64(sdp->sd_quota_di.no_formal_ino);
+ sb->__pad3.no_addr = cpu_to_be64(sdp->sd_quota_di.no_addr);
+ sb->__pad4.no_formal_ino = cpu_to_be64(sdp->sd_license_di.no_formal_ino);
+ sb->__pad4.no_addr = cpu_to_be64(sdp->sd_license_di.no_addr);
+ memcpy(sb->sb_uuid, sdp->sd_uuid, 16);
}
void lgfs2_sb_print(void *sbp)
diff --git a/gfs2/libgfs2/recovery.c b/gfs2/libgfs2/recovery.c
index 7c445f15..9234a867 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_size / ip->i_sbd->sd_sb.sb_bsize;
+ uint32_t jd_blocks = ip->i_size / ip->i_sbd->sd_bsize;
if (++*blk == jd_blocks)
*blk = 0;
@@ -85,7 +85,7 @@ int lgfs2_get_log_header(struct gfs2_inode *ip, unsigned int blk,
tmp->lh_hash = 0;
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);
+ crc = lgfs2_log_header_crc(bh->b_data, ip->i_sbd->sd_bsize);
log_header_in(&lh, bh->b_data);
brelse(bh);
lh_crc = lh.lh_crc;
@@ -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_size / ip->i_sbd->sd_sb.sb_bsize;
+ uint32_t jd_blocks = ip->i_size / ip->i_sbd->sd_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_size / ip->i_sbd->sd_sb.sb_bsize;
+ uint32_t jd_blocks = ip->i_size / ip->i_sbd->sd_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_size / ip->i_sbd->sd_sb.sb_bsize;
+ uint32_t jd_blocks = ip->i_size / ip->i_sbd->sd_bsize;
int error;
blk_1 = 0;
@@ -245,7 +245,7 @@ int lgfs2_clean_journal(struct gfs2_inode *ip, struct lgfs2_log_header *head)
return -EIO;
bh = bread(ip->i_sbd, dblock);
- memset(bh->b_data, 0, ip->i_sbd->bsize);
+ memset(bh->b_data, 0, ip->i_sbd->sd_bsize);
lh = (struct gfs2_log_header *)bh->b_data;
memset(lh, 0, sizeof(struct gfs2_log_header));
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index 96789ff4..454f6e60 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -109,14 +109,14 @@ struct rgrp_tree *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, uint64_t blk)
int lgfs2_rgrp_bitbuf_alloc(lgfs2_rgrp_t rg)
{
struct gfs2_sbd *sdp = rg->rgrps->sdp;
- size_t len = rg->rt_length * sdp->bsize;
- unsigned long io_align = sdp->bsize;
+ size_t len = rg->rt_length * sdp->sd_bsize;
+ unsigned long io_align = sdp->sd_bsize;
unsigned i;
char *bufs;
if (rg->rgrps->align > 0) {
- len = ROUND_UP(len, rg->rgrps->align * sdp->bsize);
- io_align = rg->rgrps->align_off * sdp->bsize;
+ len = ROUND_UP(len, rg->rgrps->align * sdp->sd_bsize);
+ io_align = rg->rgrps->align_off * sdp->sd_bsize;
}
if (posix_memalign((void **)&bufs, io_align, len) != 0) {
errno = ENOMEM;
@@ -125,7 +125,7 @@ int lgfs2_rgrp_bitbuf_alloc(lgfs2_rgrp_t rg)
memset(bufs, 0, len);
for (i = 0; i < rg->rt_length; i++) {
- rg->bits[i].bi_data = bufs + (i * sdp->bsize);
+ rg->bits[i].bi_data = bufs + (i * sdp->sd_bsize);
rg->bits[i].bi_modified = 0;
}
return 0;
@@ -189,8 +189,8 @@ void lgfs2_rgrp_crc_set(char *buf)
*/
uint64_t gfs2_rgrp_read(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
{
- unsigned length = rgd->rt_length * sdp->bsize;
- off_t offset = rgd->rt_addr * sdp->bsize;
+ unsigned length = rgd->rt_length * sdp->sd_bsize;
+ off_t offset = rgd->rt_addr * sdp->sd_bsize;
char *buf;
if (length == 0 || gfs2_check_range(sdp, rgd->rt_addr))
@@ -208,7 +208,7 @@ uint64_t gfs2_rgrp_read(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
for (unsigned i = 0; i < rgd->rt_length; i++) {
int mtype = (i ? GFS2_METATYPE_RB : GFS2_METATYPE_RG);
- rgd->bits[i].bi_data = buf + (i * sdp->bsize);
+ rgd->bits[i].bi_data = buf + (i * sdp->sd_bsize);
if (gfs2_check_meta(rgd->bits[i].bi_data, mtype)) {
free(buf);
rgd->bits[0].bi_data = NULL;
@@ -232,14 +232,14 @@ void gfs2_rgrp_relse(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
if (rgd->bits == NULL)
return;
for (unsigned i = 0; i < rgd->rt_length; i++) {
- off_t offset = sdp->bsize * (rgd->rt_addr + i);
+ off_t offset = sdp->sd_bsize * (rgd->rt_addr + i);
ssize_t ret;
if (rgd->bits[i].bi_data == NULL || !rgd->bits[i].bi_modified)
continue;
- ret = pwrite(sdp->device_fd, rgd->bits[i].bi_data, sdp->bsize, offset);
- if (ret != sdp->bsize) {
+ ret = pwrite(sdp->device_fd, rgd->bits[i].bi_data, sdp->sd_bsize, offset);
+ if (ret != sdp->sd_bsize) {
fprintf(stderr, "Failed to write modified resource group at block %"PRIu64": %s\n",
rgd->rt_addr, strerror(errno));
}
@@ -344,8 +344,8 @@ uint32_t lgfs2_rgrp_align_len(const lgfs2_rgrps_t rgs, uint32_t len)
*/
uint32_t lgfs2_rgrps_plan(const lgfs2_rgrps_t rgs, uint64_t space, uint32_t tgtsize)
{
- uint32_t maxlen = (GFS2_MAX_RGSIZE << 20) / rgs->sdp->bsize;
- uint32_t minlen = (GFS2_MIN_RGSIZE << 20) / rgs->sdp->bsize;
+ uint32_t maxlen = (GFS2_MAX_RGSIZE << 20) / rgs->sdp->sd_bsize;
+ uint32_t minlen = (GFS2_MIN_RGSIZE << 20) / rgs->sdp->sd_bsize;
struct rg_spec *spec = rgs->plan->rg_specs;
/* Apps should already have checked that the rg size is <=
@@ -579,7 +579,7 @@ uint64_t lgfs2_rindex_entry_new(lgfs2_rgrps_t rgs, struct gfs2_rindex *ri, uint6
if (addr + len > rgs->sdp->device.length)
return 0;
- ri_length = rgblocks2bitblocks(rgs->sdp->bsize, len, &ri_data);
+ ri_length = rgblocks2bitblocks(rgs->sdp->sd_bsize, len, &ri_data);
ri->ri_addr = cpu_to_be64(addr);
ri->ri_length = cpu_to_be32(ri_length);
ri->ri_data = cpu_to_be32(ri_data);
@@ -654,7 +654,7 @@ lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry, ui
rg->rt_dinodes = 0;
rg->rt_skip = rg_skip;
rg->rt_igeneration = 0;
- compute_bitmaps(rg, rgs->sdp->bsize);
+ compute_bitmaps(rg, rgs->sdp->sd_bsize);
rg->rgrps = rgs;
return rg;
}
@@ -685,11 +685,11 @@ int lgfs2_rgrp_write(int fd, const lgfs2_rgrp_t rg)
mh->mh_format = cpu_to_be32(GFS2_FORMAT_RB);
}
- len = sdp->bsize * rg->rt_length;
+ len = sdp->sd_bsize * rg->rt_length;
if (rg->rgrps->align > 0)
- len = ROUND_UP(len, rg->rgrps->align * sdp->bsize);
+ len = ROUND_UP(len, rg->rgrps->align * sdp->sd_bsize);
- ret = pwrite(fd, rg->bits[0].bi_data, len, rg->rt_addr * sdp->bsize);
+ ret = pwrite(fd, rg->bits[0].bi_data, len, rg->rt_addr * sdp->sd_bsize);
if (freebufs)
lgfs2_rgrp_bitbuf_free(rg);
@@ -891,7 +891,7 @@ static uint32_t lgfs2_free_extlen(const struct lgfs2_rbm *rrbm, uint32_t len)
while (len > 3) {
bi = rbm_bi(&rbm);
start = (uint8_t *)bi->bi_data;
- end = start + sdp->bsize;
+ end = start + sdp->sd_bsize;
start += bi->bi_offset;
start += (rbm.offset / GFS2_NBBY);
bytes = (len / GFS2_NBBY) < (end - start) ? (len / GFS2_NBBY):(end - start);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index e900a7df..0957e5ad 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -46,31 +46,15 @@ int build_master(struct gfs2_sbd *sdp)
return 0;
}
-/**
- * Initialise a gfs2_sb structure with sensible defaults.
- */
-void lgfs2_sb_init(struct gfs2_sb *sb, unsigned bsize, unsigned format)
-{
- memset(sb, 0, sizeof(struct gfs2_sb));
- sb->sb_header.mh_magic = GFS2_MAGIC;
- sb->sb_header.mh_type = GFS2_METATYPE_SB;
- sb->sb_header.mh_format = GFS2_FORMAT_SB;
- sb->sb_fs_format = format;
- sb->sb_multihost_format = GFS2_FORMAT_MULTI;
- sb->sb_bsize = bsize;
- sb->sb_bsize_shift = ffs(bsize) - 1;
- uuid_generate(sb->sb_uuid);
-}
-
-int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize)
+int lgfs2_sb_write(const struct gfs2_sbd *sdp, int fd)
{
int i, err = -1;
struct iovec *iov;
- const size_t sb_addr = GFS2_SB_ADDR * GFS2_BASIC_BLOCK / bsize;
+ const size_t sb_addr = GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sdp->sd_bsize;
const size_t len = sb_addr + 1;
/* We only need 2 blocks: one for zeroing and a second for the superblock */
- char *buf = calloc(2, bsize);
+ char *buf = calloc(2, sdp->sd_bsize);
if (buf == NULL)
return -1;
@@ -80,13 +64,13 @@ int lgfs2_sb_write(const struct gfs2_sb *sb, int fd, const unsigned bsize)
for (i = 0; i < len; i++) {
iov[i].iov_base = buf;
- iov[i].iov_len = bsize;
+ iov[i].iov_len = sdp->sd_bsize;
}
- gfs2_sb_out(sb, buf + bsize);
- iov[sb_addr].iov_base = buf + bsize;
+ lgfs2_sb_out(sdp, buf + sdp->sd_bsize);
+ iov[sb_addr].iov_base = buf + sdp->sd_bsize;
- if (pwritev(fd, iov, len, 0) < (len * bsize))
+ if (pwritev(fd, iov, len, 0) < (len * sdp->sd_bsize))
goto out_iov;
err = 0;
@@ -125,14 +109,14 @@ 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_size + sdp->bsize - 1) / sdp->bsize;
+ unsigned blocks = (ip->i_size + sdp->sd_bsize - 1) / sdp->sd_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;
char *buf;
- buf = calloc(1, sdp->bsize);
+ buf = calloc(1, sdp->sd_bsize);
if (buf == NULL)
return -1;
@@ -152,10 +136,10 @@ int lgfs2_write_journal_data(struct gfs2_inode *ip)
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);
+ hash = lgfs2_log_header_crc(buf, sdp->sd_bsize);
lh->lh_crc = cpu_to_be32(hash);
- if (pwrite(sdp->device_fd, buf, sdp->bsize, jblk * sdp->bsize) != sdp->bsize) {
+ if (pwrite(sdp->device_fd, buf, sdp->sd_bsize, jblk * sdp->sd_bsize) != sdp->sd_bsize) {
free(buf);
return -1;
}
@@ -186,9 +170,9 @@ static struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn
return NULL;
if (!prealloc && new &&
- ip->i_size < (lbn + 1) << sdp->sd_sb.sb_bsize_shift) {
+ ip->i_size < (lbn + 1) << sdp->sd_bsize_shift) {
bmodified(ip->i_bh);
- ip->i_size = (lbn + 1) << sdp->sd_sb.sb_bsize_shift;
+ ip->i_size = (lbn + 1) << sdp->sd_bsize_shift;
}
if (dbn == ip->i_addr)
return ip->i_bh;
@@ -259,8 +243,8 @@ int build_journal(struct gfs2_sbd *sdp, int j, struct gfs2_inode *jindex)
if (sdp->md.journal[j] == NULL) {
return errno;
}
- ret = write_journal(sdp->md.journal[j], sdp->bsize,
- sdp->jsize << 20 >> sdp->sd_sb.sb_bsize_shift);
+ ret = write_journal(sdp->md.journal[j], sdp->sd_bsize,
+ sdp->jsize << 20 >> sdp->sd_bsize_shift);
return ret;
}
@@ -387,7 +371,7 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
struct gfs2_meta_header mh;
char name[256];
struct gfs2_inode *ip;
- unsigned int blocks = sdp->qcsize << (20 - sdp->sd_sb.sb_bsize_shift);
+ unsigned int blocks = sdp->qcsize << (20 - sdp->sd_bsize_shift);
unsigned int x;
unsigned int hgt;
struct gfs2_buffer_head *bh;
@@ -403,7 +387,7 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
return errno;
}
- hgt = calc_tree_height(ip, (blocks + 1) * sdp->bsize);
+ hgt = calc_tree_height(ip, (blocks + 1) * sdp->sd_bsize);
build_height(ip, hgt);
for (x = 0; x < blocks; x++) {
@@ -411,7 +395,7 @@ int build_quota_change(struct gfs2_inode *per_node, unsigned int j)
if (!bh)
return -1;
- memset(bh->b_data, 0, sdp->bsize);
+ memset(bh->b_data, 0, sdp->sd_bsize);
gfs2_meta_header_out(&mh, bh->b_data);
bmodified(bh);
brelse(bh);
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index f304b4df..cd2a2ecf 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -22,22 +22,24 @@
*
* Returns: -1 on failure, 1 if this is gfs (gfs1), 2 if this is gfs2
*/
-int check_sb(struct gfs2_sb *sb)
+int check_sb(void *sbp)
{
- if (sb->sb_header.mh_magic != GFS2_MAGIC ||
- sb->sb_header.mh_type != GFS2_METATYPE_SB) {
+ struct gfs2_sb *sb = sbp;
+
+ if (be32_to_cpu(sb->sb_header.mh_magic) != GFS2_MAGIC ||
+ be32_to_cpu(sb->sb_header.mh_type) != GFS2_METATYPE_SB) {
errno = EIO;
return -1;
}
/* Check for gfs1 */
- if (sb->sb_fs_format == GFS_FORMAT_FS &&
- sb->sb_header.mh_format == GFS_FORMAT_SB &&
- sb->sb_multihost_format == GFS_FORMAT_MULTI) {
+ if (be32_to_cpu(sb->sb_fs_format) == GFS_FORMAT_FS &&
+ be32_to_cpu(sb->sb_header.mh_format) == GFS_FORMAT_SB &&
+ be32_to_cpu(sb->sb_multihost_format) == GFS_FORMAT_MULTI) {
return 1;
}
/* It's gfs2. Check format number is in a sensible range. */
- if (sb->sb_fs_format < LGFS2_FS_FORMAT_MIN ||
- sb->sb_fs_format > 1899) {
+ if (be32_to_cpu(sb->sb_fs_format) < LGFS2_FS_FORMAT_MIN ||
+ be32_to_cpu(sb->sb_fs_format) > 1899) {
errno = EINVAL;
return -1;
}
@@ -64,40 +66,40 @@ int read_sb(struct gfs2_sbd *sdp)
int ret;
bh = bread(sdp, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift);
- gfs2_sb_in(&sdp->sd_sb, bh->b_data);
- brelse(bh);
- ret = check_sb(&sdp->sd_sb);
+ ret = check_sb(bh->b_data);
if (ret < 0)
return ret;
if (ret == 1)
sdp->gfs1 = 1;
- sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT;
- sdp->bsize = sdp->sd_sb.sb_bsize;
- if (sdp->bsize < 512 || sdp->bsize != (sdp->bsize & -sdp->bsize)) {
+
+ lgfs2_sb_in(sdp, bh->b_data);
+ brelse(bh);
+ sdp->sd_fsb2bb_shift = sdp->sd_bsize_shift - GFS2_BASIC_BLOCK_SHIFT;
+ if (sdp->sd_bsize < 512 || sdp->sd_bsize != (sdp->sd_bsize & -sdp->sd_bsize)) {
return -1;
}
if (sdp->gfs1) {
- sdp->sd_diptrs = (sdp->sd_sb.sb_bsize -
+ sdp->sd_diptrs = (sdp->sd_bsize -
sizeof(struct gfs_dinode)) /
sizeof(uint64_t);
- sdp->sd_inptrs = (sdp->sd_sb.sb_bsize -
+ sdp->sd_inptrs = (sdp->sd_bsize -
sizeof(struct gfs_indirect)) /
sizeof(uint64_t);
} else {
- sdp->sd_diptrs = (sdp->sd_sb.sb_bsize -
+ sdp->sd_diptrs = (sdp->sd_bsize -
sizeof(struct gfs2_dinode)) /
sizeof(uint64_t);
- sdp->sd_inptrs = (sdp->sd_sb.sb_bsize -
+ sdp->sd_inptrs = (sdp->sd_bsize -
sizeof(struct gfs2_meta_header)) /
sizeof(uint64_t);
}
- sdp->sd_jbsize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
- sdp->sd_hash_bsize = sdp->bsize / 2;
- sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1;
+ sdp->sd_jbsize = sdp->sd_bsize - sizeof(struct gfs2_meta_header);
+ sdp->sd_hash_bsize = sdp->sd_bsize / 2;
+ sdp->sd_hash_bsize_shift = sdp->sd_bsize_shift - 1;
sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64_t);
- sdp->sd_heightsize[0] = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
- sdp->sd_heightsize[1] = sdp->sd_sb.sb_bsize * sdp->sd_diptrs;
+ sdp->sd_heightsize[0] = sdp->sd_bsize - sizeof(struct gfs2_dinode);
+ sdp->sd_heightsize[1] = sdp->sd_bsize * sdp->sd_diptrs;
for (x = 2; x < GFS2_MAX_META_HEIGHT; x++){
space = sdp->sd_heightsize[x - 1] * sdp->sd_inptrs;
/* FIXME: Do we really need this first check?? */
@@ -111,7 +113,7 @@ int read_sb(struct gfs2_sbd *sdp)
return -1;
}
- sdp->sd_jheightsize[0] = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode);
+ sdp->sd_jheightsize[0] = sdp->sd_bsize - sizeof(struct gfs2_dinode);
sdp->sd_jheightsize[1] = sdp->sd_jbsize * sdp->sd_diptrs;
for (x = 2; ; x++){
space = sdp->sd_jheightsize[x - 1] * sdp->sd_inptrs;
@@ -125,8 +127,8 @@ int read_sb(struct gfs2_sbd *sdp)
errno = E2BIG;
return -1;
}
- sdp->fssize = lseek(sdp->device_fd, 0, SEEK_END) / sdp->sd_sb.sb_bsize;
- sdp->sd_blocks_per_bitmap = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header))
+ sdp->fssize = lseek(sdp->device_fd, 0, SEEK_END) / sdp->sd_bsize;
+ sdp->sd_blocks_per_bitmap = (sdp->sd_bsize - sizeof(struct gfs2_meta_header))
* GFS2_NBBY;
sdp->qcsize = GFS2_DEFAULT_QCSIZE;
@@ -153,7 +155,7 @@ static int rgd_seems_ok(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
/* A max rgrp, 2GB, divided into blocksize, divided by blocks/byte
represented in the bitmap, NBBY. Rough approximation only, due to
metadata headers. I'm doing the math this way to avoid overflow. */
- most_bitmaps_possible = (GFS2_MAX_RGSIZE * 1024 * 256) / sdp->bsize;
+ most_bitmaps_possible = (GFS2_MAX_RGSIZE * 1024 * 256) / sdp->sd_bsize;
if (rgd->rt_length > most_bitmaps_possible)
return 0;
@@ -247,7 +249,7 @@ int rindex_read(struct gfs2_sbd *sdp, uint64_t *rgcount, int *ok)
prev_rgd->length = rgrp_size(prev_rgd);
}
- if(gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, rgd))
+ if(gfs2_compute_bitstructs(sdp->sd_bsize, rgd))
*ok = 0;
(*rgcount)++;
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index deb9230d..8204d263 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -174,8 +174,8 @@ static lgfs2_rgrps_t rgrps_init(struct gfs2_sbd *sdp)
if ((min_io_sz > phy_sector_sz) &&
(opt_io_sz > phy_sector_sz) &&
(opt_io_sz % min_io_sz == 0)) {
- al_base = opt_io_sz / sdp->bsize;
- al_off = min_io_sz / sdp->bsize;
+ al_base = opt_io_sz / sdp->sd_bsize;
+ al_off = min_io_sz / sdp->sd_bsize;
}
}
@@ -208,7 +208,7 @@ static unsigned initialize_new_portion(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs)
unsigned rgcount = 0;
uint64_t rgaddr = fssize;
- discard_blocks(sdp->device_fd, rgaddr * sdp->bsize, fsgrowth * sdp->bsize);
+ discard_blocks(sdp->device_fd, rgaddr * sdp->sd_bsize, fsgrowth * sdp->sd_bsize);
/* Build the remaining resource groups */
while (1) {
int err = 0;
@@ -332,7 +332,7 @@ static void print_info(struct gfs2_sbd *sdp, char *device, char *mnt_path)
(unsigned long long)sdp->device.length,
(unsigned long long)sdp->device.length);
log_notice(_("The file system will grow by %lluMB.\n"),
- (unsigned long long)(fsgrowth * sdp->bsize) / MB);
+ (unsigned long long)(fsgrowth * sdp->sd_bsize) / MB);
}
static int open_rindex(char *metafs_path, int mode)
@@ -366,7 +366,7 @@ int main(int argc, char *argv[])
srandom(time(NULL) ^ getpid());
memset(sdp, 0, sizeof(struct gfs2_sbd));
- sdp->bsize = GFS2_DEFAULT_BSIZE;
+ sdp->sd_bsize = GFS2_DEFAULT_BSIZE;
sdp->rgsize = -1;
sdp->jsize = GFS2_DEFAULT_JSIZE;
sdp->qcsize = GFS2_DEFAULT_QCSIZE;
@@ -395,8 +395,8 @@ int main(int argc, char *argv[])
perror(mnt->mnt_fsname);
exit(EXIT_FAILURE);
}
- sdp->sd_sb.sb_bsize = GFS2_DEFAULT_BSIZE;
- sdp->bsize = sdp->sd_sb.sb_bsize;
+ sdp->sd_bsize = GFS2_DEFAULT_BSIZE;
+ sdp->sd_bsize = sdp->sd_bsize;
if (compute_constants(sdp)) {
log_crit("%s\n", _("Failed to compute file system constants"));
exit(EXIT_FAILURE);
@@ -421,7 +421,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
/* Get master dinode */
- sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.no_addr);
if (sdp->master_dir == NULL) {
perror(_("Could not read master directory"));
exit(EXIT_FAILURE);
@@ -457,7 +457,7 @@ int main(int argc, char *argv[])
goto out;
}
fsgrowth = (sdp->device.length - fssize);
- rgcount = lgfs2_rgrps_plan(rgs, fsgrowth, ((GFS2_MAX_RGSIZE << 20) / sdp->bsize));
+ rgcount = lgfs2_rgrps_plan(rgs, fsgrowth, ((GFS2_MAX_RGSIZE << 20) / sdp->sd_bsize));
if (rgcount == 0) {
log_err( _("The calculated resource group size is too small.\n"));
log_err( _("%s has not grown.\n"), argv[optind]);
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index 8e349c9c..66d9e293 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -350,9 +350,9 @@ close_fd:
static int add_qc(struct gfs2_sbd *sdp, struct jadd_opts *opts)
{
int fd, error = 0;
- char new_name[256], buf[sdp->bsize];
+ char new_name[256], buf[sdp->sd_bsize];
unsigned int blocks =
- sdp->qcsize << (20 - sdp->sd_sb.sb_bsize_shift);
+ sdp->qcsize << (20 - sdp->sd_bsize_shift);
unsigned int x;
struct gfs2_meta_header mh;
@@ -362,9 +362,9 @@ static int add_qc(struct gfs2_sbd *sdp, struct jadd_opts *opts)
if ((error = set_flags(fd, JA_FL_CLEAR, FS_JOURNAL_DATA_FL)))
goto close_fd;
- memset(buf, 0, sdp->bsize);
+ memset(buf, 0, sdp->sd_bsize);
for (x=0; x<blocks; x++) {
- if (write(fd, buf, sdp->bsize) != sdp->bsize) {
+ if (write(fd, buf, sdp->sd_bsize) != sdp->sd_bsize) {
perror("add_qc write");
error = -1;
goto close_fd;
@@ -383,7 +383,7 @@ static int add_qc(struct gfs2_sbd *sdp, struct jadd_opts *opts)
gfs2_meta_header_out(&mh, buf);
for (x=0; x<blocks; x++) {
- if (write(fd, buf, sdp->bsize) != sdp->bsize) {
+ if (write(fd, buf, sdp->sd_bsize) != sdp->sd_bsize) {
perror("add_qc write");
error = 1;
goto close_fd;
@@ -413,7 +413,7 @@ static int gather_info(struct gfs2_sbd *sdp, struct jadd_opts *opts)
return -1;
}
- sdp->bsize = statbuf.f_bsize;
+ sdp->sd_bsize = statbuf.f_bsize;
sdp->blks_total = statbuf.f_blocks;
sdp->blks_alloced = sdp->blks_total - statbuf.f_bfree;
@@ -518,12 +518,12 @@ static int add_j(struct gfs2_sbd *sdp, struct jadd_opts *opts)
{
int fd, error = 0;
char new_name[256], *buf;
- uint32_t x, blocks = sdp->jsize << (20 - sdp->sd_sb.sb_bsize_shift);
+ uint32_t x, blocks = sdp->jsize << (20 - sdp->sd_bsize_shift);
struct gfs2_log_header *lh;
uint64_t seq = RANDOM(blocks), addr = 0;
off_t off = 0;
- buf = calloc(1, sdp->bsize);
+ buf = calloc(1, sdp->sd_bsize);
if (buf == NULL)
return -1;
@@ -562,14 +562,14 @@ static int add_j(struct gfs2_sbd *sdp, struct jadd_opts *opts)
lh->lh_blkno = cpu_to_be32(x);
hash = lgfs2_log_header_hash(buf);
lh->lh_hash = cpu_to_be32(hash);
- if (!(blk_addr = find_block_address(fd, off, sdp->bsize))) {
+ if (!(blk_addr = find_block_address(fd, off, sdp->sd_bsize))) {
error = -1;
goto close_fd;
}
lh->lh_addr = cpu_to_be64(blk_addr);
- hash = lgfs2_log_header_crc(buf, sdp->bsize);
+ hash = lgfs2_log_header_crc(buf, sdp->sd_bsize);
lh->lh_crc = cpu_to_be32(hash);
- if (write(fd, buf, sdp->bsize) != sdp->bsize) {
+ if (write(fd, buf, sdp->sd_bsize) != sdp->sd_bsize) {
perror("add_j write");
error = -1;
goto close_fd;
@@ -579,7 +579,7 @@ static int add_j(struct gfs2_sbd *sdp, struct jadd_opts *opts)
if (++seq == blocks)
seq = 0;
- off += sdp->bsize;
+ off += sdp->sd_bsize;
}
error = fsync(fd);
@@ -610,8 +610,8 @@ static int check_fit(struct gfs2_sbd *sdp, struct jadd_opts *opts)
uint64_t blks_per_j, total_blks;
blks_per_j = 1 + 1 +
- lgfs2_space_for_data(sdp, sdp->bsize, sdp->qcsize << 20) +
- lgfs2_space_for_data(sdp, sdp->bsize, sdp->jsize << 20);
+ lgfs2_space_for_data(sdp, sdp->sd_bsize, sdp->qcsize << 20) +
+ lgfs2_space_for_data(sdp, sdp->sd_bsize, sdp->jsize << 20);
total_blks = opts->journals * blks_per_j;
if (total_blks > (sdp->blks_total - sdp->blks_alloced)) {
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 6374ebc7..bf9e0d6d 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -635,23 +635,23 @@ static int opts_check(struct mkfs_opts *opts)
return 0;
}
-static void print_results(struct gfs2_sb *sb, struct mkfs_opts *opts, uint64_t rgrps, uint64_t fssize)
+static void print_results(struct gfs2_sbd *sb, struct mkfs_opts *opts)
{
char readable_uuid[36+1];
- uuid_unparse(sb->sb_uuid, readable_uuid);
+ uuid_unparse(sb->sd_uuid, readable_uuid);
printf("%-27s%s\n", _("Device:"), opts->dev.path);
- printf("%-27s%u\n", _("Block size:"), sb->sb_bsize);
+ printf("%-27s%u\n", _("Block size:"), sb->sd_bsize);
printf("%-27s%.2f %s (%"PRIu64" %s)\n", _("Device size:"),
/* Translators: "GB" here means "gigabytes" */
(opts->dev.size / ((float)(1 << 30))), _("GB"),
- (opts->dev.size / sb->sb_bsize), _("blocks"));
+ (opts->dev.size / sb->sd_bsize), _("blocks"));
printf("%-27s%.2f %s (%"PRIu64" %s)\n", _("Filesystem size:"),
- (fssize / ((float)(1 << 30)) * sb->sb_bsize), _("GB"), fssize, _("blocks"));
+ (sb->fssize / ((float)(1 << 30)) * sb->sd_bsize), _("GB"), sb->fssize, _("blocks"));
printf("%-27s%u\n", _("Journals:"), opts->journals);
printf("%-27s%uMB\n", _("Journal size:"), opts->jsize);
- printf("%-27s%"PRIu64"\n", _("Resource groups:"), rgrps);
+ printf("%-27s%"PRIu64"\n", _("Resource groups:"), sb->rgrps);
printf("%-27s\"%s\"\n", _("Locking protocol:"), opts->lockproto);
printf("%-27s\"%s\"\n", _("Lock table:"), opts->locktable);
/* Translators: "UUID" = universally unique identifier. */
@@ -696,7 +696,7 @@ static int zero_gap(struct gfs2_sbd *sdp, uint64_t addr, size_t blocks)
perror(_("Failed to zero blocks\n"));
return 1;
}
- zerobuf = calloc(1, sdp->bsize);
+ zerobuf = calloc(1, sdp->sd_bsize);
if (zerobuf == NULL) {
perror(_("Failed to zero blocks\n"));
free(iov);
@@ -704,10 +704,10 @@ static int zero_gap(struct gfs2_sbd *sdp, uint64_t addr, size_t blocks)
}
for (i = 0; i < blocks; i++) {
iov[i].iov_base = zerobuf;
- iov[i].iov_len = sdp->bsize;
+ iov[i].iov_len = sdp->sd_bsize;
}
- wrote = pwritev(sdp->device_fd, iov, blocks, addr * sdp->bsize);
- if (wrote != blocks * sdp->bsize) {
+ wrote = pwritev(sdp->device_fd, iov, blocks, addr * sdp->sd_bsize);
+ if (wrote != blocks * sdp->sd_bsize) {
fprintf(stderr, _("Zeroing write failed at block %"PRIu64"\n"), addr);
free(zerobuf);
free(iov);
@@ -725,17 +725,17 @@ static lgfs2_rgrps_t rgs_init(struct mkfs_opts *opts, struct gfs2_sbd *sdp)
uint64_t al_off = 0;
if (opts->align && opts->got_sunit) {
- if ((opts->sunit % sdp->bsize) != 0) {
+ if ((opts->sunit % sdp->sd_bsize) != 0) {
fprintf(stderr, _("Stripe unit (%lu) must be a multiple of block size (%u)\n"),
- opts->sunit, sdp->bsize);
+ opts->sunit, sdp->sd_bsize);
return NULL;
} else if ((opts->swidth % opts->sunit) != 0) {
fprintf(stderr, _("Stripe width (%lu) must be a multiple of stripe unit (%lu)\n"),
opts->swidth, opts->sunit);
return NULL;
} else {
- al_base = opts->swidth / sdp->bsize;
- al_off = opts->sunit / sdp->bsize;
+ al_base = opts->swidth / sdp->sd_bsize;
+ al_off = opts->sunit / sdp->sd_bsize;
}
} else if (opts->align) {
if (opts->dev.optimal_io_size <= opts->dev.physical_sector_size ||
@@ -746,8 +746,8 @@ static lgfs2_rgrps_t rgs_init(struct mkfs_opts *opts, struct gfs2_sbd *sdp)
rgrp alignment */
opts->align = 0;
} else {
- al_base = opts->dev.optimal_io_size / sdp->bsize;
- al_off = opts->dev.minimum_io_size / sdp->bsize;
+ al_base = opts->dev.optimal_io_size / sdp->sd_bsize;
+ al_off = opts->dev.minimum_io_size / sdp->sd_bsize;
}
}
@@ -770,7 +770,7 @@ static lgfs2_rgrps_t rgs_init(struct mkfs_opts *opts, struct gfs2_sbd *sdp)
static int place_rgrp(struct gfs2_sbd *sdp, lgfs2_rgrp_t rg, int debug)
{
- uint64_t prev_end = (GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sdp->bsize) + 1;
+ uint64_t prev_end = (GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sdp->sd_bsize) + 1;
lgfs2_rgrp_t prev = lgfs2_rgrp_prev(rg);
struct gfs2_rindex ri;
uint64_t addr;
@@ -837,8 +837,8 @@ static int add_rgrp(lgfs2_rgrps_t rgs, uint64_t *addr, uint32_t len, lgfs2_rgrp_
static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_opts *opts, uint64_t *rgaddr)
{
struct gfs2_progress_bar progress;
- uint64_t jfsize = lgfs2_space_for_data(sdp, sdp->bsize, opts->jsize << 20);
- uint32_t rgsize = lgfs2_rgsize_for_data(jfsize, sdp->bsize);
+ uint64_t jfsize = lgfs2_space_for_data(sdp, sdp->sd_bsize, opts->jsize << 20);
+ uint32_t rgsize = lgfs2_rgsize_for_data(jfsize, sdp->sd_bsize);
unsigned j;
gfs2_progress_init(&progress, opts->journals, _("Adding journals: "), opts->quiet);
@@ -912,7 +912,7 @@ static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_o
static int place_rgrps(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, uint64_t *rgaddr, struct mkfs_opts *opts)
{
struct gfs2_progress_bar progress;
- uint32_t rgblks = ((opts->rgsize << 20) / sdp->bsize);
+ uint32_t rgblks = ((opts->rgsize << 20) / sdp->sd_bsize);
uint32_t rgnum;
int result;
@@ -983,19 +983,24 @@ static int sbd_init(struct gfs2_sbd *sdp, struct mkfs_opts *opts, unsigned bsize
sdp->jsize = opts->jsize;
sdp->md.journals = opts->journals;
sdp->device_fd = opts->dev.fd;
- sdp->bsize = sdp->sd_sb.sb_bsize = bsize;
+ sdp->sd_bsize = bsize;
+ sdp->sd_fs_format = opts->format;
+ sdp->sd_multihost_format = GFS2_FORMAT_MULTI;
+ sdp->sd_bsize = bsize;
+ sdp->sd_bsize_shift = ffs(bsize) - 1;
+ uuid_generate(sdp->sd_uuid);
if (compute_constants(sdp)) {
perror(_("Failed to compute file system constants"));
return -1;
}
- sdp->device.length = opts->dev.size / sdp->bsize;
+ sdp->device.length = opts->dev.size / sdp->sd_bsize;
if (opts->got_fssize) {
if (opts->fssize > sdp->device.length) {
fprintf(stderr, _("Specified size is bigger than the device."));
fprintf(stderr, "%s %.2f %s (%"PRIu64" %s)\n", _("Device size:"),
opts->dev.size / ((float)(1 << 30)), _("GB"),
- opts->dev.size / sdp->bsize, _("blocks"));
+ opts->dev.size / sdp->sd_bsize, _("blocks"));
return -1;
}
sdp->device.length = opts->fssize;
@@ -1004,20 +1009,20 @@ static int sbd_init(struct gfs2_sbd *sdp, struct mkfs_opts *opts, unsigned bsize
makes sense for the device size, or set a sensible default, if one
will fit. For user-provided journal sizes, limit it to half of the fs. */
if (!opts->got_jsize) {
- int default_jsize = default_journal_size(sdp->bsize, sdp->device.length / opts->journals);
+ int default_jsize = default_journal_size(sdp->sd_bsize, sdp->device.length / opts->journals);
unsigned jsize_mb;
if (default_jsize < 0) {
fprintf(stderr, _("gfs2 will not fit on this device.\n"));
return -1;
}
- jsize_mb = (default_jsize * sdp->bsize) >> 20;
+ jsize_mb = (default_jsize * sdp->sd_bsize) >> 20;
if (jsize_mb < GFS2_MIN_JSIZE)
opts->jsize = GFS2_MIN_JSIZE;
else
opts->jsize = jsize_mb;
- } else if ((((opts->jsize * opts->journals) << 20) / sdp->bsize) > (sdp->device.length / 2)) {
- unsigned max_jsize = (sdp->device.length / 2 * sdp->bsize / opts->journals) >> 20;
+ } else if ((((opts->jsize * opts->journals) << 20) / sdp->sd_bsize) > (sdp->device.length / 2)) {
+ unsigned max_jsize = (sdp->device.length / 2 * sdp->sd_bsize / opts->journals) >> 20;
fprintf(stderr, _("gfs2 will not fit on this device.\n"));
if (max_jsize >= GFS2_MIN_JSIZE)
@@ -1118,7 +1123,6 @@ static int open_dev(struct mkfs_dev *dev, int withprobe)
int main(int argc, char *argv[])
{
struct gfs2_sbd sbd;
- struct gfs2_sb sb;
struct mkfs_opts opts;
lgfs2_rgrps_t rgs;
uint64_t rgaddr;
@@ -1149,13 +1153,11 @@ int main(int argc, char *argv[])
if (S_ISREG(opts.dev.stat.st_mode)) {
opts.got_bsize = 1; /* Use default block size for regular files */
}
-
if (sbd_init(&sbd, &opts, bsize) != 0)
exit(-1);
- lgfs2_sb_init(&sb, bsize, opts.format);
if (opts.debug) {
printf(_("File system options:\n"));
- printf(" bsize = %u\n", sbd.bsize);
+ printf(" bsize = %u\n", sbd.sd_bsize);
printf(" qcsize = %u\n", sbd.qcsize);
printf(" jsize = %u\n", sbd.jsize);
printf(" journals = %u\n", sbd.md.journals);
@@ -1205,8 +1207,8 @@ int main(int argc, char *argv[])
fprintf(stderr, _("Error building '%s': %s\n"), "master", strerror(errno));
exit(EXIT_FAILURE);
}
- sb.sb_master_dir.no_addr = sbd.master_dir->i_addr;
- sb.sb_master_dir.no_formal_ino = sbd.master_dir->i_formal_ino;
+ sbd.sd_meta_dir.no_addr = sbd.master_dir->i_addr;
+ sbd.sd_meta_dir.no_formal_ino = sbd.master_dir->i_formal_ino;
error = lgfs2_build_jindex(sbd.master_dir, mkfs_journals, opts.journals);
if (error) {
@@ -1249,13 +1251,13 @@ int main(int argc, char *argv[])
printf("%s", _("Done\n"));
build_root(&sbd);
- sb.sb_root_dir.no_addr = sbd.md.rooti->i_addr;
- sb.sb_root_dir.no_formal_ino = sbd.md.rooti->i_formal_ino;
+ sbd.sd_root_dir.no_addr = sbd.md.rooti->i_addr;
+ sbd.sd_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);
- sb.sb_lockproto[GFS2_LOCKNAME_LEN - 1] = '\0';
- sb.sb_locktable[GFS2_LOCKNAME_LEN - 1] = '\0';
+ strncpy(sbd.sd_lockproto, opts.lockproto, GFS2_LOCKNAME_LEN - 1);
+ strncpy(sbd.sd_locktable, opts.locktable, GFS2_LOCKNAME_LEN - 1);
+ sbd.sd_lockproto[GFS2_LOCKNAME_LEN - 1] = '\0';
+ sbd.sd_locktable[GFS2_LOCKNAME_LEN - 1] = '\0';
do_init_inum(&sbd);
do_init_statfs(&sbd);
@@ -1272,7 +1274,7 @@ int main(int argc, char *argv[])
fflush(stdout);
}
- error = lgfs2_sb_write(&sb, opts.dev.fd, sbd.bsize);
+ error = lgfs2_sb_write(&sbd, opts.dev.fd);
if (error) {
perror(_("Failed to write superblock\n"));
exit(EXIT_FAILURE);
@@ -1291,7 +1293,7 @@ int main(int argc, char *argv[])
if (!opts.quiet) {
printf("%s", _("Done\n"));
- print_results(&sb, &opts, sbd.rgrps, sbd.fssize);
+ print_results(&sbd, &opts);
}
return 0;
}
diff --git a/tests/nukerg.c b/tests/nukerg.c
index 3bca919c..b5ddeb0b 100644
--- a/tests/nukerg.c
+++ b/tests/nukerg.c
@@ -192,7 +192,7 @@ static int nuke_rgs(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, unsigned *rgnums, s
lgfs2_rindex_out(rg, &ri);
for (j = 0; j < count; j++) {
uint64_t addr = be64_to_cpu(ri.ri_addr);
- off_t off = addr * sdp->bsize;
+ off_t off = addr * sdp->sd_bsize;
ssize_t bytes;
if (i != rgnums[j] && rgnums[j] != ALL_RGS)
@@ -278,8 +278,7 @@ static lgfs2_rgrps_t read_rindex(struct gfs2_sbd *sdp)
static int fill_super_block(struct gfs2_sbd *sdp)
{
- sdp->sd_sb.sb_bsize = GFS2_BASIC_BLOCK;
- sdp->bsize = sdp->sd_sb.sb_bsize;
+ sdp->sd_bsize = GFS2_BASIC_BLOCK;
if (compute_constants(sdp) != 0) {
fprintf(stderr, "Failed to compute file system constants.\n");
@@ -289,7 +288,7 @@ static int fill_super_block(struct gfs2_sbd *sdp)
perror("Failed to read superblock\n");
return 1;
}
- sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_sb.sb_master_dir.no_addr);
+ sdp->master_dir = lgfs2_inode_read(sdp, sdp->sd_meta_dir.no_addr);
if (sdp->master_dir == NULL) {
fprintf(stderr, "Failed to read master directory inode.\n");
return 1;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months
[gfs2-utils] 08/27: libgfs2: Remove big-endian structs from struct
rgrp_tree
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 d8a351b18dc5947b11a355628d44fb8d409ec0d1
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed May 19 19:26:18 2021 +0100
libgfs2: Remove big-endian structs from struct rgrp_tree
Replace them with native-endian fields that combine the struct
gfs2_rindex, struct gfs2_rgrp and struct gfs_rgrp. Some fields (e.g.
rg_crc) are omitted because they are unneeded other than when the struct
is read and written. This reduces the memory usage of the resource group
tree in the utils. Convert the relevant gfs2_(struct)_in/out() functions
to use the new fields.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 83 ++++++++-----------
gfs2/edit/extended.c | 25 +++---
gfs2/edit/hexedit.c | 56 ++++++-------
gfs2/edit/journal.c | 10 +--
gfs2/edit/savemeta.c | 23 ++----
gfs2/fsck/fs_recovery.c | 14 ++--
gfs2/fsck/fsck.h | 4 +-
gfs2/fsck/initialize.c | 102 ++++++++++-------------
gfs2/fsck/main.c | 8 +-
gfs2/fsck/metawalk.c | 24 +++---
gfs2/fsck/pass1.c | 9 +-
gfs2/fsck/pass5.c | 59 ++++++-------
gfs2/fsck/rgrepair.c | 197 ++++++++++++++++++++------------------------
gfs2/fsck/util.c | 10 +--
gfs2/libgfs2/check_rgrp.c | 27 +++---
gfs2/libgfs2/fs_bits.c | 10 +--
gfs2/libgfs2/fs_ops.c | 38 ++++-----
gfs2/libgfs2/gfs1.c | 32 +++++++
gfs2/libgfs2/lang.c | 2 +-
gfs2/libgfs2/libgfs2.h | 53 +++++++++---
gfs2/libgfs2/ondisk.c | 103 +++++++++++------------
gfs2/libgfs2/rgrp.c | 159 ++++++++++++++++-------------------
gfs2/libgfs2/rgrp.h | 2 +-
gfs2/libgfs2/structures.c | 4 +-
gfs2/libgfs2/super.c | 35 ++++----
gfs2/mkfs/main_grow.c | 9 +-
gfs2/mkfs/main_mkfs.c | 25 ++++--
tests/nukerg.c | 11 +--
28 files changed, 547 insertions(+), 587 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index d1cccd59..280eac42 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -135,11 +135,9 @@ static void convert_bitmaps(struct gfs2_sbd *sdp, struct rgrp_tree *rg)
{
uint32_t blk;
int x, y;
- struct gfs2_rindex *ri;
unsigned char state;
- ri = &rg->ri;
- for (blk = 0; blk < ri->ri_length; blk++) {
+ for (blk = 0; blk < rg->rt_length; blk++) {
struct gfs2_bitmap *bi;
x = (blk) ? sizeof(struct gfs2_meta_header) :
sizeof(struct gfs2_rgrp);
@@ -164,7 +162,6 @@ static int convert_rgs(struct gfs2_sbd *sbp)
{
struct rgrp_tree *rgd;
struct osi_node *n, *next = NULL;
- struct gfs_rgrp *rgd1;
int rgs = 0;
/* --------------------------------- */
@@ -174,20 +171,17 @@ static int convert_rgs(struct gfs2_sbd *sbp)
next = osi_next(n);
rgd = (struct rgrp_tree *)n;
- rgd1 = (struct gfs_rgrp *)&rgd->rg; /* recast as gfs1 structure */
- /* rg_freemeta is a gfs1 structure, so libgfs2 doesn't know to */
- /* convert from be to cpu. We must do it now. */
- rgd->rg.rg_free = rgd1->rg_free + be32_to_cpu(rgd1->rg_freemeta);
+ rgd->rt_free = rgd->rt_free + rgd->rt_freemeta;
/* Zero it out so we don't add it again in case something breaks */
/* later on in the process and we have to re-run convert */
- rgd1->rg_freemeta = 0;
+ rgd->rt_freemeta = 0;
- sbp->blks_total += rgd->ri.ri_data;
- sbp->blks_alloced += (rgd->ri.ri_data - rgd->rg.rg_free);
- sbp->dinodes_alloced += rgd1->rg_useddi;
+ sbp->blks_total += rgd->rt_data;
+ sbp->blks_alloced += (rgd->rt_data - rgd->rt_free);
+ sbp->dinodes_alloced += rgd->rt_useddi;
convert_bitmaps(sbp, rgd);
/* Write the updated rgrp to the gfs2 buffer */
- gfs2_rgrp_out(&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_rgrp_out(rgd, rgd->bits[0].bi_data);
rgd->bits[0].bi_modified = 1;
rgs++;
if (rgs % 100 == 0) {
@@ -967,11 +961,11 @@ err_freei:
static int next_rg_meta(struct rgrp_tree *rgd, uint64_t *block, int first)
{
struct gfs2_bitmap *bits = NULL;
- uint32_t length = rgd->ri.ri_length;
- uint32_t blk = (first)? 0: (uint32_t)((*block + 1) - rgd->ri.ri_data0);
+ uint32_t length = rgd->rt_length;
+ uint32_t blk = (first)? 0: (uint32_t)((*block + 1) - rgd->rt_data0);
int i;
- if (!first && (*block < rgd->ri.ri_data0)) {
+ if (!first && (*block < rgd->rt_data0)) {
fprintf(stderr, "next_rg_meta: Start block is outside rgrp bounds.\n");
exit(1);
}
@@ -986,8 +980,7 @@ static int next_rg_meta(struct rgrp_tree *rgd, uint64_t *block, int first)
blk = gfs2_bitfit((uint8_t *)bits->bi_data + bits->bi_offset,
bits->bi_len, blk, GFS2_BLKST_DINODE);
if(blk != BFITNOENT){
- *block = blk + (bits->bi_start * GFS2_NBBY) +
- rgd->ri.ri_data0;
+ *block = blk + (bits->bi_start * GFS2_NBBY) + rgd->rt_data0;
break;
}
blk = 0;
@@ -1083,10 +1076,10 @@ static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr, osi_li
/* Figure out the absolute bitmap byte we need to fix. */
/* ignoring structure offsets and bitmap blocks for now. */
- bitmap_byte = (block - rgd->ri.ri_data0) / GFS2_NBBY;
- byte_bit = (block - rgd->ri.ri_data0) % GFS2_NBBY;
+ bitmap_byte = (block - rgd->rt_data0) / GFS2_NBBY;
+ byte_bit = (block - rgd->rt_data0) % GFS2_NBBY;
/* Now figure out which bitmap block the byte is on */
- for (blk = 0; blk < rgd->ri.ri_length; blk++) {
+ for (blk = 0; blk < rgd->rt_length; blk++) {
struct gfs2_bitmap *bi = &rgd->bits[blk];
/* figure out offset of first bitmap byte for this map: */
buf_offset = (blk) ? sizeof(struct gfs2_meta_header) :
@@ -1551,7 +1544,6 @@ static int sanity_check(struct gfs2_sbd *sdp)
static int gfs1_ri_update(struct gfs2_sbd *sdp, int *rgcount, int quiet)
{
struct rgrp_tree *rgd;
- struct gfs2_rindex *ri;
uint64_t count1 = 0, count2 = 0;
uint64_t errblock = 0;
uint64_t rmax = 0;
@@ -1572,9 +1564,8 @@ static int gfs1_ri_update(struct gfs2_sbd *sdp, int *rgcount, int quiet)
printf(".");
fflush(stdout);
}
- ri = &rgd->ri;
- if (ri->ri_data0 + ri->ri_data - 1 > rmax)
- rmax = ri->ri_data0 + ri->ri_data - 1;
+ if (rgd->rt_data0 + rgd->rt_data - 1 > rmax)
+ rmax = rgd->rt_data0 + rgd->rt_data - 1;
}
sdp->fssize = rmax;
@@ -1878,60 +1869,56 @@ static int journ_space_to_rg(struct gfs2_sbd *sdp)
for (n = osi_first(&sdp->rgtree); n; n = next) {
next = osi_next(n);
rgd = (struct rgrp_tree *)n;
- if (rgd->ri.ri_addr < jndx->ji_addr &&
+ if (rgd->rt_addr < jndx->ji_addr &&
((rgdhigh == NULL) ||
- (rgd->ri.ri_addr > rgdhigh->ri.ri_addr)))
+ (rgd->rt_addr > rgdhigh->rt_addr)))
rgdhigh = rgd;
} /* for each rg */
if (!rgdhigh) { /* if we somehow didn't find one. */
log_crit(_("Error: No suitable rg found for journal.\n"));
return -1;
}
- log_info(_("Addr 0x%llx comes after rg at addr 0x%llx\n"),
- (unsigned long long)jndx->ji_addr,
- (unsigned long long)rgdhigh->ri.ri_addr);
+ log_info(_("Addr 0x%"PRIx64" comes after rg at addr 0x%"PRIx64"\n"),
+ jndx->ji_addr, rgdhigh->rt_addr);
ri_addr = jndx->ji_addr;
/* Allocate a new rgd entry which includes rg and ri. */
rgd = rgrp_insert(&sdp->rgtree, ri_addr);
/* convert the gfs1 rgrp into a new gfs2 rgrp */
size = jndx->ji_nsegment *
be32_to_cpu(raw_gfs1_ondisk_sb.sb_seg_size);
- rgd->rg.rg_header.mh_magic = GFS2_MAGIC;
- rgd->rg.rg_header.mh_type = GFS2_METATYPE_RG;
- rgd->rg.rg_header.mh_format = GFS2_FORMAT_RG;
- rgd->rg.rg_flags = 0;
- rgd->rg.rg_dinodes = 0;
+ rgd->rt_flags = 0;
+ rgd->rt_dinodes = 0;
- rgd->ri.ri_addr = jndx->ji_addr; /* new rg addr becomes ji addr */
- rgd->ri.ri_length = rgrp_length(size, sdp); /* aka bitblocks */
+ rgd->rt_addr = jndx->ji_addr; /* new rg addr becomes ji addr */
+ rgd->rt_length = rgrp_length(size, sdp); /* aka bitblocks */
- rgd->ri.ri_data0 = jndx->ji_addr + rgd->ri.ri_length;
- rgd->ri.ri_data = size - rgd->ri.ri_length;
+ rgd->rt_data0 = jndx->ji_addr + rgd->rt_length;
+ rgd->rt_data = size - rgd->rt_length;
/* Round down to nearest multiple of GFS2_NBBY */
- while (rgd->ri.ri_data & 0x03)
- rgd->ri.ri_data--;
- sdp->blks_total += rgd->ri.ri_data; /* For statfs file update */
- rgd->rg.rg_free = rgd->ri.ri_data;
- rgd->ri.ri_bitbytes = rgd->ri.ri_data / GFS2_NBBY;
+ while (rgd->rt_data & 0x03)
+ rgd->rt_data--;
+ sdp->blks_total += rgd->rt_data; /* For statfs file update */
+ rgd->rt_free = rgd->rt_data;
+ rgd->rt_bitbytes = rgd->rt_data / GFS2_NBBY;
if (gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, rgd)) {
log_crit(_("gfs2_convert: Error converting bitmaps.\n"));
exit(-1);
}
- rgd->bits[0].bi_data = calloc(rgd->ri.ri_length, sdp->bsize);
+ rgd->bits[0].bi_data = calloc(rgd->rt_length, sdp->bsize);
if (rgd->bits[0].bi_data == NULL) {
perror("");
exit(-1);
}
- for (unsigned i = 1; i < rgd->ri.ri_length; i++)
+ for (unsigned i = 1; i < rgd->rt_length; i++)
rgd->bits[i].bi_data = rgd->bits[0].bi_data + (i * sdp->bsize);
convert_bitmaps(sdp, rgd);
- gfs2_rgrp_out(&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_rgrp_out(rgd, rgd->bits[0].bi_data);
rgd->bits[0].bi_modified = 1;
- for (unsigned i = 1; i < rgd->ri.ri_length; i++) {
+ for (unsigned i = 1; i < rgd->rt_length; i++) {
gfs2_meta_header_out(&mh, rgd->bits[i].bi_data);
rgd->bits[i].bi_modified = 1;
}
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index f3b1bba0..e9e2a7eb 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -503,8 +503,8 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
{
int error, start_line;
struct gfs2_rindex ri;
- char rbuf[sizeof(struct gfs2_rindex)];
char highlighted_addr[32];
+ struct rgrp_tree rg = {0};
start_line = line;
print_gfs2("RG index entries found: %"PRIu64".",
@@ -518,39 +518,38 @@ static int parse_rindex(struct gfs2_inode *dip, int print_rindex)
roff = print_entry_ndx * sizeof(struct gfs2_rindex);
- error = gfs2_readi(dip, (void *)&rbuf, roff,
- sizeof(struct gfs2_rindex));
+ error = gfs2_readi(dip, &ri, roff, sizeof(struct gfs2_rindex));
if (!error) /* end of file */
break;
- gfs2_rindex_in(&ri, rbuf);
+ lgfs2_rindex_in(&rg, &ri);
if (!termlines ||
(print_entry_ndx >= start_row[dmode] &&
((print_entry_ndx - start_row[dmode])+1) * lines_per_row[dmode] <=
termlines - start_line - 2)) {
if (edit_row[dmode] == print_entry_ndx) {
COLORS_HIGHLIGHT;
- sprintf(highlighted_addr, "%"PRIx64, ri.ri_addr);
+ sprintf(highlighted_addr, "%"PRIx64, rg.rt_addr);
}
print_gfs2("RG #%d", print_entry_ndx);
if (!print_rindex)
print_gfs2(" located at: %"PRIu64" (0x%"PRIx64")",
- ri.ri_addr, ri.ri_addr);
+ rg.rt_addr, rg.rt_addr);
eol(0);
if (edit_row[dmode] == print_entry_ndx)
COLORS_NORMAL;
- if(print_rindex)
- gfs2_rindex_print(&ri);
+ if (print_rindex)
+ lgfs2_rindex_print(&ri);
else {
- char buf[sizeof(struct gfs2_rgrp)] = {0};
+ struct gfs2_rgrp r = {0};
ssize_t ret;
- ret = pread(sbd.device_fd, buf, sizeof(buf), ri.ri_addr * sbd.bsize);
- if (ret != sizeof(buf)) {
+ ret = pread(sbd.device_fd, &r, sizeof(r), rg.rt_addr * sbd.bsize);
+ if (ret != sizeof(r)) {
perror("Failed to read resource group");
} else if (sbd.gfs1) {
- gfs_rgrp_print(buf);
+ gfs_rgrp_print(&r);
} else {
- lgfs2_rgrp_print(buf);
+ lgfs2_rgrp_print(&r);
}
}
last_entry_onscreen[dmode] = print_entry_ndx;
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index 4fbe071d..18afd0ed 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -390,7 +390,7 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
blknum = pgnum * screen_chunk_size;
blknum += (ptroffset - struct_len);
blknum *= 4;
- blknum += rgd->ri.ri_data0;
+ blknum += rgd->rt_data0;
print_gfs2(" blk ");
for (b = blknum; b < blknum + 4; b++) {
@@ -407,7 +407,7 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
if (rgd && (ptroffset >= struct_len || pgnum)) {
int blknum, b, btype, rb_number;
- rb_number = block - rgd->ri.ri_addr;
+ rb_number = block - rgd->rt_addr;
blknum = 0;
/* count the number of bytes representing
blocks prior to the displayed screen. */
@@ -425,7 +425,7 @@ int display_block_type(char *buf, uint64_t addr, int from_restore)
/* convert bytes to blocks */
blknum *= GFS2_NBBY;
/* add the starting offset for this rgrp */
- blknum += rgd->ri.ri_data0;
+ blknum += rgd->rt_data0;
print_gfs2(" blk ");
for (b = blknum; b < blknum + 4; b++) {
btype = lgfs2_get_bitmap(&sbd, b, rgd);
@@ -709,7 +709,7 @@ static void rgcount(void)
static uint64_t find_rgrp_block(struct gfs2_inode *dif, int rg)
{
int amt;
- struct gfs2_rindex fbuf, ri;
+ struct gfs2_rindex ri;
uint64_t foffset, gfs1_adj = 0;
foffset = rg * sizeof(struct gfs2_rindex);
@@ -721,12 +721,10 @@ static uint64_t find_rgrp_block(struct gfs2_inode *dif, int rg)
sizeof(struct gfs2_meta_header);
gfs1_adj += sizeof(struct gfs2_meta_header);
}
- amt = gfs2_readi(dif, (void *)&fbuf, foffset + gfs1_adj,
- sizeof(struct gfs2_rindex));
+ amt = gfs2_readi(dif, &ri, foffset + gfs1_adj, sizeof(ri));
if (!amt) /* end of file */
return 0;
- gfs2_rindex_in(&ri, (void *)&fbuf);
- return ri.ri_addr;
+ return be64_to_cpu(ri.ri_addr);
}
/* ------------------------------------------------------------------------ */
@@ -964,7 +962,6 @@ static void read_superblock(int fd)
static int read_rindex(void)
{
- struct gfs2_rindex *ri;
uint64_t count;
int ok;
@@ -973,8 +970,8 @@ static int read_rindex(void)
rindex_read(&sbd, &count, &ok);
if (!OSI_EMPTY_ROOT(&sbd.rgtree)) {
- ri = &((struct rgrp_tree *)osi_last(&sbd.rgtree))->ri;
- sbd.fssize = ri->ri_data0 + ri->ri_data;
+ struct rgrp_tree *rg = (struct rgrp_tree *)osi_last(&sbd.rgtree);
+ sbd.fssize = rg->rt_data0 + rg->rt_data;
}
return 0;
}
@@ -1202,7 +1199,7 @@ static int find_rg_metatype(struct rgrp_tree *rgd, uint64_t *blk, uint64_t start
struct gfs2_buffer_head *bhp = NULL;
uint64_t *ibuf = malloc(sbd.bsize * GFS2_NBBY * sizeof(uint64_t));
- for (i = 0; i < rgd->ri.ri_length; i++) {
+ for (i = 0; i < rgd->rt_length; i++) {
m = lgfs2_bm_scan(rgd, i, ibuf, GFS2_BLKST_DINODE);
for (j = 0; j < m; j++) {
@@ -1233,18 +1230,16 @@ static uint64_t find_metablockoftype_rg(uint64_t startblk, int metatype, int pri
uint64_t blk, errblk;
int first = 1, found = 0;
struct rgrp_tree *rgd = NULL;
- struct gfs2_rindex *ri;
blk = 0;
/* Skip the rgs prior to the block we've been given */
for (next = osi_first(&sbd.rgtree); next; next = osi_next(next)) {
rgd = (struct rgrp_tree *)next;
- ri = &rgd->ri;
- if (first && startblk <= ri->ri_data0) {
- startblk = ri->ri_data0;
+ if (first && startblk <= rgd->rt_data0) {
+ startblk = rgd->rt_data0;
break;
- } else if (ri->ri_addr <= startblk &&
- startblk < ri->ri_data0 + ri->ri_data)
+ } else if (rgd->rt_addr <= startblk &&
+ startblk < rgd->rt_data0 + rgd->rt_data)
break;
else
rgd = NULL;
@@ -1644,19 +1639,19 @@ static void find_print_block_rg(int bitmap)
else {
rgd = gfs2_blk2rgrpd(&sbd, rblock);
if (rgd) {
- rgblock = rgd->ri.ri_addr;
+ rgblock = rgd->rt_addr;
if (bitmap) {
struct gfs2_bitmap *bits = NULL;
- for (i = 0; i < rgd->ri.ri_length; i++) {
+ for (i = 0; i < rgd->rt_length; i++) {
bits = &(rgd->bits[i]);
- if (rblock - rgd->ri.ri_data0 <
+ if (rblock - rgd->rt_data0 <
((bits->bi_start + bits->bi_len) *
GFS2_NBBY)) {
break;
}
}
- if (i < rgd->ri.ri_length)
+ if (i < rgd->rt_length)
rgblock += i;
}
@@ -2183,7 +2178,7 @@ static int count_dinode_blks(struct rgrp_tree *rgd, int bitmap,
off = sizeof(struct gfs2_rgrp);
for (b = 0; b < rgd->bits[bitmap].bi_len << GFS2_BIT_SIZE; b++) {
- tbh = bread(&sbd, rgd->ri.ri_data0 +
+ tbh = bread(&sbd, rgd->rt_data0 +
rgd->bits[bitmap].bi_start + b);
byte = rbh->b_data + off + (b / GFS2_NBBY);
bit = (b % GFS2_NBBY) * GFS2_BIT_SIZE;
@@ -2247,17 +2242,16 @@ static void rg_repair(void)
repaired bitmap to GFS2_BLKST_DINODE. Set all others to
GFS2_BLKST_USED so fsck can sort it out. If we set them
to FREE, fsck would just nuke it all. */
- printf("Resource group at block %llu (0x%llx) appears to be "
+ printf("Resource group at block %"PRIu64" (0x%"PRIx64") appears to be "
"damaged. Attempting to fix it (in reverse order).\n",
- (unsigned long long)rgd->ri.ri_addr,
- (unsigned long long)rgd->ri.ri_addr);
+ rgd->rt_addr, rgd->rt_addr);
- for (b = rgd->ri.ri_length - 1; b >= 0; b--) {
+ for (b = rgd->rt_length - 1; b >= 0; b--) {
int mtype = (b ? GFS2_METATYPE_RB : GFS2_METATYPE_RG);
struct gfs2_meta_header *mh;
printf("Bitmap #%d:", b);
- rbh = bread(&sbd, rgd->ri.ri_addr + b);
+ rbh = bread(&sbd, rgd->rt_addr + b);
if (gfs2_check_meta(rbh->b_data, mtype)) { /* wrong type */
printf("Damaged. Repairing...");
/* Fix the meta header */
@@ -2281,8 +2275,8 @@ static void rg_repair(void)
printf("Dinodes found: %d\n", dinodes_found);
dinodes_total += dinodes_found;
if (b == 0) { /* rgrp itself was damaged */
- rgd->rg.rg_dinodes = dinodes_total;
- rgd->rg.rg_free = 0;
+ rgd->rt_dinodes = dinodes_total;
+ rgd->rt_free = 0;
}
brelse(rbh);
}
@@ -2521,7 +2515,7 @@ static void process_parameters(int argc, char *argv[], int pass)
gfs2_rgrp_free(&sbd, &sbd.rgtree);
exit(EXIT_FAILURE);
}
- for (bmap = 0; bmap < rgd->ri.ri_length; bmap++)
+ for (bmap = 0; bmap < rgd->rt_length; bmap++)
push_block(rgblk + bmap);
}
else if (!strcmp(argv[i], "rgrepair"))
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index 13b8c121..0da00235 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -255,7 +255,7 @@ static int print_ld_blks(const uint64_t *b, const char *end, int start_line,
found_bblk = 1;
print_gfs2("<-------------------------");
if (is_meta_ld) {
- o = tblk - rgd->ri.ri_data0;
+ o = tblk - rgd->rt_data0;
if (o >= (rgd->bits->bi_start +
rgd->bits->bi_len) *
GFS2_NBBY)
@@ -563,16 +563,16 @@ void dump_journal(const char *journal, int tblk)
uint64_t o;
int bmap = 0;
- print_gfs2("rgd: 0x%"PRIx64" for 0x%"PRIx32", ", rgd->ri.ri_addr,
- rgd->ri.ri_length);
- o = tblk - rgd->ri.ri_data0;
+ print_gfs2("rgd: 0x%"PRIx64" for 0x%"PRIx32", ", rgd->rt_addr,
+ rgd->rt_length);
+ o = tblk - rgd->rt_data0;
if (o >= (rgd->bits->bi_start +
rgd->bits->bi_len) * (uint64_t)GFS2_NBBY)
o += (sizeof(struct gfs2_rgrp) -
sizeof(struct gfs2_meta_header))
* GFS2_NBBY;
bmap = o / sbd.sd_blocks_per_bitmap;
- bitblk = rgd->ri.ri_addr + bmap;
+ bitblk = rgd->rt_addr + bmap;
print_gfs2("bitmap: %d, bitblk: 0x%"PRIx64, bmap, bitblk);
eol(0);
}
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 9c003e68..e55b66f6 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -994,7 +994,7 @@ static void save_allocated(struct rgrp_tree *rgd, struct metafd *mfd)
unsigned i, j, m;
uint64_t *ibuf = malloc(sbd.bsize * GFS2_NBBY * sizeof(uint64_t));
- for (i = 0; i < rgd->ri.ri_length; i++) {
+ for (i = 0; i < rgd->rt_length; i++) {
struct block_range br = {0};
m = lgfs2_bm_scan(rgd, i, ibuf, GFS2_BLKST_DINODE);
@@ -1056,33 +1056,28 @@ static char *rgrp_read(struct gfs2_sbd *sdp, uint64_t addr, unsigned blocks)
static void save_rgrp(struct gfs2_sbd *sdp, struct metafd *mfd, struct rgrp_tree *rgd, int withcontents)
{
- uint64_t addr = rgd->ri.ri_addr;
+ uint64_t addr = rgd->rt_addr;
char *buf;
- buf = rgrp_read(sdp, rgd->ri.ri_addr, rgd->ri.ri_length);
+ buf = rgrp_read(sdp, rgd->rt_addr, rgd->rt_length);
if (buf == NULL)
return;
- if (sdp->gfs1)
- gfs_rgrp_in((struct gfs_rgrp *)&rgd->rg, buf);
- else
- gfs2_rgrp_in(&rgd->rg, buf);
-
- for (unsigned i = 0; i < rgd->ri.ri_length; i++)
+ for (unsigned i = 0; i < rgd->rt_length; i++)
rgd->bits[i].bi_data = buf + (i * sdp->bsize);
- log_debug("RG at %"PRIu64" is %"PRIu32" long\n", addr, (uint32_t)rgd->ri.ri_length);
+ log_debug("RG at %"PRIu64" is %"PRIu32" long\n", addr, rgd->rt_length);
/* Save the rg and bitmaps */
- for (unsigned i = 0; i < rgd->ri.ri_length; i++) {
- report_progress(rgd->ri.ri_addr + i, 0);
- save_buf(mfd, buf + (i * sdp->bsize), rgd->ri.ri_addr + i, sdp->bsize);
+ for (unsigned i = 0; i < rgd->rt_length; i++) {
+ report_progress(rgd->rt_addr + i, 0);
+ save_buf(mfd, buf + (i * sdp->bsize), rgd->rt_addr + i, sdp->bsize);
}
/* Save the other metadata: inodes, etc. if mode is not 'savergs' */
if (withcontents)
save_allocated(rgd, mfd);
free(buf);
- for (unsigned i = 0; i < rgd->ri.ri_length; i++)
+ for (unsigned i = 0; i < rgd->rt_length; i++)
rgd->bits[i].bi_data = NULL;
}
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index e481c88a..61b37b75 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -101,19 +101,19 @@ static void refresh_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
{
int i;
- log_debug(_("Block is part of rgrp 0x%llx; refreshing the rgrp.\n"),
- (unsigned long long)rgd->ri.ri_addr);
- for (i = 0; i < rgd->ri.ri_length; i++) {
- if (rgd->ri.ri_addr + i != blkno)
+ log_debug(_("Block is part of rgrp 0x%"PRIx64"; refreshing the rgrp.\n"),
+ rgd->rt_addr);
+ for (i = 0; i < rgd->rt_length; i++) {
+ if (rgd->rt_addr + i != blkno)
continue;
memcpy(rgd->bits[i].bi_data, bh->b_data, sdp->bsize);
rgd->bits[i].bi_modified = 1;
if (i == 0) { /* this is the rgrp itself */
if (sdp->gfs1)
- gfs_rgrp_in((struct gfs_rgrp *)&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_gfs_rgrp_in(rgd, rgd->bits[0].bi_data);
else
- gfs2_rgrp_in(&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_rgrp_in(rgd, rgd->bits[0].bi_data);
}
break;
}
@@ -172,7 +172,7 @@ static int buf_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
} else {
bmodified(bh_ip);
rgd = gfs2_blk2rgrpd(sdp, blkno);
- if (rgd && blkno < rgd->ri.ri_data0)
+ if (rgd && blkno < rgd->rt_data0)
refresh_rgrp(sdp, rgd, bh_ip, blkno);
}
diff --git a/gfs2/fsck/fsck.h b/gfs2/fsck/fsck.h
index 16aab67d..8b7ac0a9 100644
--- a/gfs2/fsck/fsck.h
+++ b/gfs2/fsck/fsck.h
@@ -167,9 +167,9 @@ static inline int valid_block(struct gfs2_sbd *sdp, uint64_t blkno)
static inline int rgrp_contains_block(struct rgrp_tree *rgd, uint64_t blk)
{
- if (blk < rgd->ri.ri_addr)
+ if (blk < rgd->rt_addr)
return 0;
- if (blk >= rgd->ri.ri_data0 + rgd->ri.ri_data)
+ if (blk >= rgd->rt_data0 + rgd->rt_data)
return 0;
return 1;
}
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 3f2c088b..16cc1b49 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -134,7 +134,6 @@ static int set_block_ranges(struct gfs2_sbd *sdp)
{
struct osi_node *n, *next = NULL;
struct rgrp_tree *rgd;
- struct gfs2_rindex *ri;
char buf[sdp->sd_sb.sb_bsize];
uint64_t rmax = 0;
uint64_t rmin = 0;
@@ -145,12 +144,11 @@ static int set_block_ranges(struct gfs2_sbd *sdp)
for (n = osi_first(&sdp->rgtree); n; n = next) {
next = osi_next(n);
rgd = (struct rgrp_tree *)n;
- ri = &rgd->ri;
- if (ri->ri_data0 + ri->ri_data &&
- ri->ri_data0 + ri->ri_data - 1 > rmax)
- rmax = ri->ri_data0 + ri->ri_data - 1;
- if (!rmin || ri->ri_data0 < rmin)
- rmin = ri->ri_data0;
+ if (rgd->rt_data0 + rgd->rt_data &&
+ rgd->rt_data0 + rgd->rt_data - 1 > rmax)
+ rmax = rgd->rt_data0 + rgd->rt_data - 1;
+ if (!rmin || rgd->rt_data0 < rmin)
+ rmin = rgd->rt_data0;
}
last_fs_block = rmax;
@@ -201,17 +199,16 @@ static void check_rgrp_integrity(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
uint32_t rg_free, rg_reclaimed, rg_unlinked, rg_usedmeta, rg_useddi;
int rgb, x, y, off, bytes_to_check, total_bytes_to_check, asked = 0;
unsigned int state;
- struct gfs_rgrp *gfs1rg = (struct gfs_rgrp *)&rgd->rg;
uint64_t diblock;
struct gfs2_buffer_head *bh;
rg_free = rg_reclaimed = rg_unlinked = rg_usedmeta = rg_useddi = 0;
- total_bytes_to_check = rgd->ri.ri_bitbytes;
+ total_bytes_to_check = rgd->rt_bitbytes;
*this_rg_fixed = *this_rg_bad = *this_rg_cleaned = 0;
- diblock = rgd->ri.ri_data0;
- for (rgb = 0; rgb < rgd->ri.ri_length; rgb++){
+ diblock = rgd->rt_data0;
+ for (rgb = 0; rgb < rgd->rt_length; rgb++){
/* Count up the free blocks in the bitmap */
off = (rgb) ? sizeof(struct gfs2_meta_header) :
sizeof(struct gfs2_rgrp);
@@ -274,9 +271,8 @@ static void check_rgrp_integrity(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
sprintf(msg,
_("Okay to reclaim free "
"metadata in resource group "
- "%lld (0x%llx)? (y/n)"),
- (unsigned long long)rgd->ri.ri_addr,
- (unsigned long long)rgd->ri.ri_addr);
+ "%"PRIu64" (0x%"PRIx64")? (y/n)"),
+ rgd->rt_addr, rgd->rt_addr);
if (query("%s", msg))
*fixit = 1;
}
@@ -290,9 +286,9 @@ static void check_rgrp_integrity(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
rgd->bits[rgb].bi_modified = 1;
rg_reclaimed++;
rg_free++;
- rgd->rg.rg_free++;
- if (sdp->gfs1 && gfs1rg->rg_freemeta)
- gfs1rg->rg_freemeta--;
+ rgd->rt_free++;
+ if (sdp->gfs1 && rgd->rt_freemeta)
+ rgd->rt_freemeta--;
log_info(_("Free metadata block %lld (0x%llx) "
"reclaimed.\n"),
(unsigned long long)diblock,
@@ -323,31 +319,27 @@ static void check_rgrp_integrity(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
will be reported. */
if (rg_reclaimed && *fixit) {
if (sdp->gfs1)
- gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data);
else
- gfs2_rgrp_out(&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_rgrp_out(rgd, rgd->bits[0].bi_data);
rgd->bits[0].bi_modified = 1;
*this_rg_cleaned = 1;
- log_info( _("The rgrp at %lld (0x%llx) was cleaned of %d "
+ log_info(_("The rgrp at %"PRIu64" (0x%"PRIx64") was cleaned of %d "
"free metadata blocks.\n"),
- (unsigned long long)rgd->ri.ri_addr,
- (unsigned long long)rgd->ri.ri_addr,
- rg_reclaimed);
+ rgd->rt_addr, rgd->rt_addr, rg_reclaimed);
}
- if (rgd->rg.rg_free != rg_free) {
+ if (rgd->rt_free != rg_free) {
*this_rg_bad = 1;
*this_rg_cleaned = 0;
- log_err( _("Error: resource group %lld (0x%llx): "
+ log_err( _("Error: resource group %"PRIu64" (0x%"PRIx64"): "
"free space (%d) does not match bitmap (%d)\n"),
- (unsigned long long)rgd->ri.ri_addr,
- (unsigned long long)rgd->ri.ri_addr,
- rgd->rg.rg_free, rg_free);
+ rgd->rt_addr, rgd->rt_addr, rgd->rt_free, rg_free);
if (query( _("Fix the rgrp free blocks count? (y/n)"))) {
- rgd->rg.rg_free = rg_free;
+ rgd->rt_free = rg_free;
if (sdp->gfs1)
- gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data);
else
- gfs2_rgrp_out(&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_rgrp_out(rgd, rgd->bits[0].bi_data);
rgd->bits[0].bi_modified = 1;
*this_rg_fixed = 1;
log_err( _("The rgrp was fixed.\n"));
@@ -357,51 +349,45 @@ static void check_rgrp_integrity(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
if (!sdp->gfs1)
return;
- if (gfs1rg->rg_freemeta != rg_unlinked) {
+ if (rgd->rt_freemeta != rg_unlinked) {
*this_rg_bad = 1;
*this_rg_cleaned = 0;
- log_err( _("Error: resource group %lld (0x%llx): "
- "free meta (%d) does not match bitmap (%d)\n"),
- (unsigned long long)rgd->ri.ri_addr,
- (unsigned long long)rgd->ri.ri_addr,
- gfs1rg->rg_freemeta, rg_unlinked);
+ log_err(_("Error: resource group %"PRIu64" (0x%"PRIx64"): "
+ "free meta (%d) does not match bitmap (%d)\n"),
+ rgd->rt_addr, rgd->rt_addr, rgd->rt_freemeta, rg_unlinked);
if (query( _("Fix the rgrp free meta blocks count? (y/n)"))) {
- gfs1rg->rg_freemeta = rg_unlinked;
- gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bits[0].bi_data);
+ rgd->rt_freemeta = rg_unlinked;
+ lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data);
rgd->bits[0].bi_modified = 1;
*this_rg_fixed = 1;
log_err( _("The rgrp was fixed.\n"));
} else
log_err( _("The rgrp was not fixed.\n"));
}
- if (gfs1rg->rg_useddi != rg_useddi) {
+ if (rgd->rt_useddi != rg_useddi) {
*this_rg_bad = 1;
*this_rg_cleaned = 0;
- log_err( _("Error: resource group %lld (0x%llx): used dinode "
+ log_err(_("Error: resource group %"PRIu64" (0x%"PRIx64"): used dinode "
"count (%d) does not match bitmap (%d)\n"),
- (unsigned long long)rgd->ri.ri_addr,
- (unsigned long long)rgd->ri.ri_addr,
- gfs1rg->rg_useddi, rg_useddi);
+ rgd->rt_addr, rgd->rt_addr, rgd->rt_useddi, rg_useddi);
if (query( _("Fix the rgrp used dinode block count? (y/n)"))) {
- gfs1rg->rg_useddi = rg_useddi;
- gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bits[0].bi_data);
+ rgd->rt_useddi = rg_useddi;
+ lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data);
rgd->bits[0].bi_modified = 1;
*this_rg_fixed = 1;
log_err( _("The rgrp was fixed.\n"));
} else
log_err( _("The rgrp was not fixed.\n"));
}
- if (gfs1rg->rg_usedmeta != rg_usedmeta) {
+ if (rgd->rt_usedmeta != rg_usedmeta) {
*this_rg_bad = 1;
*this_rg_cleaned = 0;
- log_err( _("Error: resource group %lld (0x%llx): used "
+ log_err(_("Error: resource group %"PRIu64" (0x%"PRIx64"): used "
"metadata (%d) does not match bitmap (%d)\n"),
- (unsigned long long)rgd->ri.ri_addr,
- (unsigned long long)rgd->ri.ri_addr,
- gfs1rg->rg_usedmeta, rg_usedmeta);
+ rgd->rt_addr, rgd->rt_addr, rgd->rt_usedmeta, rg_usedmeta);
if (query( _("Fix the rgrp used meta blocks count? (y/n)"))) {
- gfs1rg->rg_usedmeta = rg_usedmeta;
- gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bits[0].bi_data);
+ rgd->rt_usedmeta = rg_usedmeta;
+ lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data);
rgd->bits[0].bi_modified = 1;
*this_rg_fixed = 1;
log_err( _("The rgrp was fixed.\n"));
@@ -665,8 +651,8 @@ static unsigned gfs2_rgrp_reada(struct gfs2_sbd *sdp, unsigned cur_window,
if (i < cur_window)
continue;
rgd = (struct rgrp_tree *)n;
- start = rgd->ri.ri_addr * sdp->bsize;
- len = rgd->ri.ri_length * sdp->bsize;
+ start = rgd->rt_addr * sdp->bsize;
+ len = rgd->rt_length * sdp->bsize;
posix_fadvise(sdp->device_fd, start, len, POSIX_FADV_WILLNEED);
}
@@ -686,7 +672,6 @@ static unsigned gfs2_rgrp_reada(struct gfs2_sbd *sdp, unsigned cur_window,
static int read_rgrps(struct gfs2_sbd *sdp, uint64_t expected)
{
struct rgrp_tree *rgd;
- struct gfs2_rindex *ri;
uint64_t count = 0;
uint64_t errblock = 0;
uint64_t rmax = 0;
@@ -708,9 +693,8 @@ static int read_rgrps(struct gfs2_sbd *sdp, uint64_t expected)
return errblock;
ra_window--;
count++;
- ri = &rgd->ri;
- if (ri->ri_data0 + ri->ri_data - 1 > rmax)
- rmax = ri->ri_data0 + ri->ri_data - 1;
+ if (rgd->rt_data0 + rgd->rt_data - 1 > rmax)
+ rmax = rgd->rt_data0 + rgd->rt_data - 1;
}
sdp->fssize = rmax;
diff --git a/gfs2/fsck/main.c b/gfs2/fsck/main.c
index e322b395..a7ea9bf2 100644
--- a/gfs2/fsck/main.c
+++ b/gfs2/fsck/main.c
@@ -167,7 +167,6 @@ static int check_statfs(struct gfs2_sbd *sdp)
{
struct osi_node *n, *next = NULL;
struct rgrp_tree *rgd;
- struct gfs2_rindex *ri;
struct gfs2_statfs_change sc;
uint64_t sc_total;
uint64_t sc_free;
@@ -197,10 +196,9 @@ static int check_statfs(struct gfs2_sbd *sdp)
for (n = osi_first(&sdp->rgtree); n; n = next) {
next = osi_next(n);
rgd = (struct rgrp_tree *)n;
- ri = &rgd->ri;
- sdp->blks_total += ri->ri_data;
- sdp->blks_alloced += (ri->ri_data - rgd->rg.rg_free);
- sdp->dinodes_alloced += rgd->rg.rg_dinodes;
+ sdp->blks_total += rgd->rt_data;
+ sdp->blks_alloced += (rgd->rt_data - rgd->rt_free);
+ sdp->dinodes_alloced += rgd->rt_dinodes;
}
/* See if they match */
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 991f1175..2543e2e5 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -35,7 +35,6 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
int old_state;
int treat_as_inode = 0;
int rewrite_rgrp = 0;
- struct gfs_rgrp *gfs1rg;
const char *allocdesc[2][5] = { /* gfs2 descriptions */
{"free", "data", "unlinked", "inode", "reserved"},
/* gfs1 descriptions: */
@@ -48,9 +47,6 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
rgd = gfs2_blk2rgrpd(sdp, blk);
prevrgd = rgd;
}
-
- gfs1rg = (struct gfs_rgrp *)&rgd->rg;
-
old_state = lgfs2_get_bitmap(sdp, blk, rgd);
if (old_state < 0) {
log_err( _("Block %llu (0x%llx) is not represented in the "
@@ -87,10 +83,10 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
data or data to dinode, no change in free space. */
gfs2_set_bitmap(rgd, blk, new_state);
if (new_state == GFS2_BLKST_FREE) {
- rgd->rg.rg_free++;
+ rgd->rt_free++;
rewrite_rgrp = 1;
} else if (old_state == GFS2_BLKST_FREE) {
- rgd->rg.rg_free--;
+ rgd->rt_free--;
rewrite_rgrp = 1;
}
/* If we're freeing a dinode, get rid of the data structs for it. */
@@ -117,10 +113,10 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
treat_as_inode = 1;
}
if (old_state == GFS2_BLKST_DINODE) {
- if (treat_as_inode && rgd->rg.rg_dinodes > 0)
- rgd->rg.rg_dinodes--;
- else if (sdp->gfs1 && gfs1rg->rg_usedmeta > 0)
- gfs1rg->rg_usedmeta--;
+ if (treat_as_inode && rgd->rt_dinodes > 0)
+ rgd->rt_dinodes--;
+ else if (sdp->gfs1 && rgd->rt_usedmeta > 0)
+ rgd->rt_usedmeta--;
rewrite_rgrp = 1;
}
link1_set(&nlink1map, blk, 0);
@@ -148,16 +144,16 @@ int check_n_fix_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
}
}
if (treat_as_inode)
- rgd->rg.rg_dinodes++;
+ rgd->rt_dinodes++;
else if (sdp->gfs1)
- gfs1rg->rg_usedmeta++;
+ rgd->rt_usedmeta++;
rewrite_rgrp = 1;
}
if (rewrite_rgrp) {
if (sdp->gfs1)
- gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data);
else
- gfs2_rgrp_out(&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_rgrp_out(rgd, rgd->bits[0].bi_data);
rgd->bits[0].bi_modified = 1;
}
log_err( _("The bitmap was fixed.\n"));
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 3454fd56..f2ba4235 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -1944,7 +1944,7 @@ static int pass1_process_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
if (ibuf == NULL)
return FSCK_ERROR;
- for (k = 0; k < rgd->ri.ri_length; k++) {
+ for (k = 0; k < rgd->rt_length; k++) {
n = lgfs2_bm_scan(rgd, k, ibuf, GFS2_BLKST_DINODE);
if (n) {
@@ -2116,11 +2116,10 @@ int pass1(struct gfs2_sbd *sdp)
next = osi_next(n);
log_debug("Checking metadata in resource group #%"PRIu64"\n", rg_count);
rgd = (struct rgrp_tree *)n;
- for (i = 0; i < rgd->ri.ri_length; i++) {
+ for (i = 0; i < rgd->rt_length; i++) {
log_debug("rgrp block %"PRIu64" (0x%"PRIx64") is now marked as 'rgrp data'\n",
- rgd->ri.ri_addr + i, rgd->ri.ri_addr + i);
- if (gfs2_blockmap_set(bl, rgd->ri.ri_addr + i,
- GFS2_BLKST_USED)) {
+ rgd->rt_addr + i, rgd->rt_addr + i);
+ if (gfs2_blockmap_set(bl, rgd->rt_addr + i, GFS2_BLKST_USED)) {
stack;
gfs2_special_free(&gfs1_rindex_blks);
ret = FSCK_ERROR;
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index 33265bfa..cb60415b 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -133,57 +133,48 @@ static void update_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgp,
struct gfs2_bitmap *bits;
uint64_t rg_block = 0;
int update = 0;
- struct gfs_rgrp *gfs1rg = (struct gfs_rgrp *)&rgp->rg;
- for(i = 0; i < rgp->ri.ri_length; i++) {
+ for(i = 0; i < rgp->rt_length; i++) {
bits = &rgp->bits[i];
/* update the bitmaps */
if (check_block_status(sdp, bl, bits->bi_data + bits->bi_offset,
- bits->bi_len, &rg_block, rgp->ri.ri_data0, count))
+ bits->bi_len, &rg_block, rgp->rt_data0, count))
return;
if (skip_this_pass || fsck_abort) /* if asked to skip the rest */
return;
}
/* actually adjust counters and write out to disk */
- if (rgp->rg.rg_free != count[GFS2_BLKST_FREE]) {
- log_err( _("RG #%llu (0x%llx) free count inconsistent: "
+ if (rgp->rt_free != count[GFS2_BLKST_FREE]) {
+ log_err(_("RG #%"PRIu64" (0x%"PRIx64") free count inconsistent: "
"is %u should be %u\n"),
- (unsigned long long)rgp->ri.ri_addr,
- (unsigned long long)rgp->ri.ri_addr,
- rgp->rg.rg_free, count[GFS2_BLKST_FREE]);
- rgp->rg.rg_free = count[GFS2_BLKST_FREE];
+ rgp->rt_addr, rgp->rt_addr, rgp->rt_free, count[GFS2_BLKST_FREE]);
+ rgp->rt_free = count[GFS2_BLKST_FREE];
update = 1;
}
- if (rgp->rg.rg_dinodes != count[GFS2_BLKST_DINODE]) {
- log_err( _("RG #%llu (0x%llx) Inode count inconsistent: is "
- "%u should be %u\n"),
- (unsigned long long)rgp->ri.ri_addr,
- (unsigned long long)rgp->ri.ri_addr,
- rgp->rg.rg_dinodes, count[GFS2_BLKST_DINODE]);
- rgp->rg.rg_dinodes = count[GFS2_BLKST_DINODE];
+ if (rgp->rt_dinodes != count[GFS2_BLKST_DINODE]) {
+ log_err(_("RG #%"PRIu64" (0x%"PRIx64") Inode count inconsistent: is "
+ "%u should be %u\n"),
+ rgp->rt_addr, rgp->rt_addr, rgp->rt_dinodes, count[GFS2_BLKST_DINODE]);
+ rgp->rt_dinodes = count[GFS2_BLKST_DINODE];
update = 1;
}
- if (sdp->gfs1 && gfs1rg->rg_usedmeta != count[GFS1_BLKST_USEDMETA]) {
- log_err( _("RG #%llu (0x%llx) Used metadata count "
- "inconsistent: is %u should be %u\n"),
- (unsigned long long)rgp->ri.ri_addr,
- (unsigned long long)rgp->ri.ri_addr,
- gfs1rg->rg_usedmeta, count[GFS1_BLKST_USEDMETA]);
- gfs1rg->rg_usedmeta = count[GFS1_BLKST_USEDMETA];
+ if (sdp->gfs1 && rgp->rt_usedmeta != count[GFS1_BLKST_USEDMETA]) {
+ log_err(_("RG #%"PRIu64" (0x%"PRIx64") Used metadata count "
+ "inconsistent: is %u should be %u\n"),
+ rgp->rt_addr, rgp->rt_addr, rgp->rt_usedmeta, count[GFS1_BLKST_USEDMETA]);
+ rgp->rt_usedmeta = count[GFS1_BLKST_USEDMETA];
update = 1;
}
- if (sdp->gfs1 && gfs1rg->rg_freemeta != count[GFS2_BLKST_UNLINKED]) {
- log_err( _("RG #%llu (0x%llx) Free metadata count "
- "inconsistent: is %u should be %u\n"),
- (unsigned long long)rgp->ri.ri_addr,
- (unsigned long long)rgp->ri.ri_addr,
- gfs1rg->rg_freemeta, count[GFS2_BLKST_UNLINKED]);
- gfs1rg->rg_freemeta = count[GFS2_BLKST_UNLINKED];
+ if (sdp->gfs1 && rgp->rt_freemeta != count[GFS2_BLKST_UNLINKED]) {
+ log_err(_("RG #%"PRIu64" (0x%"PRIx64") Free metadata count "
+ "inconsistent: is %u should be %u\n"),
+ rgp->rt_addr, rgp->rt_addr, rgp->rt_freemeta, count[GFS2_BLKST_UNLINKED]);
+ rgp->rt_freemeta = count[GFS2_BLKST_UNLINKED];
update = 1;
}
- if (!sdp->gfs1 && (rgp->ri.ri_data != count[GFS2_BLKST_FREE] +
+ if (!sdp->gfs1 && (rgp->rt_data != count[GFS2_BLKST_FREE] +
count[GFS2_BLKST_USED] +
count[GFS2_BLKST_UNLINKED] +
count[GFS2_BLKST_DINODE])) {
@@ -191,7 +182,7 @@ static void update_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgp,
* means that the total number of blocks we've counted
* exceeds the blocks in the rg */
log_err( _("Internal fsck error: %u != %u + %u + %u + %u\n"),
- rgp->ri.ri_data, count[GFS2_BLKST_FREE],
+ rgp->rt_data, count[GFS2_BLKST_FREE],
count[GFS2_BLKST_USED], count[GFS2_BLKST_UNLINKED],
count[GFS2_BLKST_DINODE]);
exit(FSCK_ERROR);
@@ -201,9 +192,9 @@ static void update_rgrp(struct gfs2_sbd *sdp, struct rgrp_tree *rgp,
log_warn( _("Resource group counts updated\n"));
/* write out the rgrp */
if (sdp->gfs1)
- gfs_rgrp_out(gfs1rg, rgp->bits[0].bi_data);
+ lgfs2_gfs_rgrp_out(rgp, rgp->bits[0].bi_data);
else
- gfs2_rgrp_out(&rgp->rg, rgp->bits[0].bi_data);
+ lgfs2_rgrp_out(rgp, rgp->bits[0].bi_data);
rgp->bits[0].bi_modified = 1;
} else
log_err( _("Resource group counts left inconsistent\n"));
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 316be67c..029f0711 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -23,14 +23,12 @@ struct special_blocks false_rgrps;
#define AWAY_FROM_BITMAPS 0x1000
#define MAX_RGSEGMENTS 20
-#define ri_equal(ondisk, expected, field) (ondisk.field == expected.field)
-
-#define ri_compare(rg, ondisk, expected, field, fmt, type) \
- if (ondisk.field != expected.field) { \
+#define ri_compare(rg, ondisk, expected, field, fmt) \
+ if (ondisk->field != expected->field) { \
log_warn( _("rindex #%d " #field " discrepancy: index 0x%" \
fmt " != expected: 0x%" fmt "\n"), \
- rg + 1, (type)ondisk.field, (type)expected.field); \
- ondisk.field = expected.field; \
+ rg + 1, ondisk->field, expected->field); \
+ ondisk->field = expected->field; \
rindex_modified = 1; \
}
@@ -104,7 +102,6 @@ static int find_shortest_rgdist(struct gfs2_sbd *sdp, uint64_t *dist_array,
uint64_t blk, block_last_rg, shortest_dist_btwn_rgs;
struct gfs2_buffer_head *bh;
int rgs_sampled = 0;
- struct gfs2_rindex buf, tmpndx;
uint64_t initial_first_rg_dist;
int gsegment = 0;
int is_rgrp;
@@ -238,14 +235,14 @@ static int find_shortest_rgdist(struct gfs2_sbd *sdp, uint64_t *dist_array,
/* -------------------------------------------------------------- */
if (*dist_array >= shortest_dist_btwn_rgs +
(shortest_dist_btwn_rgs / 4)) {
+ struct gfs2_rindex ri;
+
/* read in the second RG index entry for this subd. */
- gfs2_readi(sdp->md.riinode, (char *)&buf,
- sizeof(struct gfs2_rindex),
- sizeof(struct gfs2_rindex));
- gfs2_rindex_in(&tmpndx, (char *)&buf);
- if (tmpndx.ri_addr > LGFS2_SB_ADDR(sdp) + 1) { /* sanity check */
+ gfs2_readi(sdp->md.riinode, &ri, sizeof(ri), sizeof(ri));
+
+ if (be64_to_cpu(ri.ri_addr) > LGFS2_SB_ADDR(sdp) + 1) { /* sanity check */
log_warn( _("rgrp 2 is damaged: getting dist from index: "));
- *dist_array = tmpndx.ri_addr - (LGFS2_SB_ADDR(sdp) + 1);
+ *dist_array = be64_to_cpu(ri.ri_addr) - (LGFS2_SB_ADDR(sdp) + 1);
log_warn("0x%llx\n", (unsigned long long)*dist_array);
} else {
log_warn( _("rgrp index 2 is damaged: extrapolating dist: "));
@@ -330,13 +327,13 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
for (n = osi_first(&sdp->rgtree); n; n = next) {
next = osi_next(n);
rgd = (struct rgrp_tree *)n;
- if (rgd->ri.ri_addr == blk)
+ if (rgd->rt_addr == blk)
break;
}
- if (rgd && n && osi_next(n) && rgd->ri.ri_addr == blk) {
+ if (rgd && n && osi_next(n) && rgd->rt_addr == blk) {
n = osi_next(n);
next_rgd = (struct rgrp_tree *)n;
- rgrp_dist = next_rgd->ri.ri_addr - rgd->ri.ri_addr;
+ rgrp_dist = next_rgd->rt_addr - rgd->rt_addr;
return rgrp_dist;
}
mega_in_blocks = (1024 * 1024) / sdp->bsize;
@@ -352,13 +349,13 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
skip a few blocks (hopefully no more than 4). */
used_blocks = 0;
length = 0;
- block = prevrgd->ri.ri_addr;
+ block = prevrgd->rt_addr;
first = 1;
found = 0;
while (1) {
if (block >= sdp->device.length)
break;
- if (block >= prevrgd->ri.ri_addr + twogigs)
+ if (block >= prevrgd->rt_addr + twogigs)
break;
bh = bread(sdp, block);
gfs2_meta_header_in(&mh, bh->b_data);
@@ -388,7 +385,7 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
bitmap blocks. Count them all as bitmaps and you'll be
hopelessly lost. */
rgrp_dist = used_blocks + free_blocks + length;
- next_block = prevrgd->ri.ri_addr + rgrp_dist;
+ next_block = prevrgd->rt_addr + rgrp_dist;
/* Now we account for block rounding done by mkfs.gfs2 */
for (b = 0; b <= length + GFS2_NBBY; b++) {
if (next_block + b >= sdp->device.length)
@@ -414,7 +411,7 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
}
if (found) {
log_info(_("rgrp found at 0x%"PRIx64", length=%d, used=%"PRIu64", free=%d\n"),
- prevrgd->ri.ri_addr, length, used_blocks, free_blocks);
+ prevrgd->rt_addr, length, used_blocks, free_blocks);
break;
}
}
@@ -452,7 +449,7 @@ static uint64_t hunt_and_peck(struct gfs2_sbd *sdp, uint64_t blk,
rgrp_dist = AWAY_FROM_BITMAPS; /* Get away from any bitmaps
associated with the previous rgrp */
- block = prevrgd->ri.ri_addr + rgrp_dist;
+ block = prevrgd->rt_addr + rgrp_dist;
/* Now we account for block rounding done by mkfs.gfs2. A rgrp can
be at most 2GB in size, so that's where we call it. We do somewhat
obscure math here to avoid integer overflows. */
@@ -565,7 +562,7 @@ static int rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs, int gfs_grow)
log_crit( _("Can't allocate memory for rgrp repair.\n"));
goto out;
}
- calc_rgd->ri.ri_length = 1;
+ calc_rgd->rt_length = 1;
if (!rg_was_fnd) { /* if not an RG */
/* ------------------------------------------------- */
/* This SHOULD be an RG but isn't. */
@@ -592,26 +589,25 @@ static int rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs, int gfs_grow)
bitmap_was_fnd = !gfs2_check_meta(bh->b_data, GFS2_METATYPE_RB);
brelse(bh);
if (bitmap_was_fnd) /* if a bitmap */
- calc_rgd->ri.ri_length++;
+ calc_rgd->rt_length++;
else
break; /* end of bitmap, so call it quits. */
} /* for subsequent bitmaps */
- calc_rgd->ri.ri_data0 = calc_rgd->ri.ri_addr +
- calc_rgd->ri.ri_length;
+ calc_rgd->rt_data0 = calc_rgd->rt_addr +
+ calc_rgd->rt_length;
if (prev_rgd) {
uint32_t rgblocks;
- prev_rgd->ri.ri_length = rgblocks2bitblocks(sdp->bsize, block_bump, &rgblocks);
- prev_rgd->ri.ri_data = rgblocks;
- prev_rgd->ri.ri_data0 = prev_rgd->ri.ri_addr +
- prev_rgd->ri.ri_length;
- prev_rgd->ri.ri_data -= prev_rgd->ri.ri_data %
+ prev_rgd->rt_length = rgblocks2bitblocks(sdp->bsize, block_bump, &rgblocks);
+ prev_rgd->rt_data = rgblocks;
+ prev_rgd->rt_data0 = prev_rgd->rt_addr +
+ prev_rgd->rt_length;
+ prev_rgd->rt_data -= prev_rgd->rt_data %
GFS2_NBBY;
- prev_rgd->ri.ri_bitbytes = prev_rgd->ri.ri_data /
+ prev_rgd->rt_bitbytes = prev_rgd->rt_data /
GFS2_NBBY;
- log_debug( _("Prev ri_data set to: %lx.\n"),
- (unsigned long)prev_rgd->ri.ri_data);
+ log_debug(_("Prev ri_data set to: 0x%"PRIx32"\n"), prev_rgd->rt_data);
}
number_of_rgs++;
segment_rgs++;
@@ -662,17 +658,15 @@ static int rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs, int gfs_grow)
/* If we got to the end of the fs, we still need to fix the */
/* allocation information for the very last RG. */
/* ----------------------------------------------------------------- */
- if (prev_rgd && !prev_rgd->ri.ri_data) {
+ if (prev_rgd && !prev_rgd->rt_data) {
uint32_t rgblocks;
- prev_rgd->ri.ri_length = rgblocks2bitblocks(sdp->bsize, block_bump, &rgblocks);
- prev_rgd->ri.ri_data0 = prev_rgd->ri.ri_addr +
- prev_rgd->ri.ri_length;
- prev_rgd->ri.ri_data = rgblocks;
- prev_rgd->ri.ri_data -= prev_rgd->ri.ri_data % GFS2_NBBY;
- prev_rgd->ri.ri_bitbytes = prev_rgd->ri.ri_data / GFS2_NBBY;
- log_debug( _("Prev ri_data set to: %lx.\n"),
- (unsigned long)prev_rgd->ri.ri_data);
+ prev_rgd->rt_length = rgblocks2bitblocks(sdp->bsize, block_bump, &rgblocks);
+ prev_rgd->rt_data0 = prev_rgd->rt_addr + prev_rgd->rt_length;
+ prev_rgd->rt_data = rgblocks;
+ prev_rgd->rt_data -= prev_rgd->rt_data % GFS2_NBBY;
+ prev_rgd->rt_bitbytes = prev_rgd->rt_data / GFS2_NBBY;
+ log_debug(_("Prev ri_data set to: 0x%"PRIx32"\n"), prev_rgd->rt_data);
prev_rgd = NULL; /* make sure we don't use it later */
}
/* ---------------------------------------------- */
@@ -683,9 +677,9 @@ static int rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs, int gfs_grow)
next = osi_next(n);
calc_rgd = (struct rgrp_tree *)n;
log_debug("%d: 0x%"PRIx64"/%"PRIx32"/0x%"PRIx64"/0x%"PRIx32"/0x%"PRIx32"\n",
- rgi + 1, calc_rgd->ri.ri_addr, calc_rgd->ri.ri_length,
- calc_rgd->ri.ri_data0, calc_rgd->ri.ri_data,
- calc_rgd->ri.ri_bitbytes);
+ rgi + 1, calc_rgd->rt_addr, calc_rgd->rt_length,
+ calc_rgd->rt_data0, calc_rgd->rt_data,
+ calc_rgd->rt_bitbytes);
}
*num_rgs = number_of_rgs;
error = 0;
@@ -783,10 +777,10 @@ static void compute_rgrp_layout(struct gfs2_sbd *sdp, struct osi_root *rgtree, i
rl->length, rl->length);
rlast = rl;
}
- rlast->start = rlast->ri.ri_addr;
+ rlast->start = rlast->rt_addr;
rglength = rgrp_size(rlast);
rlast->length = rglength;
- old_length = rlast->ri.ri_addr + rglength;
+ old_length = rlast->rt_addr + rglength;
new_chunk = dev->length - old_length;
sdp->new_rgrps = new_chunk / rglength;
nrgrp = rgrp + sdp->new_rgrps;
@@ -821,32 +815,25 @@ static int calc_rgrps(struct gfs2_sbd *sdp)
struct osi_node *n, *next = NULL;
struct rgrp_tree *rl;
uint32_t rgblocks, bitblocks;
- struct gfs2_rindex *ri;
for (n = osi_first(&sdp->rgcalc); n; n = next) {
next = osi_next(n);
rl = (struct rgrp_tree *)n;
- ri = &rl->ri;
bitblocks = rgblocks2bitblocks(sdp->bsize, rl->length, &rgblocks);
- ri->ri_addr = rl->start;
- ri->ri_length = bitblocks;
- ri->ri_data0 = rl->start + bitblocks;
- ri->ri_data = rgblocks;
- ri->ri_bitbytes = rgblocks / GFS2_NBBY;
-
- memset(&rl->rg, 0, sizeof(rl->rg));
- rl->rg.rg_header.mh_magic = GFS2_MAGIC;
- rl->rg.rg_header.mh_type = GFS2_METATYPE_RG;
- rl->rg.rg_header.mh_format = GFS2_FORMAT_RG;
- rl->rg.rg_free = rgblocks;
+ rl->rt_addr = rl->start;
+ rl->rt_length = bitblocks;
+ rl->rt_data0 = rl->start + bitblocks;
+ rl->rt_data = rgblocks;
+ rl->rt_bitbytes = rgblocks / GFS2_NBBY;
+ rl->rt_free = rgblocks;
if (gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, rl))
return -1;
sdp->blks_total += rgblocks;
- sdp->fssize = ri->ri_data0 + ri->ri_data;
+ sdp->fssize = rl->rt_data0 + rl->rt_data;
}
return 0;
}
@@ -910,15 +897,13 @@ static int gfs2_rindex_calculate(struct gfs2_sbd *sdp, int *num_rgs)
static int rewrite_rg_block(struct gfs2_sbd *sdp, struct rgrp_tree *rg,
uint64_t errblock)
{
- int x = errblock - rg->ri.ri_addr;
+ int x = errblock - rg->rt_addr;
const char *typedesc = x ? "GFS2_METATYPE_RB" : "GFS2_METATYPE_RG";
ssize_t ret;
char *buf;
- log_err( _("Block #%lld (0x%llx) (%d of %d) is not %s.\n"),
- (unsigned long long)rg->ri.ri_addr + x,
- (unsigned long long)rg->ri.ri_addr + x,
- (int)x+1, (int)rg->ri.ri_length, typedesc);
+ log_err(_("Block #%"PRIu64" (0x%"PRIx64") (%d of %"PRIu32") is not %s.\n"),
+ rg->rt_addr + x, rg->rt_addr + x, x+1, rg->rt_length, typedesc);
if (!query( _("Fix the resource group? (y/n)")))
return 1;
@@ -944,18 +929,11 @@ static int rewrite_rg_block(struct gfs2_sbd *sdp, struct rgrp_tree *rg,
};
gfs2_meta_header_out(&mh, buf);
} else {
+ rg->rt_free = rg->rt_data;
if (sdp->gfs1)
- memset(&rg->rg, 0, sizeof(struct gfs_rgrp));
- else
- memset(&rg->rg, 0, sizeof(struct gfs2_rgrp));
- rg->rg.rg_header.mh_magic = GFS2_MAGIC;
- rg->rg.rg_header.mh_type = GFS2_METATYPE_RG;
- rg->rg.rg_header.mh_format = GFS2_FORMAT_RG;
- rg->rg.rg_free = rg->ri.ri_data;
- if (sdp->gfs1)
- gfs_rgrp_out((struct gfs_rgrp *)&rg->rg, buf);
+ lgfs2_gfs_rgrp_out(rg, buf);
else
- gfs2_rgrp_out(&rg->rg, buf);
+ lgfs2_rgrp_out(rg, buf);
}
ret = pwrite(sdp->device_fd, buf, sdp->bsize, errblock * sdp->bsize);
if (ret != sdp->bsize) {
@@ -982,15 +960,22 @@ static int expect_rindex_sanity(struct gfs2_sbd *sdp, int *num_rgs)
for (n = osi_first(&sdp->rgtree); n; n = next) {
next = osi_next(n);
rgd = (struct rgrp_tree *)n;
- exp = rgrp_insert(&sdp->rgcalc, rgd->ri.ri_addr);
+ exp = rgrp_insert(&sdp->rgcalc, rgd->rt_addr);
if (exp == NULL) {
fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
exit(-1);
}
exp->start = rgd->start;
exp->length = rgd->length;
- memcpy(&exp->ri, &rgd->ri, sizeof(exp->ri));
- memcpy(&exp->rg, &rgd->rg, sizeof(exp->rg));
+ exp->rt_data0 = rgd->rt_data0;
+ exp->rt_data = rgd->rt_data;
+ exp->rt_length = rgd->rt_length;
+ exp->rt_bitbytes = rgd->rt_bitbytes;
+ exp->rt_flags = rgd->rt_flags;
+ exp->rt_free = rgd->rt_free;
+ exp->rt_igeneration = rgd->rt_igeneration;
+ exp->rt_dinodes = rgd->rt_dinodes;
+ exp->rt_skip = rgd->rt_skip;
exp->bits = NULL;
gfs2_compute_bitstructs(sdp->sd_sb.sb_bsize, exp);
}
@@ -1127,26 +1112,26 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
expected = (struct rgrp_tree *)e;
actual = (struct rgrp_tree *)n;
- if (actual->ri.ri_addr < expected->ri.ri_addr) {
+ if (actual->rt_addr < expected->rt_addr) {
n = next;
discrepancies++;
log_info(_("%d addr: 0x%"PRIx64" < 0x%"PRIx64" * mismatch\n"),
- rg + 1, actual->ri.ri_addr, expected->ri.ri_addr);
+ rg + 1, actual->rt_addr, expected->rt_addr);
continue;
- } else if (expected->ri.ri_addr < actual->ri.ri_addr) {
+ } else if (expected->rt_addr < actual->rt_addr) {
e = enext;
discrepancies++;
log_info(_("%d addr: 0x%"PRIx64" > 0x%"PRIx64" * mismatch\n"),
- rg + 1, actual->ri.ri_addr, expected->ri.ri_addr);
+ rg + 1, actual->rt_addr, expected->rt_addr);
continue;
}
- if (!ri_equal(actual->ri, expected->ri, ri_length) ||
- !ri_equal(actual->ri, expected->ri, ri_data0) ||
- !ri_equal(actual->ri, expected->ri, ri_data) ||
- !ri_equal(actual->ri, expected->ri, ri_bitbytes)) {
+ if (actual->rt_length != expected->rt_length ||
+ actual->rt_data0 != expected->rt_data0 ||
+ actual->rt_data != expected->rt_data ||
+ actual->rt_bitbytes != expected->rt_bitbytes) {
discrepancies++;
log_info(_("%d addr: 0x%"PRIx64" 0x%"PRIx64" * has mismatch\n"),
- rg + 1, actual->ri.ri_addr, expected->ri.ri_addr);
+ rg + 1, actual->rt_addr, expected->rt_addr);
}
n = next;
e = enext;
@@ -1187,10 +1172,10 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
If we ran out of actual rindex entries due to rindex
damage, fill in a new one with the expected values. */
if (!n || /* end of actual rindex */
- expected->ri.ri_addr < actual->ri.ri_addr) {
+ expected->rt_addr < actual->rt_addr) {
log_err(_("Entry missing from rindex: 0x%"PRIx64"\n"),
- expected->ri.ri_addr);
- actual = rgrp_insert(&sdp->rgtree, expected->ri.ri_addr);
+ expected->rt_addr);
+ actual = rgrp_insert(&sdp->rgtree, expected->rt_addr);
if (!actual) {
log_err(_("Out of memory!\n"));
break;
@@ -1199,30 +1184,24 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
next = n; /* Ensure that the old actual gets checked
against a new expected, since we added */
} else {
- ri_compare(rg, actual->ri, expected->ri, ri_addr,
- "llx", unsigned long long);
- ri_compare(rg, actual->ri, expected->ri, ri_length,
- "lx", unsigned long);
- ri_compare(rg, actual->ri, expected->ri, ri_data0,
- "llx", unsigned long long);
- ri_compare(rg, actual->ri, expected->ri, ri_data,
- "lx", unsigned long);
- ri_compare(rg, actual->ri, expected->ri, ri_bitbytes,
- "lx", unsigned long);
+ ri_compare(rg, actual, expected, rt_addr, PRIx64);
+ ri_compare(rg, actual, expected, rt_length, PRIx32);
+ ri_compare(rg, actual, expected, rt_data0, PRIx64);
+ ri_compare(rg, actual, expected, rt_data, PRIx32);
+ ri_compare(rg, actual, expected, rt_bitbytes, PRIx32);
}
/* If we modified the index, write it back to disk. */
if (rindex_modified) {
if (query( _("Fix the index? (y/n)"))) {
- gfs2_rindex_out(&expected->ri, (char *)&buf);
+ lgfs2_rindex_out(expected, (char *)&buf);
gfs2_writei(sdp->md.riinode, (char *)&buf,
rg * sizeof(struct gfs2_rindex),
sizeof(struct gfs2_rindex));
- actual->ri.ri_addr = expected->ri.ri_addr;
- actual->ri.ri_length = expected->ri.ri_length;
- actual->ri.ri_data0 = expected->ri.ri_data0;
- actual->ri.ri_data = expected->ri.ri_data;
- actual->ri.ri_bitbytes =
- expected->ri.ri_bitbytes;
+ actual->rt_addr = expected->rt_addr;
+ actual->rt_length = expected->rt_length;
+ actual->rt_data0 = expected->rt_data0;
+ actual->rt_data = expected->rt_data;
+ actual->rt_bitbytes = expected->rt_bitbytes;
/* If our rindex was hosed, ri_length is bad */
/* Therefore, gfs2_compute_bitstructs might */
/* have malloced the wrong length for bitmap */
@@ -1269,7 +1248,7 @@ int rg_repair(struct gfs2_sbd *sdp, int trust_lvl, int *ok)
break;
}
i++;
- } while (i < rgd->ri.ri_length);
+ } while (i < rgd->rt_length);
}
gfs2_rgrp_free(sdp, &sdp->rgcalc);
gfs2_rgrp_free(sdp, &sdp->rgtree);
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index 84022814..dfc4512c 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -544,7 +544,6 @@ uint64_t find_free_blk(struct gfs2_sbd *sdp)
{
struct osi_node *n, *next = NULL;
struct rgrp_tree *rl = NULL;
- struct gfs2_rindex *ri;
struct gfs2_rgrp *rg;
unsigned int block, bn = 0, x = 0, y = 0;
unsigned int state;
@@ -553,17 +552,14 @@ uint64_t find_free_blk(struct gfs2_sbd *sdp)
for (n = osi_first(&sdp->rgtree); n; n = next) {
next = osi_next(n);
rl = (struct rgrp_tree *)n;
- if (rl->rg.rg_free)
+ if (rl->rt_free)
break;
}
if (n == NULL)
return 0;
- ri = &rl->ri;
- rg = &rl->rg;
-
- for (block = 0; block < ri->ri_length; block++) {
+ for (block = 0; block < rl->rt_length; block++) {
char *buf = rl->bits[block].bi_data;
x = (block) ? sizeof(struct gfs2_meta_header) : sizeof(struct gfs2_rgrp);
@@ -571,7 +567,7 @@ uint64_t find_free_blk(struct gfs2_sbd *sdp)
for (y = 0; y < GFS2_NBBY; y++) {
state = (buf[x] >> (GFS2_BIT_SIZE * y)) & 0x03;
if (state == GFS2_BLKST_FREE)
- return ri->ri_data0 + bn;
+ return rl->rt_data0 + bn;
bn++;
}
}
diff --git a/gfs2/libgfs2/check_rgrp.c b/gfs2/libgfs2/check_rgrp.c
index 98650e24..dd31a341 100644
--- a/gfs2/libgfs2/check_rgrp.c
+++ b/gfs2/libgfs2/check_rgrp.c
@@ -71,7 +71,7 @@ START_TEST(test_rbm_find_good)
rbm.rgd = lgfs2_rgrp_first(rgs);
/* Check that extent sizes up to the whole rg can be found */
- for (minext = 1; minext <= rbm.rgd->ri.ri_data; minext++) {
+ for (minext = 1; minext <= rbm.rgd->rt_data; minext++) {
int err;
uint64_t addr;
@@ -81,7 +81,7 @@ START_TEST(test_rbm_find_good)
ck_assert_int_eq(err, 0);
addr = lgfs2_rbm_to_block(&rbm);
- ck_assert(addr == rbm.rgd->ri.ri_data0);
+ ck_assert(addr == rbm.rgd->rt_data0);
}
}
END_TEST
@@ -94,7 +94,7 @@ START_TEST(test_rbm_find_bad)
lgfs2_rgrps_t rgs = tc_rgrps;
rbm.rgd = lgfs2_rgrp_first(rgs);
- minext = rbm.rgd->ri.ri_data + 1;
+ minext = rbm.rgd->rt_data + 1;
err = lgfs2_rbm_find(&rbm, GFS2_BLKST_FREE, &minext);
ck_assert_int_eq(err, 1);
@@ -114,42 +114,45 @@ START_TEST(test_rbm_find_lastblock)
rbm.rgd = rg = lgfs2_rgrp_first(rgs);
/* Flag all blocks as allocated... */
- for (i = 0; i < rg->ri.ri_length; i++)
+ for (i = 0; i < rg->rt_length; i++)
memset(rg->bits[i].bi_data, 0xff, rgs->sdp->bsize);
/* ...except the final one */
- err = gfs2_set_bitmap(rg, rg->ri.ri_data0 + rg->ri.ri_data - 1, GFS2_BLKST_FREE);
+ err = gfs2_set_bitmap(rg, rg->rt_data0 + rg->rt_data - 1, GFS2_BLKST_FREE);
ck_assert_int_eq(err, 0);
err = lgfs2_rbm_find(&rbm, GFS2_BLKST_FREE, &minext);
ck_assert_int_eq(err, 0);
addr = lgfs2_rbm_to_block(&rbm);
- ck_assert(addr == (rg->ri.ri_data0 + rg->ri.ri_data - 1));
+ ck_assert(addr == (rg->rt_data0 + rg->rt_data - 1));
}
END_TEST
START_TEST(test_rgrps_write_final)
{
lgfs2_rgrp_t rg = lgfs2_rgrp_last(tc_rgrps);
- uint64_t addr = lgfs2_rgrp_index(rg)->ri_addr;
struct gfs2_sbd *sdp = tc_rgrps->sdp;
+ struct gfs2_rindex ri;
struct gfs2_rgrp rgrp;
+ uint64_t addr;
char *buf;
+ lgfs2_rindex_out(rg, &ri);
+ addr = be64_to_cpu(ri.ri_addr);
+
buf = malloc(4096);
ck_assert(buf != NULL);
memset(buf, 0xff, sizeof(rgrp));
ck_assert(pwrite(sdp->device_fd, buf, 4096, addr * 4096) == 4096);
ck_assert(lgfs2_rgrps_write_final(sdp->device_fd, tc_rgrps) == 0);
- ck_assert(pread(sdp->device_fd, buf, 4096, addr * 4096) == 4096);
- gfs2_rgrp_in(&rgrp, buf);
- free(buf);
+ ck_assert(pread(sdp->device_fd, &rgrp, sizeof(rgrp), addr * 4096) == sizeof(rgrp));
- ck_assert(rgrp.rg_header.mh_magic == GFS2_MAGIC);
- ck_assert(rgrp.rg_header.mh_type == GFS2_METATYPE_RG);
+ ck_assert(be32_to_cpu(rgrp.rg_header.mh_magic) == GFS2_MAGIC);
+ ck_assert(be32_to_cpu(rgrp.rg_header.mh_type) == GFS2_METATYPE_RG);
ck_assert(rgrp.rg_skip == 0);
+ free(buf);
ck_assert(lgfs2_rgrps_write_final(-1, tc_rgrps) == -1);
}
diff --git a/gfs2/libgfs2/fs_bits.c b/gfs2/libgfs2/fs_bits.c
index f600f6eb..72d2b006 100644
--- a/gfs2/libgfs2/fs_bits.c
+++ b/gfs2/libgfs2/fs_bits.c
@@ -136,11 +136,11 @@ int gfs2_set_bitmap(lgfs2_rgrp_t rgd, uint64_t blkno, int state)
if ((state < GFS2_BLKST_FREE) || (state > GFS2_BLKST_DINODE))
return -1;
- if(!rgd || blkno < rgd->ri.ri_data0)
+ if(!rgd || blkno < rgd->rt_data0)
return -1;
- rgrp_block = (uint32_t)(blkno - rgd->ri.ri_data0);
- for(buf= 0; buf < rgd->ri.ri_length; buf++){
+ rgrp_block = (uint32_t)(blkno - rgd->rt_data0);
+ for(buf= 0; buf < rgd->rt_length; buf++){
bits = &(rgd->bits[buf]);
if(rgrp_block < ((bits->bi_start + bits->bi_len)*GFS2_NBBY))
break;
@@ -189,12 +189,12 @@ int lgfs2_get_bitmap(struct gfs2_sbd *sdp, uint64_t blkno, struct rgrp_tree *rgd
return -1;
}
- offset = blkno - rgd->ri.ri_data0;
+ offset = blkno - rgd->rt_data0;
if (offset > UINT_MAX) {
errno = EINVAL;
return -1;
}
- if (offset >= rgd->ri.ri_data0 + rgd->ri.ri_data) {
+ if (offset >= rgd->rt_data0 + rgd->rt_data) {
errno = E2BIG;
return -1;
}
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index ccb75df3..c0569257 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -117,19 +117,19 @@ static uint64_t find_free_block(struct rgrp_tree *rgd)
unsigned bm;
uint64_t blkno = 0;
- if (rgd == NULL || rgd->rg.rg_free == 0) {
+ if (rgd == NULL || rgd->rt_free == 0) {
errno = ENOSPC;
return 0;
}
- for (bm = 0; bm < rgd->ri.ri_length; bm++) {
+ for (bm = 0; bm < rgd->rt_length; bm++) {
unsigned long blk = 0;
struct gfs2_bitmap *bits = &rgd->bits[bm];
blk = gfs2_bitfit((uint8_t *)bits->bi_data + bits->bi_offset,
bits->bi_len, blk, GFS2_BLKST_FREE);
if (blk != BFITNOENT) {
- blkno = blk + (bits->bi_start * GFS2_NBBY) + rgd->ri.ri_data0;
+ blkno = blk + (bits->bi_start * GFS2_NBBY) + rgd->rt_data0;
break;
}
}
@@ -145,19 +145,17 @@ static int blk_alloc_in_rg(struct gfs2_sbd *sdp, unsigned state, struct rgrp_tre
return -1;
if (state == GFS2_BLKST_DINODE) {
- struct gfs_rgrp *gfs1rg = (struct gfs_rgrp *)&rgd->rg;
-
if (dinode)
- rgd->rg.rg_dinodes++;
+ rgd->rt_dinodes++;
else if (sdp->gfs1)
- gfs1rg->rg_usedmeta++;
+ rgd->rt_usedmeta++;
}
- rgd->rg.rg_free--;
+ rgd->rt_free--;
if (sdp->gfs1)
- gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data);
else
- gfs2_rgrp_out(&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_rgrp_out(rgd, rgd->bits[0].bi_data);
rgd->bits[0].bi_modified = 1;
sdp->blks_alloced++;
return 0;
@@ -178,7 +176,7 @@ static int block_alloc(struct gfs2_sbd *sdp, const uint64_t blksreq, int state,
for (n = osi_first(&sdp->rgtree); n; n = osi_next(n)) {
rgt = (struct rgrp_tree *)n;
- if (rgt->rg.rg_free >= blksreq)
+ if (rgt->rt_free >= blksreq)
break;
}
if (rgt == NULL)
@@ -350,8 +348,8 @@ int lgfs2_file_alloc(lgfs2_rgrp_t rg, uint64_t di_size, struct gfs2_inode *ip, u
ip->i_height = calc_tree_height(ip, di_size);
ip->i_flags = flags;
- rg->rg.rg_free -= blocks;
- rg->rg.rg_dinodes += 1;
+ rg->rt_free -= blocks;
+ rg->rt_dinodes += 1;
sdp->dinodes_alloced++;
sdp->blks_alloced += blocks;
@@ -1898,11 +1896,11 @@ void gfs2_free_block(struct gfs2_sbd *sdp, uint64_t block)
rgd = gfs2_blk2rgrpd(sdp, block); /* find the rg for indir block */
if (rgd) {
gfs2_set_bitmap(rgd, block, GFS2_BLKST_FREE);
- rgd->rg.rg_free++; /* adjust the free count */
+ rgd->rt_free++; /* adjust the free count */
if (sdp->gfs1)
- gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data);
else
- gfs2_rgrp_out(&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_rgrp_out(rgd, rgd->bits[0].bi_data);
rgd->bits[0].bi_modified = 1;
sdp->blks_alloced--;
}
@@ -1967,12 +1965,12 @@ int gfs2_freedi(struct gfs2_sbd *sdp, uint64_t diblock)
/* inode_put deallocated the extra block used by the disk inode, */
/* so adjust it in the superblock struct */
sdp->blks_alloced--;
- rgd->rg.rg_free++;
- rgd->rg.rg_dinodes--;
+ rgd->rt_free++;
+ rgd->rt_dinodes--;
if (sdp->gfs1)
- gfs_rgrp_out((struct gfs_rgrp *)&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_gfs_rgrp_out(rgd, rgd->bits[0].bi_data);
else
- gfs2_rgrp_out(&rgd->rg, rgd->bits[0].bi_data);
+ lgfs2_rgrp_out(rgd, rgd->bits[0].bi_data);
rgd->bits[0].bi_modified = 1;
sdp->dinodes_alloced--;
return 0;
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 6f74ce4d..d1b54a92 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -336,6 +336,20 @@ void gfs_rgrp_in(struct gfs_rgrp *rgrp, const char *buf)
memcpy(rgrp->rg_reserved, str->rg_reserved, 64);
}
+void lgfs2_gfs_rgrp_in(const lgfs2_rgrp_t rg, void *buf)
+{
+ struct gfs_rgrp *r = buf;
+
+ rg->rt_flags = be32_to_cpu(r->rg_flags);
+ rg->rt_free = be32_to_cpu(r->rg_free);
+ rg->rt_useddi = be32_to_cpu(r->rg_useddi);
+ rg->rt_freedi = be32_to_cpu(r->rg_freedi);
+ rg->rt_freedi_list.no_formal_ino = be64_to_cpu(r->rg_freedi_list.no_formal_ino);
+ rg->rt_freedi_list.no_addr = be64_to_cpu(r->rg_freedi_list.no_addr);
+ rg->rt_usedmeta = be32_to_cpu(r->rg_usedmeta);
+ rg->rt_freemeta = be32_to_cpu(r->rg_freemeta);
+}
+
void gfs_rgrp_out(const struct gfs_rgrp *rgrp, char *buf)
{
struct gfs_rgrp *str = (struct gfs_rgrp *)buf;
@@ -351,3 +365,21 @@ void gfs_rgrp_out(const struct gfs_rgrp *rgrp, char *buf)
memcpy(str->rg_reserved, rgrp->rg_reserved, 64);
}
+
+void lgfs2_gfs_rgrp_out(const lgfs2_rgrp_t rg, void *buf)
+{
+ struct gfs_rgrp *r = buf;
+
+ r->rg_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ r->rg_header.mh_type = cpu_to_be32(GFS2_METATYPE_RG);
+ r->rg_header.mh_format = cpu_to_be32(GFS2_FORMAT_RG);
+ r->rg_flags = cpu_to_be32(rg->rt_flags);
+ r->rg_free = cpu_to_be32(rg->rt_free);
+ r->rg_useddi = cpu_to_be32(rg->rt_useddi);
+ r->rg_freedi = cpu_to_be32(rg->rt_freedi);
+ r->rg_freedi_list.no_formal_ino = cpu_to_be64(rg->rt_freedi_list.no_formal_ino);
+ r->rg_freedi_list.no_addr = cpu_to_be64(rg->rt_freedi_list.no_addr);
+ r->rg_usedmeta = cpu_to_be32(rg->rt_usedmeta);
+ r->rg_freemeta = cpu_to_be32(rg->rt_freemeta);
+
+}
diff --git a/gfs2/libgfs2/lang.c b/gfs2/libgfs2/lang.c
index da35b990..3387df57 100644
--- a/gfs2/libgfs2/lang.c
+++ b/gfs2/libgfs2/lang.c
@@ -236,7 +236,7 @@ static uint64_t ast_lookup_rgrp(uint64_t rgnum, struct gfs2_sbd *sbd)
for (n = osi_first(&sbd->rgtree); n != NULL && i > 0; n = osi_next(n), i--);
if (n != NULL && i == 0)
- return ((struct rgrp_tree *)n)->ri.ri_addr;
+ return ((struct rgrp_tree *)n)->rt_addr;
fprintf(stderr, "Resource group number out of range: %"PRIu64"\n", rgnum);
return 0;
}
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index cefb60c8..91f2dcf6 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -177,11 +177,40 @@ struct rgrp_tree {
struct osi_node node;
uint64_t start; /* The offset of the beginning of this resource group */
uint64_t length; /* The length of this resource group */
-
- struct gfs2_rindex ri;
- struct gfs2_rgrp rg;
struct gfs2_bitmap *bits;
lgfs2_rgrps_t rgrps;
+
+ /* Native-endian counterparts of the on-disk rindex struct */
+ uint64_t rt_addr;
+ uint64_t rt_data0;
+ 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;
+ union {
+ struct { /* gfs2 */
+ uint64_t rt_igeneration;
+ uint32_t rt_dinodes;
+ uint32_t rt_skip;
+ };
+ struct { /* gfs1 */
+ uint32_t rt_useddi;
+ uint32_t rt_freedi;
+ struct {
+ uint64_t no_formal_ino;
+ uint64_t no_addr;
+ } rt_freedi_list;
+ uint32_t rt_usedmeta;
+ uint32_t rt_freemeta;
+ };
+ };
};
typedef struct rgrp_tree *lgfs2_rgrp_t;
@@ -190,7 +219,7 @@ extern lgfs2_rgrps_t lgfs2_rgrps_init(struct gfs2_sbd *sdp, uint64_t align, uint
extern void lgfs2_rgrps_free(lgfs2_rgrps_t *rgs);
extern uint64_t lgfs2_rindex_entry_new(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry, uint64_t addr, uint32_t len);
extern unsigned lgfs2_rindex_read_fd(int fd, lgfs2_rgrps_t rgs);
-extern const struct gfs2_rindex *lgfs2_rindex_read_one(struct gfs2_inode *rip, lgfs2_rgrps_t rgs, unsigned i);
+extern lgfs2_rgrp_t lgfs2_rindex_read_one(struct gfs2_inode *rip, lgfs2_rgrps_t rgs, unsigned i);
extern uint64_t lgfs2_rgrp_align_addr(const lgfs2_rgrps_t rgs, uint64_t addr);
extern uint32_t lgfs2_rgrp_align_len(const lgfs2_rgrps_t rgs, uint32_t len);
extern unsigned lgfs2_rgsize_for_data(uint64_t blksreq, unsigned bsize);
@@ -200,8 +229,6 @@ extern int lgfs2_rgrp_bitbuf_alloc(lgfs2_rgrp_t rg);
extern void lgfs2_rgrp_bitbuf_free(lgfs2_rgrp_t rg);
extern int lgfs2_rgrp_write(int fd, lgfs2_rgrp_t rg);
extern int lgfs2_rgrps_write_final(int fd, lgfs2_rgrps_t rgs);
-extern const struct gfs2_rindex *lgfs2_rgrp_index(lgfs2_rgrp_t rg);
-extern const struct gfs2_rgrp *lgfs2_rgrp_rgrp(lgfs2_rgrp_t rg);
extern lgfs2_rgrp_t lgfs2_rgrp_first(lgfs2_rgrps_t rgs);
extern lgfs2_rgrp_t lgfs2_rgrp_last(lgfs2_rgrps_t rgs);
extern lgfs2_rgrp_t lgfs2_rgrp_next(lgfs2_rgrp_t rg);
@@ -666,7 +693,9 @@ extern struct gfs2_inode *lgfs2_gfs_inode_get(struct gfs2_sbd *sdp, char *buf);
extern struct gfs2_inode *lgfs2_gfs_inode_read(struct gfs2_sbd *sdp, uint64_t di_addr);
extern void gfs_jindex_in(struct gfs_jindex *jindex, char *buf);
extern void gfs_rgrp_in(struct gfs_rgrp *rg, const char *buf);
+extern void lgfs2_gfs_rgrp_in(const lgfs2_rgrp_t rg, void *buf);
extern void gfs_rgrp_out(const struct gfs_rgrp *rg, char *buf);
+extern void lgfs2_gfs_rgrp_out(const lgfs2_rgrp_t rg, void *buf);
/* misc.c */
extern int compute_heightsize(unsigned bsize, uint64_t *heightsize,
@@ -702,7 +731,7 @@ extern void gfs2_rgrp_free(struct gfs2_sbd *sdp, struct osi_root *rgrp_tree);
/* figure out the size of the given resource group, in blocks */
static inline unsigned int rgrp_size(struct rgrp_tree *rgrp)
{
- return rgrp->ri.ri_data + rgrp->ri.ri_length;
+ return rgrp->rt_data + rgrp->rt_length;
}
/* structures.c */
@@ -747,10 +776,10 @@ extern void gfs2_meta_header_in(struct gfs2_meta_header *mh, const char *buf);
extern void gfs2_meta_header_out(const struct gfs2_meta_header *mh, char *buf);
extern void gfs2_sb_in(struct gfs2_sb *sb, char *buf);
extern void gfs2_sb_out(const struct gfs2_sb *sb, char *buf);
-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 lgfs2_rindex_in(lgfs2_rgrp_t rg, void *buf);
+extern void lgfs2_rindex_out(const lgfs2_rgrp_t rg, void *buf);
+extern void lgfs2_rgrp_in(lgfs2_rgrp_t rg, void *buf);
+extern void lgfs2_rgrp_out(const lgfs2_rgrp_t rg, void *buf);
extern void lgfs2_dinode_in(struct gfs2_inode *ip, char *buf);
extern void lgfs2_dinode_out(struct gfs2_inode *ip, char *buf);
extern void gfs2_dirent_in(struct gfs2_dirent *de, char *buf);
@@ -762,7 +791,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);
/* 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);
@@ -775,6 +803,7 @@ extern void lgfs2_quota_change_print(void *qcp);
extern void lgfs2_statfs_change_print(void *scp);
extern void lgfs2_ea_header_print(void *eap);
extern void lgfs2_leaf_print(void *lfp);
+extern void lgfs2_rindex_print(void *rip);
extern void lgfs2_rgrp_print(void *rgp);
__END_DECLS
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 59b78c3c..f44b76ee 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -185,77 +185,68 @@ void lgfs2_sb_print(void *sbp)
print_it(" uuid", "%36s", NULL, readable_uuid);
}
-void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf)
+void lgfs2_rindex_in(lgfs2_rgrp_t rg, void *buf)
{
- struct gfs2_rindex *str = (struct gfs2_rindex *)buf;
-
- CPIN_64(ri, str, ri_addr);
- CPIN_32(ri, str, ri_length);
- CPIN_32(ri, str, __pad);
- CPIN_64(ri, str, ri_data0);
- CPIN_32(ri, str, ri_data);
- CPIN_32(ri, str, ri_bitbytes);
- CPIN_08(ri, str, ri_reserved, sizeof(ri->ri_reserved));
+ struct gfs2_rindex *ri = buf;
+
+ rg->rt_addr = be64_to_cpu(ri->ri_addr);
+ rg->rt_length = be32_to_cpu(ri->ri_length);
+ rg->rt_data0 = be64_to_cpu(ri->ri_data0);
+ rg->rt_data = be32_to_cpu(ri->ri_data);
+ rg->rt_bitbytes = be32_to_cpu(ri->ri_bitbytes);
}
-void gfs2_rindex_out(const struct gfs2_rindex *ri, char *buf)
+void lgfs2_rindex_out(const lgfs2_rgrp_t rg, void *buf)
{
- struct gfs2_rindex *str = (struct gfs2_rindex *)buf;
-
- CPOUT_64(ri, str, ri_addr);
- CPOUT_32(ri, str, ri_length);
- str->__pad = 0;
-
- CPOUT_64(ri, str, ri_data0);
- CPOUT_32(ri, str, ri_data);
+ struct gfs2_rindex *ri = buf;
- CPOUT_32(ri, str, ri_bitbytes);
-
- CPOUT_08(ri, str, ri_reserved, sizeof(ri->ri_reserved));
+ ri->ri_addr = cpu_to_be64(rg->rt_addr);
+ ri->ri_length = cpu_to_be32(rg->rt_length);
+ ri->ri_data0 = cpu_to_be64(rg->rt_data0);
+ ri->ri_data = cpu_to_be32(rg->rt_data);
+ ri->ri_bitbytes = cpu_to_be32(rg->rt_bitbytes);
}
-void gfs2_rindex_print(const struct gfs2_rindex *ri)
+void lgfs2_rindex_print(void *rip)
{
- pv(ri, ri_addr, "%"PRIu64, "0x%"PRIx64);
- pv(ri, ri_length, "%"PRIu32, "0x%"PRIx32);
-
- pv(ri, ri_data0, "%"PRIu64, "0x%"PRIx64);
- pv(ri, ri_data, "%"PRIu32, "0x%"PRIx32);
+ struct gfs2_rindex *ri = rip;
- pv(ri, ri_bitbytes, "%"PRIu32, "0x%"PRIx32);
+ printbe64(ri, ri_addr);
+ printbe32(ri, ri_length);
+ printbe64(ri, ri_data0);
+ printbe32(ri, ri_data);
+ printbe32(ri, ri_bitbytes);
}
-void gfs2_rgrp_in(struct gfs2_rgrp *rg, char *buf)
+void lgfs2_rgrp_in(lgfs2_rgrp_t rg, void *buf)
{
- struct gfs2_rgrp *str = (struct gfs2_rgrp *)buf;
-
- gfs2_meta_header_in(&rg->rg_header, buf);
- CPIN_32(rg, str, rg_flags);
- CPIN_32(rg, str, rg_free);
- CPIN_32(rg, str, rg_dinodes);
- CPIN_32(rg, str, rg_skip);
- CPIN_64(rg, str, rg_igeneration);
- CPIN_64(rg, str, rg_data0);
- CPIN_32(rg, str, rg_data);
- CPIN_32(rg, str, rg_bitbytes);
- CPIN_32(rg, str, rg_crc);
- CPIN_08(rg, str, rg_reserved, sizeof(rg->rg_reserved));
+ struct gfs2_rgrp *r = buf;
+
+ rg->rt_flags = be32_to_cpu(r->rg_flags);
+ rg->rt_free = be32_to_cpu(r->rg_free);
+ 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_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 gfs2_rgrp_out(const struct gfs2_rgrp *rg, char *buf)
+void lgfs2_rgrp_out(const lgfs2_rgrp_t rg, void *buf)
{
- struct gfs2_rgrp *str = (struct gfs2_rgrp *)buf;
-
- gfs2_meta_header_out(&rg->rg_header, buf);
- CPOUT_32(rg, str, rg_flags);
- CPOUT_32(rg, str, rg_free);
- CPOUT_32(rg, str, rg_dinodes);
- CPOUT_32(rg, str, rg_skip);
- CPOUT_64(rg, str, rg_igeneration);
- CPOUT_64(rg, str, rg_data0);
- CPOUT_32(rg, str, rg_data);
- CPOUT_32(rg, str, rg_bitbytes);
- CPOUT_08(rg, str, rg_reserved, sizeof(rg->rg_reserved));
+ struct gfs2_rgrp *r = buf;
+
+ r->rg_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
+ r->rg_header.mh_type = cpu_to_be32(GFS2_METATYPE_RG);
+ r->rg_header.mh_format = cpu_to_be32(GFS2_FORMAT_RG);
+ r->rg_flags = cpu_to_be32(rg->rt_flags);
+ r->rg_free = cpu_to_be32(rg->rt_free);
+ 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_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);
}
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index aa5eadf2..96789ff4 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -20,13 +20,13 @@ static void compute_bitmaps(lgfs2_rgrp_t rg, const unsigned bsize)
rg->bits[0].bi_start = 0;
rg->bits[0].bi_len = bsize - sizeof(struct gfs2_rgrp);
- for (x = 1; x < rg->ri.ri_length; x++) {
+ for (x = 1; x < rg->rt_length; x++) {
rg->bits[x].bi_offset = sizeof(struct gfs2_meta_header);
rg->bits[x].bi_start = rg->bits[x - 1].bi_start + rg->bits[x - 1].bi_len;
rg->bits[x].bi_len = bsize - sizeof(struct gfs2_meta_header);
}
x--;
- rg->bits[x].bi_len = rg->ri.ri_bitbytes - rg->bits[x].bi_start;
+ rg->bits[x].bi_len = rg->rt_bitbytes - rg->bits[x].bi_start;
}
/**
@@ -37,7 +37,7 @@ static void compute_bitmaps(lgfs2_rgrp_t rg, const unsigned bsize)
*/
int gfs2_compute_bitstructs(const uint32_t bsize, struct rgrp_tree *rgd)
{
- uint32_t length = rgd->ri.ri_length;
+ uint32_t length = rgd->rt_length;
uint32_t bytes_left;
int ownbits = 0;
@@ -59,14 +59,14 @@ int gfs2_compute_bitstructs(const uint32_t bsize, struct rgrp_tree *rgd)
}
compute_bitmaps(rgd, bsize);
- bytes_left = rgd->ri.ri_bitbytes - (rgd->bits[rgd->ri.ri_length - 1].bi_start +
- rgd->bits[rgd->ri.ri_length - 1].bi_len);
+ bytes_left = rgd->rt_bitbytes - (rgd->bits[rgd->rt_length - 1].bi_start +
+ rgd->bits[rgd->rt_length - 1].bi_len);
errno = EINVAL;
if(bytes_left)
goto errbits;
if((rgd->bits[length - 1].bi_start +
- rgd->bits[length - 1].bi_len) * GFS2_NBBY != rgd->ri.ri_data)
+ rgd->bits[length - 1].bi_len) * GFS2_NBBY != rgd->rt_data)
goto errbits;
return 0;
@@ -90,9 +90,9 @@ struct rgrp_tree *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, uint64_t blk)
{
struct rgrp_tree *rgd = (struct rgrp_tree *)sdp->rgtree.osi_node;
while (rgd) {
- if (blk < rgd->ri.ri_addr)
+ if (blk < rgd->rt_addr)
rgd = (struct rgrp_tree *)rgd->node.osi_left;
- else if (blk >= rgd->ri.ri_data0 + rgd->ri.ri_data)
+ else if (blk >= rgd->rt_data0 + rgd->rt_data)
rgd = (struct rgrp_tree *)rgd->node.osi_right;
else
return rgd;
@@ -109,7 +109,7 @@ struct rgrp_tree *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, uint64_t blk)
int lgfs2_rgrp_bitbuf_alloc(lgfs2_rgrp_t rg)
{
struct gfs2_sbd *sdp = rg->rgrps->sdp;
- size_t len = rg->ri.ri_length * sdp->bsize;
+ size_t len = rg->rt_length * sdp->bsize;
unsigned long io_align = sdp->bsize;
unsigned i;
char *bufs;
@@ -124,7 +124,7 @@ int lgfs2_rgrp_bitbuf_alloc(lgfs2_rgrp_t rg)
}
memset(bufs, 0, len);
- for (i = 0; i < rg->ri.ri_length; i++) {
+ for (i = 0; i < rg->rt_length; i++) {
rg->bits[i].bi_data = bufs + (i * sdp->bsize);
rg->bits[i].bi_modified = 0;
}
@@ -143,7 +143,7 @@ void lgfs2_rgrp_bitbuf_free(lgfs2_rgrp_t rg)
unsigned i;
free(rg->bits[0].bi_data);
- for (i = 0; i < rg->ri.ri_length; i++) {
+ for (i = 0; i < rg->rt_length; i++) {
rg->bits[i].bi_data = NULL;
rg->bits[i].bi_modified = 0;
}
@@ -189,11 +189,11 @@ void lgfs2_rgrp_crc_set(char *buf)
*/
uint64_t gfs2_rgrp_read(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
{
- unsigned length = rgd->ri.ri_length * sdp->bsize;
- off_t offset = rgd->ri.ri_addr * sdp->bsize;
+ unsigned length = rgd->rt_length * sdp->bsize;
+ off_t offset = rgd->rt_addr * sdp->bsize;
char *buf;
- if (length == 0 || gfs2_check_range(sdp, rgd->ri.ri_addr))
+ if (length == 0 || gfs2_check_range(sdp, rgd->rt_addr))
return -1;
buf = calloc(1, length);
@@ -205,23 +205,24 @@ uint64_t gfs2_rgrp_read(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
return -1;
}
- for (unsigned i = 0; i < rgd->ri.ri_length; i++) {
+ for (unsigned i = 0; i < rgd->rt_length; i++) {
int mtype = (i ? GFS2_METATYPE_RB : GFS2_METATYPE_RG);
rgd->bits[i].bi_data = buf + (i * sdp->bsize);
if (gfs2_check_meta(rgd->bits[i].bi_data, mtype)) {
free(buf);
- return rgd->ri.ri_addr + i;
+ rgd->bits[0].bi_data = NULL;
+ return rgd->rt_addr + i;
}
}
if (sdp->gfs1)
- gfs_rgrp_in((struct gfs_rgrp *)&rgd->rg, buf);
+ lgfs2_gfs_rgrp_in(rgd, buf);
else {
if (lgfs2_rgrp_crc_check(buf)) {
free(buf);
- return rgd->ri.ri_addr;
+ return rgd->rt_addr;
}
- gfs2_rgrp_in(&rgd->rg, buf);
+ lgfs2_rgrp_in(rgd, buf);
}
return 0;
}
@@ -230,8 +231,8 @@ void gfs2_rgrp_relse(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
{
if (rgd->bits == NULL)
return;
- for (unsigned i = 0; i < rgd->ri.ri_length; i++) {
- off_t offset = sdp->bsize * (rgd->ri.ri_addr + i);
+ for (unsigned i = 0; i < rgd->rt_length; i++) {
+ off_t offset = sdp->bsize * (rgd->rt_addr + i);
ssize_t ret;
if (rgd->bits[i].bi_data == NULL || !rgd->bits[i].bi_modified)
@@ -240,12 +241,12 @@ void gfs2_rgrp_relse(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
ret = pwrite(sdp->device_fd, rgd->bits[i].bi_data, sdp->bsize, offset);
if (ret != sdp->bsize) {
fprintf(stderr, "Failed to write modified resource group at block %"PRIu64": %s\n",
- (uint64_t)rgd->ri.ri_addr, strerror(errno));
+ rgd->rt_addr, strerror(errno));
}
rgd->bits[i].bi_modified = 0;
}
free(rgd->bits[0].bi_data);
- for (unsigned i = 0; i < rgd->ri.ri_length; i++)
+ for (unsigned i = 0; i < rgd->rt_length; i++)
rgd->bits[i].bi_data = NULL;
}
@@ -259,9 +260,9 @@ struct rgrp_tree *rgrp_insert(struct osi_root *rgtree, uint64_t rgblock)
struct rgrp_tree *cur = (struct rgrp_tree *)*newn;
parent = *newn;
- if (rgblock < cur->ri.ri_addr)
+ if (rgblock < cur->rt_addr)
newn = &((*newn)->osi_left);
- else if (rgblock > cur->ri.ri_addr)
+ else if (rgblock > cur->rt_addr)
newn = &((*newn)->osi_right);
else
return cur;
@@ -271,7 +272,7 @@ struct rgrp_tree *rgrp_insert(struct osi_root *rgtree, uint64_t rgblock)
if (!data)
return NULL;
/* Add new node and rebalance tree. */
- data->ri.ri_addr = rgblock;
+ data->rt_addr = rgblock;
osi_link_node(&data->node, parent, newn);
osi_insert_color(&data->node, rgtree);
@@ -440,7 +441,6 @@ lgfs2_rgrps_t lgfs2_rgrps_init(struct gfs2_sbd *sdp, uint64_t align, uint64_t of
unsigned lgfs2_rindex_read_fd(int fd, lgfs2_rgrps_t rgs)
{
unsigned count = 0;
- char buf[sizeof(struct gfs2_rindex)];
errno = EINVAL;
if (fd < 0 || rgs == NULL)
@@ -449,14 +449,13 @@ unsigned lgfs2_rindex_read_fd(int fd, lgfs2_rgrps_t rgs)
while (1) {
lgfs2_rgrp_t rg;
struct gfs2_rindex ri;
- ssize_t ret = read(fd, buf, sizeof(struct gfs2_rindex));
+ ssize_t ret = read(fd, &ri, sizeof(ri));
if (ret == 0)
break;
- if (ret != sizeof(struct gfs2_rindex))
+ if (ret != sizeof(ri))
return 0;
- gfs2_rindex_in(&ri, buf);
rg = lgfs2_rgrps_append(rgs, &ri, 0);
if (rg == NULL)
return 0;
@@ -473,10 +472,9 @@ unsigned lgfs2_rindex_read_fd(int fd, lgfs2_rgrps_t rgs)
* Returns the new rindex entry added to the set or NULL on error with errno
* set.
*/
-const struct gfs2_rindex *lgfs2_rindex_read_one(struct gfs2_inode *rip, lgfs2_rgrps_t rgs, unsigned i)
+lgfs2_rgrp_t lgfs2_rindex_read_one(struct gfs2_inode *rip, lgfs2_rgrps_t rgs, unsigned i)
{
uint64_t off = i * sizeof(struct gfs2_rindex);
- char buf[sizeof(struct gfs2_rindex)];
struct gfs2_rindex ri;
lgfs2_rgrp_t rg;
int ret;
@@ -485,16 +483,15 @@ const struct gfs2_rindex *lgfs2_rindex_read_one(struct gfs2_inode *rip, lgfs2_rg
if (rip == NULL || rgs == NULL)
return NULL;
- ret = gfs2_readi(rip, buf, off, sizeof(struct gfs2_rindex));
+ ret = gfs2_readi(rip, &ri, off, sizeof(struct gfs2_rindex));
if (ret != sizeof(struct gfs2_rindex))
return NULL;
- gfs2_rindex_in(&ri, buf);
rg = lgfs2_rgrps_append(rgs, &ri, 0);
if (rg == NULL)
return NULL;
- return &rg->ri;
+ return rg;
}
/**
@@ -510,7 +507,7 @@ void lgfs2_rgrps_free(lgfs2_rgrps_t *rgs)
while ((rg = (struct rgrp_tree *)osi_first(tree))) {
int i;
free(rg->bits[0].bi_data);
- for (i = 0; i < rg->ri.ri_length; i++) {
+ for (i = 0; i < rg->rt_length; i++) {
rg->bits[i].bi_data = NULL;
}
osi_erase(&rg->node, tree);
@@ -560,6 +557,7 @@ uint32_t rgblocks2bitblocks(const unsigned int bsize, const uint32_t rgblocks, u
uint64_t lgfs2_rindex_entry_new(lgfs2_rgrps_t rgs, struct gfs2_rindex *ri, uint64_t addr, uint32_t len)
{
struct rg_spec *spec = rgs->plan->rg_specs;
+ uint32_t ri_length, ri_data;
int plan = -1;
errno = EINVAL;
if (!ri)
@@ -581,34 +579,16 @@ uint64_t lgfs2_rindex_entry_new(lgfs2_rgrps_t rgs, struct gfs2_rindex *ri, uint6
if (addr + len > rgs->sdp->device.length)
return 0;
- ri->ri_addr = addr;
- ri->ri_length = rgblocks2bitblocks(rgs->sdp->bsize, len, &ri->ri_data);
+ ri_length = rgblocks2bitblocks(rgs->sdp->bsize, len, &ri_data);
+ ri->ri_addr = cpu_to_be64(addr);
+ ri->ri_length = cpu_to_be32(ri_length);
+ ri->ri_data = cpu_to_be32(ri_data);
ri->__pad = 0;
- ri->ri_data0 = ri->ri_addr + ri->ri_length;
- ri->ri_bitbytes = ri->ri_data / GFS2_NBBY;
+ ri->ri_data0 = cpu_to_be64(addr + ri_length);
+ ri->ri_bitbytes = cpu_to_be32(ri_data / GFS2_NBBY);
memset(&ri->ri_reserved, 0, sizeof(ri->ri_reserved));
- return ri->ri_addr + len;
-}
-
-/**
- * Return the rindex structure relating to a resource group.
- * The return type is const to advise callers that making changes to this
- * structure directly isn't wise. libgfs2 functions should be used instead.
- */
-const struct gfs2_rindex *lgfs2_rgrp_index(lgfs2_rgrp_t rg)
-{
- return &rg->ri;
-}
-
-/**
- * Return the rgrp structure relating to a resource group.
- * The return type is const to advise callers that making changes to this
- * structure directly isn't wise. libgfs2 functions should be used instead.
- */
-const struct gfs2_rgrp *lgfs2_rgrp_rgrp(lgfs2_rgrp_t rg)
-{
- return &rg->rg;
+ return addr + len;
}
/**
@@ -650,12 +630,12 @@ lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry, ui
return NULL;
if (lastrg != NULL) { /* Tree is not empty */
- if (entry->ri_addr <= lastrg->ri.ri_addr)
+ if (be64_to_cpu(entry->ri_addr) <= lastrg->rt_addr)
return NULL; /* Appending with a lower address doesn't make sense */
link = &lastrg->node.osi_right;
}
- rg = calloc(1, sizeof(*rg) + (entry->ri_length * sizeof(struct gfs2_bitmap)));
+ rg = calloc(1, sizeof(*rg) + (be32_to_cpu(entry->ri_length) * sizeof(struct gfs2_bitmap)));
if (rg == NULL)
return NULL;
@@ -664,16 +644,16 @@ lgfs2_rgrp_t lgfs2_rgrps_append(lgfs2_rgrps_t rgs, struct gfs2_rindex *entry, ui
osi_link_node(&rg->node, parent, link);
osi_insert_color(&rg->node, &rgs->root);
- memcpy(&rg->ri, entry, sizeof(struct gfs2_rindex));
- rg->rg.rg_header.mh_magic = GFS2_MAGIC;
- rg->rg.rg_header.mh_type = GFS2_METATYPE_RG;
- rg->rg.rg_header.mh_format = GFS2_FORMAT_RG;
- rg->rg.rg_free = rg->ri.ri_data;
- rg->rg.rg_skip = rg_skip;
- rg->rg.rg_data0 = rg->ri.ri_data0;
- rg->rg.rg_data = rg->ri.ri_data;
- rg->rg.rg_bitbytes = rg->ri.ri_bitbytes;
- rg->rg.rg_crc = 0;
+ rg->rt_addr = be64_to_cpu(entry->ri_addr);
+ rg->rt_length = be32_to_cpu(entry->ri_length);
+ rg->rt_data0 = be64_to_cpu(entry->ri_data0);
+ rg->rt_data = be32_to_cpu(entry->ri_data);
+ rg->rt_bitbytes = be32_to_cpu(entry->ri_bitbytes);
+ rg->rt_flags = 0;
+ rg->rt_free = be32_to_cpu(entry->ri_data);
+ rg->rt_dinodes = 0;
+ rg->rt_skip = rg_skip;
+ rg->rt_igeneration = 0;
compute_bitmaps(rg, rgs->sdp->bsize);
rg->rgrps = rgs;
return rg;
@@ -687,11 +667,6 @@ int lgfs2_rgrp_write(int fd, const lgfs2_rgrp_t rg)
{
struct gfs2_sbd *sdp = rg->rgrps->sdp;
unsigned int i;
- const struct gfs2_meta_header bmh = {
- .mh_magic = GFS2_MAGIC,
- .mh_type = GFS2_METATYPE_RB,
- .mh_format = GFS2_FORMAT_RB,
- };
int freebufs = 0;
ssize_t ret;
size_t len;
@@ -701,16 +676,20 @@ int lgfs2_rgrp_write(int fd, const lgfs2_rgrp_t rg)
if (lgfs2_rgrp_bitbuf_alloc(rg) != 0)
return -1;
}
- gfs2_rgrp_out(&rg->rg, rg->bits[0].bi_data);
- for (i = 1; i < rg->ri.ri_length; i++) {
- gfs2_meta_header_out(&bmh, rg->bits[i].bi_data);
+ lgfs2_rgrp_out(rg, rg->bits[0].bi_data);
+ for (i = 1; i < rg->rt_length; i++) {
+ struct gfs2_meta_header *mh = (void *)rg->bits[i].bi_data;
+
+ mh->mh_magic = cpu_to_be32(GFS2_MAGIC);
+ mh->mh_type = cpu_to_be32(GFS2_METATYPE_RB);
+ mh->mh_format = cpu_to_be32(GFS2_FORMAT_RB);
}
- len = sdp->bsize * rg->ri.ri_length;
+ len = sdp->bsize * rg->rt_length;
if (rg->rgrps->align > 0)
len = ROUND_UP(len, rg->rgrps->align * sdp->bsize);
- ret = pwrite(fd, rg->bits[0].bi_data, len, rg->ri.ri_addr * sdp->bsize);
+ ret = pwrite(fd, rg->bits[0].bi_data, len, rg->rt_addr * sdp->bsize);
if (freebufs)
lgfs2_rgrp_bitbuf_free(rg);
@@ -729,7 +708,7 @@ int lgfs2_rgrps_write_final(int fd, lgfs2_rgrps_t rgs)
{
lgfs2_rgrp_t rg = lgfs2_rgrp_last(rgs);
- rg->rg.rg_skip = 0;
+ rg->rt_skip = 0;
if (lgfs2_rgrp_write(fd, rg) != 0)
return -1;
return 0;
@@ -769,14 +748,14 @@ lgfs2_rgrp_t lgfs2_rgrp_last(lgfs2_rgrps_t rgs)
*/
int lgfs2_rbm_from_block(struct lgfs2_rbm *rbm, uint64_t block)
{
- uint64_t rblock = block - rbm->rgd->ri.ri_data0;
+ uint64_t rblock = block - rbm->rgd->rt_data0;
struct gfs2_sbd *sdp = rbm->rgd->rgrps->sdp;
if (rblock > UINT_MAX) {
errno = EINVAL;
return 1;
}
- if (block >= rbm->rgd->ri.ri_data0 + rbm->rgd->ri.ri_data) {
+ if (block >= rbm->rgd->rt_data0 + rbm->rgd->rt_data) {
errno = E2BIG;
return 1;
}
@@ -812,7 +791,7 @@ static int lgfs2_rbm_incr(struct lgfs2_rbm *rbm)
rbm->offset++;
return 0;
}
- if (rbm->bii == rbm->rgd->ri.ri_length - 1) /* at the last bitmap */
+ if (rbm->bii == rbm->rgd->rt_length - 1) /* at the last bitmap */
return 1;
rbm->offset = 0;
@@ -953,7 +932,7 @@ int lgfs2_rbm_find(struct lgfs2_rbm *rbm, uint8_t state, uint32_t *minext)
int initial_bii;
uint32_t offset;
int n = 0;
- int iters = rbm->rgd->ri.ri_length;
+ int iters = rbm->rgd->rt_length;
uint32_t extlen;
/* If we are not starting at the beginning of a bitmap, then we
@@ -969,7 +948,7 @@ int lgfs2_rbm_find(struct lgfs2_rbm *rbm, uint8_t state, uint32_t *minext)
uint64_t block;
int ret;
- if ((rbm->rgd->rg.rg_free < *minext) && (state == GFS2_BLKST_FREE))
+ if ((rbm->rgd->rt_free < *minext) && (state == GFS2_BLKST_FREE))
goto next_bitmap;
offset = gfs2_bitfit(buf, bi->bi_len, rbm->offset, state);
@@ -1005,7 +984,7 @@ int lgfs2_rbm_find(struct lgfs2_rbm *rbm, uint8_t state, uint32_t *minext)
next_bitmap: /* Find next bitmap in the rgrp */
rbm->offset = 0;
rbm->bii++;
- if (rbm->bii == rbm->rgd->ri.ri_length)
+ if (rbm->bii == rbm->rgd->rt_length)
rbm->bii = 0;
res_covered_end_of_rgrp:
diff --git a/gfs2/libgfs2/rgrp.h b/gfs2/libgfs2/rgrp.h
index ed5c7358..386ade3d 100644
--- a/gfs2/libgfs2/rgrp.h
+++ b/gfs2/libgfs2/rgrp.h
@@ -41,7 +41,7 @@ static inline struct gfs2_bitmap *rbm_bi(const struct lgfs2_rbm *rbm)
static inline uint64_t lgfs2_rbm_to_block(const struct lgfs2_rbm *rbm)
{
- return rbm->rgd->ri.ri_data0 + (rbm_bi(rbm)->bi_start * GFS2_NBBY) +
+ return rbm->rgd->rt_data0 + (rbm_bi(rbm)->bi_start * GFS2_NBBY) +
rbm->offset;
}
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 562640f7..e900a7df 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -520,7 +520,7 @@ int build_rindex(struct gfs2_sbd *sdp)
next = osi_next(n);
rl = (struct rgrp_tree *)n;
- gfs2_rindex_out(&rl->ri, buf);
+ lgfs2_rindex_out(rl, buf);
count = gfs2_writei(ip, buf, ip->i_size, sizeof(struct gfs2_rindex));
if (count != sizeof(struct gfs2_rindex))
@@ -663,7 +663,7 @@ unsigned lgfs2_bm_scan(struct rgrp_tree *rgd, unsigned idx, uint64_t *buf, uint8
bi->bi_len, blk, state);
if (blk == BFITNOENT)
break;
- buf[n++] = blk + (bi->bi_start * GFS2_NBBY) + rgd->ri.ri_data0;
+ buf[n++] = blk + (bi->bi_start * GFS2_NBBY) + rgd->rt_data0;
blk++;
}
return n;
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index e8ade2e2..f304b4df 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -147,20 +147,20 @@ static int rgd_seems_ok(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
uint32_t most_bitmaps_possible;
/* rg length must be at least 1 */
- if (rgd->ri.ri_length == 0)
+ if (rgd->rt_length == 0)
return 0;
/* A max rgrp, 2GB, divided into blocksize, divided by blocks/byte
represented in the bitmap, NBBY. Rough approximation only, due to
metadata headers. I'm doing the math this way to avoid overflow. */
most_bitmaps_possible = (GFS2_MAX_RGSIZE * 1024 * 256) / sdp->bsize;
- if (rgd->ri.ri_length > most_bitmaps_possible)
+ if (rgd->rt_length > most_bitmaps_possible)
return 0;
- if (rgd->ri.ri_data0 != rgd->ri.ri_addr + rgd->ri.ri_length)
+ if (rgd->rt_data0 != rgd->rt_addr + rgd->rt_length)
return 0;
- if (rgd->ri.ri_bitbytes != rgd->ri.ri_data / GFS2_NBBY)
+ if (rgd->rt_bitbytes != rgd->rt_data / GFS2_NBBY)
return 0;
return 1;
@@ -180,7 +180,7 @@ static int good_on_disk(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
struct gfs2_buffer_head *bh;
int is_rgrp;
- bh = bread(sdp, rgd->ri.ri_addr);
+ bh = bread(sdp, rgd->rt_addr);
is_rgrp = (gfs2_check_meta(bh->b_data, GFS2_METATYPE_RG) == 0);
brelse(bh);
return is_rgrp;
@@ -198,10 +198,6 @@ int rindex_read(struct gfs2_sbd *sdp, uint64_t *rgcount, int *ok)
{
unsigned int rg;
int error;
- union {
- struct gfs2_rindex bufgfs2;
- } buf;
- struct gfs2_rindex ri;
struct rgrp_tree *rgd = NULL, *prev_rgd = NULL;
uint64_t prev_length = 0;
@@ -210,7 +206,10 @@ int rindex_read(struct gfs2_sbd *sdp, uint64_t *rgcount, int *ok)
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,
+ struct gfs2_rindex ri;
+ uint64_t addr;
+
+ error = gfs2_readi(sdp->md.riinode, &ri,
rg * sizeof(struct gfs2_rindex),
sizeof(struct gfs2_rindex));
if (!error)
@@ -218,17 +217,19 @@ int rindex_read(struct gfs2_sbd *sdp, uint64_t *rgcount, int *ok)
if (error != sizeof(struct gfs2_rindex))
return -1;
- gfs2_rindex_in(&ri, (char *)&buf.bufgfs2);
- if (gfs2_check_range(sdp, ri.ri_addr) != 0) {
+ addr = be64_to_cpu(ri.ri_addr);
+ if (gfs2_check_range(sdp, addr) != 0) {
*ok = 0;
if (prev_rgd == NULL)
continue;
- ri.ri_addr = prev_rgd->ri.ri_addr + prev_rgd->length;
+ addr = prev_rgd->rt_addr + prev_rgd->length;
}
- rgd = rgrp_insert(&sdp->rgtree, ri.ri_addr);
- memcpy(&rgd->ri, &ri, sizeof(struct gfs2_rindex));
-
- rgd->start = rgd->ri.ri_addr;
+ rgd = rgrp_insert(&sdp->rgtree, addr);
+ rgd->rt_length = be32_to_cpu(ri.ri_length);
+ rgd->rt_data0 = be64_to_cpu(ri.ri_data0);
+ rgd->rt_data = be32_to_cpu(ri.ri_data);
+ rgd->rt_bitbytes = be32_to_cpu(ri.ri_bitbytes);
+ rgd->start = addr;
if (prev_rgd) {
/* If rg addresses go backwards, it's not sane
(or it's converted from gfs1). */
diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
index 2fadd06a..deb9230d 100644
--- a/gfs2/mkfs/main_grow.c
+++ b/gfs2/mkfs/main_grow.c
@@ -194,8 +194,10 @@ static lgfs2_rgrps_t rgrps_init(struct gfs2_sbd *sdp)
static uint64_t filesystem_size(lgfs2_rgrps_t rgs)
{
lgfs2_rgrp_t rg = lgfs2_rgrp_last(rgs);
- const struct gfs2_rindex *ri = lgfs2_rgrp_index(rg);
- return ri->ri_data0 + ri->ri_data;
+ struct gfs2_rindex ri;
+
+ lgfs2_rindex_out(rg, &ri);
+ return be64_to_cpu(ri.ri_data0) + be32_to_cpu(ri.ri_data);
}
/**
@@ -253,8 +255,7 @@ static char *rindex_buffer(lgfs2_rgrps_t rgs, unsigned count)
exit(EXIT_FAILURE);
}
for (rg = lgfs2_rgrp_first(rgs); rg; rg = lgfs2_rgrp_next(rg)) {
- const struct gfs2_rindex *ri = lgfs2_rgrp_index(rg);
- gfs2_rindex_out(ri, buf + (sizeof(*ri) * i));
+ lgfs2_rindex_out(rg, buf + (sizeof(struct gfs2_rindex) * i));
i++;
}
return buf;
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 32211db7..6374ebc7 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -771,16 +771,21 @@ static lgfs2_rgrps_t rgs_init(struct mkfs_opts *opts, struct gfs2_sbd *sdp)
static int place_rgrp(struct gfs2_sbd *sdp, lgfs2_rgrp_t rg, int debug)
{
uint64_t prev_end = (GFS2_SB_ADDR * GFS2_BASIC_BLOCK / sdp->bsize) + 1;
- const struct gfs2_rindex *ri = lgfs2_rgrp_index(rg);
lgfs2_rgrp_t prev = lgfs2_rgrp_prev(rg);
+ struct gfs2_rindex ri;
+ uint64_t addr;
int err = 0;
if (prev != NULL) {
- prev_end = lgfs2_rgrp_index(prev)->ri_data0 +
- lgfs2_rgrp_index(prev)->ri_data;
+ lgfs2_rindex_out(prev, &ri);
+ prev_end = be64_to_cpu(ri.ri_data0) + be32_to_cpu(ri.ri_data);
}
- while (prev_end < ri->ri_addr) {
- size_t gap_len = ri->ri_addr - prev_end;
+
+ lgfs2_rindex_out(rg, &ri);
+ addr = be64_to_cpu(ri.ri_addr);
+
+ while (prev_end < addr) {
+ size_t gap_len = addr - prev_end;
if (gap_len > IOV_MAX)
gap_len = IOV_MAX;
@@ -795,11 +800,11 @@ static int place_rgrp(struct gfs2_sbd *sdp, lgfs2_rgrp_t rg, int debug)
return -1;
}
if (debug) {
- gfs2_rindex_print(ri);
+ lgfs2_rindex_print(&ri);
printf("\n");
}
- sdp->blks_total += ri->ri_data;
- sdp->fssize = ri->ri_data0 + ri->ri_data;
+ sdp->blks_total += be32_to_cpu(ri.ri_data);
+ sdp->fssize = be64_to_cpu(ri.ri_data0) + be32_to_cpu(ri.ri_data);
sdp->rgrps++;
return 0;
}
@@ -849,6 +854,7 @@ static int place_journals(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_o
int result;
lgfs2_rgrp_t rg;
struct gfs2_inode in = {0};
+ struct gfs2_rindex ri;
gfs2_progress_update(&progress, (j + 1));
@@ -867,7 +873,8 @@ 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_addr = lgfs2_rgrp_index(rg)->ri_data0;
+ lgfs2_rindex_out(rg, &ri);
+ in.i_addr = be64_to_cpu(ri.ri_data0);
/* In order to keep writes sequential here, we have to allocate
the journal, then write the rgrp header (which is now in its
final form) and then write the journal out */
diff --git a/tests/nukerg.c b/tests/nukerg.c
index f323d643..3bca919c 100644
--- a/tests/nukerg.c
+++ b/tests/nukerg.c
@@ -186,11 +186,12 @@ static int nuke_rgs(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, unsigned *rgnums, s
memset(&blankrg, 0, sizeof(blankrg));
for (rg = lgfs2_rgrp_first(rgs), i = 0; rg; rg = lgfs2_rgrp_next(rg), i++) {
- const struct gfs2_rindex *ri = lgfs2_rgrp_index(rg);
+ struct gfs2_rindex ri;
unsigned j;
+ lgfs2_rindex_out(rg, &ri);
for (j = 0; j < count; j++) {
- uint64_t addr = ri->ri_addr;
+ uint64_t addr = be64_to_cpu(ri.ri_addr);
off_t off = addr * sdp->bsize;
ssize_t bytes;
@@ -262,10 +263,10 @@ static lgfs2_rgrps_t read_rindex(struct gfs2_sbd *sdp)
}
rgcount = sdp->md.riinode->i_size / sizeof(struct gfs2_rindex);
for (i = 0; i < rgcount; i++) {
- const struct gfs2_rindex *ri;
+ lgfs2_rgrp_t rg;
- ri = lgfs2_rindex_read_one(sdp->md.riinode, rgs, i);
- if (ri == NULL) {
+ rg = lgfs2_rindex_read_one(sdp->md.riinode, rgs, i);
+ if (rg == NULL) {
fprintf(stderr, "Failed to read rindex entry %u: %s\n",
i, strerror(errno));
return NULL;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
2 years, 10 months