2 * pNFS Objects layout implementation over open-osd initiator library
4 * Copyright (C) 2009 Panasas Inc. [year of first publication]
7 * Benny Halevy <bhalevy@panasas.com>
8 * Boaz Harrosh <bharrosh@panasas.com>
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.
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
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.
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.
40 #include <linux/module.h>
41 #include <scsi/osd_initiator.h>
43 #include "objlayout.h"
45 #define NFSDBG_FACILITY NFSDBG_PNFS_LD
47 #define _LLU(x) ((unsigned long long)x)
49 enum { BIO_MAX_PAGES_KMALLOC =
50 (PAGE_SIZE - sizeof(struct bio)) / sizeof(struct bio_vec),
53 struct objio_dev_ent {
54 struct nfs4_deviceid_node id_node;
59 objio_free_deviceid_node(struct nfs4_deviceid_node *d)
61 struct objio_dev_ent *de = container_of(d, struct objio_dev_ent, id_node);
63 dprintk("%s: free od=%p\n", __func__, de->od);
64 osduld_put_device(de->od);
68 static struct objio_dev_ent *_dev_list_find(const struct nfs_server *nfss,
69 const struct nfs4_deviceid *d_id)
71 struct nfs4_deviceid_node *d;
72 struct objio_dev_ent *de;
74 d = nfs4_find_get_deviceid(nfss->pnfs_curr_ld, nfss->nfs_client, d_id);
78 de = container_of(d, struct objio_dev_ent, id_node);
82 static struct objio_dev_ent *
83 _dev_list_add(const struct nfs_server *nfss,
84 const struct nfs4_deviceid *d_id, struct osd_dev *od,
87 struct nfs4_deviceid_node *d;
88 struct objio_dev_ent *de = kzalloc(sizeof(*de), gfp_flags);
89 struct objio_dev_ent *n;
92 dprintk("%s: -ENOMEM od=%p\n", __func__, od);
96 dprintk("%s: Adding od=%p\n", __func__, od);
97 nfs4_init_deviceid_node(&de->id_node,
103 d = nfs4_insert_deviceid_node(&de->id_node);
104 n = container_of(d, struct objio_dev_ent, id_node);
106 dprintk("%s: Race with other n->od=%p\n", __func__, n->od);
107 objio_free_deviceid_node(&de->id_node);
111 atomic_inc(&de->id_node.ref);
115 struct caps_buffers {
116 u8 caps_key[OSD_CRYPTO_KEYID_SIZE];
117 u8 creds[OSD_CAP_LEN];
120 struct objio_segment {
121 struct pnfs_layout_segment lseg;
123 struct pnfs_osd_object_cred *comps;
126 unsigned stripe_unit;
127 unsigned group_width; /* Data stripe_units without integrity comps */
129 unsigned group_count;
131 unsigned comps_index;
133 /* variable length */
134 struct objio_dev_ent *ods[];
137 static inline struct objio_segment *
138 OBJIO_LSEG(struct pnfs_layout_segment *lseg)
140 return container_of(lseg, struct objio_segment, lseg);
144 typedef ssize_t (*objio_done_fn)(struct objio_state *ios);
148 struct objlayout_io_state ol_state;
150 struct objio_segment *layout;
156 unsigned long length;
157 unsigned numdevs; /* Actually used devs in this IO */
158 /* A per-device variable array of size numdevs */
159 struct _objio_per_comp {
161 struct osd_request *or;
162 unsigned long length;
168 /* Send and wait for a get_device_info of devices in the layout,
169 then look them up with the osd_initiator library */
170 static struct objio_dev_ent *_device_lookup(struct pnfs_layout_hdr *pnfslay,
171 struct objio_segment *objio_seg, unsigned comp,
174 struct pnfs_osd_deviceaddr *deviceaddr;
175 struct nfs4_deviceid *d_id;
176 struct objio_dev_ent *ode;
178 struct osd_dev_info odi;
181 d_id = &objio_seg->comps[comp].oc_object_id.oid_device_id;
183 ode = _dev_list_find(NFS_SERVER(pnfslay->plh_inode), d_id);
187 err = objlayout_get_deviceinfo(pnfslay, d_id, &deviceaddr, gfp_flags);
189 dprintk("%s: objlayout_get_deviceinfo dev(%llx:%llx) =>%d\n",
190 __func__, _DEVID_LO(d_id), _DEVID_HI(d_id), err);
194 odi.systemid_len = deviceaddr->oda_systemid.len;
195 if (odi.systemid_len > sizeof(odi.systemid)) {
198 } else if (odi.systemid_len)
199 memcpy(odi.systemid, deviceaddr->oda_systemid.data,
201 odi.osdname_len = deviceaddr->oda_osdname.len;
202 odi.osdname = (u8 *)deviceaddr->oda_osdname.data;
204 if (!odi.osdname_len && !odi.systemid_len) {
205 dprintk("%s: !odi.osdname_len && !odi.systemid_len\n",
211 od = osduld_info_lookup(&odi);
212 if (unlikely(IS_ERR(od))) {
214 dprintk("%s: osduld_info_lookup => %d\n", __func__, err);
218 ode = _dev_list_add(NFS_SERVER(pnfslay->plh_inode), d_id, od,
222 dprintk("%s: return=%d\n", __func__, err);
223 objlayout_put_deviceinfo(deviceaddr);
224 return err ? ERR_PTR(err) : ode;
227 static int objio_devices_lookup(struct pnfs_layout_hdr *pnfslay,
228 struct objio_segment *objio_seg,
234 /* lookup all devices */
235 for (i = 0; i < objio_seg->num_comps; i++) {
236 struct objio_dev_ent *ode;
238 ode = _device_lookup(pnfslay, objio_seg, i, gfp_flags);
239 if (unlikely(IS_ERR(ode))) {
243 objio_seg->ods[i] = ode;
248 dprintk("%s: return=%d\n", __func__, err);
252 static int _verify_data_map(struct pnfs_osd_layout *layout)
254 struct pnfs_osd_data_map *data_map = &layout->olo_map;
258 /* FIXME: Only raid0 for now. if not go through MDS */
259 if (data_map->odm_raid_algorithm != PNFS_OSD_RAID_0) {
260 printk(KERN_ERR "Only RAID_0 for now\n");
263 if (0 != (data_map->odm_num_comps % (data_map->odm_mirror_cnt + 1))) {
264 printk(KERN_ERR "Data Map wrong, num_comps=%u mirrors=%u\n",
265 data_map->odm_num_comps, data_map->odm_mirror_cnt);
269 if (data_map->odm_group_width)
270 group_width = data_map->odm_group_width;
272 group_width = data_map->odm_num_comps /
273 (data_map->odm_mirror_cnt + 1);
275 stripe_length = (u64)data_map->odm_stripe_unit * group_width;
276 if (stripe_length >= (1ULL << 32)) {
277 printk(KERN_ERR "Total Stripe length(0x%llx)"
278 " >= 32bit is not supported\n", _LLU(stripe_length));
282 if (0 != (data_map->odm_stripe_unit & ~PAGE_MASK)) {
283 printk(KERN_ERR "Stripe Unit(0x%llx)"
284 " must be Multples of PAGE_SIZE(0x%lx)\n",
285 _LLU(data_map->odm_stripe_unit), PAGE_SIZE);
292 static void copy_single_comp(struct pnfs_osd_object_cred *cur_comp,
293 struct pnfs_osd_object_cred *src_comp,
294 struct caps_buffers *caps_p)
296 WARN_ON(src_comp->oc_cap_key.cred_len > sizeof(caps_p->caps_key));
297 WARN_ON(src_comp->oc_cap.cred_len > sizeof(caps_p->creds));
299 *cur_comp = *src_comp;
301 memcpy(caps_p->caps_key, src_comp->oc_cap_key.cred,
302 sizeof(caps_p->caps_key));
303 cur_comp->oc_cap_key.cred = caps_p->caps_key;
305 memcpy(caps_p->creds, src_comp->oc_cap.cred,
306 sizeof(caps_p->creds));
307 cur_comp->oc_cap.cred = caps_p->creds;
310 int objio_alloc_lseg(struct pnfs_layout_segment **outp,
311 struct pnfs_layout_hdr *pnfslay,
312 struct pnfs_layout_range *range,
313 struct xdr_stream *xdr,
316 struct objio_segment *objio_seg;
317 struct pnfs_osd_xdr_decode_layout_iter iter;
318 struct pnfs_osd_layout layout;
319 struct pnfs_osd_object_cred *cur_comp, src_comp;
320 struct caps_buffers *caps_p;
323 err = pnfs_osd_xdr_decode_layout_map(&layout, &iter, xdr);
327 err = _verify_data_map(&layout);
331 objio_seg = kzalloc(sizeof(*objio_seg) +
332 sizeof(objio_seg->ods[0]) * layout.olo_num_comps +
333 sizeof(*objio_seg->comps) * layout.olo_num_comps +
334 sizeof(struct caps_buffers) * layout.olo_num_comps,
339 objio_seg->comps = (void *)(objio_seg->ods + layout.olo_num_comps);
340 cur_comp = objio_seg->comps;
341 caps_p = (void *)(cur_comp + layout.olo_num_comps);
342 while (pnfs_osd_xdr_decode_layout_comp(&src_comp, &iter, xdr, &err))
343 copy_single_comp(cur_comp++, &src_comp, caps_p++);
347 objio_seg->num_comps = layout.olo_num_comps;
348 objio_seg->comps_index = layout.olo_comps_index;
349 err = objio_devices_lookup(pnfslay, objio_seg, gfp_flags);
353 objio_seg->mirrors_p1 = layout.olo_map.odm_mirror_cnt + 1;
354 objio_seg->stripe_unit = layout.olo_map.odm_stripe_unit;
355 if (layout.olo_map.odm_group_width) {
356 objio_seg->group_width = layout.olo_map.odm_group_width;
357 objio_seg->group_depth = layout.olo_map.odm_group_depth;
358 objio_seg->group_count = layout.olo_map.odm_num_comps /
359 objio_seg->mirrors_p1 /
360 objio_seg->group_width;
362 objio_seg->group_width = layout.olo_map.odm_num_comps /
363 objio_seg->mirrors_p1;
364 objio_seg->group_depth = -1;
365 objio_seg->group_count = 1;
368 *outp = &objio_seg->lseg;
373 dprintk("%s: Error: return %d\n", __func__, err);
378 void objio_free_lseg(struct pnfs_layout_segment *lseg)
381 struct objio_segment *objio_seg = OBJIO_LSEG(lseg);
383 for (i = 0; i < objio_seg->num_comps; i++) {
384 if (!objio_seg->ods[i])
386 nfs4_put_deviceid_node(&objio_seg->ods[i]->id_node);
391 int objio_alloc_io_state(struct pnfs_layout_segment *lseg,
392 struct objlayout_io_state **outp,
395 struct objio_segment *objio_seg = OBJIO_LSEG(lseg);
396 struct objio_state *ios;
397 const unsigned first_size = sizeof(*ios) +
398 objio_seg->num_comps * sizeof(ios->per_dev[0]);
400 ios = kzalloc(first_size, gfp_flags);
404 ios->layout = objio_seg;
406 *outp = &ios->ol_state;
410 void objio_free_io_state(struct objlayout_io_state *ol_state)
412 struct objio_state *ios = container_of(ol_state, struct objio_state,
418 static void _clear_bio(struct bio *bio)
423 __bio_for_each_segment(bv, bio, i, 0) {
424 unsigned this_count = bv->bv_len;
426 if (likely(PAGE_SIZE == this_count))
427 clear_highpage(bv->bv_page);
429 zero_user(bv->bv_page, bv->bv_offset, this_count);
433 static int _io_check(struct objio_state *ios, bool is_write)
435 enum osd_err_priority oep = OSD_ERR_PRI_NO_ERROR;
439 for (i = 0; i < ios->numdevs; i++) {
440 struct osd_sense_info osi;
441 struct osd_request *or = ios->per_dev[i].or;
448 ret = osd_req_decode_sense(or, &osi);
452 if (OSD_ERR_PRI_CLEAR_PAGES == osi.osd_err_pri) {
453 /* start read offset passed endof file */
455 _clear_bio(ios->per_dev[i].bio);
456 dprintk("%s: start read offset passed end of file "
457 "offset=0x%llx, length=0x%lx\n", __func__,
458 _LLU(ios->per_dev[i].offset),
459 ios->per_dev[i].length);
461 continue; /* we recovered */
463 dev = ios->per_dev[i].dev;
465 if (osi.osd_err_pri >= oep) {
466 oep = osi.osd_err_pri;
475 * Common IO state helpers.
477 static void _io_free(struct objio_state *ios)
481 for (i = 0; i < ios->numdevs; i++) {
482 struct _objio_per_comp *per_dev = &ios->per_dev[i];
485 osd_end_request(per_dev->or);
490 bio_put(per_dev->bio);
496 struct osd_dev *_io_od(struct objio_state *ios, unsigned dev)
498 unsigned min_dev = ios->layout->comps_index;
499 unsigned max_dev = min_dev + ios->layout->num_comps;
501 BUG_ON(dev < min_dev || max_dev <= dev);
502 return ios->layout->ods[dev - min_dev]->od;
505 struct _striping_info {
512 static void _calc_stripe_info(struct objio_state *ios, u64 file_offset,
513 struct _striping_info *si)
515 u32 stripe_unit = ios->layout->stripe_unit;
516 u32 group_width = ios->layout->group_width;
517 u64 group_depth = ios->layout->group_depth;
518 u32 U = stripe_unit * group_width;
520 u64 T = U * group_depth;
521 u64 S = T * ios->layout->group_count;
522 u64 M = div64_u64(file_offset, S);
525 G = (L - (M * S)) / T
526 H = (L - (M * S)) % T
528 u64 LmodU = file_offset - M * S;
529 u32 G = div64_u64(LmodU, T);
530 u64 H = LmodU - G * T;
532 u32 N = div_u64(H, U);
534 div_u64_rem(file_offset, stripe_unit, &si->unit_off);
535 si->obj_offset = si->unit_off + (N * stripe_unit) +
536 (M * group_depth * stripe_unit);
538 /* "H - (N * U)" is just "H % U" so it's bound to u32 */
539 si->dev = (u32)(H - (N * U)) / stripe_unit + G * group_width;
540 si->dev *= ios->layout->mirrors_p1;
542 si->group_length = T - H;
545 static int _add_stripe_unit(struct objio_state *ios, unsigned *cur_pg,
546 unsigned pgbase, struct _objio_per_comp *per_dev, int cur_len,
549 unsigned pg = *cur_pg;
550 struct request_queue *q =
551 osd_request_queue(_io_od(ios, per_dev->dev));
553 per_dev->length += cur_len;
555 if (per_dev->bio == NULL) {
556 unsigned stripes = ios->layout->num_comps /
557 ios->layout->mirrors_p1;
558 unsigned pages_in_stripe = stripes *
559 (ios->layout->stripe_unit / PAGE_SIZE);
560 unsigned bio_size = (ios->ol_state.nr_pages + pages_in_stripe) /
563 if (BIO_MAX_PAGES_KMALLOC < bio_size)
564 bio_size = BIO_MAX_PAGES_KMALLOC;
566 per_dev->bio = bio_kmalloc(gfp_flags, bio_size);
567 if (unlikely(!per_dev->bio)) {
568 dprintk("Faild to allocate BIO size=%u\n", bio_size);
573 while (cur_len > 0) {
574 unsigned pglen = min_t(unsigned, PAGE_SIZE - pgbase, cur_len);
577 BUG_ON(ios->ol_state.nr_pages <= pg);
580 added_len = bio_add_pc_page(q, per_dev->bio,
581 ios->ol_state.pages[pg], pglen, pgbase);
582 if (unlikely(pglen != added_len))
593 static int _prepare_one_group(struct objio_state *ios, u64 length,
594 struct _striping_info *si, unsigned *last_pg,
597 unsigned stripe_unit = ios->layout->stripe_unit;
598 unsigned mirrors_p1 = ios->layout->mirrors_p1;
599 unsigned devs_in_group = ios->layout->group_width * mirrors_p1;
600 unsigned dev = si->dev;
601 unsigned first_dev = dev - (dev % devs_in_group);
602 unsigned max_comp = ios->numdevs ? ios->numdevs - mirrors_p1 : 0;
603 unsigned cur_pg = *last_pg;
607 struct _objio_per_comp *per_dev = &ios->per_dev[dev];
608 unsigned cur_len, page_off = 0;
610 if (!per_dev->length) {
613 per_dev->offset = si->obj_offset + stripe_unit -
615 cur_len = stripe_unit;
616 } else if (dev == si->dev) {
617 per_dev->offset = si->obj_offset;
618 cur_len = stripe_unit - si->unit_off;
619 page_off = si->unit_off & ~PAGE_MASK;
621 (page_off != ios->ol_state.pgbase));
622 } else { /* dev > si->dev */
623 per_dev->offset = si->obj_offset - si->unit_off;
624 cur_len = stripe_unit;
630 cur_len = stripe_unit;
632 if (cur_len >= length)
635 ret = _add_stripe_unit(ios, &cur_pg, page_off , per_dev,
641 dev = (dev % devs_in_group) + first_dev;
644 ios->length += cur_len;
647 ios->numdevs = max_comp + mirrors_p1;
652 static int _io_rw_pagelist(struct objio_state *ios, gfp_t gfp_flags)
654 u64 length = ios->ol_state.count;
655 u64 offset = ios->ol_state.offset;
656 struct _striping_info si;
657 unsigned last_pg = 0;
661 _calc_stripe_info(ios, offset, &si);
663 if (length < si.group_length)
664 si.group_length = length;
666 ret = _prepare_one_group(ios, si.group_length, &si, &last_pg, gfp_flags);
670 offset += si.group_length;
671 length -= si.group_length;
681 static ssize_t _sync_done(struct objio_state *ios)
683 struct completion *waiting = ios->private;
689 static void _last_io(struct kref *kref)
691 struct objio_state *ios = container_of(kref, struct objio_state, kref);
696 static void _done_io(struct osd_request *or, void *p)
698 struct objio_state *ios = p;
700 kref_put(&ios->kref, _last_io);
703 static ssize_t _io_exec(struct objio_state *ios)
705 DECLARE_COMPLETION_ONSTACK(wait);
706 ssize_t status = 0; /* sync status */
708 objio_done_fn saved_done_fn = ios->done;
709 bool sync = ios->ol_state.sync;
712 ios->done = _sync_done;
713 ios->private = &wait;
716 kref_init(&ios->kref);
718 for (i = 0; i < ios->numdevs; i++) {
719 struct osd_request *or = ios->per_dev[i].or;
724 kref_get(&ios->kref);
725 osd_execute_request_async(or, _done_io, ios);
728 kref_put(&ios->kref, _last_io);
731 wait_for_completion(&wait);
732 status = saved_done_fn(ios);
741 static ssize_t _read_done(struct objio_state *ios)
744 int ret = _io_check(ios, false);
749 status = ios->length;
753 objlayout_read_done(&ios->ol_state, status, ios->ol_state.sync);
757 static int _read_mirrors(struct objio_state *ios, unsigned cur_comp)
759 struct osd_request *or = NULL;
760 struct _objio_per_comp *per_dev = &ios->per_dev[cur_comp];
761 unsigned dev = per_dev->dev;
762 struct pnfs_osd_object_cred *cred =
763 &ios->layout->comps[dev];
764 struct osd_obj_id obj = {
765 .partition = cred->oc_object_id.oid_partition_id,
766 .id = cred->oc_object_id.oid_object_id,
770 or = osd_start_request(_io_od(ios, dev), GFP_KERNEL);
777 osd_req_read(or, &obj, per_dev->offset, per_dev->bio, per_dev->length);
779 ret = osd_finalize_request(or, 0, cred->oc_cap.cred, NULL);
781 dprintk("%s: Faild to osd_finalize_request() => %d\n",
786 dprintk("%s:[%d] dev=%d obj=0x%llx start=0x%llx length=0x%lx\n",
787 __func__, cur_comp, dev, obj.id, _LLU(per_dev->offset),
794 static ssize_t _read_exec(struct objio_state *ios)
799 for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) {
800 if (!ios->per_dev[i].length)
802 ret = _read_mirrors(ios, i);
807 ios->done = _read_done;
808 return _io_exec(ios); /* In sync mode exec returns the io status */
815 ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state)
817 struct objio_state *ios = container_of(ol_state, struct objio_state,
821 ret = _io_rw_pagelist(ios, GFP_KERNEL);
825 return _read_exec(ios);
831 static ssize_t _write_done(struct objio_state *ios)
834 int ret = _io_check(ios, true);
839 /* FIXME: should be based on the OSD's persistence model
840 * See OSD2r05 Section 4.13 Data persistence model */
841 ios->ol_state.committed = NFS_FILE_SYNC;
842 status = ios->length;
847 objlayout_write_done(&ios->ol_state, status, ios->ol_state.sync);
851 static int _write_mirrors(struct objio_state *ios, unsigned cur_comp)
853 struct _objio_per_comp *master_dev = &ios->per_dev[cur_comp];
854 unsigned dev = ios->per_dev[cur_comp].dev;
855 unsigned last_comp = cur_comp + ios->layout->mirrors_p1;
858 for (; cur_comp < last_comp; ++cur_comp, ++dev) {
859 struct osd_request *or = NULL;
860 struct pnfs_osd_object_cred *cred =
861 &ios->layout->comps[dev];
862 struct osd_obj_id obj = {
863 .partition = cred->oc_object_id.oid_partition_id,
864 .id = cred->oc_object_id.oid_object_id,
866 struct _objio_per_comp *per_dev = &ios->per_dev[cur_comp];
869 or = osd_start_request(_io_od(ios, dev), GFP_NOFS);
876 if (per_dev != master_dev) {
877 bio = bio_kmalloc(GFP_NOFS,
878 master_dev->bio->bi_max_vecs);
879 if (unlikely(!bio)) {
880 dprintk("Faild to allocate BIO size=%u\n",
881 master_dev->bio->bi_max_vecs);
886 __bio_clone(bio, master_dev->bio);
891 per_dev->length = master_dev->length;
892 per_dev->offset = master_dev->offset;
894 bio = master_dev->bio;
895 bio->bi_rw |= REQ_WRITE;
898 osd_req_write(or, &obj, per_dev->offset, bio, per_dev->length);
900 ret = osd_finalize_request(or, 0, cred->oc_cap.cred, NULL);
902 dprintk("%s: Faild to osd_finalize_request() => %d\n",
907 dprintk("%s:[%d] dev=%d obj=0x%llx start=0x%llx length=0x%lx\n",
908 __func__, cur_comp, dev, obj.id, _LLU(per_dev->offset),
916 static ssize_t _write_exec(struct objio_state *ios)
921 for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) {
922 if (!ios->per_dev[i].length)
924 ret = _write_mirrors(ios, i);
929 ios->done = _write_done;
930 return _io_exec(ios); /* In sync mode exec returns the io->status */
937 ssize_t objio_write_pagelist(struct objlayout_io_state *ol_state, bool stable)
939 struct objio_state *ios = container_of(ol_state, struct objio_state,
943 /* TODO: ios->stable = stable; */
944 ret = _io_rw_pagelist(ios, GFP_NOFS);
948 return _write_exec(ios);
952 * objlayout_pg_test(). Called by nfs_can_coalesce_requests()
954 * return 1 : coalesce page
955 * return 0 : don't coalesce page
958 objlayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
959 struct nfs_page *req)
964 static struct pnfs_layoutdriver_type objlayout_type = {
965 .id = LAYOUT_OSD2_OBJECTS,
966 .name = "LAYOUT_OSD2_OBJECTS",
968 .alloc_layout_hdr = objlayout_alloc_layout_hdr,
969 .free_layout_hdr = objlayout_free_layout_hdr,
971 .alloc_lseg = objlayout_alloc_lseg,
972 .free_lseg = objlayout_free_lseg,
974 .read_pagelist = objlayout_read_pagelist,
975 .write_pagelist = objlayout_write_pagelist,
976 .pg_test = objlayout_pg_test,
978 .free_deviceid_node = objio_free_deviceid_node,
981 MODULE_DESCRIPTION("pNFS Layout Driver for OSD2 objects");
982 MODULE_AUTHOR("Benny Halevy <bhalevy@panasas.com>");
983 MODULE_LICENSE("GPL");
988 int ret = pnfs_register_layoutdriver(&objlayout_type);
992 "%s: Registering OSD pNFS Layout Driver failed: error=%d\n",
995 printk(KERN_INFO "%s: Registered OSD pNFS Layout Driver\n",
1001 objlayout_exit(void)
1003 pnfs_unregister_layoutdriver(&objlayout_type);
1004 printk(KERN_INFO "%s: Unregistered OSD pNFS Layout Driver\n",
1008 module_init(objlayout_init);
1009 module_exit(objlayout_exit);