diff options
author | Steve French <sfrench@us.ibm.com> | 2006-01-12 17:47:08 -0500 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2006-01-12 17:47:08 -0500 |
commit | 94bc2be31a01a3055ec94176e595dfe208e92d3b (patch) | |
tree | ebfbe81c6718a6390bfa1b99c6d228237d818576 /fs/nfsd | |
parent | c32a0b689cb9cc160cfcd19735bbf50bb70c6ef4 (diff) | |
parent | 58cba4650a7a414eabd2b40cc9d8e45fcdf192d9 (diff) |
Merge with /pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs3proc.c | 11 | ||||
-rw-r--r-- | fs/nfsd/nfs3xdr.c | 47 | ||||
-rw-r--r-- | fs/nfsd/nfs4callback.c | 11 | ||||
-rw-r--r-- | fs/nfsd/nfs4recover.c | 20 | ||||
-rw-r--r-- | fs/nfsd/nfsxdr.c | 48 | ||||
-rw-r--r-- | fs/nfsd/vfs.c | 169 |
6 files changed, 150 insertions, 156 deletions
diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index 041380fe667b..6d2dfed1de08 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c | |||
@@ -56,13 +56,20 @@ static int | |||
56 | nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp, | 56 | nfsd3_proc_getattr(struct svc_rqst *rqstp, struct nfsd_fhandle *argp, |
57 | struct nfsd3_attrstat *resp) | 57 | struct nfsd3_attrstat *resp) |
58 | { | 58 | { |
59 | int nfserr; | 59 | int err, nfserr; |
60 | 60 | ||
61 | dprintk("nfsd: GETATTR(3) %s\n", | 61 | dprintk("nfsd: GETATTR(3) %s\n", |
62 | SVCFH_fmt(&argp->fh)); | 62 | SVCFH_fmt(&argp->fh)); |
63 | 63 | ||
64 | fh_copy(&resp->fh, &argp->fh); | 64 | fh_copy(&resp->fh, &argp->fh); |
65 | nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP); | 65 | nfserr = fh_verify(rqstp, &resp->fh, 0, MAY_NOP); |
66 | if (nfserr) | ||
67 | RETURN_STATUS(nfserr); | ||
68 | |||
69 | err = vfs_getattr(resp->fh.fh_export->ex_mnt, | ||
70 | resp->fh.fh_dentry, &resp->stat); | ||
71 | nfserr = nfserrno(err); | ||
72 | |||
66 | RETURN_STATUS(nfserr); | 73 | RETURN_STATUS(nfserr); |
67 | } | 74 | } |
68 | 75 | ||
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 9147b8524d05..243d94b9653a 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c | |||
@@ -154,37 +154,34 @@ decode_sattr3(u32 *p, struct iattr *iap) | |||
154 | } | 154 | } |
155 | 155 | ||
156 | static inline u32 * | 156 | static inline u32 * |
157 | encode_fattr3(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) | 157 | encode_fattr3(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp, |
158 | struct kstat *stat) | ||
158 | { | 159 | { |
159 | struct vfsmount *mnt = fhp->fh_export->ex_mnt; | ||
160 | struct dentry *dentry = fhp->fh_dentry; | 160 | struct dentry *dentry = fhp->fh_dentry; |
161 | struct kstat stat; | ||
162 | struct timespec time; | 161 | struct timespec time; |
163 | 162 | ||
164 | vfs_getattr(mnt, dentry, &stat); | 163 | *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]); |
165 | 164 | *p++ = htonl((u32) stat->mode); | |
166 | *p++ = htonl(nfs3_ftypes[(stat.mode & S_IFMT) >> 12]); | 165 | *p++ = htonl((u32) stat->nlink); |
167 | *p++ = htonl((u32) stat.mode); | 166 | *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid)); |
168 | *p++ = htonl((u32) stat.nlink); | 167 | *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid)); |
169 | *p++ = htonl((u32) nfsd_ruid(rqstp, stat.uid)); | 168 | if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) { |
170 | *p++ = htonl((u32) nfsd_rgid(rqstp, stat.gid)); | ||
171 | if (S_ISLNK(stat.mode) && stat.size > NFS3_MAXPATHLEN) { | ||
172 | p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN); | 169 | p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN); |
173 | } else { | 170 | } else { |
174 | p = xdr_encode_hyper(p, (u64) stat.size); | 171 | p = xdr_encode_hyper(p, (u64) stat->size); |
175 | } | 172 | } |
176 | p = xdr_encode_hyper(p, ((u64)stat.blocks) << 9); | 173 | p = xdr_encode_hyper(p, ((u64)stat->blocks) << 9); |
177 | *p++ = htonl((u32) MAJOR(stat.rdev)); | 174 | *p++ = htonl((u32) MAJOR(stat->rdev)); |
178 | *p++ = htonl((u32) MINOR(stat.rdev)); | 175 | *p++ = htonl((u32) MINOR(stat->rdev)); |
179 | if (is_fsid(fhp, rqstp->rq_reffh)) | 176 | if (is_fsid(fhp, rqstp->rq_reffh)) |
180 | p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid); | 177 | p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid); |
181 | else | 178 | else |
182 | p = xdr_encode_hyper(p, (u64) huge_encode_dev(stat.dev)); | 179 | p = xdr_encode_hyper(p, (u64) huge_encode_dev(stat->dev)); |
183 | p = xdr_encode_hyper(p, (u64) stat.ino); | 180 | p = xdr_encode_hyper(p, (u64) stat->ino); |
184 | p = encode_time3(p, &stat.atime); | 181 | p = encode_time3(p, &stat->atime); |
185 | lease_get_mtime(dentry->d_inode, &time); | 182 | lease_get_mtime(dentry->d_inode, &time); |
186 | p = encode_time3(p, &time); | 183 | p = encode_time3(p, &time); |
187 | p = encode_time3(p, &stat.ctime); | 184 | p = encode_time3(p, &stat->ctime); |
188 | 185 | ||
189 | return p; | 186 | return p; |
190 | } | 187 | } |
@@ -232,8 +229,14 @@ encode_post_op_attr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) | |||
232 | { | 229 | { |
233 | struct dentry *dentry = fhp->fh_dentry; | 230 | struct dentry *dentry = fhp->fh_dentry; |
234 | if (dentry && dentry->d_inode != NULL) { | 231 | if (dentry && dentry->d_inode != NULL) { |
235 | *p++ = xdr_one; /* attributes follow */ | 232 | int err; |
236 | return encode_fattr3(rqstp, p, fhp); | 233 | struct kstat stat; |
234 | |||
235 | err = vfs_getattr(fhp->fh_export->ex_mnt, dentry, &stat); | ||
236 | if (!err) { | ||
237 | *p++ = xdr_one; /* attributes follow */ | ||
238 | return encode_fattr3(rqstp, p, fhp, &stat); | ||
239 | } | ||
237 | } | 240 | } |
238 | *p++ = xdr_zero; | 241 | *p++ = xdr_zero; |
239 | return p; | 242 | return p; |
@@ -616,7 +619,7 @@ nfs3svc_encode_attrstat(struct svc_rqst *rqstp, u32 *p, | |||
616 | struct nfsd3_attrstat *resp) | 619 | struct nfsd3_attrstat *resp) |
617 | { | 620 | { |
618 | if (resp->status == 0) | 621 | if (resp->status == 0) |
619 | p = encode_fattr3(rqstp, p, &resp->fh); | 622 | p = encode_fattr3(rqstp, p, &resp->fh, &resp->stat); |
620 | return xdr_ressize_check(rqstp, p); | 623 | return xdr_ressize_check(rqstp, p); |
621 | } | 624 | } |
622 | 625 | ||
diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 583c0710e45e..d828662d737d 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c | |||
@@ -53,7 +53,7 @@ | |||
53 | #define NFSPROC4_CB_COMPOUND 1 | 53 | #define NFSPROC4_CB_COMPOUND 1 |
54 | 54 | ||
55 | /* declarations */ | 55 | /* declarations */ |
56 | static void nfs4_cb_null(struct rpc_task *task); | 56 | static const struct rpc_call_ops nfs4_cb_null_ops; |
57 | 57 | ||
58 | /* Index of predefined Linux callback client operations */ | 58 | /* Index of predefined Linux callback client operations */ |
59 | 59 | ||
@@ -431,7 +431,6 @@ nfsd4_probe_callback(struct nfs4_client *clp) | |||
431 | } | 431 | } |
432 | clnt->cl_intr = 0; | 432 | clnt->cl_intr = 0; |
433 | clnt->cl_softrtry = 1; | 433 | clnt->cl_softrtry = 1; |
434 | clnt->cl_chatty = 1; | ||
435 | 434 | ||
436 | /* Kick rpciod, put the call on the wire. */ | 435 | /* Kick rpciod, put the call on the wire. */ |
437 | 436 | ||
@@ -447,7 +446,7 @@ nfsd4_probe_callback(struct nfs4_client *clp) | |||
447 | msg.rpc_cred = nfsd4_lookupcred(clp,0); | 446 | msg.rpc_cred = nfsd4_lookupcred(clp,0); |
448 | if (IS_ERR(msg.rpc_cred)) | 447 | if (IS_ERR(msg.rpc_cred)) |
449 | goto out_rpciod; | 448 | goto out_rpciod; |
450 | status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, nfs4_cb_null, NULL); | 449 | status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, &nfs4_cb_null_ops, NULL); |
451 | put_rpccred(msg.rpc_cred); | 450 | put_rpccred(msg.rpc_cred); |
452 | 451 | ||
453 | if (status != 0) { | 452 | if (status != 0) { |
@@ -469,7 +468,7 @@ out_err: | |||
469 | } | 468 | } |
470 | 469 | ||
471 | static void | 470 | static void |
472 | nfs4_cb_null(struct rpc_task *task) | 471 | nfs4_cb_null(struct rpc_task *task, void *dummy) |
473 | { | 472 | { |
474 | struct nfs4_client *clp = (struct nfs4_client *)task->tk_msg.rpc_argp; | 473 | struct nfs4_client *clp = (struct nfs4_client *)task->tk_msg.rpc_argp; |
475 | struct nfs4_callback *cb = &clp->cl_callback; | 474 | struct nfs4_callback *cb = &clp->cl_callback; |
@@ -488,6 +487,10 @@ out: | |||
488 | put_nfs4_client(clp); | 487 | put_nfs4_client(clp); |
489 | } | 488 | } |
490 | 489 | ||
490 | static const struct rpc_call_ops nfs4_cb_null_ops = { | ||
491 | .rpc_call_done = nfs4_cb_null, | ||
492 | }; | ||
493 | |||
491 | /* | 494 | /* |
492 | * called with dp->dl_count inc'ed. | 495 | * called with dp->dl_count inc'ed. |
493 | * nfs4_lock_state() may or may not have been called. | 496 | * nfs4_lock_state() may or may not have been called. |
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 954cf893d50c..be963a133aaa 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c | |||
@@ -121,9 +121,9 @@ out: | |||
121 | static void | 121 | static void |
122 | nfsd4_sync_rec_dir(void) | 122 | nfsd4_sync_rec_dir(void) |
123 | { | 123 | { |
124 | down(&rec_dir.dentry->d_inode->i_sem); | 124 | mutex_lock(&rec_dir.dentry->d_inode->i_mutex); |
125 | nfsd_sync_dir(rec_dir.dentry); | 125 | nfsd_sync_dir(rec_dir.dentry); |
126 | up(&rec_dir.dentry->d_inode->i_sem); | 126 | mutex_unlock(&rec_dir.dentry->d_inode->i_mutex); |
127 | } | 127 | } |
128 | 128 | ||
129 | int | 129 | int |
@@ -143,7 +143,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp) | |||
143 | nfs4_save_user(&uid, &gid); | 143 | nfs4_save_user(&uid, &gid); |
144 | 144 | ||
145 | /* lock the parent */ | 145 | /* lock the parent */ |
146 | down(&rec_dir.dentry->d_inode->i_sem); | 146 | mutex_lock(&rec_dir.dentry->d_inode->i_mutex); |
147 | 147 | ||
148 | dentry = lookup_one_len(dname, rec_dir.dentry, HEXDIR_LEN-1); | 148 | dentry = lookup_one_len(dname, rec_dir.dentry, HEXDIR_LEN-1); |
149 | if (IS_ERR(dentry)) { | 149 | if (IS_ERR(dentry)) { |
@@ -159,7 +159,7 @@ nfsd4_create_clid_dir(struct nfs4_client *clp) | |||
159 | out_put: | 159 | out_put: |
160 | dput(dentry); | 160 | dput(dentry); |
161 | out_unlock: | 161 | out_unlock: |
162 | up(&rec_dir.dentry->d_inode->i_sem); | 162 | mutex_unlock(&rec_dir.dentry->d_inode->i_mutex); |
163 | if (status == 0) { | 163 | if (status == 0) { |
164 | clp->cl_firststate = 1; | 164 | clp->cl_firststate = 1; |
165 | nfsd4_sync_rec_dir(); | 165 | nfsd4_sync_rec_dir(); |
@@ -259,9 +259,9 @@ nfsd4_remove_clid_file(struct dentry *dir, struct dentry *dentry) | |||
259 | printk("nfsd4: non-file found in client recovery directory\n"); | 259 | printk("nfsd4: non-file found in client recovery directory\n"); |
260 | return -EINVAL; | 260 | return -EINVAL; |
261 | } | 261 | } |
262 | down(&dir->d_inode->i_sem); | 262 | mutex_lock(&dir->d_inode->i_mutex); |
263 | status = vfs_unlink(dir->d_inode, dentry); | 263 | status = vfs_unlink(dir->d_inode, dentry); |
264 | up(&dir->d_inode->i_sem); | 264 | mutex_unlock(&dir->d_inode->i_mutex); |
265 | return status; | 265 | return status; |
266 | } | 266 | } |
267 | 267 | ||
@@ -274,9 +274,9 @@ nfsd4_clear_clid_dir(struct dentry *dir, struct dentry *dentry) | |||
274 | * any regular files anyway, just in case the directory was created by | 274 | * any regular files anyway, just in case the directory was created by |
275 | * a kernel from the future.... */ | 275 | * a kernel from the future.... */ |
276 | nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file); | 276 | nfsd4_list_rec_dir(dentry, nfsd4_remove_clid_file); |
277 | down(&dir->d_inode->i_sem); | 277 | mutex_lock(&dir->d_inode->i_mutex); |
278 | status = vfs_rmdir(dir->d_inode, dentry); | 278 | status = vfs_rmdir(dir->d_inode, dentry); |
279 | up(&dir->d_inode->i_sem); | 279 | mutex_unlock(&dir->d_inode->i_mutex); |
280 | return status; | 280 | return status; |
281 | } | 281 | } |
282 | 282 | ||
@@ -288,9 +288,9 @@ nfsd4_unlink_clid_dir(char *name, int namlen) | |||
288 | 288 | ||
289 | dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name); | 289 | dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name); |
290 | 290 | ||
291 | down(&rec_dir.dentry->d_inode->i_sem); | 291 | mutex_lock(&rec_dir.dentry->d_inode->i_mutex); |
292 | dentry = lookup_one_len(name, rec_dir.dentry, namlen); | 292 | dentry = lookup_one_len(name, rec_dir.dentry, namlen); |
293 | up(&rec_dir.dentry->d_inode->i_sem); | 293 | mutex_unlock(&rec_dir.dentry->d_inode->i_mutex); |
294 | if (IS_ERR(dentry)) { | 294 | if (IS_ERR(dentry)) { |
295 | status = PTR_ERR(dentry); | 295 | status = PTR_ERR(dentry); |
296 | return status; | 296 | return status; |
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index b45999ff33e6..aa7bb41b293d 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c | |||
@@ -152,46 +152,44 @@ decode_sattr(u32 *p, struct iattr *iap) | |||
152 | } | 152 | } |
153 | 153 | ||
154 | static inline u32 * | 154 | static inline u32 * |
155 | encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) | 155 | encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp, |
156 | struct kstat *stat) | ||
156 | { | 157 | { |
157 | struct vfsmount *mnt = fhp->fh_export->ex_mnt; | ||
158 | struct dentry *dentry = fhp->fh_dentry; | 158 | struct dentry *dentry = fhp->fh_dentry; |
159 | struct kstat stat; | ||
160 | int type; | 159 | int type; |
161 | struct timespec time; | 160 | struct timespec time; |
162 | 161 | ||
163 | vfs_getattr(mnt, dentry, &stat); | 162 | type = (stat->mode & S_IFMT); |
164 | type = (stat.mode & S_IFMT); | ||
165 | 163 | ||
166 | *p++ = htonl(nfs_ftypes[type >> 12]); | 164 | *p++ = htonl(nfs_ftypes[type >> 12]); |
167 | *p++ = htonl((u32) stat.mode); | 165 | *p++ = htonl((u32) stat->mode); |
168 | *p++ = htonl((u32) stat.nlink); | 166 | *p++ = htonl((u32) stat->nlink); |
169 | *p++ = htonl((u32) nfsd_ruid(rqstp, stat.uid)); | 167 | *p++ = htonl((u32) nfsd_ruid(rqstp, stat->uid)); |
170 | *p++ = htonl((u32) nfsd_rgid(rqstp, stat.gid)); | 168 | *p++ = htonl((u32) nfsd_rgid(rqstp, stat->gid)); |
171 | 169 | ||
172 | if (S_ISLNK(type) && stat.size > NFS_MAXPATHLEN) { | 170 | if (S_ISLNK(type) && stat->size > NFS_MAXPATHLEN) { |
173 | *p++ = htonl(NFS_MAXPATHLEN); | 171 | *p++ = htonl(NFS_MAXPATHLEN); |
174 | } else { | 172 | } else { |
175 | *p++ = htonl((u32) stat.size); | 173 | *p++ = htonl((u32) stat->size); |
176 | } | 174 | } |
177 | *p++ = htonl((u32) stat.blksize); | 175 | *p++ = htonl((u32) stat->blksize); |
178 | if (S_ISCHR(type) || S_ISBLK(type)) | 176 | if (S_ISCHR(type) || S_ISBLK(type)) |
179 | *p++ = htonl(new_encode_dev(stat.rdev)); | 177 | *p++ = htonl(new_encode_dev(stat->rdev)); |
180 | else | 178 | else |
181 | *p++ = htonl(0xffffffff); | 179 | *p++ = htonl(0xffffffff); |
182 | *p++ = htonl((u32) stat.blocks); | 180 | *p++ = htonl((u32) stat->blocks); |
183 | if (is_fsid(fhp, rqstp->rq_reffh)) | 181 | if (is_fsid(fhp, rqstp->rq_reffh)) |
184 | *p++ = htonl((u32) fhp->fh_export->ex_fsid); | 182 | *p++ = htonl((u32) fhp->fh_export->ex_fsid); |
185 | else | 183 | else |
186 | *p++ = htonl(new_encode_dev(stat.dev)); | 184 | *p++ = htonl(new_encode_dev(stat->dev)); |
187 | *p++ = htonl((u32) stat.ino); | 185 | *p++ = htonl((u32) stat->ino); |
188 | *p++ = htonl((u32) stat.atime.tv_sec); | 186 | *p++ = htonl((u32) stat->atime.tv_sec); |
189 | *p++ = htonl(stat.atime.tv_nsec ? stat.atime.tv_nsec / 1000 : 0); | 187 | *p++ = htonl(stat->atime.tv_nsec ? stat->atime.tv_nsec / 1000 : 0); |
190 | lease_get_mtime(dentry->d_inode, &time); | 188 | lease_get_mtime(dentry->d_inode, &time); |
191 | *p++ = htonl((u32) time.tv_sec); | 189 | *p++ = htonl((u32) time.tv_sec); |
192 | *p++ = htonl(time.tv_nsec ? time.tv_nsec / 1000 : 0); | 190 | *p++ = htonl(time.tv_nsec ? time.tv_nsec / 1000 : 0); |
193 | *p++ = htonl((u32) stat.ctime.tv_sec); | 191 | *p++ = htonl((u32) stat->ctime.tv_sec); |
194 | *p++ = htonl(stat.ctime.tv_nsec ? stat.ctime.tv_nsec / 1000 : 0); | 192 | *p++ = htonl(stat->ctime.tv_nsec ? stat->ctime.tv_nsec / 1000 : 0); |
195 | 193 | ||
196 | return p; | 194 | return p; |
197 | } | 195 | } |
@@ -199,7 +197,9 @@ encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) | |||
199 | /* Helper function for NFSv2 ACL code */ | 197 | /* Helper function for NFSv2 ACL code */ |
200 | u32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) | 198 | u32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, u32 *p, struct svc_fh *fhp) |
201 | { | 199 | { |
202 | return encode_fattr(rqstp, p, fhp); | 200 | struct kstat stat; |
201 | vfs_getattr(fhp->fh_export->ex_mnt, fhp->fh_dentry, &stat); | ||
202 | return encode_fattr(rqstp, p, fhp, &stat); | ||
203 | } | 203 | } |
204 | 204 | ||
205 | /* | 205 | /* |
@@ -394,7 +394,7 @@ int | |||
394 | nfssvc_encode_attrstat(struct svc_rqst *rqstp, u32 *p, | 394 | nfssvc_encode_attrstat(struct svc_rqst *rqstp, u32 *p, |
395 | struct nfsd_attrstat *resp) | 395 | struct nfsd_attrstat *resp) |
396 | { | 396 | { |
397 | p = encode_fattr(rqstp, p, &resp->fh); | 397 | p = encode_fattr(rqstp, p, &resp->fh, &resp->stat); |
398 | return xdr_ressize_check(rqstp, p); | 398 | return xdr_ressize_check(rqstp, p); |
399 | } | 399 | } |
400 | 400 | ||
@@ -403,7 +403,7 @@ nfssvc_encode_diropres(struct svc_rqst *rqstp, u32 *p, | |||
403 | struct nfsd_diropres *resp) | 403 | struct nfsd_diropres *resp) |
404 | { | 404 | { |
405 | p = encode_fh(p, &resp->fh); | 405 | p = encode_fh(p, &resp->fh); |
406 | p = encode_fattr(rqstp, p, &resp->fh); | 406 | p = encode_fattr(rqstp, p, &resp->fh, &resp->stat); |
407 | return xdr_ressize_check(rqstp, p); | 407 | return xdr_ressize_check(rqstp, p); |
408 | } | 408 | } |
409 | 409 | ||
@@ -428,7 +428,7 @@ int | |||
428 | nfssvc_encode_readres(struct svc_rqst *rqstp, u32 *p, | 428 | nfssvc_encode_readres(struct svc_rqst *rqstp, u32 *p, |
429 | struct nfsd_readres *resp) | 429 | struct nfsd_readres *resp) |
430 | { | 430 | { |
431 | p = encode_fattr(rqstp, p, &resp->fh); | 431 | p = encode_fattr(rqstp, p, &resp->fh, &resp->stat); |
432 | *p++ = htonl(resp->count); | 432 | *p++ = htonl(resp->count); |
433 | xdr_ressize_check(rqstp, p); | 433 | xdr_ressize_check(rqstp, p); |
434 | 434 | ||
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index af7c3c3074b0..eef0576a7785 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -48,8 +48,8 @@ | |||
48 | #include <linux/fsnotify.h> | 48 | #include <linux/fsnotify.h> |
49 | #include <linux/posix_acl.h> | 49 | #include <linux/posix_acl.h> |
50 | #include <linux/posix_acl_xattr.h> | 50 | #include <linux/posix_acl_xattr.h> |
51 | #ifdef CONFIG_NFSD_V4 | ||
52 | #include <linux/xattr.h> | 51 | #include <linux/xattr.h> |
52 | #ifdef CONFIG_NFSD_V4 | ||
53 | #include <linux/nfs4.h> | 53 | #include <linux/nfs4.h> |
54 | #include <linux/nfs4_acl.h> | 54 | #include <linux/nfs4_acl.h> |
55 | #include <linux/nfsd_idmap.h> | 55 | #include <linux/nfsd_idmap.h> |
@@ -365,8 +365,30 @@ out_nfserr: | |||
365 | goto out; | 365 | goto out; |
366 | } | 366 | } |
367 | 367 | ||
368 | #if defined(CONFIG_NFSD_V4) | 368 | #if defined(CONFIG_NFSD_V2_ACL) || \ |
369 | defined(CONFIG_NFSD_V3_ACL) || \ | ||
370 | defined(CONFIG_NFSD_V4) | ||
371 | static ssize_t nfsd_getxattr(struct dentry *dentry, char *key, void **buf) | ||
372 | { | ||
373 | ssize_t buflen; | ||
374 | int error; | ||
375 | |||
376 | buflen = vfs_getxattr(dentry, key, NULL, 0); | ||
377 | if (buflen <= 0) | ||
378 | return buflen; | ||
379 | |||
380 | *buf = kmalloc(buflen, GFP_KERNEL); | ||
381 | if (!*buf) | ||
382 | return -ENOMEM; | ||
369 | 383 | ||
384 | error = vfs_getxattr(dentry, key, *buf, buflen); | ||
385 | if (error < 0) | ||
386 | return error; | ||
387 | return buflen; | ||
388 | } | ||
389 | #endif | ||
390 | |||
391 | #if defined(CONFIG_NFSD_V4) | ||
370 | static int | 392 | static int |
371 | set_nfsv4_acl_one(struct dentry *dentry, struct posix_acl *pacl, char *key) | 393 | set_nfsv4_acl_one(struct dentry *dentry, struct posix_acl *pacl, char *key) |
372 | { | 394 | { |
@@ -374,7 +396,6 @@ set_nfsv4_acl_one(struct dentry *dentry, struct posix_acl *pacl, char *key) | |||
374 | size_t buflen; | 396 | size_t buflen; |
375 | char *buf = NULL; | 397 | char *buf = NULL; |
376 | int error = 0; | 398 | int error = 0; |
377 | struct inode *inode = dentry->d_inode; | ||
378 | 399 | ||
379 | buflen = posix_acl_xattr_size(pacl->a_count); | 400 | buflen = posix_acl_xattr_size(pacl->a_count); |
380 | buf = kmalloc(buflen, GFP_KERNEL); | 401 | buf = kmalloc(buflen, GFP_KERNEL); |
@@ -388,15 +409,7 @@ set_nfsv4_acl_one(struct dentry *dentry, struct posix_acl *pacl, char *key) | |||
388 | goto out; | 409 | goto out; |
389 | } | 410 | } |
390 | 411 | ||
391 | error = -EOPNOTSUPP; | 412 | error = vfs_setxattr(dentry, key, buf, len, 0); |
392 | if (inode->i_op && inode->i_op->setxattr) { | ||
393 | down(&inode->i_sem); | ||
394 | security_inode_setxattr(dentry, key, buf, len, 0); | ||
395 | error = inode->i_op->setxattr(dentry, key, buf, len, 0); | ||
396 | if (!error) | ||
397 | security_inode_post_setxattr(dentry, key, buf, len, 0); | ||
398 | up(&inode->i_sem); | ||
399 | } | ||
400 | out: | 413 | out: |
401 | kfree(buf); | 414 | kfree(buf); |
402 | return error; | 415 | return error; |
@@ -455,44 +468,19 @@ out_nfserr: | |||
455 | static struct posix_acl * | 468 | static struct posix_acl * |
456 | _get_posix_acl(struct dentry *dentry, char *key) | 469 | _get_posix_acl(struct dentry *dentry, char *key) |
457 | { | 470 | { |
458 | struct inode *inode = dentry->d_inode; | 471 | void *buf = NULL; |
459 | char *buf = NULL; | ||
460 | int buflen, error = 0; | ||
461 | struct posix_acl *pacl = NULL; | 472 | struct posix_acl *pacl = NULL; |
473 | int buflen; | ||
462 | 474 | ||
463 | error = -EOPNOTSUPP; | 475 | buflen = nfsd_getxattr(dentry, key, &buf); |
464 | if (inode->i_op == NULL) | 476 | if (!buflen) |
465 | goto out_err; | 477 | buflen = -ENODATA; |
466 | if (inode->i_op->getxattr == NULL) | 478 | if (buflen <= 0) |
467 | goto out_err; | 479 | return ERR_PTR(buflen); |
468 | |||
469 | error = security_inode_getxattr(dentry, key); | ||
470 | if (error) | ||
471 | goto out_err; | ||
472 | |||
473 | buflen = inode->i_op->getxattr(dentry, key, NULL, 0); | ||
474 | if (buflen <= 0) { | ||
475 | error = buflen < 0 ? buflen : -ENODATA; | ||
476 | goto out_err; | ||
477 | } | ||
478 | |||
479 | buf = kmalloc(buflen, GFP_KERNEL); | ||
480 | if (buf == NULL) { | ||
481 | error = -ENOMEM; | ||
482 | goto out_err; | ||
483 | } | ||
484 | |||
485 | error = inode->i_op->getxattr(dentry, key, buf, buflen); | ||
486 | if (error < 0) | ||
487 | goto out_err; | ||
488 | 480 | ||
489 | pacl = posix_acl_from_xattr(buf, buflen); | 481 | pacl = posix_acl_from_xattr(buf, buflen); |
490 | out: | ||
491 | kfree(buf); | 482 | kfree(buf); |
492 | return pacl; | 483 | return pacl; |
493 | out_err: | ||
494 | pacl = ERR_PTR(error); | ||
495 | goto out; | ||
496 | } | 484 | } |
497 | 485 | ||
498 | int | 486 | int |
@@ -717,27 +705,33 @@ nfsd_close(struct file *filp) | |||
717 | * As this calls fsync (not fdatasync) there is no need for a write_inode | 705 | * As this calls fsync (not fdatasync) there is no need for a write_inode |
718 | * after it. | 706 | * after it. |
719 | */ | 707 | */ |
720 | static inline void nfsd_dosync(struct file *filp, struct dentry *dp, | 708 | static inline int nfsd_dosync(struct file *filp, struct dentry *dp, |
721 | struct file_operations *fop) | 709 | struct file_operations *fop) |
722 | { | 710 | { |
723 | struct inode *inode = dp->d_inode; | 711 | struct inode *inode = dp->d_inode; |
724 | int (*fsync) (struct file *, struct dentry *, int); | 712 | int (*fsync) (struct file *, struct dentry *, int); |
713 | int err = nfs_ok; | ||
725 | 714 | ||
726 | filemap_fdatawrite(inode->i_mapping); | 715 | filemap_fdatawrite(inode->i_mapping); |
727 | if (fop && (fsync = fop->fsync)) | 716 | if (fop && (fsync = fop->fsync)) |
728 | fsync(filp, dp, 0); | 717 | err=fsync(filp, dp, 0); |
729 | filemap_fdatawait(inode->i_mapping); | 718 | filemap_fdatawait(inode->i_mapping); |
719 | |||
720 | return nfserrno(err); | ||
730 | } | 721 | } |
731 | 722 | ||
732 | 723 | ||
733 | static void | 724 | static int |
734 | nfsd_sync(struct file *filp) | 725 | nfsd_sync(struct file *filp) |
735 | { | 726 | { |
727 | int err; | ||
736 | struct inode *inode = filp->f_dentry->d_inode; | 728 | struct inode *inode = filp->f_dentry->d_inode; |
737 | dprintk("nfsd: sync file %s\n", filp->f_dentry->d_name.name); | 729 | dprintk("nfsd: sync file %s\n", filp->f_dentry->d_name.name); |
738 | down(&inode->i_sem); | 730 | mutex_lock(&inode->i_mutex); |
739 | nfsd_dosync(filp, filp->f_dentry, filp->f_op); | 731 | err=nfsd_dosync(filp, filp->f_dentry, filp->f_op); |
740 | up(&inode->i_sem); | 732 | mutex_unlock(&inode->i_mutex); |
733 | |||
734 | return err; | ||
741 | } | 735 | } |
742 | 736 | ||
743 | void | 737 | void |
@@ -874,6 +868,16 @@ out: | |||
874 | return err; | 868 | return err; |
875 | } | 869 | } |
876 | 870 | ||
871 | static void kill_suid(struct dentry *dentry) | ||
872 | { | ||
873 | struct iattr ia; | ||
874 | ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID; | ||
875 | |||
876 | mutex_lock(&dentry->d_inode->i_mutex); | ||
877 | notify_change(dentry, &ia); | ||
878 | mutex_unlock(&dentry->d_inode->i_mutex); | ||
879 | } | ||
880 | |||
877 | static inline int | 881 | static inline int |
878 | nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, | 882 | nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, |
879 | loff_t offset, struct kvec *vec, int vlen, | 883 | loff_t offset, struct kvec *vec, int vlen, |
@@ -927,14 +931,8 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, | |||
927 | } | 931 | } |
928 | 932 | ||
929 | /* clear setuid/setgid flag after write */ | 933 | /* clear setuid/setgid flag after write */ |
930 | if (err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID))) { | 934 | if (err >= 0 && (inode->i_mode & (S_ISUID | S_ISGID))) |
931 | struct iattr ia; | 935 | kill_suid(dentry); |
932 | ia.ia_valid = ATTR_KILL_SUID | ATTR_KILL_SGID; | ||
933 | |||
934 | down(&inode->i_sem); | ||
935 | notify_change(dentry, &ia); | ||
936 | up(&inode->i_sem); | ||
937 | } | ||
938 | 936 | ||
939 | if (err >= 0 && stable) { | 937 | if (err >= 0 && stable) { |
940 | static ino_t last_ino; | 938 | static ino_t last_ino; |
@@ -962,7 +960,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, | |||
962 | 960 | ||
963 | if (inode->i_state & I_DIRTY) { | 961 | if (inode->i_state & I_DIRTY) { |
964 | dprintk("nfsd: write sync %d\n", current->pid); | 962 | dprintk("nfsd: write sync %d\n", current->pid); |
965 | nfsd_sync(file); | 963 | err=nfsd_sync(file); |
966 | } | 964 | } |
967 | #if 0 | 965 | #if 0 |
968 | wake_up(&inode->i_wait); | 966 | wake_up(&inode->i_wait); |
@@ -1066,7 +1064,7 @@ nfsd_commit(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1066 | return err; | 1064 | return err; |
1067 | if (EX_ISSYNC(fhp->fh_export)) { | 1065 | if (EX_ISSYNC(fhp->fh_export)) { |
1068 | if (file->f_op && file->f_op->fsync) { | 1066 | if (file->f_op && file->f_op->fsync) { |
1069 | nfsd_sync(file); | 1067 | err = nfsd_sync(file); |
1070 | } else { | 1068 | } else { |
1071 | err = nfserr_notsupp; | 1069 | err = nfserr_notsupp; |
1072 | } | 1070 | } |
@@ -1874,39 +1872,25 @@ nfsd_get_posix_acl(struct svc_fh *fhp, int type) | |||
1874 | ssize_t size; | 1872 | ssize_t size; |
1875 | struct posix_acl *acl; | 1873 | struct posix_acl *acl; |
1876 | 1874 | ||
1877 | if (!IS_POSIXACL(inode) || !inode->i_op || !inode->i_op->getxattr) | 1875 | if (!IS_POSIXACL(inode)) |
1876 | return ERR_PTR(-EOPNOTSUPP); | ||
1877 | |||
1878 | switch (type) { | ||
1879 | case ACL_TYPE_ACCESS: | ||
1880 | name = POSIX_ACL_XATTR_ACCESS; | ||
1881 | break; | ||
1882 | case ACL_TYPE_DEFAULT: | ||
1883 | name = POSIX_ACL_XATTR_DEFAULT; | ||
1884 | break; | ||
1885 | default: | ||
1878 | return ERR_PTR(-EOPNOTSUPP); | 1886 | return ERR_PTR(-EOPNOTSUPP); |
1879 | switch(type) { | ||
1880 | case ACL_TYPE_ACCESS: | ||
1881 | name = POSIX_ACL_XATTR_ACCESS; | ||
1882 | break; | ||
1883 | case ACL_TYPE_DEFAULT: | ||
1884 | name = POSIX_ACL_XATTR_DEFAULT; | ||
1885 | break; | ||
1886 | default: | ||
1887 | return ERR_PTR(-EOPNOTSUPP); | ||
1888 | } | 1887 | } |
1889 | 1888 | ||
1890 | size = inode->i_op->getxattr(fhp->fh_dentry, name, NULL, 0); | 1889 | size = nfsd_getxattr(fhp->fh_dentry, name, &value); |
1890 | if (size < 0) | ||
1891 | return ERR_PTR(size); | ||
1891 | 1892 | ||
1892 | if (size < 0) { | ||
1893 | acl = ERR_PTR(size); | ||
1894 | goto getout; | ||
1895 | } else if (size > 0) { | ||
1896 | value = kmalloc(size, GFP_KERNEL); | ||
1897 | if (!value) { | ||
1898 | acl = ERR_PTR(-ENOMEM); | ||
1899 | goto getout; | ||
1900 | } | ||
1901 | size = inode->i_op->getxattr(fhp->fh_dentry, name, value, size); | ||
1902 | if (size < 0) { | ||
1903 | acl = ERR_PTR(size); | ||
1904 | goto getout; | ||
1905 | } | ||
1906 | } | ||
1907 | acl = posix_acl_from_xattr(value, size); | 1893 | acl = posix_acl_from_xattr(value, size); |
1908 | |||
1909 | getout: | ||
1910 | kfree(value); | 1894 | kfree(value); |
1911 | return acl; | 1895 | return acl; |
1912 | } | 1896 | } |
@@ -1947,16 +1931,13 @@ nfsd_set_posix_acl(struct svc_fh *fhp, int type, struct posix_acl *acl) | |||
1947 | } else | 1931 | } else |
1948 | size = 0; | 1932 | size = 0; |
1949 | 1933 | ||
1950 | if (!fhp->fh_locked) | ||
1951 | fh_lock(fhp); /* unlocking is done automatically */ | ||
1952 | if (size) | 1934 | if (size) |
1953 | error = inode->i_op->setxattr(fhp->fh_dentry, name, | 1935 | error = vfs_setxattr(fhp->fh_dentry, name, value, size, 0); |
1954 | value, size, 0); | ||
1955 | else { | 1936 | else { |
1956 | if (!S_ISDIR(inode->i_mode) && type == ACL_TYPE_DEFAULT) | 1937 | if (!S_ISDIR(inode->i_mode) && type == ACL_TYPE_DEFAULT) |
1957 | error = 0; | 1938 | error = 0; |
1958 | else { | 1939 | else { |
1959 | error = inode->i_op->removexattr(fhp->fh_dentry, name); | 1940 | error = vfs_removexattr(fhp->fh_dentry, name); |
1960 | if (error == -ENODATA) | 1941 | if (error == -ENODATA) |
1961 | error = 0; | 1942 | error = 0; |
1962 | } | 1943 | } |