This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-sparse
in repository gfs2-utils.
commit 9402792a83efa505e573e1ada9ec96258a12e1ca
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon May 10 10:32:44 2021 +0100
libgfs2: Add a cpu-endian log header struct
This allows gfs2_log_header_{in,out} to be removed and replaced with a
smaller, static log_header_in() function.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/extended.c | 4 ++--
gfs2/fsck/fs_recovery.c | 23 +++++++++++------------
gfs2/libgfs2/libgfs2.h | 22 ++++++++++++++++------
gfs2/libgfs2/ondisk.c | 44 --------------------------------------------
gfs2/libgfs2/recovery.c | 40 ++++++++++++++++++++++++++++------------
5 files changed, 57 insertions(+), 76 deletions(-)
diff --git a/gfs2/edit/extended.c b/gfs2/edit/extended.c
index 4e8a003d..c977b6e1 100644
--- a/gfs2/edit/extended.c
+++ b/gfs2/edit/extended.c
@@ -473,7 +473,7 @@ static int print_gfs_jindex(struct gfs2_inode *dij)
static int print_gfs2_jindex(void)
{
int d, error;
- struct gfs2_log_header head;
+ struct lgfs2_log_header head;
struct gfs2_inode *ip;
for (d = 0; d < indirect->ii[0].dirents; d++) {
@@ -484,7 +484,7 @@ static int print_gfs2_jindex(void)
indirect->ii[0].dirent[d].filename,
indirect->ii[0].dirent[d].block,
ip->i_di.di_size / 1048576);
- error = gfs2_find_jhead(ip, &head);
+ error = lgfs2_find_jhead(ip, &head);
if (error) {
print_gfs2("corrupt.");
} else {
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index c7704b0e..ac187853 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -337,9 +337,9 @@ static int foreach_descriptor(struct gfs2_inode *ip, unsigned int
start,
length = be32_to_cpu(ld->ld_length);
if (be32_to_cpu(ld->ld_header.mh_type) == GFS2_METATYPE_LH) {
- struct gfs2_log_header lh;
+ struct lgfs2_log_header lh;
- error = get_log_header(ip, start, &lh);
+ error = lgfs2_get_log_header(ip, start, &lh);
if (!error) {
gfs2_replay_incr_blk(ip, &start);
bmodified(bh);
@@ -401,7 +401,7 @@ static int check_journal_seq_no(struct gfs2_inode *ip, int fix)
int error = 0, wrapped = 0;
uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
uint32_t blk;
- struct gfs2_log_header lh;
+ struct lgfs2_log_header lh;
uint64_t highest_seq = 0, lowest_seq = 0, prev_seq = 0;
int new = 0;
uint64_t dblock;
@@ -410,7 +410,7 @@ static int check_journal_seq_no(struct gfs2_inode *ip, int fix)
memset(&lh, 0, sizeof(lh));
for (blk = 0; blk < jd_blocks; blk++) {
- error = get_log_header(ip, blk, &lh);
+ error = lgfs2_get_log_header(ip, blk, &lh);
if (error == 1) /* if not a log header */
continue; /* just journal data--ignore it */
if (!lowest_seq || lh.lh_sequence < lowest_seq)
@@ -436,12 +436,11 @@ static int check_journal_seq_no(struct gfs2_inode *ip, int fix)
if (!fix)
continue;
highest_seq++;
- lh.lh_sequence = highest_seq;
- prev_seq = lh.lh_sequence;
- log_warn(_("Renumbering it as 0x%"PRIx64"\n"), lh.lh_sequence);
+ prev_seq = highest_seq;
+ log_warn(_("Renumbering it as 0x%"PRIx64"\n"), highest_seq);
block_map(ip, blk, &new, &dblock, NULL, 0);
bh = bread(ip->i_sbd, dblock);
- gfs2_log_header_out(&lh, bh->b_data);
+ ((struct gfs2_log_header *)bh->b_data)->lh_sequence = cpu_to_be64(highest_seq);
bmodified(bh);
brelse(bh);
}
@@ -492,7 +491,7 @@ static int gfs2_recover_journal(struct gfs2_inode *ip, int j, int
preen,
int force_check, int *was_clean)
{
struct gfs2_sbd *sdp = ip->i_sbd;
- struct gfs2_log_header head;
+ struct lgfs2_log_header head;
unsigned int pass;
int error;
@@ -500,7 +499,7 @@ static int gfs2_recover_journal(struct gfs2_inode *ip, int j, int
preen,
log_info( _("jid=%u: Looking at journal...\n"), j);
osi_list_init(&sd_revoke_list);
- error = gfs2_find_jhead(ip, &head);
+ error = lgfs2_find_jhead(ip, &head);
if (!error) {
error = check_journal_seq_no(ip, 0);
if (error > JOURNAL_SEQ_TOLERANCE) {
@@ -541,7 +540,7 @@ static int gfs2_recover_journal(struct gfs2_inode *ip, int j, int
preen,
j);
goto out;
}
- error = gfs2_find_jhead(ip, &head);
+ error = lgfs2_find_jhead(ip, &head);
if (error) {
log_err( _("jid=%u: Unable to fix the bad journal.\n"),
j);
@@ -591,7 +590,7 @@ static int gfs2_recover_journal(struct gfs2_inode *ip, int j, int
preen,
}
log_info( _("jid=%u: Found %u revoke tags\n"), j, sd_found_revokes);
gfs2_revoke_clean(sdp);
- error = clean_journal(ip, &head);
+ error = lgfs2_clean_journal(ip, &head);
if (error)
goto out;
log_err( _("jid=%u: Replayed %u of %u journaled data blocks\n"),
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 922d35f8..2c4b856e 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -299,6 +299,18 @@ struct gfs2_sbd {
int gfs1;
};
+struct lgfs2_log_header {
+ uint64_t lh_sequence;
+ uint32_t lh_flags;
+ uint32_t lh_tail;
+ uint32_t lh_blkno;
+ uint32_t lh_hash;
+ uint32_t lh_crc;
+ int64_t lh_local_total;
+ int64_t lh_local_free;
+ int64_t lh_local_dinodes;
+};
+
struct metapath {
unsigned int mp_list[GFS2_MAX_META_HEIGHT];
};
@@ -638,10 +650,10 @@ extern int gfs2_revoke_add(struct gfs2_sbd *sdp, uint64_t blkno,
unsigned int wh
extern int gfs2_revoke_check(struct gfs2_sbd *sdp, uint64_t blkno,
unsigned int where);
extern void gfs2_revoke_clean(struct gfs2_sbd *sdp);
-extern int get_log_header(struct gfs2_inode *ip, unsigned int blk,
- struct gfs2_log_header *head);
-extern int gfs2_find_jhead(struct gfs2_inode *ip, struct gfs2_log_header *head);
-extern int clean_journal(struct gfs2_inode *ip, struct gfs2_log_header *head);
+extern int lgfs2_get_log_header(struct gfs2_inode *ip, unsigned int blk,
+ struct lgfs2_log_header *head);
+extern int lgfs2_find_jhead(struct gfs2_inode *ip, struct lgfs2_log_header *head);
+extern int lgfs2_clean_journal(struct gfs2_inode *ip, struct lgfs2_log_header *head);
/* rgrp.c */
extern int gfs2_compute_bitstructs(const uint32_t bsize, struct rgrp_tree *rgd);
@@ -711,8 +723,6 @@ extern void gfs2_dirent_in(struct gfs2_dirent *de, char *buf);
extern void gfs2_dirent_out(struct gfs2_dirent *de, char *buf);
extern void gfs2_leaf_in(struct gfs2_leaf *lf, char *buf);
extern void gfs2_leaf_out(struct gfs2_leaf *lf, char *buf);
-extern void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf);
-extern void gfs2_log_header_out(struct gfs2_log_header *lh, char *buf);
/* Printing functions */
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 286f55ac..0387f196 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -507,50 +507,6 @@ void lgfs2_ea_header_print(void *eap)
print_it(" name", "%s", NULL, buf);
}
-void gfs2_log_header_in(struct gfs2_log_header *lh, char *buf)
-{
- struct gfs2_log_header *str = (struct gfs2_log_header *)buf;
-
- gfs2_meta_header_in(&lh->lh_header, buf);
- CPIN_64(lh, str, lh_sequence);
- CPIN_32(lh, str, lh_flags);
- CPIN_32(lh, str, lh_tail);
- CPIN_32(lh, str, lh_blkno);
- CPIN_32(lh, str, lh_hash);
- CPIN_32(lh, str, lh_crc);
- CPIN_32(lh, str, lh_nsec);
- CPIN_64(lh, str, lh_sec);
- CPIN_64(lh, str, lh_addr);
- CPIN_64(lh, str, lh_jinode);
- CPIN_64(lh, str, lh_statfs_addr);
- CPIN_64(lh, str, lh_quota_addr);
- CPIN_64(lh, str, lh_local_total);
- CPIN_64(lh, str, lh_local_free);
- CPIN_64(lh, str, lh_local_dinodes);
-}
-
-void gfs2_log_header_out(struct gfs2_log_header *lh, char *buf)
-{
- struct gfs2_log_header *str = (struct gfs2_log_header *)buf;
-
- gfs2_meta_header_out(&lh->lh_header, buf);
- CPOUT_64(lh, str, lh_sequence);
- CPOUT_32(lh, str, lh_flags);
- CPOUT_32(lh, str, lh_tail);
- CPOUT_32(lh, str, lh_blkno);
- CPOUT_32(lh, str, lh_hash);
- CPOUT_32(lh, str, lh_crc);
- CPOUT_32(lh, str, lh_nsec);
- CPOUT_64(lh, str, lh_sec);
- CPOUT_64(lh, str, lh_addr);
- CPOUT_64(lh, str, lh_jinode);
- CPOUT_64(lh, str, lh_statfs_addr);
- CPOUT_64(lh, str, lh_quota_addr);
- CPOUT_64(lh, str, lh_local_total);
- CPOUT_64(lh, str, lh_local_free);
- CPOUT_64(lh, str, lh_local_dinodes);
-}
-
void lgfs2_log_header_print(void *lhp)
{
struct gfs2_log_header *lh = lhp;
diff --git a/gfs2/libgfs2/recovery.c b/gfs2/libgfs2/recovery.c
index 78136ac2..429b222b 100644
--- a/gfs2/libgfs2/recovery.c
+++ b/gfs2/libgfs2/recovery.c
@@ -36,6 +36,21 @@ int gfs2_replay_read_block(struct gfs2_inode *ip, unsigned int blk,
return 0;
}
+static void log_header_in(struct lgfs2_log_header *lh, char *buf)
+{
+ struct gfs2_log_header *lhd = (struct gfs2_log_header *)buf;
+
+ lh->lh_sequence = be64_to_cpu(lhd->lh_sequence);
+ lh->lh_flags = be32_to_cpu(lhd->lh_flags);
+ lh->lh_tail = be32_to_cpu(lhd->lh_tail);
+ lh->lh_blkno = be32_to_cpu(lhd->lh_blkno);
+ lh->lh_hash = be32_to_cpu(lhd->lh_hash);
+ lh->lh_crc = be32_to_cpu(lhd->lh_crc);
+ lh->lh_local_total = be64_to_cpu(lhd->lh_local_total);
+ lh->lh_local_free = be64_to_cpu(lhd->lh_local_free);
+ lh->lh_local_dinodes = be64_to_cpu(lhd->lh_local_dinodes);
+}
+
/**
* get_log_header - read the log header for a given segment
* @ip: the journal incore inode
@@ -50,11 +65,12 @@ int gfs2_replay_read_block(struct gfs2_inode *ip, unsigned int blk,
* errno on error
*/
-int get_log_header(struct gfs2_inode *ip, unsigned int blk,
- struct gfs2_log_header *head)
+int lgfs2_get_log_header(struct gfs2_inode *ip, unsigned int blk,
+ struct lgfs2_log_header *head)
{
struct gfs2_buffer_head *bh;
- struct gfs2_log_header lh, *tmp;
+ struct lgfs2_log_header lh;
+ struct gfs2_log_header *tmp;
uint32_t hash, saved_hash;
uint32_t lh_crc = 0;
uint32_t crc;
@@ -70,7 +86,7 @@ int get_log_header(struct gfs2_inode *ip, unsigned int blk,
hash = lgfs2_log_header_hash(bh->b_data);
tmp->lh_hash = saved_hash;
crc = lgfs2_log_header_crc(bh->b_data, ip->i_sbd->bsize);
- gfs2_log_header_in(&lh, bh->b_data);
+ log_header_in(&lh, bh->b_data);
brelse(bh);
lh_crc = lh.lh_crc;
if (error || lh.lh_blkno != blk || lh.lh_hash != hash)
@@ -96,14 +112,14 @@ int get_log_header(struct gfs2_inode *ip, unsigned int blk,
*
* Returns: errno
*/
-static int find_good_lh(struct gfs2_inode *ip, unsigned int *blk, struct gfs2_log_header
*head)
+static int find_good_lh(struct gfs2_inode *ip, unsigned int *blk, struct lgfs2_log_header
*head)
{
unsigned int orig_blk = *blk;
int error;
uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
for (;;) {
- error = get_log_header(ip, *blk, head);
+ error = lgfs2_get_log_header(ip, *blk, head);
if (error <= 0)
return error;
@@ -126,18 +142,18 @@ static int find_good_lh(struct gfs2_inode *ip, unsigned int *blk,
struct gfs2_lo
* Returns: errno
*/
-static int jhead_scan(struct gfs2_inode *ip, struct gfs2_log_header *head)
+static int jhead_scan(struct gfs2_inode *ip, struct lgfs2_log_header *head)
{
unsigned int blk = head->lh_blkno;
uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
- struct gfs2_log_header lh;
+ struct lgfs2_log_header lh;
int error;
for (;;) {
if (++blk == jd_blocks)
blk = 0;
- error = get_log_header(ip, blk, &lh);
+ error = lgfs2_get_log_header(ip, blk, &lh);
if (error < 0)
return error;
if (error == 1)
@@ -165,9 +181,9 @@ static int jhead_scan(struct gfs2_inode *ip, struct gfs2_log_header
*head)
* Returns: errno
*/
-int gfs2_find_jhead(struct gfs2_inode *ip, struct gfs2_log_header *head)
+int lgfs2_find_jhead(struct gfs2_inode *ip, struct lgfs2_log_header *head)
{
- struct gfs2_log_header lh_1, lh_m;
+ struct lgfs2_log_header lh_1, lh_m;
uint32_t blk_1, blk_2, blk_m;
uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
int error;
@@ -213,7 +229,7 @@ int gfs2_find_jhead(struct gfs2_inode *ip, struct gfs2_log_header
*head)
* Returns: errno
*/
-int clean_journal(struct gfs2_inode *ip, struct gfs2_log_header *head)
+int lgfs2_clean_journal(struct gfs2_inode *ip, struct lgfs2_log_header *head)
{
unsigned int lblock;
struct gfs2_log_header *lh;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.