diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-15 13:46:05 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-15 13:47:35 -0400 |
commit | f4921aff5b174349bc36551f142a5dbac782ea3f (patch) | |
tree | bdff8ca1531977ad1d04ac8d70e10f8dfbb26c38 /fs | |
parent | 419217cb1d0266f62cbea6cdc6b1d1324350bc34 (diff) | |
parent | 05c88babab957dfd63bd351b25042d80bd854dd0 (diff) |
Merge git://git.linux-nfs.org/pub/linux/nfs-2.6
* git://git.linux-nfs.org/pub/linux/nfs-2.6: (131 commits)
NFSv4: Fix a typo in nfs_inode_reclaim_delegation
NFS: Add a boot parameter to disable 64 bit inode numbers
NFS: nfs_refresh_inode should clear cache_validity flags on success
NFS: Fix a connectathon regression in NFSv3 and NFSv4
NFS: Use nfs_refresh_inode() in ops that aren't expected to change the inode
SUNRPC: Don't call xprt_release in call refresh
SUNRPC: Don't call xprt_release() if call_allocate fails
SUNRPC: Fix buggy UDP transmission
[23/37] Clean up duplicate includes in
[2.6 patch] net/sunrpc/rpcb_clnt.c: make struct rpcb_program static
SUNRPC: Use correct type in buffer length calculations
SUNRPC: Fix default hostname created in rpc_create()
nfs: add server port to rpc_pipe info file
NFS: Get rid of some obsolete macros
NFS: Simplify filehandle revalidation
NFS: Ensure that nfs_link() returns a hashed dentry
NFS: Be strict about dentry revalidation when doing exclusive create
NFS: Don't zap the readdir caches upon error
NFS: Remove the redundant nfs_reval_fsid()
NFSv3: Always use directory post-op attributes in nfs3_proc_lookup
...
Fix up trivial conflict due to sock_owned_by_user() cleanup manually in
net/sunrpc/xprtsock.c
Diffstat (limited to 'fs')
-rw-r--r-- | fs/Kconfig | 8 | ||||
-rw-r--r-- | fs/lockd/mon.c | 3 | ||||
-rw-r--r-- | fs/lockd/xdr.c | 8 | ||||
-rw-r--r-- | fs/lockd/xdr4.c | 8 | ||||
-rw-r--r-- | fs/nfs/Makefile | 1 | ||||
-rw-r--r-- | fs/nfs/client.c | 49 | ||||
-rw-r--r-- | fs/nfs/delegation.c | 6 | ||||
-rw-r--r-- | fs/nfs/dir.c | 263 | ||||
-rw-r--r-- | fs/nfs/direct.c | 8 | ||||
-rw-r--r-- | fs/nfs/file.c | 105 | ||||
-rw-r--r-- | fs/nfs/inode.c | 273 | ||||
-rw-r--r-- | fs/nfs/internal.h | 50 | ||||
-rw-r--r-- | fs/nfs/nfs2xdr.c | 20 | ||||
-rw-r--r-- | fs/nfs/nfs3acl.c | 2 | ||||
-rw-r--r-- | fs/nfs/nfs3proc.c | 17 | ||||
-rw-r--r-- | fs/nfs/nfs3xdr.c | 25 | ||||
-rw-r--r-- | fs/nfs/nfs4proc.c | 85 | ||||
-rw-r--r-- | fs/nfs/nfs4state.c | 2 | ||||
-rw-r--r-- | fs/nfs/nfs4xdr.c | 72 | ||||
-rw-r--r-- | fs/nfs/nfsroot.c | 3 | ||||
-rw-r--r-- | fs/nfs/proc.c | 5 | ||||
-rw-r--r-- | fs/nfs/read.c | 9 | ||||
-rw-r--r-- | fs/nfs/super.c | 393 | ||||
-rw-r--r-- | fs/nfs/unlink.c | 3 | ||||
-rw-r--r-- | fs/nfs/write.c | 199 | ||||
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 16 |
26 files changed, 787 insertions, 846 deletions
diff --git a/fs/Kconfig b/fs/Kconfig index bb02b39380a3..815d201d8600 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
@@ -1755,6 +1755,14 @@ config SUNRPC | |||
1755 | config SUNRPC_GSS | 1755 | config SUNRPC_GSS |
1756 | tristate | 1756 | tristate |
1757 | 1757 | ||
1758 | config SUNRPC_XPRT_RDMA | ||
1759 | tristate "RDMA transport for sunrpc (EXPERIMENTAL)" | ||
1760 | depends on SUNRPC && INFINIBAND && EXPERIMENTAL | ||
1761 | default m | ||
1762 | help | ||
1763 | Adds a client RPC transport for supporting kernel NFS over RDMA | ||
1764 | mounts, including Infiniband and iWARP. Experimental. | ||
1765 | |||
1758 | config SUNRPC_BIND34 | 1766 | config SUNRPC_BIND34 |
1759 | bool "Support for rpcbind versions 3 & 4 (EXPERIMENTAL)" | 1767 | bool "Support for rpcbind versions 3 & 4 (EXPERIMENTAL)" |
1760 | depends on SUNRPC && EXPERIMENTAL | 1768 | depends on SUNRPC && EXPERIMENTAL |
diff --git a/fs/lockd/mon.c b/fs/lockd/mon.c index 3353ed8421a7..908b23fadd05 100644 --- a/fs/lockd/mon.c +++ b/fs/lockd/mon.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/utsname.h> | 10 | #include <linux/utsname.h> |
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/sunrpc/clnt.h> | 12 | #include <linux/sunrpc/clnt.h> |
13 | #include <linux/sunrpc/xprtsock.h> | ||
13 | #include <linux/sunrpc/svc.h> | 14 | #include <linux/sunrpc/svc.h> |
14 | #include <linux/lockd/lockd.h> | 15 | #include <linux/lockd/lockd.h> |
15 | #include <linux/lockd/sm_inter.h> | 16 | #include <linux/lockd/sm_inter.h> |
@@ -132,7 +133,7 @@ nsm_create(void) | |||
132 | .sin_port = 0, | 133 | .sin_port = 0, |
133 | }; | 134 | }; |
134 | struct rpc_create_args args = { | 135 | struct rpc_create_args args = { |
135 | .protocol = IPPROTO_UDP, | 136 | .protocol = XPRT_TRANSPORT_UDP, |
136 | .address = (struct sockaddr *)&sin, | 137 | .address = (struct sockaddr *)&sin, |
137 | .addrsize = sizeof(sin), | 138 | .addrsize = sizeof(sin), |
138 | .servername = "localhost", | 139 | .servername = "localhost", |
diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c index 5316e307a49d..633653bff944 100644 --- a/fs/lockd/xdr.c +++ b/fs/lockd/xdr.c | |||
@@ -62,8 +62,9 @@ static __be32 *nlm_decode_cookie(__be32 *p, struct nlm_cookie *c) | |||
62 | } | 62 | } |
63 | else | 63 | else |
64 | { | 64 | { |
65 | printk(KERN_NOTICE | 65 | dprintk("lockd: bad cookie size %d (only cookies under " |
66 | "lockd: bad cookie size %d (only cookies under %d bytes are supported.)\n", len, NLM_MAXCOOKIELEN); | 66 | "%d bytes are supported.)\n", |
67 | len, NLM_MAXCOOKIELEN); | ||
67 | return NULL; | 68 | return NULL; |
68 | } | 69 | } |
69 | return p; | 70 | return p; |
@@ -84,8 +85,7 @@ nlm_decode_fh(__be32 *p, struct nfs_fh *f) | |||
84 | unsigned int len; | 85 | unsigned int len; |
85 | 86 | ||
86 | if ((len = ntohl(*p++)) != NFS2_FHSIZE) { | 87 | if ((len = ntohl(*p++)) != NFS2_FHSIZE) { |
87 | printk(KERN_NOTICE | 88 | dprintk("lockd: bad fhandle size %d (should be %d)\n", |
88 | "lockd: bad fhandle size %d (should be %d)\n", | ||
89 | len, NFS2_FHSIZE); | 89 | len, NFS2_FHSIZE); |
90 | return NULL; | 90 | return NULL; |
91 | } | 91 | } |
diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c index 846fc1d639dd..43ff9397e6c6 100644 --- a/fs/lockd/xdr4.c +++ b/fs/lockd/xdr4.c | |||
@@ -64,8 +64,9 @@ nlm4_decode_cookie(__be32 *p, struct nlm_cookie *c) | |||
64 | } | 64 | } |
65 | else | 65 | else |
66 | { | 66 | { |
67 | printk(KERN_NOTICE | 67 | dprintk("lockd: bad cookie size %d (only cookies under " |
68 | "lockd: bad cookie size %d (only cookies under %d bytes are supported.)\n", len, NLM_MAXCOOKIELEN); | 68 | "%d bytes are supported.)\n", |
69 | len, NLM_MAXCOOKIELEN); | ||
69 | return NULL; | 70 | return NULL; |
70 | } | 71 | } |
71 | return p; | 72 | return p; |
@@ -86,8 +87,7 @@ nlm4_decode_fh(__be32 *p, struct nfs_fh *f) | |||
86 | memset(f->data, 0, sizeof(f->data)); | 87 | memset(f->data, 0, sizeof(f->data)); |
87 | f->size = ntohl(*p++); | 88 | f->size = ntohl(*p++); |
88 | if (f->size > NFS_MAXFHSIZE) { | 89 | if (f->size > NFS_MAXFHSIZE) { |
89 | printk(KERN_NOTICE | 90 | dprintk("lockd: bad fhandle size %d (should be <=%d)\n", |
90 | "lockd: bad fhandle size %d (should be <=%d)\n", | ||
91 | f->size, NFS_MAXFHSIZE); | 91 | f->size, NFS_MAXFHSIZE); |
92 | return NULL; | 92 | return NULL; |
93 | } | 93 | } |
diff --git a/fs/nfs/Makefile b/fs/nfs/Makefile index b55cb236cf74..df0f41e09885 100644 --- a/fs/nfs/Makefile +++ b/fs/nfs/Makefile | |||
@@ -16,4 +16,3 @@ nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \ | |||
16 | nfs4namespace.o | 16 | nfs4namespace.o |
17 | nfs-$(CONFIG_NFS_DIRECTIO) += direct.o | 17 | nfs-$(CONFIG_NFS_DIRECTIO) += direct.o |
18 | nfs-$(CONFIG_SYSCTL) += sysctl.o | 18 | nfs-$(CONFIG_SYSCTL) += sysctl.o |
19 | nfs-objs := $(nfs-y) | ||
diff --git a/fs/nfs/client.c b/fs/nfs/client.c index a204484072f3..a532ee12740a 100644 --- a/fs/nfs/client.c +++ b/fs/nfs/client.c | |||
@@ -23,6 +23,8 @@ | |||
23 | #include <linux/sunrpc/clnt.h> | 23 | #include <linux/sunrpc/clnt.h> |
24 | #include <linux/sunrpc/stats.h> | 24 | #include <linux/sunrpc/stats.h> |
25 | #include <linux/sunrpc/metrics.h> | 25 | #include <linux/sunrpc/metrics.h> |
26 | #include <linux/sunrpc/xprtsock.h> | ||
27 | #include <linux/sunrpc/xprtrdma.h> | ||
26 | #include <linux/nfs_fs.h> | 28 | #include <linux/nfs_fs.h> |
27 | #include <linux/nfs_mount.h> | 29 | #include <linux/nfs_mount.h> |
28 | #include <linux/nfs4_mount.h> | 30 | #include <linux/nfs4_mount.h> |
@@ -340,7 +342,8 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, | |||
340 | to->to_retries = 2; | 342 | to->to_retries = 2; |
341 | 343 | ||
342 | switch (proto) { | 344 | switch (proto) { |
343 | case IPPROTO_TCP: | 345 | case XPRT_TRANSPORT_TCP: |
346 | case XPRT_TRANSPORT_RDMA: | ||
344 | if (!to->to_initval) | 347 | if (!to->to_initval) |
345 | to->to_initval = 60 * HZ; | 348 | to->to_initval = 60 * HZ; |
346 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) | 349 | if (to->to_initval > NFS_MAX_TCP_TIMEOUT) |
@@ -349,7 +352,7 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, | |||
349 | to->to_maxval = to->to_initval + (to->to_increment * to->to_retries); | 352 | to->to_maxval = to->to_initval + (to->to_increment * to->to_retries); |
350 | to->to_exponential = 0; | 353 | to->to_exponential = 0; |
351 | break; | 354 | break; |
352 | case IPPROTO_UDP: | 355 | case XPRT_TRANSPORT_UDP: |
353 | default: | 356 | default: |
354 | if (!to->to_initval) | 357 | if (!to->to_initval) |
355 | to->to_initval = 11 * HZ / 10; | 358 | to->to_initval = 11 * HZ / 10; |
@@ -501,9 +504,9 @@ static int nfs_init_server_rpcclient(struct nfs_server *server, rpc_authflavor_t | |||
501 | /* | 504 | /* |
502 | * Initialise an NFS2 or NFS3 client | 505 | * Initialise an NFS2 or NFS3 client |
503 | */ | 506 | */ |
504 | static int nfs_init_client(struct nfs_client *clp, const struct nfs_mount_data *data) | 507 | static int nfs_init_client(struct nfs_client *clp, |
508 | const struct nfs_parsed_mount_data *data) | ||
505 | { | 509 | { |
506 | int proto = (data->flags & NFS_MOUNT_TCP) ? IPPROTO_TCP : IPPROTO_UDP; | ||
507 | int error; | 510 | int error; |
508 | 511 | ||
509 | if (clp->cl_cons_state == NFS_CS_READY) { | 512 | if (clp->cl_cons_state == NFS_CS_READY) { |
@@ -522,8 +525,8 @@ static int nfs_init_client(struct nfs_client *clp, const struct nfs_mount_data * | |||
522 | * Create a client RPC handle for doing FSSTAT with UNIX auth only | 525 | * Create a client RPC handle for doing FSSTAT with UNIX auth only |
523 | * - RFC 2623, sec 2.3.2 | 526 | * - RFC 2623, sec 2.3.2 |
524 | */ | 527 | */ |
525 | error = nfs_create_rpc_client(clp, proto, data->timeo, data->retrans, | 528 | error = nfs_create_rpc_client(clp, data->nfs_server.protocol, |
526 | RPC_AUTH_UNIX, 0); | 529 | data->timeo, data->retrans, RPC_AUTH_UNIX, 0); |
527 | if (error < 0) | 530 | if (error < 0) |
528 | goto error; | 531 | goto error; |
529 | nfs_mark_client_ready(clp, NFS_CS_READY); | 532 | nfs_mark_client_ready(clp, NFS_CS_READY); |
@@ -538,7 +541,8 @@ error: | |||
538 | /* | 541 | /* |
539 | * Create a version 2 or 3 client | 542 | * Create a version 2 or 3 client |
540 | */ | 543 | */ |
541 | static int nfs_init_server(struct nfs_server *server, const struct nfs_mount_data *data) | 544 | static int nfs_init_server(struct nfs_server *server, |
545 | const struct nfs_parsed_mount_data *data) | ||
542 | { | 546 | { |
543 | struct nfs_client *clp; | 547 | struct nfs_client *clp; |
544 | int error, nfsvers = 2; | 548 | int error, nfsvers = 2; |
@@ -551,7 +555,8 @@ static int nfs_init_server(struct nfs_server *server, const struct nfs_mount_dat | |||
551 | #endif | 555 | #endif |
552 | 556 | ||
553 | /* Allocate or find a client reference we can use */ | 557 | /* Allocate or find a client reference we can use */ |
554 | clp = nfs_get_client(data->hostname, &data->addr, nfsvers); | 558 | clp = nfs_get_client(data->nfs_server.hostname, |
559 | &data->nfs_server.address, nfsvers); | ||
555 | if (IS_ERR(clp)) { | 560 | if (IS_ERR(clp)) { |
556 | dprintk("<-- nfs_init_server() = error %ld\n", PTR_ERR(clp)); | 561 | dprintk("<-- nfs_init_server() = error %ld\n", PTR_ERR(clp)); |
557 | return PTR_ERR(clp); | 562 | return PTR_ERR(clp); |
@@ -581,7 +586,7 @@ static int nfs_init_server(struct nfs_server *server, const struct nfs_mount_dat | |||
581 | if (error < 0) | 586 | if (error < 0) |
582 | goto error; | 587 | goto error; |
583 | 588 | ||
584 | error = nfs_init_server_rpcclient(server, data->pseudoflavor); | 589 | error = nfs_init_server_rpcclient(server, data->auth_flavors[0]); |
585 | if (error < 0) | 590 | if (error < 0) |
586 | goto error; | 591 | goto error; |
587 | 592 | ||
@@ -760,7 +765,7 @@ void nfs_free_server(struct nfs_server *server) | |||
760 | * Create a version 2 or 3 volume record | 765 | * Create a version 2 or 3 volume record |
761 | * - keyed on server and FSID | 766 | * - keyed on server and FSID |
762 | */ | 767 | */ |
763 | struct nfs_server *nfs_create_server(const struct nfs_mount_data *data, | 768 | struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, |
764 | struct nfs_fh *mntfh) | 769 | struct nfs_fh *mntfh) |
765 | { | 770 | { |
766 | struct nfs_server *server; | 771 | struct nfs_server *server; |
@@ -906,7 +911,7 @@ error: | |||
906 | * Create a version 4 volume record | 911 | * Create a version 4 volume record |
907 | */ | 912 | */ |
908 | static int nfs4_init_server(struct nfs_server *server, | 913 | static int nfs4_init_server(struct nfs_server *server, |
909 | const struct nfs4_mount_data *data, rpc_authflavor_t authflavour) | 914 | const struct nfs_parsed_mount_data *data) |
910 | { | 915 | { |
911 | int error; | 916 | int error; |
912 | 917 | ||
@@ -926,7 +931,7 @@ static int nfs4_init_server(struct nfs_server *server, | |||
926 | server->acdirmin = data->acdirmin * HZ; | 931 | server->acdirmin = data->acdirmin * HZ; |
927 | server->acdirmax = data->acdirmax * HZ; | 932 | server->acdirmax = data->acdirmax * HZ; |
928 | 933 | ||
929 | error = nfs_init_server_rpcclient(server, authflavour); | 934 | error = nfs_init_server_rpcclient(server, data->auth_flavors[0]); |
930 | 935 | ||
931 | /* Done */ | 936 | /* Done */ |
932 | dprintk("<-- nfs4_init_server() = %d\n", error); | 937 | dprintk("<-- nfs4_init_server() = %d\n", error); |
@@ -937,12 +942,7 @@ static int nfs4_init_server(struct nfs_server *server, | |||
937 | * Create a version 4 volume record | 942 | * Create a version 4 volume record |
938 | * - keyed on server and FSID | 943 | * - keyed on server and FSID |
939 | */ | 944 | */ |
940 | struct nfs_server *nfs4_create_server(const struct nfs4_mount_data *data, | 945 | struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data, |
941 | const char *hostname, | ||
942 | const struct sockaddr_in *addr, | ||
943 | const char *mntpath, | ||
944 | const char *ip_addr, | ||
945 | rpc_authflavor_t authflavour, | ||
946 | struct nfs_fh *mntfh) | 946 | struct nfs_fh *mntfh) |
947 | { | 947 | { |
948 | struct nfs_fattr fattr; | 948 | struct nfs_fattr fattr; |
@@ -956,13 +956,18 @@ struct nfs_server *nfs4_create_server(const struct nfs4_mount_data *data, | |||
956 | return ERR_PTR(-ENOMEM); | 956 | return ERR_PTR(-ENOMEM); |
957 | 957 | ||
958 | /* Get a client record */ | 958 | /* Get a client record */ |
959 | error = nfs4_set_client(server, hostname, addr, ip_addr, authflavour, | 959 | error = nfs4_set_client(server, |
960 | data->proto, data->timeo, data->retrans); | 960 | data->nfs_server.hostname, |
961 | &data->nfs_server.address, | ||
962 | data->client_address, | ||
963 | data->auth_flavors[0], | ||
964 | data->nfs_server.protocol, | ||
965 | data->timeo, data->retrans); | ||
961 | if (error < 0) | 966 | if (error < 0) |
962 | goto error; | 967 | goto error; |
963 | 968 | ||
964 | /* set up the general RPC client */ | 969 | /* set up the general RPC client */ |
965 | error = nfs4_init_server(server, data, authflavour); | 970 | error = nfs4_init_server(server, data); |
966 | if (error < 0) | 971 | if (error < 0) |
967 | goto error; | 972 | goto error; |
968 | 973 | ||
@@ -971,7 +976,7 @@ struct nfs_server *nfs4_create_server(const struct nfs4_mount_data *data, | |||
971 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); | 976 | BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops); |
972 | 977 | ||
973 | /* Probe the root fh to retrieve its FSID */ | 978 | /* Probe the root fh to retrieve its FSID */ |
974 | error = nfs4_path_walk(server, mntfh, mntpath); | 979 | error = nfs4_path_walk(server, mntfh, data->nfs_server.export_path); |
975 | if (error < 0) | 980 | if (error < 0) |
976 | goto error; | 981 | goto error; |
977 | 982 | ||
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index c55a761c22bb..af8b235d405d 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c | |||
@@ -52,7 +52,7 @@ static int nfs_delegation_claim_locks(struct nfs_open_context *ctx, struct nfs4_ | |||
52 | for (fl = inode->i_flock; fl != 0; fl = fl->fl_next) { | 52 | for (fl = inode->i_flock; fl != 0; fl = fl->fl_next) { |
53 | if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) | 53 | if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) |
54 | continue; | 54 | continue; |
55 | if ((struct nfs_open_context *)fl->fl_file->private_data != ctx) | 55 | if (nfs_file_open_context(fl->fl_file) != ctx) |
56 | continue; | 56 | continue; |
57 | status = nfs4_lock_delegation_recall(state, fl); | 57 | status = nfs4_lock_delegation_recall(state, fl); |
58 | if (status >= 0) | 58 | if (status >= 0) |
@@ -109,6 +109,7 @@ again: | |||
109 | void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res) | 109 | void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res) |
110 | { | 110 | { |
111 | struct nfs_delegation *delegation = NFS_I(inode)->delegation; | 111 | struct nfs_delegation *delegation = NFS_I(inode)->delegation; |
112 | struct rpc_cred *oldcred; | ||
112 | 113 | ||
113 | if (delegation == NULL) | 114 | if (delegation == NULL) |
114 | return; | 115 | return; |
@@ -116,11 +117,12 @@ void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, st | |||
116 | sizeof(delegation->stateid.data)); | 117 | sizeof(delegation->stateid.data)); |
117 | delegation->type = res->delegation_type; | 118 | delegation->type = res->delegation_type; |
118 | delegation->maxsize = res->maxsize; | 119 | delegation->maxsize = res->maxsize; |
119 | put_rpccred(cred); | 120 | oldcred = delegation->cred; |
120 | delegation->cred = get_rpccred(cred); | 121 | delegation->cred = get_rpccred(cred); |
121 | delegation->flags &= ~NFS_DELEGATION_NEED_RECLAIM; | 122 | delegation->flags &= ~NFS_DELEGATION_NEED_RECLAIM; |
122 | NFS_I(inode)->delegation_state = delegation->type; | 123 | NFS_I(inode)->delegation_state = delegation->type; |
123 | smp_wmb(); | 124 | smp_wmb(); |
125 | put_rpccred(oldcred); | ||
124 | } | 126 | } |
125 | 127 | ||
126 | /* | 128 | /* |
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index e4a04d16b8b0..8ec7fbd8240c 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c | |||
@@ -200,9 +200,6 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page) | |||
200 | desc->timestamp = timestamp; | 200 | desc->timestamp = timestamp; |
201 | desc->timestamp_valid = 1; | 201 | desc->timestamp_valid = 1; |
202 | SetPageUptodate(page); | 202 | SetPageUptodate(page); |
203 | spin_lock(&inode->i_lock); | ||
204 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME; | ||
205 | spin_unlock(&inode->i_lock); | ||
206 | /* Ensure consistent page alignment of the data. | 203 | /* Ensure consistent page alignment of the data. |
207 | * Note: assumes we have exclusive access to this mapping either | 204 | * Note: assumes we have exclusive access to this mapping either |
208 | * through inode->i_mutex or some other mechanism. | 205 | * through inode->i_mutex or some other mechanism. |
@@ -214,9 +211,7 @@ int nfs_readdir_filler(nfs_readdir_descriptor_t *desc, struct page *page) | |||
214 | unlock_page(page); | 211 | unlock_page(page); |
215 | return 0; | 212 | return 0; |
216 | error: | 213 | error: |
217 | SetPageError(page); | ||
218 | unlock_page(page); | 214 | unlock_page(page); |
219 | nfs_zap_caches(inode); | ||
220 | desc->error = error; | 215 | desc->error = error; |
221 | return -EIO; | 216 | return -EIO; |
222 | } | 217 | } |
@@ -407,7 +402,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent, | |||
407 | struct file *file = desc->file; | 402 | struct file *file = desc->file; |
408 | struct nfs_entry *entry = desc->entry; | 403 | struct nfs_entry *entry = desc->entry; |
409 | struct dentry *dentry = NULL; | 404 | struct dentry *dentry = NULL; |
410 | unsigned long fileid; | 405 | u64 fileid; |
411 | int loop_count = 0, | 406 | int loop_count = 0, |
412 | res; | 407 | res; |
413 | 408 | ||
@@ -418,7 +413,7 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent, | |||
418 | unsigned d_type = DT_UNKNOWN; | 413 | unsigned d_type = DT_UNKNOWN; |
419 | /* Note: entry->prev_cookie contains the cookie for | 414 | /* Note: entry->prev_cookie contains the cookie for |
420 | * retrieving the current dirent on the server */ | 415 | * retrieving the current dirent on the server */ |
421 | fileid = nfs_fileid_to_ino_t(entry->ino); | 416 | fileid = entry->ino; |
422 | 417 | ||
423 | /* Get a dentry if we have one */ | 418 | /* Get a dentry if we have one */ |
424 | if (dentry != NULL) | 419 | if (dentry != NULL) |
@@ -428,11 +423,12 @@ int nfs_do_filldir(nfs_readdir_descriptor_t *desc, void *dirent, | |||
428 | /* Use readdirplus info */ | 423 | /* Use readdirplus info */ |
429 | if (dentry != NULL && dentry->d_inode != NULL) { | 424 | if (dentry != NULL && dentry->d_inode != NULL) { |
430 | d_type = dt_type(dentry->d_inode); | 425 | d_type = dt_type(dentry->d_inode); |
431 | fileid = dentry->d_inode->i_ino; | 426 | fileid = NFS_FILEID(dentry->d_inode); |
432 | } | 427 | } |
433 | 428 | ||
434 | res = filldir(dirent, entry->name, entry->len, | 429 | res = filldir(dirent, entry->name, entry->len, |
435 | file->f_pos, fileid, d_type); | 430 | file->f_pos, nfs_compat_user_ino64(fileid), |
431 | d_type); | ||
436 | if (res < 0) | 432 | if (res < 0) |
437 | break; | 433 | break; |
438 | file->f_pos++; | 434 | file->f_pos++; |
@@ -490,9 +486,6 @@ int uncached_readdir(nfs_readdir_descriptor_t *desc, void *dirent, | |||
490 | page, | 486 | page, |
491 | NFS_SERVER(inode)->dtsize, | 487 | NFS_SERVER(inode)->dtsize, |
492 | desc->plus); | 488 | desc->plus); |
493 | spin_lock(&inode->i_lock); | ||
494 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME; | ||
495 | spin_unlock(&inode->i_lock); | ||
496 | desc->page = page; | 489 | desc->page = page; |
497 | desc->ptr = kmap(page); /* matching kunmap in nfs_do_filldir */ | 490 | desc->ptr = kmap(page); /* matching kunmap in nfs_do_filldir */ |
498 | if (desc->error >= 0) { | 491 | if (desc->error >= 0) { |
@@ -558,7 +551,7 @@ static int nfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
558 | memset(desc, 0, sizeof(*desc)); | 551 | memset(desc, 0, sizeof(*desc)); |
559 | 552 | ||
560 | desc->file = filp; | 553 | desc->file = filp; |
561 | desc->dir_cookie = &((struct nfs_open_context *)filp->private_data)->dir_cookie; | 554 | desc->dir_cookie = &nfs_file_open_context(filp)->dir_cookie; |
562 | desc->decode = NFS_PROTO(inode)->decode_dirent; | 555 | desc->decode = NFS_PROTO(inode)->decode_dirent; |
563 | desc->plus = NFS_USE_READDIRPLUS(inode); | 556 | desc->plus = NFS_USE_READDIRPLUS(inode); |
564 | 557 | ||
@@ -623,7 +616,7 @@ static loff_t nfs_llseek_dir(struct file *filp, loff_t offset, int origin) | |||
623 | } | 616 | } |
624 | if (offset != filp->f_pos) { | 617 | if (offset != filp->f_pos) { |
625 | filp->f_pos = offset; | 618 | filp->f_pos = offset; |
626 | ((struct nfs_open_context *)filp->private_data)->dir_cookie = 0; | 619 | nfs_file_open_context(filp)->dir_cookie = 0; |
627 | } | 620 | } |
628 | out: | 621 | out: |
629 | mutex_unlock(&filp->f_path.dentry->d_inode->i_mutex); | 622 | mutex_unlock(&filp->f_path.dentry->d_inode->i_mutex); |
@@ -650,36 +643,18 @@ static int nfs_fsync_dir(struct file *filp, struct dentry *dentry, int datasync) | |||
650 | */ | 643 | */ |
651 | static int nfs_check_verifier(struct inode *dir, struct dentry *dentry) | 644 | static int nfs_check_verifier(struct inode *dir, struct dentry *dentry) |
652 | { | 645 | { |
653 | unsigned long verf; | ||
654 | |||
655 | if (IS_ROOT(dentry)) | 646 | if (IS_ROOT(dentry)) |
656 | return 1; | 647 | return 1; |
657 | verf = dentry->d_time; | 648 | if (!nfs_verify_change_attribute(dir, dentry->d_time)) |
658 | if (nfs_caches_unstable(dir) | 649 | return 0; |
659 | || verf != NFS_I(dir)->cache_change_attribute) | 650 | /* Revalidate nfsi->cache_change_attribute before we declare a match */ |
651 | if (nfs_revalidate_inode(NFS_SERVER(dir), dir) < 0) | ||
652 | return 0; | ||
653 | if (!nfs_verify_change_attribute(dir, dentry->d_time)) | ||
660 | return 0; | 654 | return 0; |
661 | return 1; | 655 | return 1; |
662 | } | 656 | } |
663 | 657 | ||
664 | static inline void nfs_set_verifier(struct dentry * dentry, unsigned long verf) | ||
665 | { | ||
666 | dentry->d_time = verf; | ||
667 | } | ||
668 | |||
669 | static void nfs_refresh_verifier(struct dentry * dentry, unsigned long verf) | ||
670 | { | ||
671 | nfs_set_verifier(dentry, verf); | ||
672 | } | ||
673 | |||
674 | /* | ||
675 | * Whenever an NFS operation succeeds, we know that the dentry | ||
676 | * is valid, so we update the revalidation timestamp. | ||
677 | */ | ||
678 | static inline void nfs_renew_times(struct dentry * dentry) | ||
679 | { | ||
680 | dentry->d_time = jiffies; | ||
681 | } | ||
682 | |||
683 | /* | 658 | /* |
684 | * Return the intent data that applies to this particular path component | 659 | * Return the intent data that applies to this particular path component |
685 | * | 660 | * |
@@ -695,6 +670,19 @@ static inline unsigned int nfs_lookup_check_intent(struct nameidata *nd, unsigne | |||
695 | } | 670 | } |
696 | 671 | ||
697 | /* | 672 | /* |
673 | * Use intent information to check whether or not we're going to do | ||
674 | * an O_EXCL create using this path component. | ||
675 | */ | ||
676 | static int nfs_is_exclusive_create(struct inode *dir, struct nameidata *nd) | ||
677 | { | ||
678 | if (NFS_PROTO(dir)->version == 2) | ||
679 | return 0; | ||
680 | if (nd == NULL || nfs_lookup_check_intent(nd, LOOKUP_CREATE) == 0) | ||
681 | return 0; | ||
682 | return (nd->intent.open.flags & O_EXCL) != 0; | ||
683 | } | ||
684 | |||
685 | /* | ||
698 | * Inode and filehandle revalidation for lookups. | 686 | * Inode and filehandle revalidation for lookups. |
699 | * | 687 | * |
700 | * We force revalidation in the cases where the VFS sets LOOKUP_REVAL, | 688 | * We force revalidation in the cases where the VFS sets LOOKUP_REVAL, |
@@ -717,6 +705,7 @@ int nfs_lookup_verify_inode(struct inode *inode, struct nameidata *nd) | |||
717 | (S_ISREG(inode->i_mode) || | 705 | (S_ISREG(inode->i_mode) || |
718 | S_ISDIR(inode->i_mode))) | 706 | S_ISDIR(inode->i_mode))) |
719 | goto out_force; | 707 | goto out_force; |
708 | return 0; | ||
720 | } | 709 | } |
721 | return nfs_revalidate_inode(server, inode); | 710 | return nfs_revalidate_inode(server, inode); |
722 | out_force: | 711 | out_force: |
@@ -759,7 +748,6 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
759 | int error; | 748 | int error; |
760 | struct nfs_fh fhandle; | 749 | struct nfs_fh fhandle; |
761 | struct nfs_fattr fattr; | 750 | struct nfs_fattr fattr; |
762 | unsigned long verifier; | ||
763 | 751 | ||
764 | parent = dget_parent(dentry); | 752 | parent = dget_parent(dentry); |
765 | lock_kernel(); | 753 | lock_kernel(); |
@@ -767,10 +755,6 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
767 | nfs_inc_stats(dir, NFSIOS_DENTRYREVALIDATE); | 755 | nfs_inc_stats(dir, NFSIOS_DENTRYREVALIDATE); |
768 | inode = dentry->d_inode; | 756 | inode = dentry->d_inode; |
769 | 757 | ||
770 | /* Revalidate parent directory attribute cache */ | ||
771 | if (nfs_revalidate_inode(NFS_SERVER(dir), dir) < 0) | ||
772 | goto out_zap_parent; | ||
773 | |||
774 | if (!inode) { | 758 | if (!inode) { |
775 | if (nfs_neg_need_reval(dir, dentry, nd)) | 759 | if (nfs_neg_need_reval(dir, dentry, nd)) |
776 | goto out_bad; | 760 | goto out_bad; |
@@ -785,7 +769,7 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
785 | } | 769 | } |
786 | 770 | ||
787 | /* Force a full look up iff the parent directory has changed */ | 771 | /* Force a full look up iff the parent directory has changed */ |
788 | if (nfs_check_verifier(dir, dentry)) { | 772 | if (!nfs_is_exclusive_create(dir, nd) && nfs_check_verifier(dir, dentry)) { |
789 | if (nfs_lookup_verify_inode(inode, nd)) | 773 | if (nfs_lookup_verify_inode(inode, nd)) |
790 | goto out_zap_parent; | 774 | goto out_zap_parent; |
791 | goto out_valid; | 775 | goto out_valid; |
@@ -794,7 +778,6 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
794 | if (NFS_STALE(inode)) | 778 | if (NFS_STALE(inode)) |
795 | goto out_bad; | 779 | goto out_bad; |
796 | 780 | ||
797 | verifier = nfs_save_change_attribute(dir); | ||
798 | error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, &fhandle, &fattr); | 781 | error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, &fhandle, &fattr); |
799 | if (error) | 782 | if (error) |
800 | goto out_bad; | 783 | goto out_bad; |
@@ -803,8 +786,7 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
803 | if ((error = nfs_refresh_inode(inode, &fattr)) != 0) | 786 | if ((error = nfs_refresh_inode(inode, &fattr)) != 0) |
804 | goto out_bad; | 787 | goto out_bad; |
805 | 788 | ||
806 | nfs_renew_times(dentry); | 789 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
807 | nfs_refresh_verifier(dentry, verifier); | ||
808 | out_valid: | 790 | out_valid: |
809 | unlock_kernel(); | 791 | unlock_kernel(); |
810 | dput(parent); | 792 | dput(parent); |
@@ -815,7 +797,7 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd) | |||
815 | out_zap_parent: | 797 | out_zap_parent: |
816 | nfs_zap_caches(dir); | 798 | nfs_zap_caches(dir); |
817 | out_bad: | 799 | out_bad: |
818 | NFS_CACHEINV(dir); | 800 | nfs_mark_for_revalidate(dir); |
819 | if (inode && S_ISDIR(inode->i_mode)) { | 801 | if (inode && S_ISDIR(inode->i_mode)) { |
820 | /* Purge readdir caches. */ | 802 | /* Purge readdir caches. */ |
821 | nfs_zap_caches(inode); | 803 | nfs_zap_caches(inode); |
@@ -872,8 +854,6 @@ static void nfs_dentry_iput(struct dentry *dentry, struct inode *inode) | |||
872 | nfs_complete_unlink(dentry, inode); | 854 | nfs_complete_unlink(dentry, inode); |
873 | unlock_kernel(); | 855 | unlock_kernel(); |
874 | } | 856 | } |
875 | /* When creating a negative dentry, we want to renew d_time */ | ||
876 | nfs_renew_times(dentry); | ||
877 | iput(inode); | 857 | iput(inode); |
878 | } | 858 | } |
879 | 859 | ||
@@ -883,30 +863,6 @@ struct dentry_operations nfs_dentry_operations = { | |||
883 | .d_iput = nfs_dentry_iput, | 863 | .d_iput = nfs_dentry_iput, |
884 | }; | 864 | }; |
885 | 865 | ||
886 | /* | ||
887 | * Use intent information to check whether or not we're going to do | ||
888 | * an O_EXCL create using this path component. | ||
889 | */ | ||
890 | static inline | ||
891 | int nfs_is_exclusive_create(struct inode *dir, struct nameidata *nd) | ||
892 | { | ||
893 | if (NFS_PROTO(dir)->version == 2) | ||
894 | return 0; | ||
895 | if (nd == NULL || nfs_lookup_check_intent(nd, LOOKUP_CREATE) == 0) | ||
896 | return 0; | ||
897 | return (nd->intent.open.flags & O_EXCL) != 0; | ||
898 | } | ||
899 | |||
900 | static inline int nfs_reval_fsid(struct inode *dir, const struct nfs_fattr *fattr) | ||
901 | { | ||
902 | struct nfs_server *server = NFS_SERVER(dir); | ||
903 | |||
904 | if (!nfs_fsid_equal(&server->fsid, &fattr->fsid)) | ||
905 | /* Revalidate fsid using the parent directory */ | ||
906 | return __nfs_revalidate_inode(server, dir); | ||
907 | return 0; | ||
908 | } | ||
909 | |||
910 | static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd) | 866 | static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd) |
911 | { | 867 | { |
912 | struct dentry *res; | 868 | struct dentry *res; |
@@ -945,11 +901,6 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru | |||
945 | res = ERR_PTR(error); | 901 | res = ERR_PTR(error); |
946 | goto out_unlock; | 902 | goto out_unlock; |
947 | } | 903 | } |
948 | error = nfs_reval_fsid(dir, &fattr); | ||
949 | if (error < 0) { | ||
950 | res = ERR_PTR(error); | ||
951 | goto out_unlock; | ||
952 | } | ||
953 | inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr); | 904 | inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr); |
954 | res = (struct dentry *)inode; | 905 | res = (struct dentry *)inode; |
955 | if (IS_ERR(res)) | 906 | if (IS_ERR(res)) |
@@ -958,17 +909,10 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru | |||
958 | no_entry: | 909 | no_entry: |
959 | res = d_materialise_unique(dentry, inode); | 910 | res = d_materialise_unique(dentry, inode); |
960 | if (res != NULL) { | 911 | if (res != NULL) { |
961 | struct dentry *parent; | ||
962 | if (IS_ERR(res)) | 912 | if (IS_ERR(res)) |
963 | goto out_unlock; | 913 | goto out_unlock; |
964 | /* Was a directory renamed! */ | ||
965 | parent = dget_parent(res); | ||
966 | if (!IS_ROOT(parent)) | ||
967 | nfs_mark_for_revalidate(parent->d_inode); | ||
968 | dput(parent); | ||
969 | dentry = res; | 914 | dentry = res; |
970 | } | 915 | } |
971 | nfs_renew_times(dentry); | ||
972 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 916 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
973 | out_unlock: | 917 | out_unlock: |
974 | unlock_kernel(); | 918 | unlock_kernel(); |
@@ -1020,28 +964,16 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry | |||
1020 | } | 964 | } |
1021 | dentry->d_op = NFS_PROTO(dir)->dentry_ops; | 965 | dentry->d_op = NFS_PROTO(dir)->dentry_ops; |
1022 | 966 | ||
1023 | /* Let vfs_create() deal with O_EXCL */ | 967 | /* Let vfs_create() deal with O_EXCL. Instantiate, but don't hash |
968 | * the dentry. */ | ||
1024 | if (nd->intent.open.flags & O_EXCL) { | 969 | if (nd->intent.open.flags & O_EXCL) { |
1025 | d_add(dentry, NULL); | 970 | d_instantiate(dentry, NULL); |
1026 | goto out; | 971 | goto out; |
1027 | } | 972 | } |
1028 | 973 | ||
1029 | /* Open the file on the server */ | 974 | /* Open the file on the server */ |
1030 | lock_kernel(); | 975 | lock_kernel(); |
1031 | /* Revalidate parent directory attribute cache */ | 976 | res = nfs4_atomic_open(dir, dentry, nd); |
1032 | error = nfs_revalidate_inode(NFS_SERVER(dir), dir); | ||
1033 | if (error < 0) { | ||
1034 | res = ERR_PTR(error); | ||
1035 | unlock_kernel(); | ||
1036 | goto out; | ||
1037 | } | ||
1038 | |||
1039 | if (nd->intent.open.flags & O_CREAT) { | ||
1040 | nfs_begin_data_update(dir); | ||
1041 | res = nfs4_atomic_open(dir, dentry, nd); | ||
1042 | nfs_end_data_update(dir); | ||
1043 | } else | ||
1044 | res = nfs4_atomic_open(dir, dentry, nd); | ||
1045 | unlock_kernel(); | 977 | unlock_kernel(); |
1046 | if (IS_ERR(res)) { | 978 | if (IS_ERR(res)) { |
1047 | error = PTR_ERR(res); | 979 | error = PTR_ERR(res); |
@@ -1063,8 +995,6 @@ static struct dentry *nfs_atomic_lookup(struct inode *dir, struct dentry *dentry | |||
1063 | } | 995 | } |
1064 | } else if (res != NULL) | 996 | } else if (res != NULL) |
1065 | dentry = res; | 997 | dentry = res; |
1066 | nfs_renew_times(dentry); | ||
1067 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | ||
1068 | out: | 998 | out: |
1069 | return res; | 999 | return res; |
1070 | no_open: | 1000 | no_open: |
@@ -1076,7 +1006,6 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1076 | struct dentry *parent = NULL; | 1006 | struct dentry *parent = NULL; |
1077 | struct inode *inode = dentry->d_inode; | 1007 | struct inode *inode = dentry->d_inode; |
1078 | struct inode *dir; | 1008 | struct inode *dir; |
1079 | unsigned long verifier; | ||
1080 | int openflags, ret = 0; | 1009 | int openflags, ret = 0; |
1081 | 1010 | ||
1082 | parent = dget_parent(dentry); | 1011 | parent = dget_parent(dentry); |
@@ -1086,8 +1015,12 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1086 | /* We can't create new files in nfs_open_revalidate(), so we | 1015 | /* We can't create new files in nfs_open_revalidate(), so we |
1087 | * optimize away revalidation of negative dentries. | 1016 | * optimize away revalidation of negative dentries. |
1088 | */ | 1017 | */ |
1089 | if (inode == NULL) | 1018 | if (inode == NULL) { |
1019 | if (!nfs_neg_need_reval(dir, dentry, nd)) | ||
1020 | ret = 1; | ||
1090 | goto out; | 1021 | goto out; |
1022 | } | ||
1023 | |||
1091 | /* NFS only supports OPEN on regular files */ | 1024 | /* NFS only supports OPEN on regular files */ |
1092 | if (!S_ISREG(inode->i_mode)) | 1025 | if (!S_ISREG(inode->i_mode)) |
1093 | goto no_open; | 1026 | goto no_open; |
@@ -1104,10 +1037,7 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd) | |||
1104 | * change attribute *before* we do the RPC call. | 1037 | * change attribute *before* we do the RPC call. |
1105 | */ | 1038 | */ |
1106 | lock_kernel(); | 1039 | lock_kernel(); |
1107 | verifier = nfs_save_change_attribute(dir); | ||
1108 | ret = nfs4_open_revalidate(dir, dentry, openflags, nd); | 1040 | ret = nfs4_open_revalidate(dir, dentry, openflags, nd); |
1109 | if (!ret) | ||
1110 | nfs_refresh_verifier(dentry, verifier); | ||
1111 | unlock_kernel(); | 1041 | unlock_kernel(); |
1112 | out: | 1042 | out: |
1113 | dput(parent); | 1043 | dput(parent); |
@@ -1133,6 +1063,7 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc) | |||
1133 | .len = entry->len, | 1063 | .len = entry->len, |
1134 | }; | 1064 | }; |
1135 | struct inode *inode; | 1065 | struct inode *inode; |
1066 | unsigned long verf = nfs_save_change_attribute(dir); | ||
1136 | 1067 | ||
1137 | switch (name.len) { | 1068 | switch (name.len) { |
1138 | case 2: | 1069 | case 2: |
@@ -1143,6 +1074,14 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc) | |||
1143 | if (name.name[0] == '.') | 1074 | if (name.name[0] == '.') |
1144 | return dget(parent); | 1075 | return dget(parent); |
1145 | } | 1076 | } |
1077 | |||
1078 | spin_lock(&dir->i_lock); | ||
1079 | if (NFS_I(dir)->cache_validity & NFS_INO_INVALID_DATA) { | ||
1080 | spin_unlock(&dir->i_lock); | ||
1081 | return NULL; | ||
1082 | } | ||
1083 | spin_unlock(&dir->i_lock); | ||
1084 | |||
1146 | name.hash = full_name_hash(name.name, name.len); | 1085 | name.hash = full_name_hash(name.name, name.len); |
1147 | dentry = d_lookup(parent, &name); | 1086 | dentry = d_lookup(parent, &name); |
1148 | if (dentry != NULL) { | 1087 | if (dentry != NULL) { |
@@ -1183,12 +1122,8 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc) | |||
1183 | dentry = alias; | 1122 | dentry = alias; |
1184 | } | 1123 | } |
1185 | 1124 | ||
1186 | nfs_renew_times(dentry); | ||
1187 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | ||
1188 | return dentry; | ||
1189 | out_renew: | 1125 | out_renew: |
1190 | nfs_renew_times(dentry); | 1126 | nfs_set_verifier(dentry, verf); |
1191 | nfs_refresh_verifier(dentry, nfs_save_change_attribute(dir)); | ||
1192 | return dentry; | 1127 | return dentry; |
1193 | } | 1128 | } |
1194 | 1129 | ||
@@ -1198,32 +1133,40 @@ out_renew: | |||
1198 | int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle, | 1133 | int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle, |
1199 | struct nfs_fattr *fattr) | 1134 | struct nfs_fattr *fattr) |
1200 | { | 1135 | { |
1136 | struct dentry *parent = dget_parent(dentry); | ||
1137 | struct inode *dir = parent->d_inode; | ||
1201 | struct inode *inode; | 1138 | struct inode *inode; |
1202 | int error = -EACCES; | 1139 | int error = -EACCES; |
1203 | 1140 | ||
1141 | d_drop(dentry); | ||
1142 | |||
1204 | /* We may have been initialized further down */ | 1143 | /* We may have been initialized further down */ |
1205 | if (dentry->d_inode) | 1144 | if (dentry->d_inode) |
1206 | return 0; | 1145 | goto out; |
1207 | if (fhandle->size == 0) { | 1146 | if (fhandle->size == 0) { |
1208 | struct inode *dir = dentry->d_parent->d_inode; | ||
1209 | error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr); | 1147 | error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr); |
1210 | if (error) | 1148 | if (error) |
1211 | return error; | 1149 | goto out_error; |
1212 | } | 1150 | } |
1151 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | ||
1213 | if (!(fattr->valid & NFS_ATTR_FATTR)) { | 1152 | if (!(fattr->valid & NFS_ATTR_FATTR)) { |
1214 | struct nfs_server *server = NFS_SB(dentry->d_sb); | 1153 | struct nfs_server *server = NFS_SB(dentry->d_sb); |
1215 | error = server->nfs_client->rpc_ops->getattr(server, fhandle, fattr); | 1154 | error = server->nfs_client->rpc_ops->getattr(server, fhandle, fattr); |
1216 | if (error < 0) | 1155 | if (error < 0) |
1217 | return error; | 1156 | goto out_error; |
1218 | } | 1157 | } |
1219 | inode = nfs_fhget(dentry->d_sb, fhandle, fattr); | 1158 | inode = nfs_fhget(dentry->d_sb, fhandle, fattr); |
1220 | error = PTR_ERR(inode); | 1159 | error = PTR_ERR(inode); |
1221 | if (IS_ERR(inode)) | 1160 | if (IS_ERR(inode)) |
1222 | return error; | 1161 | goto out_error; |
1223 | d_instantiate(dentry, inode); | 1162 | d_add(dentry, inode); |
1224 | if (d_unhashed(dentry)) | 1163 | out: |
1225 | d_rehash(dentry); | 1164 | dput(parent); |
1226 | return 0; | 1165 | return 0; |
1166 | out_error: | ||
1167 | nfs_mark_for_revalidate(dir); | ||
1168 | dput(parent); | ||
1169 | return error; | ||
1227 | } | 1170 | } |
1228 | 1171 | ||
1229 | /* | 1172 | /* |
@@ -1249,13 +1192,9 @@ static int nfs_create(struct inode *dir, struct dentry *dentry, int mode, | |||
1249 | open_flags = nd->intent.open.flags; | 1192 | open_flags = nd->intent.open.flags; |
1250 | 1193 | ||
1251 | lock_kernel(); | 1194 | lock_kernel(); |
1252 | nfs_begin_data_update(dir); | ||
1253 | error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, nd); | 1195 | error = NFS_PROTO(dir)->create(dir, dentry, &attr, open_flags, nd); |
1254 | nfs_end_data_update(dir); | ||
1255 | if (error != 0) | 1196 | if (error != 0) |
1256 | goto out_err; | 1197 | goto out_err; |
1257 | nfs_renew_times(dentry); | ||
1258 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | ||
1259 | unlock_kernel(); | 1198 | unlock_kernel(); |
1260 | return 0; | 1199 | return 0; |
1261 | out_err: | 1200 | out_err: |
@@ -1283,13 +1222,9 @@ nfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) | |||
1283 | attr.ia_valid = ATTR_MODE; | 1222 | attr.ia_valid = ATTR_MODE; |
1284 | 1223 | ||
1285 | lock_kernel(); | 1224 | lock_kernel(); |
1286 | nfs_begin_data_update(dir); | ||
1287 | status = NFS_PROTO(dir)->mknod(dir, dentry, &attr, rdev); | 1225 | status = NFS_PROTO(dir)->mknod(dir, dentry, &attr, rdev); |
1288 | nfs_end_data_update(dir); | ||
1289 | if (status != 0) | 1226 | if (status != 0) |
1290 | goto out_err; | 1227 | goto out_err; |
1291 | nfs_renew_times(dentry); | ||
1292 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | ||
1293 | unlock_kernel(); | 1228 | unlock_kernel(); |
1294 | return 0; | 1229 | return 0; |
1295 | out_err: | 1230 | out_err: |
@@ -1313,13 +1248,9 @@ static int nfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
1313 | attr.ia_mode = mode | S_IFDIR; | 1248 | attr.ia_mode = mode | S_IFDIR; |
1314 | 1249 | ||
1315 | lock_kernel(); | 1250 | lock_kernel(); |
1316 | nfs_begin_data_update(dir); | ||
1317 | error = NFS_PROTO(dir)->mkdir(dir, dentry, &attr); | 1251 | error = NFS_PROTO(dir)->mkdir(dir, dentry, &attr); |
1318 | nfs_end_data_update(dir); | ||
1319 | if (error != 0) | 1252 | if (error != 0) |
1320 | goto out_err; | 1253 | goto out_err; |
1321 | nfs_renew_times(dentry); | ||
1322 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | ||
1323 | unlock_kernel(); | 1254 | unlock_kernel(); |
1324 | return 0; | 1255 | return 0; |
1325 | out_err: | 1256 | out_err: |
@@ -1336,12 +1267,10 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
1336 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); | 1267 | dir->i_sb->s_id, dir->i_ino, dentry->d_name.name); |
1337 | 1268 | ||
1338 | lock_kernel(); | 1269 | lock_kernel(); |
1339 | nfs_begin_data_update(dir); | ||
1340 | error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); | 1270 | error = NFS_PROTO(dir)->rmdir(dir, &dentry->d_name); |
1341 | /* Ensure the VFS deletes this inode */ | 1271 | /* Ensure the VFS deletes this inode */ |
1342 | if (error == 0 && dentry->d_inode != NULL) | 1272 | if (error == 0 && dentry->d_inode != NULL) |
1343 | clear_nlink(dentry->d_inode); | 1273 | clear_nlink(dentry->d_inode); |
1344 | nfs_end_data_update(dir); | ||
1345 | unlock_kernel(); | 1274 | unlock_kernel(); |
1346 | 1275 | ||
1347 | return error; | 1276 | return error; |
@@ -1350,9 +1279,9 @@ static int nfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
1350 | static int nfs_sillyrename(struct inode *dir, struct dentry *dentry) | 1279 | static int nfs_sillyrename(struct inode *dir, struct dentry *dentry) |
1351 | { | 1280 | { |
1352 | static unsigned int sillycounter; | 1281 | static unsigned int sillycounter; |
1353 | const int i_inosize = sizeof(dir->i_ino)*2; | 1282 | const int fileidsize = sizeof(NFS_FILEID(dentry->d_inode))*2; |
1354 | const int countersize = sizeof(sillycounter)*2; | 1283 | const int countersize = sizeof(sillycounter)*2; |
1355 | const int slen = sizeof(".nfs") + i_inosize + countersize - 1; | 1284 | const int slen = sizeof(".nfs")+fileidsize+countersize-1; |
1356 | char silly[slen+1]; | 1285 | char silly[slen+1]; |
1357 | struct qstr qsilly; | 1286 | struct qstr qsilly; |
1358 | struct dentry *sdentry; | 1287 | struct dentry *sdentry; |
@@ -1370,8 +1299,9 @@ static int nfs_sillyrename(struct inode *dir, struct dentry *dentry) | |||
1370 | if (dentry->d_flags & DCACHE_NFSFS_RENAMED) | 1299 | if (dentry->d_flags & DCACHE_NFSFS_RENAMED) |
1371 | goto out; | 1300 | goto out; |
1372 | 1301 | ||
1373 | sprintf(silly, ".nfs%*.*lx", | 1302 | sprintf(silly, ".nfs%*.*Lx", |
1374 | i_inosize, i_inosize, dentry->d_inode->i_ino); | 1303 | fileidsize, fileidsize, |
1304 | (unsigned long long)NFS_FILEID(dentry->d_inode)); | ||
1375 | 1305 | ||
1376 | /* Return delegation in anticipation of the rename */ | 1306 | /* Return delegation in anticipation of the rename */ |
1377 | nfs_inode_return_delegation(dentry->d_inode); | 1307 | nfs_inode_return_delegation(dentry->d_inode); |
@@ -1398,19 +1328,14 @@ static int nfs_sillyrename(struct inode *dir, struct dentry *dentry) | |||
1398 | 1328 | ||
1399 | qsilly.name = silly; | 1329 | qsilly.name = silly; |
1400 | qsilly.len = strlen(silly); | 1330 | qsilly.len = strlen(silly); |
1401 | nfs_begin_data_update(dir); | ||
1402 | if (dentry->d_inode) { | 1331 | if (dentry->d_inode) { |
1403 | nfs_begin_data_update(dentry->d_inode); | ||
1404 | error = NFS_PROTO(dir)->rename(dir, &dentry->d_name, | 1332 | error = NFS_PROTO(dir)->rename(dir, &dentry->d_name, |
1405 | dir, &qsilly); | 1333 | dir, &qsilly); |
1406 | nfs_mark_for_revalidate(dentry->d_inode); | 1334 | nfs_mark_for_revalidate(dentry->d_inode); |
1407 | nfs_end_data_update(dentry->d_inode); | ||
1408 | } else | 1335 | } else |
1409 | error = NFS_PROTO(dir)->rename(dir, &dentry->d_name, | 1336 | error = NFS_PROTO(dir)->rename(dir, &dentry->d_name, |
1410 | dir, &qsilly); | 1337 | dir, &qsilly); |
1411 | nfs_end_data_update(dir); | ||
1412 | if (!error) { | 1338 | if (!error) { |
1413 | nfs_renew_times(dentry); | ||
1414 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 1339 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
1415 | d_move(dentry, sdentry); | 1340 | d_move(dentry, sdentry); |
1416 | error = nfs_async_unlink(dir, dentry); | 1341 | error = nfs_async_unlink(dir, dentry); |
@@ -1443,19 +1368,15 @@ static int nfs_safe_remove(struct dentry *dentry) | |||
1443 | goto out; | 1368 | goto out; |
1444 | } | 1369 | } |
1445 | 1370 | ||
1446 | nfs_begin_data_update(dir); | ||
1447 | if (inode != NULL) { | 1371 | if (inode != NULL) { |
1448 | nfs_inode_return_delegation(inode); | 1372 | nfs_inode_return_delegation(inode); |
1449 | nfs_begin_data_update(inode); | ||
1450 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); | 1373 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); |
1451 | /* The VFS may want to delete this inode */ | 1374 | /* The VFS may want to delete this inode */ |
1452 | if (error == 0) | 1375 | if (error == 0) |
1453 | drop_nlink(inode); | 1376 | drop_nlink(inode); |
1454 | nfs_mark_for_revalidate(inode); | 1377 | nfs_mark_for_revalidate(inode); |
1455 | nfs_end_data_update(inode); | ||
1456 | } else | 1378 | } else |
1457 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); | 1379 | error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); |
1458 | nfs_end_data_update(dir); | ||
1459 | out: | 1380 | out: |
1460 | return error; | 1381 | return error; |
1461 | } | 1382 | } |
@@ -1493,7 +1414,6 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry) | |||
1493 | spin_unlock(&dcache_lock); | 1414 | spin_unlock(&dcache_lock); |
1494 | error = nfs_safe_remove(dentry); | 1415 | error = nfs_safe_remove(dentry); |
1495 | if (!error) { | 1416 | if (!error) { |
1496 | nfs_renew_times(dentry); | ||
1497 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | 1417 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); |
1498 | } else if (need_rehash) | 1418 | } else if (need_rehash) |
1499 | d_rehash(dentry); | 1419 | d_rehash(dentry); |
@@ -1548,9 +1468,7 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym | |||
1548 | memset(kaddr + pathlen, 0, PAGE_SIZE - pathlen); | 1468 | memset(kaddr + pathlen, 0, PAGE_SIZE - pathlen); |
1549 | kunmap_atomic(kaddr, KM_USER0); | 1469 | kunmap_atomic(kaddr, KM_USER0); |
1550 | 1470 | ||
1551 | nfs_begin_data_update(dir); | ||
1552 | error = NFS_PROTO(dir)->symlink(dir, dentry, page, pathlen, &attr); | 1471 | error = NFS_PROTO(dir)->symlink(dir, dentry, page, pathlen, &attr); |
1553 | nfs_end_data_update(dir); | ||
1554 | if (error != 0) { | 1472 | if (error != 0) { |
1555 | dfprintk(VFS, "NFS: symlink(%s/%ld, %s, %s) error %d\n", | 1473 | dfprintk(VFS, "NFS: symlink(%s/%ld, %s, %s) error %d\n", |
1556 | dir->i_sb->s_id, dir->i_ino, | 1474 | dir->i_sb->s_id, dir->i_ino, |
@@ -1590,15 +1508,12 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) | |||
1590 | dentry->d_parent->d_name.name, dentry->d_name.name); | 1508 | dentry->d_parent->d_name.name, dentry->d_name.name); |
1591 | 1509 | ||
1592 | lock_kernel(); | 1510 | lock_kernel(); |
1593 | nfs_begin_data_update(dir); | 1511 | d_drop(dentry); |
1594 | nfs_begin_data_update(inode); | ||
1595 | error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); | 1512 | error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); |
1596 | if (error == 0) { | 1513 | if (error == 0) { |
1597 | atomic_inc(&inode->i_count); | 1514 | atomic_inc(&inode->i_count); |
1598 | d_instantiate(dentry, inode); | 1515 | d_add(dentry, inode); |
1599 | } | 1516 | } |
1600 | nfs_end_data_update(inode); | ||
1601 | nfs_end_data_update(dir); | ||
1602 | unlock_kernel(); | 1517 | unlock_kernel(); |
1603 | return error; | 1518 | return error; |
1604 | } | 1519 | } |
@@ -1701,22 +1616,16 @@ go_ahead: | |||
1701 | d_delete(new_dentry); | 1616 | d_delete(new_dentry); |
1702 | } | 1617 | } |
1703 | 1618 | ||
1704 | nfs_begin_data_update(old_dir); | ||
1705 | nfs_begin_data_update(new_dir); | ||
1706 | nfs_begin_data_update(old_inode); | ||
1707 | error = NFS_PROTO(old_dir)->rename(old_dir, &old_dentry->d_name, | 1619 | error = NFS_PROTO(old_dir)->rename(old_dir, &old_dentry->d_name, |
1708 | new_dir, &new_dentry->d_name); | 1620 | new_dir, &new_dentry->d_name); |
1709 | nfs_mark_for_revalidate(old_inode); | 1621 | nfs_mark_for_revalidate(old_inode); |
1710 | nfs_end_data_update(old_inode); | ||
1711 | nfs_end_data_update(new_dir); | ||
1712 | nfs_end_data_update(old_dir); | ||
1713 | out: | 1622 | out: |
1714 | if (rehash) | 1623 | if (rehash) |
1715 | d_rehash(rehash); | 1624 | d_rehash(rehash); |
1716 | if (!error) { | 1625 | if (!error) { |
1717 | d_move(old_dentry, new_dentry); | 1626 | d_move(old_dentry, new_dentry); |
1718 | nfs_renew_times(new_dentry); | 1627 | nfs_set_verifier(new_dentry, |
1719 | nfs_refresh_verifier(new_dentry, nfs_save_change_attribute(new_dir)); | 1628 | nfs_save_change_attribute(new_dir)); |
1720 | } | 1629 | } |
1721 | 1630 | ||
1722 | /* new dentry created? */ | 1631 | /* new dentry created? */ |
@@ -1842,7 +1751,7 @@ static struct nfs_access_entry *nfs_access_search_rbtree(struct inode *inode, st | |||
1842 | return NULL; | 1751 | return NULL; |
1843 | } | 1752 | } |
1844 | 1753 | ||
1845 | int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs_access_entry *res) | 1754 | static int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs_access_entry *res) |
1846 | { | 1755 | { |
1847 | struct nfs_inode *nfsi = NFS_I(inode); | 1756 | struct nfs_inode *nfsi = NFS_I(inode); |
1848 | struct nfs_access_entry *cache; | 1757 | struct nfs_access_entry *cache; |
@@ -1854,7 +1763,7 @@ int nfs_access_get_cached(struct inode *inode, struct rpc_cred *cred, struct nfs | |||
1854 | cache = nfs_access_search_rbtree(inode, cred); | 1763 | cache = nfs_access_search_rbtree(inode, cred); |
1855 | if (cache == NULL) | 1764 | if (cache == NULL) |
1856 | goto out; | 1765 | goto out; |
1857 | if (time_after(jiffies, cache->jiffies + NFS_ATTRTIMEO(inode))) | 1766 | if (!time_in_range(jiffies, cache->jiffies, cache->jiffies + nfsi->attrtimeo)) |
1858 | goto out_stale; | 1767 | goto out_stale; |
1859 | res->jiffies = cache->jiffies; | 1768 | res->jiffies = cache->jiffies; |
1860 | res->cred = cache->cred; | 1769 | res->cred = cache->cred; |
@@ -1909,7 +1818,7 @@ found: | |||
1909 | nfs_access_free_entry(entry); | 1818 | nfs_access_free_entry(entry); |
1910 | } | 1819 | } |
1911 | 1820 | ||
1912 | void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set) | 1821 | static void nfs_access_add_cache(struct inode *inode, struct nfs_access_entry *set) |
1913 | { | 1822 | { |
1914 | struct nfs_access_entry *cache = kmalloc(sizeof(*cache), GFP_KERNEL); | 1823 | struct nfs_access_entry *cache = kmalloc(sizeof(*cache), GFP_KERNEL); |
1915 | if (cache == NULL) | 1824 | if (cache == NULL) |
@@ -1957,6 +1866,24 @@ out: | |||
1957 | return -EACCES; | 1866 | return -EACCES; |
1958 | } | 1867 | } |
1959 | 1868 | ||
1869 | static int nfs_open_permission_mask(int openflags) | ||
1870 | { | ||
1871 | int mask = 0; | ||
1872 | |||
1873 | if (openflags & FMODE_READ) | ||
1874 | mask |= MAY_READ; | ||
1875 | if (openflags & FMODE_WRITE) | ||
1876 | mask |= MAY_WRITE; | ||
1877 | if (openflags & FMODE_EXEC) | ||
1878 | mask |= MAY_EXEC; | ||
1879 | return mask; | ||
1880 | } | ||
1881 | |||
1882 | int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags) | ||
1883 | { | ||
1884 | return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags)); | ||
1885 | } | ||
1886 | |||
1960 | int nfs_permission(struct inode *inode, int mask, struct nameidata *nd) | 1887 | int nfs_permission(struct inode *inode, int mask, struct nameidata *nd) |
1961 | { | 1888 | { |
1962 | struct rpc_cred *cred; | 1889 | struct rpc_cred *cred; |
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index fcf4d384610e..32fe97211eea 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
@@ -368,7 +368,7 @@ static ssize_t nfs_direct_read(struct kiocb *iocb, unsigned long user_addr, size | |||
368 | return -ENOMEM; | 368 | return -ENOMEM; |
369 | 369 | ||
370 | dreq->inode = inode; | 370 | dreq->inode = inode; |
371 | dreq->ctx = get_nfs_open_context((struct nfs_open_context *)iocb->ki_filp->private_data); | 371 | dreq->ctx = get_nfs_open_context(nfs_file_open_context(iocb->ki_filp)); |
372 | if (!is_sync_kiocb(iocb)) | 372 | if (!is_sync_kiocb(iocb)) |
373 | dreq->iocb = iocb; | 373 | dreq->iocb = iocb; |
374 | 374 | ||
@@ -510,7 +510,6 @@ static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode | |||
510 | nfs_direct_write_reschedule(dreq); | 510 | nfs_direct_write_reschedule(dreq); |
511 | break; | 511 | break; |
512 | default: | 512 | default: |
513 | nfs_end_data_update(inode); | ||
514 | if (dreq->commit_data != NULL) | 513 | if (dreq->commit_data != NULL) |
515 | nfs_commit_free(dreq->commit_data); | 514 | nfs_commit_free(dreq->commit_data); |
516 | nfs_direct_free_writedata(dreq); | 515 | nfs_direct_free_writedata(dreq); |
@@ -533,7 +532,6 @@ static inline void nfs_alloc_commit_data(struct nfs_direct_req *dreq) | |||
533 | 532 | ||
534 | static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode *inode) | 533 | static void nfs_direct_write_complete(struct nfs_direct_req *dreq, struct inode *inode) |
535 | { | 534 | { |
536 | nfs_end_data_update(inode); | ||
537 | nfs_direct_free_writedata(dreq); | 535 | nfs_direct_free_writedata(dreq); |
538 | nfs_zap_mapping(inode, inode->i_mapping); | 536 | nfs_zap_mapping(inode, inode->i_mapping); |
539 | nfs_direct_complete(dreq); | 537 | nfs_direct_complete(dreq); |
@@ -718,14 +716,12 @@ static ssize_t nfs_direct_write(struct kiocb *iocb, unsigned long user_addr, siz | |||
718 | sync = FLUSH_STABLE; | 716 | sync = FLUSH_STABLE; |
719 | 717 | ||
720 | dreq->inode = inode; | 718 | dreq->inode = inode; |
721 | dreq->ctx = get_nfs_open_context((struct nfs_open_context *)iocb->ki_filp->private_data); | 719 | dreq->ctx = get_nfs_open_context(nfs_file_open_context(iocb->ki_filp)); |
722 | if (!is_sync_kiocb(iocb)) | 720 | if (!is_sync_kiocb(iocb)) |
723 | dreq->iocb = iocb; | 721 | dreq->iocb = iocb; |
724 | 722 | ||
725 | nfs_add_stats(inode, NFSIOS_DIRECTWRITTENBYTES, count); | 723 | nfs_add_stats(inode, NFSIOS_DIRECTWRITTENBYTES, count); |
726 | 724 | ||
727 | nfs_begin_data_update(inode); | ||
728 | |||
729 | rpc_clnt_sigmask(clnt, &oldset); | 725 | rpc_clnt_sigmask(clnt, &oldset); |
730 | result = nfs_direct_write_schedule(dreq, user_addr, count, pos, sync); | 726 | result = nfs_direct_write_schedule(dreq, user_addr, count, pos, sync); |
731 | if (!result) | 727 | if (!result) |
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 579cf8a7d4a7..c664bb921425 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <asm/system.h> | 33 | #include <asm/system.h> |
34 | 34 | ||
35 | #include "delegation.h" | 35 | #include "delegation.h" |
36 | #include "internal.h" | ||
36 | #include "iostat.h" | 37 | #include "iostat.h" |
37 | 38 | ||
38 | #define NFSDBG_FACILITY NFSDBG_FILE | 39 | #define NFSDBG_FACILITY NFSDBG_FILE |
@@ -55,6 +56,8 @@ static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl); | |||
55 | static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl); | 56 | static int nfs_flock(struct file *filp, int cmd, struct file_lock *fl); |
56 | static int nfs_setlease(struct file *file, long arg, struct file_lock **fl); | 57 | static int nfs_setlease(struct file *file, long arg, struct file_lock **fl); |
57 | 58 | ||
59 | static struct vm_operations_struct nfs_file_vm_ops; | ||
60 | |||
58 | const struct file_operations nfs_file_operations = { | 61 | const struct file_operations nfs_file_operations = { |
59 | .llseek = nfs_file_llseek, | 62 | .llseek = nfs_file_llseek, |
60 | .read = do_sync_read, | 63 | .read = do_sync_read, |
@@ -174,13 +177,38 @@ static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) | |||
174 | } | 177 | } |
175 | 178 | ||
176 | /* | 179 | /* |
180 | * Helper for nfs_file_flush() and nfs_fsync() | ||
181 | * | ||
182 | * Notice that it clears the NFS_CONTEXT_ERROR_WRITE before synching to | ||
183 | * disk, but it retrieves and clears ctx->error after synching, despite | ||
184 | * the two being set at the same time in nfs_context_set_write_error(). | ||
185 | * This is because the former is used to notify the _next_ call to | ||
186 | * nfs_file_write() that a write error occured, and hence cause it to | ||
187 | * fall back to doing a synchronous write. | ||
188 | */ | ||
189 | static int nfs_do_fsync(struct nfs_open_context *ctx, struct inode *inode) | ||
190 | { | ||
191 | int have_error, status; | ||
192 | int ret = 0; | ||
193 | |||
194 | have_error = test_and_clear_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags); | ||
195 | status = nfs_wb_all(inode); | ||
196 | have_error |= test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags); | ||
197 | if (have_error) | ||
198 | ret = xchg(&ctx->error, 0); | ||
199 | if (!ret) | ||
200 | ret = status; | ||
201 | return ret; | ||
202 | } | ||
203 | |||
204 | /* | ||
177 | * Flush all dirty pages, and check for write errors. | 205 | * Flush all dirty pages, and check for write errors. |
178 | * | 206 | * |
179 | */ | 207 | */ |
180 | static int | 208 | static int |
181 | nfs_file_flush(struct file *file, fl_owner_t id) | 209 | nfs_file_flush(struct file *file, fl_owner_t id) |
182 | { | 210 | { |
183 | struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data; | 211 | struct nfs_open_context *ctx = nfs_file_open_context(file); |
184 | struct inode *inode = file->f_path.dentry->d_inode; | 212 | struct inode *inode = file->f_path.dentry->d_inode; |
185 | int status; | 213 | int status; |
186 | 214 | ||
@@ -189,16 +217,11 @@ nfs_file_flush(struct file *file, fl_owner_t id) | |||
189 | if ((file->f_mode & FMODE_WRITE) == 0) | 217 | if ((file->f_mode & FMODE_WRITE) == 0) |
190 | return 0; | 218 | return 0; |
191 | nfs_inc_stats(inode, NFSIOS_VFSFLUSH); | 219 | nfs_inc_stats(inode, NFSIOS_VFSFLUSH); |
192 | lock_kernel(); | 220 | |
193 | /* Ensure that data+attribute caches are up to date after close() */ | 221 | /* Ensure that data+attribute caches are up to date after close() */ |
194 | status = nfs_wb_all(inode); | 222 | status = nfs_do_fsync(ctx, inode); |
195 | if (!status) { | 223 | if (!status) |
196 | status = ctx->error; | 224 | nfs_revalidate_inode(NFS_SERVER(inode), inode); |
197 | ctx->error = 0; | ||
198 | if (!status) | ||
199 | nfs_revalidate_inode(NFS_SERVER(inode), inode); | ||
200 | } | ||
201 | unlock_kernel(); | ||
202 | return status; | 225 | return status; |
203 | } | 226 | } |
204 | 227 | ||
@@ -257,8 +280,11 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma) | |||
257 | dentry->d_parent->d_name.name, dentry->d_name.name); | 280 | dentry->d_parent->d_name.name, dentry->d_name.name); |
258 | 281 | ||
259 | status = nfs_revalidate_mapping(inode, file->f_mapping); | 282 | status = nfs_revalidate_mapping(inode, file->f_mapping); |
260 | if (!status) | 283 | if (!status) { |
261 | status = generic_file_mmap(file, vma); | 284 | vma->vm_ops = &nfs_file_vm_ops; |
285 | vma->vm_flags |= VM_CAN_NONLINEAR; | ||
286 | file_accessed(file); | ||
287 | } | ||
262 | return status; | 288 | return status; |
263 | } | 289 | } |
264 | 290 | ||
@@ -270,21 +296,13 @@ nfs_file_mmap(struct file * file, struct vm_area_struct * vma) | |||
270 | static int | 296 | static int |
271 | nfs_fsync(struct file *file, struct dentry *dentry, int datasync) | 297 | nfs_fsync(struct file *file, struct dentry *dentry, int datasync) |
272 | { | 298 | { |
273 | struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data; | 299 | struct nfs_open_context *ctx = nfs_file_open_context(file); |
274 | struct inode *inode = dentry->d_inode; | 300 | struct inode *inode = dentry->d_inode; |
275 | int status; | ||
276 | 301 | ||
277 | dfprintk(VFS, "nfs: fsync(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino); | 302 | dfprintk(VFS, "nfs: fsync(%s/%ld)\n", inode->i_sb->s_id, inode->i_ino); |
278 | 303 | ||
279 | nfs_inc_stats(inode, NFSIOS_VFSFSYNC); | 304 | nfs_inc_stats(inode, NFSIOS_VFSFSYNC); |
280 | lock_kernel(); | 305 | return nfs_do_fsync(ctx, inode); |
281 | status = nfs_wb_all(inode); | ||
282 | if (!status) { | ||
283 | status = ctx->error; | ||
284 | ctx->error = 0; | ||
285 | } | ||
286 | unlock_kernel(); | ||
287 | return status; | ||
288 | } | 306 | } |
289 | 307 | ||
290 | /* | 308 | /* |
@@ -333,7 +351,7 @@ static int nfs_launder_page(struct page *page) | |||
333 | const struct address_space_operations nfs_file_aops = { | 351 | const struct address_space_operations nfs_file_aops = { |
334 | .readpage = nfs_readpage, | 352 | .readpage = nfs_readpage, |
335 | .readpages = nfs_readpages, | 353 | .readpages = nfs_readpages, |
336 | .set_page_dirty = nfs_set_page_dirty, | 354 | .set_page_dirty = __set_page_dirty_nobuffers, |
337 | .writepage = nfs_writepage, | 355 | .writepage = nfs_writepage, |
338 | .writepages = nfs_writepages, | 356 | .writepages = nfs_writepages, |
339 | .prepare_write = nfs_prepare_write, | 357 | .prepare_write = nfs_prepare_write, |
@@ -346,6 +364,43 @@ const struct address_space_operations nfs_file_aops = { | |||
346 | .launder_page = nfs_launder_page, | 364 | .launder_page = nfs_launder_page, |
347 | }; | 365 | }; |
348 | 366 | ||
367 | static int nfs_vm_page_mkwrite(struct vm_area_struct *vma, struct page *page) | ||
368 | { | ||
369 | struct file *filp = vma->vm_file; | ||
370 | unsigned pagelen; | ||
371 | int ret = -EINVAL; | ||
372 | |||
373 | lock_page(page); | ||
374 | if (page->mapping != vma->vm_file->f_path.dentry->d_inode->i_mapping) | ||
375 | goto out_unlock; | ||
376 | pagelen = nfs_page_length(page); | ||
377 | if (pagelen == 0) | ||
378 | goto out_unlock; | ||
379 | ret = nfs_prepare_write(filp, page, 0, pagelen); | ||
380 | if (!ret) | ||
381 | ret = nfs_commit_write(filp, page, 0, pagelen); | ||
382 | out_unlock: | ||
383 | unlock_page(page); | ||
384 | return ret; | ||
385 | } | ||
386 | |||
387 | static struct vm_operations_struct nfs_file_vm_ops = { | ||
388 | .fault = filemap_fault, | ||
389 | .page_mkwrite = nfs_vm_page_mkwrite, | ||
390 | }; | ||
391 | |||
392 | static int nfs_need_sync_write(struct file *filp, struct inode *inode) | ||
393 | { | ||
394 | struct nfs_open_context *ctx; | ||
395 | |||
396 | if (IS_SYNC(inode) || (filp->f_flags & O_SYNC)) | ||
397 | return 1; | ||
398 | ctx = nfs_file_open_context(filp); | ||
399 | if (test_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags)) | ||
400 | return 1; | ||
401 | return 0; | ||
402 | } | ||
403 | |||
349 | static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, | 404 | static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, |
350 | unsigned long nr_segs, loff_t pos) | 405 | unsigned long nr_segs, loff_t pos) |
351 | { | 406 | { |
@@ -382,8 +437,8 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, | |||
382 | nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count); | 437 | nfs_add_stats(inode, NFSIOS_NORMALWRITTENBYTES, count); |
383 | result = generic_file_aio_write(iocb, iov, nr_segs, pos); | 438 | result = generic_file_aio_write(iocb, iov, nr_segs, pos); |
384 | /* Return error values for O_SYNC and IS_SYNC() */ | 439 | /* Return error values for O_SYNC and IS_SYNC() */ |
385 | if (result >= 0 && (IS_SYNC(inode) || (iocb->ki_filp->f_flags & O_SYNC))) { | 440 | if (result >= 0 && nfs_need_sync_write(iocb->ki_filp, inode)) { |
386 | int err = nfs_fsync(iocb->ki_filp, dentry, 1); | 441 | int err = nfs_do_fsync(nfs_file_open_context(iocb->ki_filp), inode); |
387 | if (err < 0) | 442 | if (err < 0) |
388 | result = err; | 443 | result = err; |
389 | } | 444 | } |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 71a49c3acabd..035c769b715e 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -49,6 +49,11 @@ | |||
49 | 49 | ||
50 | #define NFSDBG_FACILITY NFSDBG_VFS | 50 | #define NFSDBG_FACILITY NFSDBG_VFS |
51 | 51 | ||
52 | #define NFS_64_BIT_INODE_NUMBERS_ENABLED 1 | ||
53 | |||
54 | /* Default is to see 64-bit inode numbers */ | ||
55 | static int enable_ino64 = NFS_64_BIT_INODE_NUMBERS_ENABLED; | ||
56 | |||
52 | static void nfs_invalidate_inode(struct inode *); | 57 | static void nfs_invalidate_inode(struct inode *); |
53 | static int nfs_update_inode(struct inode *, struct nfs_fattr *); | 58 | static int nfs_update_inode(struct inode *, struct nfs_fattr *); |
54 | 59 | ||
@@ -62,6 +67,25 @@ nfs_fattr_to_ino_t(struct nfs_fattr *fattr) | |||
62 | return nfs_fileid_to_ino_t(fattr->fileid); | 67 | return nfs_fileid_to_ino_t(fattr->fileid); |
63 | } | 68 | } |
64 | 69 | ||
70 | /** | ||
71 | * nfs_compat_user_ino64 - returns the user-visible inode number | ||
72 | * @fileid: 64-bit fileid | ||
73 | * | ||
74 | * This function returns a 32-bit inode number if the boot parameter | ||
75 | * nfs.enable_ino64 is zero. | ||
76 | */ | ||
77 | u64 nfs_compat_user_ino64(u64 fileid) | ||
78 | { | ||
79 | int ino; | ||
80 | |||
81 | if (enable_ino64) | ||
82 | return fileid; | ||
83 | ino = fileid; | ||
84 | if (sizeof(ino) < sizeof(fileid)) | ||
85 | ino ^= fileid >> (sizeof(fileid)-sizeof(ino)) * 8; | ||
86 | return ino; | ||
87 | } | ||
88 | |||
65 | int nfs_write_inode(struct inode *inode, int sync) | 89 | int nfs_write_inode(struct inode *inode, int sync) |
66 | { | 90 | { |
67 | int ret; | 91 | int ret; |
@@ -85,7 +109,6 @@ void nfs_clear_inode(struct inode *inode) | |||
85 | */ | 109 | */ |
86 | BUG_ON(nfs_have_writebacks(inode)); | 110 | BUG_ON(nfs_have_writebacks(inode)); |
87 | BUG_ON(!list_empty(&NFS_I(inode)->open_files)); | 111 | BUG_ON(!list_empty(&NFS_I(inode)->open_files)); |
88 | BUG_ON(atomic_read(&NFS_I(inode)->data_updates) != 0); | ||
89 | nfs_zap_acl_cache(inode); | 112 | nfs_zap_acl_cache(inode); |
90 | nfs_access_zap_cache(inode); | 113 | nfs_access_zap_cache(inode); |
91 | } | 114 | } |
@@ -118,8 +141,8 @@ static void nfs_zap_caches_locked(struct inode *inode) | |||
118 | 141 | ||
119 | nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE); | 142 | nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE); |
120 | 143 | ||
121 | NFS_ATTRTIMEO(inode) = NFS_MINATTRTIMEO(inode); | 144 | nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); |
122 | NFS_ATTRTIMEO_UPDATE(inode) = jiffies; | 145 | nfsi->attrtimeo_timestamp = jiffies; |
123 | 146 | ||
124 | memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode))); | 147 | memset(NFS_COOKIEVERF(inode), 0, sizeof(NFS_COOKIEVERF(inode))); |
125 | if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) | 148 | if (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode)) |
@@ -156,6 +179,13 @@ static void nfs_zap_acl_cache(struct inode *inode) | |||
156 | spin_unlock(&inode->i_lock); | 179 | spin_unlock(&inode->i_lock); |
157 | } | 180 | } |
158 | 181 | ||
182 | void nfs_invalidate_atime(struct inode *inode) | ||
183 | { | ||
184 | spin_lock(&inode->i_lock); | ||
185 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME; | ||
186 | spin_unlock(&inode->i_lock); | ||
187 | } | ||
188 | |||
159 | /* | 189 | /* |
160 | * Invalidate, but do not unhash, the inode. | 190 | * Invalidate, but do not unhash, the inode. |
161 | * NB: must be called with inode->i_lock held! | 191 | * NB: must be called with inode->i_lock held! |
@@ -338,7 +368,6 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
338 | return 0; | 368 | return 0; |
339 | 369 | ||
340 | lock_kernel(); | 370 | lock_kernel(); |
341 | nfs_begin_data_update(inode); | ||
342 | /* Write all dirty data */ | 371 | /* Write all dirty data */ |
343 | if (S_ISREG(inode->i_mode)) { | 372 | if (S_ISREG(inode->i_mode)) { |
344 | filemap_write_and_wait(inode->i_mapping); | 373 | filemap_write_and_wait(inode->i_mapping); |
@@ -352,7 +381,6 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
352 | error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); | 381 | error = NFS_PROTO(inode)->setattr(dentry, &fattr, attr); |
353 | if (error == 0) | 382 | if (error == 0) |
354 | nfs_refresh_inode(inode, &fattr); | 383 | nfs_refresh_inode(inode, &fattr); |
355 | nfs_end_data_update(inode); | ||
356 | unlock_kernel(); | 384 | unlock_kernel(); |
357 | return error; | 385 | return error; |
358 | } | 386 | } |
@@ -431,7 +459,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) | |||
431 | 459 | ||
432 | /* Flush out writes to the server in order to update c/mtime */ | 460 | /* Flush out writes to the server in order to update c/mtime */ |
433 | if (S_ISREG(inode->i_mode)) | 461 | if (S_ISREG(inode->i_mode)) |
434 | nfs_sync_mapping_range(inode->i_mapping, 0, 0, FLUSH_NOCOMMIT); | 462 | nfs_wb_nocommit(inode); |
435 | 463 | ||
436 | /* | 464 | /* |
437 | * We may force a getattr if the user cares about atime. | 465 | * We may force a getattr if the user cares about atime. |
@@ -450,8 +478,10 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) | |||
450 | err = __nfs_revalidate_inode(NFS_SERVER(inode), inode); | 478 | err = __nfs_revalidate_inode(NFS_SERVER(inode), inode); |
451 | else | 479 | else |
452 | err = nfs_revalidate_inode(NFS_SERVER(inode), inode); | 480 | err = nfs_revalidate_inode(NFS_SERVER(inode), inode); |
453 | if (!err) | 481 | if (!err) { |
454 | generic_fillattr(inode, stat); | 482 | generic_fillattr(inode, stat); |
483 | stat->ino = nfs_compat_user_ino64(NFS_FILEID(inode)); | ||
484 | } | ||
455 | return err; | 485 | return err; |
456 | } | 486 | } |
457 | 487 | ||
@@ -536,7 +566,7 @@ struct nfs_open_context *nfs_find_open_context(struct inode *inode, struct rpc_c | |||
536 | static void nfs_file_clear_open_context(struct file *filp) | 566 | static void nfs_file_clear_open_context(struct file *filp) |
537 | { | 567 | { |
538 | struct inode *inode = filp->f_path.dentry->d_inode; | 568 | struct inode *inode = filp->f_path.dentry->d_inode; |
539 | struct nfs_open_context *ctx = (struct nfs_open_context *)filp->private_data; | 569 | struct nfs_open_context *ctx = nfs_file_open_context(filp); |
540 | 570 | ||
541 | if (ctx) { | 571 | if (ctx) { |
542 | filp->private_data = NULL; | 572 | filp->private_data = NULL; |
@@ -598,16 +628,10 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
598 | status = nfs_wait_on_inode(inode); | 628 | status = nfs_wait_on_inode(inode); |
599 | if (status < 0) | 629 | if (status < 0) |
600 | goto out; | 630 | goto out; |
601 | if (NFS_STALE(inode)) { | 631 | |
602 | status = -ESTALE; | 632 | status = -ESTALE; |
603 | /* Do we trust the cached ESTALE? */ | 633 | if (NFS_STALE(inode)) |
604 | if (NFS_ATTRTIMEO(inode) != 0) { | 634 | goto out; |
605 | if (nfsi->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME)) { | ||
606 | /* no */ | ||
607 | } else | ||
608 | goto out; | ||
609 | } | ||
610 | } | ||
611 | 635 | ||
612 | status = NFS_PROTO(inode)->getattr(server, NFS_FH(inode), &fattr); | 636 | status = NFS_PROTO(inode)->getattr(server, NFS_FH(inode), &fattr); |
613 | if (status != 0) { | 637 | if (status != 0) { |
@@ -654,7 +678,7 @@ int nfs_attribute_timeout(struct inode *inode) | |||
654 | 678 | ||
655 | if (nfs_have_delegation(inode, FMODE_READ)) | 679 | if (nfs_have_delegation(inode, FMODE_READ)) |
656 | return 0; | 680 | return 0; |
657 | return time_after(jiffies, nfsi->read_cache_jiffies+nfsi->attrtimeo); | 681 | return !time_in_range(jiffies, nfsi->read_cache_jiffies, nfsi->read_cache_jiffies + nfsi->attrtimeo); |
658 | } | 682 | } |
659 | 683 | ||
660 | /** | 684 | /** |
@@ -683,11 +707,8 @@ static int nfs_invalidate_mapping_nolock(struct inode *inode, struct address_spa | |||
683 | } | 707 | } |
684 | spin_lock(&inode->i_lock); | 708 | spin_lock(&inode->i_lock); |
685 | nfsi->cache_validity &= ~NFS_INO_INVALID_DATA; | 709 | nfsi->cache_validity &= ~NFS_INO_INVALID_DATA; |
686 | if (S_ISDIR(inode->i_mode)) { | 710 | if (S_ISDIR(inode->i_mode)) |
687 | memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf)); | 711 | memset(nfsi->cookieverf, 0, sizeof(nfsi->cookieverf)); |
688 | /* This ensures we revalidate child dentries */ | ||
689 | nfsi->cache_change_attribute = jiffies; | ||
690 | } | ||
691 | spin_unlock(&inode->i_lock); | 712 | spin_unlock(&inode->i_lock); |
692 | nfs_inc_stats(inode, NFSIOS_DATAINVALIDATE); | 713 | nfs_inc_stats(inode, NFSIOS_DATAINVALIDATE); |
693 | dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n", | 714 | dfprintk(PAGECACHE, "NFS: (%s/%Ld) data cache invalidated\n", |
@@ -756,56 +777,27 @@ out: | |||
756 | return ret; | 777 | return ret; |
757 | } | 778 | } |
758 | 779 | ||
759 | /** | ||
760 | * nfs_begin_data_update | ||
761 | * @inode - pointer to inode | ||
762 | * Declare that a set of operations will update file data on the server | ||
763 | */ | ||
764 | void nfs_begin_data_update(struct inode *inode) | ||
765 | { | ||
766 | atomic_inc(&NFS_I(inode)->data_updates); | ||
767 | } | ||
768 | |||
769 | /** | ||
770 | * nfs_end_data_update | ||
771 | * @inode - pointer to inode | ||
772 | * Declare end of the operations that will update file data | ||
773 | * This will mark the inode as immediately needing revalidation | ||
774 | * of its attribute cache. | ||
775 | */ | ||
776 | void nfs_end_data_update(struct inode *inode) | ||
777 | { | ||
778 | struct nfs_inode *nfsi = NFS_I(inode); | ||
779 | |||
780 | /* Directories: invalidate page cache */ | ||
781 | if (S_ISDIR(inode->i_mode)) { | ||
782 | spin_lock(&inode->i_lock); | ||
783 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; | ||
784 | spin_unlock(&inode->i_lock); | ||
785 | } | ||
786 | nfsi->cache_change_attribute = jiffies; | ||
787 | atomic_dec(&nfsi->data_updates); | ||
788 | } | ||
789 | |||
790 | static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) | 780 | static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr) |
791 | { | 781 | { |
792 | struct nfs_inode *nfsi = NFS_I(inode); | 782 | struct nfs_inode *nfsi = NFS_I(inode); |
793 | unsigned long now = jiffies; | ||
794 | 783 | ||
784 | if ((fattr->valid & NFS_ATTR_WCC_V4) != 0 && | ||
785 | nfsi->change_attr == fattr->pre_change_attr) { | ||
786 | nfsi->change_attr = fattr->change_attr; | ||
787 | if (S_ISDIR(inode->i_mode)) | ||
788 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; | ||
789 | } | ||
795 | /* If we have atomic WCC data, we may update some attributes */ | 790 | /* If we have atomic WCC data, we may update some attributes */ |
796 | if ((fattr->valid & NFS_ATTR_WCC) != 0) { | 791 | if ((fattr->valid & NFS_ATTR_WCC) != 0) { |
797 | if (timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) { | 792 | if (timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) |
798 | memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime)); | 793 | memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime)); |
799 | nfsi->cache_change_attribute = now; | ||
800 | } | ||
801 | if (timespec_equal(&inode->i_mtime, &fattr->pre_mtime)) { | 794 | if (timespec_equal(&inode->i_mtime, &fattr->pre_mtime)) { |
802 | memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime)); | 795 | memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime)); |
803 | nfsi->cache_change_attribute = now; | 796 | if (S_ISDIR(inode->i_mode)) |
797 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; | ||
804 | } | 798 | } |
805 | if (inode->i_size == fattr->pre_size && nfsi->npages == 0) { | 799 | if (inode->i_size == fattr->pre_size && nfsi->npages == 0) |
806 | inode->i_size = fattr->size; | 800 | inode->i_size = fattr->size; |
807 | nfsi->cache_change_attribute = now; | ||
808 | } | ||
809 | } | 801 | } |
810 | } | 802 | } |
811 | 803 | ||
@@ -822,7 +814,7 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat | |||
822 | { | 814 | { |
823 | struct nfs_inode *nfsi = NFS_I(inode); | 815 | struct nfs_inode *nfsi = NFS_I(inode); |
824 | loff_t cur_size, new_isize; | 816 | loff_t cur_size, new_isize; |
825 | int data_unstable; | 817 | unsigned long invalid = 0; |
826 | 818 | ||
827 | 819 | ||
828 | /* Has the inode gone and changed behind our back? */ | 820 | /* Has the inode gone and changed behind our back? */ |
@@ -831,37 +823,41 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat | |||
831 | return -EIO; | 823 | return -EIO; |
832 | } | 824 | } |
833 | 825 | ||
834 | /* Are we in the process of updating data on the server? */ | ||
835 | data_unstable = nfs_caches_unstable(inode); | ||
836 | |||
837 | /* Do atomic weak cache consistency updates */ | 826 | /* Do atomic weak cache consistency updates */ |
838 | nfs_wcc_update_inode(inode, fattr); | 827 | nfs_wcc_update_inode(inode, fattr); |
839 | 828 | ||
840 | if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && | 829 | if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && |
841 | nfsi->change_attr != fattr->change_attr) | 830 | nfsi->change_attr != fattr->change_attr) |
842 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; | 831 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
843 | 832 | ||
844 | /* Verify a few of the more important attributes */ | 833 | /* Verify a few of the more important attributes */ |
845 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) | 834 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) |
846 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; | 835 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
847 | 836 | ||
848 | cur_size = i_size_read(inode); | 837 | cur_size = i_size_read(inode); |
849 | new_isize = nfs_size_to_loff_t(fattr->size); | 838 | new_isize = nfs_size_to_loff_t(fattr->size); |
850 | if (cur_size != new_isize && nfsi->npages == 0) | 839 | if (cur_size != new_isize && nfsi->npages == 0) |
851 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; | 840 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
852 | 841 | ||
853 | /* Have any file permissions changed? */ | 842 | /* Have any file permissions changed? */ |
854 | if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) | 843 | if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) |
855 | || inode->i_uid != fattr->uid | 844 | || inode->i_uid != fattr->uid |
856 | || inode->i_gid != fattr->gid) | 845 | || inode->i_gid != fattr->gid) |
857 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL; | 846 | invalid |= NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL; |
858 | 847 | ||
859 | /* Has the link count changed? */ | 848 | /* Has the link count changed? */ |
860 | if (inode->i_nlink != fattr->nlink) | 849 | if (inode->i_nlink != fattr->nlink) |
861 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR; | 850 | invalid |= NFS_INO_INVALID_ATTR; |
862 | 851 | ||
863 | if (!timespec_equal(&inode->i_atime, &fattr->atime)) | 852 | if (!timespec_equal(&inode->i_atime, &fattr->atime)) |
864 | nfsi->cache_validity |= NFS_INO_INVALID_ATIME; | 853 | invalid |= NFS_INO_INVALID_ATIME; |
854 | |||
855 | if (invalid != 0) | ||
856 | nfsi->cache_validity |= invalid; | ||
857 | else | ||
858 | nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR | ||
859 | | NFS_INO_INVALID_ATIME | ||
860 | | NFS_INO_REVAL_PAGECACHE); | ||
865 | 861 | ||
866 | nfsi->read_cache_jiffies = fattr->time_start; | 862 | nfsi->read_cache_jiffies = fattr->time_start; |
867 | return 0; | 863 | return 0; |
@@ -911,17 +907,41 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
911 | int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr) | 907 | int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr) |
912 | { | 908 | { |
913 | struct nfs_inode *nfsi = NFS_I(inode); | 909 | struct nfs_inode *nfsi = NFS_I(inode); |
914 | int status = 0; | ||
915 | 910 | ||
916 | spin_lock(&inode->i_lock); | 911 | spin_lock(&inode->i_lock); |
917 | if (unlikely((fattr->valid & NFS_ATTR_FATTR) == 0)) { | 912 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; |
918 | nfsi->cache_validity |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE; | 913 | if (S_ISDIR(inode->i_mode)) |
919 | goto out; | 914 | nfsi->cache_validity |= NFS_INO_INVALID_DATA; |
920 | } | ||
921 | status = nfs_update_inode(inode, fattr); | ||
922 | out: | ||
923 | spin_unlock(&inode->i_lock); | 915 | spin_unlock(&inode->i_lock); |
924 | return status; | 916 | return nfs_refresh_inode(inode, fattr); |
917 | } | ||
918 | |||
919 | /** | ||
920 | * nfs_post_op_update_inode_force_wcc - try to update the inode attribute cache | ||
921 | * @inode - pointer to inode | ||
922 | * @fattr - updated attributes | ||
923 | * | ||
924 | * After an operation that has changed the inode metadata, mark the | ||
925 | * attribute cache as being invalid, then try to update it. Fake up | ||
926 | * weak cache consistency data, if none exist. | ||
927 | * | ||
928 | * This function is mainly designed to be used by the ->write_done() functions. | ||
929 | */ | ||
930 | int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr) | ||
931 | { | ||
932 | if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && | ||
933 | (fattr->valid & NFS_ATTR_WCC_V4) == 0) { | ||
934 | fattr->pre_change_attr = NFS_I(inode)->change_attr; | ||
935 | fattr->valid |= NFS_ATTR_WCC_V4; | ||
936 | } | ||
937 | if ((fattr->valid & NFS_ATTR_FATTR) != 0 && | ||
938 | (fattr->valid & NFS_ATTR_WCC) == 0) { | ||
939 | memcpy(&fattr->pre_ctime, &inode->i_ctime, sizeof(fattr->pre_ctime)); | ||
940 | memcpy(&fattr->pre_mtime, &inode->i_mtime, sizeof(fattr->pre_mtime)); | ||
941 | fattr->pre_size = inode->i_size; | ||
942 | fattr->valid |= NFS_ATTR_WCC; | ||
943 | } | ||
944 | return nfs_post_op_update_inode(inode, fattr); | ||
925 | } | 945 | } |
926 | 946 | ||
927 | /* | 947 | /* |
@@ -941,9 +961,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
941 | struct nfs_server *server; | 961 | struct nfs_server *server; |
942 | struct nfs_inode *nfsi = NFS_I(inode); | 962 | struct nfs_inode *nfsi = NFS_I(inode); |
943 | loff_t cur_isize, new_isize; | 963 | loff_t cur_isize, new_isize; |
944 | unsigned int invalid = 0; | 964 | unsigned long invalid = 0; |
945 | unsigned long now = jiffies; | 965 | unsigned long now = jiffies; |
946 | int data_stable; | ||
947 | 966 | ||
948 | dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n", | 967 | dfprintk(VFS, "NFS: %s(%s/%ld ct=%d info=0x%x)\n", |
949 | __FUNCTION__, inode->i_sb->s_id, inode->i_ino, | 968 | __FUNCTION__, inode->i_sb->s_id, inode->i_ino, |
@@ -968,57 +987,51 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
968 | * Update the read time so we don't revalidate too often. | 987 | * Update the read time so we don't revalidate too often. |
969 | */ | 988 | */ |
970 | nfsi->read_cache_jiffies = fattr->time_start; | 989 | nfsi->read_cache_jiffies = fattr->time_start; |
971 | nfsi->last_updated = now; | ||
972 | 990 | ||
973 | /* Fix a wraparound issue with nfsi->cache_change_attribute */ | 991 | nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR | NFS_INO_INVALID_ATIME |
974 | if (time_before(now, nfsi->cache_change_attribute)) | 992 | | NFS_INO_REVAL_PAGECACHE); |
975 | nfsi->cache_change_attribute = now - 600*HZ; | ||
976 | |||
977 | /* Are we racing with known updates of the metadata on the server? */ | ||
978 | data_stable = nfs_verify_change_attribute(inode, fattr->time_start); | ||
979 | if (data_stable) | ||
980 | nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_ATIME); | ||
981 | 993 | ||
982 | /* Do atomic weak cache consistency updates */ | 994 | /* Do atomic weak cache consistency updates */ |
983 | nfs_wcc_update_inode(inode, fattr); | 995 | nfs_wcc_update_inode(inode, fattr); |
984 | 996 | ||
997 | /* More cache consistency checks */ | ||
998 | if (!(fattr->valid & NFS_ATTR_FATTR_V4)) { | ||
999 | /* NFSv2/v3: Check if the mtime agrees */ | ||
1000 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) { | ||
1001 | dprintk("NFS: mtime change on server for file %s/%ld\n", | ||
1002 | inode->i_sb->s_id, inode->i_ino); | ||
1003 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; | ||
1004 | nfsi->cache_change_attribute = now; | ||
1005 | } | ||
1006 | /* If ctime has changed we should definitely clear access+acl caches */ | ||
1007 | if (!timespec_equal(&inode->i_ctime, &fattr->ctime)) | ||
1008 | invalid |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; | ||
1009 | } else if (nfsi->change_attr != fattr->change_attr) { | ||
1010 | dprintk("NFS: change_attr change on server for file %s/%ld\n", | ||
1011 | inode->i_sb->s_id, inode->i_ino); | ||
1012 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; | ||
1013 | nfsi->cache_change_attribute = now; | ||
1014 | } | ||
1015 | |||
985 | /* Check if our cached file size is stale */ | 1016 | /* Check if our cached file size is stale */ |
986 | new_isize = nfs_size_to_loff_t(fattr->size); | 1017 | new_isize = nfs_size_to_loff_t(fattr->size); |
987 | cur_isize = i_size_read(inode); | 1018 | cur_isize = i_size_read(inode); |
988 | if (new_isize != cur_isize) { | 1019 | if (new_isize != cur_isize) { |
989 | /* Do we perhaps have any outstanding writes? */ | 1020 | /* Do we perhaps have any outstanding writes, or has |
990 | if (nfsi->npages == 0) { | 1021 | * the file grown beyond our last write? */ |
991 | /* No, but did we race with nfs_end_data_update()? */ | 1022 | if (nfsi->npages == 0 || new_isize > cur_isize) { |
992 | if (data_stable) { | ||
993 | inode->i_size = new_isize; | ||
994 | invalid |= NFS_INO_INVALID_DATA; | ||
995 | } | ||
996 | invalid |= NFS_INO_INVALID_ATTR; | ||
997 | } else if (new_isize > cur_isize) { | ||
998 | inode->i_size = new_isize; | 1023 | inode->i_size = new_isize; |
999 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; | 1024 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; |
1000 | } | 1025 | } |
1001 | nfsi->cache_change_attribute = now; | ||
1002 | dprintk("NFS: isize change on server for file %s/%ld\n", | 1026 | dprintk("NFS: isize change on server for file %s/%ld\n", |
1003 | inode->i_sb->s_id, inode->i_ino); | 1027 | inode->i_sb->s_id, inode->i_ino); |
1004 | } | 1028 | } |
1005 | 1029 | ||
1006 | /* Check if the mtime agrees */ | ||
1007 | if (!timespec_equal(&inode->i_mtime, &fattr->mtime)) { | ||
1008 | memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime)); | ||
1009 | dprintk("NFS: mtime change on server for file %s/%ld\n", | ||
1010 | inode->i_sb->s_id, inode->i_ino); | ||
1011 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA; | ||
1012 | nfsi->cache_change_attribute = now; | ||
1013 | } | ||
1014 | 1030 | ||
1015 | /* If ctime has changed we should definitely clear access+acl caches */ | 1031 | memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime)); |
1016 | if (!timespec_equal(&inode->i_ctime, &fattr->ctime)) { | 1032 | memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime)); |
1017 | invalid |= NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; | ||
1018 | memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime)); | ||
1019 | nfsi->cache_change_attribute = now; | ||
1020 | } | ||
1021 | memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime)); | 1033 | memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime)); |
1034 | nfsi->change_attr = fattr->change_attr; | ||
1022 | 1035 | ||
1023 | if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) || | 1036 | if ((inode->i_mode & S_IALLUGO) != (fattr->mode & S_IALLUGO) || |
1024 | inode->i_uid != fattr->uid || | 1037 | inode->i_uid != fattr->uid || |
@@ -1039,31 +1052,29 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1039 | inode->i_blocks = fattr->du.nfs2.blocks; | 1052 | inode->i_blocks = fattr->du.nfs2.blocks; |
1040 | } | 1053 | } |
1041 | 1054 | ||
1042 | if ((fattr->valid & NFS_ATTR_FATTR_V4) != 0 && | ||
1043 | nfsi->change_attr != fattr->change_attr) { | ||
1044 | dprintk("NFS: change_attr change on server for file %s/%ld\n", | ||
1045 | inode->i_sb->s_id, inode->i_ino); | ||
1046 | nfsi->change_attr = fattr->change_attr; | ||
1047 | invalid |= NFS_INO_INVALID_ATTR|NFS_INO_INVALID_DATA|NFS_INO_INVALID_ACCESS|NFS_INO_INVALID_ACL; | ||
1048 | nfsi->cache_change_attribute = now; | ||
1049 | } | ||
1050 | |||
1051 | /* Update attrtimeo value if we're out of the unstable period */ | 1055 | /* Update attrtimeo value if we're out of the unstable period */ |
1052 | if (invalid & NFS_INO_INVALID_ATTR) { | 1056 | if (invalid & NFS_INO_INVALID_ATTR) { |
1053 | nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE); | 1057 | nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE); |
1054 | nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); | 1058 | nfsi->attrtimeo = NFS_MINATTRTIMEO(inode); |
1055 | nfsi->attrtimeo_timestamp = now; | 1059 | nfsi->attrtimeo_timestamp = now; |
1056 | } else if (time_after(now, nfsi->attrtimeo_timestamp+nfsi->attrtimeo)) { | 1060 | nfsi->last_updated = now; |
1057 | if ((nfsi->attrtimeo <<= 1) > NFS_MAXATTRTIMEO(inode)) | 1061 | } else { |
1058 | nfsi->attrtimeo = NFS_MAXATTRTIMEO(inode); | 1062 | if (!time_in_range(now, nfsi->attrtimeo_timestamp, nfsi->attrtimeo_timestamp + nfsi->attrtimeo)) { |
1059 | nfsi->attrtimeo_timestamp = now; | 1063 | if ((nfsi->attrtimeo <<= 1) > NFS_MAXATTRTIMEO(inode)) |
1064 | nfsi->attrtimeo = NFS_MAXATTRTIMEO(inode); | ||
1065 | nfsi->attrtimeo_timestamp = now; | ||
1066 | } | ||
1067 | /* | ||
1068 | * Avoid jiffy wraparound issues with nfsi->last_updated | ||
1069 | */ | ||
1070 | if (!time_in_range(nfsi->last_updated, nfsi->read_cache_jiffies, now)) | ||
1071 | nfsi->last_updated = nfsi->read_cache_jiffies; | ||
1060 | } | 1072 | } |
1073 | invalid &= ~NFS_INO_INVALID_ATTR; | ||
1061 | /* Don't invalidate the data if we were to blame */ | 1074 | /* Don't invalidate the data if we were to blame */ |
1062 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) | 1075 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) |
1063 | || S_ISLNK(inode->i_mode))) | 1076 | || S_ISLNK(inode->i_mode))) |
1064 | invalid &= ~NFS_INO_INVALID_DATA; | 1077 | invalid &= ~NFS_INO_INVALID_DATA; |
1065 | if (data_stable) | ||
1066 | invalid &= ~(NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME|NFS_INO_REVAL_PAGECACHE); | ||
1067 | if (!nfs_have_delegation(inode, FMODE_READ) || | 1078 | if (!nfs_have_delegation(inode, FMODE_READ) || |
1068 | (nfsi->cache_validity & NFS_INO_REVAL_FORCED)) | 1079 | (nfsi->cache_validity & NFS_INO_REVAL_FORCED)) |
1069 | nfsi->cache_validity |= invalid; | 1080 | nfsi->cache_validity |= invalid; |
@@ -1152,7 +1163,6 @@ static void init_once(void * foo, struct kmem_cache * cachep, unsigned long flag | |||
1152 | INIT_LIST_HEAD(&nfsi->access_cache_entry_lru); | 1163 | INIT_LIST_HEAD(&nfsi->access_cache_entry_lru); |
1153 | INIT_LIST_HEAD(&nfsi->access_cache_inode_lru); | 1164 | INIT_LIST_HEAD(&nfsi->access_cache_inode_lru); |
1154 | INIT_RADIX_TREE(&nfsi->nfs_page_tree, GFP_ATOMIC); | 1165 | INIT_RADIX_TREE(&nfsi->nfs_page_tree, GFP_ATOMIC); |
1155 | atomic_set(&nfsi->data_updates, 0); | ||
1156 | nfsi->ncommit = 0; | 1166 | nfsi->ncommit = 0; |
1157 | nfsi->npages = 0; | 1167 | nfsi->npages = 0; |
1158 | nfs4_init_once(nfsi); | 1168 | nfs4_init_once(nfsi); |
@@ -1249,6 +1259,7 @@ static void __exit exit_nfs_fs(void) | |||
1249 | /* Not quite true; I just maintain it */ | 1259 | /* Not quite true; I just maintain it */ |
1250 | MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>"); | 1260 | MODULE_AUTHOR("Olaf Kirch <okir@monad.swb.de>"); |
1251 | MODULE_LICENSE("GPL"); | 1261 | MODULE_LICENSE("GPL"); |
1262 | module_param(enable_ino64, bool, 0644); | ||
1252 | 1263 | ||
1253 | module_init(init_nfs_fs) | 1264 | module_init(init_nfs_fs) |
1254 | module_exit(exit_nfs_fs) | 1265 | module_exit(exit_nfs_fs) |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 76cf55d57101..f3acf48412be 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -5,8 +5,6 @@ | |||
5 | #include <linux/mount.h> | 5 | #include <linux/mount.h> |
6 | 6 | ||
7 | struct nfs_string; | 7 | struct nfs_string; |
8 | struct nfs_mount_data; | ||
9 | struct nfs4_mount_data; | ||
10 | 8 | ||
11 | /* Maximum number of readahead requests | 9 | /* Maximum number of readahead requests |
12 | * FIXME: this should really be a sysctl so that users may tune it to suit | 10 | * FIXME: this should really be a sysctl so that users may tune it to suit |
@@ -27,20 +25,50 @@ struct nfs_clone_mount { | |||
27 | rpc_authflavor_t authflavor; | 25 | rpc_authflavor_t authflavor; |
28 | }; | 26 | }; |
29 | 27 | ||
28 | /* | ||
29 | * In-kernel mount arguments | ||
30 | */ | ||
31 | struct nfs_parsed_mount_data { | ||
32 | int flags; | ||
33 | int rsize, wsize; | ||
34 | int timeo, retrans; | ||
35 | int acregmin, acregmax, | ||
36 | acdirmin, acdirmax; | ||
37 | int namlen; | ||
38 | unsigned int bsize; | ||
39 | unsigned int auth_flavor_len; | ||
40 | rpc_authflavor_t auth_flavors[1]; | ||
41 | char *client_address; | ||
42 | |||
43 | struct { | ||
44 | struct sockaddr_in address; | ||
45 | char *hostname; | ||
46 | unsigned int program; | ||
47 | unsigned int version; | ||
48 | unsigned short port; | ||
49 | int protocol; | ||
50 | } mount_server; | ||
51 | |||
52 | struct { | ||
53 | struct sockaddr_in address; | ||
54 | char *hostname; | ||
55 | char *export_path; | ||
56 | unsigned int program; | ||
57 | int protocol; | ||
58 | } nfs_server; | ||
59 | }; | ||
60 | |||
30 | /* client.c */ | 61 | /* client.c */ |
31 | extern struct rpc_program nfs_program; | 62 | extern struct rpc_program nfs_program; |
32 | 63 | ||
33 | extern void nfs_put_client(struct nfs_client *); | 64 | extern void nfs_put_client(struct nfs_client *); |
34 | extern struct nfs_client *nfs_find_client(const struct sockaddr_in *, int); | 65 | extern struct nfs_client *nfs_find_client(const struct sockaddr_in *, int); |
35 | extern struct nfs_server *nfs_create_server(const struct nfs_mount_data *, | 66 | extern struct nfs_server *nfs_create_server( |
36 | struct nfs_fh *); | 67 | const struct nfs_parsed_mount_data *, |
37 | extern struct nfs_server *nfs4_create_server(const struct nfs4_mount_data *, | 68 | struct nfs_fh *); |
38 | const char *, | 69 | extern struct nfs_server *nfs4_create_server( |
39 | const struct sockaddr_in *, | 70 | const struct nfs_parsed_mount_data *, |
40 | const char *, | 71 | struct nfs_fh *); |
41 | const char *, | ||
42 | rpc_authflavor_t, | ||
43 | struct nfs_fh *); | ||
44 | extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *, | 72 | extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *, |
45 | struct nfs_fh *); | 73 | struct nfs_fh *); |
46 | extern void nfs_free_server(struct nfs_server *server); | 74 | extern void nfs_free_server(struct nfs_server *server); |
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c index c5fce7567200..668ab96c7b59 100644 --- a/fs/nfs/nfs2xdr.c +++ b/fs/nfs/nfs2xdr.c | |||
@@ -251,6 +251,7 @@ nfs_xdr_readargs(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args) | |||
251 | replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS_readres_sz) << 2; | 251 | replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS_readres_sz) << 2; |
252 | xdr_inline_pages(&req->rq_rcv_buf, replen, | 252 | xdr_inline_pages(&req->rq_rcv_buf, replen, |
253 | args->pages, args->pgbase, count); | 253 | args->pages, args->pgbase, count); |
254 | req->rq_rcv_buf.flags |= XDRBUF_READ; | ||
254 | return 0; | 255 | return 0; |
255 | } | 256 | } |
256 | 257 | ||
@@ -271,7 +272,7 @@ nfs_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res) | |||
271 | res->eof = 0; | 272 | res->eof = 0; |
272 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; | 273 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; |
273 | if (iov->iov_len < hdrlen) { | 274 | if (iov->iov_len < hdrlen) { |
274 | printk(KERN_WARNING "NFS: READ reply header overflowed:" | 275 | dprintk("NFS: READ reply header overflowed:" |
275 | "length %d > %Zu\n", hdrlen, iov->iov_len); | 276 | "length %d > %Zu\n", hdrlen, iov->iov_len); |
276 | return -errno_NFSERR_IO; | 277 | return -errno_NFSERR_IO; |
277 | } else if (iov->iov_len != hdrlen) { | 278 | } else if (iov->iov_len != hdrlen) { |
@@ -281,7 +282,7 @@ nfs_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res) | |||
281 | 282 | ||
282 | recvd = req->rq_rcv_buf.len - hdrlen; | 283 | recvd = req->rq_rcv_buf.len - hdrlen; |
283 | if (count > recvd) { | 284 | if (count > recvd) { |
284 | printk(KERN_WARNING "NFS: server cheating in read reply: " | 285 | dprintk("NFS: server cheating in read reply: " |
285 | "count %d > recvd %d\n", count, recvd); | 286 | "count %d > recvd %d\n", count, recvd); |
286 | count = recvd; | 287 | count = recvd; |
287 | } | 288 | } |
@@ -313,6 +314,7 @@ nfs_xdr_writeargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args) | |||
313 | 314 | ||
314 | /* Copy the page array */ | 315 | /* Copy the page array */ |
315 | xdr_encode_pages(sndbuf, args->pages, args->pgbase, count); | 316 | xdr_encode_pages(sndbuf, args->pages, args->pgbase, count); |
317 | sndbuf->flags |= XDRBUF_WRITE; | ||
316 | return 0; | 318 | return 0; |
317 | } | 319 | } |
318 | 320 | ||
@@ -431,7 +433,7 @@ nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy) | |||
431 | 433 | ||
432 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; | 434 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; |
433 | if (iov->iov_len < hdrlen) { | 435 | if (iov->iov_len < hdrlen) { |
434 | printk(KERN_WARNING "NFS: READDIR reply header overflowed:" | 436 | dprintk("NFS: READDIR reply header overflowed:" |
435 | "length %d > %Zu\n", hdrlen, iov->iov_len); | 437 | "length %d > %Zu\n", hdrlen, iov->iov_len); |
436 | return -errno_NFSERR_IO; | 438 | return -errno_NFSERR_IO; |
437 | } else if (iov->iov_len != hdrlen) { | 439 | } else if (iov->iov_len != hdrlen) { |
@@ -454,7 +456,7 @@ nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy) | |||
454 | len = ntohl(*p++); | 456 | len = ntohl(*p++); |
455 | p += XDR_QUADLEN(len) + 1; /* name plus cookie */ | 457 | p += XDR_QUADLEN(len) + 1; /* name plus cookie */ |
456 | if (len > NFS2_MAXNAMLEN) { | 458 | if (len > NFS2_MAXNAMLEN) { |
457 | printk(KERN_WARNING "NFS: giant filename in readdir (len 0x%x)!\n", | 459 | dprintk("NFS: giant filename in readdir (len 0x%x)!\n", |
458 | len); | 460 | len); |
459 | goto err_unmap; | 461 | goto err_unmap; |
460 | } | 462 | } |
@@ -471,7 +473,7 @@ nfs_xdr_readdirres(struct rpc_rqst *req, __be32 *p, void *dummy) | |||
471 | entry[0] = entry[1] = 0; | 473 | entry[0] = entry[1] = 0; |
472 | /* truncate listing ? */ | 474 | /* truncate listing ? */ |
473 | if (!nr) { | 475 | if (!nr) { |
474 | printk(KERN_NOTICE "NFS: readdir reply truncated!\n"); | 476 | dprintk("NFS: readdir reply truncated!\n"); |
475 | entry[1] = 1; | 477 | entry[1] = 1; |
476 | } | 478 | } |
477 | goto out; | 479 | goto out; |
@@ -583,12 +585,12 @@ nfs_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, void *dummy) | |||
583 | /* Convert length of symlink */ | 585 | /* Convert length of symlink */ |
584 | len = ntohl(*p++); | 586 | len = ntohl(*p++); |
585 | if (len >= rcvbuf->page_len || len <= 0) { | 587 | if (len >= rcvbuf->page_len || len <= 0) { |
586 | dprintk(KERN_WARNING "nfs: server returned giant symlink!\n"); | 588 | dprintk("nfs: server returned giant symlink!\n"); |
587 | return -ENAMETOOLONG; | 589 | return -ENAMETOOLONG; |
588 | } | 590 | } |
589 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; | 591 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; |
590 | if (iov->iov_len < hdrlen) { | 592 | if (iov->iov_len < hdrlen) { |
591 | printk(KERN_WARNING "NFS: READLINK reply header overflowed:" | 593 | dprintk("NFS: READLINK reply header overflowed:" |
592 | "length %d > %Zu\n", hdrlen, iov->iov_len); | 594 | "length %d > %Zu\n", hdrlen, iov->iov_len); |
593 | return -errno_NFSERR_IO; | 595 | return -errno_NFSERR_IO; |
594 | } else if (iov->iov_len != hdrlen) { | 596 | } else if (iov->iov_len != hdrlen) { |
@@ -597,7 +599,7 @@ nfs_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, void *dummy) | |||
597 | } | 599 | } |
598 | recvd = req->rq_rcv_buf.len - hdrlen; | 600 | recvd = req->rq_rcv_buf.len - hdrlen; |
599 | if (recvd < len) { | 601 | if (recvd < len) { |
600 | printk(KERN_WARNING "NFS: server cheating in readlink reply: " | 602 | dprintk("NFS: server cheating in readlink reply: " |
601 | "count %u > recvd %u\n", len, recvd); | 603 | "count %u > recvd %u\n", len, recvd); |
602 | return -EIO; | 604 | return -EIO; |
603 | } | 605 | } |
@@ -695,7 +697,7 @@ nfs_stat_to_errno(int stat) | |||
695 | if (nfs_errtbl[i].stat == stat) | 697 | if (nfs_errtbl[i].stat == stat) |
696 | return nfs_errtbl[i].errno; | 698 | return nfs_errtbl[i].errno; |
697 | } | 699 | } |
698 | printk(KERN_ERR "nfs_stat_to_errno: bad nfs status return value: %d\n", stat); | 700 | dprintk("nfs_stat_to_errno: bad nfs status return value: %d\n", stat); |
699 | return nfs_errtbl[i].errno; | 701 | return nfs_errtbl[i].errno; |
700 | } | 702 | } |
701 | 703 | ||
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c index 7322da4d2055..9b7362565c0c 100644 --- a/fs/nfs/nfs3acl.c +++ b/fs/nfs/nfs3acl.c | |||
@@ -317,13 +317,11 @@ static int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl, | |||
317 | } | 317 | } |
318 | 318 | ||
319 | dprintk("NFS call setacl\n"); | 319 | dprintk("NFS call setacl\n"); |
320 | nfs_begin_data_update(inode); | ||
321 | msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_SETACL]; | 320 | msg.rpc_proc = &server->client_acl->cl_procinfo[ACLPROC3_SETACL]; |
322 | status = rpc_call_sync(server->client_acl, &msg, 0); | 321 | status = rpc_call_sync(server->client_acl, &msg, 0); |
323 | spin_lock(&inode->i_lock); | 322 | spin_lock(&inode->i_lock); |
324 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS; | 323 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ACCESS; |
325 | spin_unlock(&inode->i_lock); | 324 | spin_unlock(&inode->i_lock); |
326 | nfs_end_data_update(inode); | ||
327 | dprintk("NFS reply setacl: %d\n", status); | 325 | dprintk("NFS reply setacl: %d\n", status); |
328 | 326 | ||
329 | /* pages may have been allocated at the xdr layer. */ | 327 | /* pages may have been allocated at the xdr layer. */ |
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index c7ca5d70870b..4cdc2361a669 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c | |||
@@ -166,6 +166,7 @@ nfs3_proc_lookup(struct inode *dir, struct qstr *name, | |||
166 | nfs_fattr_init(&dir_attr); | 166 | nfs_fattr_init(&dir_attr); |
167 | nfs_fattr_init(fattr); | 167 | nfs_fattr_init(fattr); |
168 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 168 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
169 | nfs_refresh_inode(dir, &dir_attr); | ||
169 | if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR)) { | 170 | if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR)) { |
170 | msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR]; | 171 | msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR]; |
171 | msg.rpc_argp = fhandle; | 172 | msg.rpc_argp = fhandle; |
@@ -173,8 +174,6 @@ nfs3_proc_lookup(struct inode *dir, struct qstr *name, | |||
173 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 174 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
174 | } | 175 | } |
175 | dprintk("NFS reply lookup: %d\n", status); | 176 | dprintk("NFS reply lookup: %d\n", status); |
176 | if (status >= 0) | ||
177 | status = nfs_refresh_inode(dir, &dir_attr); | ||
178 | return status; | 177 | return status; |
179 | } | 178 | } |
180 | 179 | ||
@@ -607,6 +606,9 @@ nfs3_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, | |||
607 | 606 | ||
608 | nfs_fattr_init(&dir_attr); | 607 | nfs_fattr_init(&dir_attr); |
609 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 608 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
609 | |||
610 | nfs_invalidate_atime(dir); | ||
611 | |||
610 | nfs_refresh_inode(dir, &dir_attr); | 612 | nfs_refresh_inode(dir, &dir_attr); |
611 | dprintk("NFS reply readdir: %d\n", status); | 613 | dprintk("NFS reply readdir: %d\n", status); |
612 | return status; | 614 | return status; |
@@ -724,9 +726,9 @@ static int nfs3_read_done(struct rpc_task *task, struct nfs_read_data *data) | |||
724 | { | 726 | { |
725 | if (nfs3_async_handle_jukebox(task, data->inode)) | 727 | if (nfs3_async_handle_jukebox(task, data->inode)) |
726 | return -EAGAIN; | 728 | return -EAGAIN; |
727 | /* Call back common NFS readpage processing */ | 729 | |
728 | if (task->tk_status >= 0) | 730 | nfs_invalidate_atime(data->inode); |
729 | nfs_refresh_inode(data->inode, &data->fattr); | 731 | nfs_refresh_inode(data->inode, &data->fattr); |
730 | return 0; | 732 | return 0; |
731 | } | 733 | } |
732 | 734 | ||
@@ -747,7 +749,7 @@ static int nfs3_write_done(struct rpc_task *task, struct nfs_write_data *data) | |||
747 | if (nfs3_async_handle_jukebox(task, data->inode)) | 749 | if (nfs3_async_handle_jukebox(task, data->inode)) |
748 | return -EAGAIN; | 750 | return -EAGAIN; |
749 | if (task->tk_status >= 0) | 751 | if (task->tk_status >= 0) |
750 | nfs_post_op_update_inode(data->inode, data->res.fattr); | 752 | nfs_post_op_update_inode_force_wcc(data->inode, data->res.fattr); |
751 | return 0; | 753 | return 0; |
752 | } | 754 | } |
753 | 755 | ||
@@ -775,8 +777,7 @@ static int nfs3_commit_done(struct rpc_task *task, struct nfs_write_data *data) | |||
775 | { | 777 | { |
776 | if (nfs3_async_handle_jukebox(task, data->inode)) | 778 | if (nfs3_async_handle_jukebox(task, data->inode)) |
777 | return -EAGAIN; | 779 | return -EAGAIN; |
778 | if (task->tk_status >= 0) | 780 | nfs_refresh_inode(data->inode, data->res.fattr); |
779 | nfs_post_op_update_inode(data->inode, data->res.fattr); | ||
780 | return 0; | 781 | return 0; |
781 | } | 782 | } |
782 | 783 | ||
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c index d9e08f0cf2a0..616d3267b7e7 100644 --- a/fs/nfs/nfs3xdr.c +++ b/fs/nfs/nfs3xdr.c | |||
@@ -346,6 +346,7 @@ nfs3_xdr_readargs(struct rpc_rqst *req, __be32 *p, struct nfs_readargs *args) | |||
346 | replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS3_readres_sz) << 2; | 346 | replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS3_readres_sz) << 2; |
347 | xdr_inline_pages(&req->rq_rcv_buf, replen, | 347 | xdr_inline_pages(&req->rq_rcv_buf, replen, |
348 | args->pages, args->pgbase, count); | 348 | args->pages, args->pgbase, count); |
349 | req->rq_rcv_buf.flags |= XDRBUF_READ; | ||
349 | return 0; | 350 | return 0; |
350 | } | 351 | } |
351 | 352 | ||
@@ -367,6 +368,7 @@ nfs3_xdr_writeargs(struct rpc_rqst *req, __be32 *p, struct nfs_writeargs *args) | |||
367 | 368 | ||
368 | /* Copy the page array */ | 369 | /* Copy the page array */ |
369 | xdr_encode_pages(sndbuf, args->pages, args->pgbase, count); | 370 | xdr_encode_pages(sndbuf, args->pages, args->pgbase, count); |
371 | sndbuf->flags |= XDRBUF_WRITE; | ||
370 | return 0; | 372 | return 0; |
371 | } | 373 | } |
372 | 374 | ||
@@ -524,7 +526,7 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res | |||
524 | 526 | ||
525 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; | 527 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; |
526 | if (iov->iov_len < hdrlen) { | 528 | if (iov->iov_len < hdrlen) { |
527 | printk(KERN_WARNING "NFS: READDIR reply header overflowed:" | 529 | dprintk("NFS: READDIR reply header overflowed:" |
528 | "length %d > %Zu\n", hdrlen, iov->iov_len); | 530 | "length %d > %Zu\n", hdrlen, iov->iov_len); |
529 | return -errno_NFSERR_IO; | 531 | return -errno_NFSERR_IO; |
530 | } else if (iov->iov_len != hdrlen) { | 532 | } else if (iov->iov_len != hdrlen) { |
@@ -547,7 +549,7 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res | |||
547 | len = ntohl(*p++); /* string length */ | 549 | len = ntohl(*p++); /* string length */ |
548 | p += XDR_QUADLEN(len) + 2; /* name + cookie */ | 550 | p += XDR_QUADLEN(len) + 2; /* name + cookie */ |
549 | if (len > NFS3_MAXNAMLEN) { | 551 | if (len > NFS3_MAXNAMLEN) { |
550 | printk(KERN_WARNING "NFS: giant filename in readdir (len %x)!\n", | 552 | dprintk("NFS: giant filename in readdir (len %x)!\n", |
551 | len); | 553 | len); |
552 | goto err_unmap; | 554 | goto err_unmap; |
553 | } | 555 | } |
@@ -567,7 +569,7 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res | |||
567 | goto short_pkt; | 569 | goto short_pkt; |
568 | len = ntohl(*p++); | 570 | len = ntohl(*p++); |
569 | if (len > NFS3_FHSIZE) { | 571 | if (len > NFS3_FHSIZE) { |
570 | printk(KERN_WARNING "NFS: giant filehandle in " | 572 | dprintk("NFS: giant filehandle in " |
571 | "readdir (len %x)!\n", len); | 573 | "readdir (len %x)!\n", len); |
572 | goto err_unmap; | 574 | goto err_unmap; |
573 | } | 575 | } |
@@ -588,7 +590,7 @@ nfs3_xdr_readdirres(struct rpc_rqst *req, __be32 *p, struct nfs3_readdirres *res | |||
588 | entry[0] = entry[1] = 0; | 590 | entry[0] = entry[1] = 0; |
589 | /* truncate listing ? */ | 591 | /* truncate listing ? */ |
590 | if (!nr) { | 592 | if (!nr) { |
591 | printk(KERN_NOTICE "NFS: readdir reply truncated!\n"); | 593 | dprintk("NFS: readdir reply truncated!\n"); |
592 | entry[1] = 1; | 594 | entry[1] = 1; |
593 | } | 595 | } |
594 | goto out; | 596 | goto out; |
@@ -826,22 +828,23 @@ nfs3_xdr_readlinkres(struct rpc_rqst *req, __be32 *p, struct nfs_fattr *fattr) | |||
826 | /* Convert length of symlink */ | 828 | /* Convert length of symlink */ |
827 | len = ntohl(*p++); | 829 | len = ntohl(*p++); |
828 | if (len >= rcvbuf->page_len || len <= 0) { | 830 | if (len >= rcvbuf->page_len || len <= 0) { |
829 | dprintk(KERN_WARNING "nfs: server returned giant symlink!\n"); | 831 | dprintk("nfs: server returned giant symlink!\n"); |
830 | return -ENAMETOOLONG; | 832 | return -ENAMETOOLONG; |
831 | } | 833 | } |
832 | 834 | ||
833 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; | 835 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; |
834 | if (iov->iov_len < hdrlen) { | 836 | if (iov->iov_len < hdrlen) { |
835 | printk(KERN_WARNING "NFS: READLINK reply header overflowed:" | 837 | dprintk("NFS: READLINK reply header overflowed:" |
836 | "length %d > %Zu\n", hdrlen, iov->iov_len); | 838 | "length %d > %Zu\n", hdrlen, iov->iov_len); |
837 | return -errno_NFSERR_IO; | 839 | return -errno_NFSERR_IO; |
838 | } else if (iov->iov_len != hdrlen) { | 840 | } else if (iov->iov_len != hdrlen) { |
839 | dprintk("NFS: READLINK header is short. iovec will be shifted.\n"); | 841 | dprintk("NFS: READLINK header is short. " |
842 | "iovec will be shifted.\n"); | ||
840 | xdr_shift_buf(rcvbuf, iov->iov_len - hdrlen); | 843 | xdr_shift_buf(rcvbuf, iov->iov_len - hdrlen); |
841 | } | 844 | } |
842 | recvd = req->rq_rcv_buf.len - hdrlen; | 845 | recvd = req->rq_rcv_buf.len - hdrlen; |
843 | if (recvd < len) { | 846 | if (recvd < len) { |
844 | printk(KERN_WARNING "NFS: server cheating in readlink reply: " | 847 | dprintk("NFS: server cheating in readlink reply: " |
845 | "count %u > recvd %u\n", len, recvd); | 848 | "count %u > recvd %u\n", len, recvd); |
846 | return -EIO; | 849 | return -EIO; |
847 | } | 850 | } |
@@ -876,13 +879,13 @@ nfs3_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res) | |||
876 | ocount = ntohl(*p++); | 879 | ocount = ntohl(*p++); |
877 | 880 | ||
878 | if (ocount != count) { | 881 | if (ocount != count) { |
879 | printk(KERN_WARNING "NFS: READ count doesn't match RPC opaque count.\n"); | 882 | dprintk("NFS: READ count doesn't match RPC opaque count.\n"); |
880 | return -errno_NFSERR_IO; | 883 | return -errno_NFSERR_IO; |
881 | } | 884 | } |
882 | 885 | ||
883 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; | 886 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; |
884 | if (iov->iov_len < hdrlen) { | 887 | if (iov->iov_len < hdrlen) { |
885 | printk(KERN_WARNING "NFS: READ reply header overflowed:" | 888 | dprintk("NFS: READ reply header overflowed:" |
886 | "length %d > %Zu\n", hdrlen, iov->iov_len); | 889 | "length %d > %Zu\n", hdrlen, iov->iov_len); |
887 | return -errno_NFSERR_IO; | 890 | return -errno_NFSERR_IO; |
888 | } else if (iov->iov_len != hdrlen) { | 891 | } else if (iov->iov_len != hdrlen) { |
@@ -892,7 +895,7 @@ nfs3_xdr_readres(struct rpc_rqst *req, __be32 *p, struct nfs_readres *res) | |||
892 | 895 | ||
893 | recvd = req->rq_rcv_buf.len - hdrlen; | 896 | recvd = req->rq_rcv_buf.len - hdrlen; |
894 | if (count > recvd) { | 897 | if (count > recvd) { |
895 | printk(KERN_WARNING "NFS: server cheating in read reply: " | 898 | dprintk("NFS: server cheating in read reply: " |
896 | "count %d > recvd %d\n", count, recvd); | 899 | "count %d > recvd %d\n", count, recvd); |
897 | count = recvd; | 900 | count = recvd; |
898 | res->eof = 0; | 901 | res->eof = 0; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 4b90e17555a9..cb99fd90a9ac 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -62,10 +62,8 @@ struct nfs4_opendata; | |||
62 | static int _nfs4_proc_open(struct nfs4_opendata *data); | 62 | static int _nfs4_proc_open(struct nfs4_opendata *data); |
63 | static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); | 63 | static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *); |
64 | static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *); | 64 | static int nfs4_async_handle_error(struct rpc_task *, const struct nfs_server *); |
65 | static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry); | ||
66 | static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct nfs4_exception *exception); | 65 | static int nfs4_handle_exception(const struct nfs_server *server, int errorcode, struct nfs4_exception *exception); |
67 | static int nfs4_wait_clnt_recover(struct rpc_clnt *clnt, struct nfs_client *clp); | 66 | static int nfs4_wait_clnt_recover(struct rpc_clnt *clnt, struct nfs_client *clp); |
68 | static int _nfs4_do_access(struct inode *inode, struct rpc_cred *cred, int openflags); | ||
69 | static int _nfs4_proc_lookup(struct inode *dir, const struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr); | 67 | static int _nfs4_proc_lookup(struct inode *dir, const struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr); |
70 | static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr); | 68 | static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr); |
71 | 69 | ||
@@ -177,7 +175,7 @@ static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dent | |||
177 | *p++ = xdr_one; /* bitmap length */ | 175 | *p++ = xdr_one; /* bitmap length */ |
178 | *p++ = htonl(FATTR4_WORD0_FILEID); /* bitmap */ | 176 | *p++ = htonl(FATTR4_WORD0_FILEID); /* bitmap */ |
179 | *p++ = htonl(8); /* attribute buffer length */ | 177 | *p++ = htonl(8); /* attribute buffer length */ |
180 | p = xdr_encode_hyper(p, dentry->d_inode->i_ino); | 178 | p = xdr_encode_hyper(p, NFS_FILEID(dentry->d_inode)); |
181 | } | 179 | } |
182 | 180 | ||
183 | *p++ = xdr_one; /* next */ | 181 | *p++ = xdr_one; /* next */ |
@@ -189,7 +187,7 @@ static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dent | |||
189 | *p++ = xdr_one; /* bitmap length */ | 187 | *p++ = xdr_one; /* bitmap length */ |
190 | *p++ = htonl(FATTR4_WORD0_FILEID); /* bitmap */ | 188 | *p++ = htonl(FATTR4_WORD0_FILEID); /* bitmap */ |
191 | *p++ = htonl(8); /* attribute buffer length */ | 189 | *p++ = htonl(8); /* attribute buffer length */ |
192 | p = xdr_encode_hyper(p, dentry->d_parent->d_inode->i_ino); | 190 | p = xdr_encode_hyper(p, NFS_FILEID(dentry->d_parent->d_inode)); |
193 | 191 | ||
194 | readdir->pgbase = (char *)p - (char *)start; | 192 | readdir->pgbase = (char *)p - (char *)start; |
195 | readdir->count -= readdir->pgbase; | 193 | readdir->count -= readdir->pgbase; |
@@ -211,8 +209,9 @@ static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo) | |||
211 | 209 | ||
212 | spin_lock(&dir->i_lock); | 210 | spin_lock(&dir->i_lock); |
213 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA; | 211 | nfsi->cache_validity |= NFS_INO_INVALID_ATTR|NFS_INO_REVAL_PAGECACHE|NFS_INO_INVALID_DATA; |
214 | if (cinfo->before == nfsi->change_attr && cinfo->atomic) | 212 | if (!cinfo->atomic || cinfo->before != nfsi->change_attr) |
215 | nfsi->change_attr = cinfo->after; | 213 | nfsi->cache_change_attribute = jiffies; |
214 | nfsi->change_attr = cinfo->after; | ||
216 | spin_unlock(&dir->i_lock); | 215 | spin_unlock(&dir->i_lock); |
217 | } | 216 | } |
218 | 217 | ||
@@ -454,7 +453,7 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata) | |||
454 | memcpy(stateid.data, delegation->stateid.data, sizeof(stateid.data)); | 453 | memcpy(stateid.data, delegation->stateid.data, sizeof(stateid.data)); |
455 | rcu_read_unlock(); | 454 | rcu_read_unlock(); |
456 | lock_kernel(); | 455 | lock_kernel(); |
457 | ret = _nfs4_do_access(state->inode, state->owner->so_cred, open_mode); | 456 | ret = nfs_may_open(state->inode, state->owner->so_cred, open_mode); |
458 | unlock_kernel(); | 457 | unlock_kernel(); |
459 | if (ret != 0) | 458 | if (ret != 0) |
460 | goto out; | 459 | goto out; |
@@ -948,36 +947,6 @@ static int _nfs4_proc_open(struct nfs4_opendata *data) | |||
948 | return 0; | 947 | return 0; |
949 | } | 948 | } |
950 | 949 | ||
951 | static int _nfs4_do_access(struct inode *inode, struct rpc_cred *cred, int openflags) | ||
952 | { | ||
953 | struct nfs_access_entry cache; | ||
954 | int mask = 0; | ||
955 | int status; | ||
956 | |||
957 | if (openflags & FMODE_READ) | ||
958 | mask |= MAY_READ; | ||
959 | if (openflags & FMODE_WRITE) | ||
960 | mask |= MAY_WRITE; | ||
961 | if (openflags & FMODE_EXEC) | ||
962 | mask |= MAY_EXEC; | ||
963 | status = nfs_access_get_cached(inode, cred, &cache); | ||
964 | if (status == 0) | ||
965 | goto out; | ||
966 | |||
967 | /* Be clever: ask server to check for all possible rights */ | ||
968 | cache.mask = MAY_EXEC | MAY_WRITE | MAY_READ; | ||
969 | cache.cred = cred; | ||
970 | cache.jiffies = jiffies; | ||
971 | status = _nfs4_proc_access(inode, &cache); | ||
972 | if (status != 0) | ||
973 | return status; | ||
974 | nfs_access_add_cache(inode, &cache); | ||
975 | out: | ||
976 | if ((cache.mask & mask) == mask) | ||
977 | return 0; | ||
978 | return -EACCES; | ||
979 | } | ||
980 | |||
981 | static int nfs4_recover_expired_lease(struct nfs_server *server) | 950 | static int nfs4_recover_expired_lease(struct nfs_server *server) |
982 | { | 951 | { |
983 | struct nfs_client *clp = server->nfs_client; | 952 | struct nfs_client *clp = server->nfs_client; |
@@ -1381,7 +1350,7 @@ static int nfs4_intent_set_file(struct nameidata *nd, struct path *path, struct | |||
1381 | 1350 | ||
1382 | /* If the open_intent is for execute, we have an extra check to make */ | 1351 | /* If the open_intent is for execute, we have an extra check to make */ |
1383 | if (nd->intent.open.flags & FMODE_EXEC) { | 1352 | if (nd->intent.open.flags & FMODE_EXEC) { |
1384 | ret = _nfs4_do_access(state->inode, | 1353 | ret = nfs_may_open(state->inode, |
1385 | state->owner->so_cred, | 1354 | state->owner->so_cred, |
1386 | nd->intent.open.flags); | 1355 | nd->intent.open.flags); |
1387 | if (ret < 0) | 1356 | if (ret < 0) |
@@ -1390,7 +1359,7 @@ static int nfs4_intent_set_file(struct nameidata *nd, struct path *path, struct | |||
1390 | filp = lookup_instantiate_filp(nd, path->dentry, NULL); | 1359 | filp = lookup_instantiate_filp(nd, path->dentry, NULL); |
1391 | if (!IS_ERR(filp)) { | 1360 | if (!IS_ERR(filp)) { |
1392 | struct nfs_open_context *ctx; | 1361 | struct nfs_open_context *ctx; |
1393 | ctx = (struct nfs_open_context *)filp->private_data; | 1362 | ctx = nfs_file_open_context(filp); |
1394 | ctx->state = state; | 1363 | ctx->state = state; |
1395 | return 0; | 1364 | return 0; |
1396 | } | 1365 | } |
@@ -1428,13 +1397,16 @@ nfs4_atomic_open(struct inode *dir, struct dentry *dentry, struct nameidata *nd) | |||
1428 | state = nfs4_do_open(dir, &path, nd->intent.open.flags, &attr, cred); | 1397 | state = nfs4_do_open(dir, &path, nd->intent.open.flags, &attr, cred); |
1429 | put_rpccred(cred); | 1398 | put_rpccred(cred); |
1430 | if (IS_ERR(state)) { | 1399 | if (IS_ERR(state)) { |
1431 | if (PTR_ERR(state) == -ENOENT) | 1400 | if (PTR_ERR(state) == -ENOENT) { |
1432 | d_add(dentry, NULL); | 1401 | d_add(dentry, NULL); |
1402 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | ||
1403 | } | ||
1433 | return (struct dentry *)state; | 1404 | return (struct dentry *)state; |
1434 | } | 1405 | } |
1435 | res = d_add_unique(dentry, igrab(state->inode)); | 1406 | res = d_add_unique(dentry, igrab(state->inode)); |
1436 | if (res != NULL) | 1407 | if (res != NULL) |
1437 | path.dentry = res; | 1408 | path.dentry = res; |
1409 | nfs_set_verifier(path.dentry, nfs_save_change_attribute(dir)); | ||
1438 | nfs4_intent_set_file(nd, &path, state); | 1410 | nfs4_intent_set_file(nd, &path, state); |
1439 | return res; | 1411 | return res; |
1440 | } | 1412 | } |
@@ -1468,6 +1440,7 @@ nfs4_open_revalidate(struct inode *dir, struct dentry *dentry, int openflags, st | |||
1468 | } | 1440 | } |
1469 | } | 1441 | } |
1470 | if (state->inode == dentry->d_inode) { | 1442 | if (state->inode == dentry->d_inode) { |
1443 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | ||
1471 | nfs4_intent_set_file(nd, &path, state); | 1444 | nfs4_intent_set_file(nd, &path, state); |
1472 | return 1; | 1445 | return 1; |
1473 | } | 1446 | } |
@@ -1757,10 +1730,16 @@ static int nfs4_proc_lookup(struct inode *dir, struct qstr *name, struct nfs_fh | |||
1757 | 1730 | ||
1758 | static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) | 1731 | static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry) |
1759 | { | 1732 | { |
1733 | struct nfs_server *server = NFS_SERVER(inode); | ||
1734 | struct nfs_fattr fattr; | ||
1760 | struct nfs4_accessargs args = { | 1735 | struct nfs4_accessargs args = { |
1761 | .fh = NFS_FH(inode), | 1736 | .fh = NFS_FH(inode), |
1737 | .bitmask = server->attr_bitmask, | ||
1738 | }; | ||
1739 | struct nfs4_accessres res = { | ||
1740 | .server = server, | ||
1741 | .fattr = &fattr, | ||
1762 | }; | 1742 | }; |
1763 | struct nfs4_accessres res = { 0 }; | ||
1764 | struct rpc_message msg = { | 1743 | struct rpc_message msg = { |
1765 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_ACCESS], | 1744 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_ACCESS], |
1766 | .rpc_argp = &args, | 1745 | .rpc_argp = &args, |
@@ -1786,6 +1765,7 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry | |||
1786 | if (mode & MAY_EXEC) | 1765 | if (mode & MAY_EXEC) |
1787 | args.access |= NFS4_ACCESS_EXECUTE; | 1766 | args.access |= NFS4_ACCESS_EXECUTE; |
1788 | } | 1767 | } |
1768 | nfs_fattr_init(&fattr); | ||
1789 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); | 1769 | status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0); |
1790 | if (!status) { | 1770 | if (!status) { |
1791 | entry->mask = 0; | 1771 | entry->mask = 0; |
@@ -1795,6 +1775,7 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry | |||
1795 | entry->mask |= MAY_WRITE; | 1775 | entry->mask |= MAY_WRITE; |
1796 | if (res.access & (NFS4_ACCESS_LOOKUP|NFS4_ACCESS_EXECUTE)) | 1776 | if (res.access & (NFS4_ACCESS_LOOKUP|NFS4_ACCESS_EXECUTE)) |
1797 | entry->mask |= MAY_EXEC; | 1777 | entry->mask |= MAY_EXEC; |
1778 | nfs_refresh_inode(inode, &fattr); | ||
1798 | } | 1779 | } |
1799 | return status; | 1780 | return status; |
1800 | } | 1781 | } |
@@ -1900,11 +1881,13 @@ nfs4_proc_create(struct inode *dir, struct dentry *dentry, struct iattr *sattr, | |||
1900 | } | 1881 | } |
1901 | state = nfs4_do_open(dir, &path, flags, sattr, cred); | 1882 | state = nfs4_do_open(dir, &path, flags, sattr, cred); |
1902 | put_rpccred(cred); | 1883 | put_rpccred(cred); |
1884 | d_drop(dentry); | ||
1903 | if (IS_ERR(state)) { | 1885 | if (IS_ERR(state)) { |
1904 | status = PTR_ERR(state); | 1886 | status = PTR_ERR(state); |
1905 | goto out; | 1887 | goto out; |
1906 | } | 1888 | } |
1907 | d_instantiate(dentry, igrab(state->inode)); | 1889 | d_add(dentry, igrab(state->inode)); |
1890 | nfs_set_verifier(dentry, nfs_save_change_attribute(dir)); | ||
1908 | if (flags & O_EXCL) { | 1891 | if (flags & O_EXCL) { |
1909 | struct nfs_fattr fattr; | 1892 | struct nfs_fattr fattr; |
1910 | status = nfs4_do_setattr(state->inode, &fattr, sattr, state); | 1893 | status = nfs4_do_setattr(state->inode, &fattr, sattr, state); |
@@ -2218,6 +2201,9 @@ static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, | |||
2218 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 2201 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
2219 | if (status == 0) | 2202 | if (status == 0) |
2220 | memcpy(NFS_COOKIEVERF(dir), res.verifier.data, NFS4_VERIFIER_SIZE); | 2203 | memcpy(NFS_COOKIEVERF(dir), res.verifier.data, NFS4_VERIFIER_SIZE); |
2204 | |||
2205 | nfs_invalidate_atime(dir); | ||
2206 | |||
2221 | dprintk("%s: returns %d\n", __FUNCTION__, status); | 2207 | dprintk("%s: returns %d\n", __FUNCTION__, status); |
2222 | return status; | 2208 | return status; |
2223 | } | 2209 | } |
@@ -2414,6 +2400,8 @@ static int nfs4_read_done(struct rpc_task *task, struct nfs_read_data *data) | |||
2414 | rpc_restart_call(task); | 2400 | rpc_restart_call(task); |
2415 | return -EAGAIN; | 2401 | return -EAGAIN; |
2416 | } | 2402 | } |
2403 | |||
2404 | nfs_invalidate_atime(data->inode); | ||
2417 | if (task->tk_status > 0) | 2405 | if (task->tk_status > 0) |
2418 | renew_lease(server, data->timestamp); | 2406 | renew_lease(server, data->timestamp); |
2419 | return 0; | 2407 | return 0; |
@@ -2443,7 +2431,7 @@ static int nfs4_write_done(struct rpc_task *task, struct nfs_write_data *data) | |||
2443 | } | 2431 | } |
2444 | if (task->tk_status >= 0) { | 2432 | if (task->tk_status >= 0) { |
2445 | renew_lease(NFS_SERVER(inode), data->timestamp); | 2433 | renew_lease(NFS_SERVER(inode), data->timestamp); |
2446 | nfs_post_op_update_inode(inode, data->res.fattr); | 2434 | nfs_post_op_update_inode_force_wcc(inode, data->res.fattr); |
2447 | } | 2435 | } |
2448 | return 0; | 2436 | return 0; |
2449 | } | 2437 | } |
@@ -2485,8 +2473,7 @@ static int nfs4_commit_done(struct rpc_task *task, struct nfs_write_data *data) | |||
2485 | rpc_restart_call(task); | 2473 | rpc_restart_call(task); |
2486 | return -EAGAIN; | 2474 | return -EAGAIN; |
2487 | } | 2475 | } |
2488 | if (task->tk_status >= 0) | 2476 | nfs_refresh_inode(inode, data->res.fattr); |
2489 | nfs_post_op_update_inode(inode, data->res.fattr); | ||
2490 | return 0; | 2477 | return 0; |
2491 | } | 2478 | } |
2492 | 2479 | ||
@@ -3056,7 +3043,7 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co | |||
3056 | if (status == 0) { | 3043 | if (status == 0) { |
3057 | status = data->rpc_status; | 3044 | status = data->rpc_status; |
3058 | if (status == 0) | 3045 | if (status == 0) |
3059 | nfs_post_op_update_inode(inode, &data->fattr); | 3046 | nfs_refresh_inode(inode, &data->fattr); |
3060 | } | 3047 | } |
3061 | rpc_put_task(task); | 3048 | rpc_put_task(task); |
3062 | return status; | 3049 | return status; |
@@ -3303,7 +3290,7 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * | |||
3303 | status = -ENOMEM; | 3290 | status = -ENOMEM; |
3304 | if (seqid == NULL) | 3291 | if (seqid == NULL) |
3305 | goto out; | 3292 | goto out; |
3306 | task = nfs4_do_unlck(request, request->fl_file->private_data, lsp, seqid); | 3293 | task = nfs4_do_unlck(request, nfs_file_open_context(request->fl_file), lsp, seqid); |
3307 | status = PTR_ERR(task); | 3294 | status = PTR_ERR(task); |
3308 | if (IS_ERR(task)) | 3295 | if (IS_ERR(task)) |
3309 | goto out; | 3296 | goto out; |
@@ -3447,7 +3434,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f | |||
3447 | int ret; | 3434 | int ret; |
3448 | 3435 | ||
3449 | dprintk("%s: begin!\n", __FUNCTION__); | 3436 | dprintk("%s: begin!\n", __FUNCTION__); |
3450 | data = nfs4_alloc_lockdata(fl, fl->fl_file->private_data, | 3437 | data = nfs4_alloc_lockdata(fl, nfs_file_open_context(fl->fl_file), |
3451 | fl->fl_u.nfs4_fl.owner); | 3438 | fl->fl_u.nfs4_fl.owner); |
3452 | if (data == NULL) | 3439 | if (data == NULL) |
3453 | return -ENOMEM; | 3440 | return -ENOMEM; |
@@ -3573,7 +3560,7 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request) | |||
3573 | int status; | 3560 | int status; |
3574 | 3561 | ||
3575 | /* verify open state */ | 3562 | /* verify open state */ |
3576 | ctx = (struct nfs_open_context *)filp->private_data; | 3563 | ctx = nfs_file_open_context(filp); |
3577 | state = ctx->state; | 3564 | state = ctx->state; |
3578 | 3565 | ||
3579 | if (request->fl_start < 0 || request->fl_end < 0) | 3566 | if (request->fl_start < 0 || request->fl_end < 0) |
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 3e4adf8c8312..bfb36261cecb 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c | |||
@@ -774,7 +774,7 @@ static int nfs4_reclaim_locks(struct nfs4_state_recovery_ops *ops, struct nfs4_s | |||
774 | for (fl = inode->i_flock; fl != 0; fl = fl->fl_next) { | 774 | for (fl = inode->i_flock; fl != 0; fl = fl->fl_next) { |
775 | if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) | 775 | if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) |
776 | continue; | 776 | continue; |
777 | if (((struct nfs_open_context *)fl->fl_file->private_data)->state != state) | 777 | if (nfs_file_open_context(fl->fl_file)->state != state) |
778 | continue; | 778 | continue; |
779 | status = ops->recover_lock(state, fl); | 779 | status = ops->recover_lock(state, fl); |
780 | if (status >= 0) | 780 | if (status >= 0) |
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index badd73b7ca12..51dd3804866f 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -376,10 +376,12 @@ static int nfs4_stat_to_errno(int); | |||
376 | decode_locku_maxsz) | 376 | decode_locku_maxsz) |
377 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ | 377 | #define NFS4_enc_access_sz (compound_encode_hdr_maxsz + \ |
378 | encode_putfh_maxsz + \ | 378 | encode_putfh_maxsz + \ |
379 | encode_access_maxsz) | 379 | encode_access_maxsz + \ |
380 | encode_getattr_maxsz) | ||
380 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ | 381 | #define NFS4_dec_access_sz (compound_decode_hdr_maxsz + \ |
381 | decode_putfh_maxsz + \ | 382 | decode_putfh_maxsz + \ |
382 | decode_access_maxsz) | 383 | decode_access_maxsz + \ |
384 | decode_getattr_maxsz) | ||
383 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ | 385 | #define NFS4_enc_getattr_sz (compound_encode_hdr_maxsz + \ |
384 | encode_putfh_maxsz + \ | 386 | encode_putfh_maxsz + \ |
385 | encode_getattr_maxsz) | 387 | encode_getattr_maxsz) |
@@ -562,7 +564,6 @@ struct compound_hdr { | |||
562 | 564 | ||
563 | #define RESERVE_SPACE(nbytes) do { \ | 565 | #define RESERVE_SPACE(nbytes) do { \ |
564 | p = xdr_reserve_space(xdr, nbytes); \ | 566 | p = xdr_reserve_space(xdr, nbytes); \ |
565 | if (!p) printk("RESERVE_SPACE(%d) failed in function %s\n", (int) (nbytes), __FUNCTION__); \ | ||
566 | BUG_ON(!p); \ | 567 | BUG_ON(!p); \ |
567 | } while (0) | 568 | } while (0) |
568 | 569 | ||
@@ -628,8 +629,8 @@ static int encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const s | |||
628 | if (iap->ia_valid & ATTR_UID) { | 629 | if (iap->ia_valid & ATTR_UID) { |
629 | owner_namelen = nfs_map_uid_to_name(server->nfs_client, iap->ia_uid, owner_name); | 630 | owner_namelen = nfs_map_uid_to_name(server->nfs_client, iap->ia_uid, owner_name); |
630 | if (owner_namelen < 0) { | 631 | if (owner_namelen < 0) { |
631 | printk(KERN_WARNING "nfs: couldn't resolve uid %d to string\n", | 632 | dprintk("nfs: couldn't resolve uid %d to string\n", |
632 | iap->ia_uid); | 633 | iap->ia_uid); |
633 | /* XXX */ | 634 | /* XXX */ |
634 | strcpy(owner_name, "nobody"); | 635 | strcpy(owner_name, "nobody"); |
635 | owner_namelen = sizeof("nobody") - 1; | 636 | owner_namelen = sizeof("nobody") - 1; |
@@ -640,8 +641,8 @@ static int encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const s | |||
640 | if (iap->ia_valid & ATTR_GID) { | 641 | if (iap->ia_valid & ATTR_GID) { |
641 | owner_grouplen = nfs_map_gid_to_group(server->nfs_client, iap->ia_gid, owner_group); | 642 | owner_grouplen = nfs_map_gid_to_group(server->nfs_client, iap->ia_gid, owner_group); |
642 | if (owner_grouplen < 0) { | 643 | if (owner_grouplen < 0) { |
643 | printk(KERN_WARNING "nfs4: couldn't resolve gid %d to string\n", | 644 | dprintk("nfs: couldn't resolve gid %d to string\n", |
644 | iap->ia_gid); | 645 | iap->ia_gid); |
645 | strcpy(owner_group, "nobody"); | 646 | strcpy(owner_group, "nobody"); |
646 | owner_grouplen = sizeof("nobody") - 1; | 647 | owner_grouplen = sizeof("nobody") - 1; |
647 | /* goto out; */ | 648 | /* goto out; */ |
@@ -711,7 +712,7 @@ static int encode_attrs(struct xdr_stream *xdr, const struct iattr *iap, const s | |||
711 | * Now we backfill the bitmap and the attribute buffer length. | 712 | * Now we backfill the bitmap and the attribute buffer length. |
712 | */ | 713 | */ |
713 | if (len != ((char *)p - (char *)q) + 4) { | 714 | if (len != ((char *)p - (char *)q) + 4) { |
714 | printk ("encode_attr: Attr length calculation error! %u != %Zu\n", | 715 | printk(KERN_ERR "nfs: Attr length error, %u != %Zu\n", |
715 | len, ((char *)p - (char *)q) + 4); | 716 | len, ((char *)p - (char *)q) + 4); |
716 | BUG(); | 717 | BUG(); |
717 | } | 718 | } |
@@ -1376,14 +1377,20 @@ static int nfs4_xdr_enc_access(struct rpc_rqst *req, __be32 *p, const struct nfs | |||
1376 | { | 1377 | { |
1377 | struct xdr_stream xdr; | 1378 | struct xdr_stream xdr; |
1378 | struct compound_hdr hdr = { | 1379 | struct compound_hdr hdr = { |
1379 | .nops = 2, | 1380 | .nops = 3, |
1380 | }; | 1381 | }; |
1381 | int status; | 1382 | int status; |
1382 | 1383 | ||
1383 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); | 1384 | xdr_init_encode(&xdr, &req->rq_snd_buf, p); |
1384 | encode_compound_hdr(&xdr, &hdr); | 1385 | encode_compound_hdr(&xdr, &hdr); |
1385 | if ((status = encode_putfh(&xdr, args->fh)) == 0) | 1386 | status = encode_putfh(&xdr, args->fh); |
1386 | status = encode_access(&xdr, args->access); | 1387 | if (status != 0) |
1388 | goto out; | ||
1389 | status = encode_access(&xdr, args->access); | ||
1390 | if (status != 0) | ||
1391 | goto out; | ||
1392 | status = encode_getfattr(&xdr, args->bitmask); | ||
1393 | out: | ||
1387 | return status; | 1394 | return status; |
1388 | } | 1395 | } |
1389 | 1396 | ||
@@ -1857,6 +1864,7 @@ static int nfs4_xdr_enc_read(struct rpc_rqst *req, __be32 *p, struct nfs_readarg | |||
1857 | replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_read_sz) << 2; | 1864 | replen = (RPC_REPHDRSIZE + auth->au_rslack + NFS4_dec_read_sz) << 2; |
1858 | xdr_inline_pages(&req->rq_rcv_buf, replen, | 1865 | xdr_inline_pages(&req->rq_rcv_buf, replen, |
1859 | args->pages, args->pgbase, args->count); | 1866 | args->pages, args->pgbase, args->count); |
1867 | req->rq_rcv_buf.flags |= XDRBUF_READ; | ||
1860 | out: | 1868 | out: |
1861 | return status; | 1869 | return status; |
1862 | } | 1870 | } |
@@ -1933,6 +1941,7 @@ static int nfs4_xdr_enc_write(struct rpc_rqst *req, __be32 *p, struct nfs_writea | |||
1933 | status = encode_write(&xdr, args); | 1941 | status = encode_write(&xdr, args); |
1934 | if (status) | 1942 | if (status) |
1935 | goto out; | 1943 | goto out; |
1944 | req->rq_snd_buf.flags |= XDRBUF_WRITE; | ||
1936 | status = encode_getfattr(&xdr, args->bitmask); | 1945 | status = encode_getfattr(&xdr, args->bitmask); |
1937 | out: | 1946 | out: |
1938 | return status; | 1947 | return status; |
@@ -2180,9 +2189,9 @@ out: | |||
2180 | #define READ_BUF(nbytes) do { \ | 2189 | #define READ_BUF(nbytes) do { \ |
2181 | p = xdr_inline_decode(xdr, nbytes); \ | 2190 | p = xdr_inline_decode(xdr, nbytes); \ |
2182 | if (unlikely(!p)) { \ | 2191 | if (unlikely(!p)) { \ |
2183 | printk(KERN_INFO "%s: prematurely hit end of receive" \ | 2192 | dprintk("nfs: %s: prematurely hit end of receive" \ |
2184 | " buffer\n", __FUNCTION__); \ | 2193 | " buffer\n", __FUNCTION__); \ |
2185 | printk(KERN_INFO "%s: xdr->p=%p, bytes=%u, xdr->end=%p\n", \ | 2194 | dprintk("nfs: %s: xdr->p=%p, bytes=%u, xdr->end=%p\n", \ |
2186 | __FUNCTION__, xdr->p, nbytes, xdr->end); \ | 2195 | __FUNCTION__, xdr->p, nbytes, xdr->end); \ |
2187 | return -EIO; \ | 2196 | return -EIO; \ |
2188 | } \ | 2197 | } \ |
@@ -2223,9 +2232,8 @@ static int decode_op_hdr(struct xdr_stream *xdr, enum nfs_opnum4 expected) | |||
2223 | READ_BUF(8); | 2232 | READ_BUF(8); |
2224 | READ32(opnum); | 2233 | READ32(opnum); |
2225 | if (opnum != expected) { | 2234 | if (opnum != expected) { |
2226 | printk(KERN_NOTICE | 2235 | dprintk("nfs: Server returned operation" |
2227 | "nfs4_decode_op_hdr: Server returned operation" | 2236 | " %d but we issued a request for %d\n", |
2228 | " %d but we issued a request for %d\n", | ||
2229 | opnum, expected); | 2237 | opnum, expected); |
2230 | return -EIO; | 2238 | return -EIO; |
2231 | } | 2239 | } |
@@ -2758,7 +2766,7 @@ static int decode_attr_owner(struct xdr_stream *xdr, uint32_t *bitmap, struct nf | |||
2758 | dprintk("%s: nfs_map_name_to_uid failed!\n", | 2766 | dprintk("%s: nfs_map_name_to_uid failed!\n", |
2759 | __FUNCTION__); | 2767 | __FUNCTION__); |
2760 | } else | 2768 | } else |
2761 | printk(KERN_WARNING "%s: name too long (%u)!\n", | 2769 | dprintk("%s: name too long (%u)!\n", |
2762 | __FUNCTION__, len); | 2770 | __FUNCTION__, len); |
2763 | bitmap[1] &= ~FATTR4_WORD1_OWNER; | 2771 | bitmap[1] &= ~FATTR4_WORD1_OWNER; |
2764 | } | 2772 | } |
@@ -2783,7 +2791,7 @@ static int decode_attr_group(struct xdr_stream *xdr, uint32_t *bitmap, struct nf | |||
2783 | dprintk("%s: nfs_map_group_to_gid failed!\n", | 2791 | dprintk("%s: nfs_map_group_to_gid failed!\n", |
2784 | __FUNCTION__); | 2792 | __FUNCTION__); |
2785 | } else | 2793 | } else |
2786 | printk(KERN_WARNING "%s: name too long (%u)!\n", | 2794 | dprintk("%s: name too long (%u)!\n", |
2787 | __FUNCTION__, len); | 2795 | __FUNCTION__, len); |
2788 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; | 2796 | bitmap[1] &= ~FATTR4_WORD1_OWNER_GROUP; |
2789 | } | 2797 | } |
@@ -2950,7 +2958,8 @@ static int verify_attr_len(struct xdr_stream *xdr, __be32 *savep, uint32_t attrl | |||
2950 | unsigned int nwords = xdr->p - savep; | 2958 | unsigned int nwords = xdr->p - savep; |
2951 | 2959 | ||
2952 | if (unlikely(attrwords != nwords)) { | 2960 | if (unlikely(attrwords != nwords)) { |
2953 | printk(KERN_WARNING "%s: server returned incorrect attribute length: %u %c %u\n", | 2961 | dprintk("%s: server returned incorrect attribute length: " |
2962 | "%u %c %u\n", | ||
2954 | __FUNCTION__, | 2963 | __FUNCTION__, |
2955 | attrwords << 2, | 2964 | attrwords << 2, |
2956 | (attrwords < nwords) ? '<' : '>', | 2965 | (attrwords < nwords) ? '<' : '>', |
@@ -3451,7 +3460,7 @@ static int decode_read(struct xdr_stream *xdr, struct rpc_rqst *req, struct nfs_ | |||
3451 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; | 3460 | hdrlen = (u8 *) p - (u8 *) iov->iov_base; |
3452 | recvd = req->rq_rcv_buf.len - hdrlen; | 3461 | recvd = req->rq_rcv_buf.len - hdrlen; |
3453 | if (count > recvd) { | 3462 | if (count > recvd) { |
3454 | printk(KERN_WARNING "NFS: server cheating in read reply: " | 3463 | dprintk("NFS: server cheating in read reply: " |
3455 | "count %u > recvd %u\n", count, recvd); | 3464 | "count %u > recvd %u\n", count, recvd); |
3456 | count = recvd; | 3465 | count = recvd; |
3457 | eof = 0; | 3466 | eof = 0; |
@@ -3500,7 +3509,8 @@ static int decode_readdir(struct xdr_stream *xdr, struct rpc_rqst *req, struct n | |||
3500 | p += 2; /* cookie */ | 3509 | p += 2; /* cookie */ |
3501 | len = ntohl(*p++); /* filename length */ | 3510 | len = ntohl(*p++); /* filename length */ |
3502 | if (len > NFS4_MAXNAMLEN) { | 3511 | if (len > NFS4_MAXNAMLEN) { |
3503 | printk(KERN_WARNING "NFS: giant filename in readdir (len 0x%x)\n", len); | 3512 | dprintk("NFS: giant filename in readdir (len 0x%x)\n", |
3513 | len); | ||
3504 | goto err_unmap; | 3514 | goto err_unmap; |
3505 | } | 3515 | } |
3506 | xlen = XDR_QUADLEN(len); | 3516 | xlen = XDR_QUADLEN(len); |
@@ -3528,7 +3538,7 @@ short_pkt: | |||
3528 | entry[0] = entry[1] = 0; | 3538 | entry[0] = entry[1] = 0; |
3529 | /* truncate listing ? */ | 3539 | /* truncate listing ? */ |
3530 | if (!nr) { | 3540 | if (!nr) { |
3531 | printk(KERN_NOTICE "NFS: readdir reply truncated!\n"); | 3541 | dprintk("NFS: readdir reply truncated!\n"); |
3532 | entry[1] = 1; | 3542 | entry[1] = 1; |
3533 | } | 3543 | } |
3534 | goto out; | 3544 | goto out; |
@@ -3554,13 +3564,13 @@ static int decode_readlink(struct xdr_stream *xdr, struct rpc_rqst *req) | |||
3554 | READ_BUF(4); | 3564 | READ_BUF(4); |
3555 | READ32(len); | 3565 | READ32(len); |
3556 | if (len >= rcvbuf->page_len || len <= 0) { | 3566 | if (len >= rcvbuf->page_len || len <= 0) { |
3557 | dprintk(KERN_WARNING "nfs: server returned giant symlink!\n"); | 3567 | dprintk("nfs: server returned giant symlink!\n"); |
3558 | return -ENAMETOOLONG; | 3568 | return -ENAMETOOLONG; |
3559 | } | 3569 | } |
3560 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; | 3570 | hdrlen = (char *) xdr->p - (char *) iov->iov_base; |
3561 | recvd = req->rq_rcv_buf.len - hdrlen; | 3571 | recvd = req->rq_rcv_buf.len - hdrlen; |
3562 | if (recvd < len) { | 3572 | if (recvd < len) { |
3563 | printk(KERN_WARNING "NFS: server cheating in readlink reply: " | 3573 | dprintk("NFS: server cheating in readlink reply: " |
3564 | "count %u > recvd %u\n", len, recvd); | 3574 | "count %u > recvd %u\n", len, recvd); |
3565 | return -EIO; | 3575 | return -EIO; |
3566 | } | 3576 | } |
@@ -3643,7 +3653,7 @@ static int decode_getacl(struct xdr_stream *xdr, struct rpc_rqst *req, | |||
3643 | hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base; | 3653 | hdrlen = (u8 *)xdr->p - (u8 *)iov->iov_base; |
3644 | recvd = req->rq_rcv_buf.len - hdrlen; | 3654 | recvd = req->rq_rcv_buf.len - hdrlen; |
3645 | if (attrlen > recvd) { | 3655 | if (attrlen > recvd) { |
3646 | printk(KERN_WARNING "NFS: server cheating in getattr" | 3656 | dprintk("NFS: server cheating in getattr" |
3647 | " acl reply: attrlen %u > recvd %u\n", | 3657 | " acl reply: attrlen %u > recvd %u\n", |
3648 | attrlen, recvd); | 3658 | attrlen, recvd); |
3649 | return -EINVAL; | 3659 | return -EINVAL; |
@@ -3688,8 +3698,7 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp) | |||
3688 | READ_BUF(8); | 3698 | READ_BUF(8); |
3689 | READ32(opnum); | 3699 | READ32(opnum); |
3690 | if (opnum != OP_SETCLIENTID) { | 3700 | if (opnum != OP_SETCLIENTID) { |
3691 | printk(KERN_NOTICE | 3701 | dprintk("nfs: decode_setclientid: Server returned operation" |
3692 | "nfs4_decode_setclientid: Server returned operation" | ||
3693 | " %d\n", opnum); | 3702 | " %d\n", opnum); |
3694 | return -EIO; | 3703 | return -EIO; |
3695 | } | 3704 | } |
@@ -3783,8 +3792,13 @@ static int nfs4_xdr_dec_access(struct rpc_rqst *rqstp, __be32 *p, struct nfs4_ac | |||
3783 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); | 3792 | xdr_init_decode(&xdr, &rqstp->rq_rcv_buf, p); |
3784 | if ((status = decode_compound_hdr(&xdr, &hdr)) != 0) | 3793 | if ((status = decode_compound_hdr(&xdr, &hdr)) != 0) |
3785 | goto out; | 3794 | goto out; |
3786 | if ((status = decode_putfh(&xdr)) == 0) | 3795 | status = decode_putfh(&xdr); |
3787 | status = decode_access(&xdr, res); | 3796 | if (status != 0) |
3797 | goto out; | ||
3798 | status = decode_access(&xdr, res); | ||
3799 | if (status != 0) | ||
3800 | goto out; | ||
3801 | decode_getfattr(&xdr, res->fattr, res->server); | ||
3788 | out: | 3802 | out: |
3789 | return status; | 3803 | return status; |
3790 | } | 3804 | } |
diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c index 3490322d1145..e87b44ee9ac9 100644 --- a/fs/nfs/nfsroot.c +++ b/fs/nfs/nfsroot.c | |||
@@ -76,6 +76,7 @@ | |||
76 | #include <linux/fs.h> | 76 | #include <linux/fs.h> |
77 | #include <linux/init.h> | 77 | #include <linux/init.h> |
78 | #include <linux/sunrpc/clnt.h> | 78 | #include <linux/sunrpc/clnt.h> |
79 | #include <linux/sunrpc/xprtsock.h> | ||
79 | #include <linux/nfs.h> | 80 | #include <linux/nfs.h> |
80 | #include <linux/nfs_fs.h> | 81 | #include <linux/nfs_fs.h> |
81 | #include <linux/nfs_mount.h> | 82 | #include <linux/nfs_mount.h> |
@@ -491,7 +492,7 @@ static int __init root_nfs_get_handle(void) | |||
491 | struct sockaddr_in sin; | 492 | struct sockaddr_in sin; |
492 | int status; | 493 | int status; |
493 | int protocol = (nfs_data.flags & NFS_MOUNT_TCP) ? | 494 | int protocol = (nfs_data.flags & NFS_MOUNT_TCP) ? |
494 | IPPROTO_TCP : IPPROTO_UDP; | 495 | XPRT_TRANSPORT_TCP : XPRT_TRANSPORT_UDP; |
495 | int version = (nfs_data.flags & NFS_MOUNT_VER3) ? | 496 | int version = (nfs_data.flags & NFS_MOUNT_VER3) ? |
496 | NFS_MNT3_VERSION : NFS_MNT_VERSION; | 497 | NFS_MNT3_VERSION : NFS_MNT_VERSION; |
497 | 498 | ||
diff --git a/fs/nfs/proc.c b/fs/nfs/proc.c index 845cdde1d8b7..97669ed05500 100644 --- a/fs/nfs/proc.c +++ b/fs/nfs/proc.c | |||
@@ -476,6 +476,8 @@ nfs_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, | |||
476 | dprintk("NFS call readdir %d\n", (unsigned int)cookie); | 476 | dprintk("NFS call readdir %d\n", (unsigned int)cookie); |
477 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); | 477 | status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); |
478 | 478 | ||
479 | nfs_invalidate_atime(dir); | ||
480 | |||
479 | dprintk("NFS reply readdir: %d\n", status); | 481 | dprintk("NFS reply readdir: %d\n", status); |
480 | return status; | 482 | return status; |
481 | } | 483 | } |
@@ -550,6 +552,7 @@ nfs_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, | |||
550 | 552 | ||
551 | static int nfs_read_done(struct rpc_task *task, struct nfs_read_data *data) | 553 | static int nfs_read_done(struct rpc_task *task, struct nfs_read_data *data) |
552 | { | 554 | { |
555 | nfs_invalidate_atime(data->inode); | ||
553 | if (task->tk_status >= 0) { | 556 | if (task->tk_status >= 0) { |
554 | nfs_refresh_inode(data->inode, data->res.fattr); | 557 | nfs_refresh_inode(data->inode, data->res.fattr); |
555 | /* Emulate the eof flag, which isn't normally needed in NFSv2 | 558 | /* Emulate the eof flag, which isn't normally needed in NFSv2 |
@@ -576,7 +579,7 @@ static void nfs_proc_read_setup(struct nfs_read_data *data) | |||
576 | static int nfs_write_done(struct rpc_task *task, struct nfs_write_data *data) | 579 | static int nfs_write_done(struct rpc_task *task, struct nfs_write_data *data) |
577 | { | 580 | { |
578 | if (task->tk_status >= 0) | 581 | if (task->tk_status >= 0) |
579 | nfs_post_op_update_inode(data->inode, data->res.fattr); | 582 | nfs_post_op_update_inode_force_wcc(data->inode, data->res.fattr); |
580 | return 0; | 583 | return 0; |
581 | } | 584 | } |
582 | 585 | ||
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 19e05633f4e3..4587a86adaac 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -341,9 +341,6 @@ int nfs_readpage_result(struct rpc_task *task, struct nfs_read_data *data) | |||
341 | set_bit(NFS_INO_STALE, &NFS_FLAGS(data->inode)); | 341 | set_bit(NFS_INO_STALE, &NFS_FLAGS(data->inode)); |
342 | nfs_mark_for_revalidate(data->inode); | 342 | nfs_mark_for_revalidate(data->inode); |
343 | } | 343 | } |
344 | spin_lock(&data->inode->i_lock); | ||
345 | NFS_I(data->inode)->cache_validity |= NFS_INO_INVALID_ATIME; | ||
346 | spin_unlock(&data->inode->i_lock); | ||
347 | return 0; | 344 | return 0; |
348 | } | 345 | } |
349 | 346 | ||
@@ -497,8 +494,7 @@ int nfs_readpage(struct file *file, struct page *page) | |||
497 | if (ctx == NULL) | 494 | if (ctx == NULL) |
498 | goto out_unlock; | 495 | goto out_unlock; |
499 | } else | 496 | } else |
500 | ctx = get_nfs_open_context((struct nfs_open_context *) | 497 | ctx = get_nfs_open_context(nfs_file_open_context(file)); |
501 | file->private_data); | ||
502 | 498 | ||
503 | error = nfs_readpage_async(ctx, inode, page); | 499 | error = nfs_readpage_async(ctx, inode, page); |
504 | 500 | ||
@@ -576,8 +572,7 @@ int nfs_readpages(struct file *filp, struct address_space *mapping, | |||
576 | if (desc.ctx == NULL) | 572 | if (desc.ctx == NULL) |
577 | return -EBADF; | 573 | return -EBADF; |
578 | } else | 574 | } else |
579 | desc.ctx = get_nfs_open_context((struct nfs_open_context *) | 575 | desc.ctx = get_nfs_open_context(nfs_file_open_context(filp)); |
580 | filp->private_data); | ||
581 | if (rsize < PAGE_CACHE_SIZE) | 576 | if (rsize < PAGE_CACHE_SIZE) |
582 | nfs_pageio_init(&pgio, inode, nfs_pagein_multi, rsize, 0); | 577 | nfs_pageio_init(&pgio, inode, nfs_pagein_multi, rsize, 0); |
583 | else | 578 | else |
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index b878528b64c1..fa517ae9207f 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/sunrpc/clnt.h> | 33 | #include <linux/sunrpc/clnt.h> |
34 | #include <linux/sunrpc/stats.h> | 34 | #include <linux/sunrpc/stats.h> |
35 | #include <linux/sunrpc/metrics.h> | 35 | #include <linux/sunrpc/metrics.h> |
36 | #include <linux/sunrpc/xprtsock.h> | ||
37 | #include <linux/sunrpc/xprtrdma.h> | ||
36 | #include <linux/nfs_fs.h> | 38 | #include <linux/nfs_fs.h> |
37 | #include <linux/nfs_mount.h> | 39 | #include <linux/nfs_mount.h> |
38 | #include <linux/nfs4_mount.h> | 40 | #include <linux/nfs4_mount.h> |
@@ -58,36 +60,6 @@ | |||
58 | 60 | ||
59 | #define NFSDBG_FACILITY NFSDBG_VFS | 61 | #define NFSDBG_FACILITY NFSDBG_VFS |
60 | 62 | ||
61 | |||
62 | struct nfs_parsed_mount_data { | ||
63 | int flags; | ||
64 | int rsize, wsize; | ||
65 | int timeo, retrans; | ||
66 | int acregmin, acregmax, | ||
67 | acdirmin, acdirmax; | ||
68 | int namlen; | ||
69 | unsigned int bsize; | ||
70 | unsigned int auth_flavor_len; | ||
71 | rpc_authflavor_t auth_flavors[1]; | ||
72 | char *client_address; | ||
73 | |||
74 | struct { | ||
75 | struct sockaddr_in address; | ||
76 | unsigned int program; | ||
77 | unsigned int version; | ||
78 | unsigned short port; | ||
79 | int protocol; | ||
80 | } mount_server; | ||
81 | |||
82 | struct { | ||
83 | struct sockaddr_in address; | ||
84 | char *hostname; | ||
85 | char *export_path; | ||
86 | unsigned int program; | ||
87 | int protocol; | ||
88 | } nfs_server; | ||
89 | }; | ||
90 | |||
91 | enum { | 63 | enum { |
92 | /* Mount options that take no arguments */ | 64 | /* Mount options that take no arguments */ |
93 | Opt_soft, Opt_hard, | 65 | Opt_soft, Opt_hard, |
@@ -97,7 +69,7 @@ enum { | |||
97 | Opt_ac, Opt_noac, | 69 | Opt_ac, Opt_noac, |
98 | Opt_lock, Opt_nolock, | 70 | Opt_lock, Opt_nolock, |
99 | Opt_v2, Opt_v3, | 71 | Opt_v2, Opt_v3, |
100 | Opt_udp, Opt_tcp, | 72 | Opt_udp, Opt_tcp, Opt_rdma, |
101 | Opt_acl, Opt_noacl, | 73 | Opt_acl, Opt_noacl, |
102 | Opt_rdirplus, Opt_nordirplus, | 74 | Opt_rdirplus, Opt_nordirplus, |
103 | Opt_sharecache, Opt_nosharecache, | 75 | Opt_sharecache, Opt_nosharecache, |
@@ -116,7 +88,7 @@ enum { | |||
116 | 88 | ||
117 | /* Mount options that take string arguments */ | 89 | /* Mount options that take string arguments */ |
118 | Opt_sec, Opt_proto, Opt_mountproto, | 90 | Opt_sec, Opt_proto, Opt_mountproto, |
119 | Opt_addr, Opt_mounthost, Opt_clientaddr, | 91 | Opt_addr, Opt_mountaddr, Opt_clientaddr, |
120 | 92 | ||
121 | /* Mount options that are ignored */ | 93 | /* Mount options that are ignored */ |
122 | Opt_userspace, Opt_deprecated, | 94 | Opt_userspace, Opt_deprecated, |
@@ -143,6 +115,7 @@ static match_table_t nfs_mount_option_tokens = { | |||
143 | { Opt_v3, "v3" }, | 115 | { Opt_v3, "v3" }, |
144 | { Opt_udp, "udp" }, | 116 | { Opt_udp, "udp" }, |
145 | { Opt_tcp, "tcp" }, | 117 | { Opt_tcp, "tcp" }, |
118 | { Opt_rdma, "rdma" }, | ||
146 | { Opt_acl, "acl" }, | 119 | { Opt_acl, "acl" }, |
147 | { Opt_noacl, "noacl" }, | 120 | { Opt_noacl, "noacl" }, |
148 | { Opt_rdirplus, "rdirplus" }, | 121 | { Opt_rdirplus, "rdirplus" }, |
@@ -175,13 +148,14 @@ static match_table_t nfs_mount_option_tokens = { | |||
175 | { Opt_mountproto, "mountproto=%s" }, | 148 | { Opt_mountproto, "mountproto=%s" }, |
176 | { Opt_addr, "addr=%s" }, | 149 | { Opt_addr, "addr=%s" }, |
177 | { Opt_clientaddr, "clientaddr=%s" }, | 150 | { Opt_clientaddr, "clientaddr=%s" }, |
178 | { Opt_mounthost, "mounthost=%s" }, | 151 | { Opt_userspace, "mounthost=%s" }, |
152 | { Opt_mountaddr, "mountaddr=%s" }, | ||
179 | 153 | ||
180 | { Opt_err, NULL } | 154 | { Opt_err, NULL } |
181 | }; | 155 | }; |
182 | 156 | ||
183 | enum { | 157 | enum { |
184 | Opt_xprt_udp, Opt_xprt_tcp, | 158 | Opt_xprt_udp, Opt_xprt_tcp, Opt_xprt_rdma, |
185 | 159 | ||
186 | Opt_xprt_err | 160 | Opt_xprt_err |
187 | }; | 161 | }; |
@@ -189,6 +163,7 @@ enum { | |||
189 | static match_table_t nfs_xprt_protocol_tokens = { | 163 | static match_table_t nfs_xprt_protocol_tokens = { |
190 | { Opt_xprt_udp, "udp" }, | 164 | { Opt_xprt_udp, "udp" }, |
191 | { Opt_xprt_tcp, "tcp" }, | 165 | { Opt_xprt_tcp, "tcp" }, |
166 | { Opt_xprt_rdma, "rdma" }, | ||
192 | 167 | ||
193 | { Opt_xprt_err, NULL } | 168 | { Opt_xprt_err, NULL } |
194 | }; | 169 | }; |
@@ -449,7 +424,7 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, | |||
449 | const char *nostr; | 424 | const char *nostr; |
450 | } nfs_info[] = { | 425 | } nfs_info[] = { |
451 | { NFS_MOUNT_SOFT, ",soft", ",hard" }, | 426 | { NFS_MOUNT_SOFT, ",soft", ",hard" }, |
452 | { NFS_MOUNT_INTR, ",intr", "" }, | 427 | { NFS_MOUNT_INTR, ",intr", ",nointr" }, |
453 | { NFS_MOUNT_NOCTO, ",nocto", "" }, | 428 | { NFS_MOUNT_NOCTO, ",nocto", "" }, |
454 | { NFS_MOUNT_NOAC, ",noac", "" }, | 429 | { NFS_MOUNT_NOAC, ",noac", "" }, |
455 | { NFS_MOUNT_NONLM, ",nolock", "" }, | 430 | { NFS_MOUNT_NONLM, ",nolock", "" }, |
@@ -460,8 +435,6 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, | |||
460 | }; | 435 | }; |
461 | const struct proc_nfs_info *nfs_infop; | 436 | const struct proc_nfs_info *nfs_infop; |
462 | struct nfs_client *clp = nfss->nfs_client; | 437 | struct nfs_client *clp = nfss->nfs_client; |
463 | char buf[12]; | ||
464 | const char *proto; | ||
465 | 438 | ||
466 | seq_printf(m, ",vers=%d", clp->rpc_ops->version); | 439 | seq_printf(m, ",vers=%d", clp->rpc_ops->version); |
467 | seq_printf(m, ",rsize=%d", nfss->rsize); | 440 | seq_printf(m, ",rsize=%d", nfss->rsize); |
@@ -480,18 +453,8 @@ static void nfs_show_mount_options(struct seq_file *m, struct nfs_server *nfss, | |||
480 | else | 453 | else |
481 | seq_puts(m, nfs_infop->nostr); | 454 | seq_puts(m, nfs_infop->nostr); |
482 | } | 455 | } |
483 | switch (nfss->client->cl_xprt->prot) { | 456 | seq_printf(m, ",proto=%s", |
484 | case IPPROTO_TCP: | 457 | rpc_peeraddr2str(nfss->client, RPC_DISPLAY_PROTO)); |
485 | proto = "tcp"; | ||
486 | break; | ||
487 | case IPPROTO_UDP: | ||
488 | proto = "udp"; | ||
489 | break; | ||
490 | default: | ||
491 | snprintf(buf, sizeof(buf), "%u", nfss->client->cl_xprt->prot); | ||
492 | proto = buf; | ||
493 | } | ||
494 | seq_printf(m, ",proto=%s", proto); | ||
495 | seq_printf(m, ",timeo=%lu", 10U * clp->retrans_timeo / HZ); | 458 | seq_printf(m, ",timeo=%lu", 10U * clp->retrans_timeo / HZ); |
496 | seq_printf(m, ",retrans=%u", clp->retrans_count); | 459 | seq_printf(m, ",retrans=%u", clp->retrans_count); |
497 | seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor)); | 460 | seq_printf(m, ",sec=%s", nfs_pseudoflavour_to_name(nfss->client->cl_auth->au_flavor)); |
@@ -506,8 +469,8 @@ static int nfs_show_options(struct seq_file *m, struct vfsmount *mnt) | |||
506 | 469 | ||
507 | nfs_show_mount_options(m, nfss, 0); | 470 | nfs_show_mount_options(m, nfss, 0); |
508 | 471 | ||
509 | seq_puts(m, ",addr="); | 472 | seq_printf(m, ",addr="NIPQUAD_FMT, |
510 | seq_escape(m, nfss->nfs_client->cl_hostname, " \t\n\\"); | 473 | NIPQUAD(nfss->nfs_client->cl_addr.sin_addr)); |
511 | 474 | ||
512 | return 0; | 475 | return 0; |
513 | } | 476 | } |
@@ -698,13 +661,19 @@ static int nfs_parse_mount_options(char *raw, | |||
698 | break; | 661 | break; |
699 | case Opt_udp: | 662 | case Opt_udp: |
700 | mnt->flags &= ~NFS_MOUNT_TCP; | 663 | mnt->flags &= ~NFS_MOUNT_TCP; |
701 | mnt->nfs_server.protocol = IPPROTO_UDP; | 664 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; |
702 | mnt->timeo = 7; | 665 | mnt->timeo = 7; |
703 | mnt->retrans = 5; | 666 | mnt->retrans = 5; |
704 | break; | 667 | break; |
705 | case Opt_tcp: | 668 | case Opt_tcp: |
706 | mnt->flags |= NFS_MOUNT_TCP; | 669 | mnt->flags |= NFS_MOUNT_TCP; |
707 | mnt->nfs_server.protocol = IPPROTO_TCP; | 670 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
671 | mnt->timeo = 600; | ||
672 | mnt->retrans = 2; | ||
673 | break; | ||
674 | case Opt_rdma: | ||
675 | mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */ | ||
676 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; | ||
708 | mnt->timeo = 600; | 677 | mnt->timeo = 600; |
709 | mnt->retrans = 2; | 678 | mnt->retrans = 2; |
710 | break; | 679 | break; |
@@ -913,13 +882,20 @@ static int nfs_parse_mount_options(char *raw, | |||
913 | switch (token) { | 882 | switch (token) { |
914 | case Opt_xprt_udp: | 883 | case Opt_xprt_udp: |
915 | mnt->flags &= ~NFS_MOUNT_TCP; | 884 | mnt->flags &= ~NFS_MOUNT_TCP; |
916 | mnt->nfs_server.protocol = IPPROTO_UDP; | 885 | mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; |
917 | mnt->timeo = 7; | 886 | mnt->timeo = 7; |
918 | mnt->retrans = 5; | 887 | mnt->retrans = 5; |
919 | break; | 888 | break; |
920 | case Opt_xprt_tcp: | 889 | case Opt_xprt_tcp: |
921 | mnt->flags |= NFS_MOUNT_TCP; | 890 | mnt->flags |= NFS_MOUNT_TCP; |
922 | mnt->nfs_server.protocol = IPPROTO_TCP; | 891 | mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; |
892 | mnt->timeo = 600; | ||
893 | mnt->retrans = 2; | ||
894 | break; | ||
895 | case Opt_xprt_rdma: | ||
896 | /* vector side protocols to TCP */ | ||
897 | mnt->flags |= NFS_MOUNT_TCP; | ||
898 | mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; | ||
923 | mnt->timeo = 600; | 899 | mnt->timeo = 600; |
924 | mnt->retrans = 2; | 900 | mnt->retrans = 2; |
925 | break; | 901 | break; |
@@ -937,11 +913,12 @@ static int nfs_parse_mount_options(char *raw, | |||
937 | 913 | ||
938 | switch (token) { | 914 | switch (token) { |
939 | case Opt_xprt_udp: | 915 | case Opt_xprt_udp: |
940 | mnt->mount_server.protocol = IPPROTO_UDP; | 916 | mnt->mount_server.protocol = XPRT_TRANSPORT_UDP; |
941 | break; | 917 | break; |
942 | case Opt_xprt_tcp: | 918 | case Opt_xprt_tcp: |
943 | mnt->mount_server.protocol = IPPROTO_TCP; | 919 | mnt->mount_server.protocol = XPRT_TRANSPORT_TCP; |
944 | break; | 920 | break; |
921 | case Opt_xprt_rdma: /* not used for side protocols */ | ||
945 | default: | 922 | default: |
946 | goto out_unrec_xprt; | 923 | goto out_unrec_xprt; |
947 | } | 924 | } |
@@ -961,7 +938,7 @@ static int nfs_parse_mount_options(char *raw, | |||
961 | goto out_nomem; | 938 | goto out_nomem; |
962 | mnt->client_address = string; | 939 | mnt->client_address = string; |
963 | break; | 940 | break; |
964 | case Opt_mounthost: | 941 | case Opt_mountaddr: |
965 | string = match_strdup(args); | 942 | string = match_strdup(args); |
966 | if (string == NULL) | 943 | if (string == NULL) |
967 | goto out_nomem; | 944 | goto out_nomem; |
@@ -1027,16 +1004,10 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args, | |||
1027 | sin = args->mount_server.address; | 1004 | sin = args->mount_server.address; |
1028 | else | 1005 | else |
1029 | sin = args->nfs_server.address; | 1006 | sin = args->nfs_server.address; |
1030 | if (args->mount_server.port == 0) { | 1007 | /* |
1031 | status = rpcb_getport_sync(&sin, | 1008 | * autobind will be used if mount_server.port == 0 |
1032 | args->mount_server.program, | 1009 | */ |
1033 | args->mount_server.version, | 1010 | sin.sin_port = htons(args->mount_server.port); |
1034 | args->mount_server.protocol); | ||
1035 | if (status < 0) | ||
1036 | goto out_err; | ||
1037 | sin.sin_port = htons(status); | ||
1038 | } else | ||
1039 | sin.sin_port = htons(args->mount_server.port); | ||
1040 | 1011 | ||
1041 | /* | 1012 | /* |
1042 | * Now ask the mount server to map our export path | 1013 | * Now ask the mount server to map our export path |
@@ -1049,14 +1020,11 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args, | |||
1049 | args->mount_server.version, | 1020 | args->mount_server.version, |
1050 | args->mount_server.protocol, | 1021 | args->mount_server.protocol, |
1051 | root_fh); | 1022 | root_fh); |
1052 | if (status < 0) | 1023 | if (status == 0) |
1053 | goto out_err; | 1024 | return 0; |
1054 | |||
1055 | return status; | ||
1056 | 1025 | ||
1057 | out_err: | 1026 | dfprintk(MOUNT, "NFS: unable to mount server " NIPQUAD_FMT |
1058 | dfprintk(MOUNT, "NFS: unable to contact server on host " | 1027 | ", error %d\n", NIPQUAD(sin.sin_addr.s_addr), status); |
1059 | NIPQUAD_FMT "\n", NIPQUAD(sin.sin_addr.s_addr)); | ||
1060 | return status; | 1028 | return status; |
1061 | } | 1029 | } |
1062 | 1030 | ||
@@ -1079,15 +1047,31 @@ out_err: | |||
1079 | * XXX: as far as I can tell, changing the NFS program number is not | 1047 | * XXX: as far as I can tell, changing the NFS program number is not |
1080 | * supported in the NFS client. | 1048 | * supported in the NFS client. |
1081 | */ | 1049 | */ |
1082 | static int nfs_validate_mount_data(struct nfs_mount_data **options, | 1050 | static int nfs_validate_mount_data(void *options, |
1051 | struct nfs_parsed_mount_data *args, | ||
1083 | struct nfs_fh *mntfh, | 1052 | struct nfs_fh *mntfh, |
1084 | const char *dev_name) | 1053 | const char *dev_name) |
1085 | { | 1054 | { |
1086 | struct nfs_mount_data *data = *options; | 1055 | struct nfs_mount_data *data = (struct nfs_mount_data *)options; |
1087 | 1056 | ||
1088 | if (data == NULL) | 1057 | if (data == NULL) |
1089 | goto out_no_data; | 1058 | goto out_no_data; |
1090 | 1059 | ||
1060 | memset(args, 0, sizeof(*args)); | ||
1061 | args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP); | ||
1062 | args->rsize = NFS_MAX_FILE_IO_SIZE; | ||
1063 | args->wsize = NFS_MAX_FILE_IO_SIZE; | ||
1064 | args->timeo = 600; | ||
1065 | args->retrans = 2; | ||
1066 | args->acregmin = 3; | ||
1067 | args->acregmax = 60; | ||
1068 | args->acdirmin = 30; | ||
1069 | args->acdirmax = 60; | ||
1070 | args->mount_server.protocol = XPRT_TRANSPORT_UDP; | ||
1071 | args->mount_server.program = NFS_MNT_PROGRAM; | ||
1072 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; | ||
1073 | args->nfs_server.program = NFS_PROGRAM; | ||
1074 | |||
1091 | switch (data->version) { | 1075 | switch (data->version) { |
1092 | case 1: | 1076 | case 1: |
1093 | data->namlen = 0; | 1077 | data->namlen = 0; |
@@ -1116,92 +1100,73 @@ static int nfs_validate_mount_data(struct nfs_mount_data **options, | |||
1116 | if (mntfh->size < sizeof(mntfh->data)) | 1100 | if (mntfh->size < sizeof(mntfh->data)) |
1117 | memset(mntfh->data + mntfh->size, 0, | 1101 | memset(mntfh->data + mntfh->size, 0, |
1118 | sizeof(mntfh->data) - mntfh->size); | 1102 | sizeof(mntfh->data) - mntfh->size); |
1103 | |||
1104 | if (!nfs_verify_server_address((struct sockaddr *) &data->addr)) | ||
1105 | goto out_no_address; | ||
1106 | |||
1107 | /* | ||
1108 | * Translate to nfs_parsed_mount_data, which nfs_fill_super | ||
1109 | * can deal with. | ||
1110 | */ | ||
1111 | args->flags = data->flags; | ||
1112 | args->rsize = data->rsize; | ||
1113 | args->wsize = data->wsize; | ||
1114 | args->flags = data->flags; | ||
1115 | args->timeo = data->timeo; | ||
1116 | args->retrans = data->retrans; | ||
1117 | args->acregmin = data->acregmin; | ||
1118 | args->acregmax = data->acregmax; | ||
1119 | args->acdirmin = data->acdirmin; | ||
1120 | args->acdirmax = data->acdirmax; | ||
1121 | args->nfs_server.address = data->addr; | ||
1122 | if (!(data->flags & NFS_MOUNT_TCP)) | ||
1123 | args->nfs_server.protocol = XPRT_TRANSPORT_UDP; | ||
1124 | /* N.B. caller will free nfs_server.hostname in all cases */ | ||
1125 | args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL); | ||
1126 | args->namlen = data->namlen; | ||
1127 | args->bsize = data->bsize; | ||
1128 | args->auth_flavors[0] = data->pseudoflavor; | ||
1119 | break; | 1129 | break; |
1120 | default: { | 1130 | default: { |
1121 | unsigned int len; | 1131 | unsigned int len; |
1122 | char *c; | 1132 | char *c; |
1123 | int status; | 1133 | int status; |
1124 | struct nfs_parsed_mount_data args = { | ||
1125 | .flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP), | ||
1126 | .rsize = NFS_MAX_FILE_IO_SIZE, | ||
1127 | .wsize = NFS_MAX_FILE_IO_SIZE, | ||
1128 | .timeo = 600, | ||
1129 | .retrans = 2, | ||
1130 | .acregmin = 3, | ||
1131 | .acregmax = 60, | ||
1132 | .acdirmin = 30, | ||
1133 | .acdirmax = 60, | ||
1134 | .mount_server.protocol = IPPROTO_UDP, | ||
1135 | .mount_server.program = NFS_MNT_PROGRAM, | ||
1136 | .nfs_server.protocol = IPPROTO_TCP, | ||
1137 | .nfs_server.program = NFS_PROGRAM, | ||
1138 | }; | ||
1139 | |||
1140 | if (nfs_parse_mount_options((char *) *options, &args) == 0) | ||
1141 | return -EINVAL; | ||
1142 | 1134 | ||
1143 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 1135 | if (nfs_parse_mount_options((char *)options, args) == 0) |
1144 | if (data == NULL) | 1136 | return -EINVAL; |
1145 | return -ENOMEM; | ||
1146 | 1137 | ||
1147 | /* | 1138 | if (!nfs_verify_server_address((struct sockaddr *) |
1148 | * NB: after this point, caller will free "data" | 1139 | &args->nfs_server.address)) |
1149 | * if we return an error | 1140 | goto out_no_address; |
1150 | */ | ||
1151 | *options = data; | ||
1152 | 1141 | ||
1153 | c = strchr(dev_name, ':'); | 1142 | c = strchr(dev_name, ':'); |
1154 | if (c == NULL) | 1143 | if (c == NULL) |
1155 | return -EINVAL; | 1144 | return -EINVAL; |
1156 | len = c - dev_name; | 1145 | len = c - dev_name; |
1157 | if (len > sizeof(data->hostname)) | 1146 | /* N.B. caller will free nfs_server.hostname in all cases */ |
1158 | return -ENAMETOOLONG; | 1147 | args->nfs_server.hostname = kstrndup(dev_name, len, GFP_KERNEL); |
1159 | strncpy(data->hostname, dev_name, len); | ||
1160 | args.nfs_server.hostname = data->hostname; | ||
1161 | 1148 | ||
1162 | c++; | 1149 | c++; |
1163 | if (strlen(c) > NFS_MAXPATHLEN) | 1150 | if (strlen(c) > NFS_MAXPATHLEN) |
1164 | return -ENAMETOOLONG; | 1151 | return -ENAMETOOLONG; |
1165 | args.nfs_server.export_path = c; | 1152 | args->nfs_server.export_path = c; |
1166 | 1153 | ||
1167 | status = nfs_try_mount(&args, mntfh); | 1154 | status = nfs_try_mount(args, mntfh); |
1168 | if (status) | 1155 | if (status) |
1169 | return status; | 1156 | return status; |
1170 | 1157 | ||
1171 | /* | ||
1172 | * Translate to nfs_mount_data, which nfs_fill_super | ||
1173 | * can deal with. | ||
1174 | */ | ||
1175 | data->version = 6; | ||
1176 | data->flags = args.flags; | ||
1177 | data->rsize = args.rsize; | ||
1178 | data->wsize = args.wsize; | ||
1179 | data->timeo = args.timeo; | ||
1180 | data->retrans = args.retrans; | ||
1181 | data->acregmin = args.acregmin; | ||
1182 | data->acregmax = args.acregmax; | ||
1183 | data->acdirmin = args.acdirmin; | ||
1184 | data->acdirmax = args.acdirmax; | ||
1185 | data->addr = args.nfs_server.address; | ||
1186 | data->namlen = args.namlen; | ||
1187 | data->bsize = args.bsize; | ||
1188 | data->pseudoflavor = args.auth_flavors[0]; | ||
1189 | |||
1190 | break; | 1158 | break; |
1191 | } | 1159 | } |
1192 | } | 1160 | } |
1193 | 1161 | ||
1194 | if (!(data->flags & NFS_MOUNT_SECFLAVOUR)) | 1162 | if (!(args->flags & NFS_MOUNT_SECFLAVOUR)) |
1195 | data->pseudoflavor = RPC_AUTH_UNIX; | 1163 | args->auth_flavors[0] = RPC_AUTH_UNIX; |
1196 | 1164 | ||
1197 | #ifndef CONFIG_NFS_V3 | 1165 | #ifndef CONFIG_NFS_V3 |
1198 | if (data->flags & NFS_MOUNT_VER3) | 1166 | if (args->flags & NFS_MOUNT_VER3) |
1199 | goto out_v3_not_compiled; | 1167 | goto out_v3_not_compiled; |
1200 | #endif /* !CONFIG_NFS_V3 */ | 1168 | #endif /* !CONFIG_NFS_V3 */ |
1201 | 1169 | ||
1202 | if (!nfs_verify_server_address((struct sockaddr *) &data->addr)) | ||
1203 | goto out_no_address; | ||
1204 | |||
1205 | return 0; | 1170 | return 0; |
1206 | 1171 | ||
1207 | out_no_data: | 1172 | out_no_data: |
@@ -1258,7 +1223,8 @@ static inline void nfs_initialise_sb(struct super_block *sb) | |||
1258 | /* | 1223 | /* |
1259 | * Finish setting up an NFS2/3 superblock | 1224 | * Finish setting up an NFS2/3 superblock |
1260 | */ | 1225 | */ |
1261 | static void nfs_fill_super(struct super_block *sb, struct nfs_mount_data *data) | 1226 | static void nfs_fill_super(struct super_block *sb, |
1227 | struct nfs_parsed_mount_data *data) | ||
1262 | { | 1228 | { |
1263 | struct nfs_server *server = NFS_SB(sb); | 1229 | struct nfs_server *server = NFS_SB(sb); |
1264 | 1230 | ||
@@ -1379,7 +1345,7 @@ static int nfs_get_sb(struct file_system_type *fs_type, | |||
1379 | struct nfs_server *server = NULL; | 1345 | struct nfs_server *server = NULL; |
1380 | struct super_block *s; | 1346 | struct super_block *s; |
1381 | struct nfs_fh mntfh; | 1347 | struct nfs_fh mntfh; |
1382 | struct nfs_mount_data *data = raw_data; | 1348 | struct nfs_parsed_mount_data data; |
1383 | struct dentry *mntroot; | 1349 | struct dentry *mntroot; |
1384 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; | 1350 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; |
1385 | struct nfs_sb_mountdata sb_mntdata = { | 1351 | struct nfs_sb_mountdata sb_mntdata = { |
@@ -1388,12 +1354,12 @@ static int nfs_get_sb(struct file_system_type *fs_type, | |||
1388 | int error; | 1354 | int error; |
1389 | 1355 | ||
1390 | /* Validate the mount data */ | 1356 | /* Validate the mount data */ |
1391 | error = nfs_validate_mount_data(&data, &mntfh, dev_name); | 1357 | error = nfs_validate_mount_data(raw_data, &data, &mntfh, dev_name); |
1392 | if (error < 0) | 1358 | if (error < 0) |
1393 | goto out; | 1359 | goto out; |
1394 | 1360 | ||
1395 | /* Get a volume representation */ | 1361 | /* Get a volume representation */ |
1396 | server = nfs_create_server(data, &mntfh); | 1362 | server = nfs_create_server(&data, &mntfh); |
1397 | if (IS_ERR(server)) { | 1363 | if (IS_ERR(server)) { |
1398 | error = PTR_ERR(server); | 1364 | error = PTR_ERR(server); |
1399 | goto out; | 1365 | goto out; |
@@ -1417,7 +1383,7 @@ static int nfs_get_sb(struct file_system_type *fs_type, | |||
1417 | 1383 | ||
1418 | if (!s->s_root) { | 1384 | if (!s->s_root) { |
1419 | /* initial superblock/root creation */ | 1385 | /* initial superblock/root creation */ |
1420 | nfs_fill_super(s, data); | 1386 | nfs_fill_super(s, &data); |
1421 | } | 1387 | } |
1422 | 1388 | ||
1423 | mntroot = nfs_get_root(s, &mntfh); | 1389 | mntroot = nfs_get_root(s, &mntfh); |
@@ -1432,8 +1398,7 @@ static int nfs_get_sb(struct file_system_type *fs_type, | |||
1432 | error = 0; | 1398 | error = 0; |
1433 | 1399 | ||
1434 | out: | 1400 | out: |
1435 | if (data != raw_data) | 1401 | kfree(data.nfs_server.hostname); |
1436 | kfree(data); | ||
1437 | return error; | 1402 | return error; |
1438 | 1403 | ||
1439 | out_err_nosb: | 1404 | out_err_nosb: |
@@ -1559,38 +1524,49 @@ static void nfs4_fill_super(struct super_block *sb) | |||
1559 | /* | 1524 | /* |
1560 | * Validate NFSv4 mount options | 1525 | * Validate NFSv4 mount options |
1561 | */ | 1526 | */ |
1562 | static int nfs4_validate_mount_data(struct nfs4_mount_data **options, | 1527 | static int nfs4_validate_mount_data(void *options, |
1563 | const char *dev_name, | 1528 | struct nfs_parsed_mount_data *args, |
1564 | struct sockaddr_in *addr, | 1529 | const char *dev_name) |
1565 | rpc_authflavor_t *authflavour, | ||
1566 | char **hostname, | ||
1567 | char **mntpath, | ||
1568 | char **ip_addr) | ||
1569 | { | 1530 | { |
1570 | struct nfs4_mount_data *data = *options; | 1531 | struct nfs4_mount_data *data = (struct nfs4_mount_data *)options; |
1571 | char *c; | 1532 | char *c; |
1572 | 1533 | ||
1573 | if (data == NULL) | 1534 | if (data == NULL) |
1574 | goto out_no_data; | 1535 | goto out_no_data; |
1575 | 1536 | ||
1537 | memset(args, 0, sizeof(*args)); | ||
1538 | args->rsize = NFS_MAX_FILE_IO_SIZE; | ||
1539 | args->wsize = NFS_MAX_FILE_IO_SIZE; | ||
1540 | args->timeo = 600; | ||
1541 | args->retrans = 2; | ||
1542 | args->acregmin = 3; | ||
1543 | args->acregmax = 60; | ||
1544 | args->acdirmin = 30; | ||
1545 | args->acdirmax = 60; | ||
1546 | args->nfs_server.protocol = XPRT_TRANSPORT_TCP; | ||
1547 | |||
1576 | switch (data->version) { | 1548 | switch (data->version) { |
1577 | case 1: | 1549 | case 1: |
1578 | if (data->host_addrlen != sizeof(*addr)) | 1550 | if (data->host_addrlen != sizeof(args->nfs_server.address)) |
1579 | goto out_no_address; | 1551 | goto out_no_address; |
1580 | if (copy_from_user(addr, data->host_addr, sizeof(*addr))) | 1552 | if (copy_from_user(&args->nfs_server.address, |
1553 | data->host_addr, | ||
1554 | sizeof(args->nfs_server.address))) | ||
1581 | return -EFAULT; | 1555 | return -EFAULT; |
1582 | if (addr->sin_port == 0) | 1556 | if (args->nfs_server.address.sin_port == 0) |
1583 | addr->sin_port = htons(NFS_PORT); | 1557 | args->nfs_server.address.sin_port = htons(NFS_PORT); |
1584 | if (!nfs_verify_server_address((struct sockaddr *) addr)) | 1558 | if (!nfs_verify_server_address((struct sockaddr *) |
1559 | &args->nfs_server.address)) | ||
1585 | goto out_no_address; | 1560 | goto out_no_address; |
1586 | 1561 | ||
1587 | switch (data->auth_flavourlen) { | 1562 | switch (data->auth_flavourlen) { |
1588 | case 0: | 1563 | case 0: |
1589 | *authflavour = RPC_AUTH_UNIX; | 1564 | args->auth_flavors[0] = RPC_AUTH_UNIX; |
1590 | break; | 1565 | break; |
1591 | case 1: | 1566 | case 1: |
1592 | if (copy_from_user(authflavour, data->auth_flavours, | 1567 | if (copy_from_user(&args->auth_flavors[0], |
1593 | sizeof(*authflavour))) | 1568 | data->auth_flavours, |
1569 | sizeof(args->auth_flavors[0]))) | ||
1594 | return -EFAULT; | 1570 | return -EFAULT; |
1595 | break; | 1571 | break; |
1596 | default: | 1572 | default: |
@@ -1600,75 +1576,57 @@ static int nfs4_validate_mount_data(struct nfs4_mount_data **options, | |||
1600 | c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); | 1576 | c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN); |
1601 | if (IS_ERR(c)) | 1577 | if (IS_ERR(c)) |
1602 | return PTR_ERR(c); | 1578 | return PTR_ERR(c); |
1603 | *hostname = c; | 1579 | args->nfs_server.hostname = c; |
1604 | 1580 | ||
1605 | c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN); | 1581 | c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN); |
1606 | if (IS_ERR(c)) | 1582 | if (IS_ERR(c)) |
1607 | return PTR_ERR(c); | 1583 | return PTR_ERR(c); |
1608 | *mntpath = c; | 1584 | args->nfs_server.export_path = c; |
1609 | dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", *mntpath); | 1585 | dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c); |
1610 | 1586 | ||
1611 | c = strndup_user(data->client_addr.data, 16); | 1587 | c = strndup_user(data->client_addr.data, 16); |
1612 | if (IS_ERR(c)) | 1588 | if (IS_ERR(c)) |
1613 | return PTR_ERR(c); | 1589 | return PTR_ERR(c); |
1614 | *ip_addr = c; | 1590 | args->client_address = c; |
1591 | |||
1592 | /* | ||
1593 | * Translate to nfs_parsed_mount_data, which nfs4_fill_super | ||
1594 | * can deal with. | ||
1595 | */ | ||
1596 | |||
1597 | args->flags = data->flags & NFS4_MOUNT_FLAGMASK; | ||
1598 | args->rsize = data->rsize; | ||
1599 | args->wsize = data->wsize; | ||
1600 | args->timeo = data->timeo; | ||
1601 | args->retrans = data->retrans; | ||
1602 | args->acregmin = data->acregmin; | ||
1603 | args->acregmax = data->acregmax; | ||
1604 | args->acdirmin = data->acdirmin; | ||
1605 | args->acdirmax = data->acdirmax; | ||
1606 | args->nfs_server.protocol = data->proto; | ||
1615 | 1607 | ||
1616 | break; | 1608 | break; |
1617 | default: { | 1609 | default: { |
1618 | unsigned int len; | 1610 | unsigned int len; |
1619 | struct nfs_parsed_mount_data args = { | 1611 | |
1620 | .rsize = NFS_MAX_FILE_IO_SIZE, | 1612 | if (nfs_parse_mount_options((char *)options, args) == 0) |
1621 | .wsize = NFS_MAX_FILE_IO_SIZE, | ||
1622 | .timeo = 600, | ||
1623 | .retrans = 2, | ||
1624 | .acregmin = 3, | ||
1625 | .acregmax = 60, | ||
1626 | .acdirmin = 30, | ||
1627 | .acdirmax = 60, | ||
1628 | .nfs_server.protocol = IPPROTO_TCP, | ||
1629 | }; | ||
1630 | |||
1631 | if (nfs_parse_mount_options((char *) *options, &args) == 0) | ||
1632 | return -EINVAL; | 1613 | return -EINVAL; |
1633 | 1614 | ||
1634 | if (!nfs_verify_server_address((struct sockaddr *) | 1615 | if (!nfs_verify_server_address((struct sockaddr *) |
1635 | &args.nfs_server.address)) | 1616 | &args->nfs_server.address)) |
1636 | return -EINVAL; | 1617 | return -EINVAL; |
1637 | *addr = args.nfs_server.address; | ||
1638 | 1618 | ||
1639 | switch (args.auth_flavor_len) { | 1619 | switch (args->auth_flavor_len) { |
1640 | case 0: | 1620 | case 0: |
1641 | *authflavour = RPC_AUTH_UNIX; | 1621 | args->auth_flavors[0] = RPC_AUTH_UNIX; |
1642 | break; | 1622 | break; |
1643 | case 1: | 1623 | case 1: |
1644 | *authflavour = (rpc_authflavor_t) args.auth_flavors[0]; | ||
1645 | break; | 1624 | break; |
1646 | default: | 1625 | default: |
1647 | goto out_inval_auth; | 1626 | goto out_inval_auth; |
1648 | } | 1627 | } |
1649 | 1628 | ||
1650 | /* | 1629 | /* |
1651 | * Translate to nfs4_mount_data, which nfs4_fill_super | ||
1652 | * can deal with. | ||
1653 | */ | ||
1654 | data = kzalloc(sizeof(*data), GFP_KERNEL); | ||
1655 | if (data == NULL) | ||
1656 | return -ENOMEM; | ||
1657 | *options = data; | ||
1658 | |||
1659 | data->version = 1; | ||
1660 | data->flags = args.flags & NFS4_MOUNT_FLAGMASK; | ||
1661 | data->rsize = args.rsize; | ||
1662 | data->wsize = args.wsize; | ||
1663 | data->timeo = args.timeo; | ||
1664 | data->retrans = args.retrans; | ||
1665 | data->acregmin = args.acregmin; | ||
1666 | data->acregmax = args.acregmax; | ||
1667 | data->acdirmin = args.acdirmin; | ||
1668 | data->acdirmax = args.acdirmax; | ||
1669 | data->proto = args.nfs_server.protocol; | ||
1670 | |||
1671 | /* | ||
1672 | * Split "dev_name" into "hostname:mntpath". | 1630 | * Split "dev_name" into "hostname:mntpath". |
1673 | */ | 1631 | */ |
1674 | c = strchr(dev_name, ':'); | 1632 | c = strchr(dev_name, ':'); |
@@ -1678,27 +1636,25 @@ static int nfs4_validate_mount_data(struct nfs4_mount_data **options, | |||
1678 | len = c - dev_name; | 1636 | len = c - dev_name; |
1679 | if (len > NFS4_MAXNAMLEN) | 1637 | if (len > NFS4_MAXNAMLEN) |
1680 | return -ENAMETOOLONG; | 1638 | return -ENAMETOOLONG; |
1681 | *hostname = kzalloc(len, GFP_KERNEL); | 1639 | args->nfs_server.hostname = kzalloc(len, GFP_KERNEL); |
1682 | if (*hostname == NULL) | 1640 | if (args->nfs_server.hostname == NULL) |
1683 | return -ENOMEM; | 1641 | return -ENOMEM; |
1684 | strncpy(*hostname, dev_name, len - 1); | 1642 | strncpy(args->nfs_server.hostname, dev_name, len - 1); |
1685 | 1643 | ||
1686 | c++; /* step over the ':' */ | 1644 | c++; /* step over the ':' */ |
1687 | len = strlen(c); | 1645 | len = strlen(c); |
1688 | if (len > NFS4_MAXPATHLEN) | 1646 | if (len > NFS4_MAXPATHLEN) |
1689 | return -ENAMETOOLONG; | 1647 | return -ENAMETOOLONG; |
1690 | *mntpath = kzalloc(len + 1, GFP_KERNEL); | 1648 | args->nfs_server.export_path = kzalloc(len + 1, GFP_KERNEL); |
1691 | if (*mntpath == NULL) | 1649 | if (args->nfs_server.export_path == NULL) |
1692 | return -ENOMEM; | 1650 | return -ENOMEM; |
1693 | strncpy(*mntpath, c, len); | 1651 | strncpy(args->nfs_server.export_path, c, len); |
1694 | 1652 | ||
1695 | dprintk("MNTPATH: %s\n", *mntpath); | 1653 | dprintk("MNTPATH: %s\n", args->nfs_server.export_path); |
1696 | 1654 | ||
1697 | if (args.client_address == NULL) | 1655 | if (args->client_address == NULL) |
1698 | goto out_no_client_address; | 1656 | goto out_no_client_address; |
1699 | 1657 | ||
1700 | *ip_addr = args.client_address; | ||
1701 | |||
1702 | break; | 1658 | break; |
1703 | } | 1659 | } |
1704 | } | 1660 | } |
@@ -1729,14 +1685,11 @@ out_no_client_address: | |||
1729 | static int nfs4_get_sb(struct file_system_type *fs_type, | 1685 | static int nfs4_get_sb(struct file_system_type *fs_type, |
1730 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | 1686 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) |
1731 | { | 1687 | { |
1732 | struct nfs4_mount_data *data = raw_data; | 1688 | struct nfs_parsed_mount_data data; |
1733 | struct super_block *s; | 1689 | struct super_block *s; |
1734 | struct nfs_server *server; | 1690 | struct nfs_server *server; |
1735 | struct sockaddr_in addr; | ||
1736 | rpc_authflavor_t authflavour; | ||
1737 | struct nfs_fh mntfh; | 1691 | struct nfs_fh mntfh; |
1738 | struct dentry *mntroot; | 1692 | struct dentry *mntroot; |
1739 | char *mntpath = NULL, *hostname = NULL, *ip_addr = NULL; | ||
1740 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; | 1693 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; |
1741 | struct nfs_sb_mountdata sb_mntdata = { | 1694 | struct nfs_sb_mountdata sb_mntdata = { |
1742 | .mntflags = flags, | 1695 | .mntflags = flags, |
@@ -1744,14 +1697,12 @@ static int nfs4_get_sb(struct file_system_type *fs_type, | |||
1744 | int error; | 1697 | int error; |
1745 | 1698 | ||
1746 | /* Validate the mount data */ | 1699 | /* Validate the mount data */ |
1747 | error = nfs4_validate_mount_data(&data, dev_name, &addr, &authflavour, | 1700 | error = nfs4_validate_mount_data(raw_data, &data, dev_name); |
1748 | &hostname, &mntpath, &ip_addr); | ||
1749 | if (error < 0) | 1701 | if (error < 0) |
1750 | goto out; | 1702 | goto out; |
1751 | 1703 | ||
1752 | /* Get a volume representation */ | 1704 | /* Get a volume representation */ |
1753 | server = nfs4_create_server(data, hostname, &addr, mntpath, ip_addr, | 1705 | server = nfs4_create_server(&data, &mntfh); |
1754 | authflavour, &mntfh); | ||
1755 | if (IS_ERR(server)) { | 1706 | if (IS_ERR(server)) { |
1756 | error = PTR_ERR(server); | 1707 | error = PTR_ERR(server); |
1757 | goto out; | 1708 | goto out; |
@@ -1790,9 +1741,9 @@ static int nfs4_get_sb(struct file_system_type *fs_type, | |||
1790 | error = 0; | 1741 | error = 0; |
1791 | 1742 | ||
1792 | out: | 1743 | out: |
1793 | kfree(ip_addr); | 1744 | kfree(data.client_address); |
1794 | kfree(mntpath); | 1745 | kfree(data.nfs_server.export_path); |
1795 | kfree(hostname); | 1746 | kfree(data.nfs_server.hostname); |
1796 | return error; | 1747 | return error; |
1797 | 1748 | ||
1798 | out_free: | 1749 | out_free: |
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 045ab805c17f..1aed850d18f2 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c | |||
@@ -66,7 +66,6 @@ static void nfs_async_unlink_init(struct rpc_task *task, void *calldata) | |||
66 | .rpc_cred = data->cred, | 66 | .rpc_cred = data->cred, |
67 | }; | 67 | }; |
68 | 68 | ||
69 | nfs_begin_data_update(dir); | ||
70 | NFS_PROTO(dir)->unlink_setup(&msg, dir); | 69 | NFS_PROTO(dir)->unlink_setup(&msg, dir); |
71 | rpc_call_setup(task, &msg, 0); | 70 | rpc_call_setup(task, &msg, 0); |
72 | } | 71 | } |
@@ -84,8 +83,6 @@ static void nfs_async_unlink_done(struct rpc_task *task, void *calldata) | |||
84 | 83 | ||
85 | if (!NFS_PROTO(dir)->unlink_done(task, dir)) | 84 | if (!NFS_PROTO(dir)->unlink_done(task, dir)) |
86 | rpc_restart_call(task); | 85 | rpc_restart_call(task); |
87 | else | ||
88 | nfs_end_data_update(dir); | ||
89 | } | 86 | } |
90 | 87 | ||
91 | /** | 88 | /** |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 0d7a77cc394b..e2bb66c34406 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -110,6 +110,13 @@ void nfs_writedata_release(void *wdata) | |||
110 | nfs_writedata_free(wdata); | 110 | nfs_writedata_free(wdata); |
111 | } | 111 | } |
112 | 112 | ||
113 | static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error) | ||
114 | { | ||
115 | ctx->error = error; | ||
116 | smp_wmb(); | ||
117 | set_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags); | ||
118 | } | ||
119 | |||
113 | static struct nfs_page *nfs_page_find_request_locked(struct page *page) | 120 | static struct nfs_page *nfs_page_find_request_locked(struct page *page) |
114 | { | 121 | { |
115 | struct nfs_page *req = NULL; | 122 | struct nfs_page *req = NULL; |
@@ -243,10 +250,7 @@ static void nfs_end_page_writeback(struct page *page) | |||
243 | 250 | ||
244 | /* | 251 | /* |
245 | * Find an associated nfs write request, and prepare to flush it out | 252 | * Find an associated nfs write request, and prepare to flush it out |
246 | * Returns 1 if there was no write request, or if the request was | 253 | * May return an error if the user signalled nfs_wait_on_request(). |
247 | * already tagged by nfs_set_page_dirty.Returns 0 if the request | ||
248 | * was not tagged. | ||
249 | * May also return an error if the user signalled nfs_wait_on_request(). | ||
250 | */ | 254 | */ |
251 | static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, | 255 | static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, |
252 | struct page *page) | 256 | struct page *page) |
@@ -261,7 +265,7 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, | |||
261 | req = nfs_page_find_request_locked(page); | 265 | req = nfs_page_find_request_locked(page); |
262 | if (req == NULL) { | 266 | if (req == NULL) { |
263 | spin_unlock(&inode->i_lock); | 267 | spin_unlock(&inode->i_lock); |
264 | return 1; | 268 | return 0; |
265 | } | 269 | } |
266 | if (nfs_lock_request_dontget(req)) | 270 | if (nfs_lock_request_dontget(req)) |
267 | break; | 271 | break; |
@@ -282,7 +286,7 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, | |||
282 | spin_unlock(&inode->i_lock); | 286 | spin_unlock(&inode->i_lock); |
283 | nfs_unlock_request(req); | 287 | nfs_unlock_request(req); |
284 | nfs_pageio_complete(pgio); | 288 | nfs_pageio_complete(pgio); |
285 | return 1; | 289 | return 0; |
286 | } | 290 | } |
287 | if (nfs_set_page_writeback(page) != 0) { | 291 | if (nfs_set_page_writeback(page) != 0) { |
288 | spin_unlock(&inode->i_lock); | 292 | spin_unlock(&inode->i_lock); |
@@ -290,70 +294,56 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, | |||
290 | } | 294 | } |
291 | radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index, | 295 | radix_tree_tag_set(&nfsi->nfs_page_tree, req->wb_index, |
292 | NFS_PAGE_TAG_LOCKED); | 296 | NFS_PAGE_TAG_LOCKED); |
293 | ret = test_bit(PG_NEED_FLUSH, &req->wb_flags); | ||
294 | spin_unlock(&inode->i_lock); | 297 | spin_unlock(&inode->i_lock); |
295 | nfs_pageio_add_request(pgio, req); | 298 | nfs_pageio_add_request(pgio, req); |
296 | return ret; | 299 | return 0; |
297 | } | 300 | } |
298 | 301 | ||
299 | /* | 302 | static int nfs_do_writepage(struct page *page, struct writeback_control *wbc, struct nfs_pageio_descriptor *pgio) |
300 | * Write an mmapped page to the server. | ||
301 | */ | ||
302 | static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc) | ||
303 | { | 303 | { |
304 | struct nfs_pageio_descriptor mypgio, *pgio; | ||
305 | struct nfs_open_context *ctx; | ||
306 | struct inode *inode = page->mapping->host; | 304 | struct inode *inode = page->mapping->host; |
307 | unsigned offset; | ||
308 | int err; | ||
309 | 305 | ||
310 | nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE); | 306 | nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE); |
311 | nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1); | 307 | nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1); |
312 | 308 | ||
313 | if (wbc->for_writepages) | ||
314 | pgio = wbc->fs_private; | ||
315 | else { | ||
316 | nfs_pageio_init_write(&mypgio, inode, wb_priority(wbc)); | ||
317 | pgio = &mypgio; | ||
318 | } | ||
319 | |||
320 | nfs_pageio_cond_complete(pgio, page->index); | 309 | nfs_pageio_cond_complete(pgio, page->index); |
310 | return nfs_page_async_flush(pgio, page); | ||
311 | } | ||
321 | 312 | ||
322 | err = nfs_page_async_flush(pgio, page); | 313 | /* |
323 | if (err <= 0) | 314 | * Write an mmapped page to the server. |
324 | goto out; | 315 | */ |
325 | err = 0; | 316 | static int nfs_writepage_locked(struct page *page, struct writeback_control *wbc) |
326 | offset = nfs_page_length(page); | 317 | { |
327 | if (!offset) | 318 | struct nfs_pageio_descriptor pgio; |
328 | goto out; | 319 | int err; |
329 | |||
330 | nfs_pageio_cond_complete(pgio, page->index); | ||
331 | 320 | ||
332 | ctx = nfs_find_open_context(inode, NULL, FMODE_WRITE); | 321 | nfs_pageio_init_write(&pgio, page->mapping->host, wb_priority(wbc)); |
333 | if (ctx == NULL) { | 322 | err = nfs_do_writepage(page, wbc, &pgio); |
334 | err = -EBADF; | 323 | nfs_pageio_complete(&pgio); |
335 | goto out; | 324 | if (err < 0) |
336 | } | 325 | return err; |
337 | err = nfs_writepage_setup(ctx, page, 0, offset); | 326 | if (pgio.pg_error < 0) |
338 | put_nfs_open_context(ctx); | 327 | return pgio.pg_error; |
339 | if (err != 0) | 328 | return 0; |
340 | goto out; | ||
341 | err = nfs_page_async_flush(pgio, page); | ||
342 | if (err > 0) | ||
343 | err = 0; | ||
344 | out: | ||
345 | if (!wbc->for_writepages) | ||
346 | nfs_pageio_complete(pgio); | ||
347 | return err; | ||
348 | } | 329 | } |
349 | 330 | ||
350 | int nfs_writepage(struct page *page, struct writeback_control *wbc) | 331 | int nfs_writepage(struct page *page, struct writeback_control *wbc) |
351 | { | 332 | { |
352 | int err; | 333 | int ret; |
334 | |||
335 | ret = nfs_writepage_locked(page, wbc); | ||
336 | unlock_page(page); | ||
337 | return ret; | ||
338 | } | ||
339 | |||
340 | static int nfs_writepages_callback(struct page *page, struct writeback_control *wbc, void *data) | ||
341 | { | ||
342 | int ret; | ||
353 | 343 | ||
354 | err = nfs_writepage_locked(page, wbc); | 344 | ret = nfs_do_writepage(page, wbc, data); |
355 | unlock_page(page); | 345 | unlock_page(page); |
356 | return err; | 346 | return ret; |
357 | } | 347 | } |
358 | 348 | ||
359 | int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) | 349 | int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) |
@@ -365,12 +355,11 @@ int nfs_writepages(struct address_space *mapping, struct writeback_control *wbc) | |||
365 | nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGES); | 355 | nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGES); |
366 | 356 | ||
367 | nfs_pageio_init_write(&pgio, inode, wb_priority(wbc)); | 357 | nfs_pageio_init_write(&pgio, inode, wb_priority(wbc)); |
368 | wbc->fs_private = &pgio; | 358 | err = write_cache_pages(mapping, wbc, nfs_writepages_callback, &pgio); |
369 | err = generic_writepages(mapping, wbc); | ||
370 | nfs_pageio_complete(&pgio); | 359 | nfs_pageio_complete(&pgio); |
371 | if (err) | 360 | if (err < 0) |
372 | return err; | 361 | return err; |
373 | if (pgio.pg_error) | 362 | if (pgio.pg_error < 0) |
374 | return pgio.pg_error; | 363 | return pgio.pg_error; |
375 | return 0; | 364 | return 0; |
376 | } | 365 | } |
@@ -389,14 +378,11 @@ static int nfs_inode_add_request(struct inode *inode, struct nfs_page *req) | |||
389 | return error; | 378 | return error; |
390 | if (!nfsi->npages) { | 379 | if (!nfsi->npages) { |
391 | igrab(inode); | 380 | igrab(inode); |
392 | nfs_begin_data_update(inode); | ||
393 | if (nfs_have_delegation(inode, FMODE_WRITE)) | 381 | if (nfs_have_delegation(inode, FMODE_WRITE)) |
394 | nfsi->change_attr++; | 382 | nfsi->change_attr++; |
395 | } | 383 | } |
396 | SetPagePrivate(req->wb_page); | 384 | SetPagePrivate(req->wb_page); |
397 | set_page_private(req->wb_page, (unsigned long)req); | 385 | set_page_private(req->wb_page, (unsigned long)req); |
398 | if (PageDirty(req->wb_page)) | ||
399 | set_bit(PG_NEED_FLUSH, &req->wb_flags); | ||
400 | nfsi->npages++; | 386 | nfsi->npages++; |
401 | kref_get(&req->wb_kref); | 387 | kref_get(&req->wb_kref); |
402 | return 0; | 388 | return 0; |
@@ -416,12 +402,9 @@ static void nfs_inode_remove_request(struct nfs_page *req) | |||
416 | set_page_private(req->wb_page, 0); | 402 | set_page_private(req->wb_page, 0); |
417 | ClearPagePrivate(req->wb_page); | 403 | ClearPagePrivate(req->wb_page); |
418 | radix_tree_delete(&nfsi->nfs_page_tree, req->wb_index); | 404 | radix_tree_delete(&nfsi->nfs_page_tree, req->wb_index); |
419 | if (test_and_clear_bit(PG_NEED_FLUSH, &req->wb_flags)) | ||
420 | __set_page_dirty_nobuffers(req->wb_page); | ||
421 | nfsi->npages--; | 405 | nfsi->npages--; |
422 | if (!nfsi->npages) { | 406 | if (!nfsi->npages) { |
423 | spin_unlock(&inode->i_lock); | 407 | spin_unlock(&inode->i_lock); |
424 | nfs_end_data_update(inode); | ||
425 | iput(inode); | 408 | iput(inode); |
426 | } else | 409 | } else |
427 | spin_unlock(&inode->i_lock); | 410 | spin_unlock(&inode->i_lock); |
@@ -682,7 +665,7 @@ static struct nfs_page * nfs_update_request(struct nfs_open_context* ctx, | |||
682 | 665 | ||
683 | int nfs_flush_incompatible(struct file *file, struct page *page) | 666 | int nfs_flush_incompatible(struct file *file, struct page *page) |
684 | { | 667 | { |
685 | struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data; | 668 | struct nfs_open_context *ctx = nfs_file_open_context(file); |
686 | struct nfs_page *req; | 669 | struct nfs_page *req; |
687 | int do_flush, status; | 670 | int do_flush, status; |
688 | /* | 671 | /* |
@@ -716,7 +699,7 @@ int nfs_flush_incompatible(struct file *file, struct page *page) | |||
716 | int nfs_updatepage(struct file *file, struct page *page, | 699 | int nfs_updatepage(struct file *file, struct page *page, |
717 | unsigned int offset, unsigned int count) | 700 | unsigned int offset, unsigned int count) |
718 | { | 701 | { |
719 | struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data; | 702 | struct nfs_open_context *ctx = nfs_file_open_context(file); |
720 | struct inode *inode = page->mapping->host; | 703 | struct inode *inode = page->mapping->host; |
721 | int status = 0; | 704 | int status = 0; |
722 | 705 | ||
@@ -967,7 +950,7 @@ static void nfs_writeback_done_partial(struct rpc_task *task, void *calldata) | |||
967 | 950 | ||
968 | if (task->tk_status < 0) { | 951 | if (task->tk_status < 0) { |
969 | nfs_set_pageerror(page); | 952 | nfs_set_pageerror(page); |
970 | req->wb_context->error = task->tk_status; | 953 | nfs_context_set_write_error(req->wb_context, task->tk_status); |
971 | dprintk(", error = %d\n", task->tk_status); | 954 | dprintk(", error = %d\n", task->tk_status); |
972 | goto out; | 955 | goto out; |
973 | } | 956 | } |
@@ -1030,7 +1013,7 @@ static void nfs_writeback_done_full(struct rpc_task *task, void *calldata) | |||
1030 | 1013 | ||
1031 | if (task->tk_status < 0) { | 1014 | if (task->tk_status < 0) { |
1032 | nfs_set_pageerror(page); | 1015 | nfs_set_pageerror(page); |
1033 | req->wb_context->error = task->tk_status; | 1016 | nfs_context_set_write_error(req->wb_context, task->tk_status); |
1034 | dprintk(", error = %d\n", task->tk_status); | 1017 | dprintk(", error = %d\n", task->tk_status); |
1035 | goto remove_request; | 1018 | goto remove_request; |
1036 | } | 1019 | } |
@@ -1244,7 +1227,7 @@ static void nfs_commit_done(struct rpc_task *task, void *calldata) | |||
1244 | req->wb_bytes, | 1227 | req->wb_bytes, |
1245 | (long long)req_offset(req)); | 1228 | (long long)req_offset(req)); |
1246 | if (task->tk_status < 0) { | 1229 | if (task->tk_status < 0) { |
1247 | req->wb_context->error = task->tk_status; | 1230 | nfs_context_set_write_error(req->wb_context, task->tk_status); |
1248 | nfs_inode_remove_request(req); | 1231 | nfs_inode_remove_request(req); |
1249 | dprintk(", error = %d\n", task->tk_status); | 1232 | dprintk(", error = %d\n", task->tk_status); |
1250 | goto next; | 1233 | goto next; |
@@ -1347,53 +1330,52 @@ long nfs_sync_mapping_wait(struct address_space *mapping, struct writeback_contr | |||
1347 | return ret; | 1330 | return ret; |
1348 | } | 1331 | } |
1349 | 1332 | ||
1350 | /* | 1333 | static int __nfs_write_mapping(struct address_space *mapping, struct writeback_control *wbc, int how) |
1351 | * flush the inode to disk. | ||
1352 | */ | ||
1353 | int nfs_wb_all(struct inode *inode) | ||
1354 | { | 1334 | { |
1355 | struct address_space *mapping = inode->i_mapping; | ||
1356 | struct writeback_control wbc = { | ||
1357 | .bdi = mapping->backing_dev_info, | ||
1358 | .sync_mode = WB_SYNC_ALL, | ||
1359 | .nr_to_write = LONG_MAX, | ||
1360 | .for_writepages = 1, | ||
1361 | .range_cyclic = 1, | ||
1362 | }; | ||
1363 | int ret; | 1335 | int ret; |
1364 | 1336 | ||
1365 | ret = nfs_writepages(mapping, &wbc); | 1337 | ret = nfs_writepages(mapping, wbc); |
1366 | if (ret < 0) | 1338 | if (ret < 0) |
1367 | goto out; | 1339 | goto out; |
1368 | ret = nfs_sync_mapping_wait(mapping, &wbc, 0); | 1340 | ret = nfs_sync_mapping_wait(mapping, wbc, how); |
1369 | if (ret >= 0) | 1341 | if (ret < 0) |
1370 | return 0; | 1342 | goto out; |
1343 | return 0; | ||
1371 | out: | 1344 | out: |
1372 | __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); | 1345 | __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); |
1373 | return ret; | 1346 | return ret; |
1374 | } | 1347 | } |
1375 | 1348 | ||
1376 | int nfs_sync_mapping_range(struct address_space *mapping, loff_t range_start, loff_t range_end, int how) | 1349 | /* Two pass sync: first using WB_SYNC_NONE, then WB_SYNC_ALL */ |
1350 | static int nfs_write_mapping(struct address_space *mapping, int how) | ||
1377 | { | 1351 | { |
1378 | struct writeback_control wbc = { | 1352 | struct writeback_control wbc = { |
1379 | .bdi = mapping->backing_dev_info, | 1353 | .bdi = mapping->backing_dev_info, |
1380 | .sync_mode = WB_SYNC_ALL, | 1354 | .sync_mode = WB_SYNC_NONE, |
1381 | .nr_to_write = LONG_MAX, | 1355 | .nr_to_write = LONG_MAX, |
1382 | .range_start = range_start, | ||
1383 | .range_end = range_end, | ||
1384 | .for_writepages = 1, | 1356 | .for_writepages = 1, |
1357 | .range_cyclic = 1, | ||
1385 | }; | 1358 | }; |
1386 | int ret; | 1359 | int ret; |
1387 | 1360 | ||
1388 | ret = nfs_writepages(mapping, &wbc); | 1361 | ret = __nfs_write_mapping(mapping, &wbc, how); |
1389 | if (ret < 0) | 1362 | if (ret < 0) |
1390 | goto out; | 1363 | return ret; |
1391 | ret = nfs_sync_mapping_wait(mapping, &wbc, how); | 1364 | wbc.sync_mode = WB_SYNC_ALL; |
1392 | if (ret >= 0) | 1365 | return __nfs_write_mapping(mapping, &wbc, how); |
1393 | return 0; | 1366 | } |
1394 | out: | 1367 | |
1395 | __mark_inode_dirty(mapping->host, I_DIRTY_PAGES); | 1368 | /* |
1396 | return ret; | 1369 | * flush the inode to disk. |
1370 | */ | ||
1371 | int nfs_wb_all(struct inode *inode) | ||
1372 | { | ||
1373 | return nfs_write_mapping(inode->i_mapping, 0); | ||
1374 | } | ||
1375 | |||
1376 | int nfs_wb_nocommit(struct inode *inode) | ||
1377 | { | ||
1378 | return nfs_write_mapping(inode->i_mapping, FLUSH_NOCOMMIT); | ||
1397 | } | 1379 | } |
1398 | 1380 | ||
1399 | int nfs_wb_page_cancel(struct inode *inode, struct page *page) | 1381 | int nfs_wb_page_cancel(struct inode *inode, struct page *page) |
@@ -1477,35 +1459,6 @@ int nfs_wb_page(struct inode *inode, struct page* page) | |||
1477 | return nfs_wb_page_priority(inode, page, FLUSH_STABLE); | 1459 | return nfs_wb_page_priority(inode, page, FLUSH_STABLE); |
1478 | } | 1460 | } |
1479 | 1461 | ||
1480 | int nfs_set_page_dirty(struct page *page) | ||
1481 | { | ||
1482 | struct address_space *mapping = page->mapping; | ||
1483 | struct inode *inode; | ||
1484 | struct nfs_page *req; | ||
1485 | int ret; | ||
1486 | |||
1487 | if (!mapping) | ||
1488 | goto out_raced; | ||
1489 | inode = mapping->host; | ||
1490 | if (!inode) | ||
1491 | goto out_raced; | ||
1492 | spin_lock(&inode->i_lock); | ||
1493 | req = nfs_page_find_request_locked(page); | ||
1494 | if (req != NULL) { | ||
1495 | /* Mark any existing write requests for flushing */ | ||
1496 | ret = !test_and_set_bit(PG_NEED_FLUSH, &req->wb_flags); | ||
1497 | spin_unlock(&inode->i_lock); | ||
1498 | nfs_release_request(req); | ||
1499 | return ret; | ||
1500 | } | ||
1501 | ret = __set_page_dirty_nobuffers(page); | ||
1502 | spin_unlock(&inode->i_lock); | ||
1503 | return ret; | ||
1504 | out_raced: | ||
1505 | return !TestSetPageDirty(page); | ||
1506 | } | ||
1507 | |||
1508 | |||
1509 | int __init nfs_init_writepagecache(void) | 1462 | int __init nfs_init_writepagecache(void) |
1510 | { | 1463 | { |
1511 | nfs_wdata_cachep = kmem_cache_create("nfs_write_data", | 1464 | nfs_wdata_cachep = kmem_cache_create("nfs_write_data", |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index e15f2cf8ac15..57333944af7f 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -102,7 +102,8 @@ check_filename(char *str, int len, __be32 err) | |||
102 | out: \ | 102 | out: \ |
103 | return status; \ | 103 | return status; \ |
104 | xdr_error: \ | 104 | xdr_error: \ |
105 | printk(KERN_NOTICE "xdr error! (%s:%d)\n", __FILE__, __LINE__); \ | 105 | dprintk("NFSD: xdr error (%s:%d)\n", \ |
106 | __FILE__, __LINE__); \ | ||
106 | status = nfserr_bad_xdr; \ | 107 | status = nfserr_bad_xdr; \ |
107 | goto out | 108 | goto out |
108 | 109 | ||
@@ -124,7 +125,8 @@ xdr_error: \ | |||
124 | if (!(x = (p==argp->tmp || p == argp->tmpp) ? \ | 125 | if (!(x = (p==argp->tmp || p == argp->tmpp) ? \ |
125 | savemem(argp, p, nbytes) : \ | 126 | savemem(argp, p, nbytes) : \ |
126 | (char *)p)) { \ | 127 | (char *)p)) { \ |
127 | printk(KERN_NOTICE "xdr error! (%s:%d)\n", __FILE__, __LINE__); \ | 128 | dprintk("NFSD: xdr error (%s:%d)\n", \ |
129 | __FILE__, __LINE__); \ | ||
128 | goto xdr_error; \ | 130 | goto xdr_error; \ |
129 | } \ | 131 | } \ |
130 | p += XDR_QUADLEN(nbytes); \ | 132 | p += XDR_QUADLEN(nbytes); \ |
@@ -140,7 +142,8 @@ xdr_error: \ | |||
140 | p = argp->p; \ | 142 | p = argp->p; \ |
141 | argp->p += XDR_QUADLEN(nbytes); \ | 143 | argp->p += XDR_QUADLEN(nbytes); \ |
142 | } else if (!(p = read_buf(argp, nbytes))) { \ | 144 | } else if (!(p = read_buf(argp, nbytes))) { \ |
143 | printk(KERN_NOTICE "xdr error! (%s:%d)\n", __FILE__, __LINE__); \ | 145 | dprintk("NFSD: xdr error (%s:%d)\n", \ |
146 | __FILE__, __LINE__); \ | ||
144 | goto xdr_error; \ | 147 | goto xdr_error; \ |
145 | } \ | 148 | } \ |
146 | } while (0) | 149 | } while (0) |
@@ -948,7 +951,8 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) | |||
948 | */ | 951 | */ |
949 | avail = (char*)argp->end - (char*)argp->p; | 952 | avail = (char*)argp->end - (char*)argp->p; |
950 | if (avail + argp->pagelen < write->wr_buflen) { | 953 | if (avail + argp->pagelen < write->wr_buflen) { |
951 | printk(KERN_NOTICE "xdr error! (%s:%d)\n", __FILE__, __LINE__); | 954 | dprintk("NFSD: xdr error (%s:%d)\n", |
955 | __FILE__, __LINE__); | ||
952 | goto xdr_error; | 956 | goto xdr_error; |
953 | } | 957 | } |
954 | argp->rqstp->rq_vec[0].iov_base = p; | 958 | argp->rqstp->rq_vec[0].iov_base = p; |
@@ -1019,7 +1023,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) | |||
1019 | argp->ops = kmalloc(argp->opcnt * sizeof(*argp->ops), GFP_KERNEL); | 1023 | argp->ops = kmalloc(argp->opcnt * sizeof(*argp->ops), GFP_KERNEL); |
1020 | if (!argp->ops) { | 1024 | if (!argp->ops) { |
1021 | argp->ops = argp->iops; | 1025 | argp->ops = argp->iops; |
1022 | printk(KERN_INFO "nfsd: couldn't allocate room for COMPOUND\n"); | 1026 | dprintk("nfsd: couldn't allocate room for COMPOUND\n"); |
1023 | goto xdr_error; | 1027 | goto xdr_error; |
1024 | } | 1028 | } |
1025 | } | 1029 | } |
@@ -1326,7 +1330,7 @@ static char *nfsd4_path(struct svc_rqst *rqstp, struct svc_export *exp, __be32 * | |||
1326 | path = exp->ex_path; | 1330 | path = exp->ex_path; |
1327 | 1331 | ||
1328 | if (strncmp(path, rootpath, strlen(rootpath))) { | 1332 | if (strncmp(path, rootpath, strlen(rootpath))) { |
1329 | printk("nfsd: fs_locations failed;" | 1333 | dprintk("nfsd: fs_locations failed;" |
1330 | "%s is not contained in %s\n", path, rootpath); | 1334 | "%s is not contained in %s\n", path, rootpath); |
1331 | *stat = nfserr_notsupp; | 1335 | *stat = nfserr_notsupp; |
1332 | return NULL; | 1336 | return NULL; |