X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=fs%2Fxfs%2Fxfs_dfrag.c;h=29a6c866f2c33c30e822785c76d5202766fc0e2b;hb=da2f4d679c8070ba5b6a920281e495917b293aa0;hp=925b0a22c6641021fb05bb94d17481c3682432f0;hpb=a844f4510dce23c07f3923cb42138f5fdd745017;p=safe%2Fjmp%2Flinux-2.6 diff --git a/fs/xfs/xfs_dfrag.c b/fs/xfs/xfs_dfrag.c index 925b0a2..29a6c86 100644 --- a/fs/xfs/xfs_dfrag.c +++ b/fs/xfs/xfs_dfrag.c @@ -1,33 +1,19 @@ /* - * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. + * Copyright (c) 2000-2006 Silicon Graphics, Inc. + * All Rights Reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation. * - * This program is distributed in the hope that it would be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * This program is distributed in the hope that it would be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Further, this software is distributed without any warranty that it is - * free of the rightful claim of any third person regarding infringement - * or the like. Any license provided herein, whether implied or - * otherwise, applies only to this software file. Patent licenses, if - * any, provided herein do not apply to combinations of this program with - * other software, or any other product whatsoever. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write the Free Software Foundation, Inc., 59 - * Temple Place - Suite 330, Boston MA 02111-1307, USA. - * - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, - * Mountain View, CA 94043, or: - * - * http://www.sgi.com - * - * For further information regarding this notice, see: - * - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ + * You should have received a copy of the GNU General Public License + * along with this program; if not, write the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include "xfs.h" #include "xfs_fs.h" @@ -68,26 +54,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; - bhv_desc_t *bdp, *tbdp; - vn_bhv_head_t *bhp, *tbhp; - 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; } @@ -99,33 +73,27 @@ xfs_swapext( /* Pull information for the target fd */ if (((fp = fget((int)sxp->sx_fdtarget)) == NULL) || - ((vp = LINVFS_GET_VP(fp->f_dentry->d_inode)) == NULL)) { + ((vp = vn_from_inode(fp->f_dentry->d_inode)) == NULL)) { error = XFS_ERROR(EINVAL); goto error0; } - bhp = VN_BHV_HEAD(vp); - bdp = vn_bhv_lookup(bhp, &xfs_vnodeops); - if (bdp == NULL) { + ip = xfs_vtoi(vp); + if (ip == NULL) { error = XFS_ERROR(EBADF); goto error0; - } else { - ip = XFS_BHVTOI(bdp); } if (((tfp = fget((int)sxp->sx_fdtmp)) == NULL) || - ((tvp = LINVFS_GET_VP(tfp->f_dentry->d_inode)) == NULL)) { + ((tvp = vn_from_inode(tfp->f_dentry->d_inode)) == NULL)) { error = XFS_ERROR(EINVAL); goto error0; } - tbhp = VN_BHV_HEAD(tvp); - tbdp = vn_bhv_lookup(tbhp, &xfs_vnodeops); - if (tbdp == NULL) { + tip = xfs_vtoi(tvp); + if (tip == NULL) { error = XFS_ERROR(EBADF); goto error0; - } else { - tip = XFS_BHVTOI(tbdp); } if (ip->i_mount != tip->i_mount) { @@ -140,14 +108,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) { @@ -159,6 +169,7 @@ xfs_swapext( } xfs_lock_inodes(ips, 2, 0, lock_flags); + locked = 1; /* Check permissions */ error = xfs_iaccess(ip, S_IWUSR, NULL); @@ -191,7 +202,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 */ @@ -236,7 +247,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)) { @@ -255,7 +266,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, @@ -382,16 +393,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; }