* [PATCH 1/2] ext4: Fix block zeroing when punching holes in indirect block files
@ 2014-06-18 19:33 Jan Kara
2014-06-18 19:33 ` [PATCH 2/2] ext4: Fix hole punching for files with indirect blocks Jan Kara
2014-06-19 15:38 ` [PATCH 1/2] ext4: Fix block zeroing when punching holes in indirect block files Lukáš Czerner
0 siblings, 2 replies; 4+ messages in thread
From: Jan Kara @ 2014-06-18 19:33 UTC (permalink / raw)
To: Ted Tso; +Cc: linux-ext4, Jan Kara
free_holes_block() passed local variable as a block pointer
to ext4_clear_blocks(). Thus ext4_clear_blocks() zeroed out this local
variable instead of proper place in inode / indirect block. We later
zero out proper place in inode / indirect block but don't dirty the
inode / buffer again which can lead to subtle issues (some changes e.g.
to inode can be lost).
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/indirect.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index 8a57e9fcd1b9..9d381707a6fc 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -1329,8 +1329,8 @@ static int free_hole_blocks(handle_t *handle, struct inode *inode,
if (level == 0 ||
(bh && all_zeroes((__le32 *)bh->b_data,
(__le32 *)bh->b_data + addr_per_block))) {
- ext4_free_data(handle, inode, parent_bh, &blk, &blk+1);
- *i_data = 0;
+ ext4_free_data(handle, inode, parent_bh,
+ i_data, i_data + 1);
}
brelse(bh);
bh = NULL;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ext4: Fix hole punching for files with indirect blocks
2014-06-18 19:33 [PATCH 1/2] ext4: Fix block zeroing when punching holes in indirect block files Jan Kara
@ 2014-06-18 19:33 ` Jan Kara
2014-06-19 15:38 ` [PATCH 1/2] ext4: Fix block zeroing when punching holes in indirect block files Lukáš Czerner
1 sibling, 0 replies; 4+ messages in thread
From: Jan Kara @ 2014-06-18 19:33 UTC (permalink / raw)
To: Ted Tso; +Cc: linux-ext4, Jan Kara, stable
Hole punching code for files with indirect blocks wrongly computed
number of blocks which need to be cleared when traversing the indirect
block tree. That could result in punching more blocks than actually
requested and thus effectively cause a data loss. For example:
fallocate -n -p 10240000 4096
will punch the range 10240000 - 12632064 instead of the range 1024000 -
10244096. Fix the calculation.
CC: stable@vger.kernel.org
Fixes: 8bad6fc813a3a5300f51369c39d315679fd88c72
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/indirect.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index 9d381707a6fc..771949c82715 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -1310,16 +1310,24 @@ static int free_hole_blocks(handle_t *handle, struct inode *inode,
blk = *i_data;
if (level > 0) {
ext4_lblk_t first2;
+ ext4_lblk_t count2;
+
bh = sb_bread(inode->i_sb, le32_to_cpu(blk));
if (!bh) {
EXT4_ERROR_INODE_BLOCK(inode, le32_to_cpu(blk),
"Read failure");
return -EIO;
}
- first2 = (first > offset) ? first - offset : 0;
+ if (first > offset) {
+ first2 = first - offset;
+ count2 = count;
+ } else {
+ first2 = 0;
+ count2 = count - (offset - first);
+ }
ret = free_hole_blocks(handle, inode, bh,
(__le32 *)bh->b_data, level - 1,
- first2, count - offset,
+ first2, count2,
inode->i_sb->s_blocksize >> 2);
if (ret) {
brelse(bh);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ext4: Fix block zeroing when punching holes in indirect block files
2014-06-18 19:33 [PATCH 1/2] ext4: Fix block zeroing when punching holes in indirect block files Jan Kara
2014-06-18 19:33 ` [PATCH 2/2] ext4: Fix hole punching for files with indirect blocks Jan Kara
@ 2014-06-19 15:38 ` Lukáš Czerner
1 sibling, 0 replies; 4+ messages in thread
From: Lukáš Czerner @ 2014-06-19 15:38 UTC (permalink / raw)
To: Jan Kara; +Cc: Ted Tso, linux-ext4
On Wed, 18 Jun 2014, Jan Kara wrote:
> Date: Wed, 18 Jun 2014 21:33:03 +0200
> From: Jan Kara <jack@suse.cz>
> To: Ted Tso <tytso@mit.edu>
> Cc: linux-ext4@vger.kernel.org, Jan Kara <jack@suse.cz>
> Subject: [PATCH 1/2] ext4: Fix block zeroing when punching holes in indirect
> block files
>
> free_holes_block() passed local variable as a block pointer
> to ext4_clear_blocks(). Thus ext4_clear_blocks() zeroed out this local
> variable instead of proper place in inode / indirect block. We later
> zero out proper place in inode / indirect block but don't dirty the
> inode / buffer again which can lead to subtle issues (some changes e.g.
> to inode can be lost).
Please see my patch
[PATCH] ext4: Fix punch hole on files with indirect mapping
which fixes those issues in a different way while also make this
operation faster.
Thanks!
-Lukas
>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/ext4/indirect.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
> index 8a57e9fcd1b9..9d381707a6fc 100644
> --- a/fs/ext4/indirect.c
> +++ b/fs/ext4/indirect.c
> @@ -1329,8 +1329,8 @@ static int free_hole_blocks(handle_t *handle, struct inode *inode,
> if (level == 0 ||
> (bh && all_zeroes((__le32 *)bh->b_data,
> (__le32 *)bh->b_data + addr_per_block))) {
> - ext4_free_data(handle, inode, parent_bh, &blk, &blk+1);
> - *i_data = 0;
> + ext4_free_data(handle, inode, parent_bh,
> + i_data, i_data + 1);
> }
> brelse(bh);
> bh = NULL;
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] ext4: Fix block zeroing when punching holes in indirect block files
2014-10-10 14:23 [PATCH 0/2 v2] Fix data corruption when blocksize < pagesize for mmapped data Jan Kara
@ 2014-10-10 14:23 ` Jan Kara
0 siblings, 0 replies; 4+ messages in thread
From: Jan Kara @ 2014-10-10 14:23 UTC (permalink / raw)
To: linux-fsdevel
Cc: Dave Kleikamp, jfs-discussion, tytso, Jeff Mahoney, Mark Fasheh,
Dave Chinner, reiserfs-devel, xfs, cluster-devel, Joel Becker,
Jan Kara, linux-ext4, Steven Whitehouse, ocfs2-devel, viro
free_holes_block() passed local variable as a block pointer
to ext4_clear_blocks(). Thus ext4_clear_blocks() zeroed out this local
variable instead of proper place in inode / indirect block. We later
zero out proper place in inode / indirect block but don't dirty the
inode / buffer again which can lead to subtle issues (some changes e.g.
to inode can be lost).
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/indirect.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index 8a57e9fcd1b9..9d381707a6fc 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -1329,8 +1329,8 @@ static int free_hole_blocks(handle_t *handle, struct inode *inode,
if (level == 0 ||
(bh && all_zeroes((__le32 *)bh->b_data,
(__le32 *)bh->b_data + addr_per_block))) {
- ext4_free_data(handle, inode, parent_bh, &blk, &blk+1);
- *i_data = 0;
+ ext4_free_data(handle, inode, parent_bh,
+ i_data, i_data + 1);
}
brelse(bh);
bh = NULL;
--
1.8.1.4
------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-10-10 14:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-18 19:33 [PATCH 1/2] ext4: Fix block zeroing when punching holes in indirect block files Jan Kara
2014-06-18 19:33 ` [PATCH 2/2] ext4: Fix hole punching for files with indirect blocks Jan Kara
2014-06-19 15:38 ` [PATCH 1/2] ext4: Fix block zeroing when punching holes in indirect block files Lukáš Czerner
-- strict thread matches above, loose matches on Subject: below --
2014-10-10 14:23 [PATCH 0/2 v2] Fix data corruption when blocksize < pagesize for mmapped data Jan Kara
2014-10-10 14:23 ` [PATCH 1/2] ext4: Fix block zeroing when punching holes in indirect block files Jan Kara
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).