From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-xfs <linux-xfs@vger.kernel.org>,
Brian Foster <bfoster@redhat.com>,
Eric Sandeen <sandeen@redhat.com>,
Carlos Maiolino <cmaiolin@redhat.com>,
billodo@redhat.com, Dave Chinner <david@fromorbit.com>
Subject: Re: [RFC PATCH] xfs: refactor dir2 leaf readahead shadow buffer cleverness
Date: Fri, 28 Apr 2017 11:01:26 -0700 [thread overview]
Message-ID: <20170428180126.GB27447@birch.djwong.org> (raw)
In-Reply-To: <20170427073228.GB29468@infradead.org>
On Thu, Apr 27, 2017 at 12:32:28AM -0700, Christoph Hellwig wrote:
> On Mon, Apr 24, 2017 at 07:03:53PM -0700, Darrick J. Wong wrote:
> > Currently, the dir2 leaf block getdents function uses a complex state
> > tracking mechanism to create a shadow copy of the block mappings and
> > then uses the shadow copy to schedule readahead. Since the read and
> > readahead functions are perfectly capable of reading the mappings
> > themselves, we can tear all that out in favor of a simpler function that
> > simply keeps pushing the readahead window further out.
>
> I like where this goes a lot. A few more comments below:
>
> > + /* Flush old buf; remember its daddr for error detection. */
> > + if (*bpp) {
> > + old_daddr = (*bpp)->b_bn;
> > + xfs_trans_brelse(args->trans, *bpp);
>
> I don't really understand the whole old_daddr logic. How could we
> go backwards in the logic block space?
I was being overly paranoid that we could somehow end up with the same
buffer, but I've convinced myself that this isn't actually possible.
> > + * Look for mapped directory blocks at or above the current
> > + * offset. We must truncate down to the nearest directory
> > + * block to start the scanning operation.
>
> Use all 80 chars available on the terminal for comments, please :)
Ok.
> > + last_da = xfs_dir2_byte_to_da(geo, XFS_DIR2_LEAF_OFFSET);
> > + map_off = xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, *cur_off));
> > + do {
> > + nmap = 1;
> > + error = xfs_bmapi_read(dp, map_off, last_da - map_off,
> > + &map, &nmap, 0);
> > + if (error || !nmap)
> > + goto out;
> > + map_off = map.br_startoff + map.br_blockcount;
> > + } while (map_off < last_da && map.br_startblock == HOLESTARTBLOCK);
> > +
> > + if (map.br_startblock == HOLESTARTBLOCK)
> > goto out;
>
> This shows that xfs_bmapi_read really is the wrong interface for the
> calles. Raw calls to xfs_iext_lookup_extent / xfs_iext_get_extent would
> make this loop easier to understand, and also more efficient by not
> doing the full lookup.
>
> > + while (ra_want > 0 && next_ra < last_da) {
> > + nmap = 1;
> > + error = xfs_bmapi_read(dp, next_ra, last_da - next_ra,
> > + &map, &nmap, 0);
> > + if (error || !nmap)
> > + break;
> > + next_ra = roundup((xfs_dablk_t)map.br_startoff, geo->fsbcount);
> > + while (ra_want > 0 &&
> > + map.br_startblock != HOLESTARTBLOCK &&
> > + next_ra < map.br_startoff + map.br_blockcount) {
> > + xfs_dir3_data_readahead(dp, next_ra, -2);
> > + *ra_blk = next_ra;
> > + ra_want -= geo->fsbcount;
> > + next_ra += geo->fsbcount;
> > }
> > + next_ra = map.br_startoff + map.br_blockcount;
>
> Same here..
<nod>
--D
next prev parent reply other threads:[~2017-04-28 18:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-25 2:03 [RFC PATCH] xfs: refactor dir2 leaf readahead shadow buffer cleverness Darrick J. Wong
2017-04-27 7:32 ` Christoph Hellwig
2017-04-28 18:01 ` Darrick J. Wong [this message]
2017-04-27 13:04 ` Brian Foster
2017-04-28 18:46 ` Darrick J. Wong
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=20170428180126.GB27447@birch.djwong.org \
--to=darrick.wong@oracle.com \
--cc=bfoster@redhat.com \
--cc=billodo@redhat.com \
--cc=cmaiolin@redhat.com \
--cc=david@fromorbit.com \
--cc=hch@infradead.org \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.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;
as well as URLs for NNTP newsgroup(s).