From: Jeff Liu <jeff.liu@oracle.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: SEEK_DATA/SEEK_HOLE support
Date: Mon, 03 Oct 2011 00:06:37 +0800 [thread overview]
Message-ID: <4E888C0D.9060701@oracle.com> (raw)
In-Reply-To: <20111002154259.GA14543@infradead.org>
Hi Christoph,
Thanks for your prompt response!
On 10/02/2011 11:42 PM, Christoph Hellwig wrote:
> On Sun, Oct 02, 2011 at 11:04:31PM +0800, Jeff Liu wrote:
>> Dear developer,
>>
>> Does anyone already worked on SEEK_DATA/SEEK_HOLE for XFS? I'd like to
>> implement it if not. :)
>
> Dave mentioned he had a basic implementation, he might have some code
> that you can improve on.
>
> Did we get consensus about the the semantics of them for unwritten
> extents? If we want them to be exact in the fact of unwritten extents
> that is going to be the most work, e.g. if we find an unwritten extent
> we'll then have to do a pagecache lookup and check if pages are dirty
> and in that case not treat them as a hole.
IMHO, to avoid data loss in some user application like cp(1), for
unwritten extents, we always need to check the pages status. Just as
you mentioned above, return the map offset if pages are dirty for
SEEK_DATA, or a hole found.
-Jeff
>
> The rest of the implementation should be easy, e.g. doing something like
> the following pseudo-code which missed all the proper error codes and
> conversions from the lseek arguments to filesystem blocks and the
> required locking around it:
>
>
> seek_hole()
> {
> xfs_bmap_search_extents(ip, bno, XFS_DATA_FORK, &eof, &lastx, &got,
> &prev);
>
> for (;;) {
> if (eof) {
> /* past the file, nothing do here */
> return;
> }
>
> if (got.br_startoff > bno)
> /* found hole, return it */
> return;
> }
>
> if (++lastx == ifp->if_bytes / sizeof(xfs_bmbt_rec_t)) {
> /* reached EOF */
> return;
> }
> xfs_bmbt_get_all(xfs_iext_get_ext(ifp, lastx), &got);
> }
> }
>
> seek_data()
> {
> xfs_bmap_search_extents(ip, bno, XFS_DATA_FORK, &eof, &lastx, &got,
> &prev);
>
> for (;;) {
> if (eof) {
> /* past the file, nothing do here */
> return;
> }
>
> /* next data extent */
> return got.br_startoff < bno ? bno : got.br_startof;
> }
> }
>
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2011-10-02 16:06 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-02 15:04 SEEK_DATA/SEEK_HOLE support Jeff Liu
2011-10-02 15:42 ` Christoph Hellwig
2011-10-02 16:06 ` Jeff Liu [this message]
2011-10-02 17:59 ` Christoph Hellwig
2011-10-02 19:11 ` Andi Kleen
2011-10-03 4:04 ` Jeff Liu
2011-10-03 23:43 ` Dave Chinner
2011-10-04 13:02 ` Christoph Hellwig
2011-10-05 4:36 ` Dave Chinner
2011-10-05 5:32 ` Jeff Liu
2011-10-05 9:23 ` Dave Chinner
2011-10-05 13:56 ` Jeff Liu
2011-10-05 7:34 ` Michael Monnerie
2011-10-05 9:36 ` Dave Chinner
2011-10-05 18:22 ` Michael Monnerie
2011-10-06 0:32 ` Dave Chinner
2011-11-14 10:24 ` Christoph Hellwig
2011-11-14 12:47 ` Jeff Liu
2011-11-14 12:50 ` Christoph Hellwig
2011-11-19 8:29 ` XFS SEEK_DATA/SEEK_HOLE support V1 Jeff Liu
2011-11-19 8:34 ` Jeff Liu
2011-11-19 8:37 ` [PATCH] Introduce SEEK_DATA/SEEK_HOLE support to XFS V1 Jeff Liu
2011-11-19 19:11 ` Christoph Hellwig
2011-11-20 13:15 ` Jeff Liu
2011-11-20 0:30 ` Dave Chinner
2011-11-20 13:59 ` Jeff Liu
2011-11-20 15:30 ` Christoph Hellwig
2011-11-20 22:34 ` Dave Chinner
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=4E888C0D.9060701@oracle.com \
--to=jeff.liu@oracle.com \
--cc=hch@infradead.org \
--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