aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/blocklayout/extents.c
diff options
context:
space:
mode:
authorFred Isaman <iisaman@citi.umich.edu>2011-07-30 20:52:41 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-07-31 12:18:16 -0400
commit9e69296999362c4e4b2821b64389b47e86e4821b (patch)
treee8810b4207cc054086eaeb519aa53d2af621ff0d /fs/nfs/blocklayout/extents.c
parente9643fe80d1a1e0ad6acdf43138c39b5709fdbbe (diff)
pnfsblock: basic extent code
Adds structures and basic create/delete code for extents. Signed-off-by: Fred Isaman <iisaman@citi.umich.edu> Signed-off-by: Benny Halevy <bhalevy@panasas.com> Signed-off-by: Zhang Jingwang <Jingwang.Zhang@emc.com> Signed-off-by: Benny Halevy <bhalevy@tonian.com> Signed-off-by: Jim Rees <rees@umich.edu> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/blocklayout/extents.c')
-rw-r--r--fs/nfs/blocklayout/extents.c89
1 files changed, 89 insertions, 0 deletions
diff --git a/fs/nfs/blocklayout/extents.c b/fs/nfs/blocklayout/extents.c
new file mode 100644
index 000000000000..d0ca7604d33e
--- /dev/null
+++ b/fs/nfs/blocklayout/extents.c
@@ -0,0 +1,89 @@
1/*
2 * linux/fs/nfs/blocklayout/blocklayout.h
3 *
4 * Module for the NFSv4.1 pNFS block layout driver.
5 *
6 * Copyright (c) 2006 The Regents of the University of Michigan.
7 * All rights reserved.
8 *
9 * Andy Adamson <andros@citi.umich.edu>
10 * Fred Isaman <iisaman@umich.edu>
11 *
12 * permission is granted to use, copy, create derivative works and
13 * redistribute this software and such derivative works for any purpose,
14 * so long as the name of the university of michigan is not used in
15 * any advertising or publicity pertaining to the use or distribution
16 * of this software without specific, written prior authorization. if
17 * the above copyright notice or any other identification of the
18 * university of michigan is included in any copy of any portion of
19 * this software, then the disclaimer below must also be included.
20 *
21 * this software is provided as is, without representation from the
22 * university of michigan as to its fitness for any purpose, and without
23 * warranty by the university of michigan of any kind, either express
24 * or implied, including without limitation the implied warranties of
25 * merchantability and fitness for a particular purpose. the regents
26 * of the university of michigan shall not be liable for any damages,
27 * including special, indirect, incidental, or consequential damages,
28 * with respect to any claim arising out or in connection with the use
29 * of the software, even if it has been or is hereafter advised of the
30 * possibility of such damages.
31 */
32
33#include "blocklayout.h"
34#define NFSDBG_FACILITY NFSDBG_PNFS_LD
35
36static void print_bl_extent(struct pnfs_block_extent *be)
37{
38 dprintk("PRINT EXTENT extent %p\n", be);
39 if (be) {
40 dprintk(" be_f_offset %llu\n", (u64)be->be_f_offset);
41 dprintk(" be_length %llu\n", (u64)be->be_length);
42 dprintk(" be_v_offset %llu\n", (u64)be->be_v_offset);
43 dprintk(" be_state %d\n", be->be_state);
44 }
45}
46
47static void
48destroy_extent(struct kref *kref)
49{
50 struct pnfs_block_extent *be;
51
52 be = container_of(kref, struct pnfs_block_extent, be_refcnt);
53 dprintk("%s be=%p\n", __func__, be);
54 kfree(be);
55}
56
57void
58bl_put_extent(struct pnfs_block_extent *be)
59{
60 if (be) {
61 dprintk("%s enter %p (%i)\n", __func__, be,
62 atomic_read(&be->be_refcnt.refcount));
63 kref_put(&be->be_refcnt, destroy_extent);
64 }
65}
66
67struct pnfs_block_extent *bl_alloc_extent(void)
68{
69 struct pnfs_block_extent *be;
70
71 be = kmalloc(sizeof(struct pnfs_block_extent), GFP_NOFS);
72 if (!be)
73 return NULL;
74 INIT_LIST_HEAD(&be->be_node);
75 kref_init(&be->be_refcnt);
76 be->be_inval = NULL;
77 return be;
78}
79
80static void print_elist(struct list_head *list)
81{
82 struct pnfs_block_extent *be;
83 dprintk("****************\n");
84 dprintk("Extent list looks like:\n");
85 list_for_each_entry(be, list, be_node) {
86 print_bl_extent(be);
87 }
88 dprintk("****************\n");
89}