aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/blocklayout/Makefile2
-rw-r--r--fs/nfs/blocklayout/blocklayout.c20
-rw-r--r--fs/nfs/blocklayout/blocklayout.h1
-rw-r--r--fs/nfs/blocklayout/extents.c89
4 files changed, 107 insertions, 5 deletions
diff --git a/fs/nfs/blocklayout/Makefile b/fs/nfs/blocklayout/Makefile
index 6bf49cd5da06..5cfadf6ebc90 100644
--- a/fs/nfs/blocklayout/Makefile
+++ b/fs/nfs/blocklayout/Makefile
@@ -2,4 +2,4 @@
2# Makefile for the pNFS block layout driver kernel module 2# Makefile for the pNFS block layout driver kernel module
3# 3#
4obj-$(CONFIG_PNFS_BLOCK) += blocklayoutdriver.o 4obj-$(CONFIG_PNFS_BLOCK) += blocklayoutdriver.o
5blocklayoutdriver-objs := blocklayout.o 5blocklayoutdriver-objs := blocklayout.o extents.o
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index 1f5287c2230a..8dde3723482e 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -53,12 +53,24 @@ bl_write_pagelist(struct nfs_write_data *wdata,
53 return PNFS_NOT_ATTEMPTED; 53 return PNFS_NOT_ATTEMPTED;
54} 54}
55 55
56/* STUB */ 56/* FIXME - range ignored */
57static void 57static void
58release_extents(struct pnfs_block_layout *bl, 58release_extents(struct pnfs_block_layout *bl, struct pnfs_layout_range *range)
59 struct pnfs_layout_range *range)
60{ 59{
61 return; 60 int i;
61 struct pnfs_block_extent *be;
62
63 spin_lock(&bl->bl_ext_lock);
64 for (i = 0; i < EXTENT_LISTS; i++) {
65 while (!list_empty(&bl->bl_extents[i])) {
66 be = list_first_entry(&bl->bl_extents[i],
67 struct pnfs_block_extent,
68 be_node);
69 list_del(&be->be_node);
70 bl_put_extent(be);
71 }
72 }
73 spin_unlock(&bl->bl_ext_lock);
62} 74}
63 75
64/* STUB */ 76/* STUB */
diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/blocklayout.h
index 8bfa4668ff31..98e2f60c2143 100644
--- a/fs/nfs/blocklayout/blocklayout.h
+++ b/fs/nfs/blocklayout/blocklayout.h
@@ -88,4 +88,5 @@ static inline struct pnfs_block_layout *BLK_LO2EXT(struct pnfs_layout_hdr *lo)
88 return container_of(lo, struct pnfs_block_layout, bl_layout); 88 return container_of(lo, struct pnfs_block_layout, bl_layout);
89} 89}
90 90
91void bl_put_extent(struct pnfs_block_extent *be);
91#endif /* FS_NFS_NFS4BLOCKLAYOUT_H */ 92#endif /* FS_NFS_NFS4BLOCKLAYOUT_H */
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}