From: Theodore Ts'o <tytso@mit.edu>
To: Jan Kara <jack@suse.cz>
Cc: linux-ext4@vger.kernel.org, stable@vger.kernel.org,
Zheng Liu <wenqing.lz@taobao.com>
Subject: Re: [PATCH 1/2] ext4: Fix SEEK_HOLE
Date: Sat, 20 May 2017 00:14:00 -0400 [thread overview]
Message-ID: <20170520041400.xrcels53pwk5py33@thunk.org> (raw)
In-Reply-To: <20170518104942.14588-2-jack@suse.cz>
On Thu, May 18, 2017 at 12:49:41PM +0200, Jan Kara wrote:
> Currently, SEEK_HOLE implementation in ext4 may both return that there's
> a hole at some offset although that offset already has data and skip
> some holes during a search for the next hole. The first problem is
> demostrated by:
>
> xfs_io -c "falloc 0 256k" -c "pwrite 0 56k" -c "seek -h 0" file
> wrote 57344/57344 bytes at offset 0
> 56 KiB, 14 ops; 0.0000 sec (2.054 GiB/sec and 538461.5385 ops/sec)
> Whence Result
> HOLE 0
>
> Where we can see that SEEK_HOLE wrongly returned offset 0 as containing
> a hole although we have written data there. The second problem can be
> demonstrated by:
>
> xfs_io -c "falloc 0 256k" -c "pwrite 0 56k" -c "pwrite 128k 8k"
> -c "seek -h 0" file
>
> wrote 57344/57344 bytes at offset 0
> 56 KiB, 14 ops; 0.0000 sec (1.978 GiB/sec and 518518.5185 ops/sec)
> wrote 8192/8192 bytes at offset 131072
> 8 KiB, 2 ops; 0.0000 sec (2 GiB/sec and 500000.0000 ops/sec)
> Whence Result
> HOLE 139264
>
> Where we can see that hole at offsets 56k..128k has been ignored by the
> SEEK_HOLE call.
>
> The underlying problem is in the ext4_find_unwritten_pgoff() which is
> just buggy. In some cases it fails to update returned offset when it
> finds a hole (when no pages are found or when the first found page has
> higher index than expected), in some cases conditions for detecting hole
> are just missing (we fail to detect a situation where indices of
> returned pages are not contiguous).
>
> Fix ext4_find_unwritten_pgoff() to properly detect non-contiguous page
> indices and also handle all cases where we got less pages then expected
> in one place and handle it properly there.
>
> CC: stable@vger.kernel.org
> Fixes: c8c0df241cc2719b1262e627f999638411934f60
> CC: Zheng Liu <wenqing.lz@taobao.com>
> Signed-off-by: Jan Kara <jack@suse.cz>
Thanks, applied.
- Ted
next prev parent reply other threads:[~2017-05-20 4:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-18 10:49 [PATCH 0/2 v3] ext4: Fix SEEK_HOLE implementation Jan Kara
2017-05-18 10:49 ` [PATCH 1/2] ext4: Fix SEEK_HOLE Jan Kara
2017-05-20 4:14 ` Theodore Ts'o [this message]
2017-05-18 10:49 ` [PATCH 2/2] ext4: Fix off-by-in in loop termination in ext4_find_unwritten_pgoff() Jan Kara
2017-05-20 4:15 ` Theodore Ts'o
-- strict thread matches above, loose matches on Subject: below --
2017-05-17 12:07 [PATCH 0/2 v2] ext4: Fix SEEK_HOLE implementation Jan Kara
2017-05-17 12:07 ` [PATCH 1/2] ext4: Fix SEEK_HOLE Jan Kara
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=20170520041400.xrcels53pwk5py33@thunk.org \
--to=tytso@mit.edu \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=wenqing.lz@taobao.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