From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: tytso@mit.edu, darrick.wong@oracle.com
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH 04/14] filefrag: fix broken extent emulation and uninitialized variables
Date: Wed, 13 May 2015 17:21:34 -0700 [thread overview]
Message-ID: <20150514002134.10785.61003.stgit@birch.djwong.org> (raw)
In-Reply-To: <20150514002108.10785.85860.stgit@birch.djwong.org>
This started with the fm_ext being uninitialized, but upon closer
analysis I discovered that forcing extent emulation in FIBMAP mode
was reporting an extent for every block in the file. Fix both
problems.
The Coverity bug was 1297512.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
misc/filefrag.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/misc/filefrag.c b/misc/filefrag.c
index c1a8684..3b104c6 100644
--- a/misc/filefrag.c
+++ b/misc/filefrag.c
@@ -287,8 +287,8 @@ static int filefrag_fibmap(int fd, int blk_shift, int *num_extents,
const long bpib = st->st_blksize / 4;
int count;
+ memset(&fm_ext, 0, sizeof(fm_ext));
if (force_extent) {
- memset(&fm_ext, 0, sizeof(fm_ext));
fm_ext.fe_flags = FIEMAP_EXTENT_MERGED;
}
@@ -331,15 +331,17 @@ static int filefrag_fibmap(int fd, int blk_shift, int *num_extents,
blk_shift, st);
fm_ext.fe_length = 0;
(*num_extents)++;
+ fm_ext.fe_logical = logical;
+ fm_ext.fe_physical = block * st->st_blksize;
} else if (last_block && (block != last_block + 1)) {
if (verbose)
printf("Discontinuity: Block %ld is at %lu (was "
"%lu)\n", i, block, last_block + 1);
fm_ext.fe_length = 0;
(*num_extents)++;
+ fm_ext.fe_logical = logical;
+ fm_ext.fe_physical = block * st->st_blksize;
}
- fm_ext.fe_logical = logical;
- fm_ext.fe_physical = block * st->st_blksize;
fm_ext.fe_length += st->st_blksize;
last_block = block;
}
next prev parent reply other threads:[~2015-05-14 0:21 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-14 0:21 [PATCH 00/14] e2fsprogs May 2015 patchbomb Darrick J. Wong
2015-05-14 0:21 ` [PATCH 01/14] misc: fix Coverity bugs Darrick J. Wong
2015-05-16 22:36 ` Theodore Ts'o
2015-05-14 0:21 ` [PATCH 02/14] undo-io: write out index block after every write Darrick J. Wong
2015-05-17 0:18 ` Theodore Ts'o
2015-05-14 0:21 ` [PATCH 03/14] misc: fix undo file setup Darrick J. Wong
2015-05-17 0:20 ` Theodore Ts'o
2015-05-14 0:21 ` Darrick J. Wong [this message]
2015-05-17 0:26 ` [PATCH 04/14] filefrag: fix broken extent emulation and uninitialized variables Theodore Ts'o
2015-05-14 0:21 ` [PATCH 05/14] e2fsck: fix buffer overrun in revoke block scanning Darrick J. Wong
2015-05-14 19:37 ` [PATCH v2 " Darrick J. Wong
2015-05-17 0:50 ` Theodore Ts'o
2015-05-14 0:21 ` [PATCH 06/14] e2fsck: convert block-mapped files to extents on bigalloc fs Darrick J. Wong
2015-05-17 0:51 ` Theodore Ts'o
2015-05-14 0:21 ` [PATCH 07/14] libext2fs: support allocating uninit blocks in bmap2() Darrick J. Wong
2015-05-17 0:54 ` Theodore Ts'o
2015-05-14 0:22 ` [PATCH 08/14] libext2fs: find/alloc a range of empty blocks Darrick J. Wong
2015-05-17 1:02 ` Theodore Ts'o
2015-05-14 0:22 ` [PATCH 09/14] libext2fs: add new hooks to support large allocations Darrick J. Wong
2015-06-11 0:08 ` Theodore Ts'o
2015-05-14 0:22 ` [PATCH 10/14] libext2fs: implement fallocate Darrick J. Wong
2015-06-11 0:09 ` Theodore Ts'o
2015-05-14 0:22 ` [PATCH 11/14] libext2fs: use fallocate for creating journals and hugefiles Darrick J. Wong
2015-05-17 3:39 ` Theodore Ts'o
2015-05-18 19:24 ` Darrick J. Wong
2015-05-18 21:18 ` [PATCH v2 " Darrick J. Wong
2015-06-11 0:12 ` Theodore Ts'o
2015-05-14 0:22 ` [PATCH 12/14] debugfs: implement fallocate Darrick J. Wong
2015-06-11 0:12 ` Theodore Ts'o
2015-05-14 0:22 ` [PATCH 13/14] tests: test debugfs punch command Darrick J. Wong
2015-06-11 0:13 ` Theodore Ts'o
2015-05-18 21:17 ` [PATCH 15/14] libext2fs: remove unnecessary undo file flush calls Darrick J. Wong
2015-06-11 0:13 ` Theodore Ts'o
2015-06-05 1:38 ` [PATCH 16/14] libext2fs: require the inline data xattr on all inline data files Darrick J. Wong
2015-06-11 0:15 ` Theodore Ts'o
2015-07-23 21:12 ` Darrick J. Wong
[not found] ` <20150514002240.10785.35238.stgit@birch.djwong.org>
2015-06-11 0:13 ` [PATCH 14/14] misc: add fuse2fs, a FUSE server for e2fsprogs (v4.3) Theodore Ts'o
2015-06-15 18:37 ` Darrick J. Wong
2015-06-15 19:21 ` Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150514002134.10785.61003.stgit@birch.djwong.org \
--to=darrick.wong@oracle.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).