Lines Matching refs:ls
158 struct nfs4_layout_stateid *ls = layoutstateid(stid); in nfsd4_free_layout_stateid() local
159 struct nfs4_client *clp = ls->ls_stid.sc_client; in nfsd4_free_layout_stateid()
160 struct nfs4_file *fp = ls->ls_stid.sc_file; in nfsd4_free_layout_stateid()
162 trace_nfsd_layoutstate_free(&ls->ls_stid.sc_stateid); in nfsd4_free_layout_stateid()
165 list_del_init(&ls->ls_perclnt); in nfsd4_free_layout_stateid()
169 list_del_init(&ls->ls_perfile); in nfsd4_free_layout_stateid()
172 if (!nfsd4_layout_ops[ls->ls_layout_type]->disable_recalls) in nfsd4_free_layout_stateid()
173 vfs_setlease(ls->ls_file->nf_file, F_UNLCK, NULL, (void **)&ls); in nfsd4_free_layout_stateid()
174 nfsd_file_put(ls->ls_file); in nfsd4_free_layout_stateid()
176 if (ls->ls_recalled) in nfsd4_free_layout_stateid()
177 atomic_dec(&ls->ls_stid.sc_file->fi_lo_recalls); in nfsd4_free_layout_stateid()
179 kmem_cache_free(nfs4_layout_stateid_cache, ls); in nfsd4_free_layout_stateid()
183 nfsd4_layout_setlease(struct nfs4_layout_stateid *ls) in nfsd4_layout_setlease() argument
188 if (nfsd4_layout_ops[ls->ls_layout_type]->disable_recalls) in nfsd4_layout_setlease()
199 fl->fl_owner = ls; in nfsd4_layout_setlease()
201 fl->fl_file = ls->ls_file->nf_file; in nfsd4_layout_setlease()
218 struct nfs4_layout_stateid *ls; in nfsd4_alloc_layout_stateid() local
229 ls = layoutstateid(stp); in nfsd4_alloc_layout_stateid()
230 INIT_LIST_HEAD(&ls->ls_perclnt); in nfsd4_alloc_layout_stateid()
231 INIT_LIST_HEAD(&ls->ls_perfile); in nfsd4_alloc_layout_stateid()
232 spin_lock_init(&ls->ls_lock); in nfsd4_alloc_layout_stateid()
233 INIT_LIST_HEAD(&ls->ls_layouts); in nfsd4_alloc_layout_stateid()
234 mutex_init(&ls->ls_mutex); in nfsd4_alloc_layout_stateid()
235 ls->ls_layout_type = layout_type; in nfsd4_alloc_layout_stateid()
236 nfsd4_init_cb(&ls->ls_recall, clp, &nfsd4_cb_layout_ops, in nfsd4_alloc_layout_stateid()
240 ls->ls_file = nfsd_file_get(fp->fi_deleg_file); in nfsd4_alloc_layout_stateid()
242 ls->ls_file = find_any_file(fp); in nfsd4_alloc_layout_stateid()
243 BUG_ON(!ls->ls_file); in nfsd4_alloc_layout_stateid()
245 if (nfsd4_layout_setlease(ls)) { in nfsd4_alloc_layout_stateid()
246 nfsd_file_put(ls->ls_file); in nfsd4_alloc_layout_stateid()
248 kmem_cache_free(nfs4_layout_stateid_cache, ls); in nfsd4_alloc_layout_stateid()
254 list_add(&ls->ls_perclnt, &clp->cl_lo_states); in nfsd4_alloc_layout_stateid()
258 list_add(&ls->ls_perfile, &fp->fi_lo_states); in nfsd4_alloc_layout_stateid()
261 trace_nfsd_layoutstate_alloc(&ls->ls_stid.sc_stateid); in nfsd4_alloc_layout_stateid()
262 return ls; in nfsd4_alloc_layout_stateid()
270 struct nfs4_layout_stateid *ls; in nfsd4_preprocess_layout_stateid() local
290 ls = nfsd4_alloc_layout_stateid(cstate, stid, layout_type); in nfsd4_preprocess_layout_stateid()
294 if (!ls) in nfsd4_preprocess_layout_stateid()
296 mutex_lock(&ls->ls_mutex); in nfsd4_preprocess_layout_stateid()
298 ls = container_of(stid, struct nfs4_layout_stateid, ls_stid); in nfsd4_preprocess_layout_stateid()
301 mutex_lock(&ls->ls_mutex); in nfsd4_preprocess_layout_stateid()
304 if (layout_type != ls->ls_layout_type) in nfsd4_preprocess_layout_stateid()
308 *lsp = ls; in nfsd4_preprocess_layout_stateid()
312 mutex_unlock(&ls->ls_mutex); in nfsd4_preprocess_layout_stateid()
320 nfsd4_recall_file_layout(struct nfs4_layout_stateid *ls) in nfsd4_recall_file_layout() argument
322 spin_lock(&ls->ls_lock); in nfsd4_recall_file_layout()
323 if (ls->ls_recalled) in nfsd4_recall_file_layout()
326 ls->ls_recalled = true; in nfsd4_recall_file_layout()
327 atomic_inc(&ls->ls_stid.sc_file->fi_lo_recalls); in nfsd4_recall_file_layout()
328 if (list_empty(&ls->ls_layouts)) in nfsd4_recall_file_layout()
331 trace_nfsd_layout_recall(&ls->ls_stid.sc_stateid); in nfsd4_recall_file_layout()
333 refcount_inc(&ls->ls_stid.sc_count); in nfsd4_recall_file_layout()
334 nfsd4_run_cb(&ls->ls_recall); in nfsd4_recall_file_layout()
337 spin_unlock(&ls->ls_lock); in nfsd4_recall_file_layout()
384 nfsd4_recall_conflict(struct nfs4_layout_stateid *ls) in nfsd4_recall_conflict() argument
386 struct nfs4_file *fp = ls->ls_stid.sc_file; in nfsd4_recall_conflict()
393 if (l != ls) { in nfsd4_recall_conflict()
403 nfsd4_insert_layout(struct nfsd4_layoutget *lgp, struct nfs4_layout_stateid *ls) in nfsd4_insert_layout() argument
406 struct nfs4_file *fp = ls->ls_stid.sc_file; in nfsd4_insert_layout()
411 nfserr = nfsd4_recall_conflict(ls); in nfsd4_insert_layout()
414 spin_lock(&ls->ls_lock); in nfsd4_insert_layout()
415 list_for_each_entry(lp, &ls->ls_layouts, lo_perstate) { in nfsd4_insert_layout()
419 spin_unlock(&ls->ls_lock); in nfsd4_insert_layout()
426 new->lo_state = ls; in nfsd4_insert_layout()
429 nfserr = nfsd4_recall_conflict(ls); in nfsd4_insert_layout()
432 spin_lock(&ls->ls_lock); in nfsd4_insert_layout()
433 list_for_each_entry(lp, &ls->ls_layouts, lo_perstate) { in nfsd4_insert_layout()
438 refcount_inc(&ls->ls_stid.sc_count); in nfsd4_insert_layout()
439 list_add_tail(&new->lo_perstate, &ls->ls_layouts); in nfsd4_insert_layout()
442 nfs4_inc_and_copy_stateid(&lgp->lg_sid, &ls->ls_stid); in nfsd4_insert_layout()
443 spin_unlock(&ls->ls_lock); in nfsd4_insert_layout()
494 struct nfs4_layout_stateid *ls; in nfsd4_return_file_layouts() local
502 &ls); in nfsd4_return_file_layouts()
508 spin_lock(&ls->ls_lock); in nfsd4_return_file_layouts()
509 list_for_each_entry_safe(lp, n, &ls->ls_layouts, lo_perstate) { in nfsd4_return_file_layouts()
515 if (!list_empty(&ls->ls_layouts)) { in nfsd4_return_file_layouts()
517 nfs4_inc_and_copy_stateid(&lrp->lr_sid, &ls->ls_stid); in nfsd4_return_file_layouts()
520 trace_nfsd_layoutstate_unhash(&ls->ls_stid.sc_stateid); in nfsd4_return_file_layouts()
521 nfs4_unhash_stid(&ls->ls_stid); in nfsd4_return_file_layouts()
524 spin_unlock(&ls->ls_lock); in nfsd4_return_file_layouts()
526 mutex_unlock(&ls->ls_mutex); in nfsd4_return_file_layouts()
527 nfs4_put_stid(&ls->ls_stid); in nfsd4_return_file_layouts()
537 struct nfs4_layout_stateid *ls, *n; in nfsd4_return_client_layouts() local
545 list_for_each_entry_safe(ls, n, &clp->cl_lo_states, ls_perclnt) { in nfsd4_return_client_layouts()
546 if (ls->ls_layout_type != lrp->lr_layout_type) in nfsd4_return_client_layouts()
550 !fh_fsid_match(&ls->ls_stid.sc_file->fi_fhandle, in nfsd4_return_client_layouts()
554 spin_lock(&ls->ls_lock); in nfsd4_return_client_layouts()
555 list_for_each_entry_safe(lp, t, &ls->ls_layouts, lo_perstate) { in nfsd4_return_client_layouts()
560 spin_unlock(&ls->ls_lock); in nfsd4_return_client_layouts()
569 nfsd4_return_all_layouts(struct nfs4_layout_stateid *ls, in nfsd4_return_all_layouts() argument
572 spin_lock(&ls->ls_lock); in nfsd4_return_all_layouts()
573 list_splice_init(&ls->ls_layouts, reaplist); in nfsd4_return_all_layouts()
574 spin_unlock(&ls->ls_lock); in nfsd4_return_all_layouts()
580 struct nfs4_layout_stateid *ls, *n; in nfsd4_return_all_client_layouts() local
584 list_for_each_entry_safe(ls, n, &clp->cl_lo_states, ls_perclnt) in nfsd4_return_all_client_layouts()
585 nfsd4_return_all_layouts(ls, &reaplist); in nfsd4_return_all_client_layouts()
594 struct nfs4_layout_stateid *ls, *n; in nfsd4_return_all_file_layouts() local
598 list_for_each_entry_safe(ls, n, &fp->fi_lo_states, ls_perfile) { in nfsd4_return_all_file_layouts()
599 if (ls->ls_stid.sc_client == clp) in nfsd4_return_all_file_layouts()
600 nfsd4_return_all_layouts(ls, &reaplist); in nfsd4_return_all_file_layouts()
608 nfsd4_cb_layout_fail(struct nfs4_layout_stateid *ls) in nfsd4_cb_layout_fail() argument
610 struct nfs4_client *clp = ls->ls_stid.sc_client; in nfsd4_cb_layout_fail()
630 argv[2] = ls->ls_file->nf_file->f_path.mnt->mnt_sb->s_id; in nfsd4_cb_layout_fail()
644 struct nfs4_layout_stateid *ls = in nfsd4_cb_layout_prepare() local
647 mutex_lock(&ls->ls_mutex); in nfsd4_cb_layout_prepare()
648 nfs4_inc_and_copy_stateid(&ls->ls_recall_sid, &ls->ls_stid); in nfsd4_cb_layout_prepare()
649 mutex_unlock(&ls->ls_mutex); in nfsd4_cb_layout_prepare()
655 struct nfs4_layout_stateid *ls = in nfsd4_cb_layout_done() local
670 if (list_empty(&ls->ls_layouts)) in nfsd4_cb_layout_done()
675 nn = net_generic(ls->ls_stid.sc_client->net, nfsd_net_id); in nfsd4_cb_layout_done()
690 trace_nfsd_layout_recall_fail(&ls->ls_stid.sc_stateid); in nfsd4_cb_layout_done()
692 ops = nfsd4_layout_ops[ls->ls_layout_type]; in nfsd4_cb_layout_done()
694 ops->fence_client(ls); in nfsd4_cb_layout_done()
696 nfsd4_cb_layout_fail(ls); in nfsd4_cb_layout_done()
699 trace_nfsd_layout_recall_done(&ls->ls_stid.sc_stateid); in nfsd4_cb_layout_done()
708 struct nfs4_layout_stateid *ls = in nfsd4_cb_layout_release() local
712 trace_nfsd_layout_recall_release(&ls->ls_stid.sc_stateid); in nfsd4_cb_layout_release()
714 nfsd4_return_all_layouts(ls, &reaplist); in nfsd4_cb_layout_release()
716 nfs4_put_stid(&ls->ls_stid); in nfsd4_cb_layout_release()