cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2 Patch] GFS2: Add readahead to sequential directory traversal
Date: Wed, 05 Oct 2011 10:09:12 +0100	[thread overview]
Message-ID: <1317805752.2757.14.camel@menhir> (raw)
In-Reply-To: <efb32931-09c6-415e-9f47-2c85d32f6b59@zmail06.collab.prod.int.phx2.redhat.com>

Hi,

Were we not intending to make this turn itself off in cases where it
produces no benefit? I thought the plan was to track the state via the
file descriptor in order to avoid readingahead the same blocks over and
over again too,

Steve.

On Tue, 2011-10-04 at 12:39 -0400, Bob Peterson wrote:
> Hi,
> 
> This patch adds read-ahead capability to GFS2's
> directory hash table management.  It greatly improves
> performance for some directory operations.  For example:
> In one of my file systems that has 1000 directories, each
> of which has 1000 files, time to execute a recursive
> ls (time ls -fR /mnt/gfs2 > /dev/null) was reduced
> from 2m2.814s on a stock kernel to 0m45.938s.
> 
> Regards,
> 
> Bob Peterson
> Red Hat File Systems
> 
> Signed-off-by: Bob Peterson <rpeterso@redhat.com> 
> --
>  fs/gfs2/dir.c |   33 +++++++++++++++++++++++++++++++++
>  1 files changed, 33 insertions(+), 0 deletions(-)
> 
> diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c
> index 2045d70..9b4262e 100644
> --- a/fs/gfs2/dir.c
> +++ b/fs/gfs2/dir.c
> @@ -1376,6 +1376,37 @@ out:
>  	return error;
>  }
>  
> +static void gfs2_dir_readahead(struct inode *inode, __be64 *ht, unsigned hsize,
> +			       u32 index)
> +{
> +	struct gfs2_inode *ip = GFS2_I(inode);
> +	struct gfs2_glock *gl = ip->i_gl;
> +	struct buffer_head *bh;
> +	u64 blocknr = 0, last;
> +	unsigned count = 0;
> +
> +	while (index < hsize) {
> +		last = blocknr;
> +		blocknr = be64_to_cpu(ht[index++]);
> +		if (blocknr == last)
> +			continue;
> +		count++;
> +		if (count > 128)
> +			break;
> +		bh = gfs2_getbuf(gl, blocknr, 1);
> +		if (trylock_buffer(bh)) {
> +			if (buffer_uptodate(bh)) {
> +				unlock_buffer(bh);
> +				brelse(bh);
> +				continue;
> +			}
> +			bh->b_end_io = end_buffer_read_sync;
> +			submit_bh(READA | REQ_META, bh);
> +			continue;
> +		}
> +		brelse(bh);
> +	}
> +}
>  
>  /**
>   * dir_e_read - Reads the entries from a directory into a filldir buffer
> @@ -1406,6 +1437,8 @@ static int dir_e_read(struct inode *inode, u64 *offset, void *opaque,
>  	if (IS_ERR(lp))
>  		return PTR_ERR(lp);
>  
> +	gfs2_dir_readahead(inode, lp, hsize, index);
> +
>  	while (index < hsize) {
>  		error = gfs2_dir_read_leaf(inode, offset, opaque, filldir,
>  					   &copied, &depth,
> 




  reply	other threads:[~2011-10-05  9:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <db5d593f-00ad-45ad-b300-c018d8588a44@zmail06.collab.prod.int.phx2.redhat.com>
2011-10-04 16:39 ` [Cluster-devel] [GFS2 Patch] GFS2: Add readahead to sequential directory traversal Bob Peterson
2011-10-05  9:09   ` Steven Whitehouse [this message]
2011-10-06 16:15     ` Bob Peterson
2011-10-07 11:02       ` Steven Whitehouse
2011-10-07 16:01         ` Bob Peterson
2011-10-08 11:13           ` Steven Whitehouse
2011-10-10  8:49           ` Steven Whitehouse
2011-10-21 16:53             ` Bob Peterson
2011-10-24  8:17               ` Steven Whitehouse
2011-10-24 19:56                 ` Bob Peterson
2011-10-25  7:48                   ` Steven Whitehouse
2011-10-27 16:16                     ` Bob Peterson

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=1317805752.2757.14.camel@menhir \
    --to=swhiteho@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).