From: Christoph Hellwig <hch@infradead.org>
To: Lachlan McIlroy <lachlan@sgi.com>
Cc: xfs-dev <xfs-dev@sgi.com>, xfs-oss <xfs@oss.sgi.com>,
akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org
Subject: Re: [REVIEW] Prevent direct I/O from mapping extents beyond eof
Date: Fri, 15 Aug 2008 18:09:58 -0400 [thread overview]
Message-ID: <20080815220958.GB13770@infradead.org> (raw)
In-Reply-To: <48A50152.8020104@sgi.com>
On Fri, Aug 15, 2008 at 02:08:50PM +1000, Lachlan McIlroy wrote:
> With the help from some tracing I found that we try to map extents beyond
> eof when doing a direct I/O read. It appears that the way to inform the
> generic direct I/O path (ie do_direct_IO()) that we have breached eof is
> to return an unmapped buffer from xfs_get_blocks_direct(). This will cause
> do_direct_IO() to jump to the hole handling code where is will check for
> eof and then abort.
>
> This problem was found because a direct I/O read was trying to map beyond
> eof and was encountering delayed allocations. The delayed allocations beyond
> eof are speculative allocations and they didn't get converted when the direct
> I/O flushed the file because there was only enough space in the current AG
> to convert and write out the dirty pages within eof. Note that
> xfs_iomap_write_allocate() wont necessarily convert all the delayed allocation
> passed to it - it will return after allocating the first extent - so if the
> delayed allocation extends beyond eof then it will stay that way.
>
> This change will detect a direct I/O read beyond eof:
The change looks good to me, but I really think the direct I/O could
should never send down requests like this down to the filesystems. akpm
and -fsdevel Cc'ed.
> --- a/fs/xfs/linux-2.6/xfs_aops.c 2008-08-15 13:30:03.000000000 +1000
> +++ b/fs/xfs/linux-2.6/xfs_aops.c 2008-08-11 16:51:07.000000000 +1000
> @@ -1338,6 +1338,10 @@ __xfs_get_blocks(
> offset = (xfs_off_t)iblock << inode->i_blkbits;
> ASSERT(bh_result->b_size >= (1 << inode->i_blkbits));
> size = bh_result->b_size;
> +
> + if (!create && direct && offset >= i_size_read(inode))
> + return 0;
> +
> error = xfs_iomap(XFS_I(inode), offset, size,
> create ? flags : BMAPI_READ, &iomap, &niomap);
> if (error)
>
>
---end quoted text---
next parent reply other threads:[~2008-08-15 22:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <48A50152.8020104@sgi.com>
2008-08-15 22:09 ` Christoph Hellwig [this message]
2008-08-15 22:27 ` [REVIEW] Prevent direct I/O from mapping extents beyond eof Andrew Morton
2008-08-15 22:40 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080815220958.GB13770@infradead.org \
--to=hch@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=lachlan@sgi.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=xfs-dev@sgi.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox