Commit 5584c30630f8a4aac557093b1603e166fe7385be

Authored by Trond Myklebust
1 parent bd7bf9d540

NFSv4: Clean up is_atomic_open()

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 1 changed file with 8 additions and 7 deletions Side-by-side Diff

... ... @@ -973,7 +973,7 @@
973 973 * Use intent information to determine whether we need to substitute
974 974 * the NFSv4-style stateful OPEN for the LOOKUP call
975 975 */
976   -static int is_atomic_open(struct inode *dir, struct nameidata *nd)
  976 +static int is_atomic_open(struct nameidata *nd)
977 977 {
978 978 if (nd == NULL || nfs_lookup_check_intent(nd, LOOKUP_OPEN) == 0)
979 979 return 0;
... ... @@ -996,7 +996,7 @@
996 996 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
997 997  
998 998 /* Check that we are indeed trying to open this file */
999   - if (!is_atomic_open(dir, nd))
  999 + if (!is_atomic_open(nd))
1000 1000 goto no_open;
1001 1001  
1002 1002 if (dentry->d_name.len > NFS_SERVER(dir)->namelen) {
1003 1003  
... ... @@ -1047,10 +1047,10 @@
1047 1047 struct inode *dir;
1048 1048 int openflags, ret = 0;
1049 1049  
  1050 + if (!is_atomic_open(nd))
  1051 + goto no_open;
1050 1052 parent = dget_parent(dentry);
1051 1053 dir = parent->d_inode;
1052   - if (!is_atomic_open(dir, nd))
1053   - goto no_open;
1054 1054 /* We can't create new files in nfs_open_revalidate(), so we
1055 1055 * optimize away revalidation of negative dentries.
1056 1056 */
1057 1057  
... ... @@ -1062,11 +1062,11 @@
1062 1062  
1063 1063 /* NFS only supports OPEN on regular files */
1064 1064 if (!S_ISREG(inode->i_mode))
1065   - goto no_open;
  1065 + goto no_open_dput;
1066 1066 openflags = nd->intent.open.flags;
1067 1067 /* We cannot do exclusive creation on a positive dentry */
1068 1068 if ((openflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
1069   - goto no_open;
  1069 + goto no_open_dput;
1070 1070 /* We can't create new files, or truncate existing ones here */
1071 1071 openflags &= ~(O_CREAT|O_TRUNC);
1072 1072  
1073 1073  
... ... @@ -1081,8 +1081,9 @@
1081 1081 if (!ret)
1082 1082 d_drop(dentry);
1083 1083 return ret;
1084   -no_open:
  1084 +no_open_dput:
1085 1085 dput(parent);
  1086 +no_open:
1086 1087 if (inode != NULL && nfs_have_delegation(inode, FMODE_READ))
1087 1088 return 1;
1088 1089 return nfs_lookup_revalidate(dentry, nd);