[Top] [All Lists]


To: Jeff Liu <jeff.liu@xxxxxxxxxx>
Subject: Re: SEEK_DATA/SEEK_HOLE support
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Tue, 4 Oct 2011 10:43:05 +1100
Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx>, xfs@xxxxxxxxxxx
In-reply-to: <4E89343B.4030007@xxxxxxxxxx>
References: <4E887D7F.2010306@xxxxxxxxxx> <20111002154259.GA14543@xxxxxxxxxxxxx> <4E888C0D.9060701@xxxxxxxxxx> <20111002175902.GA9420@xxxxxxxxxxxxx> <4E89343B.4030007@xxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Mon, Oct 03, 2011 at 12:04:11PM +0800, Jeff Liu wrote:
> On 10/03/2011 01:59 AM, Christoph Hellwig wrote:
> > On Mon, Oct 03, 2011 at 12:06:37AM +0800, Jeff Liu wrote:
> >> 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.
> > 
> > I'd suggest to first implement the simple versions I schemed below,
> > which would treat unwritten extents as data.  That is sub-optimal,
> > but a) safe and b) easy to implement.  The second step would be to
> > add probing for unwritten extents, which is even something we could
> > do as a common helper routine shared by filesystems.
> So I'll wait for Dave's patch become ready, and then continue to improve
> it if necessary.
> In the meantime, I'll try to figure out how to add a helper which can be
> shared by all file systems for UNWRITTEN extents.

The lookup is pretty simple - if there's cached data over the
unwritten range, then I'm considering it a data range. If there's no
cached data over the unwritten extent, it's a hole. That makes the
lookup simply a case of finding the first cached page in the
unwritten extent.

It'll end up reading something like this:

        iomap = offset_to_extent(offset);
        first_index = extent_to_page_index(iomap);

        nr_found = pagevec_lookup(&pvec, inode->i_mapping, first_index, 1);
        if (!nr_found)

        offset = page->index << PAGECACHE_SHIFT;

        /* If we fell off the end of the extent lookup next extent */
        if (offset >= end_of_extent(iomap)) {
                offset = end_of_extent(iomap);
                goto next_extent;

All the extent manipulations are pretty filesystem specific, so
there's not much that can be extracted into generic helper, I



Dave Chinner

<Prev in Thread] Current Thread [Next in Thread>