diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-12-23 15:21:54 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2008-12-23 15:21:54 -0500 |
commit | 5584c30630f8a4aac557093b1603e166fe7385be (patch) | |
tree | c19db130a3b69bcc6a68eade044732571857db94 /fs/nfs/dir.c | |
parent | bd7bf9d540c001055fba796ebf146d90e4dd2eb2 (diff) |
NFSv4: Clean up is_atomic_open()
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r-- | fs/nfs/dir.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 3e64b98f3a93..121b533f1f28 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -973,7 +973,7 @@ struct dentry_operations nfs4_dentry_operations = { | |||
973 | * Use intent information to determine whether we need to substitute | 973 | * Use intent information to determine whether we need to substitute |
974 | * the NFSv4-style stateful OPEN for the LOOKUP call | 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 | if (nd == NULL || nfs_lookup_check_intent(nd, LOOKUP_OPEN) == 0) | 978 | if (nd == NULL || nfs_lookup_check_intent(nd, LOOKUP_OPEN) == 0) |
979 | return 0; | 979 | return 0; |
@@ -996,7 +996,7 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry | |||
996 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); | 996 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); |
997 | 997 | ||
998 | /* Check that we are indeed trying to open this file */ | 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 | goto no_open; | 1000 | goto no_open; |
1001 | 1001 | ||
1002 | if (dentry->d_name.len > NFS_SERVER(dir)->namelen) { | 1002 | if (dentry->d_name.len > NFS_SERVER(dir)->namelen) { |
@@ -1047,10 +1047,10 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1047 | struct inode *dir; | 1047 | struct inode *dir; |
1048 | int openflags, ret = 0; | 1048 | int openflags, ret = 0; |
1049 | 1049 | ||
1050 | if (!is_atomic_open(nd)) | ||
1051 | goto no_open; | ||
1050 | parent = dget_parent(dentry); | 1052 | parent = dget_parent(dentry); |
1051 | dir = parent->d_inode; | 1053 | dir = parent->d_inode; |
1052 | if (!is_atomic_open(dir, nd)) | ||
1053 | goto no_open; | ||
1054 | /* We can't create new files in nfs_open_revalidate(), so we | 1054 | /* We can't create new files in nfs_open_revalidate(), so we |
1055 | * optimize away revalidation of negative dentries. | 1055 | * optimize away revalidation of negative dentries. |
1056 | */ | 1056 | */ |
@@ -1062,11 +1062,11 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1062 | 1062 | ||
1063 | /* NFS only supports OPEN on regular files */ | 1063 | /* NFS only supports OPEN on regular files */ |
1064 | if (!S_ISREG(inode->i_mode)) | 1064 | if (!S_ISREG(inode->i_mode)) |
1065 | goto no_open; | 1065 | goto no_open_dput; |
1066 | openflags = nd->intent.open.flags; | 1066 | openflags = nd->intent.open.flags; |
1067 | /* We cannot do exclusive creation on a positive dentry */ | 1067 | /* We cannot do exclusive creation on a positive dentry */ |
1068 | if ((openflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) | 1068 | if ((openflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) |
1069 | goto no_open; | 1069 | goto no_open_dput; |
1070 | /* We can't create new files, or truncate existing ones here */ | 1070 | /* We can't create new files, or truncate existing ones here */ |
1071 | openflags &= ~(O_CREAT|O_TRUNC); | 1071 | openflags &= ~(O_CREAT|O_TRUNC); |
1072 | 1072 | ||
@@ -1081,8 +1081,9 @@ out: | |||
1081 | if (!ret) | 1081 | if (!ret) |
1082 | d_drop(dentry); | 1082 | d_drop(dentry); |
1083 | return ret; | 1083 | return ret; |
1084 | no_open: | 1084 | no_open_dput: |
1085 | dput(parent); | 1085 | dput(parent); |
1086 | no_open: | ||
1086 | if (inode != NULL && nfs_have_delegation(inode, FMODE_READ)) | 1087 | if (inode != NULL && nfs_have_delegation(inode, FMODE_READ)) |
1087 | return 1; | 1088 | return 1; |
1088 | return nfs_lookup_revalidate(dentry, nd); | 1089 | return nfs_lookup_revalidate(dentry, nd); |