On 2017/10/14 0:59, Weichao Guo wrote:
> Punching hole with a length which far larger than file size will
> cause a long time looping in truncate_hole after lock_op, it can
> be reproduced as the following:
>
> $ echo "abc" > file
> $ xfs_io -c "fpunch 0 HUGE_LENGTH" file
>
> This may cause other I/Os blocked a long time. Let's fix this case
> by setting the hole to end after the page that contains i_size.
You know, we can reserve blocks across EOF through fallocate(fd,
FALLOC_FL_KEEP_SIZE,
ofs, len), so this patch will cause f2fs losing ability of punching preallocated
blocks across EOF.
How about below change:
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index cfee75bf88d9..91fd2ef7221b 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -847,7 +847,7 @@ int truncate_hole(struct inode *inode, pgoff_t pg_start,
pgoff_t pg_end)
err = get_dnode_of_data(&dn, pg_start, LOOKUP_NODE);
if (err) {
if (err == -ENOENT) {
- pg_start++;
+ pg_start = get_next_page_offset(&dn, pg_start);
continue;
}
return err;
Thanks,
>
> Signed-off-by: Weichao Guo <[email protected]>
> ---
> fs/f2fs/file.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 517e112..1b44d26 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -873,6 +873,14 @@ static int punch_hole(struct inode *inode, loff_t
> offset, loff_t len)
> if (ret)
> return ret;
>
> + /*
> + * If the hole extends beyond i_size, set the hole
> + * to end after the page that contains i_size
> + */
> + if (offset + len > inode->i_size)
> + len = inode->i_size + PAGE_CACHE_SIZE -
> + (inode->i_size & (PAGE_CACHE_SIZE - 1)) - offset;
> +
> pg_start = ((unsigned long long) offset) >> PAGE_SHIFT;
> pg_end = ((unsigned long long) offset + len) >> PAGE_SHIFT;
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel