@@ -650,6 +650,16 @@ static const struct cred *ovl_setup_cred_for_create(struct dentry *dentry,
650650 return override_cred ;
651651}
652652
653+ static int ovl_create_handle_whiteouts (struct dentry * dentry ,
654+ struct inode * inode ,
655+ struct ovl_cattr * attr )
656+ {
657+ if (!ovl_dentry_is_whiteout (dentry ))
658+ return ovl_create_upper (dentry , inode , attr );
659+
660+ return ovl_create_over_whiteout (dentry , inode , attr );
661+ }
662+
653663static int ovl_create_or_link (struct dentry * dentry , struct inode * inode ,
654664 struct ovl_cattr * attr , bool origin )
655665{
@@ -668,29 +678,28 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
668678 return err ;
669679 }
670680
671- if (!attr -> hardlink ) {
672- /*
673- * In the creation cases(create, mkdir, mknod, symlink),
674- * ovl should transfer current's fs{u,g}id to underlying
675- * fs. Because underlying fs want to initialize its new
676- * inode owner using current's fs{u,g}id. And in this
677- * case, the @inode is a new inode that is initialized
678- * in inode_init_owner() to current's fs{u,g}id. So use
679- * the inode's i_{u,g}id to override the cred's fs{u,g}id.
680- *
681- * But in the other hardlink case, ovl_link() does not
682- * create a new inode, so just use the ovl mounter's
683- * fs{u,g}id.
684- */
685- new_cred = ovl_setup_cred_for_create (dentry , inode , attr -> mode , old_cred );
686- if (IS_ERR (new_cred ))
687- return PTR_ERR (new_cred );
688- }
681+ /*
682+ * In the creation cases(create, mkdir, mknod, symlink),
683+ * ovl should transfer current's fs{u,g}id to underlying
684+ * fs. Because underlying fs want to initialize its new
685+ * inode owner using current's fs{u,g}id. And in this
686+ * case, the @inode is a new inode that is initialized
687+ * in inode_init_owner() to current's fs{u,g}id. So use
688+ * the inode's i_{u,g}id to override the cred's fs{u,g}id.
689+ *
690+ * But in the other hardlink case, ovl_link() does not
691+ * create a new inode, so just use the ovl mounter's
692+ * fs{u,g}id.
693+ */
694+
695+ if (attr -> hardlink )
696+ return ovl_create_handle_whiteouts (dentry , inode , attr );
689697
690- if (!ovl_dentry_is_whiteout (dentry ))
691- return ovl_create_upper (dentry , inode , attr );
698+ new_cred = ovl_setup_cred_for_create (dentry , inode , attr -> mode , old_cred );
699+ if (IS_ERR (new_cred ))
700+ return PTR_ERR (new_cred );
692701
693- return ovl_create_over_whiteout (dentry , inode , attr );
702+ return ovl_create_handle_whiteouts (dentry , inode , attr );
694703 }
695704 return err ;
696705}
0 commit comments