From aefe5e7c6f92de5a8e68d894e10bdac1a12cbf1b Mon Sep 17 00:00:00 2001 From: Lachlan McIlroy Date: Wed, 17 Sep 2008 16:52:50 +1000 Subject: [PATCH] --- yaml --- r: 109903 b: refs/heads/master c: 2fd6f6ec64ff347447d26646ac6188f3658b383c h: refs/heads/master i: 109901: cdc403a0d73deacafea9a486fad216735b93b5c5 109899: a20753ac571e47a7690c0c5c069d19b5fba4bc5d 109895: 049ffed9a01505d64ed9f6eed0766040546c3f8c 109887: be0ce958c9b077ef0e7472f3b87cf254e008aa6e v: v3 --- [refs] | 2 +- trunk/fs/xfs/xfs_vnodeops.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index e87da38bef51..bcb3c8cfc53b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: e1f5dbd7077eebec794452a516cb02f1669b036d +refs/heads/master: 2fd6f6ec64ff347447d26646ac6188f3658b383c diff --git a/trunk/fs/xfs/xfs_vnodeops.c b/trunk/fs/xfs/xfs_vnodeops.c index 98a0aecafddc..8b6812f66a15 100644 --- a/trunk/fs/xfs/xfs_vnodeops.c +++ b/trunk/fs/xfs/xfs_vnodeops.c @@ -3160,6 +3160,13 @@ xfs_alloc_file_space( /* * Zero file bytes between startoff and endoff inclusive. * The iolock is held exclusive and no blocks are buffered. + * + * This function is used by xfs_free_file_space() to zero + * partial blocks when the range to free is not block aligned. + * When unreserving space with boundaries that are not block + * aligned we round up the start and round down the end + * boundaries and then use this function to zero the parts of + * the blocks that got dropped during the rounding. */ STATIC int xfs_zero_remaining_bytes( @@ -3176,6 +3183,17 @@ xfs_zero_remaining_bytes( int nimap; int error = 0; + /* + * Avoid doing I/O beyond eof - it's not necessary + * since nothing can read beyond eof. The space will + * be zeroed when the file is extended anyway. + */ + if (startoff >= ip->i_size) + return 0; + + if (endoff > ip->i_size) + endoff = ip->i_size; + bp = xfs_buf_get_noaddr(mp->m_sb.sb_blocksize, XFS_IS_REALTIME_INODE(ip) ? mp->m_rtdev_targp : mp->m_ddev_targp);