@@ -594,22 +594,6 @@ static int __rpc_mkpipe_dentry(struct inode *dir, struct dentry *dentry,
594594 return 0 ;
595595}
596596
597- static struct dentry * __rpc_lookup_create_exclusive (struct dentry * parent ,
598- const char * name )
599- {
600- struct qstr q = QSTR (name );
601- struct dentry * dentry = try_lookup_noperm (& q , parent );
602- if (!dentry ) {
603- dentry = d_alloc (parent , & q );
604- if (!dentry )
605- return ERR_PTR (- ENOMEM );
606- }
607- if (d_really_is_negative (dentry ))
608- return dentry ;
609- dput (dentry );
610- return ERR_PTR (- EEXIST );
611- }
612-
613597static int rpc_populate (struct dentry * parent ,
614598 const struct rpc_filelist * files ,
615599 int start , int eof ,
@@ -619,9 +603,8 @@ static int rpc_populate(struct dentry *parent,
619603 struct dentry * dentry ;
620604 int i , err ;
621605
622- inode_lock (dir );
623606 for (i = start ; i < eof ; i ++ ) {
624- dentry = __rpc_lookup_create_exclusive (parent , files [i ].name );
607+ dentry = simple_start_creating (parent , files [i ].name );
625608 err = PTR_ERR (dentry );
626609 if (IS_ERR (dentry ))
627610 goto out_bad ;
@@ -633,20 +616,20 @@ static int rpc_populate(struct dentry *parent,
633616 files [i ].mode ,
634617 files [i ].i_fop ,
635618 private );
619+ inode_unlock (dir );
636620 break ;
637621 case S_IFDIR :
638622 err = __rpc_mkdir (dir , dentry ,
639623 files [i ].mode ,
640624 NULL ,
641625 private );
626+ inode_unlock (dir );
642627 }
643628 if (err != 0 )
644629 goto out_bad ;
645630 }
646- inode_unlock (dir );
647631 return 0 ;
648632out_bad :
649- inode_unlock (dir );
650633 printk (KERN_WARNING "%s: %s failed to populate directory %pd\n" ,
651634 __FILE__ , __func__ , parent );
652635 return err ;
@@ -660,27 +643,21 @@ static struct dentry *rpc_mkdir_populate(struct dentry *parent,
660643 struct inode * dir = d_inode (parent );
661644 int error ;
662645
663- inode_lock_nested (dir , I_MUTEX_PARENT );
664- dentry = __rpc_lookup_create_exclusive (parent , name );
646+ dentry = simple_start_creating (parent , name );
665647 if (IS_ERR (dentry ))
666- goto out ;
648+ return dentry ;
667649 error = __rpc_mkdir (dir , dentry , mode , NULL , private );
650+ inode_unlock (dir );
668651 if (error != 0 )
669- goto out_err ;
652+ return ERR_PTR ( error ) ;
670653 if (populate != NULL ) {
671654 error = populate (dentry , args_populate );
672655 if (error ) {
673- inode_unlock (dir );
674656 simple_recursive_removal (dentry , NULL );
675657 return ERR_PTR (error );
676658 }
677659 }
678- out :
679- inode_unlock (dir );
680660 return dentry ;
681- out_err :
682- dentry = ERR_PTR (error );
683- goto out ;
684661}
685662
686663/**
@@ -715,12 +692,9 @@ int rpc_mkpipe_dentry(struct dentry *parent, const char *name,
715692 if (pipe -> ops -> downcall == NULL )
716693 umode &= ~0222 ;
717694
718- inode_lock_nested (dir , I_MUTEX_PARENT );
719- dentry = __rpc_lookup_create_exclusive (parent , name );
720- if (IS_ERR (dentry )) {
721- inode_unlock (dir );
695+ dentry = simple_start_creating (parent , name );
696+ if (IS_ERR (dentry ))
722697 return PTR_ERR (dentry );
723- }
724698 err = __rpc_mkpipe_dentry (dir , dentry , umode , & rpc_pipe_fops ,
725699 private , pipe );
726700 if (unlikely (err ))
0 commit comments