From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [gfs2-utils PATCH] fsck.gfs2: File read-ahead
Date: Thu, 10 Jul 2014 12:54:44 -0400 (EDT) [thread overview]
Message-ID: <884434227.6309633.1405011284079.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <2043634717.6309285.1405011223827.JavaMail.zimbra@redhat.com>
Hi,
This patch introduces file read-ahead to pass1.
Regards,
Bob Peterson
Red Hat File Systems
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
gfs2/fsck/metawalk.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++--
gfs2/fsck/metawalk.h | 1 +
gfs2/fsck/pass1.c | 1 +
3 files changed, 65 insertions(+), 2 deletions(-)
diff --git a/gfs2/fsck/metawalk.c b/gfs2/fsck/metawalk.c
index 659af4e..8da17c6 100644
--- a/gfs2/fsck/metawalk.c
+++ b/gfs2/fsck/metawalk.c
@@ -1184,6 +1184,59 @@ static void free_metalist(struct gfs2_inode *ip, osi_list_t *mlp)
}
}
+static void file_ra(struct gfs2_inode *ip, struct gfs2_buffer_head *bh,
+ int head_size, int maxptrs, int h)
+{
+ struct gfs2_sbd *sdp = ip->i_sbd;
+ uint64_t *p, sblock = 0, block;
+ int extlen = 0;
+
+ if (h + 2 == ip->i_di.di_height) {
+ p = (uint64_t *)(bh->b_data + head_size);
+ if (*p && *(p + 1)) {
+ sblock = be64_to_cpu(*p);
+ p++;
+ block = be64_to_cpu(*p);
+ extlen = block - sblock;
+ if (extlen > 1 && extlen <= maxptrs) {
+ posix_fadvise(sdp->device_fd,
+ sblock * sdp->bsize,
+ (extlen + 1) * sdp->bsize,
+ POSIX_FADV_WILLNEED);
+ return;
+ }
+ }
+ extlen = 0;
+ }
+ for (p = (uint64_t *)(bh->b_data + head_size);
+ p < (uint64_t *)(bh->b_data + sdp->bsize); p++) {
+ if (*p) {
+ if (!sblock) {
+ sblock = be64_to_cpu(*p);
+ extlen = 1;
+ continue;
+ }
+ block = be64_to_cpu(*p);
+ if (block == sblock + extlen) {
+ extlen++;
+ continue;
+ }
+ }
+ if (extlen && sblock) {
+ if (extlen > 1)
+ extlen--;
+ posix_fadvise(sdp->device_fd, sblock * sdp->bsize,
+ extlen * sdp->bsize,
+ POSIX_FADV_WILLNEED);
+ extlen = 0;
+ p--;
+ }
+ }
+ if (extlen)
+ posix_fadvise(sdp->device_fd, sblock * sdp->bsize,
+ extlen * sdp->bsize, POSIX_FADV_WILLNEED);
+}
+
/**
* build_and_check_metalist - check a bunch of indirect blocks
* This includes hash table blocks for directories
@@ -1204,6 +1257,7 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
int h, head_size, iblk_type;
uint64_t *ptr, block;
int error, was_duplicate, is_valid;
+ int maxptrs;
osi_list_add(&metabh->b_altlist, &mlp[0]);
@@ -1225,13 +1279,18 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
iblk_type = GFS2_METATYPE_JD;
else
iblk_type = GFS2_METATYPE_IN;
- if (ip->i_sbd->gfs1)
+ if (ip->i_sbd->gfs1) {
head_size = sizeof(struct gfs_indirect);
- else
+ maxptrs = (ip->i_sbd->bsize - head_size) /
+ sizeof(uint64_t);
+ } else {
head_size = sizeof(struct gfs2_meta_header);
+ maxptrs = ip->i_sbd->sd_inptrs;
+ }
} else {
iblk_type = GFS2_METATYPE_DI;
head_size = sizeof(struct gfs2_dinode);
+ maxptrs = ip->i_sbd->sd_diptrs;
}
prev_list = &mlp[h - 1];
cur_list = &mlp[h];
@@ -1246,6 +1305,8 @@ static int build_and_check_metalist(struct gfs2_inode *ip, osi_list_t *mlp,
continue;
}
+ if (pass->readahead)
+ file_ra(ip, bh, head_size, maxptrs, h);
/* Now check the metadata itself */
for (ptr = (uint64_t *)(bh->b_data + head_size);
(char *)ptr < (bh->b_data + ip->i_sbd->bsize);
diff --git a/gfs2/fsck/metawalk.h b/gfs2/fsck/metawalk.h
index 5e30bfe..a4e0676 100644
--- a/gfs2/fsck/metawalk.h
+++ b/gfs2/fsck/metawalk.h
@@ -94,6 +94,7 @@ enum meta_check_rc {
struct metawalk_fxns {
void *private;
int invalid_meta_is_fatal;
+ int readahead;
int (*check_leaf_depth) (struct gfs2_inode *ip, uint64_t leaf_no,
int ref_count, struct gfs2_buffer_head *lbh);
int (*check_leaf) (struct gfs2_inode *ip, uint64_t block,
diff --git a/gfs2/fsck/pass1.c b/gfs2/fsck/pass1.c
index 4f1b77a..fec2f64 100644
--- a/gfs2/fsck/pass1.c
+++ b/gfs2/fsck/pass1.c
@@ -1055,6 +1055,7 @@ static int rangecheck_eattr_leaf(struct gfs2_inode *ip, uint64_t block,
struct metawalk_fxns rangecheck_fxns = {
.private = NULL,
+ .readahead = 1,
.check_metalist = rangecheck_metadata,
.check_data = rangecheck_data,
.check_leaf = rangecheck_leaf,
next parent reply other threads:[~2014-07-10 16:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2043634717.6309285.1405011223827.JavaMail.zimbra@redhat.com>
2014-07-10 16:54 ` Bob Peterson [this message]
2014-07-11 16:07 ` [Cluster-devel] [gfs2-utils PATCH] fsck.gfs2: File read-ahead Steven Whitehouse
2014-07-11 16:47 ` 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=884434227.6309633.1405011284079.JavaMail.zimbra@redhat.com \
--to=rpeterso@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.