blob: 8dde3723482ed4cd09fffdf707970ddec9f1f5b7 [file] [log] [blame]
Fred Isaman155e7522011-07-30 20:52:39 -04001/*
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
Fred Isaman9e692962011-07-30 20:52:41 -040056/* FIXME - range ignored */
Fred Isaman155e7522011-07-30 20:52:39 -040057static void
Fred Isaman9e692962011-07-30 20:52:41 -040058release_extents(struct pnfs_block_layout *bl, struct pnfs_layout_range *range)
Fred Isaman155e7522011-07-30 20:52:39 -040059{
Fred Isaman9e692962011-07-30 20:52:41 -040060 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);
Fred Isaman155e7522011-07-30 20:52:39 -040074}
75
76/* STUB */
77static void
78release_inval_marks(struct pnfs_inval_markings *marks)
79{
80 return;
81}
82
83static void bl_free_layout_hdr(struct pnfs_layout_hdr *lo)
84{
85 struct pnfs_block_layout *bl = BLK_LO2EXT(lo);
86
87 dprintk("%s enter\n", __func__);
88 release_extents(bl, NULL);
89 release_inval_marks(&bl->bl_inval);
90 kfree(bl);
91}
92
93static struct pnfs_layout_hdr *bl_alloc_layout_hdr(struct inode *inode,
94 gfp_t gfp_flags)
95{
96 struct pnfs_block_layout *bl;
97
98 dprintk("%s enter\n", __func__);
99 bl = kzalloc(sizeof(*bl), gfp_flags);
100 if (!bl)
101 return NULL;
102 spin_lock_init(&bl->bl_ext_lock);
103 INIT_LIST_HEAD(&bl->bl_extents[0]);
104 INIT_LIST_HEAD(&bl->bl_extents[1]);
105 INIT_LIST_HEAD(&bl->bl_commit);
106 INIT_LIST_HEAD(&bl->bl_committing);
107 bl->bl_count = 0;
108 bl->bl_blocksize = NFS_SERVER(inode)->pnfs_blksize >> SECTOR_SHIFT;
109 BL_INIT_INVAL_MARKS(&bl->bl_inval, bl->bl_blocksize);
110 return &bl->bl_layout;
111}
112
113static void
114bl_free_lseg(struct pnfs_layout_segment *lseg)
115{
116}
117
118static struct pnfs_layout_segment *
119bl_alloc_lseg(struct pnfs_layout_hdr *lo,
120 struct nfs4_layoutget_res *lgr, gfp_t gfp_flags)
121{
122 return NULL;
123}
124
125static void
126bl_encode_layoutcommit(struct pnfs_layout_hdr *lo, struct xdr_stream *xdr,
127 const struct nfs4_layoutcommit_args *arg)
128{
129}
130
131static void
132bl_cleanup_layoutcommit(struct nfs4_layoutcommit_data *lcdata)
133{
134}
135
136static int
137bl_set_layoutdriver(struct nfs_server *server, const struct nfs_fh *fh)
138{
139 dprintk("%s enter\n", __func__);
140 return 0;
141}
142
143static int
144bl_clear_layoutdriver(struct nfs_server *server)
145{
146 dprintk("%s enter\n", __func__);
147 return 0;
148}
149
Benny Halevye9643fe2011-07-30 20:52:40 -0400150static const struct nfs_pageio_ops bl_pg_read_ops = {
151 .pg_init = pnfs_generic_pg_init_read,
152 .pg_test = pnfs_generic_pg_test,
153 .pg_doio = pnfs_generic_pg_readpages,
154};
155
156static const struct nfs_pageio_ops bl_pg_write_ops = {
157 .pg_init = pnfs_generic_pg_init_write,
158 .pg_test = pnfs_generic_pg_test,
159 .pg_doio = pnfs_generic_pg_writepages,
160};
161
Fred Isaman155e7522011-07-30 20:52:39 -0400162static struct pnfs_layoutdriver_type blocklayout_type = {
163 .id = LAYOUT_BLOCK_VOLUME,
164 .name = "LAYOUT_BLOCK_VOLUME",
165 .read_pagelist = bl_read_pagelist,
166 .write_pagelist = bl_write_pagelist,
167 .alloc_layout_hdr = bl_alloc_layout_hdr,
168 .free_layout_hdr = bl_free_layout_hdr,
169 .alloc_lseg = bl_alloc_lseg,
170 .free_lseg = bl_free_lseg,
171 .encode_layoutcommit = bl_encode_layoutcommit,
172 .cleanup_layoutcommit = bl_cleanup_layoutcommit,
173 .set_layoutdriver = bl_set_layoutdriver,
174 .clear_layoutdriver = bl_clear_layoutdriver,
Benny Halevye9643fe2011-07-30 20:52:40 -0400175 .pg_read_ops = &bl_pg_read_ops,
176 .pg_write_ops = &bl_pg_write_ops,
Fred Isaman155e7522011-07-30 20:52:39 -0400177};
178
179static int __init nfs4blocklayout_init(void)
180{
181 int ret;
182
183 dprintk("%s: NFSv4 Block Layout Driver Registering...\n", __func__);
184
185 ret = pnfs_register_layoutdriver(&blocklayout_type);
186 return ret;
187}
188
189static void __exit nfs4blocklayout_exit(void)
190{
191 dprintk("%s: NFSv4 Block Layout Driver Unregistering...\n",
192 __func__);
193
194 pnfs_unregister_layoutdriver(&blocklayout_type);
195}
196
197MODULE_ALIAS("nfs-layouttype4-3");
198
199module_init(nfs4blocklayout_init);
200module_exit(nfs4blocklayout_exit);