aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
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/inode.c20
-rw-r--r--fs/nfs/nfs3acl.c10
-rw-r--r--fs/nfs/nfs4_fs.h10
-rw-r--r--fs/nfs/nfs4filelayout.c1
-rw-r--r--fs/nfs/nfs4proc.c70
-rw-r--r--fs/nfs/nfs4state.c12
-rw-r--r--fs/nfs/nfs4xdr.c2
-rw-r--r--fs/nfs/pagelist.c4
-rw-r--r--fs/nfs/read.c8
-rw-r--r--fs/nfs/super.c16
-rw-r--r--fs/nfs/write.c24
15 files changed, 151 insertions, 144 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/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/nfs3acl.c b/fs/nfs/nfs3acl.c
index 274342771655..e49e73107e62 100644
--- a/fs/nfs/nfs3acl.c
+++ b/fs/nfs/nfs3acl.c
@@ -427,16 +427,12 @@ int nfs3_proc_set_default_acl(struct inode *dir, struct inode *inode,
427 } 427 }
428 if (!dfacl) 428 if (!dfacl)
429 return 0; 429 return 0;
430 acl = posix_acl_clone(dfacl, GFP_KERNEL); 430 acl = posix_acl_dup(dfacl);
431 error = -ENOMEM; 431 error = posix_acl_create(&acl, GFP_KERNEL, &mode);
432 if (!acl)
433 goto out_release_dfacl;
434 error = posix_acl_create_masq(acl, &mode);
435 if (error < 0) 432 if (error < 0)
436 goto out_release_acl; 433 goto out_release_dfacl;
437 error = nfs3_proc_setacls(inode, acl, S_ISDIR(inode->i_mode) ? 434 error = nfs3_proc_setacls(inode, acl, S_ISDIR(inode->i_mode) ?
438 dfacl : NULL); 435 dfacl : NULL);
439out_release_acl:
440 posix_acl_release(acl); 436 posix_acl_release(acl);
441out_release_dfacl: 437out_release_dfacl:
442 posix_acl_release(dfacl); 438 posix_acl_release(dfacl);
diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h
index c4a69833dd0d..b788f2eb1ba0 100644
--- a/fs/nfs/nfs4_fs.h
+++ b/fs/nfs/nfs4_fs.h
@@ -238,7 +238,7 @@ extern int nfs4_proc_async_renew(struct nfs_client *, struct rpc_cred *);
238extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *); 238extern int nfs4_proc_renew(struct nfs_client *, struct rpc_cred *);
239extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *); 239extern int nfs4_init_clientid(struct nfs_client *, struct rpc_cred *);
240extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *); 240extern int nfs41_init_clientid(struct nfs_client *, struct rpc_cred *);
241extern int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait, bool roc); 241extern int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait, bool roc);
242extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle); 242extern int nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle);
243extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name, 243extern int nfs4_proc_fs_locations(struct inode *dir, const struct qstr *name,
244 struct nfs4_fs_locations *fs_locations, struct page *page); 244 struct nfs4_fs_locations *fs_locations, struct page *page);
@@ -341,8 +341,8 @@ extern struct nfs4_state_owner * nfs4_get_state_owner(struct nfs_server *, struc
341extern void nfs4_put_state_owner(struct nfs4_state_owner *); 341extern void nfs4_put_state_owner(struct nfs4_state_owner *);
342extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *); 342extern struct nfs4_state * nfs4_get_open_state(struct inode *, struct nfs4_state_owner *);
343extern void nfs4_put_open_state(struct nfs4_state *); 343extern void nfs4_put_open_state(struct nfs4_state *);
344extern void nfs4_close_state(struct path *, struct nfs4_state *, fmode_t); 344extern void nfs4_close_state(struct nfs4_state *, fmode_t);
345extern void nfs4_close_sync(struct path *, struct nfs4_state *, fmode_t); 345extern void nfs4_close_sync(struct nfs4_state *, fmode_t);
346extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t); 346extern void nfs4_state_set_mode_locked(struct nfs4_state *, fmode_t);
347extern void nfs4_schedule_lease_recovery(struct nfs_client *); 347extern void nfs4_schedule_lease_recovery(struct nfs_client *);
348extern void nfs4_schedule_state_manager(struct nfs_client *); 348extern void nfs4_schedule_state_manager(struct nfs_client *);
@@ -373,8 +373,8 @@ extern struct svc_version nfs4_callback_version4;
373 373
374#else 374#else
375 375
376#define nfs4_close_state(a, b, c) do { } while (0) 376#define nfs4_close_state(a, b) do { } while (0)
377#define nfs4_close_sync(a, b, c) do { } while (0) 377#define nfs4_close_sync(a, b) do { } while (0)
378 378
379#endif /* CONFIG_NFS_V4 */ 379#endif /* CONFIG_NFS_V4 */
380#endif /* __LINUX_FS_NFS_NFS4_FS.H */ 380#endif /* __LINUX_FS_NFS_NFS4_FS.H */
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 0bafcc91c27f..f9d03abcd04c 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -398,7 +398,6 @@ filelayout_write_pagelist(struct nfs_write_data *data, int sync)
398 * this offset and save the original offset. 398 * this offset and save the original offset.
399 */ 399 */
400 data->args.offset = filelayout_get_dserver_offset(lseg, offset); 400 data->args.offset = filelayout_get_dserver_offset(lseg, offset);
401 data->mds_offset = offset;
402 401
403 /* Perform an asynchronous write */ 402 /* Perform an asynchronous write */
404 status = nfs_initiate_write(data, ds->ds_clp->cl_rpcclient, 403 status = nfs_initiate_write(data, ds->ds_clp->cl_rpcclient,
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 5879b23e0c99..26bece8f3083 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -763,8 +763,8 @@ struct nfs4_opendata {
763 struct nfs_open_confirmres c_res; 763 struct nfs_open_confirmres c_res;
764 struct nfs_fattr f_attr; 764 struct nfs_fattr f_attr;
765 struct nfs_fattr dir_attr; 765 struct nfs_fattr dir_attr;
766 struct path path;
767 struct dentry *dir; 766 struct dentry *dir;
767 struct dentry *dentry;
768 struct nfs4_state_owner *owner; 768 struct nfs4_state_owner *owner;
769 struct nfs4_state *state; 769 struct nfs4_state *state;
770 struct iattr attrs; 770 struct iattr attrs;
@@ -786,12 +786,12 @@ static void nfs4_init_opendata_res(struct nfs4_opendata *p)
786 nfs_fattr_init(&p->dir_attr); 786 nfs_fattr_init(&p->dir_attr);
787} 787}
788 788
789static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path, 789static struct nfs4_opendata *nfs4_opendata_alloc(struct dentry *dentry,
790 struct nfs4_state_owner *sp, fmode_t fmode, int flags, 790 struct nfs4_state_owner *sp, fmode_t fmode, int flags,
791 const struct iattr *attrs, 791 const struct iattr *attrs,
792 gfp_t gfp_mask) 792 gfp_t gfp_mask)
793{ 793{
794 struct dentry *parent = dget_parent(path->dentry); 794 struct dentry *parent = dget_parent(dentry);
795 struct inode *dir = parent->d_inode; 795 struct inode *dir = parent->d_inode;
796 struct nfs_server *server = NFS_SERVER(dir); 796 struct nfs_server *server = NFS_SERVER(dir);
797 struct nfs4_opendata *p; 797 struct nfs4_opendata *p;
@@ -802,8 +802,8 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path,
802 p->o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid, gfp_mask); 802 p->o_arg.seqid = nfs_alloc_seqid(&sp->so_seqid, gfp_mask);
803 if (p->o_arg.seqid == NULL) 803 if (p->o_arg.seqid == NULL)
804 goto err_free; 804 goto err_free;
805 path_get(path); 805 nfs_sb_active(dentry->d_sb);
806 p->path = *path; 806 p->dentry = dget(dentry);
807 p->dir = parent; 807 p->dir = parent;
808 p->owner = sp; 808 p->owner = sp;
809 atomic_inc(&sp->so_count); 809 atomic_inc(&sp->so_count);
@@ -812,7 +812,7 @@ static struct nfs4_opendata *nfs4_opendata_alloc(struct path *path,
812 p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE); 812 p->o_arg.fmode = fmode & (FMODE_READ|FMODE_WRITE);
813 p->o_arg.clientid = server->nfs_client->cl_clientid; 813 p->o_arg.clientid = server->nfs_client->cl_clientid;
814 p->o_arg.id = sp->so_owner_id.id; 814 p->o_arg.id = sp->so_owner_id.id;
815 p->o_arg.name = &p->path.dentry->d_name; 815 p->o_arg.name = &dentry->d_name;
816 p->o_arg.server = server; 816 p->o_arg.server = server;
817 p->o_arg.bitmask = server->attr_bitmask; 817 p->o_arg.bitmask = server->attr_bitmask;
818 p->o_arg.claim = NFS4_OPEN_CLAIM_NULL; 818 p->o_arg.claim = NFS4_OPEN_CLAIM_NULL;
@@ -842,13 +842,15 @@ static void nfs4_opendata_free(struct kref *kref)
842{ 842{
843 struct nfs4_opendata *p = container_of(kref, 843 struct nfs4_opendata *p = container_of(kref,
844 struct nfs4_opendata, kref); 844 struct nfs4_opendata, kref);
845 struct super_block *sb = p->dentry->d_sb;
845 846
846 nfs_free_seqid(p->o_arg.seqid); 847 nfs_free_seqid(p->o_arg.seqid);
847 if (p->state != NULL) 848 if (p->state != NULL)
848 nfs4_put_open_state(p->state); 849 nfs4_put_open_state(p->state);
849 nfs4_put_state_owner(p->owner); 850 nfs4_put_state_owner(p->owner);
850 dput(p->dir); 851 dput(p->dir);
851 path_put(&p->path); 852 dput(p->dentry);
853 nfs_sb_deactive(sb);
852 kfree(p); 854 kfree(p);
853} 855}
854 856
@@ -1130,7 +1132,7 @@ static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context
1130{ 1132{
1131 struct nfs4_opendata *opendata; 1133 struct nfs4_opendata *opendata;
1132 1134
1133 opendata = nfs4_opendata_alloc(&ctx->path, state->owner, 0, 0, NULL, GFP_NOFS); 1135 opendata = nfs4_opendata_alloc(ctx->dentry, state->owner, 0, 0, NULL, GFP_NOFS);
1134 if (opendata == NULL) 1136 if (opendata == NULL)
1135 return ERR_PTR(-ENOMEM); 1137 return ERR_PTR(-ENOMEM);
1136 opendata->state = state; 1138 opendata->state = state;
@@ -1154,7 +1156,7 @@ static int nfs4_open_recover_helper(struct nfs4_opendata *opendata, fmode_t fmod
1154 newstate = nfs4_opendata_to_nfs4_state(opendata); 1156 newstate = nfs4_opendata_to_nfs4_state(opendata);
1155 if (IS_ERR(newstate)) 1157 if (IS_ERR(newstate))
1156 return PTR_ERR(newstate); 1158 return PTR_ERR(newstate);
1157 nfs4_close_state(&opendata->path, newstate, fmode); 1159 nfs4_close_state(newstate, fmode);
1158 *res = newstate; 1160 *res = newstate;
1159 return 0; 1161 return 0;
1160} 1162}
@@ -1352,7 +1354,7 @@ static void nfs4_open_confirm_release(void *calldata)
1352 goto out_free; 1354 goto out_free;
1353 state = nfs4_opendata_to_nfs4_state(data); 1355 state = nfs4_opendata_to_nfs4_state(data);
1354 if (!IS_ERR(state)) 1356 if (!IS_ERR(state))
1355 nfs4_close_state(&data->path, state, data->o_arg.fmode); 1357 nfs4_close_state(state, data->o_arg.fmode);
1356out_free: 1358out_free:
1357 nfs4_opendata_put(data); 1359 nfs4_opendata_put(data);
1358} 1360}
@@ -1497,7 +1499,7 @@ static void nfs4_open_release(void *calldata)
1497 goto out_free; 1499 goto out_free;
1498 state = nfs4_opendata_to_nfs4_state(data); 1500 state = nfs4_opendata_to_nfs4_state(data);
1499 if (!IS_ERR(state)) 1501 if (!IS_ERR(state))
1500 nfs4_close_state(&data->path, state, data->o_arg.fmode); 1502 nfs4_close_state(state, data->o_arg.fmode);
1501out_free: 1503out_free:
1502 nfs4_opendata_put(data); 1504 nfs4_opendata_put(data);
1503} 1505}
@@ -1648,7 +1650,7 @@ static int _nfs4_open_expired(struct nfs_open_context *ctx, struct nfs4_state *s
1648 return PTR_ERR(opendata); 1650 return PTR_ERR(opendata);
1649 ret = nfs4_open_recover(opendata, state); 1651 ret = nfs4_open_recover(opendata, state);
1650 if (ret == -ESTALE) 1652 if (ret == -ESTALE)
1651 d_drop(ctx->path.dentry); 1653 d_drop(ctx->dentry);
1652 nfs4_opendata_put(opendata); 1654 nfs4_opendata_put(opendata);
1653 return ret; 1655 return ret;
1654} 1656}
@@ -1706,7 +1708,7 @@ static inline void nfs4_exclusive_attrset(struct nfs4_opendata *opendata, struct
1706/* 1708/*
1707 * Returns a referenced nfs4_state 1709 * Returns a referenced nfs4_state
1708 */ 1710 */
1709static 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) 1711static 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)
1710{ 1712{
1711 struct nfs4_state_owner *sp; 1713 struct nfs4_state_owner *sp;
1712 struct nfs4_state *state = NULL; 1714 struct nfs4_state *state = NULL;
@@ -1723,15 +1725,15 @@ static int _nfs4_do_open(struct inode *dir, struct path *path, fmode_t fmode, in
1723 status = nfs4_recover_expired_lease(server); 1725 status = nfs4_recover_expired_lease(server);
1724 if (status != 0) 1726 if (status != 0)
1725 goto err_put_state_owner; 1727 goto err_put_state_owner;
1726 if (path->dentry->d_inode != NULL) 1728 if (dentry->d_inode != NULL)
1727 nfs4_return_incompatible_delegation(path->dentry->d_inode, fmode); 1729 nfs4_return_incompatible_delegation(dentry->d_inode, fmode);
1728 status = -ENOMEM; 1730 status = -ENOMEM;
1729 opendata = nfs4_opendata_alloc(path, sp, fmode, flags, sattr, GFP_KERNEL); 1731 opendata = nfs4_opendata_alloc(dentry, sp, fmode, flags, sattr, GFP_KERNEL);
1730 if (opendata == NULL) 1732 if (opendata == NULL)
1731 goto err_put_state_owner; 1733 goto err_put_state_owner;
1732 1734
1733 if (path->dentry->d_inode != NULL) 1735 if (dentry->d_inode != NULL)
1734 opendata->state = nfs4_get_open_state(path->dentry->d_inode, sp); 1736 opendata->state = nfs4_get_open_state(dentry->d_inode, sp);
1735 1737
1736 status = _nfs4_proc_open(opendata); 1738 status = _nfs4_proc_open(opendata);
1737 if (status != 0) 1739 if (status != 0)
@@ -1769,14 +1771,14 @@ out_err:
1769} 1771}
1770 1772
1771 1773
1772static struct nfs4_state *nfs4_do_open(struct inode *dir, struct path *path, fmode_t fmode, int flags, struct iattr *sattr, struct rpc_cred *cred) 1774static struct nfs4_state *nfs4_do_open(struct inode *dir, struct dentry *dentry, fmode_t fmode, int flags, struct iattr *sattr, struct rpc_cred *cred)
1773{ 1775{
1774 struct nfs4_exception exception = { }; 1776 struct nfs4_exception exception = { };
1775 struct nfs4_state *res; 1777 struct nfs4_state *res;
1776 int status; 1778 int status;
1777 1779
1778 do { 1780 do {
1779 status = _nfs4_do_open(dir, path, fmode, flags, sattr, cred, &res); 1781 status = _nfs4_do_open(dir, dentry, fmode, flags, sattr, cred, &res);
1780 if (status == 0) 1782 if (status == 0)
1781 break; 1783 break;
1782 /* NOTE: BAD_SEQID means the server and client disagree about the 1784 /* NOTE: BAD_SEQID means the server and client disagree about the
@@ -1873,7 +1875,6 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
1873} 1875}
1874 1876
1875struct nfs4_closedata { 1877struct nfs4_closedata {
1876 struct path path;
1877 struct inode *inode; 1878 struct inode *inode;
1878 struct nfs4_state *state; 1879 struct nfs4_state *state;
1879 struct nfs_closeargs arg; 1880 struct nfs_closeargs arg;
@@ -1888,13 +1889,14 @@ static void nfs4_free_closedata(void *data)
1888{ 1889{
1889 struct nfs4_closedata *calldata = data; 1890 struct nfs4_closedata *calldata = data;
1890 struct nfs4_state_owner *sp = calldata->state->owner; 1891 struct nfs4_state_owner *sp = calldata->state->owner;
1892 struct super_block *sb = calldata->state->inode->i_sb;
1891 1893
1892 if (calldata->roc) 1894 if (calldata->roc)
1893 pnfs_roc_release(calldata->state->inode); 1895 pnfs_roc_release(calldata->state->inode);
1894 nfs4_put_open_state(calldata->state); 1896 nfs4_put_open_state(calldata->state);
1895 nfs_free_seqid(calldata->arg.seqid); 1897 nfs_free_seqid(calldata->arg.seqid);
1896 nfs4_put_state_owner(sp); 1898 nfs4_put_state_owner(sp);
1897 path_put(&calldata->path); 1899 nfs_sb_deactive(sb);
1898 kfree(calldata); 1900 kfree(calldata);
1899} 1901}
1900 1902
@@ -2014,7 +2016,7 @@ static const struct rpc_call_ops nfs4_close_ops = {
2014 * 2016 *
2015 * NOTE: Caller must be holding the sp->so_owner semaphore! 2017 * NOTE: Caller must be holding the sp->so_owner semaphore!
2016 */ 2018 */
2017int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, int wait, bool roc) 2019int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait, bool roc)
2018{ 2020{
2019 struct nfs_server *server = NFS_SERVER(state->inode); 2021 struct nfs_server *server = NFS_SERVER(state->inode);
2020 struct nfs4_closedata *calldata; 2022 struct nfs4_closedata *calldata;
@@ -2050,8 +2052,7 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, gfp_t gfp_mask, i
2050 calldata->res.seqid = calldata->arg.seqid; 2052 calldata->res.seqid = calldata->arg.seqid;
2051 calldata->res.server = server; 2053 calldata->res.server = server;
2052 calldata->roc = roc; 2054 calldata->roc = roc;
2053 path_get(path); 2055 nfs_sb_active(calldata->inode->i_sb);
2054 calldata->path = *path;
2055 2056
2056 msg.rpc_argp = &calldata->arg; 2057 msg.rpc_argp = &calldata->arg;
2057 msg.rpc_resp = &calldata->res; 2058 msg.rpc_resp = &calldata->res;
@@ -2080,7 +2081,7 @@ nfs4_atomic_open(struct inode *dir, struct nfs_open_context *ctx, int open_flags
2080 struct nfs4_state *state; 2081 struct nfs4_state *state;
2081 2082
2082 /* Protect against concurrent sillydeletes */ 2083 /* Protect against concurrent sillydeletes */
2083 state = nfs4_do_open(dir, &ctx->path, ctx->mode, open_flags, attr, ctx->cred); 2084 state = nfs4_do_open(dir, ctx->dentry, ctx->mode, open_flags, attr, ctx->cred);
2084 if (IS_ERR(state)) 2085 if (IS_ERR(state))
2085 return ERR_CAST(state); 2086 return ERR_CAST(state);
2086 ctx->state = state; 2087 ctx->state = state;
@@ -2092,9 +2093,9 @@ static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync)
2092 if (ctx->state == NULL) 2093 if (ctx->state == NULL)
2093 return; 2094 return;
2094 if (is_sync) 2095 if (is_sync)
2095 nfs4_close_sync(&ctx->path, ctx->state, ctx->mode); 2096 nfs4_close_sync(ctx->state, ctx->mode);
2096 else 2097 else
2097 nfs4_close_state(&ctx->path, ctx->state, ctx->mode); 2098 nfs4_close_state(ctx->state, ctx->mode);
2098} 2099}
2099 2100
2100static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle) 2101static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle)
@@ -2616,10 +2617,7 @@ static int
2616nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, 2617nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
2617 int flags, struct nfs_open_context *ctx) 2618 int flags, struct nfs_open_context *ctx)
2618{ 2619{
2619 struct path my_path = { 2620 struct dentry *de = dentry;
2620 .dentry = dentry,
2621 };
2622 struct path *path = &my_path;
2623 struct nfs4_state *state; 2621 struct nfs4_state *state;
2624 struct rpc_cred *cred = NULL; 2622 struct rpc_cred *cred = NULL;
2625 fmode_t fmode = 0; 2623 fmode_t fmode = 0;
@@ -2627,11 +2625,11 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
2627 2625
2628 if (ctx != NULL) { 2626 if (ctx != NULL) {
2629 cred = ctx->cred; 2627 cred = ctx->cred;
2630 path = &ctx->path; 2628 de = ctx->dentry;
2631 fmode = ctx->mode; 2629 fmode = ctx->mode;
2632 } 2630 }
2633 sattr->ia_mode &= ~current_umask(); 2631 sattr->ia_mode &= ~current_umask();
2634 state = nfs4_do_open(dir, path, fmode, flags, sattr, cred); 2632 state = nfs4_do_open(dir, de, fmode, flags, sattr, cred);
2635 d_drop(dentry); 2633 d_drop(dentry);
2636 if (IS_ERR(state)) { 2634 if (IS_ERR(state)) {
2637 status = PTR_ERR(state); 2635 status = PTR_ERR(state);
@@ -2642,7 +2640,7 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr,
2642 if (ctx != NULL) 2640 if (ctx != NULL)
2643 ctx->state = state; 2641 ctx->state = state;
2644 else 2642 else
2645 nfs4_close_sync(path, state, fmode); 2643 nfs4_close_sync(state, fmode);
2646out: 2644out:
2647 return status; 2645 return status;
2648} 2646}
@@ -4294,7 +4292,7 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
4294 memcpy(data->lsp->ls_stateid.data, data->res.stateid.data, 4292 memcpy(data->lsp->ls_stateid.data, data->res.stateid.data,
4295 sizeof(data->lsp->ls_stateid.data)); 4293 sizeof(data->lsp->ls_stateid.data));
4296 data->lsp->ls_flags |= NFS_LOCK_INITIALIZED; 4294 data->lsp->ls_flags |= NFS_LOCK_INITIALIZED;
4297 renew_lease(NFS_SERVER(data->ctx->path.dentry->d_inode), data->timestamp); 4295 renew_lease(NFS_SERVER(data->ctx->dentry->d_inode), data->timestamp);
4298 } 4296 }
4299out: 4297out:
4300 dprintk("%s: done, ret = %d!\n", __func__, data->rpc_status); 4298 dprintk("%s: done, ret = %d!\n", __func__, data->rpc_status);
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index e97dd219f84f..7acfe8843626 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/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 6870bc61ceec..e6e8f3b9a1de 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -91,7 +91,7 @@ static int nfs4_stat_to_errno(int);
91#define encode_getfh_maxsz (op_encode_hdr_maxsz) 91#define encode_getfh_maxsz (op_encode_hdr_maxsz)
92#define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \ 92#define decode_getfh_maxsz (op_decode_hdr_maxsz + 1 + \
93 ((3+NFS4_FHSIZE) >> 2)) 93 ((3+NFS4_FHSIZE) >> 2))
94#define nfs4_fattr_bitmap_maxsz 3 94#define nfs4_fattr_bitmap_maxsz 4
95#define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz) 95#define encode_getattr_maxsz (op_encode_hdr_maxsz + nfs4_fattr_bitmap_maxsz)
96#define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2)) 96#define nfs4_name_maxsz (1 + ((3 + NFS4_MAXNAMLEN) >> 2))
97#define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2)) 97#define nfs4_path_maxsz (1 + ((3 + NFS4_MAXPATHLEN) >> 2))
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index 009855716286..18449f43c568 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 20a7f952e244..a68679f538fc 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -144,7 +144,7 @@ int nfs_readpage_async(struct nfs_open_context *ctx, struct inode *inode,
144 144
145static void nfs_readpage_release(struct nfs_page *req) 145static void nfs_readpage_release(struct nfs_page *req)
146{ 146{
147 struct inode *d_inode = req->wb_context->path.dentry->d_inode; 147 struct inode *d_inode = req->wb_context->dentry->d_inode;
148 148
149 if (PageUptodate(req->wb_page)) 149 if (PageUptodate(req->wb_page))
150 nfs_readpage_to_fscache(d_inode, req->wb_page, 0); 150 nfs_readpage_to_fscache(d_inode, req->wb_page, 0);
@@ -152,8 +152,8 @@ static void nfs_readpage_release(struct nfs_page *req)
152 unlock_page(req->wb_page); 152 unlock_page(req->wb_page);
153 153
154 dprintk("NFS: read done (%s/%Ld %d@%Ld)\n", 154 dprintk("NFS: read done (%s/%Ld %d@%Ld)\n",
155 req->wb_context->path.dentry->d_inode->i_sb->s_id, 155 req->wb_context->dentry->d_inode->i_sb->s_id,
156 (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), 156 (long long)NFS_FILEID(req->wb_context->dentry->d_inode),
157 req->wb_bytes, 157 req->wb_bytes,
158 (long long)req_offset(req)); 158 (long long)req_offset(req));
159 nfs_release_request(req); 159 nfs_release_request(req);
@@ -207,7 +207,7 @@ static int nfs_read_rpcsetup(struct nfs_page *req, struct nfs_read_data *data,
207 unsigned int count, unsigned int offset, 207 unsigned int count, unsigned int offset,
208 struct pnfs_layout_segment *lseg) 208 struct pnfs_layout_segment *lseg)
209{ 209{
210 struct inode *inode = req->wb_context->path.dentry->d_inode; 210 struct inode *inode = req->wb_context->dentry->d_inode;
211 211
212 data->req = req; 212 data->req = req;
213 data->inode = inode; 213 data->inode = inode;
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 e268e3b23497..08579312c57b 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);
@@ -852,18 +852,20 @@ static int nfs_write_rpcsetup(struct nfs_page *req,
852 struct pnfs_layout_segment *lseg, 852 struct pnfs_layout_segment *lseg,
853 int how) 853 int how)
854{ 854{
855 struct inode *inode = req->wb_context->path.dentry->d_inode; 855 struct inode *inode = req->wb_context->dentry->d_inode;
856 856
857 /* Set up the RPC argument and reply structs 857 /* Set up the RPC argument and reply structs
858 * NB: take care not to mess about with data->commit et al. */ 858 * NB: take care not to mess about with data->commit et al. */
859 859
860 data->req = req; 860 data->req = req;
861 data->inode = inode = req->wb_context->path.dentry->d_inode; 861 data->inode = inode = req->wb_context->dentry->d_inode;
862 data->cred = req->wb_context->cred; 862 data->cred = req->wb_context->cred;
863 data->lseg = get_lseg(lseg); 863 data->lseg = get_lseg(lseg);
864 864
865 data->args.fh = NFS_FH(inode); 865 data->args.fh = NFS_FH(inode);
866 data->args.offset = req_offset(req) + offset; 866 data->args.offset = req_offset(req) + offset;
867 /* pnfs_set_layoutcommit needs this */
868 data->mds_offset = data->args.offset;
867 data->args.pgbase = req->wb_pgbase + offset; 869 data->args.pgbase = req->wb_pgbase + offset;
868 data->args.pages = data->pagevec; 870 data->args.pages = data->pagevec;
869 data->args.count = count; 871 data->args.count = count;
@@ -1051,9 +1053,9 @@ static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata)
1051 1053
1052 dprintk("NFS: %5u write(%s/%lld %d@%lld)", 1054 dprintk("NFS: %5u write(%s/%lld %d@%lld)",
1053 task->tk_pid, 1055 task->tk_pid,
1054 data->req->wb_context->path.dentry->d_inode->i_sb->s_id, 1056 data->req->wb_context->dentry->d_inode->i_sb->s_id,
1055 (long long) 1057 (long long)
1056 NFS_FILEID(data->req->wb_context->path.dentry->d_inode), 1058 NFS_FILEID(data->req->wb_context->dentry->d_inode),
1057 data->req->wb_bytes, (long long)req_offset(data->req)); 1059 data->req->wb_bytes, (long long)req_offset(data->req));
1058 1060
1059 nfs_writeback_done(task, data); 1061 nfs_writeback_done(task, data);
@@ -1146,8 +1148,8 @@ static void nfs_writeback_release_full(void *calldata)
1146 1148
1147 dprintk("NFS: %5u write (%s/%lld %d@%lld)", 1149 dprintk("NFS: %5u write (%s/%lld %d@%lld)",
1148 data->task.tk_pid, 1150 data->task.tk_pid,
1149 req->wb_context->path.dentry->d_inode->i_sb->s_id, 1151 req->wb_context->dentry->d_inode->i_sb->s_id,
1150 (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), 1152 (long long)NFS_FILEID(req->wb_context->dentry->d_inode),
1151 req->wb_bytes, 1153 req->wb_bytes,
1152 (long long)req_offset(req)); 1154 (long long)req_offset(req));
1153 1155
@@ -1345,7 +1347,7 @@ void nfs_init_commit(struct nfs_write_data *data,
1345 struct pnfs_layout_segment *lseg) 1347 struct pnfs_layout_segment *lseg)
1346{ 1348{
1347 struct nfs_page *first = nfs_list_entry(head->next); 1349 struct nfs_page *first = nfs_list_entry(head->next);
1348 struct inode *inode = first->wb_context->path.dentry->d_inode; 1350 struct inode *inode = first->wb_context->dentry->d_inode;
1349 1351
1350 /* Set up the RPC argument and reply structs 1352 /* Set up the RPC argument and reply structs
1351 * NB: take care not to mess about with data->commit et al. */ 1353 * NB: take care not to mess about with data->commit et al. */
@@ -1433,8 +1435,8 @@ void nfs_commit_release_pages(struct nfs_write_data *data)
1433 nfs_clear_request_commit(req); 1435 nfs_clear_request_commit(req);
1434 1436
1435 dprintk("NFS: commit (%s/%lld %d@%lld)", 1437 dprintk("NFS: commit (%s/%lld %d@%lld)",
1436 req->wb_context->path.dentry->d_inode->i_sb->s_id, 1438 req->wb_context->dentry->d_sb->s_id,
1437 (long long)NFS_FILEID(req->wb_context->path.dentry->d_inode), 1439 (long long)NFS_FILEID(req->wb_context->dentry->d_inode),
1438 req->wb_bytes, 1440 req->wb_bytes,
1439 (long long)req_offset(req)); 1441 (long long)req_offset(req));
1440 if (status < 0) { 1442 if (status < 0) {