public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Don't do I/O beyond eof when unreserving space
@ 2008-09-02  5:24 Lachlan McIlroy
  2008-09-02 21:51 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Lachlan McIlroy @ 2008-09-02  5:24 UTC (permalink / raw)
  To: xfs-dev, xfs-oss

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Don't do I/O beyond eof when unreserving space
  2008-09-02  5:24 [PATCH] Don't do I/O beyond eof when unreserving space Lachlan McIlroy
@ 2008-09-02 21:51 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2008-09-02 21:51 UTC (permalink / raw)
  To: Lachlan McIlroy; +Cc: xfs-dev, xfs-oss

On Tue, Sep 02, 2008 at 03:24:57PM +1000, Lachlan McIlroy wrote:
> 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.

Makes sense.  Would be nice to have a comment above the check explaining
why these first strange checks are there.  Something like the first
setence of the patch description here.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-09-02 21:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-02  5:24 [PATCH] Don't do I/O beyond eof when unreserving space Lachlan McIlroy
2008-09-02 21:51 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox