aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-06-10 15:36:40 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-07-14 08:34:07 -0400
commitfa3c56bbda6c2ac2a57d96ba501dbe85cccd312b (patch)
tree8cda2d282bf386e88cd9e05967d1624034332a75 /fs
parentfacc3530fb5c89a40bc83045422add392b8db4a1 (diff)
fs/nfs/dir.c: switch to passing nd->flags instead of nd wherever possible
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/dir.c51
1 files changed, 19 insertions, 32 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index ad5aef4995aa..71a199435ca9 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1031,27 +1031,14 @@ static int nfs_check_verifier(struct inode *dir, struct dentry *dentry)
1031} 1031}
1032 1032
1033/* 1033/*
1034 * Return the intent data that applies to this particular path component
1035 *
1036 * Note that the current set of intents only apply to the very last
1037 * component of the path and none of them is set before that last
1038 * component.
1039 */
1040static inline unsigned int nfs_lookup_check_intent(unsigned int flags,
1041 unsigned int mask)
1042{
1043 return flags & mask;
1044}
1045
1046/*
1047 * Use intent information to check whether or not we're going to do 1034 * Use intent information to check whether or not we're going to do
1048 * an O_EXCL create using this path component. 1035 * an O_EXCL create using this path component.
1049 */ 1036 */
1050static int nfs_is_exclusive_create(struct inode *dir, struct nameidata *nd) 1037static int nfs_is_exclusive_create(struct inode *dir, unsigned int flags)
1051{ 1038{
1052 if (NFS_PROTO(dir)->version == 2) 1039 if (NFS_PROTO(dir)->version == 2)
1053 return 0; 1040 return 0;
1054 return nd && nfs_lookup_check_intent(nd->flags, LOOKUP_EXCL); 1041 return flags & LOOKUP_EXCL;
1055} 1042}
1056 1043
1057/* 1044/*
@@ -1063,20 +1050,18 @@ static int nfs_is_exclusive_create(struct inode *dir, struct nameidata *nd)
1063 * 1050 *
1064 */ 1051 */
1065static inline 1052static inline
1066int nfs_lookup_verify_inode(struct inode *inode, struct nameidata *nd) 1053int nfs_lookup_verify_inode(struct inode *inode, unsigned int flags)
1067{ 1054{
1068 struct nfs_server *server = NFS_SERVER(inode); 1055 struct nfs_server *server = NFS_SERVER(inode);
1069 1056
1070 if (IS_AUTOMOUNT(inode)) 1057 if (IS_AUTOMOUNT(inode))
1071 return 0; 1058 return 0;
1072 /* VFS wants an on-the-wire revalidation */ 1059 /* VFS wants an on-the-wire revalidation */
1073 if (nd->flags & LOOKUP_REVAL) 1060 if (flags & LOOKUP_REVAL)
1074 goto out_force; 1061 goto out_force;
1075 /* This is an open(2) */ 1062 /* This is an open(2) */
1076 if (nfs_lookup_check_intent(nd->flags, LOOKUP_OPEN) != 0 && 1063 if ((flags & LOOKUP_OPEN) && !(server->flags & NFS_MOUNT_NOCTO) &&
1077 !(server->flags & NFS_MOUNT_NOCTO) && 1064 (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
1078 (S_ISREG(inode->i_mode) ||
1079 S_ISDIR(inode->i_mode)))
1080 goto out_force; 1065 goto out_force;
1081 return 0; 1066 return 0;
1082out_force: 1067out_force:
@@ -1092,10 +1077,10 @@ out_force:
1092 */ 1077 */
1093static inline 1078static inline
1094int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry, 1079int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry,
1095 struct nameidata *nd) 1080 unsigned int flags)
1096{ 1081{
1097 /* Don't revalidate a negative dentry if we're creating a new file */ 1082 /* Don't revalidate a negative dentry if we're creating a new file */
1098 if (nd != NULL && nfs_lookup_check_intent(nd->flags, LOOKUP_CREATE) != 0) 1083 if (flags & LOOKUP_CREATE)
1099 return 0; 1084 return 0;
1100 if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG) 1085 if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG)
1101 return 1; 1086 return 1;
@@ -1115,6 +1100,7 @@ int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry,
1115 */ 1100 */
1116static int nfs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd) 1101static int nfs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd)
1117{ 1102{
1103 unsigned int flags = nd->flags;
1118 struct inode *dir; 1104 struct inode *dir;
1119 struct inode *inode; 1105 struct inode *inode;
1120 struct dentry *parent; 1106 struct dentry *parent;
@@ -1122,7 +1108,7 @@ static int nfs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd)
1122 struct nfs_fattr *fattr = NULL; 1108 struct nfs_fattr *fattr = NULL;
1123 int error; 1109 int error;
1124 1110
1125 if (nd->flags & LOOKUP_RCU) 1111 if (flags & LOOKUP_RCU)
1126 return -ECHILD; 1112 return -ECHILD;
1127 1113
1128 parent = dget_parent(dentry); 1114 parent = dget_parent(dentry);
@@ -1131,7 +1117,7 @@ static int nfs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd)
1131 inode = dentry->d_inode; 1117 inode = dentry->d_inode;
1132 1118
1133 if (!inode) { 1119 if (!inode) {
1134 if (nfs_neg_need_reval(dir, dentry, nd)) 1120 if (nfs_neg_need_reval(dir, dentry, flags))
1135 goto out_bad; 1121 goto out_bad;
1136 goto out_valid_noent; 1122 goto out_valid_noent;
1137 } 1123 }
@@ -1147,8 +1133,8 @@ static int nfs_lookup_revalidate(struct dentry *dentry, struct nameidata *nd)
1147 goto out_set_verifier; 1133 goto out_set_verifier;
1148 1134
1149 /* Force a full look up iff the parent directory has changed */ 1135 /* Force a full look up iff the parent directory has changed */
1150 if (!nfs_is_exclusive_create(dir, nd) && nfs_check_verifier(dir, dentry)) { 1136 if (!nfs_is_exclusive_create(dir, flags) && nfs_check_verifier(dir, dentry)) {
1151 if (nfs_lookup_verify_inode(inode, nd)) 1137 if (nfs_lookup_verify_inode(inode, flags))
1152 goto out_zap_parent; 1138 goto out_zap_parent;
1153 goto out_valid; 1139 goto out_valid;
1154 } 1140 }
@@ -1306,7 +1292,7 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
1306 * If we're doing an exclusive create, optimize away the lookup 1292 * If we're doing an exclusive create, optimize away the lookup
1307 * but don't hash the dentry. 1293 * but don't hash the dentry.
1308 */ 1294 */
1309 if (nfs_is_exclusive_create(dir, nd)) { 1295 if (nd && nfs_is_exclusive_create(dir, nd->flags)) {
1310 d_instantiate(dentry, NULL); 1296 d_instantiate(dentry, NULL);
1311 res = NULL; 1297 res = NULL;
1312 goto out; 1298 goto out;
@@ -1507,15 +1493,16 @@ no_open:
1507 1493
1508static int nfs4_lookup_revalidate(struct dentry *dentry, struct nameidata *nd) 1494static int nfs4_lookup_revalidate(struct dentry *dentry, struct nameidata *nd)
1509{ 1495{
1496 unsigned int flags = nd->flags;
1510 struct dentry *parent = NULL; 1497 struct dentry *parent = NULL;
1511 struct inode *inode; 1498 struct inode *inode;
1512 struct inode *dir; 1499 struct inode *dir;
1513 int ret = 0; 1500 int ret = 0;
1514 1501
1515 if (nd->flags & LOOKUP_RCU) 1502 if (flags & LOOKUP_RCU)
1516 return -ECHILD; 1503 return -ECHILD;
1517 1504
1518 if (!(nd->flags & LOOKUP_OPEN) || (nd->flags & LOOKUP_DIRECTORY)) 1505 if (!(flags & LOOKUP_OPEN) || (flags & LOOKUP_DIRECTORY))
1519 goto no_open; 1506 goto no_open;
1520 if (d_mountpoint(dentry)) 1507 if (d_mountpoint(dentry))
1521 goto no_open; 1508 goto no_open;
@@ -1528,7 +1515,7 @@ static int nfs4_lookup_revalidate(struct dentry *dentry, struct nameidata *nd)
1528 * optimize away revalidation of negative dentries. 1515 * optimize away revalidation of negative dentries.
1529 */ 1516 */
1530 if (inode == NULL) { 1517 if (inode == NULL) {
1531 if (!nfs_neg_need_reval(dir, dentry, nd)) 1518 if (!nfs_neg_need_reval(dir, dentry, flags))
1532 ret = 1; 1519 ret = 1;
1533 goto out; 1520 goto out;
1534 } 1521 }
@@ -1537,7 +1524,7 @@ static int nfs4_lookup_revalidate(struct dentry *dentry, struct nameidata *nd)
1537 if (!S_ISREG(inode->i_mode)) 1524 if (!S_ISREG(inode->i_mode))
1538 goto no_open_dput; 1525 goto no_open_dput;
1539 /* We cannot do exclusive creation on a positive dentry */ 1526 /* We cannot do exclusive creation on a positive dentry */
1540 if (nd && nd->flags & LOOKUP_EXCL) 1527 if (flags & LOOKUP_EXCL)
1541 goto no_open_dput; 1528 goto no_open_dput;
1542 1529
1543 /* Let f_op->open() actually open (and revalidate) the file */ 1530 /* Let f_op->open() actually open (and revalidate) the file */