X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=fs%2Fxfs%2Fxfs_dfrag.c;h=b847e6a7a3f03ba3a5e0f8e200414e97347e0609;hb=1714f9bfc92d6ee67e84127332a1fae27772acfe;hp=4968a6358e613acb627cc4e4e57aad45342a2367;hpb=95d465fd750897ab32462a6702fbfe1b122cbbc0;p=powerpc.git diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c index 4968a6358e..b847e6a7a3 100644 --- a/fs/xfs/xfs_dfrag.c +++ b/fs/xfs/xfs_dfrag.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. + * Copyright (c) 2000-2006 Silicon Graphics, Inc. * All Rights Reserved. * * This program is free software; you can redistribute it and/or @@ -24,14 +24,12 @@ #include "xfs_trans.h" #include "xfs_sb.h" #include "xfs_ag.h" -#include "xfs_dir.h" #include "xfs_dir2.h" #include "xfs_dmapi.h" #include "xfs_mount.h" #include "xfs_bmap_btree.h" #include "xfs_alloc_btree.h" #include "xfs_ialloc_btree.h" -#include "xfs_dir_sf.h" #include "xfs_dir2_sf.h" #include "xfs_attr_sf.h" #include "xfs_dinode.h" @@ -43,7 +41,6 @@ #include "xfs_itable.h" #include "xfs_dfrag.h" #include "xfs_error.h" -#include "xfs_mac.h" #include "xfs_rw.h" /* @@ -54,24 +51,14 @@ xfs_swapext( xfs_swapext_t __user *sxu) { xfs_swapext_t *sxp; - xfs_inode_t *ip=NULL, *tip=NULL, *ips[2]; - xfs_trans_t *tp; + xfs_inode_t *ip=NULL, *tip=NULL; xfs_mount_t *mp; - xfs_bstat_t *sbp; struct file *fp = NULL, *tfp = NULL; - vnode_t *vp, *tvp; - static uint lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL; - int ilf_fields, tilf_fields; + bhv_vnode_t *vp, *tvp; int error = 0; - xfs_ifork_t *tempifp, *ifp, *tifp; - __uint64_t tmp; - int aforkblks = 0; - int taforkblks = 0; - char locked = 0; sxp = kmem_alloc(sizeof(xfs_swapext_t), KM_MAYFAIL); - tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL); - if (!sxp || !tempifp) { + if (!sxp) { error = XFS_ERROR(ENOMEM); goto error0; } @@ -83,7 +70,7 @@ xfs_swapext( /* Pull information for the target fd */ if (((fp = fget((int)sxp->sx_fdtarget)) == NULL) || - ((vp = vn_from_inode(fp->f_dentry->d_inode)) == NULL)) { + ((vp = vn_from_inode(fp->f_path.dentry->d_inode)) == NULL)) { error = XFS_ERROR(EINVAL); goto error0; } @@ -95,7 +82,7 @@ xfs_swapext( } if (((tfp = fget((int)sxp->sx_fdtmp)) == NULL) || - ((tvp = vn_from_inode(tfp->f_dentry->d_inode)) == NULL)) { + ((tvp = vn_from_inode(tfp->f_path.dentry->d_inode)) == NULL)) { error = XFS_ERROR(EINVAL); goto error0; } @@ -118,14 +105,56 @@ xfs_swapext( mp = ip->i_mount; - sbp = &sxp->sx_stat; - if (XFS_FORCED_SHUTDOWN(mp)) { error = XFS_ERROR(EIO); goto error0; } - locked = 1; + error = XFS_SWAP_EXTENTS(mp, &ip->i_iocore, &tip->i_iocore, sxp); + + error0: + if (fp != NULL) + fput(fp); + if (tfp != NULL) + fput(tfp); + + if (sxp != NULL) + kmem_free(sxp, sizeof(xfs_swapext_t)); + + return error; +} + +int +xfs_swap_extents( + xfs_inode_t *ip, + xfs_inode_t *tip, + xfs_swapext_t *sxp) +{ + xfs_mount_t *mp; + xfs_inode_t *ips[2]; + xfs_trans_t *tp; + xfs_bstat_t *sbp = &sxp->sx_stat; + bhv_vnode_t *vp, *tvp; + xfs_ifork_t *tempifp, *ifp, *tifp; + int ilf_fields, tilf_fields; + static uint lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL; + int error = 0; + int aforkblks = 0; + int taforkblks = 0; + __uint64_t tmp; + char locked = 0; + + mp = ip->i_mount; + + tempifp = kmem_alloc(sizeof(xfs_ifork_t), KM_MAYFAIL); + if (!tempifp) { + error = XFS_ERROR(ENOMEM); + goto error0; + } + + sbp = &sxp->sx_stat; + vp = XFS_ITOV(ip); + tvp = XFS_ITOV(tip); /* Lock in i_ino order */ if (ip->i_ino < tip->i_ino) { @@ -137,6 +166,7 @@ xfs_swapext( } xfs_lock_inodes(ips, 2, 0, lock_flags); + locked = 1; /* Check permissions */ error = xfs_iaccess(ip, S_IWUSR, NULL); @@ -169,7 +199,7 @@ xfs_swapext( if (VN_CACHED(tvp) != 0) { xfs_inval_cached_trace(&tip->i_iocore, 0, -1, 0, -1); - VOP_FLUSHINVAL_PAGES(tvp, 0, -1, FI_REMAPF_LOCKED); + bhv_vop_flushinval_pages(tvp, 0, -1, FI_REMAPF_LOCKED); } /* Verify O_DIRECT for ftmp */ @@ -214,7 +244,7 @@ xfs_swapext( /* We need to fail if the file is memory mapped. Once we have tossed * all existing pages, the page fault will have no option * but to go to the filesystem for pages. By making the page fault call - * VOP_READ (or write in the case of autogrow) they block on the iolock + * vop_read (or write in the case of autogrow) they block on the iolock * until we have switched the extents. */ if (VN_MAPPED(vp)) { @@ -233,7 +263,7 @@ xfs_swapext( * fields change. */ - VOP_TOSS_PAGES(vp, 0, -1, FI_REMAPF); + bhv_vop_toss_pages(vp, 0, -1, FI_REMAPF); tp = xfs_trans_alloc(mp, XFS_TRANS_SWAPEXT); if ((error = xfs_trans_reserve(tp, 0, @@ -360,16 +390,7 @@ xfs_swapext( xfs_iunlock(ip, lock_flags); xfs_iunlock(tip, lock_flags); } - - if (fp != NULL) - fput(fp); - if (tfp != NULL) - fput(tfp); - - if (sxp != NULL) - kmem_free(sxp, sizeof(xfs_swapext_t)); if (tempifp != NULL) kmem_free(tempifp, sizeof(xfs_ifork_t)); - return error; }