aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/Kconfig8
-rw-r--r--fs/nfs/Makefile1
-rw-r--r--fs/nfs/blocklayout/Makefile5
-rw-r--r--fs/nfs/blocklayout/blocklayout.c174
-rw-r--r--fs/nfs/blocklayout/blocklayout.h91
5 files changed, 278 insertions, 1 deletions
diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig
index 2cde5d954750..be020771c6b4 100644
--- a/fs/nfs/Kconfig
+++ b/fs/nfs/Kconfig
@@ -79,15 +79,21 @@ config NFS_V4_1
79 depends on NFS_FS && NFS_V4 && EXPERIMENTAL 79 depends on NFS_FS && NFS_V4 && EXPERIMENTAL
80 select SUNRPC_BACKCHANNEL 80 select SUNRPC_BACKCHANNEL
81 select PNFS_FILE_LAYOUT 81 select PNFS_FILE_LAYOUT
82 select PNFS_BLOCK
83 select MD
84 select BLK_DEV_DM
82 help 85 help
83 This option enables support for minor version 1 of the NFSv4 protocol 86 This option enables support for minor version 1 of the NFSv4 protocol
84 (RFC 5661) in the kernel's NFS client. 87 (RFC 5661 and RFC 5663) in the kernel's NFS client.
85 88
86 If unsure, say N. 89 If unsure, say N.
87 90
88config PNFS_FILE_LAYOUT 91config PNFS_FILE_LAYOUT
89 tristate 92 tristate
90 93
94config PNFS_BLOCK
95 tristate
96
91config PNFS_OBJLAYOUT 97config PNFS_OBJLAYOUT
92 tristate "Provide support for the pNFS Objects Layout Driver for NFSv4.1 pNFS (EXPERIMENTAL)" 98 tristate "Provide support for the pNFS Objects Layout Driver for NFSv4.1 pNFS (EXPERIMENTAL)"
93 depends on NFS_FS && NFS_V4_1 && SCSI_OSD_ULD 99 depends on NFS_FS && NFS_V4_1 && SCSI_OSD_ULD
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile
index 6a34f7dd0e6f..b58613d0abb3 100644
--- a/fs/nfs/Makefile
+++ b/fs/nfs/Makefile
@@ -23,3 +23,4 @@ obj-$(CONFIG_PNFS_FILE_LAYOUT) += nfs_layout_nfsv41_files.o
23nfs_layout_nfsv41_files-y := nfs4filelayout.o nfs4filelayoutdev.o 23nfs_layout_nfsv41_files-y := nfs4filelayout.o nfs4filelayoutdev.o
24 24
25obj-$(CONFIG_PNFS_OBJLAYOUT) += objlayout/ 25obj-$(CONFIG_PNFS_OBJLAYOUT) += objlayout/
26obj-$(CONFIG_PNFS_BLOCK) += blocklayout/
diff --git a/fs/nfs/blocklayout/Makefile b/fs/nfs/blocklayout/Makefile
new file mode 100644
index 000000000000..6bf49cd5da06
--- /dev/null
+++ b/fs/nfs/blocklayout/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for the pNFS block layout driver kernel module
3#
4obj-$(CONFIG_PNFS_BLOCK) += blocklayoutdriver.o
5blocklayoutdriver-objs := blocklayout.o
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
new file mode 100644
index 000000000000..44562cbbe394
--- /dev/null
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -0,0 +1,174 @@
1/*
2 * linux/fs/nfs/blocklayout/blocklayout.c
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#include <linux/module.h>
33#include <linux/init.h>
34
35#include "blocklayout.h"
36
37#define NFSDBG_FACILITY NFSDBG_PNFS_LD
38
39MODULE_LICENSE("GPL");
40MODULE_AUTHOR("Andy Adamson <andros@citi.umich.edu>");
41MODULE_DESCRIPTION("The NFSv4.1 pNFS Block layout driver");
42
43static enum pnfs_try_status
44bl_read_pagelist(struct nfs_read_data *rdata)
45{
46 return PNFS_NOT_ATTEMPTED;
47}
48
49static enum pnfs_try_status
50bl_write_pagelist(struct nfs_write_data *wdata,
51 int sync)
52{
53 return PNFS_NOT_ATTEMPTED;
54}
55
56/* STUB */
57static void
58release_extents(struct pnfs_block_layout *bl,
59 struct pnfs_layout_range *range)
60{
61 return;
62}
63
64/* STUB */
65static void
66release_inval_marks(struct pnfs_inval_markings *marks)
67{
68 return;
69}
70
71static void bl_free_layout_hdr(struct pnfs_layout_hdr *lo)
72{
73 struct pnfs_block_layout *bl = BLK_LO2EXT(lo);
74
75 dprintk("%s enter\n", __func__);
76 release_extents(bl, NULL);
77 release_inval_marks(&bl->bl_inval);
78 kfree(bl);
79}
80
81static struct pnfs_layout_hdr *bl_alloc_layout_hdr(struct inode *inode,
82 gfp_t gfp_flags)
83{
84 struct pnfs_block_layout *bl;
85
86 dprintk("%s enter\n", __func__);
87 bl = kzalloc(sizeof(*bl), gfp_flags);
88 if (!bl)
89 return NULL;
90 spin_lock_init(&bl->bl_ext_lock);
91 INIT_LIST_HEAD(&bl->bl_extents[0]);
92 INIT_LIST_HEAD(&bl->bl_extents[1]);
93 INIT_LIST_HEAD(&bl->bl_commit);
94 INIT_LIST_HEAD(&bl->bl_committing);
95 bl->bl_count = 0;
96 bl->bl_blocksize = NFS_SERVER(inode)->pnfs_blksize >> SECTOR_SHIFT;
97 BL_INIT_INVAL_MARKS(&bl->bl_inval, bl->bl_blocksize);
98 return &bl->bl_layout;
99}
100
101static void
102bl_free_lseg(struct pnfs_layout_segment *lseg)
103{
104}
105
106static struct pnfs_layout_segment *
107bl_alloc_lseg(struct pnfs_layout_hdr *lo,
108 struct nfs4_layoutget_res *lgr, gfp_t gfp_flags)
109{
110 return NULL;
111}
112
113static void
114bl_encode_layoutcommit(struct pnfs_layout_hdr *lo, struct xdr_stream *xdr,
115 const struct nfs4_layoutcommit_args *arg)
116{
117}
118
119static void
120bl_cleanup_layoutcommit(struct nfs4_layoutcommit_data *lcdata)
121{
122}
123
124static int
125bl_set_layoutdriver(struct nfs_server *server, const struct nfs_fh *fh)
126{
127 dprintk("%s enter\n", __func__);
128 return 0;
129}
130
131static int
132bl_clear_layoutdriver(struct nfs_server *server)
133{
134 dprintk("%s enter\n", __func__);
135 return 0;
136}
137
138static struct pnfs_layoutdriver_type blocklayout_type = {
139 .id = LAYOUT_BLOCK_VOLUME,
140 .name = "LAYOUT_BLOCK_VOLUME",
141 .read_pagelist = bl_read_pagelist,
142 .write_pagelist = bl_write_pagelist,
143 .alloc_layout_hdr = bl_alloc_layout_hdr,
144 .free_layout_hdr = bl_free_layout_hdr,
145 .alloc_lseg = bl_alloc_lseg,
146 .free_lseg = bl_free_lseg,
147 .encode_layoutcommit = bl_encode_layoutcommit,
148 .cleanup_layoutcommit = bl_cleanup_layoutcommit,
149 .set_layoutdriver = bl_set_layoutdriver,
150 .clear_layoutdriver = bl_clear_layoutdriver,
151};
152
153static int __init nfs4blocklayout_init(void)
154{
155 int ret;
156
157 dprintk("%s: NFSv4 Block Layout Driver Registering...\n", __func__);
158
159 ret = pnfs_register_layoutdriver(&blocklayout_type);
160 return ret;
161}
162
163static void __exit nfs4blocklayout_exit(void)
164{
165 dprintk("%s: NFSv4 Block Layout Driver Unregistering...\n",
166 __func__);
167
168 pnfs_unregister_layoutdriver(&blocklayout_type);
169}
170
171MODULE_ALIAS("nfs-layouttype4-3");
172
173module_init(nfs4blocklayout_init);
174module_exit(nfs4blocklayout_exit);
diff --git a/fs/nfs/blocklayout/blocklayout.h b/fs/nfs/blocklayout/blocklayout.h
new file mode 100644
index 000000000000..8bfa4668ff31
--- /dev/null
+++ b/fs/nfs/blocklayout/blocklayout.h
@@ -0,0 +1,91 @@
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#ifndef FS_NFS_NFS4BLOCKLAYOUT_H
33#define FS_NFS_NFS4BLOCKLAYOUT_H
34
35#include <linux/device-mapper.h>
36#include <linux/nfs_fs.h>
37#include "../pnfs.h"
38
39enum exstate4 {
40 PNFS_BLOCK_READWRITE_DATA = 0,
41 PNFS_BLOCK_READ_DATA = 1,
42 PNFS_BLOCK_INVALID_DATA = 2, /* mapped, but data is invalid */
43 PNFS_BLOCK_NONE_DATA = 3 /* unmapped, it's a hole */
44};
45
46struct pnfs_inval_markings {
47 /* STUB */
48};
49
50/* sector_t fields are all in 512-byte sectors */
51struct pnfs_block_extent {
52 struct kref be_refcnt;
53 struct list_head be_node; /* link into lseg list */
54 struct nfs4_deviceid be_devid; /* FIXME: could use device cache instead */
55 struct block_device *be_mdev;
56 sector_t be_f_offset; /* the starting offset in the file */
57 sector_t be_length; /* the size of the extent */
58 sector_t be_v_offset; /* the starting offset in the volume */
59 enum exstate4 be_state; /* the state of this extent */
60 struct pnfs_inval_markings *be_inval; /* tracks INVAL->RW transition */
61};
62
63static inline void
64BL_INIT_INVAL_MARKS(struct pnfs_inval_markings *marks, sector_t blocksize)
65{
66 /* STUB */
67}
68
69enum extentclass4 {
70 RW_EXTENT = 0, /* READWRTE and INVAL */
71 RO_EXTENT = 1, /* READ and NONE */
72 EXTENT_LISTS = 2,
73};
74
75struct pnfs_block_layout {
76 struct pnfs_layout_hdr bl_layout;
77 struct pnfs_inval_markings bl_inval; /* tracks INVAL->RW transition */
78 spinlock_t bl_ext_lock; /* Protects list manipulation */
79 struct list_head bl_extents[EXTENT_LISTS]; /* R and RW extents */
80 struct list_head bl_commit; /* Needs layout commit */
81 struct list_head bl_committing; /* Layout committing */
82 unsigned int bl_count; /* entries in bl_commit */
83 sector_t bl_blocksize; /* Server blocksize in sectors */
84};
85
86static inline struct pnfs_block_layout *BLK_LO2EXT(struct pnfs_layout_hdr *lo)
87{
88 return container_of(lo, struct pnfs_block_layout, bl_layout);
89}
90
91#endif /* FS_NFS_NFS4BLOCKLAYOUT_H */