2 * Copyright (c) 2014 Christoph Hellwig.
4 #include <linux/blkdev.h>
5 #include <linux/kmod.h>
6 #include <linux/file.h>
7 #include <linux/jhash.h>
8 #include <linux/sched.h>
9 #include <linux/sunrpc/addr.h>
15 #define NFSDDBG_FACILITY NFSDDBG_PNFS
18 struct list_head lo_perstate
;
19 struct nfs4_layout_stateid
*lo_state
;
20 struct nfsd4_layout_seg lo_seg
;
23 static struct kmem_cache
*nfs4_layout_cache
;
24 static struct kmem_cache
*nfs4_layout_stateid_cache
;
26 static const struct nfsd4_callback_ops nfsd4_cb_layout_ops
;
27 static const struct lock_manager_operations nfsd4_layouts_lm_ops
;
29 const struct nfsd4_layout_ops
*nfsd4_layout_ops
[LAYOUT_TYPE_MAX
] = {
30 #ifdef CONFIG_NFSD_FLEXFILELAYOUT
31 [LAYOUT_FLEX_FILES
] = &ff_layout_ops
,
33 #ifdef CONFIG_NFSD_BLOCKLAYOUT
34 [LAYOUT_BLOCK_VOLUME
] = &bl_layout_ops
,
36 #ifdef CONFIG_NFSD_SCSILAYOUT
37 [LAYOUT_SCSI
] = &scsi_layout_ops
,
41 /* pNFS device ID to export fsid mapping */
42 #define DEVID_HASH_BITS 8
43 #define DEVID_HASH_SIZE (1 << DEVID_HASH_BITS)
44 #define DEVID_HASH_MASK (DEVID_HASH_SIZE - 1)
45 static u64 nfsd_devid_seq
= 1;
46 static struct list_head nfsd_devid_hash
[DEVID_HASH_SIZE
];
47 static DEFINE_SPINLOCK(nfsd_devid_lock
);
49 static inline u32
devid_hashfn(u64 idx
)
51 return jhash_2words(idx
, idx
>> 32, 0) & DEVID_HASH_MASK
;
55 nfsd4_alloc_devid_map(const struct svc_fh
*fhp
)
57 const struct knfsd_fh
*fh
= &fhp
->fh_handle
;
58 size_t fsid_len
= key_len(fh
->fh_fsid_type
);
59 struct nfsd4_deviceid_map
*map
, *old
;
62 map
= kzalloc(sizeof(*map
) + fsid_len
, GFP_KERNEL
);
66 map
->fsid_type
= fh
->fh_fsid_type
;
67 memcpy(&map
->fsid
, fh
->fh_fsid
, fsid_len
);
69 spin_lock(&nfsd_devid_lock
);
70 if (fhp
->fh_export
->ex_devid_map
)
73 for (i
= 0; i
< DEVID_HASH_SIZE
; i
++) {
74 list_for_each_entry(old
, &nfsd_devid_hash
[i
], hash
) {
75 if (old
->fsid_type
!= fh
->fh_fsid_type
)
77 if (memcmp(old
->fsid
, fh
->fh_fsid
,
78 key_len(old
->fsid_type
)))
81 fhp
->fh_export
->ex_devid_map
= old
;
86 map
->idx
= nfsd_devid_seq
++;
87 list_add_tail_rcu(&map
->hash
, &nfsd_devid_hash
[devid_hashfn(map
->idx
)]);
88 fhp
->fh_export
->ex_devid_map
= map
;
92 spin_unlock(&nfsd_devid_lock
);
96 struct nfsd4_deviceid_map
*
97 nfsd4_find_devid_map(int idx
)
99 struct nfsd4_deviceid_map
*map
, *ret
= NULL
;
102 list_for_each_entry_rcu(map
, &nfsd_devid_hash
[devid_hashfn(idx
)], hash
)
111 nfsd4_set_deviceid(struct nfsd4_deviceid
*id
, const struct svc_fh
*fhp
,
112 u32 device_generation
)
114 if (!fhp
->fh_export
->ex_devid_map
) {
115 nfsd4_alloc_devid_map(fhp
);
116 if (!fhp
->fh_export
->ex_devid_map
)
120 id
->fsid_idx
= fhp
->fh_export
->ex_devid_map
->idx
;
121 id
->generation
= device_generation
;
126 void nfsd4_setup_layout_type(struct svc_export
*exp
)
128 #if defined(CONFIG_NFSD_BLOCKLAYOUT) || defined(CONFIG_NFSD_SCSILAYOUT)
129 struct super_block
*sb
= exp
->ex_path
.mnt
->mnt_sb
;
132 if (!(exp
->ex_flags
& NFSEXP_PNFS
))
136 * If flex file is configured, use it by default. Otherwise
137 * check if the file system supports exporting a block-like layout.
138 * If the block device supports reservations prefer the SCSI layout,
139 * otherwise advertise the block layout.
141 #ifdef CONFIG_NFSD_FLEXFILELAYOUT
142 exp
->ex_layout_types
|= 1 << LAYOUT_FLEX_FILES
;
144 #ifdef CONFIG_NFSD_BLOCKLAYOUT
145 /* overwrite flex file layout selection if needed */
146 if (sb
->s_export_op
->get_uuid
&&
147 sb
->s_export_op
->map_blocks
&&
148 sb
->s_export_op
->commit_blocks
)
149 exp
->ex_layout_types
|= 1 << LAYOUT_BLOCK_VOLUME
;
151 #ifdef CONFIG_NFSD_SCSILAYOUT
152 /* overwrite block layout selection if needed */
153 if (sb
->s_export_op
->map_blocks
&&
154 sb
->s_export_op
->commit_blocks
&&
155 sb
->s_bdev
&& sb
->s_bdev
->bd_disk
->fops
->pr_ops
)
156 exp
->ex_layout_types
|= 1 << LAYOUT_SCSI
;
161 nfsd4_free_layout_stateid(struct nfs4_stid
*stid
)
163 struct nfs4_layout_stateid
*ls
= layoutstateid(stid
);
164 struct nfs4_client
*clp
= ls
->ls_stid
.sc_client
;
165 struct nfs4_file
*fp
= ls
->ls_stid
.sc_file
;
167 trace_layoutstate_free(&ls
->ls_stid
.sc_stateid
);
169 spin_lock(&clp
->cl_lock
);
170 list_del_init(&ls
->ls_perclnt
);
171 spin_unlock(&clp
->cl_lock
);
173 spin_lock(&fp
->fi_lock
);
174 list_del_init(&ls
->ls_perfile
);
175 spin_unlock(&fp
->fi_lock
);
177 if (!nfsd4_layout_ops
[ls
->ls_layout_type
]->disable_recalls
)
178 vfs_setlease(ls
->ls_file
, F_UNLCK
, NULL
, (void **)&ls
);
182 atomic_dec(&ls
->ls_stid
.sc_file
->fi_lo_recalls
);
184 kmem_cache_free(nfs4_layout_stateid_cache
, ls
);
188 nfsd4_layout_setlease(struct nfs4_layout_stateid
*ls
)
190 struct file_lock
*fl
;
193 if (nfsd4_layout_ops
[ls
->ls_layout_type
]->disable_recalls
)
196 fl
= locks_alloc_lock();
200 fl
->fl_lmops
= &nfsd4_layouts_lm_ops
;
201 fl
->fl_flags
= FL_LAYOUT
;
202 fl
->fl_type
= F_RDLCK
;
203 fl
->fl_end
= OFFSET_MAX
;
205 fl
->fl_pid
= current
->tgid
;
206 fl
->fl_file
= ls
->ls_file
;
208 status
= vfs_setlease(fl
->fl_file
, fl
->fl_type
, &fl
, NULL
);
217 static struct nfs4_layout_stateid
*
218 nfsd4_alloc_layout_stateid(struct nfsd4_compound_state
*cstate
,
219 struct nfs4_stid
*parent
, u32 layout_type
)
221 struct nfs4_client
*clp
= cstate
->clp
;
222 struct nfs4_file
*fp
= parent
->sc_file
;
223 struct nfs4_layout_stateid
*ls
;
224 struct nfs4_stid
*stp
;
226 stp
= nfs4_alloc_stid(cstate
->clp
, nfs4_layout_stateid_cache
);
229 stp
->sc_free
= nfsd4_free_layout_stateid
;
233 ls
= layoutstateid(stp
);
234 INIT_LIST_HEAD(&ls
->ls_perclnt
);
235 INIT_LIST_HEAD(&ls
->ls_perfile
);
236 spin_lock_init(&ls
->ls_lock
);
237 INIT_LIST_HEAD(&ls
->ls_layouts
);
238 mutex_init(&ls
->ls_mutex
);
239 ls
->ls_layout_type
= layout_type
;
240 nfsd4_init_cb(&ls
->ls_recall
, clp
, &nfsd4_cb_layout_ops
,
241 NFSPROC4_CLNT_CB_LAYOUT
);
243 if (parent
->sc_type
== NFS4_DELEG_STID
)
244 ls
->ls_file
= get_file(fp
->fi_deleg_file
);
246 ls
->ls_file
= find_any_file(fp
);
247 BUG_ON(!ls
->ls_file
);
249 if (nfsd4_layout_setlease(ls
)) {
252 kmem_cache_free(nfs4_layout_stateid_cache
, ls
);
256 spin_lock(&clp
->cl_lock
);
257 stp
->sc_type
= NFS4_LAYOUT_STID
;
258 list_add(&ls
->ls_perclnt
, &clp
->cl_lo_states
);
259 spin_unlock(&clp
->cl_lock
);
261 spin_lock(&fp
->fi_lock
);
262 list_add(&ls
->ls_perfile
, &fp
->fi_lo_states
);
263 spin_unlock(&fp
->fi_lock
);
265 trace_layoutstate_alloc(&ls
->ls_stid
.sc_stateid
);
270 nfsd4_preprocess_layout_stateid(struct svc_rqst
*rqstp
,
271 struct nfsd4_compound_state
*cstate
, stateid_t
*stateid
,
272 bool create
, u32 layout_type
, struct nfs4_layout_stateid
**lsp
)
274 struct nfs4_layout_stateid
*ls
;
275 struct nfs4_stid
*stid
;
276 unsigned char typemask
= NFS4_LAYOUT_STID
;
280 typemask
|= (NFS4_OPEN_STID
| NFS4_LOCK_STID
| NFS4_DELEG_STID
);
282 status
= nfsd4_lookup_stateid(cstate
, stateid
, typemask
, &stid
,
283 net_generic(SVC_NET(rqstp
), nfsd_net_id
));
287 if (!fh_match(&cstate
->current_fh
.fh_handle
,
288 &stid
->sc_file
->fi_fhandle
)) {
289 status
= nfserr_bad_stateid
;
293 if (stid
->sc_type
!= NFS4_LAYOUT_STID
) {
294 ls
= nfsd4_alloc_layout_stateid(cstate
, stid
, layout_type
);
297 status
= nfserr_jukebox
;
300 mutex_lock(&ls
->ls_mutex
);
302 ls
= container_of(stid
, struct nfs4_layout_stateid
, ls_stid
);
304 status
= nfserr_bad_stateid
;
305 mutex_lock(&ls
->ls_mutex
);
306 if (nfsd4_stateid_generation_after(stateid
, &stid
->sc_stateid
))
307 goto out_unlock_stid
;
308 if (layout_type
!= ls
->ls_layout_type
)
309 goto out_unlock_stid
;
316 mutex_unlock(&ls
->ls_mutex
);
324 nfsd4_recall_file_layout(struct nfs4_layout_stateid
*ls
)
326 spin_lock(&ls
->ls_lock
);
330 ls
->ls_recalled
= true;
331 atomic_inc(&ls
->ls_stid
.sc_file
->fi_lo_recalls
);
332 if (list_empty(&ls
->ls_layouts
))
335 trace_layout_recall(&ls
->ls_stid
.sc_stateid
);
337 atomic_inc(&ls
->ls_stid
.sc_count
);
338 nfsd4_run_cb(&ls
->ls_recall
);
341 spin_unlock(&ls
->ls_lock
);
345 layout_end(struct nfsd4_layout_seg
*seg
)
347 u64 end
= seg
->offset
+ seg
->length
;
348 return end
>= seg
->offset
? end
: NFS4_MAX_UINT64
;
352 layout_update_len(struct nfsd4_layout_seg
*lo
, u64 end
)
354 if (end
== NFS4_MAX_UINT64
)
355 lo
->length
= NFS4_MAX_UINT64
;
357 lo
->length
= end
- lo
->offset
;
361 layouts_overlapping(struct nfs4_layout
*lo
, struct nfsd4_layout_seg
*s
)
363 if (s
->iomode
!= IOMODE_ANY
&& s
->iomode
!= lo
->lo_seg
.iomode
)
365 if (layout_end(&lo
->lo_seg
) <= s
->offset
)
367 if (layout_end(s
) <= lo
->lo_seg
.offset
)
373 layouts_try_merge(struct nfsd4_layout_seg
*lo
, struct nfsd4_layout_seg
*new)
375 if (lo
->iomode
!= new->iomode
)
377 if (layout_end(new) < lo
->offset
)
379 if (layout_end(lo
) < new->offset
)
382 lo
->offset
= min(lo
->offset
, new->offset
);
383 layout_update_len(lo
, max(layout_end(lo
), layout_end(new)));
388 nfsd4_recall_conflict(struct nfs4_layout_stateid
*ls
)
390 struct nfs4_file
*fp
= ls
->ls_stid
.sc_file
;
391 struct nfs4_layout_stateid
*l
, *n
;
392 __be32 nfserr
= nfs_ok
;
394 assert_spin_locked(&fp
->fi_lock
);
396 list_for_each_entry_safe(l
, n
, &fp
->fi_lo_states
, ls_perfile
) {
398 nfsd4_recall_file_layout(l
);
399 nfserr
= nfserr_recallconflict
;
407 nfsd4_insert_layout(struct nfsd4_layoutget
*lgp
, struct nfs4_layout_stateid
*ls
)
409 struct nfsd4_layout_seg
*seg
= &lgp
->lg_seg
;
410 struct nfs4_file
*fp
= ls
->ls_stid
.sc_file
;
411 struct nfs4_layout
*lp
, *new = NULL
;
414 spin_lock(&fp
->fi_lock
);
415 nfserr
= nfsd4_recall_conflict(ls
);
418 spin_lock(&ls
->ls_lock
);
419 list_for_each_entry(lp
, &ls
->ls_layouts
, lo_perstate
) {
420 if (layouts_try_merge(&lp
->lo_seg
, seg
))
423 spin_unlock(&ls
->ls_lock
);
424 spin_unlock(&fp
->fi_lock
);
426 new = kmem_cache_alloc(nfs4_layout_cache
, GFP_KERNEL
);
428 return nfserr_jukebox
;
429 memcpy(&new->lo_seg
, seg
, sizeof(lp
->lo_seg
));
432 spin_lock(&fp
->fi_lock
);
433 nfserr
= nfsd4_recall_conflict(ls
);
436 spin_lock(&ls
->ls_lock
);
437 list_for_each_entry(lp
, &ls
->ls_layouts
, lo_perstate
) {
438 if (layouts_try_merge(&lp
->lo_seg
, seg
))
442 atomic_inc(&ls
->ls_stid
.sc_count
);
443 list_add_tail(&new->lo_perstate
, &ls
->ls_layouts
);
446 nfs4_inc_and_copy_stateid(&lgp
->lg_sid
, &ls
->ls_stid
);
447 spin_unlock(&ls
->ls_lock
);
449 spin_unlock(&fp
->fi_lock
);
451 kmem_cache_free(nfs4_layout_cache
, new);
456 nfsd4_free_layouts(struct list_head
*reaplist
)
458 while (!list_empty(reaplist
)) {
459 struct nfs4_layout
*lp
= list_first_entry(reaplist
,
460 struct nfs4_layout
, lo_perstate
);
462 list_del(&lp
->lo_perstate
);
463 nfs4_put_stid(&lp
->lo_state
->ls_stid
);
464 kmem_cache_free(nfs4_layout_cache
, lp
);
469 nfsd4_return_file_layout(struct nfs4_layout
*lp
, struct nfsd4_layout_seg
*seg
,
470 struct list_head
*reaplist
)
472 struct nfsd4_layout_seg
*lo
= &lp
->lo_seg
;
473 u64 end
= layout_end(lo
);
475 if (seg
->offset
<= lo
->offset
) {
476 if (layout_end(seg
) >= end
) {
477 list_move_tail(&lp
->lo_perstate
, reaplist
);
480 lo
->offset
= layout_end(seg
);
482 /* retain the whole layout segment on a split. */
483 if (layout_end(seg
) < end
) {
484 dprintk("%s: split not supported\n", __func__
);
490 layout_update_len(lo
, end
);
494 nfsd4_return_file_layouts(struct svc_rqst
*rqstp
,
495 struct nfsd4_compound_state
*cstate
,
496 struct nfsd4_layoutreturn
*lrp
)
498 struct nfs4_layout_stateid
*ls
;
499 struct nfs4_layout
*lp
, *n
;
504 nfserr
= nfsd4_preprocess_layout_stateid(rqstp
, cstate
, &lrp
->lr_sid
,
505 false, lrp
->lr_layout_type
,
508 trace_layout_return_lookup_fail(&lrp
->lr_sid
);
512 spin_lock(&ls
->ls_lock
);
513 list_for_each_entry_safe(lp
, n
, &ls
->ls_layouts
, lo_perstate
) {
514 if (layouts_overlapping(lp
, &lrp
->lr_seg
)) {
515 nfsd4_return_file_layout(lp
, &lrp
->lr_seg
, &reaplist
);
519 if (!list_empty(&ls
->ls_layouts
)) {
521 nfs4_inc_and_copy_stateid(&lrp
->lr_sid
, &ls
->ls_stid
);
522 lrp
->lrs_present
= 1;
524 trace_layoutstate_unhash(&ls
->ls_stid
.sc_stateid
);
525 nfs4_unhash_stid(&ls
->ls_stid
);
526 lrp
->lrs_present
= 0;
528 spin_unlock(&ls
->ls_lock
);
530 mutex_unlock(&ls
->ls_mutex
);
531 nfs4_put_stid(&ls
->ls_stid
);
532 nfsd4_free_layouts(&reaplist
);
537 nfsd4_return_client_layouts(struct svc_rqst
*rqstp
,
538 struct nfsd4_compound_state
*cstate
,
539 struct nfsd4_layoutreturn
*lrp
)
541 struct nfs4_layout_stateid
*ls
, *n
;
542 struct nfs4_client
*clp
= cstate
->clp
;
543 struct nfs4_layout
*lp
, *t
;
546 lrp
->lrs_present
= 0;
548 spin_lock(&clp
->cl_lock
);
549 list_for_each_entry_safe(ls
, n
, &clp
->cl_lo_states
, ls_perclnt
) {
550 if (ls
->ls_layout_type
!= lrp
->lr_layout_type
)
553 if (lrp
->lr_return_type
== RETURN_FSID
&&
554 !fh_fsid_match(&ls
->ls_stid
.sc_file
->fi_fhandle
,
555 &cstate
->current_fh
.fh_handle
))
558 spin_lock(&ls
->ls_lock
);
559 list_for_each_entry_safe(lp
, t
, &ls
->ls_layouts
, lo_perstate
) {
560 if (lrp
->lr_seg
.iomode
== IOMODE_ANY
||
561 lrp
->lr_seg
.iomode
== lp
->lo_seg
.iomode
)
562 list_move_tail(&lp
->lo_perstate
, &reaplist
);
564 spin_unlock(&ls
->ls_lock
);
566 spin_unlock(&clp
->cl_lock
);
568 nfsd4_free_layouts(&reaplist
);
573 nfsd4_return_all_layouts(struct nfs4_layout_stateid
*ls
,
574 struct list_head
*reaplist
)
576 spin_lock(&ls
->ls_lock
);
577 list_splice_init(&ls
->ls_layouts
, reaplist
);
578 spin_unlock(&ls
->ls_lock
);
582 nfsd4_return_all_client_layouts(struct nfs4_client
*clp
)
584 struct nfs4_layout_stateid
*ls
, *n
;
587 spin_lock(&clp
->cl_lock
);
588 list_for_each_entry_safe(ls
, n
, &clp
->cl_lo_states
, ls_perclnt
)
589 nfsd4_return_all_layouts(ls
, &reaplist
);
590 spin_unlock(&clp
->cl_lock
);
592 nfsd4_free_layouts(&reaplist
);
596 nfsd4_return_all_file_layouts(struct nfs4_client
*clp
, struct nfs4_file
*fp
)
598 struct nfs4_layout_stateid
*ls
, *n
;
601 spin_lock(&fp
->fi_lock
);
602 list_for_each_entry_safe(ls
, n
, &fp
->fi_lo_states
, ls_perfile
) {
603 if (ls
->ls_stid
.sc_client
== clp
)
604 nfsd4_return_all_layouts(ls
, &reaplist
);
606 spin_unlock(&fp
->fi_lock
);
608 nfsd4_free_layouts(&reaplist
);
612 nfsd4_cb_layout_fail(struct nfs4_layout_stateid
*ls
)
614 struct nfs4_client
*clp
= ls
->ls_stid
.sc_client
;
615 char addr_str
[INET6_ADDRSTRLEN
];
616 static char *envp
[] = {
619 "PATH=/sbin:/usr/sbin:/bin:/usr/bin",
625 rpc_ntop((struct sockaddr
*)&clp
->cl_addr
, addr_str
, sizeof(addr_str
));
628 "nfsd: client %s failed to respond to layout recall. "
629 " Fencing..\n", addr_str
);
631 argv
[0] = "/sbin/nfsd-recall-failed";
633 argv
[2] = ls
->ls_file
->f_path
.mnt
->mnt_sb
->s_id
;
636 error
= call_usermodehelper(argv
[0], argv
, envp
, UMH_WAIT_PROC
);
638 printk(KERN_ERR
"nfsd: fence failed for client %s: %d!\n",
644 nfsd4_cb_layout_prepare(struct nfsd4_callback
*cb
)
646 struct nfs4_layout_stateid
*ls
=
647 container_of(cb
, struct nfs4_layout_stateid
, ls_recall
);
649 mutex_lock(&ls
->ls_mutex
);
650 nfs4_inc_and_copy_stateid(&ls
->ls_recall_sid
, &ls
->ls_stid
);
651 mutex_unlock(&ls
->ls_mutex
);
655 nfsd4_cb_layout_done(struct nfsd4_callback
*cb
, struct rpc_task
*task
)
657 struct nfs4_layout_stateid
*ls
=
658 container_of(cb
, struct nfs4_layout_stateid
, ls_recall
);
661 const struct nfsd4_layout_ops
*ops
;
665 switch (task
->tk_status
) {
669 * Anything left? If not, then call it done. Note that we don't
670 * take the spinlock since this is an optimization and nothing
671 * should get added until the cb counter goes to zero.
673 if (list_empty(&ls
->ls_layouts
))
676 /* Poll the client until it's done with the layout */
678 nn
= net_generic(ls
->ls_stid
.sc_client
->net
, nfsd_net_id
);
680 /* Client gets 2 lease periods to return it */
681 cutoff
= ktime_add_ns(task
->tk_start
,
682 nn
->nfsd4_lease
* NSEC_PER_SEC
* 2);
684 if (ktime_before(now
, cutoff
)) {
685 rpc_delay(task
, HZ
/100); /* 10 mili-seconds */
689 case -NFS4ERR_NOMATCHING_LAYOUT
:
690 trace_layout_recall_done(&ls
->ls_stid
.sc_stateid
);
695 * Unknown error or non-responding client, we'll need to fence.
697 trace_layout_recall_fail(&ls
->ls_stid
.sc_stateid
);
699 ops
= nfsd4_layout_ops
[ls
->ls_layout_type
];
700 if (ops
->fence_client
)
701 ops
->fence_client(ls
);
703 nfsd4_cb_layout_fail(ls
);
709 nfsd4_cb_layout_release(struct nfsd4_callback
*cb
)
711 struct nfs4_layout_stateid
*ls
=
712 container_of(cb
, struct nfs4_layout_stateid
, ls_recall
);
715 trace_layout_recall_release(&ls
->ls_stid
.sc_stateid
);
717 nfsd4_return_all_layouts(ls
, &reaplist
);
718 nfsd4_free_layouts(&reaplist
);
719 nfs4_put_stid(&ls
->ls_stid
);
722 static const struct nfsd4_callback_ops nfsd4_cb_layout_ops
= {
723 .prepare
= nfsd4_cb_layout_prepare
,
724 .done
= nfsd4_cb_layout_done
,
725 .release
= nfsd4_cb_layout_release
,
729 nfsd4_layout_lm_break(struct file_lock
*fl
)
732 * We don't want the locks code to timeout the lease for us;
733 * we'll remove it ourself if a layout isn't returned
736 fl
->fl_break_time
= 0;
737 nfsd4_recall_file_layout(fl
->fl_owner
);
742 nfsd4_layout_lm_change(struct file_lock
*onlist
, int arg
,
743 struct list_head
*dispose
)
745 BUG_ON(!(arg
& F_UNLCK
));
746 return lease_modify(onlist
, arg
, dispose
);
749 static const struct lock_manager_operations nfsd4_layouts_lm_ops
= {
750 .lm_break
= nfsd4_layout_lm_break
,
751 .lm_change
= nfsd4_layout_lm_change
,
755 nfsd4_init_pnfs(void)
759 for (i
= 0; i
< DEVID_HASH_SIZE
; i
++)
760 INIT_LIST_HEAD(&nfsd_devid_hash
[i
]);
762 nfs4_layout_cache
= kmem_cache_create("nfs4_layout",
763 sizeof(struct nfs4_layout
), 0, 0, NULL
);
764 if (!nfs4_layout_cache
)
767 nfs4_layout_stateid_cache
= kmem_cache_create("nfs4_layout_stateid",
768 sizeof(struct nfs4_layout_stateid
), 0, 0, NULL
);
769 if (!nfs4_layout_stateid_cache
) {
770 kmem_cache_destroy(nfs4_layout_cache
);
777 nfsd4_exit_pnfs(void)
781 kmem_cache_destroy(nfs4_layout_cache
);
782 kmem_cache_destroy(nfs4_layout_stateid_cache
);
784 for (i
= 0; i
< DEVID_HASH_SIZE
; i
++) {
785 struct nfsd4_deviceid_map
*map
, *n
;
787 list_for_each_entry_safe(map
, n
, &nfsd_devid_hash
[i
], hash
)