linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benny Halevy <benny@tonian.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 11/13] pnfsd-block: set the sbid part of the deviceid
Date: Sun,  4 Dec 2011 15:50:06 +0200	[thread overview]
Message-ID: <1323006606-13883-1-git-send-email-benny@tonian.com> (raw)
In-Reply-To: <4EDB79A9.2080109@tonian.com>

From: Benny Halevy <bhalevy@tonian.com>

Signed-off-by: Benny Halevy <bhalevy@tonian.com>
---
 fs/nfsd/bl_ops.c    |   34 ++++++++++++++++++----------------
 fs/nfsd/nfs4pnfsd.c |   28 +++++++++++++++++++++++++---
 fs/nfsd/pnfsd.h     |    1 +
 3 files changed, 44 insertions(+), 19 deletions(-)

diff --git a/fs/nfsd/bl_ops.c b/fs/nfsd/bl_ops.c
index f5980a3..04788a1 100644
--- a/fs/nfsd/bl_ops.c
+++ b/fs/nfsd/bl_ops.c
@@ -95,7 +95,7 @@
     dev_t devid, int my_loc, int idx);
 static int layout_cache_fill_from(bl_layout_rec_t *r, struct list_head *h,
     struct nfsd4_layout_seg *seg);
-struct list_head *layout_cache_iter(bl_layout_rec_t *r,
+struct list_head *layout_cache_iter(struct super_block *, bl_layout_rec_t *r,
     struct list_head *bl_possible, struct nfsd4_layout_seg *seg);
 static void layout_cache_merge(bl_layout_rec_t *r, struct list_head *h);
 static int layout_cache_update(bl_layout_rec_t *r, struct list_head *h);
@@ -117,8 +117,8 @@ static void extents_count(struct fiemap_extent_info *fei, struct inode *i,
 static boolean_t extents_get(struct fiemap_extent_info *fei, struct inode *i,
     u64 foff, u64 len);
 static boolean_t extents_process(struct fiemap_extent_info *fei,
-    struct list_head *bl_candidates, struct nfsd4_layout_seg *, dev_t dev,
-    pnfs_blocklayout_layout_t *b);
+    struct list_head *bl_candidates, struct nfsd4_layout_seg *,
+    u64 sbid, dev_t dev, pnfs_blocklayout_layout_t *b);
 static void extents_cleanup(struct fiemap_extent_info *fei);
 
 void
@@ -420,7 +420,7 @@ enum nfsstat4
 	res->lg_return_on_close	= 1;
 	res->lg_seg.length	= 0;
 	
-	bl_candidates = layout_cache_iter(r, &bl_possible, &res->lg_seg);
+	bl_candidates = layout_cache_iter(i->i_sb, r, &bl_possible, &res->lg_seg);
 	if (!bl_candidates) {
 		nfserr = NFS4ERR_LAYOUTTRYLATER;
 		goto layoutget_cleanup;
@@ -775,8 +775,8 @@ enum nfsstat4
 }
 
 struct list_head *
-layout_cache_iter(bl_layout_rec_t *r, struct list_head *bl_possible,
-    struct nfsd4_layout_seg *seg)
+layout_cache_iter(struct super_block *sb, bl_layout_rec_t *r,
+		  struct list_head *bl_possible, struct nfsd4_layout_seg *seg)
 {
 	pnfs_blocklayout_layout_t	*b,
 					*n		= NULL;
@@ -784,6 +784,7 @@ struct list_head *
 	struct fiemap_extent_info	fei;
 	struct inode			*i;
 	dev_t				dev;
+	u64				sbid = find_sbid(sb);
 	
 	dev	= r->blr_rdev;
 	i	= r->blr_inode;
@@ -810,7 +811,7 @@ struct list_head *
 				    b->bll_len) == False)
 					goto cleanup;
 				if (extents_process(&fei, bl_candidates,
-				    seg, dev, b) == False)
+						    seg, sbid, dev, b) == False)
 					goto cleanup;
 				extents_cleanup(&fei);
 				
@@ -825,7 +826,7 @@ struct list_head *
 				n = bll_alloc(b->bll_foff, b->bll_len,
 				    BLOCK_LAYOUT_NEW, bl_candidates);
 				n->bll_es = PNFS_BLOCK_NONE_DATA;
-				n->bll_vol_id.sbid = 0;
+				n->bll_vol_id.sbid = sbid;
 				n->bll_vol_id.devid = dev;
 				seg->length += b->bll_len;
 			} else {
@@ -1177,7 +1178,8 @@ struct list_head *
 	pnfs_blocklayout_layout_t	*b,
 					*n;
 	enum pnfs_block_extent_state4	s;
-	
+	u64				sbid = find_sbid(r->blr_inode->i_sb);
+
 	list_for_each_entry(b, &r->blr_layouts, bll_list) {
 		if (seg->offset < b->bll_foff) {
 			n = bll_alloc(seg->offset,
@@ -1218,7 +1220,7 @@ struct list_head *
 				return False;
 			
 			n->bll_soff = b->bll_soff + seg->offset - b->bll_foff;
-			n->bll_vol_id.sbid = 0;
+			n->bll_vol_id.sbid = sbid;
 			n->bll_vol_id.devid = b->bll_vol_id.devid;
 			n->bll_es = s;
 			seg->offset += n->bll_len;
@@ -1232,7 +1234,7 @@ struct list_head *
 
 static u64
 bll_alloc_holey(struct list_head *bl_candidates, u64 offset, u64 length,
-    dev_t dev)
+		u64 sbid, dev_t dev)
 {
 	pnfs_blocklayout_layout_t	*n;
 	
@@ -1240,7 +1242,7 @@ struct list_head *
 	if (!n)
 		return 0;
 	n->bll_es = PNFS_BLOCK_NONE_DATA;
-	n->bll_vol_id.sbid = 0;
+	n->bll_vol_id.sbid = sbid;
 	n->bll_vol_id.devid = dev;
 	
 	return n->bll_len;
@@ -1323,7 +1325,7 @@ struct list_head *
  */
 static boolean_t
 extents_process(struct fiemap_extent_info *fei, struct list_head *bl_candidates,
-    struct nfsd4_layout_seg *seg, dev_t dev, pnfs_blocklayout_layout_t *b)
+    struct nfsd4_layout_seg *seg, u64 sbid, dev_t dev, pnfs_blocklayout_layout_t *b)
 {
 	struct fiemap_extent		*fep,
 					*fep_last	= NULL;
@@ -1353,7 +1355,7 @@ struct list_head *
 			    _2SECTS(fep_last->fe_length));
 			last_end = fep_last->fe_logical + fep_last->fe_length;
 			rval = bll_alloc_holey(bl_candidates, last_end,
-			    fep->fe_logical - last_end, dev);
+			    fep->fe_logical - last_end, sbid, dev);
 			if (!rval)
 				return False;
 			seg->length += rval;
@@ -1369,7 +1371,7 @@ struct list_head *
 		n->bll_soff = fep->fe_physical;
 		n->bll_es = seg->iomode == IOMODE_READ ?
 		    PNFS_BLOCK_READ_DATA : PNFS_BLOCK_READWRITE_DATA;
-		n->bll_vol_id.sbid = 0;
+		n->bll_vol_id.sbid = sbid;
 		n->bll_vol_id.devid = dev;
 		seg->length += fep->fe_length;
 		print_bll(n, "New extent");
@@ -1638,7 +1640,7 @@ struct list_head *
 	if (n) {
 		n->bll_es			= b->bll_es;
 		n->bll_soff			= b->bll_soff;
-		n->bll_vol_id.devid		= b->bll_vol_id.devid;
+		n->bll_vol_id			= b->bll_vol_id;
 	}
 	return n;
 }
diff --git a/fs/nfsd/nfs4pnfsd.c b/fs/nfsd/nfs4pnfsd.c
index 42e2bb0..6b2e327 100644
--- a/fs/nfsd/nfs4pnfsd.c
+++ b/fs/nfsd/nfs4pnfsd.c
@@ -416,15 +416,14 @@ struct super_block *
 	return sb;
 }
 
-u64
-find_create_sbid(struct super_block *sb)
+static u64
+__find_sbid(struct super_block *sb)
 {
 	struct sbid_tracker *sbid;
 	unsigned long hash_idx = sbid_hashval(sb);
 	int pos = 0;
 	u64 id = 0;
 
-	spin_lock(&layout_lock);
 	list_for_each_entry (sbid, &sbid_hashtbl[hash_idx], hash) {
 		pos++;
 		if (sbid->sb != sb)
@@ -434,6 +433,29 @@ struct super_block *
 		id = sbid->id;
 		break;
 	}
+
+	return id;
+}
+
+u64
+find_sbid(struct super_block *sb)
+{
+	u64 id;
+
+	spin_lock(&layout_lock);
+	id = __find_sbid(sb);
+	spin_unlock(&layout_lock);
+
+	return id;
+}
+
+u64
+find_create_sbid(struct super_block *sb)
+{
+	u64 id;
+
+	spin_lock(&layout_lock);
+	id = __find_sbid(sb);
 	spin_unlock(&layout_lock);
 
 	if (!id)
diff --git a/fs/nfsd/pnfsd.h b/fs/nfsd/pnfsd.h
index f0862fb..abcb308 100644
--- a/fs/nfsd/pnfsd.h
+++ b/fs/nfsd/pnfsd.h
@@ -111,6 +111,7 @@ struct nfs4_notify_device {
 	struct nfsd4_callback		nd_recall;
 };
 
+u64 find_sbid(struct super_block *);
 u64 find_create_sbid(struct super_block *);
 struct super_block *find_sbid_id(u64);
 __be32 nfs4_pnfs_get_layout(struct nfsd4_pnfs_layoutget *, struct exp_xdr_stream *);
-- 
1.7.6


  parent reply	other threads:[~2011-12-04 13:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-04 13:46 [PATCH 0/13] misc pnfsd patches Benny Halevy
2011-12-04 13:47 ` [PATCH 01/13] SQUASHME: pnfsd: add missing nfs4_unlock_state in nfs4_pnfs_return_layout Benny Halevy
2011-12-04 13:48 ` [PATCH 02/13] DEBUG: pnfsd: printouts Benny Halevy
2011-12-04 13:48 ` [PATCH 03/13] pnfsd-block: reverse boolean_t values so they make sense Benny Halevy
2011-12-06  2:10   ` J. Bruce Fields
2011-12-06 11:27     ` Benny Halevy
2011-12-06 11:56       ` J. Bruce Fields
2011-12-07 12:45         ` Benny Halevy
2011-12-04 13:48 ` [PATCH 04/13] pnfsd-block: mv include/linux/nfsd4_block.h include/linux/nfsd/ Benny Halevy
2011-12-06  2:12   ` J. Bruce Fields
2011-12-06 11:28     ` Benny Halevy
2011-12-04 13:48 ` [PATCH 05/13] pnfsd-block: do not override s_pnfs_op Benny Halevy
2011-12-04 13:48 ` [PATCH 06/13] pnfsd-block: change blr_lock to mutex Benny Halevy
2011-12-04 13:49 ` [PATCH 07/13] pnfsd-block: dprint fiemap rval Benny Halevy
2011-12-04 13:49 ` [PATCH 08/13] pnfsd-block: allow positive " Benny Halevy
2011-12-04 13:49 ` [PATCH 09/13] pnfsd-block: use SECT_SIZE helper macros Benny Halevy
2011-12-04 13:49 ` [PATCH 10/13] pnfsd-block: undo dependence on spnfs Benny Halevy
2011-12-04 13:50 ` Benny Halevy [this message]
2011-12-04 13:50 ` [PATCH 12/13] DEBUG: pnfs: printouts Benny Halevy
2011-12-04 13:50 ` [PATCH 13/13] DEBUG: pnfsblock: add devid debug printouts 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=1323006606-13883-1-git-send-email-benny@tonian.com \
    --to=benny@tonian.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;
as well as URLs for NNTP newsgroup(s).