All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jim Rees <rees@umich.edu>
To: Trond Myklebust <Trond.Myklebust@netapp.com>
Cc: linux-nfs@vger.kernel.org
Subject: [PATCH v1 15/25] pnfsblock: bl_find_get_extent
Date: Sun, 17 Jul 2011 19:59:02 -0400	[thread overview]
Message-ID: <1310947152-12255-16-git-send-email-rees@umich.edu> (raw)
In-Reply-To: <1310947152-12255-1-git-send-email-rees@umich.edu>

=46rom: Fred <iisaman@citi.umich.edu>

Implement bl_find_get_extent(), one of the core extent manipulation
routines.

[pnfsblock: Lookup list entry of layouts and tags in reverse order]
Signed-off-by: Zhang Jingwang <zhangjingwang-U4AKAne5IzAR5TUyvShJeg@public.gmane.org>
Signed-off-by: Fred Isaman <iisaman@citi.umich.edu>
Signed-off-by: Benny Halevy <bhalevy@panasas.com>

pnfsblock: fix print format warnings for sector_t and size_t

gcc spews warnings about these on x86_64, e.g.:
fs/nfs/blocklayout/blocklayout.c:74: warning: format =E2=80=98%Lu=E2=80=
=99 expects type =E2=80=98long long unsigned int=E2=80=99, but argument=
 2 has type =E2=80=98sector_t=E2=80=99
fs/nfs/blocklayout/blocklayout.c:388: warning: format =E2=80=98%d=E2=80=
=99 expects type =E2=80=98int=E2=80=99, but argument 5 has type =E2=80=98=
size_t=E2=80=99

Signed-off-by: Benny Halevy <bhalevy@panasas.com>
Signed-off-by: Benny Halevy <benny@tonian.com>
---
 fs/nfs/blocklayout/blocklayout.h |    3 ++
 fs/nfs/blocklayout/extents.c     |   47 ++++++++++++++++++++++++++++++=
++++++++
 2 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/bloc=
klayout.h
index ee402c7..4e61b52 100644
--- a/fs/nfs/blocklayout/blocklayout.h
+++ b/fs/nfs/blocklayout/blocklayout.h
@@ -197,6 +197,9 @@ int nfs4_blk_process_layoutget(struct pnfs_layout_h=
dr *lo,
 void free_block_dev(struct pnfs_block_dev *bdev);
=20
 /* extents.c */
+struct pnfs_block_extent *
+bl_find_get_extent(struct pnfs_block_layout *bl, sector_t isect,
+		struct pnfs_block_extent **cow_read);
 void bl_put_extent(struct pnfs_block_extent *be);
 struct pnfs_block_extent *alloc_extent(void);
 int bl_add_merge_extent(struct pnfs_block_layout *bl,
diff --git a/fs/nfs/blocklayout/extents.c b/fs/nfs/blocklayout/extents.=
c
index d76bb43..14065ca 100644
--- a/fs/nfs/blocklayout/extents.c
+++ b/fs/nfs/blocklayout/extents.c
@@ -201,3 +201,50 @@ bl_add_merge_extent(struct pnfs_block_layout *bl,
 	bl_put_extent(new);
 	return -EIO;
 }
+
+/* Returns extent, or NULL.  If a second READ extent exists, it is ret=
urned
+ * in cow_read, if given.
+ *
+ * The extents are kept in two seperate ordered lists, one for READ an=
d NONE,
+ * one for READWRITE and INVALID.  Within each list, we assume:
+ * 1. Extents are ordered by file offset.
+ * 2. For any given isect, there is at most one extents that matches.
+ */
+struct pnfs_block_extent *
+bl_find_get_extent(struct pnfs_block_layout *bl, sector_t isect,
+	    struct pnfs_block_extent **cow_read)
+{
+	struct pnfs_block_extent *be, *cow, *ret;
+	int i;
+
+	dprintk("%s enter with isect %llu\n", __func__, (u64)isect);
+	cow =3D ret =3D NULL;
+	spin_lock(&bl->bl_ext_lock);
+	for (i =3D 0; i < EXTENT_LISTS; i++) {
+		if (ret &&
+		    (!cow_read || ret->be_state !=3D PNFS_BLOCK_INVALID_DATA))
+			break;
+		list_for_each_entry_reverse(be, &bl->bl_extents[i], be_node) {
+			if (isect >=3D be->be_f_offset + be->be_length)
+				break;
+			if (isect >=3D be->be_f_offset) {
+				/* We have found an extent */
+				dprintk("%s Get %p (%i)\n", __func__, be,
+					atomic_read(&be->be_refcnt.refcount));
+				kref_get(&be->be_refcnt);
+				if (!ret)
+					ret =3D be;
+				else if (be->be_state !=3D PNFS_BLOCK_READ_DATA)
+					bl_put_extent(be);
+				else
+					cow =3D be;
+				break;
+			}
+		}
+	}
+	spin_unlock(&bl->bl_ext_lock);
+	if (cow_read)
+		*cow_read =3D cow;
+	print_bl_extent(ret);
+	return ret;
+}
--=20
1.7.4.1


  parent reply	other threads:[~2011-07-17 23:59 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-17 23:58 [PATCH v1 00/25] add block layout driver to pnfs client Jim Rees
2011-07-17 23:58 ` [PATCH v1 01/25] pnfs: GETDEVICELIST Jim Rees
2011-07-17 23:58 ` [PATCH v1 02/25] pnfs: add set-clear layoutdriver interface Jim Rees
2011-07-17 23:58 ` [PATCH v1 03/25] NFS41: Let layoutcommit handle multiple segments Jim Rees
2011-07-17 23:58 ` [PATCH v1 04/25] NFS41: save layoutcommit cred after first successful layoutget Jim Rees
2011-07-17 23:58 ` [PATCH v1 05/25] pnfs: ask for layout_blksize and save it in nfs_server Jim Rees
2011-07-17 23:58 ` [PATCH v1 06/25] pnfs: cleanup_layoutcommit Jim Rees
2011-07-17 23:58 ` [PATCH v1 07/25] pnfsblock: add blocklayout Kconfig option, Makefile, and stubs Jim Rees
2011-07-17 23:58 ` [PATCH v1 08/25] pnfsblock: basic extent code Jim Rees
2011-07-17 23:58 ` [PATCH v1 09/25] pnfsblock: add device operations Jim Rees
2011-07-17 23:58 ` [PATCH v1 10/25] pnfsblock: remove " Jim Rees
2011-07-17 23:58 ` [PATCH v1 11/25] pnfsblock: lseg alloc and free Jim Rees
2011-07-17 23:58 ` [PATCH v1 12/25] pnfsblock: merge extents Jim Rees
2011-07-17 23:59 ` [PATCH v1 13/25] pnfsblock: call and parse getdevicelist Jim Rees
2011-07-17 23:59 ` [PATCH v1 14/25] pnfsblock: xdr decode pnfs_block_layout4 Jim Rees
2011-07-17 23:59 ` Jim Rees [this message]
2011-07-17 23:59 ` [PATCH v1 16/25] pnfsblock: add extent manipulation functions Jim Rees
2011-07-17 23:59 ` [PATCH v1 17/25] pnfsblock: merge rw extents Jim Rees
2011-07-17 23:59 ` [PATCH v1 18/25] pnfsblock: encode_layoutcommit Jim Rees
2011-07-17 23:59 ` [PATCH v1 19/25] pnfsblock: cleanup_layoutcommit Jim Rees
2011-07-17 23:59 ` [PATCH v1 20/25] pnfsblock: bl_read_pagelist Jim Rees
2011-07-17 23:59 ` [PATCH v1 21/25] pnfsblock: bl_write_pagelist Jim Rees
2011-07-17 23:59 ` [PATCH v1 22/25] pnfsblock: note written INVAL areas for layoutcommit Jim Rees
2011-07-17 23:59 ` [PATCH v1 23/25] pnfsblock: Implement release_inval_marks Jim Rees
2011-07-17 23:59 ` [PATCH v1 24/25] pnfsblock: use pageio_ops api Jim Rees
2011-07-17 23:59 ` [PATCH v1 25/25] pnfsblock: write_pagelist handle zero invalid extents Jim Rees

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=1310947152-12255-16-git-send-email-rees@umich.edu \
    --to=rees@umich.edu \
    --cc=Trond.Myklebust@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 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.