[XFS] Cleanup various fid related bits:

- merge xfs_fid2 into it's only caller xfs_dm_inode_to_fh.
- remove xfs_vget and opencode it in the two callers, simplifying
both of them by avoiding the awkward calling convetion.
- assign directly to the dm_fid_t members in various places in the
dmapi code instead of casting them to xfs_fid_t first (which
is identical to dm_fid_t)

SGI-PV: 974747
SGI-Modid: xfs-linux-melb:xfs-kern:30258a

Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Vlad Apostolov <vapo@sgi.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>

authored by

Christoph Hellwig and committed by
Lachlan McIlroy
f71354bc edd319dc

+17 -84
+17 -8
fs/xfs/linux-2.6/xfs_export.c
··· 118 u64 ino, 119 u32 generation) 120 { 121 - xfs_fid_t xfid; 122 - bhv_vnode_t *vp; 123 int error; 124 125 - xfid.fid_len = sizeof(xfs_fid_t) - sizeof(xfid.fid_len); 126 - xfid.fid_pad = 0; 127 - xfid.fid_ino = ino; 128 - xfid.fid_gen = generation; 129 130 - error = xfs_vget(XFS_M(sb), &vp, &xfid); 131 if (error) 132 return ERR_PTR(-error); 133 134 - return vp ? vn_to_inode(vp) : NULL; 135 } 136 137 STATIC struct dentry *
··· 118 u64 ino, 119 u32 generation) 120 { 121 + xfs_mount_t *mp = XFS_M(sb); 122 + xfs_inode_t *ip; 123 int error; 124 125 + /* 126 + * NFS can sometimes send requests for ino 0. Fail them gracefully. 127 + */ 128 + if (ino == 0) 129 + return ERR_PTR(-ESTALE); 130 131 + error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0); 132 if (error) 133 return ERR_PTR(-error); 134 + if (!ip) 135 + return ERR_PTR(-EIO); 136 137 + if (!ip->i_d.di_mode || ip->i_d.di_gen != generation) { 138 + xfs_iput_new(ip, XFS_ILOCK_SHARED); 139 + return ERR_PTR(-ENOENT); 140 + } 141 + 142 + xfs_iunlock(ip, XFS_ILOCK_SHARED); 143 + return ip->i_vnode; 144 } 145 146 STATIC struct dentry *
-53
fs/xfs/xfs_vfsops.c
··· 1408 1409 return XFS_ERROR(last_error); 1410 } 1411 - 1412 - /* 1413 - * xfs_vget - called by DMAPI and NFSD to get vnode from file handle 1414 - */ 1415 - int 1416 - xfs_vget( 1417 - xfs_mount_t *mp, 1418 - bhv_vnode_t **vpp, 1419 - xfs_fid_t *xfid) 1420 - { 1421 - xfs_inode_t *ip; 1422 - int error; 1423 - xfs_ino_t ino; 1424 - unsigned int igen; 1425 - 1426 - /* 1427 - * Invalid. Since handles can be created in user space and passed in 1428 - * via gethandle(), this is not cause for a panic. 1429 - */ 1430 - if (xfid->fid_len != sizeof(*xfid) - sizeof(xfid->fid_len)) 1431 - return XFS_ERROR(EINVAL); 1432 - 1433 - ino = xfid->fid_ino; 1434 - igen = xfid->fid_gen; 1435 - 1436 - /* 1437 - * NFS can sometimes send requests for ino 0. Fail them gracefully. 1438 - */ 1439 - if (ino == 0) 1440 - return XFS_ERROR(ESTALE); 1441 - 1442 - error = xfs_iget(mp, NULL, ino, 0, XFS_ILOCK_SHARED, &ip, 0); 1443 - if (error) { 1444 - *vpp = NULL; 1445 - return error; 1446 - } 1447 - 1448 - if (ip == NULL) { 1449 - *vpp = NULL; 1450 - return XFS_ERROR(EIO); 1451 - } 1452 - 1453 - if (ip->i_d.di_mode == 0 || ip->i_d.di_gen != igen) { 1454 - xfs_iput_new(ip, XFS_ILOCK_SHARED); 1455 - *vpp = NULL; 1456 - return XFS_ERROR(ENOENT); 1457 - } 1458 - 1459 - *vpp = XFS_ITOV(ip); 1460 - xfs_iunlock(ip, XFS_ILOCK_SHARED); 1461 - return 0; 1462 - } 1463 -
··· 1408 1409 return XFS_ERROR(last_error); 1410 }
-1
fs/xfs/xfs_vfsops.h
··· 15 struct xfs_mount_args *args); 16 int xfs_root(struct xfs_mount *mp, bhv_vnode_t **vpp); 17 int xfs_sync(struct xfs_mount *mp, int flags); 18 - int xfs_vget(struct xfs_mount *mp, bhv_vnode_t **vpp, struct xfs_fid *xfid); 19 void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname, 20 int lnnum); 21 void xfs_attr_quiesce(struct xfs_mount *mp);
··· 15 struct xfs_mount_args *args); 16 int xfs_root(struct xfs_mount *mp, bhv_vnode_t **vpp); 17 int xfs_sync(struct xfs_mount *mp, int flags); 18 void xfs_do_force_shutdown(struct xfs_mount *mp, int flags, char *fname, 19 int lnnum); 20 void xfs_attr_quiesce(struct xfs_mount *mp);
-21
fs/xfs/xfs_vnodeops.c
··· 3457 goto std_return; 3458 } 3459 3460 - 3461 - int 3462 - xfs_fid2( 3463 - xfs_inode_t *ip, 3464 - xfs_fid_t *xfid) 3465 - { 3466 - xfs_itrace_entry(ip); 3467 - 3468 - xfid->fid_len = sizeof(xfs_fid_t) - sizeof(xfid->fid_len); 3469 - xfid->fid_pad = 0; 3470 - /* 3471 - * use memcpy because the inode is a long long and there's no 3472 - * assurance that xfid->fid_ino is properly aligned. 3473 - */ 3474 - memcpy(&xfid->fid_ino, &ip->i_ino, sizeof(xfid->fid_ino)); 3475 - xfid->fid_gen = ip->i_d.di_gen; 3476 - 3477 - return 0; 3478 - } 3479 - 3480 - 3481 int 3482 xfs_rwlock( 3483 xfs_inode_t *ip,
··· 3457 goto std_return; 3458 } 3459 3460 int 3461 xfs_rwlock( 3462 xfs_inode_t *ip,
-1
fs/xfs/xfs_vnodeops.h
··· 39 int xfs_symlink(struct xfs_inode *dp, bhv_vname_t *dentry, 40 char *target_path, mode_t mode, bhv_vnode_t **vpp, 41 struct cred *credp); 42 - int xfs_fid2(struct xfs_inode *ip, struct xfs_fid *xfid); 43 int xfs_rwlock(struct xfs_inode *ip, bhv_vrwlock_t locktype); 44 void xfs_rwunlock(struct xfs_inode *ip, bhv_vrwlock_t locktype); 45 int xfs_inode_flush(struct xfs_inode *ip, int flags);
··· 39 int xfs_symlink(struct xfs_inode *dp, bhv_vname_t *dentry, 40 char *target_path, mode_t mode, bhv_vnode_t **vpp, 41 struct cred *credp); 42 int xfs_rwlock(struct xfs_inode *ip, bhv_vrwlock_t locktype); 43 void xfs_rwunlock(struct xfs_inode *ip, bhv_vrwlock_t locktype); 44 int xfs_inode_flush(struct xfs_inode *ip, int flags);