| .. | .. |
|---|
| 507 | 507 | return ret; |
|---|
| 508 | 508 | } |
|---|
| 509 | 509 | |
|---|
| 510 | | -static struct nfsd_file *find_deleg_file(struct nfs4_file *f) |
|---|
| 510 | +static struct nfsd_file *find_any_file_locked(struct nfs4_file *f) |
|---|
| 511 | 511 | { |
|---|
| 512 | | - struct nfsd_file *ret = NULL; |
|---|
| 512 | + lockdep_assert_held(&f->fi_lock); |
|---|
| 513 | 513 | |
|---|
| 514 | | - spin_lock(&f->fi_lock); |
|---|
| 514 | + if (f->fi_fds[O_RDWR]) |
|---|
| 515 | + return f->fi_fds[O_RDWR]; |
|---|
| 516 | + if (f->fi_fds[O_WRONLY]) |
|---|
| 517 | + return f->fi_fds[O_WRONLY]; |
|---|
| 518 | + if (f->fi_fds[O_RDONLY]) |
|---|
| 519 | + return f->fi_fds[O_RDONLY]; |
|---|
| 520 | + return NULL; |
|---|
| 521 | +} |
|---|
| 522 | + |
|---|
| 523 | +static struct nfsd_file *find_deleg_file_locked(struct nfs4_file *f) |
|---|
| 524 | +{ |
|---|
| 525 | + lockdep_assert_held(&f->fi_lock); |
|---|
| 526 | + |
|---|
| 515 | 527 | if (f->fi_deleg_file) |
|---|
| 516 | | - ret = nfsd_file_get(f->fi_deleg_file); |
|---|
| 517 | | - spin_unlock(&f->fi_lock); |
|---|
| 518 | | - return ret; |
|---|
| 528 | + return f->fi_deleg_file; |
|---|
| 529 | + return NULL; |
|---|
| 519 | 530 | } |
|---|
| 520 | 531 | |
|---|
| 521 | 532 | static atomic_long_t num_delegations; |
|---|
| .. | .. |
|---|
| 1134 | 1145 | WARN_ON(!list_empty(&dp->dl_recall_lru)); |
|---|
| 1135 | 1146 | |
|---|
| 1136 | 1147 | if (clp->cl_minorversion) { |
|---|
| 1148 | + spin_lock(&clp->cl_lock); |
|---|
| 1137 | 1149 | dp->dl_stid.sc_type = NFS4_REVOKED_DELEG_STID; |
|---|
| 1138 | 1150 | refcount_inc(&dp->dl_stid.sc_count); |
|---|
| 1139 | | - spin_lock(&clp->cl_lock); |
|---|
| 1140 | 1151 | list_add(&dp->dl_recall_lru, &clp->cl_revoked); |
|---|
| 1141 | 1152 | spin_unlock(&clp->cl_lock); |
|---|
| 1142 | 1153 | } |
|---|
| .. | .. |
|---|
| 2462 | 2473 | ols = openlockstateid(st); |
|---|
| 2463 | 2474 | oo = ols->st_stateowner; |
|---|
| 2464 | 2475 | nf = st->sc_file; |
|---|
| 2465 | | - file = find_any_file(nf); |
|---|
| 2476 | + |
|---|
| 2477 | + spin_lock(&nf->fi_lock); |
|---|
| 2478 | + file = find_any_file_locked(nf); |
|---|
| 2466 | 2479 | if (!file) |
|---|
| 2467 | | - return 0; |
|---|
| 2480 | + goto out; |
|---|
| 2468 | 2481 | |
|---|
| 2469 | 2482 | seq_printf(s, "- "); |
|---|
| 2470 | 2483 | nfs4_show_stateid(s, &st->sc_stateid); |
|---|
| .. | .. |
|---|
| 2486 | 2499 | seq_printf(s, ", "); |
|---|
| 2487 | 2500 | nfs4_show_owner(s, oo); |
|---|
| 2488 | 2501 | seq_printf(s, " }\n"); |
|---|
| 2489 | | - nfsd_file_put(file); |
|---|
| 2490 | | - |
|---|
| 2502 | +out: |
|---|
| 2503 | + spin_unlock(&nf->fi_lock); |
|---|
| 2491 | 2504 | return 0; |
|---|
| 2492 | 2505 | } |
|---|
| 2493 | 2506 | |
|---|
| .. | .. |
|---|
| 2501 | 2514 | ols = openlockstateid(st); |
|---|
| 2502 | 2515 | oo = ols->st_stateowner; |
|---|
| 2503 | 2516 | nf = st->sc_file; |
|---|
| 2504 | | - file = find_any_file(nf); |
|---|
| 2517 | + spin_lock(&nf->fi_lock); |
|---|
| 2518 | + file = find_any_file_locked(nf); |
|---|
| 2505 | 2519 | if (!file) |
|---|
| 2506 | | - return 0; |
|---|
| 2520 | + goto out; |
|---|
| 2507 | 2521 | |
|---|
| 2508 | 2522 | seq_printf(s, "- "); |
|---|
| 2509 | 2523 | nfs4_show_stateid(s, &st->sc_stateid); |
|---|
| .. | .. |
|---|
| 2523 | 2537 | seq_printf(s, ", "); |
|---|
| 2524 | 2538 | nfs4_show_owner(s, oo); |
|---|
| 2525 | 2539 | seq_printf(s, " }\n"); |
|---|
| 2526 | | - nfsd_file_put(file); |
|---|
| 2527 | | - |
|---|
| 2540 | +out: |
|---|
| 2541 | + spin_unlock(&nf->fi_lock); |
|---|
| 2528 | 2542 | return 0; |
|---|
| 2529 | 2543 | } |
|---|
| 2530 | 2544 | |
|---|
| .. | .. |
|---|
| 2536 | 2550 | |
|---|
| 2537 | 2551 | ds = delegstateid(st); |
|---|
| 2538 | 2552 | nf = st->sc_file; |
|---|
| 2539 | | - file = find_deleg_file(nf); |
|---|
| 2553 | + spin_lock(&nf->fi_lock); |
|---|
| 2554 | + file = find_deleg_file_locked(nf); |
|---|
| 2540 | 2555 | if (!file) |
|---|
| 2541 | | - return 0; |
|---|
| 2556 | + goto out; |
|---|
| 2542 | 2557 | |
|---|
| 2543 | 2558 | seq_printf(s, "- "); |
|---|
| 2544 | 2559 | nfs4_show_stateid(s, &st->sc_stateid); |
|---|
| .. | .. |
|---|
| 2554 | 2569 | seq_printf(s, ", "); |
|---|
| 2555 | 2570 | nfs4_show_fname(s, file); |
|---|
| 2556 | 2571 | seq_printf(s, " }\n"); |
|---|
| 2557 | | - nfsd_file_put(file); |
|---|
| 2558 | | - |
|---|
| 2572 | +out: |
|---|
| 2573 | + spin_unlock(&nf->fi_lock); |
|---|
| 2559 | 2574 | return 0; |
|---|
| 2560 | 2575 | } |
|---|
| 2561 | 2576 | |
|---|
| .. | .. |
|---|
| 5641 | 5656 | if (ZERO_STATEID(stateid) || ONE_STATEID(stateid) || |
|---|
| 5642 | 5657 | CLOSE_STATEID(stateid)) |
|---|
| 5643 | 5658 | return status; |
|---|
| 5644 | | - if (!same_clid(&stateid->si_opaque.so_clid, &cl->cl_clientid)) |
|---|
| 5645 | | - return status; |
|---|
| 5646 | 5659 | spin_lock(&cl->cl_lock); |
|---|
| 5647 | 5660 | s = find_stateid_locked(cl, stateid); |
|---|
| 5648 | 5661 | if (!s) |
|---|
| .. | .. |
|---|
| 7379 | 7392 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); |
|---|
| 7380 | 7393 | int ret; |
|---|
| 7381 | 7394 | |
|---|
| 7382 | | - ret = get_nfsdfs(net); |
|---|
| 7395 | + ret = nfs4_state_create_net(net); |
|---|
| 7383 | 7396 | if (ret) |
|---|
| 7384 | 7397 | return ret; |
|---|
| 7385 | | - ret = nfs4_state_create_net(net); |
|---|
| 7386 | | - if (ret) { |
|---|
| 7387 | | - mntput(nn->nfsd_mnt); |
|---|
| 7388 | | - return ret; |
|---|
| 7389 | | - } |
|---|
| 7390 | 7398 | locks_start_grace(net, &nn->nfsd4_manager); |
|---|
| 7391 | 7399 | nfsd4_client_tracking_init(net); |
|---|
| 7392 | 7400 | if (nn->track_reclaim_completes && nn->reclaim_str_hashtbl_size == 0) |
|---|
| .. | .. |
|---|
| 7456 | 7464 | |
|---|
| 7457 | 7465 | nfsd4_client_tracking_exit(net); |
|---|
| 7458 | 7466 | nfs4_state_destroy_net(net); |
|---|
| 7459 | | - mntput(nn->nfsd_mnt); |
|---|
| 7460 | 7467 | } |
|---|
| 7461 | 7468 | |
|---|
| 7462 | 7469 | void |
|---|