]> git.hungrycats.org Git - linux/commitdiff
[XFS] Change DMAPI dm_punch_hole to punch holes, rather than just
authorDean Roehrich <roehrich@sgi.com>
Sat, 28 Aug 2004 01:45:09 +0000 (11:45 +1000)
committerNathan Scott <nathans@lips.borg.umn.edu>
Sat, 28 Aug 2004 01:45:09 +0000 (11:45 +1000)
truncate files.

SGI Modid: xfs-linux:xfs-kern:177585a
Signed-off-by: Nathan Scott <nathans@sgi.com>
fs/xfs/xfs_vnodeops.c

index b7ecbce3e8b9905842b4d1b95958416d62d79dde..69c7fdcd38ec2d077a043ea3ef175d153975fff2 100644 (file)
@@ -283,7 +283,7 @@ xfs_getattr(
 /*
  * xfs_setattr
  */
-STATIC int
+int
 xfs_setattr(
        bhv_desc_t              *bdp,
        vattr_t                 *vap,
@@ -305,6 +305,7 @@ xfs_setattr(
        int                     mandlock_before, mandlock_after;
        struct xfs_dquot        *udqp, *gdqp, *olddquot1, *olddquot2;
        int                     file_owner;
+       int                     need_iolock = (flags & ATTR_DMI) == 0;
 
        vp = BHV_TO_VNODE(bdp);
        vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
@@ -406,7 +407,8 @@ xfs_setattr(
                                goto error_return;
                        }
                }
-               lock_flags |= XFS_IOLOCK_EXCL;
+               if (need_iolock)
+                       lock_flags |= XFS_IOLOCK_EXCL;
        }
 
        xfs_ilock(ip, lock_flags);
@@ -678,7 +680,8 @@ xfs_setattr(
                                             XFS_TRANS_PERM_LOG_RES,
                                             XFS_ITRUNCATE_LOG_COUNT))) {
                        xfs_trans_cancel(tp, 0);
-                       xfs_iunlock(ip, XFS_IOLOCK_EXCL);
+                       if (need_iolock)
+                               xfs_iunlock(ip, XFS_IOLOCK_EXCL);
                        return code;
                }
                commit_flags = XFS_TRANS_RELEASE_LOG_RES;
@@ -4297,6 +4300,7 @@ xfs_free_file_space(
        int                     rt;
        xfs_fileoff_t           startoffset_fsb;
        xfs_trans_t             *tp;
+       int                     need_iolock = (attr_flags & ATTR_DMI) == 0;
 
        vn_trace_entry(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
        mp = ip->i_mount;
@@ -4324,7 +4328,8 @@ xfs_free_file_space(
                        return(error);
        }
 
-       xfs_ilock(ip, XFS_IOLOCK_EXCL);
+       if (need_iolock)
+               xfs_ilock(ip, XFS_IOLOCK_EXCL);
        rounding = MAX((__uint8_t)(1 << mp->m_sb.sb_blocklog),
                        (__uint8_t)NBPP);
        ilen = len + (offset & (rounding - 1));
@@ -4342,10 +4347,8 @@ xfs_free_file_space(
                nimap = 1;
                error = xfs_bmapi(NULL, ip, startoffset_fsb, 1, 0, NULL, 0,
                        &imap, &nimap, NULL);
-               if (error) {
-                       xfs_iunlock(ip, XFS_IOLOCK_EXCL);
-                       return error;
-               }
+               if (error)
+                       goto out_unlock_iolock;
                ASSERT(nimap == 0 || nimap == 1);
                if (nimap && imap.br_startblock != HOLESTARTBLOCK) {
                        xfs_daddr_t     block;
@@ -4359,10 +4362,8 @@ xfs_free_file_space(
                nimap = 1;
                error = xfs_bmapi(NULL, ip, endoffset_fsb - 1, 1, 0, NULL, 0,
                        &imap, &nimap, NULL);
-               if (error) {
-                       xfs_iunlock(ip, XFS_IOLOCK_EXCL);
-                       return error;
-               }
+               if (error)
+                       goto out_unlock_iolock;
                ASSERT(nimap == 0 || nimap == 1);
                if (nimap && imap.br_startblock != HOLESTARTBLOCK) {
                        ASSERT(imap.br_startblock != DELAYSTARTBLOCK);
@@ -4451,14 +4452,17 @@ xfs_free_file_space(
                xfs_iunlock(ip, XFS_ILOCK_EXCL);
        }
 
-       xfs_iunlock(ip, XFS_IOLOCK_EXCL);
+ out_unlock_iolock:
+       if (need_iolock)
+               xfs_iunlock(ip, XFS_IOLOCK_EXCL);
        return error;
 
  error0:
        xfs_bmap_cancel(&free_list);
  error1:
        xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT);
-       xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
+       xfs_iunlock(ip, need_iolock ? (XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL) :
+                   XFS_ILOCK_EXCL);
        return error;
 }
 
@@ -4615,20 +4619,21 @@ xfs_change_file_space(
        xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
        xfs_trans_ihold(tp, ip);
 
-       ip->i_d.di_mode &= ~S_ISUID;
-
-       /*
-        * Note that we don't have to worry about mandatory
-        * file locking being disabled here because we only
-        * clear the S_ISGID bit if the Group execute bit is
-        * on, but if it was on then mandatory locking wouldn't
-        * have been enabled.
-        */
-       if (ip->i_d.di_mode & S_IXGRP)
-               ip->i_d.di_mode &= ~S_ISGID;
+       if ((attr_flags & ATTR_DMI) == 0) {
+               ip->i_d.di_mode &= ~S_ISUID;
 
-       xfs_ichgtime(ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
+               /*
+                * Note that we don't have to worry about mandatory
+                * file locking being disabled here because we only
+                * clear the S_ISGID bit if the Group execute bit is
+                * on, but if it was on then mandatory locking wouldn't
+                * have been enabled.
+                */
+               if (ip->i_d.di_mode & S_IXGRP)
+                       ip->i_d.di_mode &= ~S_ISGID;
 
+               xfs_ichgtime(ip, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
+       }
        if (setprealloc)
                ip->i_d.di_flags |= XFS_DIFLAG_PREALLOC;
        else if (clrprealloc)