xfs
[Top] [All Lists]

Fix to xfs_dfrag.c to insure fput done on all error exists

To: linux-xfs@xxxxxxxxxxx
Subject: Fix to xfs_dfrag.c to insure fput done on all error exists
From: William L Jones <jones@xxxxxxxxxxxxxxxxxx>
Date: Fri, 4 Aug 2000 12:32:49 -0500 (CDT)
Sender: owner-linux-xfs-announce@xxxxxxxxxxx


*** xfs_dfrag.c.orig    Thu Aug  3 19:43:01 2000
--- xfs_dfrag.c Fri Aug  4 12:17:56 2000
***************
*** 104,109 ****
--- 104,110 ----
        __uint64_t      cxfs_val;
        int             aforkblks = 0;
        int             locked = 0;
+       int             cell = 0;
  
        if (copyin(sxp, &sx, sizeof sx))
                return XFS_ERROR(EFAULT);
***************
*** 169,176 ****
                  goto error0;
        }
  
-       locked = 1;
        CELL_ONLY(cxfs_val = cfs_start_defrag(vp));
  
        /* Lock in i_ino order */
        if (ip->i_ino < tip->i_ino) {
--- 170,177 ----
                  goto error0;
        }
  
        CELL_ONLY(cxfs_val = cfs_start_defrag(vp));
+       cell = 1;
  
        /* Lock in i_ino order */
        if (ip->i_ino < tip->i_ino) {
***************
*** 182,187 ****
--- 183,189 ----
        }
        lock_flags = XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL;
        xfs_lock_inodes(ips, 2, 0, lock_flags);
+       locked = 1;
  
        /* Check permissions */
          if (error = _MAC_XFS_IACCESS(ip, MACWRITE)) {
***************
*** 291,297 ****
                xfs_iunlock(ip,  XFS_IOLOCK_EXCL);
                xfs_iunlock(tip, XFS_IOLOCK_EXCL);
                xfs_trans_cancel(tp, 0);
!               return error;
        }
        xfs_lock_inodes(ips, 2, 0, XFS_ILOCK_EXCL);
  
--- 293,300 ----
                xfs_iunlock(ip,  XFS_IOLOCK_EXCL);
                xfs_iunlock(tip, XFS_IOLOCK_EXCL);
                xfs_trans_cancel(tp, 0);
!               locked = 0;
!               goto error0;
        }
        xfs_lock_inodes(ips, 2, 0, XFS_ILOCK_EXCL);
  
***************
*** 305,311 ****
                        xfs_iunlock(ip,  lock_flags);
                        xfs_iunlock(tip, lock_flags);
                        xfs_trans_cancel(tp, 0);
!                       return error;
                }
        }
  
--- 308,315 ----
                        xfs_iunlock(ip,  lock_flags);
                        xfs_iunlock(tip, lock_flags);
                        xfs_trans_cancel(tp, 0);
!                       locked = 0;
!                       goto error0;
                }
        }
  
***************
*** 404,412 ****
  
   error0:
        if (locked) {
-               CELL_ONLY(cfs_end_defrag(vp, cxfs_val));
                xfs_iunlock(ip,  lock_flags);
                xfs_iunlock(tip, lock_flags);
        }
  
          if (fp != NULL) fput(fp);
--- 408,418 ----
  
   error0:
        if (locked) {
                xfs_iunlock(ip,  lock_flags);
                xfs_iunlock(tip, lock_flags);
+       }
+       if (cell) {
+               CELL_ONLY(cfs_end_defrag(vp, cxfs_val));
        }
  
          if (fp != NULL) fput(fp);

<Prev in Thread] Current Thread [Next in Thread>
  • Fix to xfs_dfrag.c to insure fput done on all error exists, William L Jones <=