Benny Halevy | c93407d | 2011-05-22 19:49:06 +0300 | [diff] [blame] | 1 | /* |
| 2 | * pNFS Objects layout implementation over open-osd initiator library |
| 3 | * |
| 4 | * Copyright (C) 2009 Panasas Inc. [year of first publication] |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Benny Halevy <bhalevy@panasas.com> |
| 8 | * Boaz Harrosh <bharrosh@panasas.com> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 |
| 12 | * See the file COPYING included with this distribution for more details. |
| 13 | * |
| 14 | * Redistribution and use in source and binary forms, with or without |
| 15 | * modification, are permitted provided that the following conditions |
| 16 | * are met: |
| 17 | * |
| 18 | * 1. Redistributions of source code must retain the above copyright |
| 19 | * notice, this list of conditions and the following disclaimer. |
| 20 | * 2. Redistributions in binary form must reproduce the above copyright |
| 21 | * notice, this list of conditions and the following disclaimer in the |
| 22 | * documentation and/or other materials provided with the distribution. |
| 23 | * 3. Neither the name of the Panasas company nor the names of its |
| 24 | * contributors may be used to endorse or promote products derived |
| 25 | * from this software without specific prior written permission. |
| 26 | * |
| 27 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 28 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 29 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 30 | * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 31 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 32 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 33 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 34 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
| 35 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 36 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 37 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 38 | */ |
| 39 | |
| 40 | #include <linux/module.h> |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 41 | #include <scsi/osd_ore.h> |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 42 | |
| 43 | #include "objlayout.h" |
| 44 | |
| 45 | #define NFSDBG_FACILITY NFSDBG_PNFS_LD |
| 46 | |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 47 | struct objio_dev_ent { |
| 48 | struct nfs4_deviceid_node id_node; |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 49 | struct ore_dev od; |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | static void |
| 53 | objio_free_deviceid_node(struct nfs4_deviceid_node *d) |
| 54 | { |
| 55 | struct objio_dev_ent *de = container_of(d, struct objio_dev_ent, id_node); |
| 56 | |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 57 | dprintk("%s: free od=%p\n", __func__, de->od.od); |
| 58 | osduld_put_device(de->od.od); |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 59 | kfree(de); |
| 60 | } |
| 61 | |
| 62 | static struct objio_dev_ent *_dev_list_find(const struct nfs_server *nfss, |
| 63 | const struct nfs4_deviceid *d_id) |
| 64 | { |
| 65 | struct nfs4_deviceid_node *d; |
| 66 | struct objio_dev_ent *de; |
| 67 | |
| 68 | d = nfs4_find_get_deviceid(nfss->pnfs_curr_ld, nfss->nfs_client, d_id); |
| 69 | if (!d) |
| 70 | return NULL; |
| 71 | |
| 72 | de = container_of(d, struct objio_dev_ent, id_node); |
| 73 | return de; |
| 74 | } |
| 75 | |
| 76 | static struct objio_dev_ent * |
| 77 | _dev_list_add(const struct nfs_server *nfss, |
| 78 | const struct nfs4_deviceid *d_id, struct osd_dev *od, |
| 79 | gfp_t gfp_flags) |
| 80 | { |
| 81 | struct nfs4_deviceid_node *d; |
| 82 | struct objio_dev_ent *de = kzalloc(sizeof(*de), gfp_flags); |
| 83 | struct objio_dev_ent *n; |
| 84 | |
| 85 | if (!de) { |
| 86 | dprintk("%s: -ENOMEM od=%p\n", __func__, od); |
| 87 | return NULL; |
| 88 | } |
| 89 | |
| 90 | dprintk("%s: Adding od=%p\n", __func__, od); |
| 91 | nfs4_init_deviceid_node(&de->id_node, |
| 92 | nfss->pnfs_curr_ld, |
| 93 | nfss->nfs_client, |
| 94 | d_id); |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 95 | de->od.od = od; |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 96 | |
| 97 | d = nfs4_insert_deviceid_node(&de->id_node); |
| 98 | n = container_of(d, struct objio_dev_ent, id_node); |
| 99 | if (n != de) { |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 100 | dprintk("%s: Race with other n->od=%p\n", __func__, n->od.od); |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 101 | objio_free_deviceid_node(&de->id_node); |
| 102 | de = n; |
| 103 | } |
| 104 | |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 105 | return de; |
| 106 | } |
| 107 | |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 108 | struct objio_segment { |
| 109 | struct pnfs_layout_segment lseg; |
| 110 | |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 111 | struct ore_layout layout; |
| 112 | struct ore_components oc; |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | static inline struct objio_segment * |
| 116 | OBJIO_LSEG(struct pnfs_layout_segment *lseg) |
| 117 | { |
| 118 | return container_of(lseg, struct objio_segment, lseg); |
| 119 | } |
| 120 | |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 121 | struct objio_state { |
| 122 | /* Generic layer */ |
Boaz Harrosh | e2e0435 | 2011-10-31 15:03:35 -0700 | [diff] [blame] | 123 | struct objlayout_io_res oir; |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 124 | |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 125 | bool sync; |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 126 | /*FIXME: Support for extra_bytes at ore_get_rw_state() */ |
| 127 | struct ore_io_state *ios; |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 128 | }; |
| 129 | |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 130 | /* Send and wait for a get_device_info of devices in the layout, |
| 131 | then look them up with the osd_initiator library */ |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 132 | static int objio_devices_lookup(struct pnfs_layout_hdr *pnfslay, |
| 133 | struct objio_segment *objio_seg, unsigned c, struct nfs4_deviceid *d_id, |
| 134 | gfp_t gfp_flags) |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 135 | { |
| 136 | struct pnfs_osd_deviceaddr *deviceaddr; |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 137 | struct objio_dev_ent *ode; |
| 138 | struct osd_dev *od; |
| 139 | struct osd_dev_info odi; |
Sachin Bhamare | 18d98f6 | 2012-03-19 20:47:58 -0700 | [diff] [blame] | 140 | bool retry_flag = true; |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 141 | int err; |
| 142 | |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 143 | ode = _dev_list_find(NFS_SERVER(pnfslay->plh_inode), d_id); |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 144 | if (ode) { |
| 145 | objio_seg->oc.ods[c] = &ode->od; /* must use container_of */ |
| 146 | return 0; |
| 147 | } |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 148 | |
| 149 | err = objlayout_get_deviceinfo(pnfslay, d_id, &deviceaddr, gfp_flags); |
| 150 | if (unlikely(err)) { |
| 151 | dprintk("%s: objlayout_get_deviceinfo dev(%llx:%llx) =>%d\n", |
| 152 | __func__, _DEVID_LO(d_id), _DEVID_HI(d_id), err); |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 153 | return err; |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | odi.systemid_len = deviceaddr->oda_systemid.len; |
| 157 | if (odi.systemid_len > sizeof(odi.systemid)) { |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 158 | dprintk("%s: odi.systemid_len > sizeof(systemid=%zd)\n", |
| 159 | __func__, sizeof(odi.systemid)); |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 160 | err = -EINVAL; |
| 161 | goto out; |
| 162 | } else if (odi.systemid_len) |
| 163 | memcpy(odi.systemid, deviceaddr->oda_systemid.data, |
| 164 | odi.systemid_len); |
| 165 | odi.osdname_len = deviceaddr->oda_osdname.len; |
| 166 | odi.osdname = (u8 *)deviceaddr->oda_osdname.data; |
| 167 | |
| 168 | if (!odi.osdname_len && !odi.systemid_len) { |
| 169 | dprintk("%s: !odi.osdname_len && !odi.systemid_len\n", |
| 170 | __func__); |
| 171 | err = -ENODEV; |
| 172 | goto out; |
| 173 | } |
| 174 | |
Sachin Bhamare | 18d98f6 | 2012-03-19 20:47:58 -0700 | [diff] [blame] | 175 | retry_lookup: |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 176 | od = osduld_info_lookup(&odi); |
| 177 | if (unlikely(IS_ERR(od))) { |
| 178 | err = PTR_ERR(od); |
| 179 | dprintk("%s: osduld_info_lookup => %d\n", __func__, err); |
Sachin Bhamare | 18d98f6 | 2012-03-19 20:47:58 -0700 | [diff] [blame] | 180 | if (err == -ENODEV && retry_flag) { |
| 181 | err = objlayout_autologin(deviceaddr); |
| 182 | if (likely(!err)) { |
| 183 | retry_flag = false; |
| 184 | goto retry_lookup; |
| 185 | } |
| 186 | } |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 187 | goto out; |
| 188 | } |
| 189 | |
| 190 | ode = _dev_list_add(NFS_SERVER(pnfslay->plh_inode), d_id, od, |
| 191 | gfp_flags); |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 192 | objio_seg->oc.ods[c] = &ode->od; /* must use container_of */ |
| 193 | dprintk("Adding new dev_id(%llx:%llx)\n", |
| 194 | _DEVID_LO(d_id), _DEVID_HI(d_id)); |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 195 | out: |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 196 | objlayout_put_deviceinfo(deviceaddr); |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 197 | return err; |
| 198 | } |
| 199 | |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 200 | static void copy_single_comp(struct ore_components *oc, unsigned c, |
| 201 | struct pnfs_osd_object_cred *src_comp) |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 202 | { |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 203 | struct ore_comp *ocomp = &oc->comps[c]; |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 204 | |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 205 | WARN_ON(src_comp->oc_cap_key.cred_len > 0); /* libosd is NO_SEC only */ |
| 206 | WARN_ON(src_comp->oc_cap.cred_len > sizeof(ocomp->cred)); |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 207 | |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 208 | ocomp->obj.partition = src_comp->oc_object_id.oid_partition_id; |
| 209 | ocomp->obj.id = src_comp->oc_object_id.oid_object_id; |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 210 | |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 211 | memcpy(ocomp->cred, src_comp->oc_cap.cred, sizeof(ocomp->cred)); |
| 212 | } |
| 213 | |
| 214 | int __alloc_objio_seg(unsigned numdevs, gfp_t gfp_flags, |
| 215 | struct objio_segment **pseg) |
| 216 | { |
Boaz Harrosh | 5318a29c | 2012-03-13 20:44:26 -0700 | [diff] [blame] | 217 | /* This is the in memory structure of the objio_segment |
| 218 | * |
| 219 | * struct __alloc_objio_segment { |
| 220 | * struct objio_segment olseg; |
| 221 | * struct ore_dev *ods[numdevs]; |
| 222 | * struct ore_comp comps[numdevs]; |
| 223 | * } *aolseg; |
| 224 | * NOTE: The code as above compiles and runs perfectly. It is elegant, |
| 225 | * type safe and compact. At some Past time Linus has decided he does not |
| 226 | * like variable length arrays, For the sake of this principal we uglify |
| 227 | * the code as below. |
| 228 | */ |
| 229 | struct objio_segment *lseg; |
| 230 | size_t lseg_size = sizeof(*lseg) + |
| 231 | numdevs * sizeof(lseg->oc.ods[0]) + |
| 232 | numdevs * sizeof(*lseg->oc.comps); |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 233 | |
Boaz Harrosh | 5318a29c | 2012-03-13 20:44:26 -0700 | [diff] [blame] | 234 | lseg = kzalloc(lseg_size, gfp_flags); |
| 235 | if (unlikely(!lseg)) { |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 236 | dprintk("%s: Faild allocation numdevs=%d size=%zd\n", __func__, |
Boaz Harrosh | 5318a29c | 2012-03-13 20:44:26 -0700 | [diff] [blame] | 237 | numdevs, lseg_size); |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 238 | return -ENOMEM; |
| 239 | } |
| 240 | |
Boaz Harrosh | 5318a29c | 2012-03-13 20:44:26 -0700 | [diff] [blame] | 241 | lseg->oc.numdevs = numdevs; |
| 242 | lseg->oc.single_comp = EC_MULTPLE_COMPS; |
| 243 | lseg->oc.ods = (void *)(lseg + 1); |
| 244 | lseg->oc.comps = (void *)(lseg->oc.ods + numdevs); |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 245 | |
Boaz Harrosh | 5318a29c | 2012-03-13 20:44:26 -0700 | [diff] [blame] | 246 | *pseg = lseg; |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 247 | return 0; |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | int objio_alloc_lseg(struct pnfs_layout_segment **outp, |
| 251 | struct pnfs_layout_hdr *pnfslay, |
| 252 | struct pnfs_layout_range *range, |
| 253 | struct xdr_stream *xdr, |
| 254 | gfp_t gfp_flags) |
| 255 | { |
| 256 | struct objio_segment *objio_seg; |
| 257 | struct pnfs_osd_xdr_decode_layout_iter iter; |
| 258 | struct pnfs_osd_layout layout; |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 259 | struct pnfs_osd_object_cred src_comp; |
| 260 | unsigned cur_comp; |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 261 | int err; |
| 262 | |
| 263 | err = pnfs_osd_xdr_decode_layout_map(&layout, &iter, xdr); |
| 264 | if (unlikely(err)) |
| 265 | return err; |
| 266 | |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 267 | err = __alloc_objio_seg(layout.olo_num_comps, gfp_flags, &objio_seg); |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 268 | if (unlikely(err)) |
| 269 | return err; |
| 270 | |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 271 | objio_seg->layout.stripe_unit = layout.olo_map.odm_stripe_unit; |
| 272 | objio_seg->layout.group_width = layout.olo_map.odm_group_width; |
| 273 | objio_seg->layout.group_depth = layout.olo_map.odm_group_depth; |
| 274 | objio_seg->layout.mirrors_p1 = layout.olo_map.odm_mirror_cnt + 1; |
| 275 | objio_seg->layout.raid_algorithm = layout.olo_map.odm_raid_algorithm; |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 276 | |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 277 | err = ore_verify_layout(layout.olo_map.odm_num_comps, |
| 278 | &objio_seg->layout); |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 279 | if (unlikely(err)) |
| 280 | goto err; |
| 281 | |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 282 | objio_seg->oc.first_dev = layout.olo_comps_index; |
| 283 | cur_comp = 0; |
| 284 | while (pnfs_osd_xdr_decode_layout_comp(&src_comp, &iter, xdr, &err)) { |
| 285 | copy_single_comp(&objio_seg->oc, cur_comp, &src_comp); |
| 286 | err = objio_devices_lookup(pnfslay, objio_seg, cur_comp, |
| 287 | &src_comp.oc_object_id.oid_device_id, |
| 288 | gfp_flags); |
| 289 | if (err) |
| 290 | goto err; |
| 291 | ++cur_comp; |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 292 | } |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 293 | /* pnfs_osd_xdr_decode_layout_comp returns false on error */ |
| 294 | if (unlikely(err)) |
| 295 | goto err; |
Boaz Harrosh | 9342077 | 2011-05-25 21:25:29 +0300 | [diff] [blame] | 296 | |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 297 | *outp = &objio_seg->lseg; |
| 298 | return 0; |
| 299 | |
| 300 | err: |
| 301 | kfree(objio_seg); |
| 302 | dprintk("%s: Error: return %d\n", __func__, err); |
| 303 | *outp = NULL; |
| 304 | return err; |
| 305 | } |
| 306 | |
| 307 | void objio_free_lseg(struct pnfs_layout_segment *lseg) |
| 308 | { |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 309 | int i; |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 310 | struct objio_segment *objio_seg = OBJIO_LSEG(lseg); |
| 311 | |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 312 | for (i = 0; i < objio_seg->oc.numdevs; i++) { |
| 313 | struct ore_dev *od = objio_seg->oc.ods[i]; |
| 314 | struct objio_dev_ent *ode; |
| 315 | |
| 316 | if (!od) |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 317 | break; |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 318 | ode = container_of(od, typeof(*ode), od); |
| 319 | nfs4_put_deviceid_node(&ode->id_node); |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 320 | } |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 321 | kfree(objio_seg); |
| 322 | } |
| 323 | |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 324 | static int |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 325 | objio_alloc_io_state(struct pnfs_layout_hdr *pnfs_layout_type, bool is_reading, |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 326 | struct pnfs_layout_segment *lseg, struct page **pages, unsigned pgbase, |
| 327 | loff_t offset, size_t count, void *rpcdata, gfp_t gfp_flags, |
| 328 | struct objio_state **outp) |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 329 | { |
| 330 | struct objio_segment *objio_seg = OBJIO_LSEG(lseg); |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 331 | struct ore_io_state *ios; |
| 332 | int ret; |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 333 | struct __alloc_objio_state { |
| 334 | struct objio_state objios; |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 335 | struct pnfs_osd_ioerr ioerrs[objio_seg->oc.numdevs]; |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 336 | } *aos; |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 337 | |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 338 | aos = kzalloc(sizeof(*aos), gfp_flags); |
| 339 | if (unlikely(!aos)) |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 340 | return -ENOMEM; |
| 341 | |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 342 | objlayout_init_ioerrs(&aos->objios.oir, objio_seg->oc.numdevs, |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 343 | aos->ioerrs, rpcdata, pnfs_layout_type); |
| 344 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 345 | ret = ore_get_rw_state(&objio_seg->layout, &objio_seg->oc, is_reading, |
| 346 | offset, count, &ios); |
| 347 | if (unlikely(ret)) { |
| 348 | kfree(aos); |
| 349 | return ret; |
| 350 | } |
| 351 | |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 352 | ios->pages = pages; |
| 353 | ios->pgbase = pgbase; |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 354 | ios->private = aos; |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 355 | BUG_ON(ios->nr_pages > (pgbase + count + PAGE_SIZE - 1) >> PAGE_SHIFT); |
| 356 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 357 | aos->objios.sync = 0; |
| 358 | aos->objios.ios = ios; |
| 359 | *outp = &aos->objios; |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 360 | return 0; |
| 361 | } |
| 362 | |
Boaz Harrosh | e2e0435 | 2011-10-31 15:03:35 -0700 | [diff] [blame] | 363 | void objio_free_result(struct objlayout_io_res *oir) |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 364 | { |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 365 | struct objio_state *objios = container_of(oir, struct objio_state, oir); |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 366 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 367 | ore_put_io_state(objios->ios); |
| 368 | kfree(objios); |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 369 | } |
| 370 | |
Boaz Harrosh | adb5853 | 2011-05-26 21:49:46 +0300 | [diff] [blame] | 371 | enum pnfs_osd_errno osd_pri_2_pnfs_err(enum osd_err_priority oep) |
| 372 | { |
| 373 | switch (oep) { |
| 374 | case OSD_ERR_PRI_NO_ERROR: |
| 375 | return (enum pnfs_osd_errno)0; |
| 376 | |
| 377 | case OSD_ERR_PRI_CLEAR_PAGES: |
| 378 | BUG_ON(1); |
| 379 | return 0; |
| 380 | |
| 381 | case OSD_ERR_PRI_RESOURCE: |
| 382 | return PNFS_OSD_ERR_RESOURCE; |
| 383 | case OSD_ERR_PRI_BAD_CRED: |
| 384 | return PNFS_OSD_ERR_BAD_CRED; |
| 385 | case OSD_ERR_PRI_NO_ACCESS: |
| 386 | return PNFS_OSD_ERR_NO_ACCESS; |
| 387 | case OSD_ERR_PRI_UNREACHABLE: |
| 388 | return PNFS_OSD_ERR_UNREACHABLE; |
| 389 | case OSD_ERR_PRI_NOT_FOUND: |
| 390 | return PNFS_OSD_ERR_NOT_FOUND; |
| 391 | case OSD_ERR_PRI_NO_SPACE: |
| 392 | return PNFS_OSD_ERR_NO_SPACE; |
| 393 | default: |
| 394 | WARN_ON(1); |
| 395 | /* fallthrough */ |
| 396 | case OSD_ERR_PRI_EIO: |
| 397 | return PNFS_OSD_ERR_EIO; |
| 398 | } |
| 399 | } |
| 400 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 401 | static void __on_dev_error(struct ore_io_state *ios, |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 402 | struct ore_dev *od, unsigned dev_index, enum osd_err_priority oep, |
| 403 | u64 dev_offset, u64 dev_len) |
| 404 | { |
| 405 | struct objio_state *objios = ios->private; |
| 406 | struct pnfs_osd_objid pooid; |
| 407 | struct objio_dev_ent *ode = container_of(od, typeof(*ode), od); |
| 408 | /* FIXME: what to do with more-then-one-group layouts. We need to |
| 409 | * translate from ore_io_state index to oc->comps index |
| 410 | */ |
| 411 | unsigned comp = dev_index; |
| 412 | |
| 413 | pooid.oid_device_id = ode->id_node.deviceid; |
| 414 | pooid.oid_partition_id = ios->oc->comps[comp].obj.partition; |
| 415 | pooid.oid_object_id = ios->oc->comps[comp].obj.id; |
| 416 | |
| 417 | objlayout_io_set_result(&objios->oir, comp, |
| 418 | &pooid, osd_pri_2_pnfs_err(oep), |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 419 | dev_offset, dev_len, !ios->reading); |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 420 | } |
| 421 | |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 422 | /* |
| 423 | * read |
| 424 | */ |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 425 | static void _read_done(struct ore_io_state *ios, void *private) |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 426 | { |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 427 | struct objio_state *objios = private; |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 428 | ssize_t status; |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 429 | int ret = ore_check_io(ios, &__on_dev_error); |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 430 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 431 | /* FIXME: _io_free(ios) can we dealocate the libosd resources; */ |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 432 | |
| 433 | if (likely(!ret)) |
| 434 | status = ios->length; |
| 435 | else |
| 436 | status = ret; |
| 437 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 438 | objlayout_read_done(&objios->oir, status, objios->sync); |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 439 | } |
| 440 | |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 441 | int objio_read_pagelist(struct nfs_read_data *rdata) |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 442 | { |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 443 | struct objio_state *objios; |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 444 | int ret; |
| 445 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 446 | ret = objio_alloc_io_state(NFS_I(rdata->inode)->layout, true, |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 447 | rdata->lseg, rdata->args.pages, rdata->args.pgbase, |
| 448 | rdata->args.offset, rdata->args.count, rdata, |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 449 | GFP_KERNEL, &objios); |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 450 | if (unlikely(ret)) |
| 451 | return ret; |
| 452 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 453 | objios->ios->done = _read_done; |
| 454 | dprintk("%s: offset=0x%llx length=0x%x\n", __func__, |
| 455 | rdata->args.offset, rdata->args.count); |
| 456 | return ore_read(objios->ios); |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 457 | } |
| 458 | |
| 459 | /* |
| 460 | * write |
| 461 | */ |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 462 | static void _write_done(struct ore_io_state *ios, void *private) |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 463 | { |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 464 | struct objio_state *objios = private; |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 465 | ssize_t status; |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 466 | int ret = ore_check_io(ios, &__on_dev_error); |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 467 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 468 | /* FIXME: _io_free(ios) can we dealocate the libosd resources; */ |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 469 | |
| 470 | if (likely(!ret)) { |
| 471 | /* FIXME: should be based on the OSD's persistence model |
| 472 | * See OSD2r05 Section 4.13 Data persistence model */ |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 473 | objios->oir.committed = NFS_FILE_SYNC; |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 474 | status = ios->length; |
| 475 | } else { |
| 476 | status = ret; |
| 477 | } |
| 478 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 479 | objlayout_write_done(&objios->oir, status, objios->sync); |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 480 | } |
| 481 | |
Boaz Harrosh | 278c023 | 2011-10-31 15:16:54 -0700 | [diff] [blame] | 482 | static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate) |
| 483 | { |
| 484 | struct objio_state *objios = priv; |
| 485 | struct nfs_write_data *wdata = objios->oir.rpcdata; |
| 486 | pgoff_t index = offset / PAGE_SIZE; |
| 487 | struct page *page = find_get_page(wdata->inode->i_mapping, index); |
| 488 | |
| 489 | if (!page) { |
| 490 | page = find_or_create_page(wdata->inode->i_mapping, |
| 491 | index, GFP_NOFS); |
| 492 | if (unlikely(!page)) { |
| 493 | dprintk("%s: grab_cache_page Failed index=0x%lx\n", |
| 494 | __func__, index); |
| 495 | return NULL; |
| 496 | } |
| 497 | unlock_page(page); |
| 498 | } |
| 499 | if (PageDirty(page) || PageWriteback(page)) |
| 500 | *uptodate = true; |
| 501 | else |
| 502 | *uptodate = PageUptodate(page); |
| 503 | dprintk("%s: index=0x%lx uptodate=%d\n", __func__, index, *uptodate); |
| 504 | return page; |
| 505 | } |
| 506 | |
| 507 | static void __r4w_put_page(void *priv, struct page *page) |
| 508 | { |
| 509 | dprintk("%s: index=0x%lx\n", __func__, page->index); |
| 510 | page_cache_release(page); |
| 511 | return; |
| 512 | } |
| 513 | |
| 514 | static const struct _ore_r4w_op _r4w_op = { |
| 515 | .get_page = &__r4w_get_page, |
| 516 | .put_page = &__r4w_put_page, |
| 517 | }; |
| 518 | |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 519 | int objio_write_pagelist(struct nfs_write_data *wdata, int how) |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 520 | { |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 521 | struct objio_state *objios; |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 522 | int ret; |
| 523 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 524 | ret = objio_alloc_io_state(NFS_I(wdata->inode)->layout, false, |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 525 | wdata->lseg, wdata->args.pages, wdata->args.pgbase, |
| 526 | wdata->args.offset, wdata->args.count, wdata, GFP_NOFS, |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 527 | &objios); |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 528 | if (unlikely(ret)) |
| 529 | return ret; |
| 530 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 531 | objios->sync = 0 != (how & FLUSH_SYNC); |
Boaz Harrosh | 278c023 | 2011-10-31 15:16:54 -0700 | [diff] [blame] | 532 | objios->ios->r4w = &_r4w_op; |
Boaz Harrosh | 9621855 | 2011-10-31 14:47:32 -0700 | [diff] [blame] | 533 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 534 | if (!objios->sync) |
| 535 | objios->ios->done = _write_done; |
| 536 | |
| 537 | dprintk("%s: offset=0x%llx length=0x%x\n", __func__, |
| 538 | wdata->args.offset, wdata->args.count); |
| 539 | ret = ore_write(objios->ios); |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 540 | if (unlikely(ret)) |
| 541 | return ret; |
| 542 | |
Boaz Harrosh | eecfc63 | 2011-10-31 15:15:38 -0700 | [diff] [blame] | 543 | if (objios->sync) |
| 544 | _write_done(objios->ios, objios); |
| 545 | |
| 546 | return 0; |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 547 | } |
| 548 | |
Boaz Harrosh | 9342077 | 2011-05-25 21:25:29 +0300 | [diff] [blame] | 549 | static bool objio_pg_test(struct nfs_pageio_descriptor *pgio, |
| 550 | struct nfs_page *prev, struct nfs_page *req) |
| 551 | { |
| 552 | if (!pnfs_generic_pg_test(pgio, prev, req)) |
| 553 | return false; |
| 554 | |
| 555 | return pgio->pg_count + req->wb_bytes <= |
Boaz Harrosh | af4f5b5 | 2011-10-31 15:04:19 -0700 | [diff] [blame] | 556 | OBJIO_LSEG(pgio->pg_lseg)->layout.max_io_length; |
Boaz Harrosh | 9342077 | 2011-05-25 21:25:29 +0300 | [diff] [blame] | 557 | } |
| 558 | |
Trond Myklebust | 1751c36 | 2011-06-10 13:30:23 -0400 | [diff] [blame] | 559 | static const struct nfs_pageio_ops objio_pg_read_ops = { |
Trond Myklebust | d8007d4 | 2011-06-10 13:30:23 -0400 | [diff] [blame] | 560 | .pg_init = pnfs_generic_pg_init_read, |
Trond Myklebust | 1751c36 | 2011-06-10 13:30:23 -0400 | [diff] [blame] | 561 | .pg_test = objio_pg_test, |
Trond Myklebust | 493292d | 2011-07-13 15:58:28 -0400 | [diff] [blame] | 562 | .pg_doio = pnfs_generic_pg_readpages, |
Trond Myklebust | 1751c36 | 2011-06-10 13:30:23 -0400 | [diff] [blame] | 563 | }; |
| 564 | |
| 565 | static const struct nfs_pageio_ops objio_pg_write_ops = { |
Trond Myklebust | d8007d4 | 2011-06-10 13:30:23 -0400 | [diff] [blame] | 566 | .pg_init = pnfs_generic_pg_init_write, |
Trond Myklebust | 1751c36 | 2011-06-10 13:30:23 -0400 | [diff] [blame] | 567 | .pg_test = objio_pg_test, |
Trond Myklebust | dce8129 | 2011-07-13 15:59:19 -0400 | [diff] [blame] | 568 | .pg_doio = pnfs_generic_pg_writepages, |
Trond Myklebust | 1751c36 | 2011-06-10 13:30:23 -0400 | [diff] [blame] | 569 | }; |
| 570 | |
Benny Halevy | c93407d | 2011-05-22 19:49:06 +0300 | [diff] [blame] | 571 | static struct pnfs_layoutdriver_type objlayout_type = { |
| 572 | .id = LAYOUT_OSD2_OBJECTS, |
| 573 | .name = "LAYOUT_OSD2_OBJECTS", |
Boaz Harrosh | fe0fe83 | 2012-01-06 09:31:20 +0200 | [diff] [blame] | 574 | .flags = PNFS_LAYOUTRET_ON_SETATTR | |
| 575 | PNFS_LAYOUTRET_ON_ERROR, |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 576 | |
Benny Halevy | e51b841 | 2011-05-22 19:51:48 +0300 | [diff] [blame] | 577 | .alloc_layout_hdr = objlayout_alloc_layout_hdr, |
| 578 | .free_layout_hdr = objlayout_free_layout_hdr, |
| 579 | |
Boaz Harrosh | 09f5bf4 | 2011-05-22 19:50:20 +0300 | [diff] [blame] | 580 | .alloc_lseg = objlayout_alloc_lseg, |
| 581 | .free_lseg = objlayout_free_lseg, |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 582 | |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 583 | .read_pagelist = objlayout_read_pagelist, |
| 584 | .write_pagelist = objlayout_write_pagelist, |
Trond Myklebust | 1751c36 | 2011-06-10 13:30:23 -0400 | [diff] [blame] | 585 | .pg_read_ops = &objio_pg_read_ops, |
| 586 | .pg_write_ops = &objio_pg_write_ops, |
Boaz Harrosh | 04f8345 | 2011-05-22 19:52:19 +0300 | [diff] [blame] | 587 | |
Boaz Harrosh | b6c05f1 | 2011-05-26 21:45:34 +0300 | [diff] [blame] | 588 | .free_deviceid_node = objio_free_deviceid_node, |
Boaz Harrosh | adb5853 | 2011-05-26 21:49:46 +0300 | [diff] [blame] | 589 | |
Boaz Harrosh | a0fe8bf | 2011-05-22 19:54:13 +0300 | [diff] [blame] | 590 | .encode_layoutcommit = objlayout_encode_layoutcommit, |
Boaz Harrosh | adb5853 | 2011-05-26 21:49:46 +0300 | [diff] [blame] | 591 | .encode_layoutreturn = objlayout_encode_layoutreturn, |
Benny Halevy | c93407d | 2011-05-22 19:49:06 +0300 | [diff] [blame] | 592 | }; |
| 593 | |
| 594 | MODULE_DESCRIPTION("pNFS Layout Driver for OSD2 objects"); |
| 595 | MODULE_AUTHOR("Benny Halevy <bhalevy@panasas.com>"); |
| 596 | MODULE_LICENSE("GPL"); |
| 597 | |
| 598 | static int __init |
| 599 | objlayout_init(void) |
| 600 | { |
| 601 | int ret = pnfs_register_layoutdriver(&objlayout_type); |
| 602 | |
| 603 | if (ret) |
| 604 | printk(KERN_INFO |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 605 | "NFS: %s: Registering OSD pNFS Layout Driver failed: error=%d\n", |
Benny Halevy | c93407d | 2011-05-22 19:49:06 +0300 | [diff] [blame] | 606 | __func__, ret); |
| 607 | else |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 608 | printk(KERN_INFO "NFS: %s: Registered OSD pNFS Layout Driver\n", |
Benny Halevy | c93407d | 2011-05-22 19:49:06 +0300 | [diff] [blame] | 609 | __func__); |
| 610 | return ret; |
| 611 | } |
| 612 | |
| 613 | static void __exit |
| 614 | objlayout_exit(void) |
| 615 | { |
| 616 | pnfs_unregister_layoutdriver(&objlayout_type); |
Weston Andros Adamson | a030889 | 2012-01-26 13:32:23 -0500 | [diff] [blame] | 617 | printk(KERN_INFO "NFS: %s: Unregistered OSD pNFS Layout Driver\n", |
Benny Halevy | c93407d | 2011-05-22 19:49:06 +0300 | [diff] [blame] | 618 | __func__); |
| 619 | } |
| 620 | |
J. Bruce Fields | f85ef69 | 2011-07-15 19:18:42 -0400 | [diff] [blame] | 621 | MODULE_ALIAS("nfs-layouttype4-2"); |
| 622 | |
Benny Halevy | c93407d | 2011-05-22 19:49:06 +0300 | [diff] [blame] | 623 | module_init(objlayout_init); |
| 624 | module_exit(objlayout_exit); |