2 * Module for pnfs flexfile layout driver.
4 * Copyright (c) 2014, Primary Data, Inc. All rights reserved.
6 * Tao Peng <bergwolf@primarydata.com>
9 #include <linux/nfs_fs.h>
10 #include <linux/nfs_page.h>
11 #include <linux/module.h>
13 #include <linux/sunrpc/metrics.h>
15 #include "flexfilelayout.h"
16 #include "../nfs4session.h"
17 #include "../nfs4idmap.h"
18 #include "../internal.h"
19 #include "../delegation.h"
20 #include "../nfs4trace.h"
21 #include "../iostat.h"
25 #define NFSDBG_FACILITY NFSDBG_PNFS_LD
27 #define FF_LAYOUT_POLL_RETRY_MAX (15*HZ)
29 static struct pnfs_layout_hdr
*
30 ff_layout_alloc_layout_hdr(struct inode
*inode
, gfp_t gfp_flags
)
32 struct nfs4_flexfile_layout
*ffl
;
34 ffl
= kzalloc(sizeof(*ffl
), gfp_flags
);
36 INIT_LIST_HEAD(&ffl
->error_list
);
37 INIT_LIST_HEAD(&ffl
->mirrors
);
38 return &ffl
->generic_hdr
;
44 ff_layout_free_layout_hdr(struct pnfs_layout_hdr
*lo
)
46 struct nfs4_ff_layout_ds_err
*err
, *n
;
48 list_for_each_entry_safe(err
, n
, &FF_LAYOUT_FROM_HDR(lo
)->error_list
,
53 kfree(FF_LAYOUT_FROM_HDR(lo
));
56 static int decode_stateid(struct xdr_stream
*xdr
, nfs4_stateid
*stateid
)
60 p
= xdr_inline_decode(xdr
, NFS4_STATEID_SIZE
);
61 if (unlikely(p
== NULL
))
63 memcpy(stateid
, p
, NFS4_STATEID_SIZE
);
64 dprintk("%s: stateid id= [%x%x%x%x]\n", __func__
,
65 p
[0], p
[1], p
[2], p
[3]);
69 static int decode_deviceid(struct xdr_stream
*xdr
, struct nfs4_deviceid
*devid
)
73 p
= xdr_inline_decode(xdr
, NFS4_DEVICEID4_SIZE
);
76 memcpy(devid
, p
, NFS4_DEVICEID4_SIZE
);
77 nfs4_print_deviceid(devid
);
81 static int decode_nfs_fh(struct xdr_stream
*xdr
, struct nfs_fh
*fh
)
85 p
= xdr_inline_decode(xdr
, 4);
88 fh
->size
= be32_to_cpup(p
++);
89 if (fh
->size
> sizeof(struct nfs_fh
)) {
90 printk(KERN_ERR
"NFS flexfiles: Too big fh received %d\n",
95 p
= xdr_inline_decode(xdr
, fh
->size
);
98 memcpy(&fh
->data
, p
, fh
->size
);
99 dprintk("%s: fh len %d\n", __func__
, fh
->size
);
105 * Currently only stringified uids and gids are accepted.
106 * I.e., kerberos is not supported to the DSes, so no pricipals.
108 * That means that one common function will suffice, but when
109 * principals are added, this should be split to accomodate
110 * calls to both nfs_map_name_to_uid() and nfs_map_group_to_gid().
113 decode_name(struct xdr_stream
*xdr
, u32
*id
)
118 /* opaque_length(4)*/
119 p
= xdr_inline_decode(xdr
, 4);
122 len
= be32_to_cpup(p
++);
126 dprintk("%s: len %u\n", __func__
, len
);
129 p
= xdr_inline_decode(xdr
, len
);
133 if (!nfs_map_string_to_numeric((char *)p
, len
, id
))
139 static bool ff_mirror_match_fh(const struct nfs4_ff_layout_mirror
*m1
,
140 const struct nfs4_ff_layout_mirror
*m2
)
144 if (m1
->fh_versions_cnt
!= m2
->fh_versions_cnt
)
146 for (i
= 0; i
< m1
->fh_versions_cnt
; i
++) {
147 bool found_fh
= false;
148 for (j
= 0; j
< m2
->fh_versions_cnt
; i
++) {
149 if (nfs_compare_fh(&m1
->fh_versions
[i
],
150 &m2
->fh_versions
[j
]) == 0) {
161 static struct nfs4_ff_layout_mirror
*
162 ff_layout_add_mirror(struct pnfs_layout_hdr
*lo
,
163 struct nfs4_ff_layout_mirror
*mirror
)
165 struct nfs4_flexfile_layout
*ff_layout
= FF_LAYOUT_FROM_HDR(lo
);
166 struct nfs4_ff_layout_mirror
*pos
;
167 struct inode
*inode
= lo
->plh_inode
;
169 spin_lock(&inode
->i_lock
);
170 list_for_each_entry(pos
, &ff_layout
->mirrors
, mirrors
) {
171 if (mirror
->mirror_ds
!= pos
->mirror_ds
)
173 if (!ff_mirror_match_fh(mirror
, pos
))
175 if (atomic_inc_not_zero(&pos
->ref
)) {
176 spin_unlock(&inode
->i_lock
);
180 list_add(&mirror
->mirrors
, &ff_layout
->mirrors
);
182 spin_unlock(&inode
->i_lock
);
187 ff_layout_remove_mirror(struct nfs4_ff_layout_mirror
*mirror
)
190 if (mirror
->layout
== NULL
)
192 inode
= mirror
->layout
->plh_inode
;
193 spin_lock(&inode
->i_lock
);
194 list_del(&mirror
->mirrors
);
195 spin_unlock(&inode
->i_lock
);
196 mirror
->layout
= NULL
;
199 static struct nfs4_ff_layout_mirror
*ff_layout_alloc_mirror(gfp_t gfp_flags
)
201 struct nfs4_ff_layout_mirror
*mirror
;
203 mirror
= kzalloc(sizeof(*mirror
), gfp_flags
);
204 if (mirror
!= NULL
) {
205 spin_lock_init(&mirror
->lock
);
206 atomic_set(&mirror
->ref
, 1);
207 INIT_LIST_HEAD(&mirror
->mirrors
);
212 static void ff_layout_free_mirror(struct nfs4_ff_layout_mirror
*mirror
)
214 ff_layout_remove_mirror(mirror
);
215 kfree(mirror
->fh_versions
);
217 put_rpccred(mirror
->cred
);
218 nfs4_ff_layout_put_deviceid(mirror
->mirror_ds
);
222 static void ff_layout_put_mirror(struct nfs4_ff_layout_mirror
*mirror
)
224 if (mirror
!= NULL
&& atomic_dec_and_test(&mirror
->ref
))
225 ff_layout_free_mirror(mirror
);
228 static void ff_layout_free_mirror_array(struct nfs4_ff_layout_segment
*fls
)
232 if (fls
->mirror_array
) {
233 for (i
= 0; i
< fls
->mirror_array_cnt
; i
++) {
234 /* normally mirror_ds is freed in
235 * .free_deviceid_node but we still do it here
236 * for .alloc_lseg error path */
237 ff_layout_put_mirror(fls
->mirror_array
[i
]);
239 kfree(fls
->mirror_array
);
240 fls
->mirror_array
= NULL
;
244 static int ff_layout_check_layout(struct nfs4_layoutget_res
*lgr
)
248 dprintk("--> %s\n", __func__
);
250 /* FIXME: remove this check when layout segment support is added */
251 if (lgr
->range
.offset
!= 0 ||
252 lgr
->range
.length
!= NFS4_MAX_UINT64
) {
253 dprintk("%s Only whole file layouts supported. Use MDS i/o\n",
258 dprintk("--> %s returns %d\n", __func__
, ret
);
262 static void _ff_layout_free_lseg(struct nfs4_ff_layout_segment
*fls
)
265 ff_layout_free_mirror_array(fls
);
271 ff_lseg_range_is_after(const struct pnfs_layout_range
*l1
,
272 const struct pnfs_layout_range
*l2
)
276 if (l1
->iomode
!= l2
->iomode
)
277 return l1
->iomode
!= IOMODE_READ
;
278 end1
= pnfs_calc_offset_end(l1
->offset
, l1
->length
);
279 end2
= pnfs_calc_offset_end(l2
->offset
, l2
->length
);
280 if (end1
< l2
->offset
)
282 if (end2
< l1
->offset
)
284 return l2
->offset
<= l1
->offset
;
288 ff_lseg_merge(struct pnfs_layout_segment
*new,
289 struct pnfs_layout_segment
*old
)
291 u64 new_end
, old_end
;
293 if (new->pls_range
.iomode
!= old
->pls_range
.iomode
)
295 old_end
= pnfs_calc_offset_end(old
->pls_range
.offset
,
296 old
->pls_range
.length
);
297 if (old_end
< new->pls_range
.offset
)
299 new_end
= pnfs_calc_offset_end(new->pls_range
.offset
,
300 new->pls_range
.length
);
301 if (new_end
< old
->pls_range
.offset
)
304 /* Mergeable: copy info from 'old' to 'new' */
305 if (new_end
< old_end
)
307 if (new->pls_range
.offset
< old
->pls_range
.offset
)
308 new->pls_range
.offset
= old
->pls_range
.offset
;
309 new->pls_range
.length
= pnfs_calc_offset_length(new->pls_range
.offset
,
311 if (test_bit(NFS_LSEG_ROC
, &old
->pls_flags
))
312 set_bit(NFS_LSEG_ROC
, &new->pls_flags
);
313 if (test_bit(NFS_LSEG_LAYOUTRETURN
, &old
->pls_flags
))
314 set_bit(NFS_LSEG_LAYOUTRETURN
, &new->pls_flags
);
319 ff_layout_add_lseg(struct pnfs_layout_hdr
*lo
,
320 struct pnfs_layout_segment
*lseg
,
321 struct list_head
*free_me
)
323 pnfs_generic_layout_insert_lseg(lo
, lseg
,
324 ff_lseg_range_is_after
,
329 static void ff_layout_sort_mirrors(struct nfs4_ff_layout_segment
*fls
)
333 for (i
= 0; i
< fls
->mirror_array_cnt
- 1; i
++) {
334 for (j
= i
+ 1; j
< fls
->mirror_array_cnt
; j
++)
335 if (fls
->mirror_array
[i
]->efficiency
<
336 fls
->mirror_array
[j
]->efficiency
)
337 swap(fls
->mirror_array
[i
],
338 fls
->mirror_array
[j
]);
342 static void ff_layout_mark_devices_valid(struct nfs4_ff_layout_segment
*fls
)
344 struct nfs4_deviceid_node
*node
;
347 if (!(fls
->flags
& FF_FLAGS_NO_IO_THRU_MDS
))
349 for (i
= 0; i
< fls
->mirror_array_cnt
; i
++) {
350 node
= &fls
->mirror_array
[i
]->mirror_ds
->id_node
;
351 clear_bit(NFS_DEVICEID_UNAVAILABLE
, &node
->flags
);
355 static struct pnfs_layout_segment
*
356 ff_layout_alloc_lseg(struct pnfs_layout_hdr
*lh
,
357 struct nfs4_layoutget_res
*lgr
,
360 struct pnfs_layout_segment
*ret
;
361 struct nfs4_ff_layout_segment
*fls
= NULL
;
362 struct xdr_stream stream
;
364 struct page
*scratch
;
366 u32 mirror_array_cnt
;
370 dprintk("--> %s\n", __func__
);
371 scratch
= alloc_page(gfp_flags
);
373 return ERR_PTR(-ENOMEM
);
375 xdr_init_decode_pages(&stream
, &buf
, lgr
->layoutp
->pages
,
377 xdr_set_scratch_buffer(&stream
, page_address(scratch
), PAGE_SIZE
);
379 /* stripe unit and mirror_array_cnt */
381 p
= xdr_inline_decode(&stream
, 8 + 4);
385 p
= xdr_decode_hyper(p
, &stripe_unit
);
386 mirror_array_cnt
= be32_to_cpup(p
++);
387 dprintk("%s: stripe_unit=%llu mirror_array_cnt=%u\n", __func__
,
388 stripe_unit
, mirror_array_cnt
);
390 if (mirror_array_cnt
> NFS4_FLEXFILE_LAYOUT_MAX_MIRROR_CNT
||
391 mirror_array_cnt
== 0)
395 fls
= kzalloc(sizeof(*fls
), gfp_flags
);
399 fls
->mirror_array_cnt
= mirror_array_cnt
;
400 fls
->stripe_unit
= stripe_unit
;
401 fls
->mirror_array
= kcalloc(fls
->mirror_array_cnt
,
402 sizeof(fls
->mirror_array
[0]), gfp_flags
);
403 if (fls
->mirror_array
== NULL
)
406 for (i
= 0; i
< fls
->mirror_array_cnt
; i
++) {
407 struct nfs4_ff_layout_mirror
*mirror
;
408 struct nfs4_deviceid devid
;
409 struct nfs4_deviceid_node
*idnode
;
415 p
= xdr_inline_decode(&stream
, 4);
418 ds_count
= be32_to_cpup(p
);
420 /* FIXME: allow for striping? */
424 fls
->mirror_array
[i
] = ff_layout_alloc_mirror(gfp_flags
);
425 if (fls
->mirror_array
[i
] == NULL
) {
430 fls
->mirror_array
[i
]->ds_count
= ds_count
;
433 rc
= decode_deviceid(&stream
, &devid
);
437 idnode
= nfs4_find_get_deviceid(NFS_SERVER(lh
->plh_inode
),
438 &devid
, lh
->plh_lc_cred
,
441 * upon success, mirror_ds is allocated by previous
442 * getdeviceinfo, or newly by .alloc_deviceid_node
443 * nfs4_find_get_deviceid failure is indeed getdeviceinfo falure
446 fls
->mirror_array
[i
]->mirror_ds
=
447 FF_LAYOUT_MIRROR_DS(idnode
);
453 p
= xdr_inline_decode(&stream
, 4);
456 fls
->mirror_array
[i
]->efficiency
= be32_to_cpup(p
);
459 rc
= decode_stateid(&stream
, &fls
->mirror_array
[i
]->stateid
);
464 p
= xdr_inline_decode(&stream
, 4);
467 fh_count
= be32_to_cpup(p
);
469 fls
->mirror_array
[i
]->fh_versions
=
470 kzalloc(fh_count
* sizeof(struct nfs_fh
),
472 if (fls
->mirror_array
[i
]->fh_versions
== NULL
) {
477 for (j
= 0; j
< fh_count
; j
++) {
478 rc
= decode_nfs_fh(&stream
,
479 &fls
->mirror_array
[i
]->fh_versions
[j
]);
484 fls
->mirror_array
[i
]->fh_versions_cnt
= fh_count
;
487 rc
= decode_name(&stream
, &fls
->mirror_array
[i
]->uid
);
492 rc
= decode_name(&stream
, &fls
->mirror_array
[i
]->gid
);
496 mirror
= ff_layout_add_mirror(lh
, fls
->mirror_array
[i
]);
497 if (mirror
!= fls
->mirror_array
[i
]) {
498 ff_layout_free_mirror(fls
->mirror_array
[i
]);
499 fls
->mirror_array
[i
] = mirror
;
502 dprintk("%s: uid %d gid %d\n", __func__
,
503 fls
->mirror_array
[i
]->uid
,
504 fls
->mirror_array
[i
]->gid
);
507 p
= xdr_inline_decode(&stream
, 4);
509 fls
->flags
= be32_to_cpup(p
);
511 ff_layout_sort_mirrors(fls
);
512 rc
= ff_layout_check_layout(lgr
);
515 ff_layout_mark_devices_valid(fls
);
517 ret
= &fls
->generic_hdr
;
518 dprintk("<-- %s (success)\n", __func__
);
520 __free_page(scratch
);
523 _ff_layout_free_lseg(fls
);
525 dprintk("<-- %s (%d)\n", __func__
, rc
);
529 static bool ff_layout_has_rw_segments(struct pnfs_layout_hdr
*layout
)
531 struct pnfs_layout_segment
*lseg
;
533 list_for_each_entry(lseg
, &layout
->plh_segs
, pls_list
)
534 if (lseg
->pls_range
.iomode
== IOMODE_RW
)
541 ff_layout_free_lseg(struct pnfs_layout_segment
*lseg
)
543 struct nfs4_ff_layout_segment
*fls
= FF_LAYOUT_LSEG(lseg
);
545 dprintk("--> %s\n", __func__
);
547 if (lseg
->pls_range
.iomode
== IOMODE_RW
) {
548 struct nfs4_flexfile_layout
*ffl
;
551 ffl
= FF_LAYOUT_FROM_HDR(lseg
->pls_layout
);
552 inode
= ffl
->generic_hdr
.plh_inode
;
553 spin_lock(&inode
->i_lock
);
554 if (!ff_layout_has_rw_segments(lseg
->pls_layout
)) {
555 ffl
->commit_info
.nbuckets
= 0;
556 kfree(ffl
->commit_info
.buckets
);
557 ffl
->commit_info
.buckets
= NULL
;
559 spin_unlock(&inode
->i_lock
);
561 _ff_layout_free_lseg(fls
);
564 /* Return 1 until we have multiple lsegs support */
566 ff_layout_get_lseg_count(struct nfs4_ff_layout_segment
*fls
)
572 nfs4_ff_start_busy_timer(struct nfs4_ff_busy_timer
*timer
, ktime_t now
)
574 /* first IO request? */
575 if (atomic_inc_return(&timer
->n_ops
) == 1) {
576 timer
->start_time
= now
;
581 nfs4_ff_end_busy_timer(struct nfs4_ff_busy_timer
*timer
, ktime_t now
)
585 if (atomic_dec_return(&timer
->n_ops
) < 0)
588 start
= timer
->start_time
;
589 timer
->start_time
= now
;
590 return ktime_sub(now
, start
);
594 nfs4_ff_layoutstat_start_io(struct nfs4_ff_layout_mirror
*mirror
,
595 struct nfs4_ff_layoutstat
*layoutstat
,
598 static const ktime_t notime
= {0};
599 s64 report_interval
= FF_LAYOUTSTATS_REPORT_INTERVAL
;
601 nfs4_ff_start_busy_timer(&layoutstat
->busy_timer
, now
);
602 if (ktime_equal(mirror
->start_time
, notime
))
603 mirror
->start_time
= now
;
604 if (ktime_equal(mirror
->last_report_time
, notime
))
605 mirror
->last_report_time
= now
;
606 if (layoutstats_timer
!= 0)
607 report_interval
= (s64
)layoutstats_timer
* 1000LL;
608 if (ktime_to_ms(ktime_sub(now
, mirror
->last_report_time
)) >=
610 mirror
->last_report_time
= now
;
618 nfs4_ff_layout_stat_io_update_requested(struct nfs4_ff_layoutstat
*layoutstat
,
621 struct nfs4_ff_io_stat
*iostat
= &layoutstat
->io_stat
;
623 iostat
->ops_requested
++;
624 iostat
->bytes_requested
+= requested
;
628 nfs4_ff_layout_stat_io_update_completed(struct nfs4_ff_layoutstat
*layoutstat
,
631 ktime_t time_completed
,
632 ktime_t time_started
)
634 struct nfs4_ff_io_stat
*iostat
= &layoutstat
->io_stat
;
635 ktime_t completion_time
= ktime_sub(time_completed
, time_started
);
638 iostat
->ops_completed
++;
639 iostat
->bytes_completed
+= completed
;
640 iostat
->bytes_not_delivered
+= requested
- completed
;
642 timer
= nfs4_ff_end_busy_timer(&layoutstat
->busy_timer
, time_completed
);
643 iostat
->total_busy_time
=
644 ktime_add(iostat
->total_busy_time
, timer
);
645 iostat
->aggregate_completion_time
=
646 ktime_add(iostat
->aggregate_completion_time
,
651 nfs4_ff_layout_stat_io_start_read(struct inode
*inode
,
652 struct nfs4_ff_layout_mirror
*mirror
,
653 __u64 requested
, ktime_t now
)
657 spin_lock(&mirror
->lock
);
658 report
= nfs4_ff_layoutstat_start_io(mirror
, &mirror
->read_stat
, now
);
659 nfs4_ff_layout_stat_io_update_requested(&mirror
->read_stat
, requested
);
660 spin_unlock(&mirror
->lock
);
663 pnfs_report_layoutstat(inode
, GFP_KERNEL
);
667 nfs4_ff_layout_stat_io_end_read(struct rpc_task
*task
,
668 struct nfs4_ff_layout_mirror
*mirror
,
672 spin_lock(&mirror
->lock
);
673 nfs4_ff_layout_stat_io_update_completed(&mirror
->read_stat
,
674 requested
, completed
,
675 ktime_get(), task
->tk_start
);
676 spin_unlock(&mirror
->lock
);
680 nfs4_ff_layout_stat_io_start_write(struct inode
*inode
,
681 struct nfs4_ff_layout_mirror
*mirror
,
682 __u64 requested
, ktime_t now
)
686 spin_lock(&mirror
->lock
);
687 report
= nfs4_ff_layoutstat_start_io(mirror
, &mirror
->write_stat
, now
);
688 nfs4_ff_layout_stat_io_update_requested(&mirror
->write_stat
, requested
);
689 spin_unlock(&mirror
->lock
);
692 pnfs_report_layoutstat(inode
, GFP_NOIO
);
696 nfs4_ff_layout_stat_io_end_write(struct rpc_task
*task
,
697 struct nfs4_ff_layout_mirror
*mirror
,
700 enum nfs3_stable_how committed
)
702 if (committed
== NFS_UNSTABLE
)
703 requested
= completed
= 0;
705 spin_lock(&mirror
->lock
);
706 nfs4_ff_layout_stat_io_update_completed(&mirror
->write_stat
,
707 requested
, completed
, ktime_get(), task
->tk_start
);
708 spin_unlock(&mirror
->lock
);
712 ff_layout_alloc_commit_info(struct pnfs_layout_segment
*lseg
,
713 struct nfs_commit_info
*cinfo
,
716 struct nfs4_ff_layout_segment
*fls
= FF_LAYOUT_LSEG(lseg
);
717 struct pnfs_commit_bucket
*buckets
;
720 if (cinfo
->ds
->nbuckets
!= 0) {
721 /* This assumes there is only one RW lseg per file.
722 * To support multiple lseg per file, we need to
723 * change struct pnfs_commit_bucket to allow dynamic
724 * increasing nbuckets.
729 size
= ff_layout_get_lseg_count(fls
) * FF_LAYOUT_MIRROR_COUNT(lseg
);
731 buckets
= kcalloc(size
, sizeof(struct pnfs_commit_bucket
),
738 spin_lock(cinfo
->lock
);
739 if (cinfo
->ds
->nbuckets
!= 0)
742 cinfo
->ds
->buckets
= buckets
;
743 cinfo
->ds
->nbuckets
= size
;
744 for (i
= 0; i
< size
; i
++) {
745 INIT_LIST_HEAD(&buckets
[i
].written
);
746 INIT_LIST_HEAD(&buckets
[i
].committing
);
747 /* mark direct verifier as unset */
748 buckets
[i
].direct_verf
.committed
=
749 NFS_INVALID_STABLE_HOW
;
752 spin_unlock(cinfo
->lock
);
757 static struct nfs4_pnfs_ds
*
758 ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment
*lseg
,
762 struct nfs4_ff_layout_segment
*fls
= FF_LAYOUT_LSEG(lseg
);
763 struct nfs4_pnfs_ds
*ds
;
766 /* mirrors are sorted by efficiency */
767 for (idx
= start_idx
; idx
< fls
->mirror_array_cnt
; idx
++) {
768 ds
= nfs4_ff_layout_prepare_ds(lseg
, idx
, false);
779 ff_layout_pg_init_read(struct nfs_pageio_descriptor
*pgio
,
780 struct nfs_page
*req
)
782 struct nfs_pgio_mirror
*pgm
;
783 struct nfs4_ff_layout_mirror
*mirror
;
784 struct nfs4_pnfs_ds
*ds
;
787 /* Use full layout for now */
789 pgio
->pg_lseg
= pnfs_update_layout(pgio
->pg_inode
,
795 /* If no lseg, fall back to read through mds */
796 if (pgio
->pg_lseg
== NULL
)
799 ds
= ff_layout_choose_best_ds_for_read(pgio
->pg_lseg
, 0, &ds_idx
);
802 mirror
= FF_LAYOUT_COMP(pgio
->pg_lseg
, ds_idx
);
804 pgio
->pg_mirror_idx
= ds_idx
;
806 /* read always uses only one mirror - idx 0 for pgio layer */
807 pgm
= &pgio
->pg_mirrors
[0];
808 pgm
->pg_bsize
= mirror
->mirror_ds
->ds_versions
[0].rsize
;
812 pnfs_put_lseg(pgio
->pg_lseg
);
813 pgio
->pg_lseg
= NULL
;
814 nfs_pageio_reset_read_mds(pgio
);
818 ff_layout_pg_init_write(struct nfs_pageio_descriptor
*pgio
,
819 struct nfs_page
*req
)
821 struct nfs4_ff_layout_mirror
*mirror
;
822 struct nfs_pgio_mirror
*pgm
;
823 struct nfs_commit_info cinfo
;
824 struct nfs4_pnfs_ds
*ds
;
829 pgio
->pg_lseg
= pnfs_update_layout(pgio
->pg_inode
,
835 /* If no lseg, fall back to write through mds */
836 if (pgio
->pg_lseg
== NULL
)
839 nfs_init_cinfo(&cinfo
, pgio
->pg_inode
, pgio
->pg_dreq
);
840 status
= ff_layout_alloc_commit_info(pgio
->pg_lseg
, &cinfo
, GFP_NOFS
);
844 /* Use a direct mapping of ds_idx to pgio mirror_idx */
845 if (WARN_ON_ONCE(pgio
->pg_mirror_count
!=
846 FF_LAYOUT_MIRROR_COUNT(pgio
->pg_lseg
)))
849 for (i
= 0; i
< pgio
->pg_mirror_count
; i
++) {
850 ds
= nfs4_ff_layout_prepare_ds(pgio
->pg_lseg
, i
, true);
853 pgm
= &pgio
->pg_mirrors
[i
];
854 mirror
= FF_LAYOUT_COMP(pgio
->pg_lseg
, i
);
855 pgm
->pg_bsize
= mirror
->mirror_ds
->ds_versions
[0].wsize
;
861 pnfs_put_lseg(pgio
->pg_lseg
);
862 pgio
->pg_lseg
= NULL
;
863 nfs_pageio_reset_write_mds(pgio
);
867 ff_layout_pg_get_mirror_count_write(struct nfs_pageio_descriptor
*pgio
,
868 struct nfs_page
*req
)
871 pgio
->pg_lseg
= pnfs_update_layout(pgio
->pg_inode
,
878 return FF_LAYOUT_MIRROR_COUNT(pgio
->pg_lseg
);
880 /* no lseg means that pnfs is not in use, so no mirroring here */
881 nfs_pageio_reset_write_mds(pgio
);
885 static const struct nfs_pageio_ops ff_layout_pg_read_ops
= {
886 .pg_init
= ff_layout_pg_init_read
,
887 .pg_test
= pnfs_generic_pg_test
,
888 .pg_doio
= pnfs_generic_pg_readpages
,
889 .pg_cleanup
= pnfs_generic_pg_cleanup
,
892 static const struct nfs_pageio_ops ff_layout_pg_write_ops
= {
893 .pg_init
= ff_layout_pg_init_write
,
894 .pg_test
= pnfs_generic_pg_test
,
895 .pg_doio
= pnfs_generic_pg_writepages
,
896 .pg_get_mirror_count
= ff_layout_pg_get_mirror_count_write
,
897 .pg_cleanup
= pnfs_generic_pg_cleanup
,
900 static void ff_layout_reset_write(struct nfs_pgio_header
*hdr
, bool retry_pnfs
)
902 struct rpc_task
*task
= &hdr
->task
;
904 pnfs_layoutcommit_inode(hdr
->inode
, false);
907 dprintk("%s Reset task %5u for i/o through pNFS "
908 "(req %s/%llu, %u bytes @ offset %llu)\n", __func__
,
910 hdr
->inode
->i_sb
->s_id
,
911 (unsigned long long)NFS_FILEID(hdr
->inode
),
913 (unsigned long long)hdr
->args
.offset
);
916 struct nfs_open_context
*ctx
;
918 ctx
= nfs_list_entry(hdr
->pages
.next
)->wb_context
;
919 set_bit(NFS_CONTEXT_RESEND_WRITES
, &ctx
->flags
);
920 hdr
->completion_ops
->error_cleanup(&hdr
->pages
);
922 nfs_direct_set_resched_writes(hdr
->dreq
);
923 /* fake unstable write to let common nfs resend pages */
924 hdr
->verf
.committed
= NFS_UNSTABLE
;
925 hdr
->good_bytes
= hdr
->args
.count
;
930 if (!test_and_set_bit(NFS_IOHDR_REDO
, &hdr
->flags
)) {
931 dprintk("%s Reset task %5u for i/o through MDS "
932 "(req %s/%llu, %u bytes @ offset %llu)\n", __func__
,
934 hdr
->inode
->i_sb
->s_id
,
935 (unsigned long long)NFS_FILEID(hdr
->inode
),
937 (unsigned long long)hdr
->args
.offset
);
939 task
->tk_status
= pnfs_write_done_resend_to_mds(hdr
);
943 static void ff_layout_reset_read(struct nfs_pgio_header
*hdr
)
945 struct rpc_task
*task
= &hdr
->task
;
947 pnfs_layoutcommit_inode(hdr
->inode
, false);
949 if (!test_and_set_bit(NFS_IOHDR_REDO
, &hdr
->flags
)) {
950 dprintk("%s Reset task %5u for i/o through MDS "
951 "(req %s/%llu, %u bytes @ offset %llu)\n", __func__
,
953 hdr
->inode
->i_sb
->s_id
,
954 (unsigned long long)NFS_FILEID(hdr
->inode
),
956 (unsigned long long)hdr
->args
.offset
);
958 task
->tk_status
= pnfs_read_done_resend_to_mds(hdr
);
962 static int ff_layout_async_handle_error_v4(struct rpc_task
*task
,
963 struct nfs4_state
*state
,
964 struct nfs_client
*clp
,
965 struct pnfs_layout_segment
*lseg
,
968 struct pnfs_layout_hdr
*lo
= lseg
->pls_layout
;
969 struct inode
*inode
= lo
->plh_inode
;
970 struct nfs_server
*mds_server
= NFS_SERVER(inode
);
972 struct nfs4_deviceid_node
*devid
= FF_LAYOUT_DEVID_NODE(lseg
, idx
);
973 struct nfs_client
*mds_client
= mds_server
->nfs_client
;
974 struct nfs4_slot_table
*tbl
= &clp
->cl_session
->fc_slot_table
;
976 if (task
->tk_status
>= 0)
979 switch (task
->tk_status
) {
980 /* MDS state errors */
981 case -NFS4ERR_DELEG_REVOKED
:
982 case -NFS4ERR_ADMIN_REVOKED
:
983 case -NFS4ERR_BAD_STATEID
:
986 nfs_remove_bad_delegation(state
->inode
);
987 case -NFS4ERR_OPENMODE
:
990 if (nfs4_schedule_stateid_recovery(mds_server
, state
) < 0)
991 goto out_bad_stateid
;
992 goto wait_on_recovery
;
993 case -NFS4ERR_EXPIRED
:
995 if (nfs4_schedule_stateid_recovery(mds_server
, state
) < 0)
996 goto out_bad_stateid
;
998 nfs4_schedule_lease_recovery(mds_client
);
999 goto wait_on_recovery
;
1000 /* DS session errors */
1001 case -NFS4ERR_BADSESSION
:
1002 case -NFS4ERR_BADSLOT
:
1003 case -NFS4ERR_BAD_HIGH_SLOT
:
1004 case -NFS4ERR_DEADSESSION
:
1005 case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION
:
1006 case -NFS4ERR_SEQ_FALSE_RETRY
:
1007 case -NFS4ERR_SEQ_MISORDERED
:
1008 dprintk("%s ERROR %d, Reset session. Exchangeid "
1009 "flags 0x%x\n", __func__
, task
->tk_status
,
1010 clp
->cl_exchange_flags
);
1011 nfs4_schedule_session_recovery(clp
->cl_session
, task
->tk_status
);
1013 case -NFS4ERR_DELAY
:
1014 case -NFS4ERR_GRACE
:
1015 rpc_delay(task
, FF_LAYOUT_POLL_RETRY_MAX
);
1017 case -NFS4ERR_RETRY_UNCACHED_REP
:
1019 /* Invalidate Layout errors */
1020 case -NFS4ERR_PNFS_NO_LAYOUT
:
1021 case -ESTALE
: /* mapped NFS4ERR_STALE */
1022 case -EBADHANDLE
: /* mapped NFS4ERR_BADHANDLE */
1023 case -EISDIR
: /* mapped NFS4ERR_ISDIR */
1024 case -NFS4ERR_FHEXPIRED
:
1025 case -NFS4ERR_WRONG_TYPE
:
1026 dprintk("%s Invalid layout error %d\n", __func__
,
1029 * Destroy layout so new i/o will get a new layout.
1030 * Layout will not be destroyed until all current lseg
1031 * references are put. Mark layout as invalid to resend failed
1032 * i/o and all i/o waiting on the slot table to the MDS until
1033 * layout is destroyed and a new valid layout is obtained.
1035 pnfs_destroy_layout(NFS_I(inode
));
1036 rpc_wake_up(&tbl
->slot_tbl_waitq
);
1038 /* RPC connection errors */
1046 dprintk("%s DS connection error %d\n", __func__
,
1048 nfs4_mark_deviceid_unavailable(devid
);
1049 rpc_wake_up(&tbl
->slot_tbl_waitq
);
1052 if (ff_layout_no_fallback_to_mds(lseg
) ||
1053 ff_layout_has_available_ds(lseg
))
1054 return -NFS4ERR_RESET_TO_PNFS
;
1056 dprintk("%s Retry through MDS. Error %d\n", __func__
,
1058 return -NFS4ERR_RESET_TO_MDS
;
1061 task
->tk_status
= 0;
1064 task
->tk_status
= -EIO
;
1067 rpc_sleep_on(&mds_client
->cl_rpcwaitq
, task
, NULL
);
1068 if (test_bit(NFS4CLNT_MANAGER_RUNNING
, &mds_client
->cl_state
) == 0)
1069 rpc_wake_up_queued_task(&mds_client
->cl_rpcwaitq
, task
);
1073 /* Retry all errors through either pNFS or MDS except for -EJUKEBOX */
1074 static int ff_layout_async_handle_error_v3(struct rpc_task
*task
,
1075 struct pnfs_layout_segment
*lseg
,
1078 struct nfs4_deviceid_node
*devid
= FF_LAYOUT_DEVID_NODE(lseg
, idx
);
1080 if (task
->tk_status
>= 0)
1083 switch (task
->tk_status
) {
1084 /* File access problems. Don't mark the device as unavailable */
1093 nfs_inc_stats(lseg
->pls_layout
->plh_inode
, NFSIOS_DELAY
);
1096 dprintk("%s DS connection error %d\n", __func__
,
1098 nfs4_mark_deviceid_unavailable(devid
);
1100 /* FIXME: Need to prevent infinite looping here. */
1101 return -NFS4ERR_RESET_TO_PNFS
;
1103 task
->tk_status
= 0;
1104 rpc_restart_call(task
);
1105 rpc_delay(task
, NFS_JUKEBOX_RETRY_TIME
);
1109 static int ff_layout_async_handle_error(struct rpc_task
*task
,
1110 struct nfs4_state
*state
,
1111 struct nfs_client
*clp
,
1112 struct pnfs_layout_segment
*lseg
,
1115 int vers
= clp
->cl_nfs_mod
->rpc_vers
->number
;
1119 return ff_layout_async_handle_error_v3(task
, lseg
, idx
);
1121 return ff_layout_async_handle_error_v4(task
, state
, clp
,
1124 /* should never happen */
1130 static void ff_layout_io_track_ds_error(struct pnfs_layout_segment
*lseg
,
1131 int idx
, u64 offset
, u64 length
,
1132 u32 status
, int opnum
, int error
)
1134 struct nfs4_ff_layout_mirror
*mirror
;
1141 case -EPROTONOSUPPORT
:
1152 status
= NFS4ERR_NXIO
;
1155 status
= NFS4ERR_ACCESS
;
1162 mirror
= FF_LAYOUT_COMP(lseg
, idx
);
1163 err
= ff_layout_track_ds_error(FF_LAYOUT_FROM_HDR(lseg
->pls_layout
),
1164 mirror
, offset
, length
, status
, opnum
,
1166 pnfs_error_mark_layout_for_return(lseg
->pls_layout
->plh_inode
, lseg
);
1167 dprintk("%s: err %d op %d status %u\n", __func__
, err
, opnum
, status
);
1170 /* NFS_PROTO call done callback routines */
1171 static int ff_layout_read_done_cb(struct rpc_task
*task
,
1172 struct nfs_pgio_header
*hdr
)
1176 trace_nfs4_pnfs_read(hdr
, task
->tk_status
);
1177 if (task
->tk_status
< 0)
1178 ff_layout_io_track_ds_error(hdr
->lseg
, hdr
->pgio_mirror_idx
,
1179 hdr
->args
.offset
, hdr
->args
.count
,
1180 hdr
->res
.op_status
, OP_READ
,
1182 err
= ff_layout_async_handle_error(task
, hdr
->args
.context
->state
,
1183 hdr
->ds_clp
, hdr
->lseg
,
1184 hdr
->pgio_mirror_idx
);
1187 case -NFS4ERR_RESET_TO_PNFS
:
1188 if (ff_layout_choose_best_ds_for_read(hdr
->lseg
,
1189 hdr
->pgio_mirror_idx
+ 1,
1190 &hdr
->pgio_mirror_idx
))
1192 set_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE
,
1193 &hdr
->lseg
->pls_layout
->plh_flags
);
1194 pnfs_read_resend_pnfs(hdr
);
1195 return task
->tk_status
;
1196 case -NFS4ERR_RESET_TO_MDS
:
1197 ff_layout_reset_read(hdr
);
1198 return task
->tk_status
;
1205 rpc_restart_call_prepare(task
);
1210 ff_layout_need_layoutcommit(struct pnfs_layout_segment
*lseg
)
1212 return !(FF_LAYOUT_LSEG(lseg
)->flags
& FF_FLAGS_NO_LAYOUTCOMMIT
);
1216 * We reference the rpc_cred of the first WRITE that triggers the need for
1217 * a LAYOUTCOMMIT, and use it to send the layoutcommit compound.
1218 * rfc5661 is not clear about which credential should be used.
1220 * Flexlayout client should treat DS replied FILE_SYNC as DATA_SYNC, so
1221 * to follow http://www.rfc-editor.org/errata_search.php?rfc=5661&eid=2751
1222 * we always send layoutcommit after DS writes.
1225 ff_layout_set_layoutcommit(struct nfs_pgio_header
*hdr
)
1227 if (!ff_layout_need_layoutcommit(hdr
->lseg
))
1230 pnfs_set_layoutcommit(hdr
->inode
, hdr
->lseg
,
1231 hdr
->mds_offset
+ hdr
->res
.count
);
1232 dprintk("%s inode %lu pls_end_pos %lu\n", __func__
, hdr
->inode
->i_ino
,
1233 (unsigned long) NFS_I(hdr
->inode
)->layout
->plh_lwb
);
1237 ff_layout_reset_to_mds(struct pnfs_layout_segment
*lseg
, int idx
)
1239 /* No mirroring for now */
1240 struct nfs4_deviceid_node
*node
= FF_LAYOUT_DEVID_NODE(lseg
, idx
);
1242 return ff_layout_test_devid_unavailable(node
);
1245 static int ff_layout_read_prepare_common(struct rpc_task
*task
,
1246 struct nfs_pgio_header
*hdr
)
1248 nfs4_ff_layout_stat_io_start_read(hdr
->inode
,
1249 FF_LAYOUT_COMP(hdr
->lseg
, hdr
->pgio_mirror_idx
),
1253 if (unlikely(test_bit(NFS_CONTEXT_BAD
, &hdr
->args
.context
->flags
))) {
1254 rpc_exit(task
, -EIO
);
1257 if (ff_layout_reset_to_mds(hdr
->lseg
, hdr
->pgio_mirror_idx
)) {
1258 dprintk("%s task %u reset io to MDS\n", __func__
, task
->tk_pid
);
1259 if (ff_layout_has_available_ds(hdr
->lseg
))
1260 pnfs_read_resend_pnfs(hdr
);
1262 ff_layout_reset_read(hdr
);
1266 hdr
->pgio_done_cb
= ff_layout_read_done_cb
;
1272 * Call ops for the async read/write cases
1273 * In the case of dense layouts, the offset needs to be reset to its
1276 static void ff_layout_read_prepare_v3(struct rpc_task
*task
, void *data
)
1278 struct nfs_pgio_header
*hdr
= data
;
1280 if (ff_layout_read_prepare_common(task
, hdr
))
1283 rpc_call_start(task
);
1286 static int ff_layout_setup_sequence(struct nfs_client
*ds_clp
,
1287 struct nfs4_sequence_args
*args
,
1288 struct nfs4_sequence_res
*res
,
1289 struct rpc_task
*task
)
1291 if (ds_clp
->cl_session
)
1292 return nfs41_setup_sequence(ds_clp
->cl_session
,
1296 return nfs40_setup_sequence(ds_clp
->cl_slot_tbl
,
1302 static void ff_layout_read_prepare_v4(struct rpc_task
*task
, void *data
)
1304 struct nfs_pgio_header
*hdr
= data
;
1306 if (ff_layout_setup_sequence(hdr
->ds_clp
,
1307 &hdr
->args
.seq_args
,
1312 if (ff_layout_read_prepare_common(task
, hdr
))
1315 if (nfs4_set_rw_stateid(&hdr
->args
.stateid
, hdr
->args
.context
,
1316 hdr
->args
.lock_context
, FMODE_READ
) == -EIO
)
1317 rpc_exit(task
, -EIO
); /* lost lock, terminate I/O */
1320 static void ff_layout_read_call_done(struct rpc_task
*task
, void *data
)
1322 struct nfs_pgio_header
*hdr
= data
;
1324 dprintk("--> %s task->tk_status %d\n", __func__
, task
->tk_status
);
1326 nfs4_ff_layout_stat_io_end_read(task
,
1327 FF_LAYOUT_COMP(hdr
->lseg
, hdr
->pgio_mirror_idx
),
1328 hdr
->args
.count
, hdr
->res
.count
);
1330 if (test_bit(NFS_IOHDR_REDO
, &hdr
->flags
) &&
1331 task
->tk_status
== 0) {
1332 nfs4_sequence_done(task
, &hdr
->res
.seq_res
);
1336 /* Note this may cause RPC to be resent */
1337 hdr
->mds_ops
->rpc_call_done(task
, hdr
);
1340 static void ff_layout_read_count_stats(struct rpc_task
*task
, void *data
)
1342 struct nfs_pgio_header
*hdr
= data
;
1344 rpc_count_iostats_metrics(task
,
1345 &NFS_CLIENT(hdr
->inode
)->cl_metrics
[NFSPROC4_CLNT_READ
]);
1348 static int ff_layout_write_done_cb(struct rpc_task
*task
,
1349 struct nfs_pgio_header
*hdr
)
1353 trace_nfs4_pnfs_write(hdr
, task
->tk_status
);
1354 if (task
->tk_status
< 0)
1355 ff_layout_io_track_ds_error(hdr
->lseg
, hdr
->pgio_mirror_idx
,
1356 hdr
->args
.offset
, hdr
->args
.count
,
1357 hdr
->res
.op_status
, OP_WRITE
,
1359 err
= ff_layout_async_handle_error(task
, hdr
->args
.context
->state
,
1360 hdr
->ds_clp
, hdr
->lseg
,
1361 hdr
->pgio_mirror_idx
);
1364 case -NFS4ERR_RESET_TO_PNFS
:
1365 pnfs_set_retry_layoutget(hdr
->lseg
->pls_layout
);
1366 ff_layout_reset_write(hdr
, true);
1367 return task
->tk_status
;
1368 case -NFS4ERR_RESET_TO_MDS
:
1369 pnfs_clear_retry_layoutget(hdr
->lseg
->pls_layout
);
1370 ff_layout_reset_write(hdr
, false);
1371 return task
->tk_status
;
1373 rpc_restart_call_prepare(task
);
1377 if (hdr
->res
.verf
->committed
== NFS_FILE_SYNC
||
1378 hdr
->res
.verf
->committed
== NFS_DATA_SYNC
)
1379 ff_layout_set_layoutcommit(hdr
);
1381 /* zero out fattr since we don't care DS attr at all */
1382 hdr
->fattr
.valid
= 0;
1383 if (task
->tk_status
>= 0)
1384 nfs_writeback_update_inode(hdr
);
1389 static int ff_layout_commit_done_cb(struct rpc_task
*task
,
1390 struct nfs_commit_data
*data
)
1394 trace_nfs4_pnfs_commit_ds(data
, task
->tk_status
);
1395 if (task
->tk_status
< 0)
1396 ff_layout_io_track_ds_error(data
->lseg
, data
->ds_commit_index
,
1397 data
->args
.offset
, data
->args
.count
,
1398 data
->res
.op_status
, OP_COMMIT
,
1400 err
= ff_layout_async_handle_error(task
, NULL
, data
->ds_clp
,
1401 data
->lseg
, data
->ds_commit_index
);
1404 case -NFS4ERR_RESET_TO_PNFS
:
1405 pnfs_set_retry_layoutget(data
->lseg
->pls_layout
);
1406 pnfs_generic_prepare_to_resend_writes(data
);
1408 case -NFS4ERR_RESET_TO_MDS
:
1409 pnfs_clear_retry_layoutget(data
->lseg
->pls_layout
);
1410 pnfs_generic_prepare_to_resend_writes(data
);
1413 rpc_restart_call_prepare(task
);
1417 if (data
->verf
.committed
== NFS_UNSTABLE
1418 && ff_layout_need_layoutcommit(data
->lseg
))
1419 pnfs_set_layoutcommit(data
->inode
, data
->lseg
, data
->lwb
);
1424 static int ff_layout_write_prepare_common(struct rpc_task
*task
,
1425 struct nfs_pgio_header
*hdr
)
1427 nfs4_ff_layout_stat_io_start_write(hdr
->inode
,
1428 FF_LAYOUT_COMP(hdr
->lseg
, hdr
->pgio_mirror_idx
),
1432 if (unlikely(test_bit(NFS_CONTEXT_BAD
, &hdr
->args
.context
->flags
))) {
1433 rpc_exit(task
, -EIO
);
1437 if (ff_layout_reset_to_mds(hdr
->lseg
, hdr
->pgio_mirror_idx
)) {
1440 retry_pnfs
= ff_layout_has_available_ds(hdr
->lseg
);
1441 dprintk("%s task %u reset io to %s\n", __func__
,
1442 task
->tk_pid
, retry_pnfs
? "pNFS" : "MDS");
1443 ff_layout_reset_write(hdr
, retry_pnfs
);
1451 static void ff_layout_write_prepare_v3(struct rpc_task
*task
, void *data
)
1453 struct nfs_pgio_header
*hdr
= data
;
1455 if (ff_layout_write_prepare_common(task
, hdr
))
1458 rpc_call_start(task
);
1461 static void ff_layout_write_prepare_v4(struct rpc_task
*task
, void *data
)
1463 struct nfs_pgio_header
*hdr
= data
;
1465 if (ff_layout_setup_sequence(hdr
->ds_clp
,
1466 &hdr
->args
.seq_args
,
1471 if (ff_layout_write_prepare_common(task
, hdr
))
1474 if (nfs4_set_rw_stateid(&hdr
->args
.stateid
, hdr
->args
.context
,
1475 hdr
->args
.lock_context
, FMODE_WRITE
) == -EIO
)
1476 rpc_exit(task
, -EIO
); /* lost lock, terminate I/O */
1479 static void ff_layout_write_call_done(struct rpc_task
*task
, void *data
)
1481 struct nfs_pgio_header
*hdr
= data
;
1483 nfs4_ff_layout_stat_io_end_write(task
,
1484 FF_LAYOUT_COMP(hdr
->lseg
, hdr
->pgio_mirror_idx
),
1485 hdr
->args
.count
, hdr
->res
.count
,
1486 hdr
->res
.verf
->committed
);
1488 if (test_bit(NFS_IOHDR_REDO
, &hdr
->flags
) &&
1489 task
->tk_status
== 0) {
1490 nfs4_sequence_done(task
, &hdr
->res
.seq_res
);
1494 /* Note this may cause RPC to be resent */
1495 hdr
->mds_ops
->rpc_call_done(task
, hdr
);
1498 static void ff_layout_write_count_stats(struct rpc_task
*task
, void *data
)
1500 struct nfs_pgio_header
*hdr
= data
;
1502 rpc_count_iostats_metrics(task
,
1503 &NFS_CLIENT(hdr
->inode
)->cl_metrics
[NFSPROC4_CLNT_WRITE
]);
1506 static void ff_layout_commit_prepare_common(struct rpc_task
*task
,
1507 struct nfs_commit_data
*cdata
)
1509 nfs4_ff_layout_stat_io_start_write(cdata
->inode
,
1510 FF_LAYOUT_COMP(cdata
->lseg
, cdata
->ds_commit_index
),
1514 static void ff_layout_commit_prepare_v3(struct rpc_task
*task
, void *data
)
1516 ff_layout_commit_prepare_common(task
, data
);
1517 rpc_call_start(task
);
1520 static void ff_layout_commit_prepare_v4(struct rpc_task
*task
, void *data
)
1522 struct nfs_commit_data
*wdata
= data
;
1524 if (ff_layout_setup_sequence(wdata
->ds_clp
,
1525 &wdata
->args
.seq_args
,
1526 &wdata
->res
.seq_res
,
1529 ff_layout_commit_prepare_common(task
, data
);
1532 static void ff_layout_commit_done(struct rpc_task
*task
, void *data
)
1534 struct nfs_commit_data
*cdata
= data
;
1535 struct nfs_page
*req
;
1538 if (task
->tk_status
== 0) {
1539 list_for_each_entry(req
, &cdata
->pages
, wb_list
)
1540 count
+= req
->wb_bytes
;
1543 nfs4_ff_layout_stat_io_end_write(task
,
1544 FF_LAYOUT_COMP(cdata
->lseg
, cdata
->ds_commit_index
),
1545 count
, count
, NFS_FILE_SYNC
);
1547 pnfs_generic_write_commit_done(task
, data
);
1550 static void ff_layout_commit_count_stats(struct rpc_task
*task
, void *data
)
1552 struct nfs_commit_data
*cdata
= data
;
1554 rpc_count_iostats_metrics(task
,
1555 &NFS_CLIENT(cdata
->inode
)->cl_metrics
[NFSPROC4_CLNT_COMMIT
]);
1558 static const struct rpc_call_ops ff_layout_read_call_ops_v3
= {
1559 .rpc_call_prepare
= ff_layout_read_prepare_v3
,
1560 .rpc_call_done
= ff_layout_read_call_done
,
1561 .rpc_count_stats
= ff_layout_read_count_stats
,
1562 .rpc_release
= pnfs_generic_rw_release
,
1565 static const struct rpc_call_ops ff_layout_read_call_ops_v4
= {
1566 .rpc_call_prepare
= ff_layout_read_prepare_v4
,
1567 .rpc_call_done
= ff_layout_read_call_done
,
1568 .rpc_count_stats
= ff_layout_read_count_stats
,
1569 .rpc_release
= pnfs_generic_rw_release
,
1572 static const struct rpc_call_ops ff_layout_write_call_ops_v3
= {
1573 .rpc_call_prepare
= ff_layout_write_prepare_v3
,
1574 .rpc_call_done
= ff_layout_write_call_done
,
1575 .rpc_count_stats
= ff_layout_write_count_stats
,
1576 .rpc_release
= pnfs_generic_rw_release
,
1579 static const struct rpc_call_ops ff_layout_write_call_ops_v4
= {
1580 .rpc_call_prepare
= ff_layout_write_prepare_v4
,
1581 .rpc_call_done
= ff_layout_write_call_done
,
1582 .rpc_count_stats
= ff_layout_write_count_stats
,
1583 .rpc_release
= pnfs_generic_rw_release
,
1586 static const struct rpc_call_ops ff_layout_commit_call_ops_v3
= {
1587 .rpc_call_prepare
= ff_layout_commit_prepare_v3
,
1588 .rpc_call_done
= ff_layout_commit_done
,
1589 .rpc_count_stats
= ff_layout_commit_count_stats
,
1590 .rpc_release
= pnfs_generic_commit_release
,
1593 static const struct rpc_call_ops ff_layout_commit_call_ops_v4
= {
1594 .rpc_call_prepare
= ff_layout_commit_prepare_v4
,
1595 .rpc_call_done
= ff_layout_commit_done
,
1596 .rpc_count_stats
= ff_layout_commit_count_stats
,
1597 .rpc_release
= pnfs_generic_commit_release
,
1600 static enum pnfs_try_status
1601 ff_layout_read_pagelist(struct nfs_pgio_header
*hdr
)
1603 struct pnfs_layout_segment
*lseg
= hdr
->lseg
;
1604 struct nfs4_pnfs_ds
*ds
;
1605 struct rpc_clnt
*ds_clnt
;
1606 struct rpc_cred
*ds_cred
;
1607 loff_t offset
= hdr
->args
.offset
;
1608 u32 idx
= hdr
->pgio_mirror_idx
;
1612 dprintk("--> %s ino %lu pgbase %u req %Zu@%llu\n",
1613 __func__
, hdr
->inode
->i_ino
,
1614 hdr
->args
.pgbase
, (size_t)hdr
->args
.count
, offset
);
1616 ds
= nfs4_ff_layout_prepare_ds(lseg
, idx
, false);
1620 ds_clnt
= nfs4_ff_find_or_create_ds_client(lseg
, idx
, ds
->ds_clp
,
1622 if (IS_ERR(ds_clnt
))
1625 ds_cred
= ff_layout_get_ds_cred(lseg
, idx
, hdr
->cred
);
1626 if (IS_ERR(ds_cred
))
1629 vers
= nfs4_ff_layout_ds_version(lseg
, idx
);
1631 dprintk("%s USE DS: %s cl_count %d vers %d\n", __func__
,
1632 ds
->ds_remotestr
, atomic_read(&ds
->ds_clp
->cl_count
), vers
);
1634 atomic_inc(&ds
->ds_clp
->cl_count
);
1635 hdr
->ds_clp
= ds
->ds_clp
;
1636 fh
= nfs4_ff_layout_select_ds_fh(lseg
, idx
);
1640 * Note that if we ever decide to split across DSes,
1641 * then we may need to handle dense-like offsets.
1643 hdr
->args
.offset
= offset
;
1644 hdr
->mds_offset
= offset
;
1646 /* Perform an asynchronous read to ds */
1647 nfs_initiate_pgio(ds_clnt
, hdr
, ds_cred
, ds
->ds_clp
->rpc_ops
,
1648 vers
== 3 ? &ff_layout_read_call_ops_v3
:
1649 &ff_layout_read_call_ops_v4
,
1650 0, RPC_TASK_SOFTCONN
);
1652 return PNFS_ATTEMPTED
;
1655 if (ff_layout_has_available_ds(lseg
))
1656 return PNFS_TRY_AGAIN
;
1657 return PNFS_NOT_ATTEMPTED
;
1660 /* Perform async writes. */
1661 static enum pnfs_try_status
1662 ff_layout_write_pagelist(struct nfs_pgio_header
*hdr
, int sync
)
1664 struct pnfs_layout_segment
*lseg
= hdr
->lseg
;
1665 struct nfs4_pnfs_ds
*ds
;
1666 struct rpc_clnt
*ds_clnt
;
1667 struct rpc_cred
*ds_cred
;
1668 loff_t offset
= hdr
->args
.offset
;
1671 int idx
= hdr
->pgio_mirror_idx
;
1673 ds
= nfs4_ff_layout_prepare_ds(lseg
, idx
, true);
1675 return PNFS_NOT_ATTEMPTED
;
1677 ds_clnt
= nfs4_ff_find_or_create_ds_client(lseg
, idx
, ds
->ds_clp
,
1679 if (IS_ERR(ds_clnt
))
1680 return PNFS_NOT_ATTEMPTED
;
1682 ds_cred
= ff_layout_get_ds_cred(lseg
, idx
, hdr
->cred
);
1683 if (IS_ERR(ds_cred
))
1684 return PNFS_NOT_ATTEMPTED
;
1686 vers
= nfs4_ff_layout_ds_version(lseg
, idx
);
1688 dprintk("%s ino %lu sync %d req %Zu@%llu DS: %s cl_count %d vers %d\n",
1689 __func__
, hdr
->inode
->i_ino
, sync
, (size_t) hdr
->args
.count
,
1690 offset
, ds
->ds_remotestr
, atomic_read(&ds
->ds_clp
->cl_count
),
1693 hdr
->pgio_done_cb
= ff_layout_write_done_cb
;
1694 atomic_inc(&ds
->ds_clp
->cl_count
);
1695 hdr
->ds_clp
= ds
->ds_clp
;
1696 hdr
->ds_commit_idx
= idx
;
1697 fh
= nfs4_ff_layout_select_ds_fh(lseg
, idx
);
1702 * Note that if we ever decide to split across DSes,
1703 * then we may need to handle dense-like offsets.
1705 hdr
->args
.offset
= offset
;
1707 /* Perform an asynchronous write */
1708 nfs_initiate_pgio(ds_clnt
, hdr
, ds_cred
, ds
->ds_clp
->rpc_ops
,
1709 vers
== 3 ? &ff_layout_write_call_ops_v3
:
1710 &ff_layout_write_call_ops_v4
,
1711 sync
, RPC_TASK_SOFTCONN
);
1712 return PNFS_ATTEMPTED
;
1715 static u32
calc_ds_index_from_commit(struct pnfs_layout_segment
*lseg
, u32 i
)
1720 static struct nfs_fh
*
1721 select_ds_fh_from_commit(struct pnfs_layout_segment
*lseg
, u32 i
)
1723 struct nfs4_ff_layout_segment
*flseg
= FF_LAYOUT_LSEG(lseg
);
1725 /* FIXME: Assume that there is only one NFS version available
1728 return &flseg
->mirror_array
[i
]->fh_versions
[0];
1731 static int ff_layout_initiate_commit(struct nfs_commit_data
*data
, int how
)
1733 struct pnfs_layout_segment
*lseg
= data
->lseg
;
1734 struct nfs4_pnfs_ds
*ds
;
1735 struct rpc_clnt
*ds_clnt
;
1736 struct rpc_cred
*ds_cred
;
1741 idx
= calc_ds_index_from_commit(lseg
, data
->ds_commit_index
);
1742 ds
= nfs4_ff_layout_prepare_ds(lseg
, idx
, true);
1746 ds_clnt
= nfs4_ff_find_or_create_ds_client(lseg
, idx
, ds
->ds_clp
,
1748 if (IS_ERR(ds_clnt
))
1751 ds_cred
= ff_layout_get_ds_cred(lseg
, idx
, data
->cred
);
1752 if (IS_ERR(ds_cred
))
1755 vers
= nfs4_ff_layout_ds_version(lseg
, idx
);
1757 dprintk("%s ino %lu, how %d cl_count %d vers %d\n", __func__
,
1758 data
->inode
->i_ino
, how
, atomic_read(&ds
->ds_clp
->cl_count
),
1760 data
->commit_done_cb
= ff_layout_commit_done_cb
;
1761 data
->cred
= ds_cred
;
1762 atomic_inc(&ds
->ds_clp
->cl_count
);
1763 data
->ds_clp
= ds
->ds_clp
;
1764 fh
= select_ds_fh_from_commit(lseg
, data
->ds_commit_index
);
1768 return nfs_initiate_commit(ds_clnt
, data
, ds
->ds_clp
->rpc_ops
,
1769 vers
== 3 ? &ff_layout_commit_call_ops_v3
:
1770 &ff_layout_commit_call_ops_v4
,
1771 how
, RPC_TASK_SOFTCONN
);
1773 pnfs_generic_prepare_to_resend_writes(data
);
1774 pnfs_generic_commit_release(data
);
1779 ff_layout_commit_pagelist(struct inode
*inode
, struct list_head
*mds_pages
,
1780 int how
, struct nfs_commit_info
*cinfo
)
1782 return pnfs_generic_commit_pagelist(inode
, mds_pages
, how
, cinfo
,
1783 ff_layout_initiate_commit
);
1786 static struct pnfs_ds_commit_info
*
1787 ff_layout_get_ds_info(struct inode
*inode
)
1789 struct pnfs_layout_hdr
*layout
= NFS_I(inode
)->layout
;
1794 return &FF_LAYOUT_FROM_HDR(layout
)->commit_info
;
1798 ff_layout_free_deviceid_node(struct nfs4_deviceid_node
*d
)
1800 nfs4_ff_layout_free_deviceid(container_of(d
, struct nfs4_ff_layout_ds
,
1804 static int ff_layout_encode_ioerr(struct nfs4_flexfile_layout
*flo
,
1805 struct xdr_stream
*xdr
,
1806 const struct nfs4_layoutreturn_args
*args
)
1808 struct pnfs_layout_hdr
*hdr
= &flo
->generic_hdr
;
1810 int count
= 0, ret
= 0;
1812 start
= xdr_reserve_space(xdr
, 4);
1813 if (unlikely(!start
))
1816 /* This assume we always return _ALL_ layouts */
1817 spin_lock(&hdr
->plh_inode
->i_lock
);
1818 ret
= ff_layout_encode_ds_ioerr(flo
, xdr
, &count
, &args
->range
);
1819 spin_unlock(&hdr
->plh_inode
->i_lock
);
1821 *start
= cpu_to_be32(count
);
1826 /* report nothing for now */
1827 static void ff_layout_encode_iostats(struct nfs4_flexfile_layout
*flo
,
1828 struct xdr_stream
*xdr
,
1829 const struct nfs4_layoutreturn_args
*args
)
1833 p
= xdr_reserve_space(xdr
, 4);
1835 *p
= cpu_to_be32(0);
1838 static struct nfs4_deviceid_node
*
1839 ff_layout_alloc_deviceid_node(struct nfs_server
*server
,
1840 struct pnfs_device
*pdev
, gfp_t gfp_flags
)
1842 struct nfs4_ff_layout_ds
*dsaddr
;
1844 dsaddr
= nfs4_ff_alloc_deviceid_node(server
, pdev
, gfp_flags
);
1847 return &dsaddr
->id_node
;
1851 ff_layout_encode_layoutreturn(struct pnfs_layout_hdr
*lo
,
1852 struct xdr_stream
*xdr
,
1853 const struct nfs4_layoutreturn_args
*args
)
1855 struct nfs4_flexfile_layout
*flo
= FF_LAYOUT_FROM_HDR(lo
);
1858 dprintk("%s: Begin\n", __func__
);
1859 start
= xdr_reserve_space(xdr
, 4);
1862 if (ff_layout_encode_ioerr(flo
, xdr
, args
))
1865 ff_layout_encode_iostats(flo
, xdr
, args
);
1867 *start
= cpu_to_be32((xdr
->p
- start
- 1) * 4);
1868 dprintk("%s: Return\n", __func__
);
1872 ff_layout_ntop4(const struct sockaddr
*sap
, char *buf
, const size_t buflen
)
1874 const struct sockaddr_in
*sin
= (struct sockaddr_in
*)sap
;
1876 return snprintf(buf
, buflen
, "%pI4", &sin
->sin_addr
);
1880 ff_layout_ntop6_noscopeid(const struct sockaddr
*sap
, char *buf
,
1883 const struct sockaddr_in6
*sin6
= (struct sockaddr_in6
*)sap
;
1884 const struct in6_addr
*addr
= &sin6
->sin6_addr
;
1887 * RFC 4291, Section 2.2.2
1889 * Shorthanded ANY address
1891 if (ipv6_addr_any(addr
))
1892 return snprintf(buf
, buflen
, "::");
1895 * RFC 4291, Section 2.2.2
1897 * Shorthanded loopback address
1899 if (ipv6_addr_loopback(addr
))
1900 return snprintf(buf
, buflen
, "::1");
1903 * RFC 4291, Section 2.2.3
1905 * Special presentation address format for mapped v4
1908 if (ipv6_addr_v4mapped(addr
))
1909 return snprintf(buf
, buflen
, "::ffff:%pI4",
1910 &addr
->s6_addr32
[3]);
1913 * RFC 4291, Section 2.2.1
1915 return snprintf(buf
, buflen
, "%pI6c", addr
);
1918 /* Derived from rpc_sockaddr2uaddr */
1920 ff_layout_encode_netaddr(struct xdr_stream
*xdr
, struct nfs4_pnfs_ds_addr
*da
)
1922 struct sockaddr
*sap
= (struct sockaddr
*)&da
->da_addr
;
1923 char portbuf
[RPCBIND_MAXUADDRPLEN
];
1924 char addrbuf
[RPCBIND_MAXUADDRLEN
];
1926 unsigned short port
;
1930 switch (sap
->sa_family
) {
1932 if (ff_layout_ntop4(sap
, addrbuf
, sizeof(addrbuf
)) == 0)
1934 port
= ntohs(((struct sockaddr_in
*)sap
)->sin_port
);
1939 if (ff_layout_ntop6_noscopeid(sap
, addrbuf
, sizeof(addrbuf
)) == 0)
1941 port
= ntohs(((struct sockaddr_in6
*)sap
)->sin6_port
);
1946 /* we only support tcp and tcp6 */
1951 snprintf(portbuf
, sizeof(portbuf
), ".%u.%u", port
>> 8, port
& 0xff);
1952 len
= strlcat(addrbuf
, portbuf
, sizeof(addrbuf
));
1954 p
= xdr_reserve_space(xdr
, 4 + netid_len
);
1955 xdr_encode_opaque(p
, netid
, netid_len
);
1957 p
= xdr_reserve_space(xdr
, 4 + len
);
1958 xdr_encode_opaque(p
, addrbuf
, len
);
1962 ff_layout_encode_nfstime(struct xdr_stream
*xdr
,
1965 struct timespec64 ts
;
1968 p
= xdr_reserve_space(xdr
, 12);
1969 ts
= ktime_to_timespec64(t
);
1970 p
= xdr_encode_hyper(p
, ts
.tv_sec
);
1971 *p
++ = cpu_to_be32(ts
.tv_nsec
);
1975 ff_layout_encode_io_latency(struct xdr_stream
*xdr
,
1976 struct nfs4_ff_io_stat
*stat
)
1980 p
= xdr_reserve_space(xdr
, 5 * 8);
1981 p
= xdr_encode_hyper(p
, stat
->ops_requested
);
1982 p
= xdr_encode_hyper(p
, stat
->bytes_requested
);
1983 p
= xdr_encode_hyper(p
, stat
->ops_completed
);
1984 p
= xdr_encode_hyper(p
, stat
->bytes_completed
);
1985 p
= xdr_encode_hyper(p
, stat
->bytes_not_delivered
);
1986 ff_layout_encode_nfstime(xdr
, stat
->total_busy_time
);
1987 ff_layout_encode_nfstime(xdr
, stat
->aggregate_completion_time
);
1991 ff_layout_encode_layoutstats(struct xdr_stream
*xdr
,
1992 struct nfs42_layoutstat_args
*args
,
1993 struct nfs42_layoutstat_devinfo
*devinfo
)
1995 struct nfs4_ff_layout_mirror
*mirror
= devinfo
->layout_private
;
1996 struct nfs4_pnfs_ds_addr
*da
;
1997 struct nfs4_pnfs_ds
*ds
= mirror
->mirror_ds
->ds
;
1998 struct nfs_fh
*fh
= &mirror
->fh_versions
[0];
2001 da
= list_first_entry(&ds
->ds_addrs
, struct nfs4_pnfs_ds_addr
, da_node
);
2002 dprintk("%s: DS %s: encoding address %s\n",
2003 __func__
, ds
->ds_remotestr
, da
->da_remotestr
);
2004 /* layoutupdate length */
2005 start
= xdr_reserve_space(xdr
, 4);
2007 ff_layout_encode_netaddr(xdr
, da
);
2009 p
= xdr_reserve_space(xdr
, 4 + fh
->size
);
2010 xdr_encode_opaque(p
, fh
->data
, fh
->size
);
2011 /* ff_io_latency4 read */
2012 spin_lock(&mirror
->lock
);
2013 ff_layout_encode_io_latency(xdr
, &mirror
->read_stat
.io_stat
);
2014 /* ff_io_latency4 write */
2015 ff_layout_encode_io_latency(xdr
, &mirror
->write_stat
.io_stat
);
2016 spin_unlock(&mirror
->lock
);
2018 ff_layout_encode_nfstime(xdr
, ktime_sub(ktime_get(), mirror
->start_time
));
2020 p
= xdr_reserve_space(xdr
, 4);
2021 *p
= cpu_to_be32(false);
2023 *start
= cpu_to_be32((xdr
->p
- start
- 1) * 4);
2027 ff_layout_mirror_prepare_stats(struct nfs42_layoutstat_args
*args
,
2028 struct pnfs_layout_hdr
*lo
,
2031 struct nfs4_flexfile_layout
*ff_layout
= FF_LAYOUT_FROM_HDR(lo
);
2032 struct nfs4_ff_layout_mirror
*mirror
;
2033 struct nfs4_deviceid_node
*dev
;
2034 struct nfs42_layoutstat_devinfo
*devinfo
;
2037 list_for_each_entry(mirror
, &ff_layout
->mirrors
, mirrors
) {
2040 if (!mirror
->mirror_ds
)
2042 /* mirror refcount put in cleanup_layoutstats */
2043 if (!atomic_inc_not_zero(&mirror
->ref
))
2045 dev
= &mirror
->mirror_ds
->id_node
;
2046 devinfo
= &args
->devinfo
[i
];
2047 memcpy(&devinfo
->dev_id
, &dev
->deviceid
, NFS4_DEVICEID4_SIZE
);
2048 devinfo
->offset
= 0;
2049 devinfo
->length
= NFS4_MAX_UINT64
;
2050 devinfo
->read_count
= mirror
->read_stat
.io_stat
.ops_completed
;
2051 devinfo
->read_bytes
= mirror
->read_stat
.io_stat
.bytes_completed
;
2052 devinfo
->write_count
= mirror
->write_stat
.io_stat
.ops_completed
;
2053 devinfo
->write_bytes
= mirror
->write_stat
.io_stat
.bytes_completed
;
2054 devinfo
->layout_type
= LAYOUT_FLEX_FILES
;
2055 devinfo
->layoutstats_encode
= ff_layout_encode_layoutstats
;
2056 devinfo
->layout_private
= mirror
;
2064 ff_layout_prepare_layoutstats(struct nfs42_layoutstat_args
*args
)
2066 struct nfs4_flexfile_layout
*ff_layout
;
2067 struct nfs4_ff_layout_mirror
*mirror
;
2070 spin_lock(&args
->inode
->i_lock
);
2071 ff_layout
= FF_LAYOUT_FROM_HDR(NFS_I(args
->inode
)->layout
);
2072 list_for_each_entry(mirror
, &ff_layout
->mirrors
, mirrors
) {
2073 if (atomic_read(&mirror
->ref
) != 0)
2076 spin_unlock(&args
->inode
->i_lock
);
2077 /* For now, send at most PNFS_LAYOUTSTATS_MAXDEV statistics */
2078 if (dev_count
> PNFS_LAYOUTSTATS_MAXDEV
) {
2079 dprintk("%s: truncating devinfo to limit (%d:%d)\n",
2080 __func__
, dev_count
, PNFS_LAYOUTSTATS_MAXDEV
);
2081 dev_count
= PNFS_LAYOUTSTATS_MAXDEV
;
2083 args
->devinfo
= kmalloc_array(dev_count
, sizeof(*args
->devinfo
), GFP_NOIO
);
2087 spin_lock(&args
->inode
->i_lock
);
2088 args
->num_dev
= ff_layout_mirror_prepare_stats(args
,
2089 &ff_layout
->generic_hdr
, dev_count
);
2090 spin_unlock(&args
->inode
->i_lock
);
2096 ff_layout_cleanup_layoutstats(struct nfs42_layoutstat_data
*data
)
2098 struct nfs4_ff_layout_mirror
*mirror
;
2101 for (i
= 0; i
< data
->args
.num_dev
; i
++) {
2102 mirror
= data
->args
.devinfo
[i
].layout_private
;
2103 data
->args
.devinfo
[i
].layout_private
= NULL
;
2104 ff_layout_put_mirror(mirror
);
2108 static struct pnfs_layoutdriver_type flexfilelayout_type
= {
2109 .id
= LAYOUT_FLEX_FILES
,
2110 .name
= "LAYOUT_FLEX_FILES",
2111 .owner
= THIS_MODULE
,
2112 .alloc_layout_hdr
= ff_layout_alloc_layout_hdr
,
2113 .free_layout_hdr
= ff_layout_free_layout_hdr
,
2114 .alloc_lseg
= ff_layout_alloc_lseg
,
2115 .free_lseg
= ff_layout_free_lseg
,
2116 .add_lseg
= ff_layout_add_lseg
,
2117 .pg_read_ops
= &ff_layout_pg_read_ops
,
2118 .pg_write_ops
= &ff_layout_pg_write_ops
,
2119 .get_ds_info
= ff_layout_get_ds_info
,
2120 .free_deviceid_node
= ff_layout_free_deviceid_node
,
2121 .mark_request_commit
= pnfs_layout_mark_request_commit
,
2122 .clear_request_commit
= pnfs_generic_clear_request_commit
,
2123 .scan_commit_lists
= pnfs_generic_scan_commit_lists
,
2124 .recover_commit_reqs
= pnfs_generic_recover_commit_reqs
,
2125 .commit_pagelist
= ff_layout_commit_pagelist
,
2126 .read_pagelist
= ff_layout_read_pagelist
,
2127 .write_pagelist
= ff_layout_write_pagelist
,
2128 .alloc_deviceid_node
= ff_layout_alloc_deviceid_node
,
2129 .encode_layoutreturn
= ff_layout_encode_layoutreturn
,
2130 .sync
= pnfs_nfs_generic_sync
,
2131 .prepare_layoutstats
= ff_layout_prepare_layoutstats
,
2132 .cleanup_layoutstats
= ff_layout_cleanup_layoutstats
,
2135 static int __init
nfs4flexfilelayout_init(void)
2137 printk(KERN_INFO
"%s: NFSv4 Flexfile Layout Driver Registering...\n",
2139 return pnfs_register_layoutdriver(&flexfilelayout_type
);
2142 static void __exit
nfs4flexfilelayout_exit(void)
2144 printk(KERN_INFO
"%s: NFSv4 Flexfile Layout Driver Unregistering...\n",
2146 pnfs_unregister_layoutdriver(&flexfilelayout_type
);
2149 MODULE_ALIAS("nfs-layouttype4-4");
2151 MODULE_LICENSE("GPL");
2152 MODULE_DESCRIPTION("The NFSv4 flexfile layout driver");
2154 module_init(nfs4flexfilelayout_init
);
2155 module_exit(nfs4flexfilelayout_exit
);