[gfs2-utils] branch master updated: mkf.gfs2: Clarify when extended
options are invalid
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
The following commit(s) were added to refs/heads/master by this push:
new 6114591 mkf.gfs2: Clarify when extended options are invalid
6114591 is described below
commit 61145913214489c32398603f3439c4c0194d5ce4
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Jun 30 14:00:56 2020 +0100
mkf.gfs2: Clarify when extended options are invalid
Omitting the argument of '-o' can give a misleading error message:
$ mkfs.gfs2 -o -p lock_nolock /dev/foo
Invalid option '-p'
so clarify that the -o arg is an invalid extended option.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/mkfs/main_mkfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 412d470..bb8762b 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -311,7 +311,8 @@ static void opt_parse_extended(char *str, struct mkfs_opts *opts)
print_ext_opts();
exit(0);
} else {
- fprintf(stderr, _("Invalid option '%s'\n"), key);
+ fprintf(stderr, _("Invalid extended option (specified with -o): '%s'\n"), key);
+ print_ext_opts();
exit(-1);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 9 months
[gfs2-utils] branch master updated: gfs2_jadd: Fix static analysis
warnings
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
The following commit(s) were added to refs/heads/master by this push:
new 8a0b4b2 gfs2_jadd: Fix static analysis warnings
8a0b4b2 is described below
commit 8a0b4b2183e05be4c92612b0a82ed64617e6a742
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Jun 9 15:24:28 2020 +0100
gfs2_jadd: Fix static analysis warnings
Fix these warnings:
gfs2/mkfs/main_jadd.c:264:8: warning: Although the value stored to
'error' is used in the enclosing expression, the value is never actually
read from 'error'
gfs2/mkfs/main_jadd.c:514:15: warning: Assigned value is garbage or
undefined
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/mkfs/main_jadd.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/gfs2/mkfs/main_jadd.c b/gfs2/mkfs/main_jadd.c
index ea89c96..03134a6 100644
--- a/gfs2/mkfs/main_jadd.c
+++ b/gfs2/mkfs/main_jadd.c
@@ -241,7 +241,7 @@ static void print_results(struct jadd_opts *opts)
static int create_new_inode(struct jadd_opts *opts, uint64_t *addr)
{
char *name = opts->new_inode;
- int fd, error = 0;
+ int fd;
for (;;) {
fd = open(name, O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW | O_CLOEXEC, 0600);
@@ -261,9 +261,10 @@ static int create_new_inode(struct jadd_opts *opts, uint64_t *addr)
if (addr != NULL) {
struct stat st;
- if ((error = fstat(fd, &st))) {
+ if (fstat(fd, &st) == -1) {
perror("fstat");
- return close(fd);
+ close(fd);
+ return -1;
}
*addr = st.st_ino;
}
@@ -481,7 +482,7 @@ static int add_j(struct gfs2_sbd *sdp, struct jadd_opts *opts)
unsigned int x, blocks =
sdp->jsize << (20 - sdp->sd_sb.sb_bsize_shift);
struct gfs2_log_header lh;
- uint64_t seq = RANDOM(blocks), addr;
+ uint64_t seq = RANDOM(blocks), addr = 0;
off_t off = 0;
if ((fd = create_new_inode(opts, &addr)) < 0)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 10 months
[gfs2-utils] 07/07: fsck.gfs2: Clear bad indirect block pointers
when bitmap meets expectations
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit 4707be4ee1e214cc420679650e1897b3b0817638
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Oct 18 19:43:48 2019 +0100
fsck.gfs2: Clear bad indirect block pointers when bitmap meets expectations
This issue only occurs when an indirect pointer of a 'system' directory
points to an invalid block but the block's bitmap state is as expected.
If the block's state is not as expected, the corruption is fixed by an
earlier check.
In this scenario, pass1_check_metalist() checks the type of a block and
compares it with what it expected the indirect pointer to point to. If
there is a metadata mismatch a bad indirect pointer is reported but the
entire inode is considered invalid, causing it to be removed later, or
rebuilt in the case of protected structures such as the root inode.
This is heavy-handed and the right thing to do is to zero the indirect
block pointer.
Previously we had no access to the pointer block itself to update it in
pass1_check_metalist() but now that an iptr is passed in, it's just a
case of zeroing the pointer at the correct offset and marking the bh as
modified. This means that fsck.gfs2 can now fix bad indirect pointers of
the root directory without throwing away the entire directory tree.
Resolves: rhbz#1487726
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/pass1.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 66cf6dc..deef142 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -401,8 +401,15 @@ static int pass1_check_metalist(struct iptr iptr, struct gfs2_buffer_head **bh,
(unsigned long long)ip->i_di.di_num.no_addr,
(unsigned long long)block,
(unsigned long long)block, blktypedesc);
- brelse(nbh);
- return meta_skip_further;
+ if (query(_("Zero the indirect block pointer? (y/n) "))){
+ *iptr_ptr(iptr) = 0;
+ bmodified(iptr.ipt_bh);
+ *is_valid = 1;
+ return meta_skip_one;
+ } else {
+ brelse(nbh);
+ return meta_skip_further;
+ }
}
bc->indir_count++;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 10 months
[gfs2-utils] 06/07: fsck.gfs2: Retain context for indirect pointers
in ->check_metalist
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit 5cf083a5c231bfe0950a276aff9249dd63f708d3
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Oct 18 19:16:08 2019 +0100
fsck.gfs2: Retain context for indirect pointers in ->check_metalist
When the pass->check_metalist() functions are called, the pointer is
thrown away and the function is just called with a block address,
meaning that ->check_metalist() is unable to fix the pointer itself if
it deems the block pointed to is garbage.
Add an iptr structure which collects together the inode, the metadata
block buffer and the offset of the pointer in that buffer. The iptr is
now passed to ->check_metadata instead of the separate inode and block
address arguments.
Resolves: rhbz#1487726
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/afterpass1_common.c | 6 +++--
gfs2/fsck/afterpass1_common.h | 4 +--
gfs2/fsck/fs_recovery.c | 8 +++---
gfs2/fsck/metawalk.c | 55 ++++++++++++++++++++--------------------
gfs2/fsck/metawalk.h | 15 +++++++++--
gfs2/fsck/pass1.c | 59 ++++++++++++++++++++++---------------------
gfs2/fsck/pass1b.c | 22 ++++++++--------
gfs2/fsck/pass2.c | 8 +++---
8 files changed, 98 insertions(+), 79 deletions(-)
diff --git a/gfs2/fsck/afterpass1_common.c b/gfs2/fsck/afterpass1_common.c
index b747640..55a6c76 100644
--- a/gfs2/fsck/afterpass1_common.c
+++ b/gfs2/fsck/afterpass1_common.c
@@ -175,10 +175,12 @@ int remove_dentry_from_dir(struct gfs2_sbd *sdp, uint64_t dir,
return error;
}
-int delete_metadata(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h, int *is_valid,
+int delete_metadata(struct iptr iptr, struct gfs2_buffer_head **bh, int h, int *is_valid,
int *was_duplicate, void *private)
{
+ struct gfs2_inode *ip = iptr.ipt_ip;
+ uint64_t block = iptr_block(iptr);
+
*is_valid = 1;
*was_duplicate = 0;
return delete_block_if_notdup(ip, block, bh, _("metadata"),
diff --git a/gfs2/fsck/afterpass1_common.h b/gfs2/fsck/afterpass1_common.h
index 829828f..74b913f 100644
--- a/gfs2/fsck/afterpass1_common.h
+++ b/gfs2/fsck/afterpass1_common.h
@@ -2,9 +2,9 @@
#define _AFTERPASS1_H
#include "util.h"
+#include "metawalk.h"
-extern int delete_metadata(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h, int *is_valid,
+extern int delete_metadata(struct iptr iptr, struct gfs2_buffer_head **bh, int h, int *is_valid,
int *was_duplicate, void *private);
extern int delete_leaf(struct gfs2_inode *ip, uint64_t block, void *private);
extern int delete_data(struct gfs2_inode *ip, uint64_t metablock,
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 3acbb5d..614c01a 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -636,11 +636,11 @@ static int rangecheck_jblock(struct gfs2_inode *ip, uint64_t block)
return meta_is_good;
}
-static int rangecheck_jmeta(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h,
- int *is_valid, int *was_duplicate,
- void *private)
+static int rangecheck_jmeta(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private)
{
+ struct gfs2_inode *ip = iptr.ipt_ip;
+ uint64_t block = iptr_block(iptr);
int rc;
*bh = NULL;
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index dbe9f1f..d91ed63 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1207,9 +1207,11 @@ static void file_ra(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
extlen * sdp->bsize, POSIX_FADV_WILLNEED);
}
-static int do_check_metalist(struct gfs2_inode *ip, uint64_t block, int height,
- struct gfs2_buffer_head **bhp, struct metawalk_fxns *pass)
+static int do_check_metalist(struct iptr iptr, int height, struct gfs2_buffer_head **bhp,
+ struct metawalk_fxns *pass)
{
+ struct gfs2_inode *ip = iptr.ipt_ip;
+ uint64_t block = iptr_block(iptr);
int was_duplicate = 0;
int is_valid = 1;
int error;
@@ -1217,7 +1219,7 @@ static int do_check_metalist(struct gfs2_inode *ip, uint64_t block, int height,
if (pass->check_metalist == NULL)
return 0;
- error = pass->check_metalist(ip, block, bhp, height, &is_valid,
+ error = pass->check_metalist(iptr, bhp, height, &is_valid,
&was_duplicate, pass->private);
if (error == meta_error) {
stack;
@@ -1267,10 +1269,11 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
struct metawalk_fxns *pass)
{
uint32_t height = ip->i_di.di_height;
- struct gfs2_buffer_head *bh, *nbh, *metabh = ip->i_bh;
+ struct gfs2_buffer_head *metabh = ip->i_bh;
osi_list_t *prev_list, *cur_list, *tmp;
+ struct iptr iptr = { .ipt_ip = ip, 0};
int h, head_size, iblk_type;
- uint64_t *ptr, block, *undoptr;
+ uint64_t *undoptr;
int maxptrs;
int error;
@@ -1310,39 +1313,37 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
prev_list = &mlp[h - 1];
cur_list = &mlp[h];
- for (tmp = prev_list->next; tmp != prev_list; tmp = tmp->next){
- bh = osi_list_entry(tmp, struct gfs2_buffer_head,
- b_altlist);
- if (gfs2_check_meta(bh->b_data, iblk_type)) {
+ for (tmp = prev_list->next; tmp != prev_list; tmp = tmp->next) {
+ iptr.ipt_off = head_size;
+ iptr.ipt_bh = osi_list_entry(tmp, struct gfs2_buffer_head, b_altlist);
+
+ if (gfs2_check_meta(iptr_buf(iptr), iblk_type)) {
if (pass->invalid_meta_is_fatal)
return meta_error;
continue;
}
-
if (pass->readahead)
- file_ra(ip, bh, head_size, maxptrs, h);
+ file_ra(ip, iptr.ipt_bh, head_size, maxptrs, h);
+
/* Now check the metadata itself */
- for (ptr = (uint64_t *)(bh->b_data + head_size);
- (char *)ptr < (bh->b_data + ip->i_sbd->bsize);
- ptr++) {
+ for (; iptr.ipt_off < ip->i_sbd->bsize; iptr.ipt_off += sizeof(uint64_t)) {
+ struct gfs2_buffer_head *nbh = NULL;
+
if (skip_this_pass || fsck_abort) {
free_metalist(ip, mlp);
return meta_is_good;
}
- nbh = NULL;
-
- if (!*ptr)
+ if (!iptr_block(iptr))
continue;
- block = be64_to_cpu(*ptr);
- error = do_check_metalist(ip, block, h, &nbh, pass);
+ error = do_check_metalist(iptr, h, &nbh, pass);
if (error == meta_error || error == meta_skip_further)
goto error_undo;
if (error == meta_skip_one)
continue;
if (!nbh)
- nbh = bread(ip->i_sbd, block);
+ nbh = bread(ip->i_sbd, iptr_block(iptr));
osi_list_add_prev(&nbh->b_altlist, cur_list);
} /* for all data on the indirect block */
} /* for blocks at that height */
@@ -1353,16 +1354,16 @@ error_undo: /* undo what we've done so far for this block */
if (pass->undo_check_meta == NULL)
return error;
- log_info(_("Undoing the work we did before the error on block %llu "
- "(0x%llx).\n"), (unsigned long long)bh->b_blocknr,
- (unsigned long long)bh->b_blocknr);
- for (undoptr = (uint64_t *)(bh->b_data + head_size); undoptr < ptr &&
- (char *)undoptr < (bh->b_data + ip->i_sbd->bsize);
+ log_info(_("Undoing the work we did before the error on block %"PRIu64" (0x%"PRIx64").\n"),
+ iptr.ipt_bh->b_blocknr, iptr.ipt_bh->b_blocknr);
+ for (undoptr = (uint64_t *)(iptr_buf(iptr) + head_size);
+ undoptr < iptr_ptr(iptr) && undoptr < iptr_endptr(iptr);
undoptr++) {
- if (!*undoptr)
+ uint64_t block = be64_to_cpu(*undoptr);
+
+ if (block == 0)
continue;
- block = be64_to_cpu(*undoptr);
pass->undo_check_meta(ip, block, h, pass->private);
}
return error;
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index b5a037a..592479d 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -42,6 +42,17 @@ enum meta_check_rc {
meta_skip_one = 2,
};
+struct iptr {
+ struct gfs2_inode *ipt_ip;
+ struct gfs2_buffer_head *ipt_bh;
+ unsigned ipt_off;
+};
+
+#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_buf(i) (i.ipt_bh->b_data)
+
/* metawalk_fxns: function pointers to check various parts of the fs
*
* The functions should return -1 on fatal errors, 1 if the block
@@ -66,7 +77,7 @@ struct metawalk_fxns {
int (*check_leaf) (struct gfs2_inode *ip, uint64_t block,
void *private);
/* parameters to the check_metalist sub-functions:
- ip: incore inode pointer
+ iptr: reference to the inode and its indirect pointer that we're analyzing
block: block number of the metadata block to be checked
bh: buffer_head to be returned
h: height
@@ -79,7 +90,7 @@ struct metawalk_fxns {
returns: 0 - everything is good, but there may be duplicates
1 - skip further processing
*/
- int (*check_metalist) (struct gfs2_inode *ip, uint64_t block,
+ int (*check_metalist) (struct iptr iptr,
struct gfs2_buffer_head **bh, int h,
int *is_valid, int *was_duplicate,
void *private);
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index f03078e..66cf6dc 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -39,9 +39,8 @@ struct block_count {
};
static int p1check_leaf(struct gfs2_inode *ip, uint64_t block, void *private);
-static int pass1_check_metalist(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h, int *is_valid,
- int *was_duplicate, void *private);
+static int pass1_check_metalist(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private);
static int undo_check_metalist(struct gfs2_inode *ip, uint64_t block,
int h, void *private);
static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
@@ -69,10 +68,8 @@ static int check_extended_leaf_eattr(struct gfs2_inode *ip, int i,
void *private);
static int finish_eattr_indir(struct gfs2_inode *ip, int leaf_pointers,
int leaf_pointer_errors, void *private);
-static int invalidate_metadata(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h,
- int *is_valid, int *was_duplicate,
- void *private);
+static int invalidate_metadata(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private);
static int invalidate_leaf(struct gfs2_inode *ip, uint64_t block,
void *private);
static int invalidate_data(struct gfs2_inode *ip, uint64_t metablock,
@@ -223,12 +220,12 @@ struct metawalk_fxns invalidate_fxns = {
* marked "in use" by the bitmap. You don't want root's indirect blocks
* deleted, do you? Or worse, reused for lost+found.
*/
-static int resuscitate_metalist(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h,
- int *is_valid, int *was_duplicate,
- void *private)
+static int resuscitate_metalist(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private)
{
struct block_count *bc = (struct block_count *)private;
+ struct gfs2_inode *ip = iptr.ipt_ip;
+ uint64_t block = iptr_block(iptr);
*is_valid = 1;
*was_duplicate = 0;
@@ -344,15 +341,16 @@ static int p1check_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
return 0;
}
-static int pass1_check_metalist(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h, int *is_valid,
- int *was_duplicate, void *private)
+static int pass1_check_metalist(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private)
{
- int q;
- int iblk_type;
- struct gfs2_buffer_head *nbh;
struct block_count *bc = (struct block_count *)private;
+ struct gfs2_inode *ip = iptr.ipt_ip;
+ uint64_t block = iptr_block(iptr);
+ struct gfs2_buffer_head *nbh;
const char *blktypedesc;
+ int iblk_type;
+ int q;
*bh = NULL;
@@ -1111,11 +1109,12 @@ static int mark_block_invalid(struct gfs2_inode *ip, uint64_t block,
return meta_is_good;
}
-static int invalidate_metadata(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h,
- int *is_valid, int *was_duplicate,
- void *private)
+static int invalidate_metadata(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private)
{
+ struct gfs2_inode *ip = iptr.ipt_ip;
+ uint64_t block = iptr_block(iptr);
+
*is_valid = 1;
*was_duplicate = 0;
return mark_block_invalid(ip, block, ref_as_meta, _("metadata"),
@@ -1214,11 +1213,12 @@ static int rangecheck_block(struct gfs2_inode *ip, uint64_t block,
return meta_is_good;
}
-static int rangecheck_metadata(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h,
- int *is_valid, int *was_duplicate,
- void *private)
+static int rangecheck_metadata(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private)
{
+ struct gfs2_inode *ip = iptr.ipt_ip;
+ uint64_t block = iptr_block(iptr);
+
*is_valid = 1;
*was_duplicate = 0;
return rangecheck_block(ip, block, bh, btype_meta, private);
@@ -1317,12 +1317,13 @@ static int set_ip_blockmap(struct gfs2_inode *ip)
return 0;
}
-static int alloc_metalist(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h, int *is_valid,
- int *was_duplicate, void *private)
+static int alloc_metalist(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private)
{
- int q;
const char *desc = (const char *)private;
+ struct gfs2_inode *ip = iptr.ipt_ip;
+ uint64_t block = iptr_block(iptr);
+ int q;
/* No need to range_check here--if it was added, it's in range. */
/* We can't check the bitmap here because this function is called
diff --git a/gfs2/fsck/pass1b.c b/gfs2/fsck/pass1b.c
index 62686fe..350902b 100644
--- a/gfs2/fsck/pass1b.c
+++ b/gfs2/fsck/pass1b.c
@@ -69,9 +69,8 @@ static void log_inode_reference(struct duptree *dt, osi_list_t *tmp, int inval)
(unsigned long long)dt->block, reftypestring);
}
-static int findref_meta(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h,
- int *is_valid, int *was_duplicate, void *private)
+static int findref_meta(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private)
{
*is_valid = 1;
*was_duplicate = 0;
@@ -393,10 +392,12 @@ static void resolve_dup_references(struct gfs2_sbd *sdp, struct duptree *dt,
return;
}
-static int clone_check_meta(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h,
- int *is_valid, int *was_duplicate, void *private)
+static int clone_check_meta(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private)
{
+ struct gfs2_inode *ip = iptr.ipt_ip;
+ uint64_t block = iptr_block(iptr);
+
*was_duplicate = 0;
*is_valid = 1;
*bh = bread(ip->i_sbd, block);
@@ -788,11 +789,12 @@ static int check_leaf_refs(struct gfs2_inode *ip, uint64_t block,
return add_duplicate_ref(ip, block, ref_as_meta, 1, INODE_VALID);
}
-static int check_metalist_refs(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h,
- int *is_valid, int *was_duplicate,
- void *private)
+static int check_metalist_refs(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private)
{
+ struct gfs2_inode *ip = iptr.ipt_ip;
+ uint64_t block = iptr_block(iptr);
+
*was_duplicate = 0;
*is_valid = 1;
return add_duplicate_ref(ip, block, ref_as_meta, 1, INODE_VALID);
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index d10b908..d80f306 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -1873,10 +1873,12 @@ struct metawalk_fxns pass2_fxns = {
.repair_leaf = pass2_repair_leaf,
};
-static int check_metalist_qc(struct gfs2_inode *ip, uint64_t block,
- struct gfs2_buffer_head **bh, int h,
- int *is_valid, int *was_duplicate, void *private)
+static int check_metalist_qc(struct iptr iptr, struct gfs2_buffer_head **bh, int h,
+ int *is_valid, int *was_duplicate, void *private)
{
+ struct gfs2_inode *ip = iptr.ipt_ip;
+ uint64_t block = iptr_block(iptr);
+
*was_duplicate = 0;
*is_valid = 1;
*bh = bread(ip->i_sbd, block);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 10 months
[gfs2-utils] 05/07: fsck.gfs2: Fix segfault in
build_and_check_metalist
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit ab1c367459b5fd71eb80ad40645f25c21b95e70d
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Oct 18 16:07:44 2019 +0100
fsck.gfs2: Fix segfault in build_and_check_metalist
In unlikely circumstances, indirect pointer corruption in a 'system'
inode's metadata tree can lead to the inode block state being marked as
'free' in pass1, which causes build_and_check_metalist() to be called in
pass 2. The pass has a NULL ->check_metalist function pointer and so a
segfault occurs when build_and_check_metalist attempts to call it.
Fix the segfault by calling ->check_metalist() only when it's not NULL.
This required some refactoring to make the extra level of if-nesting
easier to implement and read.
Resolves: rhbz#1487726
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/metawalk.c | 107 +++++++++++++++++++++++----------------------------
gfs2/fsck/metawalk.h | 1 +
2 files changed, 50 insertions(+), 58 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 4d6a2d2..dbe9f1f 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1207,6 +1207,51 @@ static void file_ra(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
extlen * sdp->bsize, POSIX_FADV_WILLNEED);
}
+static int do_check_metalist(struct gfs2_inode *ip, uint64_t block, int height,
+ struct gfs2_buffer_head **bhp, struct metawalk_fxns *pass)
+{
+ int was_duplicate = 0;
+ int is_valid = 1;
+ int error;
+
+ if (pass->check_metalist == NULL)
+ return 0;
+
+ error = pass->check_metalist(ip, block, bhp, height, &is_valid,
+ &was_duplicate, pass->private);
+ if (error == meta_error) {
+ stack;
+ log_info("\n");
+ log_info(_("Serious metadata error on block %"PRIu64" (0x%"PRIx64").\n"),
+ block, block);
+ return error;
+ }
+ if (error == meta_skip_further) {
+ log_info("\n");
+ log_info(_("Unrecoverable metadata error on block %"PRIu64" (0x%"PRIx64")\n"),
+ block, block);
+ log_info(_("Further metadata will be skipped.\n"));
+ return error;
+ }
+ if (!is_valid) {
+ log_debug("Skipping rejected block %"PRIu64" (0x%"PRIx64")\n", block, block);
+ if (pass->invalid_meta_is_fatal)
+ return meta_error;
+ return meta_skip_one;
+ }
+ if (was_duplicate) {
+ log_debug("Skipping duplicate %"PRIu64" (0x%"PRIx64")\n", block, block);
+ return meta_skip_one;
+ }
+ if (!valid_block_ip(ip, block)) {
+ log_debug("Skipping invalid block %"PRIu64" (0x%"PRIx64")\n", block, block);
+ if (pass->invalid_meta_is_fatal)
+ return meta_error;
+ return meta_skip_one;
+ }
+ return error;
+}
+
/**
* build_and_check_metalist - check a bunch of indirect blocks
* This includes hash table blocks for directories
@@ -1226,8 +1271,8 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
osi_list_t *prev_list, *cur_list, *tmp;
int h, head_size, iblk_type;
uint64_t *ptr, block, *undoptr;
- int error, was_duplicate, is_valid;
int maxptrs;
+ int error;
osi_list_add(&metabh->b_altlist, &mlp[0]);
@@ -1291,65 +1336,11 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
continue;
block = be64_to_cpu(*ptr);
- was_duplicate = 0;
- error = pass->check_metalist(ip, block, &nbh,
- h, &is_valid,
- &was_duplicate,
- pass->private);
- /* check_metalist should hold any buffers
- it gets with "bread". */
- if (error == meta_error) {
- stack;
- log_info(_("\nSerious metadata "
- "error on block %llu "
- "(0x%llx).\n"),
- (unsigned long long)block,
- (unsigned long long)block);
+ error = do_check_metalist(ip, block, h, &nbh, pass);
+ if (error == meta_error || error == meta_skip_further)
goto error_undo;
- }
- if (error == meta_skip_further) {
- log_info(_("\nUnrecoverable metadata "
- "error on block %llu "
- "(0x%llx). Further metadata"
- " will be skipped.\n"),
- (unsigned long long)block,
- (unsigned long long)block);
- goto error_undo;
- }
- if (!is_valid) {
- log_debug( _("Skipping rejected block "
- "%llu (0x%llx)\n"),
- (unsigned long long)block,
- (unsigned long long)block);
- if (pass->invalid_meta_is_fatal) {
- error = meta_error;
- goto error_undo;
- }
- continue;
- }
- /* Note that there's a special case in which
- we need to process the metadata block, even
- if it was a duplicate. That's for cases
- where we deleted the last reference as
- metadata. */
- if (was_duplicate) {
- log_debug( _("Skipping duplicate %llu "
- "(0x%llx)\n"),
- (unsigned long long)block,
- (unsigned long long)block);
+ if (error == meta_skip_one)
continue;
- }
- if (!valid_block_ip(ip, block)) {
- log_debug( _("Skipping invalid block "
- "%lld (0x%llx)\n"),
- (unsigned long long)block,
- (unsigned long long)block);
- if (pass->invalid_meta_is_fatal) {
- error = meta_error;
- goto error_undo;
- }
- continue;
- }
if (!nbh)
nbh = bread(ip->i_sbd, block);
osi_list_add_prev(&nbh->b_altlist, cur_list);
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index 119efee..b5a037a 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -39,6 +39,7 @@ enum meta_check_rc {
meta_error = -1,
meta_is_good = 0,
meta_skip_further = 1,
+ meta_skip_one = 2,
};
/* metawalk_fxns: function pointers to check various parts of the fs
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 10 months
[gfs2-utils] 04/07: fsck.gfs2: Disambiguate check_metalist
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit 9b201fd8c20a27d5802862ed63e895b5e4204b3e
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Fri Jun 14 11:41:03 2019 +0100
fsck.gfs2: Disambiguate check_metalist
Rename to pass1_check_metalist
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/pass1.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 0b59971..f03078e 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -39,7 +39,7 @@ struct block_count {
};
static int p1check_leaf(struct gfs2_inode *ip, uint64_t block, void *private);
-static int check_metalist(struct gfs2_inode *ip, uint64_t block,
+static int pass1_check_metalist(struct gfs2_inode *ip, uint64_t block,
struct gfs2_buffer_head **bh, int h, int *is_valid,
int *was_duplicate, void *private);
static int undo_check_metalist(struct gfs2_inode *ip, uint64_t block,
@@ -191,7 +191,7 @@ out:
struct metawalk_fxns pass1_fxns = {
.private = NULL,
.check_leaf = p1check_leaf,
- .check_metalist = check_metalist,
+ .check_metalist = pass1_check_metalist,
.check_data = pass1_check_data,
.check_eattr_indir = check_eattr_indir,
.check_eattr_leaf = check_eattr_leaf,
@@ -344,7 +344,7 @@ static int p1check_leaf(struct gfs2_inode *ip, uint64_t block, void *private)
return 0;
}
-static int check_metalist(struct gfs2_inode *ip, uint64_t block,
+static int pass1_check_metalist(struct gfs2_inode *ip, uint64_t block,
struct gfs2_buffer_head **bh, int h, int *is_valid,
int *was_duplicate, void *private)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 10 months
[gfs2-utils] 03/07: gfs2-utils: Accept a char* instead of a buffer
head in gfs2_check_meta
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit 2c070ddf1f552e459d8cb7e08e404b56480353df
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Mon Jan 28 15:50:51 2019 +0000
gfs2-utils: Accept a char* instead of a buffer head in gfs2_check_meta
This allows us to call it from different contexts.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 6 +++---
gfs2/edit/hexedit.c | 6 +++---
gfs2/edit/savemeta.c | 2 +-
gfs2/fsck/fs_recovery.c | 6 +++---
gfs2/fsck/initialize.c | 6 +++---
gfs2/fsck/metawalk.c | 10 +++++-----
gfs2/fsck/pass1.c | 12 ++++++------
gfs2/fsck/pass2.c | 8 ++++----
gfs2/fsck/pass5.c | 2 +-
gfs2/fsck/rgrepair.c | 10 +++++-----
gfs2/libgfs2/fs_ops.c | 6 +++---
gfs2/libgfs2/libgfs2.h | 2 +-
gfs2/libgfs2/rgrp.c | 2 +-
gfs2/libgfs2/structures.c | 6 +++---
gfs2/libgfs2/super.c | 2 +-
15 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 9845049..d13a525 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -832,7 +832,7 @@ static int fix_xattr(struct gfs2_sbd *sbp, struct gfs2_buffer_head *bh, struct g
/* Read in the i_di.di_eattr block */
eabh = bread(sbp, ip->i_di.di_eattr);
- if (!gfs2_check_meta(eabh, GFS_METATYPE_IN)) {/* if it is an indirect block */
+ if (!gfs2_check_meta(eabh->b_data, GFS_METATYPE_IN)) {/* if it is an indirect block */
len = sbp->bsize - sizeof(struct gfs_indirect);
buf = malloc(len);
if (!buf) {
@@ -1008,7 +1008,7 @@ static int next_rg_metatype(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
return -1;
bh = bread(sdp, *block);
first = 0;
- } while(gfs2_check_meta(bh, type));
+ } while(gfs2_check_meta(bh->b_data, type));
brelse(bh);
return 0;
}
@@ -1068,7 +1068,7 @@ static int inode_renumber(struct gfs2_sbd *sbp, uint64_t root_inode_addr, osi_li
sbp->sd_sb.sb_root_dir.no_formal_ino = sbp->md.next_inum;
}
bh = bread(sbp, block);
- if (!gfs2_check_meta(bh, GFS_METATYPE_DI)) {/* if it is an dinode */
+ if (!gfs2_check_meta(bh->b_data, GFS_METATYPE_DI)) {/* if it is an dinode */
/* Skip the rindex and jindex inodes for now. */
if (block != rindex_addr && block != jindex_addr) {
error = adjust_inode(sbp, bh);
diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
index b67fde2..923d6b4 100644
--- a/gfs2/edit/hexedit.c
+++ b/gfs2/edit/hexedit.c
@@ -1274,7 +1274,7 @@ static int find_rg_metatype(struct rgrp_tree *rgd, uint64_t *blk, uint64_t start
for (j = 0; j < m; j++) {
*blk = ibuf[j];
bhp = bread(&sbd, *blk);
- found = (*blk > startblk) && !gfs2_check_meta(bhp, mtype);
+ found = (*blk > startblk) && !gfs2_check_meta(bhp->b_data, mtype);
brelse(bhp);
if (found) {
free(ibuf);
@@ -2279,7 +2279,7 @@ static int count_dinode_blks(struct rgrp_tree *rgd, int bitmap,
rgd->bits[bitmap].bi_start + b);
byte = rbh->b_data + off + (b / GFS2_NBBY);
bit = (b % GFS2_NBBY) * GFS2_BIT_SIZE;
- if (gfs2_check_meta(tbh, GFS2_METATYPE_DI) == 0) {
+ if (gfs2_check_meta(tbh->b_data, GFS2_METATYPE_DI) == 0) {
dinodes++;
new_state = GFS2_BLKST_DINODE;
} else {
@@ -2350,7 +2350,7 @@ static void rg_repair(void)
printf("Bitmap #%d:", b);
rbh = bread(&sbd, rgd->ri.ri_addr + b);
- if (gfs2_check_meta(rbh, mtype)) { /* wrong type */
+ if (gfs2_check_meta(rbh->b_data, mtype)) { /* wrong type */
printf("Damaged. Repairing...");
/* Fix the meta header */
memset(rbh->b_data, 0, sbd.bsize);
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 04f67fc..1065e40 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -567,7 +567,7 @@ static int save_leaf_chain(struct metafd *mfd, struct gfs2_sbd *sdp, uint64_t bl
return 1;
}
warm_fuzzy_stuff(blk, FALSE);
- if (gfs2_check_meta(bh, GFS2_METATYPE_LF) == 0) {
+ if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_LF) == 0) {
int ret = save_bh(mfd, bh, blk, NULL);
if (ret != 0) {
brelse(bh);
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 17b2a3a..3acbb5d 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -211,7 +211,7 @@ static int revoke_lo_scan_elements(struct gfs2_inode *ip, unsigned int start,
return error;
if (!first) {
- if (gfs2_check_meta(bh, GFS2_METATYPE_LB))
+ if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_LB))
continue;
}
while (offset + sizeof(uint64_t) <= sdp->sd_sb.sb_bsize) {
@@ -355,7 +355,7 @@ static int foreach_descriptor(struct gfs2_inode *ip, unsigned int start,
bmodified(bh);
brelse(bh);
return error;
- } else if (gfs2_check_meta(bh, GFS2_METATYPE_LD)) {
+ } else if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_LD)) {
bmodified(bh);
brelse(bh);
return -EIO;
@@ -649,7 +649,7 @@ static int rangecheck_jmeta(struct gfs2_inode *ip, uint64_t block,
rc = rangecheck_jblock(ip, block);
if (rc == meta_is_good) {
*bh = bread(ip->i_sbd, block);
- *is_valid = (gfs2_check_meta(*bh, GFS2_METATYPE_IN) == 0);
+ *is_valid = (gfs2_check_meta((*bh)->b_data, GFS2_METATYPE_IN) == 0);
if (!(*is_valid)) {
log_err( _("Journal at block %lld (0x%llx) has a bad "
"indirect block pointer %lld (0x%llx) "
diff --git a/gfs2/fsck/initialize.c b/gfs2/fsck/initialize.c
index 4e323ff..5720c09 100644
--- a/gfs2/fsck/initialize.c
+++ b/gfs2/fsck/initialize.c
@@ -243,7 +243,7 @@ static void check_rgrp_integrity(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
if (state == GFS2_BLKST_DINODE) {
if (sdp->gfs1) {
bh = bread(sdp, diblock);
- if (!gfs2_check_meta(bh,
+ if (!gfs2_check_meta(bh->b_data,
GFS2_METATYPE_DI))
rg_useddi++;
else
@@ -298,7 +298,7 @@ static void check_rgrp_integrity(struct gfs2_sbd *sdp, struct rgrp_tree *rgd,
(unsigned long long)diblock,
(unsigned long long)diblock);
bh = bread(sdp, diblock);
- if (!gfs2_check_meta(bh, GFS2_METATYPE_DI)) {
+ if (!gfs2_check_meta(bh->b_data, GFS2_METATYPE_DI)) {
struct gfs2_inode *ip =
fsck_inode_get(sdp, rgd, bh);
if (ip->i_di.di_blocks > 1) {
@@ -1169,7 +1169,7 @@ static int peruse_metadata(struct gfs2_sbd *sdp, uint64_t startblock)
/* Max RG size is 2GB. 2G / bsize. */
for (blk = startblock; blk < startblock + max_rg_size; blk++) {
bh = bread(sdp, blk);
- if (gfs2_check_meta(bh, GFS2_METATYPE_DI)) {
+ if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_DI)) {
brelse(bh);
continue;
}
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index a334180..4d6a2d2 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -559,7 +559,7 @@ int check_leaf(struct gfs2_inode *ip, int lindex, struct metawalk_fxns *pass,
/* Try to read in the leaf block. */
lbh = bread(sdp, *leaf_no);
/* Make sure it's really a valid leaf block. */
- if (gfs2_check_meta(lbh, GFS2_METATYPE_LF)) {
+ if (gfs2_check_meta(lbh->b_data, GFS2_METATYPE_LF)) {
msg = _("that is not really a leaf");
goto bad_leaf;
}
@@ -768,7 +768,7 @@ int check_leaf_blks(struct gfs2_inode *ip, struct metawalk_fxns *pass)
if (valid_block_ip(ip, leaf_no)) {
lbh = bread(sdp, leaf_no);
/* Make sure it's really a valid leaf block. */
- if (gfs2_check_meta(lbh, GFS2_METATYPE_LF) == 0) {
+ if (gfs2_check_meta(lbh->b_data, GFS2_METATYPE_LF) == 0) {
brelse(lbh);
first_ok_leaf = leaf_no;
break;
@@ -1268,7 +1268,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
for (tmp = prev_list->next; tmp != prev_list; tmp = tmp->next){
bh = osi_list_entry(tmp, struct gfs2_buffer_head,
b_altlist);
- if (gfs2_check_meta(bh, iblk_type)) {
+ if (gfs2_check_meta(bh->b_data, iblk_type)) {
if (pass->invalid_meta_is_fatal)
return meta_error;
@@ -1513,7 +1513,7 @@ static int undo_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
static int hdr_size(struct gfs2_buffer_head *bh, int height)
{
if (height > 1) {
- if (gfs2_check_meta(bh, GFS2_METATYPE_IN))
+ if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_IN))
return 0;
if (bh->sdp->gfs1)
return sizeof(struct gfs_indirect);
@@ -1521,7 +1521,7 @@ static int hdr_size(struct gfs2_buffer_head *bh, int height)
return sizeof(struct gfs2_meta_header);
}
/* if this isn't really a dinode, skip it */
- if (gfs2_check_meta(bh, GFS2_METATYPE_DI))
+ if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_DI))
return 0;
return sizeof(struct gfs2_dinode);
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index c7de3e3..0b59971 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -393,7 +393,7 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
}
nbh = bread(ip->i_sbd, block);
- *is_valid = (gfs2_check_meta(nbh, iblk_type) == 0);
+ *is_valid = (gfs2_check_meta(nbh->b_data, iblk_type) == 0);
if (!(*is_valid)) {
log_err( _("Inode %lld (0x%llx) has a bad indirect block "
@@ -519,7 +519,7 @@ static int blockmap_set_as_data(struct gfs2_inode *ip, uint64_t block)
/* The bitmap says it's a dinode, but a block reference begs to differ.
So which is it? */
bh = bread(ip->i_sbd, block);
- if (gfs2_check_meta(bh, GFS2_METATYPE_DI) != 0)
+ if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_DI) != 0)
goto out;
/* The meta header agrees it's a dinode. But it might be data in
@@ -747,7 +747,7 @@ static int check_eattr_indir(struct gfs2_inode *ip, uint64_t indirect,
handling sort it out. If it isn't, clear it but don't
count it as a duplicate. */
*bh = bread(sdp, indirect);
- if (gfs2_check_meta(*bh, GFS2_METATYPE_IN)) {
+ if (gfs2_check_meta((*bh)->b_data, GFS2_METATYPE_IN)) {
bc->ea_count++;
if (q != GFS2_BLKST_FREE) { /* Duplicate? */
add_duplicate_ref(ip, indirect, ref_as_ea, 0,
@@ -829,7 +829,7 @@ static int check_ealeaf_block(struct gfs2_inode *ip, uint64_t block, int btype,
really is an EA. If it is, let duplicate handling sort it out.
If it isn't, clear it but don't count it as a duplicate. */
leaf_bh = bread(sdp, block);
- if (gfs2_check_meta(leaf_bh, btype)) {
+ if (gfs2_check_meta(leaf_bh->b_data, btype)) {
bc->ea_count++;
if (q != GFS2_BLKST_FREE) { /* Duplicate? */
add_duplicate_ref(ip, block, ref_as_ea, 0,
@@ -1666,7 +1666,7 @@ static int check_system_inode(struct gfs2_sbd *sdp,
" (0x%llx)\n"), filename,
(unsigned long long)iblock,
(unsigned long long)iblock);
- if (gfs2_check_meta((*sysinode)->i_bh, GFS2_METATYPE_DI)) {
+ if (gfs2_check_meta((*sysinode)->i_bh->b_data, GFS2_METATYPE_DI)) {
log_err( _("Found invalid system dinode at block #"
"%llu (0x%llx)\n"),
(unsigned long long)iblock,
@@ -1935,7 +1935,7 @@ static int pass1_process_bitmap(struct gfs2_sbd *sdp, struct rgrp_tree *rgd, uin
bh = bread(sdp, block);
is_inode = 0;
- if (gfs2_check_meta(bh, GFS2_METATYPE_DI) == 0)
+ if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_DI) == 0)
is_inode = 1;
check_magic = ((struct gfs2_meta_header *)
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index abc2b96..d10b908 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -651,7 +651,7 @@ static int basic_dentry_checks(struct gfs2_inode *ip, struct gfs2_dirent *dent,
struct gfs2_buffer_head *tbh;
tbh = bread(sdp, entry->no_addr);
- if (gfs2_check_meta(tbh, GFS2_METATYPE_DI)) { /* not dinode */
+ if (gfs2_check_meta(tbh->b_data, GFS2_METATYPE_DI)) { /* not dinode */
log_err( _("Directory entry '%s' pointing to block "
"%llu (0x%llx) in directory %llu (0x%llx) "
"is not really a GFS1 dinode.\n"), tmp_name,
@@ -1600,7 +1600,7 @@ static int check_hash_tbl_dups(struct gfs2_inode *ip, uint64_t *tbl,
continue;
lbh = bread(ip->i_sbd, leafblk);
- if (gfs2_check_meta(lbh, GFS2_METATYPE_LF)) { /* Chked later */
+ if (gfs2_check_meta(lbh->b_data, GFS2_METATYPE_LF)) { /* Chked later */
brelse(lbh);
continue;
}
@@ -1794,7 +1794,7 @@ static int check_hash_tbl(struct gfs2_inode *ip, uint64_t *tbl,
proper_len, proper_len);
lbh = bread(ip->i_sbd, leafblk);
gfs2_leaf_in(&leaf, lbh);
- if (gfs2_check_meta(lbh, GFS2_METATYPE_LF) ||
+ if (gfs2_check_meta(lbh->b_data, GFS2_METATYPE_LF) ||
leaf.lf_depth > ip->i_di.di_depth)
leaf.lf_depth = factor;
brelse(lbh);
@@ -1895,7 +1895,7 @@ static int check_data_qc(struct gfs2_inode *ip, uint64_t metablock,
return -1;
bh = bread(ip->i_sbd, block);
- if (gfs2_check_meta(bh, GFS2_METATYPE_QC) != 0) {
+ if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_QC) != 0) {
log_crit(_("Error: quota_change block at %lld (0x%llx) is "
"the wrong metadata type.\n"),
(unsigned long long)block, (unsigned long long)block);
diff --git a/gfs2/fsck/pass5.c b/gfs2/fsck/pass5.c
index 554f39f..6693daa 100644
--- a/gfs2/fsck/pass5.c
+++ b/gfs2/fsck/pass5.c
@@ -49,7 +49,7 @@ static int check_block_status(struct gfs2_sbd *sdp, struct gfs2_bmap *bl,
struct gfs2_buffer_head *bh;
bh = bread(sdp, block);
- if (gfs2_check_meta(bh, GFS2_METATYPE_DI) == 0)
+ if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_DI) == 0)
count[GFS2_BLKST_DINODE]++;
else
count[GFS1_BLKST_USEDMETA]++;
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index f397db1..9a91461 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -71,7 +71,7 @@ static void find_journaled_rgs(struct gfs2_sbd *sdp)
if (!dblock)
break;
bh = bread(sdp, dblock);
- if (!gfs2_check_meta(bh, GFS2_METATYPE_RG)) {
+ if (!gfs2_check_meta(bh->b_data, GFS2_METATYPE_RG)) {
/* False rgrp found at block dblock */
false_count++;
gfs2_special_set(&false_rgrps, dblock);
@@ -128,7 +128,7 @@ static int find_shortest_rgdist(struct gfs2_sbd *sdp, uint64_t *dist_array,
is_rgrp = 0;
else {
bh = bread(sdp, blk);
- is_rgrp = (gfs2_check_meta(bh, GFS2_METATYPE_RG) == 0);
+ is_rgrp = (gfs2_check_meta(bh->b_data, GFS2_METATYPE_RG) == 0);
brelse(bh);
}
if (!is_rgrp) {
@@ -146,7 +146,7 @@ static int find_shortest_rgdist(struct gfs2_sbd *sdp, uint64_t *dist_array,
is_rgrp = 0;
} else {
bh = bread(sdp, nblk);
- is_rgrp = (((gfs2_check_meta(bh,
+ is_rgrp = (((gfs2_check_meta(bh->b_data,
GFS2_METATYPE_RG) == 0)));
brelse(bh);
}
@@ -562,7 +562,7 @@ static int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs,
while (blk <= sdp->device.length) {
log_debug( _("Block 0x%llx\n"), (unsigned long long)blk);
bh = bread(sdp, blk);
- rg_was_fnd = (!gfs2_check_meta(bh, GFS2_METATYPE_RG));
+ rg_was_fnd = (!gfs2_check_meta(bh->b_data, GFS2_METATYPE_RG));
brelse(bh);
/* Allocate a new RG and index. */
calc_rgd = rgrp_insert(&sdp->rgcalc, blk);
@@ -594,7 +594,7 @@ static int gfs2_rindex_rebuild(struct gfs2_sbd *sdp, int *num_rgs,
for (fwd_block = blk + 1; fwd_block < sdp->device.length; fwd_block++) {
int bitmap_was_fnd;
bh = bread(sdp, fwd_block);
- bitmap_was_fnd = !gfs2_check_meta(bh, GFS2_METATYPE_RB);
+ 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++;
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 3acfb67..f796c76 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -883,7 +883,7 @@ void dirent2_del(struct gfs2_inode *dip, struct gfs2_buffer_head *bh,
uint16_t cur_rec_len, prev_rec_len;
bmodified(bh);
- if (gfs2_check_meta(bh, GFS2_METATYPE_LF) == 0) {
+ if (gfs2_check_meta(bh->b_data, GFS2_METATYPE_LF) == 0) {
struct gfs2_leaf *lf = (struct gfs2_leaf *)bh->b_data;
lf->lf_entries = be16_to_cpu(lf->lf_entries) - 1;
@@ -1102,7 +1102,7 @@ int gfs2_get_leaf(struct gfs2_inode *dip, uint64_t leaf_no,
int error = 0;
*bhp = bread(dip->i_sbd, leaf_no);
- error = gfs2_check_meta(*bhp, GFS2_METATYPE_LF);
+ error = gfs2_check_meta((*bhp)->b_data, GFS2_METATYPE_LF);
if(error)
brelse(*bhp);
return error;
@@ -1154,7 +1154,7 @@ static int get_next_leaf(struct gfs2_inode *dip,struct gfs2_buffer_head *bh_in,
if (*bh_out == NULL)
return -ENOENT;
/* Check for a leaf pointing to a non-leaf */
- if (gfs2_check_meta(*bh_out, GFS2_METATYPE_LF)) {
+ if (gfs2_check_meta((*bh_out)->b_data, GFS2_METATYPE_LF)) {
brelse(*bh_out);
*bh_out = NULL;
return -ENOENT;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 570c89b..228eceb 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -696,7 +696,7 @@ extern int build_quota(struct gfs2_sbd *sdp);
extern int build_root(struct gfs2_sbd *sdp);
extern int do_init_inum(struct gfs2_sbd *sdp);
extern int do_init_statfs(struct gfs2_sbd *sdp);
-extern int gfs2_check_meta(struct gfs2_buffer_head *bh, int type);
+extern int gfs2_check_meta(const char *buf, int type);
extern unsigned lgfs2_bm_scan(struct rgrp_tree *rgd, unsigned idx,
uint64_t *buf, uint8_t state);
extern int build_inum_range(struct gfs2_inode *per_node, unsigned int j);
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index bb0776a..0040d6d 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -184,7 +184,7 @@ uint64_t gfs2_rgrp_read(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
int mtype = (x ? GFS2_METATYPE_RB : GFS2_METATYPE_RG);
bi->bi_bh = bhs[x];
- if (gfs2_check_meta(bi->bi_bh, mtype)) {
+ if (gfs2_check_meta(bi->bi_bh->b_data, mtype)) {
unsigned err = x;
do {
brelse(rgd->bits[x].bi_bh);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 1cc88b5..208aa5d 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -593,10 +593,10 @@ int do_init_statfs(struct gfs2_sbd *sdp)
return 0;
}
-int gfs2_check_meta(struct gfs2_buffer_head *bh, int type)
+int gfs2_check_meta(const char *buf, int type)
{
- uint32_t check_magic = ((struct gfs2_meta_header *)(bh->b_data))->mh_magic;
- uint32_t check_type = ((struct gfs2_meta_header *)(bh->b_data))->mh_type;
+ uint32_t check_magic = ((struct gfs2_meta_header *)buf)->mh_magic;
+ uint32_t check_type = ((struct gfs2_meta_header *)buf)->mh_type;
check_magic = be32_to_cpu(check_magic);
check_type = be32_to_cpu(check_type);
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index cc9679f..5165754 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -182,7 +182,7 @@ static int good_on_disk(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
int is_rgrp;
bh = bread(sdp, rgd->ri.ri_addr);
- is_rgrp = (gfs2_check_meta(bh, GFS2_METATYPE_RG) == 0);
+ is_rgrp = (gfs2_check_meta(bh->b_data, GFS2_METATYPE_RG) == 0);
brelse(bh);
return is_rgrp;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 10 months
[gfs2-utils] 02/07: fsck.gfs2: Disambiguate 'check_data'
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit 0b04ce1ec5309002b5990e300c46a806421a8503
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Jun 4 17:16:18 2019 +0100
fsck.gfs2: Disambiguate 'check_data'
Having several functions with this name confuses profiling tools and
makes reports difficult to read. Give the different check_data
functions better names.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/metawalk.c | 4 ++--
gfs2/fsck/pass1.c | 6 +++---
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 4d6dcfa..a334180 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1390,7 +1390,7 @@ error_undo: /* undo what we've done so far for this block */
* 1 if errors were found and corrected
* 2 (ENOENT) is there were too many bad pointers
*/
-static int check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
+static int metawalk_check_data(struct gfs2_inode *ip, struct metawalk_fxns *pass,
struct gfs2_buffer_head *bh, int head_size,
uint64_t *blks_checked, struct error_block *error_blk)
{
@@ -1589,7 +1589,7 @@ int check_metatree(struct gfs2_inode *ip, struct metawalk_fxns *pass)
continue;
if (pass->check_data)
- error = check_data(ip, pass, bh, head_size,
+ error = metawalk_check_data(ip, pass, bh, head_size,
&blks_checked, &error_blk);
if (pass->big_file_msg && ip->i_di.di_blocks > COMFORTABLE_BLKS)
pass->big_file_msg(ip, blks_checked);
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 6f04109..c7de3e3 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -44,7 +44,7 @@ static int check_metalist(struct gfs2_inode *ip, uint64_t block,
int *was_duplicate, void *private);
static int undo_check_metalist(struct gfs2_inode *ip, uint64_t block,
int h, void *private);
-static int check_data(struct gfs2_inode *ip, uint64_t metablock,
+static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
struct gfs2_buffer_head *bh, uint64_t *ptr);
static int undo_check_data(struct gfs2_inode *ip, uint64_t block,
@@ -192,7 +192,7 @@ struct metawalk_fxns pass1_fxns = {
.private = NULL,
.check_leaf = p1check_leaf,
.check_metalist = check_metalist,
- .check_data = check_data,
+ .check_data = pass1_check_data,
.check_eattr_indir = check_eattr_indir,
.check_eattr_leaf = check_eattr_leaf,
.check_dentry = NULL,
@@ -542,7 +542,7 @@ out:
return error;
}
-static int check_data(struct gfs2_inode *ip, uint64_t metablock,
+static int pass1_check_data(struct gfs2_inode *ip, uint64_t metablock,
uint64_t block, void *private,
struct gfs2_buffer_head *bbh, uint64_t *ptr)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 10 months
[gfs2-utils] 01/07: libgfs2: Use sizeof for 'reserved' fields in
ondisk.c
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch RHEL7
in repository gfs2-utils.
commit f1969cd08d656377527455903d90431889c48211
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed May 9 17:59:32 2018 +0100
libgfs2: Use sizeof for 'reserved' fields in ondisk.c
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/ondisk.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/gfs2/libgfs2/ondisk.c b/gfs2/libgfs2/ondisk.c
index 66de223..bf3c663 100644
--- a/gfs2/libgfs2/ondisk.c
+++ b/gfs2/libgfs2/ondisk.c
@@ -189,7 +189,7 @@ void gfs2_rindex_in(struct gfs2_rindex *ri, char *buf)
CPIN_64(ri, str, ri_data0);
CPIN_32(ri, str, ri_data);
CPIN_32(ri, str, ri_bitbytes);
- CPIN_08(ri, str, ri_reserved, 64);
+ CPIN_08(ri, str, ri_reserved, sizeof(ri->ri_reserved));
}
void gfs2_rindex_out(const struct gfs2_rindex *ri, char *buf)
@@ -205,7 +205,7 @@ void gfs2_rindex_out(const struct gfs2_rindex *ri, char *buf)
CPOUT_32(ri, str, ri_bitbytes);
- CPOUT_08(ri, str, ri_reserved, 64);
+ CPOUT_08(ri, str, ri_reserved, sizeof(ri->ri_reserved));
}
void gfs2_rindex_print(const struct gfs2_rindex *ri)
@@ -228,7 +228,7 @@ void gfs2_rgrp_in(struct gfs2_rgrp *rg, struct gfs2_buffer_head *bh)
CPIN_32(rg, str, rg_free);
CPIN_32(rg, str, rg_dinodes);
- CPIN_08(rg, str, rg_reserved, 80);
+ CPIN_08(rg, str, rg_reserved, sizeof(rg->rg_reserved));
}
void gfs2_rgrp_out(const struct gfs2_rgrp *rg, char *buf)
@@ -240,7 +240,7 @@ void gfs2_rgrp_out(const struct gfs2_rgrp *rg, char *buf)
CPOUT_32(rg, str, rg_free);
CPOUT_32(rg, str, rg_dinodes);
- CPOUT_08(rg, str, rg_reserved, 80);
+ CPOUT_08(rg, str, rg_reserved, sizeof(rg->rg_reserved));
}
void gfs2_rgrp_out_bh(const struct gfs2_rgrp *rg, struct gfs2_buffer_head *bh)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 10 months
[gfs2-utils] branch master updated: mkfs.gfs2: Don't use i/o limits
hints <4K for block size
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
The following commit(s) were added to refs/heads/master by this push:
new b33f887 mkfs.gfs2: Don't use i/o limits hints <4K for block size
b33f887 is described below
commit b33f8871a821b7f0461dec89f0066a9cb6aa1c71
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed May 27 12:31:58 2020 +0100
mkfs.gfs2: Don't use i/o limits hints <4K for block size
Some devices report an optimal_io_size less than 4K. Currently mkfs.gfs2
uses the non-zero value to choose the block size, which is almost
certainly a bad choice when it's less than 4K. Update choose_blocksize()
to avoid using device topology hints for the block size choice when
they're less than the default block size (4K). Test case included.
Resolves: rhbz#1839219
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/mkfs/main_mkfs.c | 2 +-
tests/mkfs.at | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
index 846b341..412d470 100644
--- a/gfs2/mkfs/main_mkfs.c
+++ b/gfs2/mkfs/main_mkfs.c
@@ -505,7 +505,7 @@ static unsigned choose_blocksize(struct mkfs_opts *opts)
}
if (!opts->got_bsize && got_topol) {
if (dev->optimal_io_size <= getpagesize() &&
- dev->optimal_io_size >= dev->minimum_io_size)
+ dev->optimal_io_size >= GFS2_DEFAULT_BSIZE)
bsize = dev->optimal_io_size;
else if (dev->physical_sector_size <= getpagesize() &&
dev->physical_sector_size >= GFS2_DEFAULT_BSIZE)
diff --git a/tests/mkfs.at b/tests/mkfs.at
index 57785a0..4c8b224 100644
--- a/tests/mkfs.at
+++ b/tests/mkfs.at
@@ -112,6 +112,8 @@ AT_CLEANUP
AT_SETUP([Device i/o limits handling])
AT_KEYWORDS(mkfs.gfs2 mkfs)
AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=0:0:0:0:0 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=0:512:512:512:512 $GFS_TGT], 0, [ignore], [ignore])
+AT_CHECK([gfs2_edit -p sb field sb_bsize $GFS_TGT | tr -d '\n' ], 0, [4096], [ignore])
AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=7168:512:0:33553920:512 $GFS_TGT], 0, [ignore], [ignore])
AT_CHECK([$GFS_MKFS -p lock_nolock -o test_topology=7168:512:8192:33553920:512 $GFS_TGT], 0, [ignore], [Warning: device is not properly aligned. This may harm performance.
])
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
3 years, 10 months