Commit e9dbca8d732e20b8d31a3094a8669c014e7ee262

Authored by Stanislav Kinsbursky
Committed by Trond Myklebust
1 parent da3b462296

NFS: release per-net clients lock before calling PipeFS dentries creation

v3:
1) Lookup for client is performed from the beginning of the list on each PipeFS
event handling operation.

Lockdep is sad otherwise, because inode mutex is taken on PipeFS dentry
creation, which can be called on mount notification, where this per-net client
lock is taken on clients list walk.

Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 1 changed file with 24 additions and 6 deletions Side-by-side Diff

... ... @@ -553,23 +553,41 @@
553 553 return err;
554 554 }
555 555  
556   -static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,
557   - void *ptr)
  556 +static struct nfs_client *nfs_get_client_for_event(struct net *net, int event)
558 557 {
559   - struct super_block *sb = ptr;
560   - struct nfs_net *nn = net_generic(sb->s_fs_info, nfs_net_id);
  558 + struct nfs_net *nn = net_generic(net, nfs_net_id);
  559 + struct dentry *cl_dentry;
561 560 struct nfs_client *clp;
562   - int error = 0;
563 561  
564 562 spin_lock(&nn->nfs_client_lock);
565 563 list_for_each_entry(clp, &nn->nfs_client_list, cl_share_link) {
566 564 if (clp->rpc_ops != &nfs_v4_clientops)
567 565 continue;
  566 + cl_dentry = clp->cl_idmap->idmap_pipe->dentry;
  567 + if (((event == RPC_PIPEFS_MOUNT) && cl_dentry) ||
  568 + ((event == RPC_PIPEFS_UMOUNT) && !cl_dentry))
  569 + continue;
  570 + atomic_inc(&clp->cl_count);
  571 + spin_unlock(&nn->nfs_client_lock);
  572 + return clp;
  573 + }
  574 + spin_unlock(&nn->nfs_client_lock);
  575 + return NULL;
  576 +}
  577 +
  578 +static int rpc_pipefs_event(struct notifier_block *nb, unsigned long event,
  579 + void *ptr)
  580 +{
  581 + struct super_block *sb = ptr;
  582 + struct nfs_client *clp;
  583 + int error = 0;
  584 +
  585 + while ((clp = nfs_get_client_for_event(sb->s_fs_info, event))) {
568 586 error = __rpc_pipefs_event(clp, event, sb);
  587 + nfs_put_client(clp);
569 588 if (error)
570 589 break;
571 590 }
572   - spin_unlock(&nn->nfs_client_lock);
573 591 return error;
574 592 }
575 593