* [PATCH] libext2fs: When truncating file, punch out blocks at end
@ 2012-01-07 4:47 Darrick J. Wong
2012-02-15 20:12 ` Ted Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2012-01-07 4:47 UTC (permalink / raw)
To: Theodore Tso, Darrick J. Wong; +Cc: linux-ext4
Currently, ext2fs_file_set_size2 punches out data blocks between the end of the
file and infinity when truncate_block <= old_truncate (i.e. when you've made
the file longer). This is not a useful behavior, particularly since it *fails*
to punch out the data blocks when the file is shortened (i.e. truncate_block <
old_truncate). This seems to be the result of the test being backwards, so fix
the code to punch only when the file is getting shorter.
Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
---
lib/ext2fs/fileio.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c
index d56f5b5..8751635 100644
--- a/lib/ext2fs/fileio.c
+++ b/lib/ext2fs/fileio.c
@@ -389,7 +389,7 @@ errcode_t ext2fs_file_set_size2(ext2_file_t file, ext2_off64_t size)
return retval;
}
- if (truncate_block <= old_truncate)
+ if (truncate_block >= old_truncate)
return 0;
return ext2fs_punch(file->fs, file->ino, &file->inode, 0,
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] libext2fs: When truncating file, punch out blocks at end
2012-01-07 4:47 [PATCH] libext2fs: When truncating file, punch out blocks at end Darrick J. Wong
@ 2012-02-15 20:12 ` Ted Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Ted Ts'o @ 2012-02-15 20:12 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-ext4
On Fri, Jan 06, 2012 at 08:47:37PM -0800, Darrick J. Wong wrote:
> Currently, ext2fs_file_set_size2 punches out data blocks between the
> end of the file and infinity when truncate_block <= old_truncate
> (i.e. when you've made the file longer). This is not a useful
> behavior, particularly since it *fails* to punch out the data blocks
> when the file is shortened (i.e. truncate_block < old_truncate).
> This seems to be the result of the test being backwards, so fix the
> code to punch only when the file is getting shorter.
>
> Signed-off-by: Darrick J. Wong <djwong@us.ibm.com>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-15 20:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-07 4:47 [PATCH] libext2fs: When truncating file, punch out blocks at end Darrick J. Wong
2012-02-15 20:12 ` Ted Ts'o
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.