aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorStephen Rothwell <sfr@canb.auug.org.au>2011-07-25 13:59:46 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2011-07-25 14:53:52 -0400
commit5f00bcb38ef9a980a33c6dbdc0044964b05f22dd (patch)
tree3175fb9375aecb50bde1be0bf4fa8aa8155131d6 /fs/nfs
parent34006cee28f7344f9557a4be3816c7891b1bbab1 (diff)
parentb6844e8f64920cdee620157252169ba63afb0c89 (diff)
Merge branch 'master' into devel and apply fixup from Stephen Rothwell:
vfs/nfs: fixup for nfs_open_context change Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/cache_lib.c9
-rw-r--r--fs/nfs/dir.c87
-rw-r--r--fs/nfs/direct.c4
-rw-r--r--fs/nfs/file.c18
-rw-r--r--fs/nfs/fscache.c8
-rw-r--r--fs/nfs/inode.c20
-rw-r--r--fs/nfs/nfs4_fs.h10
-rw-r--r--fs/nfs/nfs4proc.c70
-rw-r--r--fs/nfs/nfs4state.c12
-rw-r--r--fs/nfs/pagelist.c4
-rw-r--r--fs/nfs/read.c10
-rw-r--r--fs/nfs/super.c16
-rw-r--r--fs/nfs/write.c24
13 files changed, 150 insertions, 142 deletions
diff --git a/fs/nfs/cache_lib.c b/fs/nfs/cache_lib.c
index 84690319e625..c98b439332fc 100644
--- a/fs/nfs/cache_lib.c
+++ b/fs/nfs/cache_lib.c
@@ -113,19 +113,18 @@ int nfs_cache_wait_for_upcall(struct nfs_cache_defer_req *dreq)
113 113
114int nfs_cache_register(struct cache_detail *cd) 114int nfs_cache_register(struct cache_detail *cd)
115{ 115{
116 struct nameidata nd;
117 struct vfsmount *mnt; 116 struct vfsmount *mnt;
117 struct path path;
118 int ret; 118 int ret;
119 119
120 mnt = rpc_get_mount(); 120 mnt = rpc_get_mount();
121 if (IS_ERR(mnt)) 121 if (IS_ERR(mnt))
122 return PTR_ERR(mnt); 122 return PTR_ERR(mnt);
123 ret = vfs_path_lookup(mnt->mnt_root, mnt, "/cache", 0, &nd); 123 ret = vfs_path_lookup(mnt->mnt_root, mnt, "/cache", 0, &path);
124 if (ret) 124 if (ret)
125 goto err; 125 goto err;
126 ret = sunrpc_cache_register_pipefs(nd.path.dentry, 126 ret = sunrpc_cache_register_pipefs(path.dentry, cd->name, 0600, cd);
127 cd->name, 0600, cd); 127 path_put(&path);
128 path_put(&nd.path);
129 if (!ret) 128 if (!ret)
130 return ret; 129 return ret;
131err: 130err:
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index ededdbd0db38..57f578e2560a 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -56,7 +56,7 @@ static int nfs_link(struct dentry *, struct inode *, struct dentry *);
56static int nfs_mknod(struct inode *, struct dentry *, int, dev_t); 56static int nfs_mknod(struct inode *, struct dentry *, int, dev_t);
57static int nfs_rename(struct inode *, struct dentry *, 57static int nfs_rename(struct inode *, struct dentry *,
58 struct inode *, struct dentry *); 58 struct inode *, struct dentry *);
59static int nfs_fsync_dir(struct file *, int); 59static int nfs_fsync_dir(struct file *, loff_t, loff_t, int);
60static loff_t nfs_llseek_dir(struct file *, loff_t, int); 60static loff_t nfs_llseek_dir(struct file *, loff_t, int);
61static void nfs_readdir_clear_array(struct page*); 61static void nfs_readdir_clear_array(struct page*);
62 62
@@ -945,15 +945,19 @@ out:
945 * All directory operations under NFS are synchronous, so fsync() 945 * All directory operations under NFS are synchronous, so fsync()
946 * is a dummy operation. 946 * is a dummy operation.
947 */ 947 */
948static int nfs_fsync_dir(struct file *filp, int datasync) 948static int nfs_fsync_dir(struct file *filp, loff_t start, loff_t end,
949 int datasync)
949{ 950{
950 struct dentry *dentry = filp->f_path.dentry; 951 struct dentry *dentry = filp->f_path.dentry;
952 struct inode *inode = dentry->d_inode;
951 953
952 dfprintk(FILE, "NFS: fsync dir(%s/%s) datasync %d\n", 954 dfprintk(FILE, "NFS: fsync dir(%s/%s) datasync %d\n",
953 dentry->d_parent->d_name.name, dentry->d_name.name, 955 dentry->d_parent->d_name.name, dentry->d_name.name,
954 datasync); 956 datasync);
955 957
958 mutex_lock(&inode->i_mutex);
956 nfs_inc_stats(dentry->d_inode, NFSIOS_VFSFSYNC); 959 nfs_inc_stats(dentry->d_inode, NFSIOS_VFSFSYNC);
960 mutex_unlock(&inode->i_mutex);
957 return 0; 961 return 0;
958} 962}
959 963
@@ -997,14 +1001,12 @@ static int nfs_check_verifier(struct inode *dir, struct dentry *dentry)
997 * Return the intent data that applies to this particular path component 1001 * Return the intent data that applies to this particular path component
998 * 1002 *
999 * Note that the current set of intents only apply to the very last 1003 * Note that the current set of intents only apply to the very last
1000 * component of the path. 1004 * component of the path and none of them is set before that last
1001 * We check for this using LOOKUP_CONTINUE and LOOKUP_PARENT. 1005 * component.
1002 */ 1006 */
1003static inline unsigned int nfs_lookup_check_intent(struct nameidata *nd, 1007static inline unsigned int nfs_lookup_check_intent(struct nameidata *nd,
1004 unsigned int mask) 1008 unsigned int mask)
1005{ 1009{
1006 if (nd->flags & (LOOKUP_CONTINUE|LOOKUP_PARENT))
1007 return 0;
1008 return nd->flags & mask; 1010 return nd->flags & mask;
1009} 1011}
1010 1012
@@ -1338,25 +1340,31 @@ static int is_atomic_open(struct nameidata *nd)
1338 return 0; 1340 return 0;
1339 /* Are we trying to write to a read only partition? */ 1341 /* Are we trying to write to a read only partition? */
1340 if (__mnt_is_readonly(nd->path.mnt) && 1342 if (__mnt_is_readonly(nd->path.mnt) &&
1341 (nd->intent.open.flags & (O_CREAT|O_TRUNC|FMODE_WRITE))) 1343 (nd->intent.open.flags & (O_CREAT|O_TRUNC|O_ACCMODE)))
1342 return 0; 1344 return 0;
1343 return 1; 1345 return 1;
1344} 1346}
1345 1347
1346static struct nfs_open_context *nameidata_to_nfs_open_context(struct dentry *dentry, struct nameidata *nd) 1348static fmode_t flags_to_mode(int flags)
1349{
1350 fmode_t res = (__force fmode_t)flags & FMODE_EXEC;
1351 if ((flags & O_ACCMODE) != O_WRONLY)
1352 res |= FMODE_READ;
1353 if ((flags & O_ACCMODE) != O_RDONLY)
1354 res |= FMODE_WRITE;
1355 return res;
1356}
1357
1358static struct nfs_open_context *create_nfs_open_context(struct dentry *dentry, int open_flags)
1347{ 1359{
1348 struct path path = {
1349 .mnt = nd->path.mnt,
1350 .dentry = dentry,
1351 };
1352 struct nfs_open_context *ctx; 1360 struct nfs_open_context *ctx;
1353 struct rpc_cred *cred; 1361 struct rpc_cred *cred;
1354 fmode_t fmode = nd->intent.open.flags & (FMODE_READ | FMODE_WRITE | FMODE_EXEC); 1362 fmode_t fmode = flags_to_mode(open_flags);
1355 1363
1356 cred = rpc_lookup_cred(); 1364 cred = rpc_lookup_cred();
1357 if (IS_ERR(cred)) 1365 if (IS_ERR(cred))
1358 return ERR_CAST(cred); 1366 return ERR_CAST(cred);
1359 ctx = alloc_nfs_open_context(&path, cred, fmode); 1367 ctx = alloc_nfs_open_context(dentry, cred, fmode);
1360 put_rpccred(cred); 1368 put_rpccred(cred);
1361 if (ctx == NULL) 1369 if (ctx == NULL)
1362 return ERR_PTR(-ENOMEM); 1370 return ERR_PTR(-ENOMEM);
@@ -1376,13 +1384,13 @@ static int nfs_intent_set_file(struct nameidata *nd, struct nfs_open_context *ct
1376 1384
1377 /* If the open_intent is for execute, we have an extra check to make */ 1385 /* If the open_intent is for execute, we have an extra check to make */
1378 if (ctx->mode & FMODE_EXEC) { 1386 if (ctx->mode & FMODE_EXEC) {
1379 ret = nfs_may_open(ctx->path.dentry->d_inode, 1387 ret = nfs_may_open(ctx->dentry->d_inode,
1380 ctx->cred, 1388 ctx->cred,
1381 nd->intent.open.flags); 1389 nd->intent.open.flags);
1382 if (ret < 0) 1390 if (ret < 0)
1383 goto out; 1391 goto out;
1384 } 1392 }
1385 filp = lookup_instantiate_filp(nd, ctx->path.dentry, do_open); 1393 filp = lookup_instantiate_filp(nd, ctx->dentry, do_open);
1386 if (IS_ERR(filp)) 1394 if (IS_ERR(filp))
1387 ret = PTR_ERR(filp); 1395 ret = PTR_ERR(filp);
1388 else 1396 else
@@ -1420,12 +1428,13 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
1420 goto out; 1428 goto out;
1421 } 1429 }
1422 1430
1423 ctx = nameidata_to_nfs_open_context(dentry, nd); 1431 open_flags = nd->intent.open.flags;
1432
1433 ctx = create_nfs_open_context(dentry, open_flags);
1424 res = ERR_CAST(ctx); 1434 res = ERR_CAST(ctx);
1425 if (IS_ERR(ctx)) 1435 if (IS_ERR(ctx))
1426 goto out; 1436 goto out;
1427 1437
1428 open_flags = nd->intent.open.flags;
1429 if (nd->flags & LOOKUP_CREATE) { 1438 if (nd->flags & LOOKUP_CREATE) {
1430 attr.ia_mode = nd->intent.open.create_mode; 1439 attr.ia_mode = nd->intent.open.create_mode;
1431 attr.ia_valid = ATTR_MODE; 1440 attr.ia_valid = ATTR_MODE;
@@ -1463,8 +1472,8 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry
1463 res = d_add_unique(dentry, inode); 1472 res = d_add_unique(dentry, inode);
1464 nfs_unblock_sillyrename(dentry->d_parent); 1473 nfs_unblock_sillyrename(dentry->d_parent);
1465 if (res != NULL) { 1474 if (res != NULL) {
1466 dput(ctx->path.dentry); 1475 dput(ctx->dentry);
1467 ctx->path.dentry = dget(res); 1476 ctx->dentry = dget(res);
1468 dentry = res; 1477 dentry = res;
1469 } 1478 }
1470 err = nfs_intent_set_file(nd, ctx); 1479 err = nfs_intent_set_file(nd, ctx);
@@ -1517,7 +1526,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
1517 /* We can't create new files, or truncate existing ones here */ 1526 /* We can't create new files, or truncate existing ones here */
1518 openflags &= ~(O_CREAT|O_EXCL|O_TRUNC); 1527 openflags &= ~(O_CREAT|O_EXCL|O_TRUNC);
1519 1528
1520 ctx = nameidata_to_nfs_open_context(dentry, nd); 1529 ctx = create_nfs_open_context(dentry, openflags);
1521 ret = PTR_ERR(ctx); 1530 ret = PTR_ERR(ctx);
1522 if (IS_ERR(ctx)) 1531 if (IS_ERR(ctx))
1523 goto out; 1532 goto out;
@@ -1570,7 +1579,7 @@ static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode,
1570 struct nfs_open_context *ctx = NULL; 1579 struct nfs_open_context *ctx = NULL;
1571 struct iattr attr; 1580 struct iattr attr;
1572 int error; 1581 int error;
1573 int open_flags = 0; 1582 int open_flags = O_CREAT|O_EXCL;
1574 1583
1575 dfprintk(VFS, "NFS: create(%s/%ld), %s\n", 1584 dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
1576 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); 1585 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
@@ -1578,27 +1587,27 @@ static int nfs_open_create(struct inode *dir, struct dentry *dentry, int mode,
1578 attr.ia_mode = mode; 1587 attr.ia_mode = mode;
1579 attr.ia_valid = ATTR_MODE; 1588 attr.ia_valid = ATTR_MODE;
1580 1589
1581 if ((nd->flags & LOOKUP_CREATE) != 0) { 1590 if (nd)
1582 open_flags = nd->intent.open.flags; 1591 open_flags = nd->intent.open.flags;
1583 1592
1584 ctx = nameidata_to_nfs_open_context(dentry, nd); 1593 ctx = create_nfs_open_context(dentry, open_flags);
1585 error = PTR_ERR(ctx); 1594 error = PTR_ERR(ctx);
1586 if (IS_ERR(ctx)) 1595 if (IS_ERR(ctx))
1587 goto out_err_drop; 1596 goto out_err_drop;
1588 }
1589 1597
1590 error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, ctx); 1598 error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, ctx);
1591 if (error != 0) 1599 if (error != 0)
1592 goto out_put_ctx; 1600 goto out_put_ctx;
1593 if (ctx != NULL) { 1601 if (nd) {
1594 error = nfs_intent_set_file(nd, ctx); 1602 error = nfs_intent_set_file(nd, ctx);
1595 if (error < 0) 1603 if (error < 0)
1596 goto out_err; 1604 goto out_err;
1605 } else {
1606 put_nfs_open_context(ctx);
1597 } 1607 }
1598 return 0; 1608 return 0;
1599out_put_ctx: 1609out_put_ctx:
1600 if (ctx != NULL) 1610 put_nfs_open_context(ctx);
1601 put_nfs_open_context(ctx);
1602out_err_drop: 1611out_err_drop:
1603 d_drop(dentry); 1612 d_drop(dentry);
1604out_err: 1613out_err:
@@ -1660,7 +1669,7 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode,
1660{ 1669{
1661 struct iattr attr; 1670 struct iattr attr;
1662 int error; 1671 int error;
1663 int open_flags = 0; 1672 int open_flags = O_CREAT|O_EXCL;
1664 1673
1665 dfprintk(VFS, "NFS: create(%s/%ld), %s\n", 1674 dfprintk(VFS, "NFS: create(%s/%ld), %s\n",
1666 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); 1675 dir->i_sb->s_id, dir->i_ino, dentry->d_name.name);
@@ -1668,7 +1677,7 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode,
1668 attr.ia_mode = mode; 1677 attr.ia_mode = mode;
1669 attr.ia_valid = ATTR_MODE; 1678 attr.ia_valid = ATTR_MODE;
1670 1679
1671 if ((nd->flags & LOOKUP_CREATE) != 0) 1680 if (nd)
1672 open_flags = nd->intent.open.flags; 1681 open_flags = nd->intent.open.flags;
1673 1682
1674 error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, NULL); 1683 error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, NULL);
@@ -2259,11 +2268,11 @@ static int nfs_open_permission_mask(int openflags)
2259{ 2268{
2260 int mask = 0; 2269 int mask = 0;
2261 2270
2262 if (openflags & FMODE_READ) 2271 if ((openflags & O_ACCMODE) != O_WRONLY)
2263 mask |= MAY_READ; 2272 mask |= MAY_READ;
2264 if (openflags & FMODE_WRITE) 2273 if ((openflags & O_ACCMODE) != O_RDONLY)
2265 mask |= MAY_WRITE; 2274 mask |= MAY_WRITE;
2266 if (openflags & FMODE_EXEC) 2275 if (openflags & __FMODE_EXEC)
2267 mask |= MAY_EXEC; 2276 mask |= MAY_EXEC;
2268 return mask; 2277 return mask;
2269} 2278}
@@ -2273,12 +2282,12 @@ int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags)
2273 return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags)); 2282 return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags));
2274} 2283}
2275 2284
2276int nfs_permission(struct inode *inode, int mask, unsigned int flags) 2285int nfs_permission(struct inode *inode, int mask)
2277{ 2286{
2278 struct rpc_cred *cred; 2287 struct rpc_cred *cred;
2279 int res = 0; 2288 int res = 0;
2280 2289
2281 if (flags & IPERM_FLAG_RCU) 2290 if (mask & MAY_NOT_BLOCK)
2282 return -ECHILD; 2291 return -ECHILD;
2283 2292
2284 nfs_inc_stats(inode, NFSIOS_VFSACCESS); 2293 nfs_inc_stats(inode, NFSIOS_VFSACCESS);
@@ -2328,7 +2337,7 @@ out:
2328out_notsup: 2337out_notsup:
2329 res = nfs_revalidate_inode(NFS_SERVER(inode), inode); 2338 res = nfs_revalidate_inode(NFS_SERVER(inode), inode);
2330 if (res == 0) 2339 if (res == 0)
2331 res = generic_permission(inode, mask, flags, NULL); 2340 res = generic_permission(inode, mask);
2332 goto out; 2341 goto out;
2333} 2342}
2334 2343
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 8eea25366717..b35d25b98da6 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -284,7 +284,7 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
284 loff_t pos) 284 loff_t pos)
285{ 285{
286 struct nfs_open_context *ctx = dreq->ctx; 286 struct nfs_open_context *ctx = dreq->ctx;
287 struct inode *inode = ctx->path.dentry->d_inode; 287 struct inode *inode = ctx->dentry->d_inode;
288 unsigned long user_addr = (unsigned long)iov->iov_base; 288 unsigned long user_addr = (unsigned long)iov->iov_base;
289 size_t count = iov->iov_len; 289 size_t count = iov->iov_len;
290 size_t rsize = NFS_SERVER(inode)->rsize; 290 size_t rsize = NFS_SERVER(inode)->rsize;
@@ -715,7 +715,7 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
715 loff_t pos, int sync) 715 loff_t pos, int sync)
716{ 716{
717 struct nfs_open_context *ctx = dreq->ctx; 717 struct nfs_open_context *ctx = dreq->ctx;
718 struct inode *inode = ctx->path.dentry->d_inode; 718 struct inode *inode = ctx->dentry->d_inode;
719 unsigned long user_addr = (unsigned long)iov->iov_base; 719 unsigned long user_addr = (unsigned long)iov->iov_base;
720 size_t count = iov->iov_len; 720 size_t count = iov->iov_len;
721 struct rpc_task *task; 721 struct rpc_task *task;
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 2f093ed16980..28b8c3f3cda3 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -55,7 +55,7 @@ static ssize_t nfs_file_splice_write(struct pipe_inode_info *pipe,
55static ssize_t nfs_file_write(struct kiocb *, const struct iovec *iov, 55static ssize_t nfs_file_write(struct kiocb *, const struct iovec *iov,
56 unsigned long nr_segs, loff_t pos); 56 unsigned long nr_segs, loff_t pos);
57static int nfs_file_flush(struct file *, fl_owner_t id); 57static int nfs_file_flush(struct file *, fl_owner_t id);
58static int nfs_file_fsync(struct file *, int datasync); 58static int nfs_file_fsync(struct file *, loff_t, loff_t, int datasync);
59static int nfs_check_flags(int flags); 59static int nfs_check_flags(int flags);
60static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl); 60static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl);
61static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl); 61static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl);
@@ -187,8 +187,11 @@ static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin)
187 filp->f_path.dentry->d_name.name, 187 filp->f_path.dentry->d_name.name,
188 offset, origin); 188 offset, origin);
189 189
190 /* origin == SEEK_END => we must revalidate the cached file length */ 190 /*
191 if (origin == SEEK_END) { 191 * origin == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
192 * the cached file length
193 */
194 if (origin != SEEK_SET || origin != SEEK_CUR) {
192 struct inode *inode = filp->f_mapping->host; 195 struct inode *inode = filp->f_mapping->host;
193 196
194 int retval = nfs_revalidate_file_size(inode, filp); 197 int retval = nfs_revalidate_file_size(inode, filp);
@@ -305,7 +308,7 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma)
305 * fall back to doing a synchronous write. 308 * fall back to doing a synchronous write.
306 */ 309 */
307static int 310static int
308nfs_file_fsync(struct file *file, int datasync) 311nfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
309{ 312{
310 struct dentry *dentry = file->f_path.dentry; 313 struct dentry *dentry = file->f_path.dentry;
311 struct nfs_open_context *ctx = nfs_file_open_context(file); 314 struct nfs_open_context *ctx = nfs_file_open_context(file);
@@ -313,11 +316,15 @@ nfs_file_fsync(struct file *file, int datasync)
313 int have_error, status; 316 int have_error, status;
314 int ret = 0; 317 int ret = 0;
315 318
316
317 dprintk("NFS: fsync file(%s/%s) datasync %d\n", 319 dprintk("NFS: fsync file(%s/%s) datasync %d\n",
318 dentry->d_parent->d_name.name, dentry->d_name.name, 320 dentry->d_parent->d_name.name, dentry->d_name.name,
319 datasync); 321 datasync);
320 322
323 ret = filemap_write_and_wait_range(inode->i_mapping, start, end);
324 if (ret)
325 return ret;
326 mutex_lock(&inode->i_mutex);
327
321 nfs_inc_stats(inode, NFSIOS_VFSFSYNC); 328 nfs_inc_stats(inode, NFSIOS_VFSFSYNC);
322 have_error = test_and_clear_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags); 329 have_error = test_and_clear_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags);
323 status = nfs_commit_inode(inode, FLUSH_SYNC); 330 status = nfs_commit_inode(inode, FLUSH_SYNC);
@@ -329,6 +336,7 @@ nfs_file_fsync(struct file *file, int datasync)
329 if (!ret && !datasync) 336 if (!ret && !datasync)
330 /* application has asked for meta-data sync */ 337 /* application has asked for meta-data sync */
331 ret = pnfs_layoutcommit_inode(inode, true); 338 ret = pnfs_layoutcommit_inode(inode, true);
339 mutex_unlock(&inode->i_mutex);
332 return ret; 340 return ret;
333} 341}
334 342
diff --git a/fs/nfs/fscache.c b/fs/nfs/fscache.c
index ce153a6b3aec..419119c371bf 100644
--- a/fs/nfs/fscache.c
+++ b/fs/nfs/fscache.c
@@ -259,12 +259,10 @@ static void nfs_fscache_disable_inode_cookie(struct inode *inode)
259 dfprintk(FSCACHE, 259 dfprintk(FSCACHE,
260 "NFS: nfsi 0x%p turning cache off\n", NFS_I(inode)); 260 "NFS: nfsi 0x%p turning cache off\n", NFS_I(inode));
261 261
262 /* Need to invalidate any mapped pages that were read in before 262 /* Need to uncache any pages attached to this inode that
263 * turning off the cache. 263 * fscache knows about before turning off the cache.
264 */ 264 */
265 if (inode->i_mapping && inode->i_mapping->nrpages) 265 fscache_uncache_all_inode_pages(NFS_I(inode)->fscache, inode);
266 invalidate_inode_pages2(inode->i_mapping);
267
268 nfs_fscache_zap_inode_cookie(inode); 266 nfs_fscache_zap_inode_cookie(inode);
269 } 267 }
270} 268}
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 6f4850deb272..fe1203797b2b 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -567,7 +567,7 @@ static struct nfs_lock_context *__nfs_find_lock_context(struct nfs_open_context
567struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx) 567struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx)
568{ 568{
569 struct nfs_lock_context *res, *new = NULL; 569 struct nfs_lock_context *res, *new = NULL;
570 struct inode *inode = ctx->path.dentry->d_inode; 570 struct inode *inode = ctx->dentry->d_inode;
571 571
572 spin_lock(&inode->i_lock); 572 spin_lock(&inode->i_lock);
573 res = __nfs_find_lock_context(ctx); 573 res = __nfs_find_lock_context(ctx);
@@ -594,7 +594,7 @@ struct nfs_lock_context *nfs_get_lock_context(struct nfs_open_context *ctx)
594void nfs_put_lock_context(struct nfs_lock_context *l_ctx) 594void nfs_put_lock_context(struct nfs_lock_context *l_ctx)
595{ 595{
596 struct nfs_open_context *ctx = l_ctx->open_context; 596 struct nfs_open_context *ctx = l_ctx->open_context;
597 struct inode *inode = ctx->path.dentry->d_inode; 597 struct inode *inode = ctx->dentry->d_inode;
598 598
599 if (!atomic_dec_and_lock(&l_ctx->count, &inode->i_lock)) 599 if (!atomic_dec_and_lock(&l_ctx->count, &inode->i_lock))
600 return; 600 return;
@@ -620,7 +620,7 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
620 return; 620 return;
621 if (!is_sync) 621 if (!is_sync)
622 return; 622 return;
623 inode = ctx->path.dentry->d_inode; 623 inode = ctx->dentry->d_inode;
624 if (!list_empty(&NFS_I(inode)->open_files)) 624 if (!list_empty(&NFS_I(inode)->open_files))
625 return; 625 return;
626 server = NFS_SERVER(inode); 626 server = NFS_SERVER(inode);
@@ -629,14 +629,14 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
629 nfs_revalidate_inode(server, inode); 629 nfs_revalidate_inode(server, inode);
630} 630}
631 631
632struct nfs_open_context *alloc_nfs_open_context(struct path *path, struct rpc_cred *cred, fmode_t f_mode) 632struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct rpc_cred *cred, fmode_t f_mode)
633{ 633{
634 struct nfs_open_context *ctx; 634 struct nfs_open_context *ctx;
635 635
636 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); 636 ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
637 if (ctx != NULL) { 637 if (ctx != NULL) {
638 ctx->path = *path; 638 nfs_sb_active(dentry->d_sb);
639 path_get(&ctx->path); 639 ctx->dentry = dget(dentry);
640 ctx->cred = get_rpccred(cred); 640 ctx->cred = get_rpccred(cred);
641 ctx->state = NULL; 641 ctx->state = NULL;
642 ctx->mode = f_mode; 642 ctx->mode = f_mode;
@@ -658,7 +658,8 @@ struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx)
658 658
659static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync) 659static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync)
660{ 660{
661 struct inode *inode = ctx->path.dentry->d_inode; 661 struct inode *inode = ctx->dentry->d_inode;
662 struct super_block *sb = ctx->dentry->d_sb;
662 663
663 if (!list_empty(&ctx->list)) { 664 if (!list_empty(&ctx->list)) {
664 if (!atomic_dec_and_lock(&ctx->lock_context.count, &inode->i_lock)) 665 if (!atomic_dec_and_lock(&ctx->lock_context.count, &inode->i_lock))
@@ -671,7 +672,8 @@ static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync)
671 NFS_PROTO(inode)->close_context(ctx, is_sync); 672 NFS_PROTO(inode)->close_context(ctx, is_sync);
672 if (ctx->cred != NULL) 673 if (ctx->cred != NULL)
673 put_rpccred(ctx->cred); 674 put_rpccred(ctx->cred);
674 path_put(&ctx->path); 675 dput(ctx->dentry);
676 nfs_sb_deactive(sb);
675 kfree(ctx); 677 kfree(ctx);
676} 678}
677 679
@@ -741,7 +743,7 @@ int nfs_open(struct inode *inode, struct file *filp)
741 cred = rpc_lookup_cred(); 743 cred = rpc_lookup_cred();
742 if (IS_ERR(cred)) 744 if (IS_ERR(cred))
743 return PTR_ERR(cred); 745 return PTR_ERR(cred);
744 ctx = alloc_nfs_open_context(&filp->f_path, cred, filp->f_mode); 746 ctx = alloc_nfs_open_context(filp->f_path.dentry, cred, filp->f_mode);
745 put_rpccred(cred); 747 put_rpccred(cred);
746 if (ctx == NULL) 748 if (ctx == NULL)
747 return -ENOMEM; 749 return -ENOMEM;
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index c30aed2c70f4..1909ee8be350 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -241,7 +241,7 @@ extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *);
241extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); 241extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *);
242extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); 242extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);
243extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); 243extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);
244extern int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait, bool roc); 244extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait, bool roc);
245extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); 245extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle);
246extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, 246extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
247 struct nfs4_fs_locations *fs_locations, struct page *page); 247 struct nfs4_fs_locations *fs_locations, struct page *page);
@@ -344,8 +344,8 @@ extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struc
344extern void nfs4_put_state_owner(struct nfs4_state_owner *); 344extern void nfs4_put_state_owner(struct nfs4_state_owner *);
345extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *); 345extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *);
346extern void nfs4_put_open_state(struct nfs4_state *); 346extern void nfs4_put_open_state(struct nfs4_state *);
347extern void nfs4_close_state(struct path *, struct nfs4_state *, fmode_t); 347extern void nfs4_close_state(struct nfs4_state *, fmode_t);
348extern void nfs4_close_sync(struct path *, struct nfs4_state *, fmode_t); 348extern void nfs4_close_sync(struct nfs4_state *, fmode_t);
349extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t); 349extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t);
350extern void nfs4_schedule_lease_recovery(struct nfs_client *); 350extern void nfs4_schedule_lease_recovery(struct nfs_client *);
351extern void nfs4_schedule_state_manager(struct nfs_client *); 351extern void nfs4_schedule_state_manager(struct nfs_client *);
@@ -378,8 +378,8 @@ extern struct svc_version nfs4_callback_version4;
378 378
379#else 379#else
380 380
381#define nfs4_close_state(a, b, c) do { } while (0) 381#define nfs4_close_state(a, b) do { } while (0)
382#define nfs4_close_sync(a, b, c) do { } while (0) 382#define nfs4_close_sync(a, b) do { } while (0)
383 383
384#endif /* CONFIG_NFS_V4 */ 384#endif /* CONFIG_NFS_V4 */
385#endif /* __LINUX_FS_NFS_NFS4_FS.H */ 385#endif /* __LINUX_FS_NFS_NFS4_FS.H */
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 93ef77666efc..079614deca3f 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -766,8 +766,8 @@ struct nfs4_opendata {
766 struct nfs_open_confirmres c_res; 766 struct nfs_open_confirmres c_res;
767 struct nfs_fattr f_attr; 767 struct nfs_fattr f_attr;
768 struct nfs_fattr dir_attr; 768 struct nfs_fattr dir_attr;
769 struct path path;
770 struct dentry *dir; 769 struct dentry *dir;
770 struct dentry *dentry;
771 struct nfs4_state_owner *owner; 771 struct nfs4_state_owner *owner;
772 struct nfs4_state *state; 772 struct nfs4_state *state;
773 struct iattr attrs; 773 struct iattr attrs;
@@ -789,12 +789,12 @@ static void nfs4_init_opendata_res(struct nfs4_opendata *p)
789 nfs_fattr_init(&p->dir_attr); 789 nfs_fattr_init(&p->dir_attr);
790} 790}
791 791
792static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path, 792static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
793 struct nfs4_state_owner *sp, fmode_t fmode, int flags, 793 struct nfs4_state_owner *sp, fmode_t fmode, int flags,
794 const struct iattr *attrs, 794 const struct iattr *attrs,
795 gfp_t gfp_mask) 795 gfp_t gfp_mask)
796{ 796{
797 struct dentry *parent = dget_parent(path->dentry); 797 struct dentry *parent = dget_parent(dentry);
798 struct inode *dir = parent->d_inode; 798 struct inode *dir = parent->d_inode;
799 struct nfs_server *server = NFS_SERVER(dir); 799 struct nfs_server *server = NFS_SERVER(dir);
800 struct nfs4_opendata *p; 800 struct nfs4_opendata *p;
@@ -805,8 +805,8 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path,
805 p->o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid, gfp_mask); 805 p->o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid, gfp_mask);
806 if (p->o_arg.seqid == NULL) 806 if (p->o_arg.seqid == NULL)
807 goto err_free; 807 goto err_free;
808 path_get(path); 808 nfs_sb_active(dentry->d_sb);
809 p->path = *path; 809 p->dentry = dget(dentry);
810 p->dir = parent; 810 p->dir = parent;
811 p->owner = sp; 811 p->owner = sp;
812 atomic_inc(&sp->so_count); 812 atomic_inc(&sp->so_count);
@@ -815,7 +815,7 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path,
815 p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE); 815 p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE);
816 p->o_arg.clientid = server->nfs_client->cl_clientid; 816 p->o_arg.clientid = server->nfs_client->cl_clientid;
817 p->o_arg.id = sp->so_owner_id.id; 817 p->o_arg.id = sp->so_owner_id.id;
818 p->o_arg.name = &p->path.dentry->d_name; 818 p->o_arg.name = &dentry->d_name;
819 p->o_arg.server = server; 819 p->o_arg.server = server;
820 p->o_arg.bitmask = server->attr_bitmask; 820 p->o_arg.bitmask = server->attr_bitmask;
821 p->o_arg.claim = NFS4_OPEN_CLAIM_NULL; 821 p->o_arg.claim = NFS4_OPEN_CLAIM_NULL;
@@ -845,13 +845,15 @@ static void nfs4_opendata_free(struct kref *kref)
845{ 845{
846 struct nfs4_opendata *p = container_of(kref, 846 struct nfs4_opendata *p = container_of(kref,
847 struct nfs4_opendata, kref); 847 struct nfs4_opendata, kref);
848 struct super_block *sb = p->dentry->d_sb;
848 849
849 nfs_free_seqid(p->o_arg.seqid); 850 nfs_free_seqid(p->o_arg.seqid);
850 if (p->state != NULL) 851 if (p->state != NULL)
851 nfs4_put_open_state(p->state); 852 nfs4_put_open_state(p->state);
852 nfs4_put_state_owner(p->owner); 853 nfs4_put_state_owner(p->owner);
853 dput(p->dir); 854 dput(p->dir);
854 path_put(&p->path); 855 dput(p->dentry);
856 nfs_sb_deactive(sb);
855 kfree(p); 857 kfree(p);
856} 858}
857 859
@@ -1133,7 +1135,7 @@ static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context
1133{ 1135{
1134 struct nfs4_opendata *opendata; 1136 struct nfs4_opendata *opendata;
1135 1137
1136 opendata = nfs4_opendata_alloc(&ctx->path, state->owner, 0, 0, NULL, GFP_NOFS); 1138 opendata = nfs4_opendata_alloc(ctx->dentry, state->owner, 0, 0, NULL, GFP_NOFS);
1137 if (opendata == NULL) 1139 if (opendata == NULL)
1138 return ERR_PTR(-ENOMEM); 1140 return ERR_PTR(-ENOMEM);
1139 opendata->state = state; 1141 opendata->state = state;
@@ -1157,7 +1159,7 @@ static int nfs4_open_recover_helper(struct nfs4_opendata *opendata, fmode_t fmod
1157 newstate = nfs4_opendata_to_nfs4_state(opendata); 1159 newstate = nfs4_opendata_to_nfs4_state(opendata);
1158 if (IS_ERR(newstate)) 1160 if (IS_ERR(newstate))
1159 return PTR_ERR(newstate); 1161 return PTR_ERR(newstate);
1160 nfs4_close_state(&opendata->path, newstate, fmode); 1162 nfs4_close_state(newstate, fmode);
1161 *res = newstate; 1163 *res = newstate;
1162 return 0; 1164 return 0;
1163} 1165}
@@ -1355,7 +1357,7 @@ static void nfs4_open_confirm_release(void *calldata)
1355 goto out_free; 1357 goto out_free;
1356 state = nfs4_opendata_to_nfs4_state(data); 1358 state = nfs4_opendata_to_nfs4_state(data);
1357 if (!IS_ERR(state)) 1359 if (!IS_ERR(state))
1358 nfs4_close_state(&data->path, state, data->o_arg.fmode); 1360 nfs4_close_state(state, data->o_arg.fmode);
1359out_free: 1361out_free:
1360 nfs4_opendata_put(data); 1362 nfs4_opendata_put(data);
1361} 1363}
@@ -1500,7 +1502,7 @@ static void nfs4_open_release(void *calldata)
1500 goto out_free; 1502 goto out_free;
1501 state = nfs4_opendata_to_nfs4_state(data); 1503 state = nfs4_opendata_to_nfs4_state(data);
1502 if (!IS_ERR(state)) 1504 if (!IS_ERR(state))
1503 nfs4_close_state(&data->path, state, data->o_arg.fmode); 1505 nfs4_close_state(state, data->o_arg.fmode);
1504out_free: 1506out_free:
1505 nfs4_opendata_put(data); 1507 nfs4_opendata_put(data);
1506} 1508}
@@ -1651,7 +1653,7 @@ static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *s
1651 return PTR_ERR(opendata); 1653 return PTR_ERR(opendata);
1652 ret = nfs4_open_recover(opendata, state); 1654 ret = nfs4_open_recover(opendata, state);
1653 if (ret == -ESTALE) 1655 if (ret == -ESTALE)
1654 d_drop(ctx->path.dentry); 1656 d_drop(ctx->dentry);
1655 nfs4_opendata_put(opendata); 1657 nfs4_opendata_put(opendata);
1656 return ret; 1658 return ret;
1657} 1659}
@@ -1723,7 +1725,7 @@ static inline void nfs4_exclusive_attrset(struct nfs4_opendata *opendata, struct
1723/* 1725/*
1724 * Returns a referenced nfs4_state 1726 * Returns a referenced nfs4_state
1725 */ 1727 */
1726static int _nfs4_do_open(struct inode *dir, struct path *path, fmode_t fmode, int flags, struct iattr *sattr, struct rpc_cred *cred, struct nfs4_state **res) 1728static int _nfs4_do_open(struct inode *dir, struct dentry *dentry, fmode_t fmode, int flags, struct iattr *sattr, struct rpc_cred *cred, struct nfs4_state **res)
1727{ 1729{
1728 struct nfs4_state_owner *sp; 1730 struct nfs4_state_owner *sp;
1729 struct nfs4_state *state = NULL; 1731 struct nfs4_state *state = NULL;
@@ -1740,15 +1742,15 @@ static int _nfs4_do_open(struct inode *dir, struct path *path, fmode_t fmode, in
1740 status = nfs4_recover_expired_lease(server); 1742 status = nfs4_recover_expired_lease(server);
1741 if (status != 0) 1743 if (status != 0)
1742 goto err_put_state_owner; 1744 goto err_put_state_owner;
1743 if (path->dentry->d_inode != NULL) 1745 if (dentry->d_inode != NULL)
1744 nfs4_return_incompatible_delegation(path->dentry->d_inode, fmode); 1746 nfs4_return_incompatible_delegation(dentry->d_inode, fmode);
1745 status = -ENOMEM; 1747 status = -ENOMEM;
1746 opendata = nfs4_opendata_alloc(path, sp, fmode, flags, sattr, GFP_KERNEL); 1748 opendata = nfs4_opendata_alloc(dentry, sp, fmode, flags, sattr, GFP_KERNEL);
1747 if (opendata == NULL) 1749 if (opendata == NULL)
1748 goto err_put_state_owner; 1750 goto err_put_state_owner;
1749 1751
1750 if (path->dentry->d_inode != NULL) 1752 if (dentry->d_inode != NULL)
1751 opendata->state = nfs4_get_open_state(path->dentry->d_inode, sp); 1753 opendata->state = nfs4_get_open_state(dentry->d_inode, sp);
1752 1754
1753 status = _nfs4_proc_open(opendata); 1755 status = _nfs4_proc_open(opendata);
1754 if (status != 0) 1756 if (status != 0)
@@ -1786,14 +1788,14 @@ out_err:
1786} 1788}
1787 1789
1788 1790
1789static struct nfs4_state *nfs4_do_open(struct inode *dir, struct path *path, fmode_t fmode, int flags, struct iattr *sattr, struct rpc_cred *cred) 1791static struct nfs4_state *nfs4_do_open(struct inode *dir, struct dentry *dentry, fmode_t fmode, int flags, struct iattr *sattr, struct rpc_cred *cred)
1790{ 1792{
1791 struct nfs4_exception exception = { }; 1793 struct nfs4_exception exception = { };
1792 struct nfs4_state *res; 1794 struct nfs4_state *res;
1793 int status; 1795 int status;
1794 1796
1795 do { 1797 do {
1796 status = _nfs4_do_open(dir, path, fmode, flags, sattr, cred, &res); 1798 status = _nfs4_do_open(dir, dentry, fmode, flags, sattr, cred, &res);
1797 if (status == 0) 1799 if (status == 0)
1798 break; 1800 break;
1799 /* NOTE: BAD_SEQID means the server and client disagree about the 1801 /* NOTE: BAD_SEQID means the server and client disagree about the
@@ -1890,7 +1892,6 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
1890} 1892}
1891 1893
1892struct nfs4_closedata { 1894struct nfs4_closedata {
1893 struct path path;
1894 struct inode *inode; 1895 struct inode *inode;
1895 struct nfs4_state *state; 1896 struct nfs4_state *state;
1896 struct nfs_closeargs arg; 1897 struct nfs_closeargs arg;
@@ -1905,13 +1906,14 @@ static void nfs4_free_closedata(void *data)
1905{ 1906{
1906 struct nfs4_closedata *calldata = data; 1907 struct nfs4_closedata *calldata = data;
1907 struct nfs4_state_owner *sp = calldata->state->owner; 1908 struct nfs4_state_owner *sp = calldata->state->owner;
1909 struct super_block *sb = calldata->state->inode->i_sb;
1908 1910
1909 if (calldata->roc) 1911 if (calldata->roc)
1910 pnfs_roc_release(calldata->state->inode); 1912 pnfs_roc_release(calldata->state->inode);
1911 nfs4_put_open_state(calldata->state); 1913 nfs4_put_open_state(calldata->state);
1912 nfs_free_seqid(calldata->arg.seqid); 1914 nfs_free_seqid(calldata->arg.seqid);
1913 nfs4_put_state_owner(sp); 1915 nfs4_put_state_owner(sp);
1914 path_put(&calldata->path); 1916 nfs_sb_deactive(sb);
1915 kfree(calldata); 1917 kfree(calldata);
1916} 1918}
1917 1919
@@ -2031,7 +2033,7 @@ static const struct rpc_call_ops nfs4_close_ops = {
2031 * 2033 *
2032 * NOTE: Caller must be holding the sp->so_owner semaphore! 2034 * NOTE: Caller must be holding the sp->so_owner semaphore!
2033 */ 2035 */
2034int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait, bool roc) 2036int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait, bool roc)
2035{ 2037{
2036 struct nfs_server *server = NFS_SERVER(state->inode); 2038 struct nfs_server *server = NFS_SERVER(state->inode);
2037 struct nfs4_closedata *calldata; 2039 struct nfs4_closedata *calldata;
@@ -2067,8 +2069,7 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, i
2067 calldata->res.seqid = calldata->arg.seqid; 2069 calldata->res.seqid = calldata->arg.seqid;
2068 calldata->res.server = server; 2070 calldata->res.server = server;
2069 calldata->roc = roc; 2071 calldata->roc = roc;
2070 path_get(path); 2072 nfs_sb_active(calldata->inode->i_sb);
2071 calldata->path = *path;
2072 2073
2073 msg.rpc_argp = &calldata->arg; 2074 msg.rpc_argp = &calldata->arg;
2074 msg.rpc_resp = &calldata->res; 2075 msg.rpc_resp = &calldata->res;
@@ -2097,7 +2098,7 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags
2097 struct nfs4_state *state; 2098 struct nfs4_state *state;
2098 2099
2099 /* Protect against concurrent sillydeletes */ 2100 /* Protect against concurrent sillydeletes */
2100 state = nfs4_do_open(dir, &ctx->path, ctx->mode, open_flags, attr, ctx->cred); 2101 state = nfs4_do_open(dir, ctx->dentry, ctx->mode, open_flags, attr, ctx->cred);
2101 if (IS_ERR(state)) 2102 if (IS_ERR(state))
2102 return ERR_CAST(state); 2103 return ERR_CAST(state);
2103 ctx->state = state; 2104 ctx->state = state;
@@ -2109,9 +2110,9 @@ static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync)
2109 if (ctx->state == NULL) 2110 if (ctx->state == NULL)
2110 return; 2111 return;
2111 if (is_sync) 2112 if (is_sync)
2112 nfs4_close_sync(&ctx->path, ctx->state, ctx->mode); 2113 nfs4_close_sync(ctx->state, ctx->mode);
2113 else 2114 else
2114 nfs4_close_state(&ctx->path, ctx->state, ctx->mode); 2115 nfs4_close_state(ctx->state, ctx->mode);
2115} 2116}
2116 2117
2117static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) 2118static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle)
@@ -2634,10 +2635,7 @@ static int
2634nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, 2635nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
2635 int flags, struct nfs_open_context *ctx) 2636 int flags, struct nfs_open_context *ctx)
2636{ 2637{
2637 struct path my_path = { 2638 struct dentry *de = dentry;
2638 .dentry = dentry,
2639 };
2640 struct path *path = &my_path;
2641 struct nfs4_state *state; 2639 struct nfs4_state *state;
2642 struct rpc_cred *cred = NULL; 2640 struct rpc_cred *cred = NULL;
2643 fmode_t fmode = 0; 2641 fmode_t fmode = 0;
@@ -2645,11 +2643,11 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
2645 2643
2646 if (ctx != NULL) { 2644 if (ctx != NULL) {
2647 cred = ctx->cred; 2645 cred = ctx->cred;
2648 path = &ctx->path; 2646 de = ctx->dentry;
2649 fmode = ctx->mode; 2647 fmode = ctx->mode;
2650 } 2648 }
2651 sattr->ia_mode &= ~current_umask(); 2649 sattr->ia_mode &= ~current_umask();
2652 state = nfs4_do_open(dir, path, fmode, flags, sattr, cred); 2650 state = nfs4_do_open(dir, de, fmode, flags, sattr, cred);
2653 d_drop(dentry); 2651 d_drop(dentry);
2654 if (IS_ERR(state)) { 2652 if (IS_ERR(state)) {
2655 status = PTR_ERR(state); 2653 status = PTR_ERR(state);
@@ -2660,7 +2658,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
2660 if (ctx != NULL) 2658 if (ctx != NULL)
2661 ctx->state = state; 2659 ctx->state = state;
2662 else 2660 else
2663 nfs4_close_sync(path, state, fmode); 2661 nfs4_close_sync(state, fmode);
2664out: 2662out:
2665 return status; 2663 return status;
2666} 2664}
@@ -4312,7 +4310,7 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
4312 memcpy(data->lsp->ls_stateid.data, data->res.stateid.data, 4310 memcpy(data->lsp->ls_stateid.data, data->res.stateid.data,
4313 sizeof(data->lsp->ls_stateid.data)); 4311 sizeof(data->lsp->ls_stateid.data));
4314 data->lsp->ls_flags |= NFS_LOCK_INITIALIZED; 4312 data->lsp->ls_flags |= NFS_LOCK_INITIALIZED;
4315 renew_lease(NFS_SERVER(data->ctx->path.dentry->d_inode), data->timestamp); 4313 renew_lease(NFS_SERVER(data->ctx->dentry->d_inode), data->timestamp);
4316 } 4314 }
4317out: 4315out:
4318 dprintk("%s: done, ret = %d!\n", __func__, data->rpc_status); 4316 dprintk("%s: done, ret = %d!\n", __func__, data->rpc_status);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 5d744a52b4e1..72ab97ef3d61 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -641,7 +641,7 @@ void nfs4_put_open_state(struct nfs4_state *state)
641/* 641/*
642 * Close the current file. 642 * Close the current file.
643 */ 643 */
644static void __nfs4_close(struct path *path, struct nfs4_state *state, 644static void __nfs4_close(struct nfs4_state *state,
645 fmode_t fmode, gfp_t gfp_mask, int wait) 645 fmode_t fmode, gfp_t gfp_mask, int wait)
646{ 646{
647 struct nfs4_state_owner *owner = state->owner; 647 struct nfs4_state_owner *owner = state->owner;
@@ -685,18 +685,18 @@ static void __nfs4_close(struct path *path, struct nfs4_state *state,
685 } else { 685 } else {
686 bool roc = pnfs_roc(state->inode); 686 bool roc = pnfs_roc(state->inode);
687 687
688 nfs4_do_close(path, state, gfp_mask, wait, roc); 688 nfs4_do_close(state, gfp_mask, wait, roc);
689 } 689 }
690} 690}
691 691
692void nfs4_close_state(struct path *path, struct nfs4_state *state, fmode_t fmode) 692void nfs4_close_state(struct nfs4_state *state, fmode_t fmode)
693{ 693{
694 __nfs4_close(path, state, fmode, GFP_NOFS, 0); 694 __nfs4_close(state, fmode, GFP_NOFS, 0);
695} 695}
696 696
697void nfs4_close_sync(struct path *path, struct nfs4_state *state, fmode_t fmode) 697void nfs4_close_sync(struct nfs4_state *state, fmode_t fmode)
698{ 698{
699 __nfs4_close(path, state, fmode, GFP_KERNEL, 1); 699 __nfs4_close(state, fmode, GFP_KERNEL, 1);
700} 700}
701 701
702/* 702/*
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 7139dbf8784e..b60970cc7f1f 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -114,7 +114,7 @@ int nfs_set_page_tag_locked(struct nfs_page *req)
114 if (!nfs_lock_request_dontget(req)) 114 if (!nfs_lock_request_dontget(req))
115 return 0; 115 return 0;
116 if (test_bit(PG_MAPPED, &req->wb_flags)) 116 if (test_bit(PG_MAPPED, &req->wb_flags))
117 radix_tree_tag_set(&NFS_I(req->wb_context->path.dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED); 117 radix_tree_tag_set(&NFS_I(req->wb_context->dentry->d_inode)->nfs_page_tree, req->wb_index, NFS_PAGE_TAG_LOCKED);
118 return 1; 118 return 1;
119} 119}
120 120
@@ -124,7 +124,7 @@ int nfs_set_page_tag_locked(struct nfs_page *req)
124void nfs_clear_page_tag_locked(struct nfs_page *req) 124void nfs_clear_page_tag_locked(struct nfs_page *req)
125{ 125{
126 if (test_bit(PG_MAPPED, &req->wb_flags)) { 126 if (test_bit(PG_MAPPED, &req->wb_flags)) {
127 struct inode *inode = req->wb_context->path.dentry->d_inode; 127 struct inode *inode = req->wb_context->dentry->d_inode;
128 struct nfs_inode *nfsi = NFS_I(inode); 128 struct nfs_inode *nfsi = NFS_I(inode);
129 129
130 spin_lock(&inode->i_lock); 130 spin_lock(&inode->i_lock);
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 7cba2280e2b8..2171c043ab08 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -159,7 +159,7 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
159 159
160static void nfs_readpage_release(struct nfs_page *req) 160static void nfs_readpage_release(struct nfs_page *req)
161{ 161{
162 struct inode *d_inode = req->wb_context->path.dentry->d_inode; 162 struct inode *d_inode = req->wb_context->dentry->d_inode;
163 163
164 if (PageUptodate(req->wb_page)) 164 if (PageUptodate(req->wb_page))
165 nfs_readpage_to_fscache(d_inode, req->wb_page, 0); 165 nfs_readpage_to_fscache(d_inode, req->wb_page, 0);
@@ -167,8 +167,8 @@ static void nfs_readpage_release(struct nfs_page *req)
167 unlock_page(req->wb_page); 167 unlock_page(req->wb_page);
168 168
169 dprintk("NFS: read done (%s/%Ld %d@%Ld)\n", 169 dprintk("NFS: read done (%s/%Ld %d@%Ld)\n",
170 req->wb_context->path.dentry->d_inode->i_sb->s_id, 170 req->wb_context->dentry->d_inode->i_sb->s_id,
171 (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), 171 (long long)NFS_FILEID(req->wb_context->dentry->d_inode),
172 req->wb_bytes, 172 req->wb_bytes,
173 (long long)req_offset(req)); 173 (long long)req_offset(req));
174 nfs_release_request(req); 174 nfs_release_request(req);
@@ -220,7 +220,7 @@ EXPORT_SYMBOL_GPL(nfs_initiate_read);
220static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data, 220static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
221 unsigned int count, unsigned int offset) 221 unsigned int count, unsigned int offset)
222{ 222{
223 struct inode *inode = req->wb_context->path.dentry->d_inode; 223 struct inode *inode = req->wb_context->dentry->d_inode;
224 224
225 data->req = req; 225 data->req = req;
226 data->inode = inode; 226 data->inode = inode;
@@ -243,7 +243,7 @@ static void nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
243static int nfs_do_read(struct nfs_read_data *data, 243static int nfs_do_read(struct nfs_read_data *data,
244 const struct rpc_call_ops *call_ops) 244 const struct rpc_call_ops *call_ops)
245{ 245{
246 struct inode *inode = data->args.context->path.dentry->d_inode; 246 struct inode *inode = data->args.context->dentry->d_inode;
247 247
248 return nfs_initiate_read(data, NFS_CLIENT(inode), call_ops); 248 return nfs_initiate_read(data, NFS_CLIENT(inode), call_ops);
249} 249}
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index ce40e5c568ba..b961ceac66b4 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2773,16 +2773,12 @@ static void nfs_referral_loop_unprotect(void)
2773static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt, 2773static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
2774 const char *export_path) 2774 const char *export_path)
2775{ 2775{
2776 struct nameidata *nd = NULL;
2777 struct mnt_namespace *ns_private; 2776 struct mnt_namespace *ns_private;
2778 struct super_block *s; 2777 struct super_block *s;
2779 struct dentry *dentry; 2778 struct dentry *dentry;
2779 struct path path;
2780 int ret; 2780 int ret;
2781 2781
2782 nd = kmalloc(sizeof(*nd), GFP_KERNEL);
2783 if (nd == NULL)
2784 return ERR_PTR(-ENOMEM);
2785
2786 ns_private = create_mnt_ns(root_mnt); 2782 ns_private = create_mnt_ns(root_mnt);
2787 ret = PTR_ERR(ns_private); 2783 ret = PTR_ERR(ns_private);
2788 if (IS_ERR(ns_private)) 2784 if (IS_ERR(ns_private))
@@ -2793,7 +2789,7 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
2793 goto out_put_mnt_ns; 2789 goto out_put_mnt_ns;
2794 2790
2795 ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt, 2791 ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt,
2796 export_path, LOOKUP_FOLLOW, nd); 2792 export_path, LOOKUP_FOLLOW, &path);
2797 2793
2798 nfs_referral_loop_unprotect(); 2794 nfs_referral_loop_unprotect();
2799 put_mnt_ns(ns_private); 2795 put_mnt_ns(ns_private);
@@ -2801,12 +2797,11 @@ static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
2801 if (ret != 0) 2797 if (ret != 0)
2802 goto out_err; 2798 goto out_err;
2803 2799
2804 s = nd->path.mnt->mnt_sb; 2800 s = path.mnt->mnt_sb;
2805 atomic_inc(&s->s_active); 2801 atomic_inc(&s->s_active);
2806 dentry = dget(nd->path.dentry); 2802 dentry = dget(path.dentry);
2807 2803
2808 path_put(&nd->path); 2804 path_put(&path);
2809 kfree(nd);
2810 down_write(&s->s_umount); 2805 down_write(&s->s_umount);
2811 return dentry; 2806 return dentry;
2812out_put_mnt_ns: 2807out_put_mnt_ns:
@@ -2814,7 +2809,6 @@ out_put_mnt_ns:
2814out_mntput: 2809out_mntput:
2815 mntput(root_mnt); 2810 mntput(root_mnt);
2816out_err: 2811out_err:
2817 kfree(nd);
2818 return ERR_PTR(ret); 2812 return ERR_PTR(ret);
2819} 2813}
2820 2814
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 9fba5270b1a8..ebed5183f420 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -409,7 +409,7 @@ out:
409 */ 409 */
410static void nfs_inode_remove_request(struct nfs_page *req) 410static void nfs_inode_remove_request(struct nfs_page *req)
411{ 411{
412 struct inode *inode = req->wb_context->path.dentry->d_inode; 412 struct inode *inode = req->wb_context->dentry->d_inode;
413 struct nfs_inode *nfsi = NFS_I(inode); 413 struct nfs_inode *nfsi = NFS_I(inode);
414 414
415 BUG_ON (!NFS_WBACK_BUSY(req)); 415 BUG_ON (!NFS_WBACK_BUSY(req));
@@ -438,7 +438,7 @@ nfs_mark_request_dirty(struct nfs_page *req)
438static void 438static void
439nfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg) 439nfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg)
440{ 440{
441 struct inode *inode = req->wb_context->path.dentry->d_inode; 441 struct inode *inode = req->wb_context->dentry->d_inode;
442 struct nfs_inode *nfsi = NFS_I(inode); 442 struct nfs_inode *nfsi = NFS_I(inode);
443 443
444 spin_lock(&inode->i_lock); 444 spin_lock(&inode->i_lock);
@@ -850,13 +850,13 @@ static void nfs_write_rpcsetup(struct nfs_page *req,
850 unsigned int count, unsigned int offset, 850 unsigned int count, unsigned int offset,
851 int how) 851 int how)
852{ 852{
853 struct inode *inode = req->wb_context->path.dentry->d_inode; 853 struct inode *inode = req->wb_context->dentry->d_inode;
854 854
855 /* Set up the RPC argument and reply structs 855 /* Set up the RPC argument and reply structs
856 * NB: take care not to mess about with data->commit et al. */ 856 * NB: take care not to mess about with data->commit et al. */
857 857
858 data->req = req; 858 data->req = req;
859 data->inode = inode = req->wb_context->path.dentry->d_inode; 859 data->inode = inode = req->wb_context->dentry->d_inode;
860 data->cred = req->wb_context->cred; 860 data->cred = req->wb_context->cred;
861 861
862 data->args.fh = NFS_FH(inode); 862 data->args.fh = NFS_FH(inode);
@@ -889,7 +889,7 @@ static int nfs_do_write(struct nfs_write_data *data,
889 const struct rpc_call_ops *call_ops, 889 const struct rpc_call_ops *call_ops,
890 int how) 890 int how)
891{ 891{
892 struct inode *inode = data->args.context->path.dentry->d_inode; 892 struct inode *inode = data->args.context->dentry->d_inode;
893 893
894 return nfs_initiate_write(data, NFS_CLIENT(inode), call_ops, how); 894 return nfs_initiate_write(data, NFS_CLIENT(inode), call_ops, how);
895} 895}
@@ -1081,9 +1081,9 @@ static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
1081 1081
1082 dprintk("NFS: %5u write(%s/%lld %d@%lld)", 1082 dprintk("NFS: %5u write(%s/%lld %d@%lld)",
1083 task->tk_pid, 1083 task->tk_pid,
1084 data->req->wb_context->path.dentry->d_inode->i_sb->s_id, 1084 data->req->wb_context->dentry->d_inode->i_sb->s_id,
1085 (long long) 1085 (long long)
1086 NFS_FILEID(data->req->wb_context->path.dentry->d_inode), 1086 NFS_FILEID(data->req->wb_context->dentry->d_inode),
1087 data->req->wb_bytes, (long long)req_offset(data->req)); 1087 data->req->wb_bytes, (long long)req_offset(data->req));
1088 1088
1089 nfs_writeback_done(task, data); 1089 nfs_writeback_done(task, data);
@@ -1176,8 +1176,8 @@ static void nfs_writeback_release_full(void *calldata)
1176 1176
1177 dprintk("NFS: %5u write (%s/%lld %d@%lld)", 1177 dprintk("NFS: %5u write (%s/%lld %d@%lld)",
1178 data->task.tk_pid, 1178 data->task.tk_pid,
1179 req->wb_context->path.dentry->d_inode->i_sb->s_id, 1179 req->wb_context->dentry->d_inode->i_sb->s_id,
1180 (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), 1180 (long long)NFS_FILEID(req->wb_context->dentry->d_inode),
1181 req->wb_bytes, 1181 req->wb_bytes,
1182 (long long)req_offset(req)); 1182 (long long)req_offset(req));
1183 1183
@@ -1375,7 +1375,7 @@ void nfs_init_commit(struct nfs_write_data *data,
1375 struct pnfs_layout_segment *lseg) 1375 struct pnfs_layout_segment *lseg)
1376{ 1376{
1377 struct nfs_page *first = nfs_list_entry(head->next); 1377 struct nfs_page *first = nfs_list_entry(head->next);
1378 struct inode *inode = first->wb_context->path.dentry->d_inode; 1378 struct inode *inode = first->wb_context->dentry->d_inode;
1379 1379
1380 /* Set up the RPC argument and reply structs 1380 /* Set up the RPC argument and reply structs
1381 * NB: take care not to mess about with data->commit et al. */ 1381 * NB: take care not to mess about with data->commit et al. */
@@ -1463,8 +1463,8 @@ void nfs_commit_release_pages(struct nfs_write_data *data)
1463 nfs_clear_request_commit(req); 1463 nfs_clear_request_commit(req);
1464 1464
1465 dprintk("NFS: commit (%s/%lld %d@%lld)", 1465 dprintk("NFS: commit (%s/%lld %d@%lld)",
1466 req->wb_context->path.dentry->d_inode->i_sb->s_id, 1466 req->wb_context->dentry->d_sb->s_id,
1467 (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), 1467 (long long)NFS_FILEID(req->wb_context->dentry->d_inode),
1468 req->wb_bytes, 1468 req->wb_bytes,
1469 (long long)req_offset(req)); 1469 (long long)req_offset(req));
1470 if (status < 0) { 1470 if (status < 0) {