From: andros@netapp.com
To: bhalevy@panasas.com
Cc: linux-nfs@vger.kernel.org, Fred Isaman <iisaman@netapp.com>
Subject: [PATCH 2/2] SQUASHME pnfs-submit wave3 avoid calculating j index twice per call
Date: Mon, 14 Feb 2011 14:31:49 -0500 [thread overview]
Message-ID: <1297711909-27015-3-git-send-email-andros@netapp.com> (raw)
In-Reply-To: <1297711909-27015-2-git-send-email-andros@netapp.com>
From: Fred Isaman <iisaman@netapp.com>
Calculating the j index is expensive, so save and reuse it instead of recalculating.
Signed-off-by: Fred Isaman <iisaman@netapp.com>
---
fs/nfs/nfs4filelayout.c | 7 ++++---
fs/nfs/nfs4filelayout.h | 5 +++--
fs/nfs/nfs4filelayoutdev.c | 16 +++++++---------
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 80e7a66..3768377 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -220,7 +220,7 @@ filelayout_read_pagelist(struct nfs_read_data *data)
struct pnfs_layout_segment *lseg = data->lseg;
struct nfs4_pnfs_ds *ds;
loff_t offset = data->args.offset;
- u32 idx;
+ u32 j, idx;
struct nfs_fh *fh;
dprintk("--> %s ino %lu pgbase %u req %Zu@%llu\n",
@@ -228,7 +228,8 @@ filelayout_read_pagelist(struct nfs_read_data *data)
data->args.pgbase, (size_t)data->args.count, offset);
/* Retrieve the correct rpc_client for the byte range */
- idx = nfs4_fl_calc_ds_index(lseg, offset);
+ j = nfs4_fl_calc_j_index(lseg, offset);
+ idx = nfs4_fl_calc_ds_index(lseg, j);
ds = nfs4_fl_prepare_ds(lseg, idx);
if (!ds) {
/* Either layout fh index faulty, or ds connect failed */
@@ -241,7 +242,7 @@ filelayout_read_pagelist(struct nfs_read_data *data)
/* No multipath support. Use first DS */
data->ds_clp = ds->ds_clp;
- fh = nfs4_fl_select_ds_fh(lseg, offset);
+ fh = nfs4_fl_select_ds_fh(lseg, j);
if (fh)
data->args.fh = fh;
diff --git a/fs/nfs/nfs4filelayout.h b/fs/nfs/nfs4filelayout.h
index 7e33bd8..1809aa6 100644
--- a/fs/nfs/nfs4filelayout.h
+++ b/fs/nfs/nfs4filelayout.h
@@ -84,12 +84,13 @@ FILELAYOUT_LSEG(struct pnfs_layout_segment *lseg)
}
extern struct nfs_fh *
-nfs4_fl_select_ds_fh(struct pnfs_layout_segment *lseg, loff_t offset);
+nfs4_fl_select_ds_fh(struct pnfs_layout_segment *lseg, u32 j);
extern void nfs4_fl_free_deviceid_callback(struct pnfs_deviceid_node *);
extern void print_ds(struct nfs4_pnfs_ds *ds);
extern void print_deviceid(struct nfs4_deviceid *dev_id);
-u32 nfs4_fl_calc_ds_index(struct pnfs_layout_segment *lseg, loff_t offset);
+u32 nfs4_fl_calc_j_index(struct pnfs_layout_segment *lseg, loff_t offset);
+u32 nfs4_fl_calc_ds_index(struct pnfs_layout_segment *lseg, u32 j);
struct nfs4_pnfs_ds *nfs4_fl_prepare_ds(struct pnfs_layout_segment *lseg,
u32 ds_idx);
extern struct nfs4_file_layout_dsaddr *
diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c
index 1e1c536..2780d97 100644
--- a/fs/nfs/nfs4filelayoutdev.c
+++ b/fs/nfs/nfs4filelayoutdev.c
@@ -517,8 +517,8 @@ nfs4_fl_find_get_deviceid(struct nfs_client *clp, struct nfs4_deviceid *id)
* Want res = (offset - layout->pattern_offset)/ layout->stripe_unit
* Then: ((res + fsi) % dsaddr->stripe_count)
*/
-static u32
-_nfs4_fl_calc_j_index(struct pnfs_layout_segment *lseg, loff_t offset)
+u32
+nfs4_fl_calc_j_index(struct pnfs_layout_segment *lseg, loff_t offset)
{
struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
u64 tmp;
@@ -530,16 +530,13 @@ _nfs4_fl_calc_j_index(struct pnfs_layout_segment *lseg, loff_t offset)
}
u32
-nfs4_fl_calc_ds_index(struct pnfs_layout_segment *lseg, loff_t offset)
+nfs4_fl_calc_ds_index(struct pnfs_layout_segment *lseg, u32 j)
{
- u32 j;
-
- j = _nfs4_fl_calc_j_index(lseg, offset);
return FILELAYOUT_LSEG(lseg)->dsaddr->stripe_indices[j];
}
struct nfs_fh *
-nfs4_fl_select_ds_fh(struct pnfs_layout_segment *lseg, loff_t offset)
+nfs4_fl_select_ds_fh(struct pnfs_layout_segment *lseg, u32 j)
{
struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
u32 i;
@@ -551,11 +548,12 @@ nfs4_fl_select_ds_fh(struct pnfs_layout_segment *lseg, loff_t offset)
/* Use the MDS OPEN fh set in nfs_read_rpcsetup */
return NULL;
else
- i = nfs4_fl_calc_ds_index(lseg, offset);
+ i = nfs4_fl_calc_ds_index(lseg, j);
} else
- i = _nfs4_fl_calc_j_index(lseg, offset);
+ i = j;
return flseg->fh_array[i];
}
+
void
filelayout_mark_devid_negative(struct nfs_client *mds_clp,
struct pnfs_deviceid_node *devid,
--
1.6.6
next prev parent reply other threads:[~2011-02-14 19:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-14 19:31 [PATCH 0/2] update pnfs-submit-wave3 andros
2011-02-14 19:31 ` [PATCH 1/2] SQUASHME pnfs_submit wave3 general cleanup andros
2011-02-14 19:31 ` andros [this message]
2011-02-14 22:16 ` [PATCH 0/2] update pnfs-submit-wave3 Benny Halevy
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=1297711909-27015-3-git-send-email-andros@netapp.com \
--to=andros@netapp.com \
--cc=bhalevy@panasas.com \
--cc=iisaman@netapp.com \
--cc=linux-nfs@vger.kernel.org \
/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