diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-03-05 21:44:35 -0500 |
---|---|---|
committer | Lachlan McIlroy <lachlan@redback.melbourne.sgi.com> | 2008-04-17 21:38:53 -0400 |
commit | db0bb7baa1533db156d8af3ebeda1f0473a0197a (patch) | |
tree | 39247febd2c597ad58f754b0fd3ce35cd2c4e796 /fs/xfs/linux-2.6/xfs_iops.c | |
parent | 155cc6b784a959ed456fe46dca522e1d28b3b718 (diff) |
[XFS] cleanup xfs_vn_mknod
- use proper goto based unwinding instead of the current mess of
multiple conditionals
- rename ip to inode because that's the normal convention for Linux
inodes while ip is the convention for xfs_inodes
- remove unlikely checks for the default_acl - branches marked unlikely
might lead to extreme branch bredictor slowdons if taken and for some
workloads a default acl is quite common
- properly indent the switch statements
- remove xfs_has_fs_struct as nfsd has a fs_struct in any semi-recent
kernel
SGI-PV: 976035
SGI-Modid: xfs-linux-melb:xfs-kern:30529a
Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs/xfs/linux-2.6/xfs_iops.c')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_iops.c | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c index cc4abd3daa49..346701183318 100644 --- a/fs/xfs/linux-2.6/xfs_iops.c +++ b/fs/xfs/linux-2.6/xfs_iops.c | |||
@@ -241,18 +241,6 @@ xfs_init_security( | |||
241 | return error; | 241 | return error; |
242 | } | 242 | } |
243 | 243 | ||
244 | /* | ||
245 | * Determine whether a process has a valid fs_struct (kernel daemons | ||
246 | * like knfsd don't have an fs_struct). | ||
247 | * | ||
248 | * XXX(hch): nfsd is broken, better fix it instead. | ||
249 | */ | ||
250 | STATIC_INLINE int | ||
251 | xfs_has_fs_struct(struct task_struct *task) | ||
252 | { | ||
253 | return (task->fs != init_task.fs); | ||
254 | } | ||
255 | |||
256 | STATIC void | 244 | STATIC void |
257 | xfs_cleanup_inode( | 245 | xfs_cleanup_inode( |
258 | struct inode *dir, | 246 | struct inode *dir, |
@@ -284,7 +272,7 @@ xfs_vn_mknod( | |||
284 | int mode, | 272 | int mode, |
285 | dev_t rdev) | 273 | dev_t rdev) |
286 | { | 274 | { |
287 | struct inode *ip; | 275 | struct inode *inode; |
288 | bhv_vnode_t *vp = NULL, *dvp = vn_from_inode(dir); | 276 | bhv_vnode_t *vp = NULL, *dvp = vn_from_inode(dir); |
289 | xfs_acl_t *default_acl = NULL; | 277 | xfs_acl_t *default_acl = NULL; |
290 | attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS; | 278 | attrexists_t test_default_acl = _ACL_DEFAULT_EXISTS; |
@@ -297,7 +285,7 @@ xfs_vn_mknod( | |||
297 | if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)) | 285 | if (unlikely(!sysv_valid_dev(rdev) || MAJOR(rdev) & ~0x1ff)) |
298 | return -EINVAL; | 286 | return -EINVAL; |
299 | 287 | ||
300 | if (unlikely(test_default_acl && test_default_acl(dvp))) { | 288 | if (test_default_acl && test_default_acl(dvp)) { |
301 | if (!_ACL_ALLOC(default_acl)) { | 289 | if (!_ACL_ALLOC(default_acl)) { |
302 | return -ENOMEM; | 290 | return -ENOMEM; |
303 | } | 291 | } |
@@ -307,11 +295,14 @@ xfs_vn_mknod( | |||
307 | } | 295 | } |
308 | } | 296 | } |
309 | 297 | ||
310 | if (IS_POSIXACL(dir) && !default_acl && xfs_has_fs_struct(current)) | 298 | if (IS_POSIXACL(dir) && !default_acl) |
311 | mode &= ~current->fs->umask; | 299 | mode &= ~current->fs->umask; |
312 | 300 | ||
313 | switch (mode & S_IFMT) { | 301 | switch (mode & S_IFMT) { |
314 | case S_IFCHR: case S_IFBLK: case S_IFIFO: case S_IFSOCK: | 302 | case S_IFCHR: |
303 | case S_IFBLK: | ||
304 | case S_IFIFO: | ||
305 | case S_IFSOCK: | ||
315 | rdev = sysv_encode_dev(rdev); | 306 | rdev = sysv_encode_dev(rdev); |
316 | case S_IFREG: | 307 | case S_IFREG: |
317 | error = xfs_create(XFS_I(dir), dentry, mode, rdev, &vp, NULL); | 308 | error = xfs_create(XFS_I(dir), dentry, mode, rdev, &vp, NULL); |
@@ -324,32 +315,34 @@ xfs_vn_mknod( | |||
324 | break; | 315 | break; |
325 | } | 316 | } |
326 | 317 | ||
327 | if (unlikely(!error)) { | 318 | if (unlikely(error)) |
328 | error = xfs_init_security(vp, dir); | 319 | goto out_free_acl; |
329 | if (error) | ||
330 | xfs_cleanup_inode(dir, vp, dentry, mode); | ||
331 | } | ||
332 | 320 | ||
333 | if (unlikely(default_acl)) { | 321 | error = xfs_init_security(vp, dir); |
334 | if (!error) { | 322 | if (unlikely(error)) |
335 | error = _ACL_INHERIT(vp, mode, default_acl); | 323 | goto out_cleanup_inode; |
336 | if (!error) | 324 | |
337 | xfs_iflags_set(XFS_I(vp), XFS_IMODIFIED); | 325 | if (default_acl) { |
338 | else | 326 | error = _ACL_INHERIT(vp, mode, default_acl); |
339 | xfs_cleanup_inode(dir, vp, dentry, mode); | 327 | if (unlikely(error)) |
340 | } | 328 | goto out_cleanup_inode; |
329 | xfs_iflags_set(XFS_I(vp), XFS_IMODIFIED); | ||
341 | _ACL_FREE(default_acl); | 330 | _ACL_FREE(default_acl); |
342 | } | 331 | } |
343 | 332 | ||
344 | if (likely(!error)) { | 333 | inode = vn_to_inode(vp); |
345 | ASSERT(vp); | ||
346 | ip = vn_to_inode(vp); | ||
347 | 334 | ||
348 | if (S_ISDIR(mode)) | 335 | if (S_ISDIR(mode)) |
349 | xfs_validate_fields(ip); | 336 | xfs_validate_fields(inode); |
350 | d_instantiate(dentry, ip); | 337 | d_instantiate(dentry, inode); |
351 | xfs_validate_fields(dir); | 338 | xfs_validate_fields(dir); |
352 | } | 339 | return -error; |
340 | |||
341 | out_cleanup_inode: | ||
342 | xfs_cleanup_inode(dir, vp, dentry, mode); | ||
343 | out_free_acl: | ||
344 | if (default_acl) | ||
345 | _ACL_FREE(default_acl); | ||
353 | return -error; | 346 | return -error; |
354 | } | 347 | } |
355 | 348 | ||