xfs
[Top] [All Lists]

[PATCH] Don't do I/O beyond eof when unreserving space

To: xfs-dev <xfs-dev@xxxxxxx>, xfs-oss <xfs@xxxxxxxxxxx>
Subject: [PATCH] Don't do I/O beyond eof when unreserving space
From: Lachlan McIlroy <lachlan@xxxxxxx>
Date: Tue, 02 Sep 2008 15:24:57 +1000
Reply-to: lachlan@xxxxxxx
User-agent: Thunderbird 2.0.0.16 (X11/20080707)
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,
xfs_zero_remaining_bytes(), to zero the parts of the blocks that got dropped
during the rounding.  The problem is we don't consider if these blocks are
beyond eof.  Worse still is if we encounter delayed allocations beyond eof
we will try to use the magic delayed allocation block number as a real block
number.  If the file size is ever extended to expose these blocks then we'll
go through xfs_zero_eof() to zero them anyway.

--- a/fs/xfs/xfs_vnodeops.c     2008-09-02 14:54:24.000000000 +1000
+++ b/fs/xfs/xfs_vnodeops.c     2008-09-02 14:51:03.000000000 +1000
@@ -3176,6 +3176,12 @@ xfs_zero_remaining_bytes(
        int                     nimap;
        int                     error = 0;

+       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);

<Prev in Thread] Current Thread [Next in Thread>