From: Jeff Liu <jeff.liu@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: "Michael L. Semon" <mlsemon35@gmail.com>,
"xfs@oss.sgi.com" <xfs@oss.sgi.com>
Subject: Re: [PATCH] xfs: fix s_max_bytes to MAX_LFS_FILESIZE if needed
Date: Wed, 10 Jul 2013 21:14:14 +0800 [thread overview]
Message-ID: <51DD5E26.7020709@oracle.com> (raw)
In-Reply-To: <20130710064855.GQ3438@dastard>
Hi Dave,
Thanks for the quick response.
On 07/10/2013 02:48 PM, Dave Chinner wrote:
> On Wed, Jul 10, 2013 at 02:28:20PM +0800, Jeff Liu wrote:
>> Could anyone help to review this patch?
>
> Sorry, I missed it.
>
>>> On 32-bit machine, the s_maxbytes is larger than the MAX_LFS_FILESIZE limits if CONFIG_LBDAF is
>>> not enabled. Hence it's possible to create a huge file via buffered-IO write with a given offset
>>> beyond this limitation. e.g.
>>>
>>> # block_size=4096
>>> # offset=$(((2**32 - 1) * $block_size))
>>> # xfs_io -f -c "pwrite $offset $block_size" /storage/test_file
>>>
>>> In this case, xfs_io will hang at the page writeback stage soon since the given offset would
>>> cause an overflow at xfs_vm_writepage():
>>>
>>> end_index = offset >> PAGE_CACHE_SHIFT;
>>> last_index = (offset - 1) >> PAGE_CACHE_SHIFT;
>>> if (page->index >= end_index) {
>>> unsigned offset_into_page = offset & (PAGE_CACHE_SIZE - 1);
>>>
>>> /*
>>> * Just skip the page if it is fully outside i_size, e.g. due
>>> * to a truncate operation that is in progress.
>>> */
>>> if (page->index >= end_index + 1 || offset_into_page == 0) {
>>> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>> unlock_page(page);
>>> return 0;
>>> }
>>> end_index is unsigned long so that the max value is '2^32-1 = 4294967295', and it
>>> would be evaluated to the max value with the given offset(when writing the page offset
>>> up to s_max_bytes) for above test case. As a result, (page->index >= end_index + 1) is
>>> ok as (end_index + 1) is overflowed to ZERO.
>>>
>>> Actually, create a file as above on 32-bit machine should be failed with EFBIG error returned
>>> because there has strict check up at generic_write_checks() against the given offset with a
>>> *correct* s_max_bytes.
>>>
>>> This patch fix the s_max_bytes to MAX_LFS_FILESIZE if the pre-calculated value is greater
>>> than it.
>
> Isn't MAX_LFS_FILESIZE defined on 32 bit systems to 8TB and the
> problem here is that we are overflowing at 16TB? If so, that means
> addin gthis patch will potentially cause problems with existing
> working setups that have (sparse) files larger than 8TB on 32 bit
> systems.
Yes, but maybe I should say end_index is wrapped to zero rather than
overflow in this situation.
>
> So, can't we simply subtract PAGE_CACHE_SIZE from the offset
> being returned to avoid this overflow?
It seems that this change does not works to me because page->index is
greater than end_index in most cases for large files.
IOWs, what I mentioned in comment log is incorrect and it misled you.
I worked out another patch, it looks works for this test but I need to
run some extra tests before posting.
Thanks,
-Jeff
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2013-07-10 13:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-12 10:26 [PATCH] xfs: fix s_max_bytes to MAX_LFS_FILESIZE if needed Jeff Liu
2013-04-12 15:20 ` Michael L. Semon
2013-04-13 5:03 ` Michael L. Semon
2013-04-13 21:20 ` Michael L. Semon
2013-04-16 5:40 ` Jeff Liu
2013-04-16 5:55 ` Michael L. Semon
2013-07-10 6:28 ` Jeff Liu
2013-07-10 6:48 ` Dave Chinner
2013-07-10 13:14 ` Jeff Liu [this message]
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=51DD5E26.7020709@oracle.com \
--to=jeff.liu@oracle.com \
--cc=david@fromorbit.com \
--cc=mlsemon35@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.