diff options
author | Miklos Szeredi <mszeredi@suse.cz> | 2008-07-01 09:38:35 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2008-07-01 15:22:03 -0400 |
commit | 07cad1d2a4b0112acd41381d5bc6be82fd71ebac (patch) | |
tree | 736d279de9f0684b4320196478eceabb1700b89d /fs/nfsd/vfs.c | |
parent | 100766f8347c1aeb5a548c5c7aa9012f4a3276f1 (diff) |
nfsd: clean up mnt_want_write calls
Multiple mnt_want_write() calls in the switch statement looks really
ugly.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Acked-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'fs/nfsd/vfs.c')
-rw-r--r-- | fs/nfsd/vfs.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 5e05ddda4560..0f4481e0502d 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c | |||
@@ -1250,36 +1250,34 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1250 | iap->ia_mode = 0; | 1250 | iap->ia_mode = 0; |
1251 | iap->ia_mode = (iap->ia_mode & S_IALLUGO) | type; | 1251 | iap->ia_mode = (iap->ia_mode & S_IALLUGO) | type; |
1252 | 1252 | ||
1253 | err = nfserr_inval; | ||
1254 | if (!S_ISREG(type) && !S_ISDIR(type) && !special_file(type)) { | ||
1255 | printk(KERN_WARNING "nfsd: bad file type %o in nfsd_create\n", | ||
1256 | type); | ||
1257 | goto out; | ||
1258 | } | ||
1259 | |||
1260 | host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); | ||
1261 | if (host_err) | ||
1262 | goto out_nfserr; | ||
1263 | |||
1253 | /* | 1264 | /* |
1254 | * Get the dir op function pointer. | 1265 | * Get the dir op function pointer. |
1255 | */ | 1266 | */ |
1256 | err = 0; | 1267 | err = 0; |
1257 | switch (type) { | 1268 | switch (type) { |
1258 | case S_IFREG: | 1269 | case S_IFREG: |
1259 | host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); | ||
1260 | if (host_err) | ||
1261 | goto out_nfserr; | ||
1262 | host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL); | 1270 | host_err = vfs_create(dirp, dchild, iap->ia_mode, NULL); |
1263 | break; | 1271 | break; |
1264 | case S_IFDIR: | 1272 | case S_IFDIR: |
1265 | host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); | ||
1266 | if (host_err) | ||
1267 | goto out_nfserr; | ||
1268 | host_err = vfs_mkdir(dirp, dchild, iap->ia_mode); | 1273 | host_err = vfs_mkdir(dirp, dchild, iap->ia_mode); |
1269 | break; | 1274 | break; |
1270 | case S_IFCHR: | 1275 | case S_IFCHR: |
1271 | case S_IFBLK: | 1276 | case S_IFBLK: |
1272 | case S_IFIFO: | 1277 | case S_IFIFO: |
1273 | case S_IFSOCK: | 1278 | case S_IFSOCK: |
1274 | host_err = mnt_want_write(fhp->fh_export->ex_path.mnt); | ||
1275 | if (host_err) | ||
1276 | goto out_nfserr; | ||
1277 | host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev); | 1279 | host_err = vfs_mknod(dirp, dchild, iap->ia_mode, rdev); |
1278 | break; | 1280 | break; |
1279 | default: | ||
1280 | printk("nfsd: bad file type %o in nfsd_create\n", type); | ||
1281 | host_err = -EINVAL; | ||
1282 | goto out_nfserr; | ||
1283 | } | 1281 | } |
1284 | if (host_err < 0) { | 1282 | if (host_err < 0) { |
1285 | mnt_drop_write(fhp->fh_export->ex_path.mnt); | 1283 | mnt_drop_write(fhp->fh_export->ex_path.mnt); |
@@ -1291,7 +1289,6 @@ nfsd_create(struct svc_rqst *rqstp, struct svc_fh *fhp, | |||
1291 | write_inode_now(dchild->d_inode, 1); | 1289 | write_inode_now(dchild->d_inode, 1); |
1292 | } | 1290 | } |
1293 | 1291 | ||
1294 | |||
1295 | err2 = nfsd_create_setattr(rqstp, resfhp, iap); | 1292 | err2 = nfsd_create_setattr(rqstp, resfhp, iap); |
1296 | if (err2) | 1293 | if (err2) |
1297 | err = err2; | 1294 | err = err2; |