[gfs2-utils] 03/03: libgfs2: Read multiple blocks at once in
gfs2_readi()
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-fsckperf
in repository gfs2-utils.
commit f3ad05fdab09f85db6c020d447b3faf11fdb36c9
Author: Andrew Price <anprice(a)redhat.com>
Date: Fri Mar 9 21:09:59 2018 +0000
libgfs2: Read multiple blocks at once in gfs2_readi()
Although gfs2_readi() does take the extent length passed back from
block_map() into account, it still reads the extents block-by-block
using bread(). Instead, read the blocks in one go and only do the
copying block-by-block.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_ops.c | 105 ++++++++++++++++++++++++++++----------------------
1 file changed, 58 insertions(+), 47 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 7e87e43..87b6d03 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -562,33 +562,24 @@ void block_map(struct gfs2_inode *ip, uint64_t lblock, int *new,
brelse(bh);
}
-static void
-copy2mem(struct gfs2_buffer_head *bh, void **buf, unsigned int offset,
- unsigned int size)
-{
- char **p = (char **)buf;
-
- if (bh)
- memcpy(*p, bh->b_data + offset, size);
- else
- memset(*p, 0, size);
-
- *p += size;
-}
-
-int gfs2_readi(struct gfs2_inode *ip, void *buf,
- uint64_t offset, unsigned int size)
+int gfs2_readi(struct gfs2_inode *ip, void *_buf, uint64_t offset, unsigned int size)
{
struct gfs2_sbd *sdp = ip->i_sbd;
- struct gfs2_buffer_head *bh;
uint64_t lblock, dblock;
+ char *buf = _buf;
unsigned int o;
uint32_t extlen = 0;
unsigned int amount;
int not_new = 0;
- int isdir = !!(S_ISDIR(ip->i_di.di_mode));
+ int isdir = S_ISDIR(ip->i_di.di_mode);
int journaled = ip->i_di.di_flags & GFS2_DIF_JDATA;
int copied = 0;
+ unsigned hoff;
+
+ if (sdp->gfs1)
+ hoff = (journaled) ? sizeof(struct gfs2_meta_header) : 0;
+ else
+ hoff = (isdir) ? sizeof(struct gfs2_meta_header) : 0;
if (offset >= ip->i_di.di_size)
return 0;
@@ -614,40 +605,60 @@ int gfs2_readi(struct gfs2_inode *ip, void *buf,
o += sizeof(struct gfs2_meta_header);
while (copied < size) {
- amount = size - copied;
- if (amount > sdp->bsize - o)
- amount = sdp->bsize - o;
+ char *dbuf = NULL;
+ uint32_t i;
- if (!extlen) {
- if (sdp->gfs1)
- gfs1_block_map(ip, lblock, ¬_new, &dblock,
- &extlen, FALSE);
- else
- block_map(ip, lblock, ¬_new, &dblock,
- &extlen, FALSE);
- }
+ if (sdp->gfs1)
+ gfs1_block_map(ip, lblock, ¬_new, &dblock, &extlen, FALSE);
+ else
+ block_map(ip, lblock, ¬_new, &dblock, &extlen, FALSE);
if (dblock) {
- if (dblock == ip->i_di.di_num.no_addr)
- bh = ip->i_bh;
- else
- bh = bread(sdp, dblock);
- dblock++;
- extlen--;
- } else
- bh = NULL;
-
- copy2mem(bh, &buf, o, amount);
- if (bh && bh != ip->i_bh)
- brelse(bh);
+ size_t count;
+ ssize_t ret;
+ off_t off;
+
+ if (extlen * sdp->bsize > size - copied)
+ extlen = ((size - copied) + sdp->bsize - 1) >>
+ sdp->sd_sb.sb_bsize_shift;
+
+ /* inode block might be dirty so use its contents if starting there */
+ if (dblock == ip->i_di.di_num.no_addr) {
+ amount = size - copied;
+ if (amount > sdp->bsize - o)
+ amount = sdp->bsize - o;
+
+ memcpy(buf + copied, ip->i_bh->b_data + o, amount);
+ copied += amount;
+ if (copied == size)
+ return copied;
+ extlen--;
+ dblock++;
+ lblock++;
+ o = hoff;
+ }
+ count = extlen * sdp->bsize;
+ off = dblock * sdp->bsize;
+ dbuf = malloc(count);
+ ret = pread(sdp->device_fd, dbuf, count, off);
+ if (ret != count) {
+ free(dbuf);
+ continue;
+ }
+ }
+ for (i = 0; i < extlen && copied < size; i++) {
+ char *b = dbuf + (i * sdp->bsize);
- copied += amount;
- lblock++;
+ amount = size - copied;
+ if (amount > sdp->bsize - o)
+ amount = sdp->bsize - o;
- if (sdp->gfs1)
- o = (journaled) ? sizeof(struct gfs2_meta_header) : 0;
- else
- o = (isdir) ? sizeof(struct gfs2_meta_header) : 0;
+ memcpy(buf + copied, b + o, amount);
+ copied += amount;
+ lblock++;
+ o = hoff;
+ }
+ free(dbuf);
}
return copied;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 1 month
[gfs2-utils] 02/03: fsck.gfs2: Scan log headers in multi-block
chunks
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-fsckperf
in repository gfs2-utils.
commit d93a20ad3c8b273b1f8740a6ebc121fed87ae325
Author: Andrew Price <anprice(a)redhat.com>
Date: Fri Mar 9 18:32:32 2018 +0000
fsck.gfs2: Scan log headers in multi-block chunks
check_journal_seq_no() scans log headers issuing block-by-block reads.
block_map() gives us the length of an extent we can read in one go but
block_map() is called deep in the call path that operates on a single
block. Instead, do the block_map() and read the extent in
check_journal_seq_no(), then scan the multi-block buffers for log
headers. This requires a new lgfs2_get_log_header() function that
accepts a buffer instead of reading one.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/fs_recovery.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++---
gfs2/libgfs2/libgfs2.h | 1 +
gfs2/libgfs2/recovery.c | 51 ++++++++++++++++++++++++++++---------------------
3 files changed, 78 insertions(+), 25 deletions(-)
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 677abd7..3eaf576 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -391,6 +391,39 @@ static int foreach_descriptor(struct gfs2_inode *ip, unsigned int start,
}
/**
+ * Read an extent from a gfs2 inode.
+ * lblk: The logical data block to read
+ * extlen: The length of the extent (in fs blocks) that is read
+ * Returns a buffer (*extlen * bsize) in size containing the inode data
+ * or NULL on error.
+ */
+static char *readi_extent(struct gfs2_inode *ip, uint64_t lblk, uint32_t *extlen)
+{
+ struct gfs2_sbd *sdp = ip->i_sbd;
+ uint64_t dblock;
+ int notnew = 0;
+ ssize_t bytes;
+ ssize_t bufsz;
+ char *buf;
+
+ block_map(ip, lblk, ¬new, &dblock, extlen, FALSE);
+ if (dblock == 0)
+ return NULL;
+
+ bufsz = *extlen * sdp->bsize;
+ buf = malloc(bufsz);
+ if (buf == NULL)
+ return NULL;
+
+ bytes = pread(sdp->device_fd, buf, bufsz, dblock * sdp->bsize);
+ if (bytes != bufsz) {
+ free(buf);
+ return NULL;
+ }
+ return buf;
+}
+
+/**
* check_journal_seq_no - Check and Fix log header sequencing problems
* @ip: the journal incore inode
* @fix: if 1, fix the sequence numbers, otherwise just report the problem
@@ -399,6 +432,7 @@ static int foreach_descriptor(struct gfs2_inode *ip, unsigned int start,
*/
static int check_journal_seq_no(struct gfs2_inode *ip, int fix)
{
+ struct gfs2_sbd *sdp = ip->i_sbd;
int error = 0, wrapped = 0;
uint32_t jd_blocks = ip->i_di.di_size / ip->i_sbd->sd_sb.sb_bsize;
uint32_t blk;
@@ -407,12 +441,22 @@ static int check_journal_seq_no(struct gfs2_inode *ip, int fix)
int new = 0;
uint64_t dblock;
struct gfs2_buffer_head *bh;
+ uint32_t extlen = 0;
int seq_errors = 0;
+ char *buf = NULL;
+ int b;
memset(&lh, 0, sizeof(lh));
- for (blk = 0; blk < jd_blocks; blk++) {
- error = get_log_header(ip, blk, &lh);
- if (error == 1) /* if not a log header */
+ for (blk = 0, b = 0; blk < jd_blocks; blk++, b++) {
+ if (extlen - b == 0) {
+ free(buf);
+ buf = readi_extent(ip, blk, &extlen);
+ if (buf == NULL)
+ return -1;
+ b = 0;
+ }
+ error = lgfs2_get_log_header(buf + (b * sdp->bsize), sdp->bsize, &lh);
+ if (error == 1 || lh.lh_blkno != blk) /* if not a log header */
continue; /* just journal data--ignore it */
if (!lowest_seq || lh.lh_sequence < lowest_seq)
lowest_seq = lh.lh_sequence;
@@ -448,6 +492,7 @@ static int check_journal_seq_no(struct gfs2_inode *ip, int fix)
bmodified(bh);
brelse(bh);
}
+ free(buf);
if (seq_errors && fix) {
log_err(_("%d sequence errors fixed.\n"), seq_errors);
seq_errors = 0;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 3a54195..215907a 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -660,6 +660,7 @@ 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 lgfs2_get_log_header(char *buf, unsigned bsize, struct gfs2_log_header *lh);
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);
diff --git a/gfs2/libgfs2/recovery.c b/gfs2/libgfs2/recovery.c
index 6b14bf9..1321b57 100644
--- a/gfs2/libgfs2/recovery.c
+++ b/gfs2/libgfs2/recovery.c
@@ -36,6 +36,31 @@ int gfs2_replay_read_block(struct gfs2_inode *ip, unsigned int blk,
return 0;
}
+int lgfs2_get_log_header(char *buf, unsigned bsize, struct gfs2_log_header *lh)
+{
+ struct gfs2_log_header *dlh = (struct gfs2_log_header *)buf;
+ uint32_t saved_hash;
+ uint32_t lh_crc = 0;
+ uint32_t hash;
+ uint32_t crc;
+
+ saved_hash = dlh->lh_hash;
+ dlh->lh_hash = 0;
+ hash = lgfs2_log_header_hash(buf);
+ dlh->lh_hash = saved_hash;
+ crc = lgfs2_log_header_crc(buf, bsize);
+ gfs2_log_header_in(lh, buf);
+#ifdef GFS2_HAS_LH_V2
+ lh_crc = lh->lh_crc;
+#endif
+ if (lh->lh_hash != hash)
+ return 1;
+ /* Don't check the crc if it's zero, as it is in pre-v2 log headers */
+ if (lh_crc != 0 && lh_crc != crc)
+ return 1;
+ return 0;
+}
+
/**
* get_log_header - read the log header for a given segment
* @ip: the journal incore inode
@@ -54,35 +79,17 @@ int get_log_header(struct gfs2_inode *ip, unsigned int blk,
struct gfs2_log_header *head)
{
struct gfs2_buffer_head *bh;
- struct gfs2_log_header lh, *tmp;
- uint32_t hash, saved_hash;
- uint32_t lh_crc = 0;
- uint32_t crc;
int error;
error = gfs2_replay_read_block(ip, blk, &bh);
if (error)
return error;
- tmp = (struct gfs2_log_header *)bh->b_data;
- saved_hash = tmp->lh_hash;
- 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);
- gfs2_log_header_in(&lh, bh->b_data);
- brelse(bh);
-#ifdef GFS2_HAS_LH_V2
- lh_crc = lh.lh_crc;
-#endif
- if (error || lh.lh_blkno != blk || lh.lh_hash != hash)
- return 1;
- /* Don't check the crc if it's zero, as it is in pre-v2 log headers */
- if (lh_crc != 0 && lh_crc != crc)
+ error = lgfs2_get_log_header(bh->b_data, ip->i_sbd->bsize, head);
+ if (error)
+ return error;
+ if (head->lh_blkno != blk)
return 1;
-
- *head = lh;
-
return 0;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 1 month
[gfs2-utils] 01/03: libgfs2: Read the rindex in one go
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-fsckperf
in repository gfs2-utils.
commit 53acc6ad8dc5297d4cc1085c9a402e87ae827006
Author: Andrew Price <anprice(a)redhat.com>
Date: Fri Mar 9 10:15:05 2018 +0000
libgfs2: Read the rindex in one go
Calling gfs2_readi() for each rindex entry causes many reads to be
issued for the indirect blocks as well as the data blocks in the rindex.
Read the whole thing into a buffer before processing each entry in turn.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/super.c | 51 ++++++++++++++++++++++++++++++---------------------
1 file changed, 30 insertions(+), 21 deletions(-)
diff --git a/gfs2/libgfs2/super.c b/gfs2/libgfs2/super.c
index 6e7d8c2..c01eefc 100644
--- a/gfs2/libgfs2/super.c
+++ b/gfs2/libgfs2/super.c
@@ -191,33 +191,41 @@ static int good_on_disk(struct gfs2_sbd *sdp, struct rgrp_tree *rgd)
*/
int rindex_read(struct gfs2_sbd *sdp, int fd, uint64_t *count1, int *sane)
{
- unsigned int rg;
- int error;
- union {
- struct gfs2_rindex bufgfs2;
- } buf;
+ unsigned int rgs;
+ size_t ri_size;
+ size_t bytes;
+ char *buf;
struct gfs2_rindex ri;
struct rgrp_tree *rgd = NULL, *prev_rgd = NULL;
uint64_t prev_length = 0;
+ unsigned int i;
*sane = 1;
*count1 = 0;
- if (!fd && sdp->md.riinode->i_di.di_size % sizeof(struct gfs2_rindex))
- *sane = 0; /* rindex file size must be a multiple of 96 */
- for (rg = 0; ; rg++) {
- if (fd > 0)
- error = read(fd, &buf, sizeof(struct gfs2_rindex));
- else
- error = gfs2_readi(sdp->md.riinode,
- (char *)&buf.bufgfs2,
- rg * sizeof(struct gfs2_rindex),
- sizeof(struct gfs2_rindex));
- if (!error)
- break;
- if (error != sizeof(struct gfs2_rindex))
- return -1;
+ if (fd > 0) {
+ struct stat st;
- gfs2_rindex_in(&ri, (char *)&buf.bufgfs2);
+ if (fstat(fd, &st) != 0)
+ return -1;
+ ri_size = st.st_size;
+ } else {
+ ri_size = sdp->md.riinode->i_di.di_size;
+ }
+ if (ri_size % sizeof(struct gfs2_rindex))
+ *sane = 0; /* rindex file size must be a multiple of 96 */
+ if ((buf = malloc(ri_size)) == NULL)
+ return -1;
+ if (fd > 0)
+ bytes = read(fd, buf, ri_size);
+ else
+ bytes = gfs2_readi(sdp->md.riinode, buf, 0, ri_size);
+ if (bytes != ri_size) {
+ free(buf);
+ return -1;
+ }
+ rgs = ri_size / sizeof(struct gfs2_rindex);
+ for (i = 0; i < rgs; i++) {
+ gfs2_rindex_in(&ri, buf + (sizeof(ri) * i));
if (gfs2_check_range(sdp, ri.ri_addr) != 0) {
*sane = 0;
if (prev_rgd == NULL)
@@ -236,7 +244,7 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, uint64_t *count1, int *sane)
*sane = 0;
else if (!rgd_seems_sane(sdp, rgd))
*sane = 0;
- else if (*sane && rg > 2 && prev_length &&
+ else if (*sane && i > 2 && prev_length &&
prev_length != rgd->start -
prev_rgd->start)
*sane = good_on_disk(sdp, rgd);
@@ -251,6 +259,7 @@ int rindex_read(struct gfs2_sbd *sdp, int fd, uint64_t *count1, int *sane)
(*count1)++;
prev_rgd = rgd;
}
+ free(buf);
if (prev_rgd)
prev_rgd->length = rgrp_size(prev_rgd);
if (*count1 == 0)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 1 month
[gfs2-utils] 09/09: gfs2l: Remove some dead code from the
interpreter loop
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 90c03cb519a08e24e542f56345a9ab28b9fbec9e
Author: Andrew Price <anprice(a)redhat.com>
Date: Wed Mar 7 11:53:18 2018 +0000
gfs2l: Remove some dead code from the interpreter loop
Spotted by coverity.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/gfs2l.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/gfs2/libgfs2/gfs2l.c b/gfs2/libgfs2/gfs2l.c
index 9c63ec4..a8aa5fa 100644
--- a/gfs2/libgfs2/gfs2l.c
+++ b/gfs2/libgfs2/gfs2l.c
@@ -178,10 +178,6 @@ int main(int argc, char *argv[])
for (result = lgfs2_lang_result_next(state, &sbd);
result != NULL;
result = lgfs2_lang_result_next(state, &sbd)) {
- if (result == NULL) {
- fprintf(stderr, "Failed to interpret script\n");
- return -1;
- }
lgfs2_lang_result_print(result);
lgfs2_lang_result_free(&result);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 1 month
[gfs2-utils] 08/09: glocktop: Fix memory leak in show_inode
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 08c1fd6f23d773ebafbf8ec5d645626c061c6615
Author: Andrew Price <anprice(a)redhat.com>
Date: Wed Mar 7 11:50:33 2018 +0000
glocktop: Fix memory leak in show_inode
Spotted by coverity.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/glocktop/glocktop.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
index 45d8c49..0305d3d 100644
--- a/gfs2/glocktop/glocktop.c
+++ b/gfs2/glocktop/glocktop.c
@@ -625,8 +625,10 @@ static const char *show_inode(const char *id, int fd, unsigned long long block)
break;
/* Stop at the root inode */
if (ip->i_di.di_num.no_addr ==
- parent->i_di.di_num.no_addr)
+ parent->i_di.di_num.no_addr) {
+ inode_put(&parent);
break;
+ }
inode_put(&ip);
ip = parent;
dirarray[subdepth++] = parent->i_di.di_num.no_addr;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 1 month
[gfs2-utils] 07/09: libgfs2: Fix a memory leak in lgfs2_build_jindex
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 21f522e24ef5a99eb0845c0846c053a7082835a5
Author: Andrew Price <anprice(a)redhat.com>
Date: Wed Mar 7 11:46:26 2018 +0000
libgfs2: Fix a memory leak in lgfs2_build_jindex
Spotted by coverity.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/structures.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 4cbd78a..c84701d 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -293,8 +293,10 @@ int lgfs2_build_jindex(struct gfs2_inode *master, struct gfs2_inum *jnls, size_t
for (j = 0; j < nmemb; j++) {
snprintf(fname, GFS2_FNAMESIZE, "journal%u", j);
ret = dir_add(jindex, fname, strlen(fname), &jnls[j], IF2DT(S_IFREG | 0600));
- if (ret)
+ if (ret) {
+ inode_put(&jindex);
return 1;
+ }
}
if (cfg_debug) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 1 month
[gfs2-utils] 06/09: gfs2-utils: Avoid some more potential in
overflows
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit dd314bd9df1f93d2608f50da7d73bf5d1ad99abc
Author: Andrew Price <anprice(a)redhat.com>
Date: Wed Mar 7 11:42:36 2018 +0000
gfs2-utils: Avoid some more potential in overflows
Spotted by coverity.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/savemeta.c | 2 +-
gfs2/fsck/rgrepair.c | 2 +-
gfs2/libgfs2/misc.c | 2 +-
gfs2/libgfs2/rgrp.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
index 25fd7bc..04f1221 100644
--- a/gfs2/edit/savemeta.c
+++ b/gfs2/edit/savemeta.c
@@ -744,7 +744,7 @@ static void get_journal_inode_blocks(void)
break;
gfs_jindex_in(&ji, jbuf);
jblock = ji.ji_addr;
- gfs1_journal_size = ji.ji_nsegment * 16;
+ gfs1_journal_size = (uint64_t)ji.ji_nsegment * 16;
} else {
if (journal > indirect->ii[0].dirents - 3)
break;
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index e45a649..2f14590 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -341,7 +341,7 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
return rgrp_dist;
}
mega_in_blocks = (1024 * 1024) / sdp->bsize;
- twogigs = 2048 * mega_in_blocks;
+ 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
the bare minimum block number where it ends. If we don't have
diff --git a/gfs2/libgfs2/misc.c b/gfs2/libgfs2/misc.c
index f6ae74c..6dfd9af 100644
--- a/gfs2/libgfs2/misc.c
+++ b/gfs2/libgfs2/misc.c
@@ -16,7 +16,7 @@ int compute_heightsize(unsigned bsize, uint64_t *heightsize,
uint32_t *maxheight, uint32_t bsize1, int diptrs, int inptrs)
{
heightsize[0] = bsize - sizeof(struct gfs2_dinode);
- heightsize[1] = bsize1 * diptrs;
+ heightsize[1] = (uint64_t)bsize1 * diptrs;
for (*maxheight = 2;; (*maxheight)++) {
uint64_t space, d;
uint32_t m;
diff --git a/gfs2/libgfs2/rgrp.c b/gfs2/libgfs2/rgrp.c
index 2d4fb78..b61c593 100644
--- a/gfs2/libgfs2/rgrp.c
+++ b/gfs2/libgfs2/rgrp.c
@@ -384,7 +384,7 @@ uint32_t lgfs2_rgrps_plan(const lgfs2_rgrps_t rgs, uint64_t space, uint32_t tgts
over all of the rgrps so that we don't end with a single
tiny one. */
rgs->plan[0].num++;
- while (((rgs->plan[0].len - adj) * (rgs->plan[0].num)) >= space)
+ while (((rgs->plan[0].len - adj) * (uint64_t)rgs->plan[0].num) >= space)
rgs->plan[0].len -= adj;
/* We've adjusted the size of the rgrps down as far as we can
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 1 month
[gfs2-utils] 05/09: gfs2_edit: Avoid a potential int overflow in
dump_journal
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 60b5256092bc53adaab5a9516e05ecd00ee5f11b
Author: Andrew Price <anprice(a)redhat.com>
Date: Wed Mar 7 11:32:36 2018 +0000
gfs2_edit: Avoid a potential int overflow in dump_journal
Spotted by coverity: "Potentially overflowing expression
(rgd->bits->bi_start + rgd->bits->bi_len) * 4U with type unsigned int
(32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used
in a context that expects an expression of type uint64_t (64 bits,
unsigned)"
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/journal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index 12a9c25..559bd4e 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -530,7 +530,7 @@ void dump_journal(const char *journal, int tblk)
rgd->ri.ri_length);
o = tblk - rgd->ri.ri_data0;
if (o >= (rgd->bits->bi_start +
- rgd->bits->bi_len) * GFS2_NBBY)
+ rgd->bits->bi_len) * (uint64_t)GFS2_NBBY)
o += (sizeof(struct gfs2_rgrp) -
sizeof(struct gfs2_meta_header))
* GFS2_NBBY;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 1 month
[gfs2-utils] 04/09: gfs2_edit: Avoid potential int overflow in
find_journal_block()
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 126942d61376bb2facdfcf067aa433bcae4c7d7d
Author: Andrew Price <anprice(a)redhat.com>
Date: Tue Mar 6 11:40:26 2018 +0000
gfs2_edit: Avoid potential int overflow in find_journal_block()
Spotted by coverity: "Potentially overflowing expression ji.ji_nsegment
* 16U with type unsigned int (32 bits, unsigned) is evaluated using
32-bit arithmetic, and then used in a context that expects an expression
of type uint64_t"
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/journal.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index 57bad84..12a9c25 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -72,7 +72,7 @@ uint64_t find_journal_block(const char *journal, uint64_t *j_size)
if (amtread) {
gfs_jindex_in(&ji, jbuf);
jblock = ji.ji_addr;
- *j_size = ji.ji_nsegment * 0x10;
+ *j_size = (uint64_t)ji.ji_nsegment * 0x10;
}
inode_put(&jiinode);
} else {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 1 month
[gfs2-utils] 03/09: fsck.gfs2: Avoid int overflow in
find_next_rgrp_dist
by git repository hosting
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch master
in repository gfs2-utils.
commit 1fcfbf36b1563f692d4a12a53f959fb21b42e32c
Author: Andrew Price <anprice(a)redhat.com>
Date: Tue Mar 6 11:31:44 2018 +0000
fsck.gfs2: Avoid int overflow in find_next_rgrp_dist
Spotted by coverity: "Potentially overflowing expression 2048 *
mega_in_blocks with type int (32 bits, signed) is evaluated using 32-bit
arithmetic, and then used in a context that expects an expression of
type uint64_t"
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/rgrepair.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index e64f70d..e45a649 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -324,7 +324,8 @@ static uint64_t find_next_rgrp_dist(struct gfs2_sbd *sdp, uint64_t blk,
struct rgrp_tree *rgd = NULL, *next_rgd;
struct gfs2_buffer_head *bh;
struct gfs2_meta_header mh;
- int first, length, b, found, mega_in_blocks;
+ int first, length, b, found;
+ uint64_t mega_in_blocks;
uint32_t free_blocks;
for (n = osi_first(&sdp->rgtree); n; n = next) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
6 years, 1 month