[XFS] Remove xfs_iflush_all and clean up xfs_finish_reclaim_all()
[pandora-kernel.git] / fs / xfs / xfs_vnodeops.c
index aa238c8..a671457 100644 (file)
@@ -1838,6 +1838,12 @@ again:
 #endif
 }
 
+/*
+ * xfs_lock_two_inodes() can only be used to lock one type of lock
+ * at a time - the iolock or the ilock, but not both at once. If
+ * we lock both at once, lockdep will report false positives saying
+ * we have violated locking orders.
+ */
 void
 xfs_lock_two_inodes(
        xfs_inode_t             *ip0,
@@ -1848,6 +1854,8 @@ xfs_lock_two_inodes(
        int                     attempts = 0;
        xfs_log_item_t          *lp;
 
+       if (lock_mode & (XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL))
+               ASSERT((lock_mode & (XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)) == 0);
        ASSERT(ip0->i_ino != ip1->i_ino);
 
        if (ip0->i_ino > ip1->i_ino) {
@@ -2910,36 +2918,30 @@ xfs_finish_reclaim(
 }
 
 int
-xfs_finish_reclaim_all(xfs_mount_t *mp, int noblock)
+xfs_finish_reclaim_all(
+       xfs_mount_t     *mp,
+       int              noblock,
+       int             mode)
 {
-       int             purged;
        xfs_inode_t     *ip, *n;
-       int             done = 0;
 
-       while (!done) {
-               purged = 0;
-               XFS_MOUNT_ILOCK(mp);
-               list_for_each_entry_safe(ip, n, &mp->m_del_inodes, i_reclaim) {
-                       if (noblock) {
-                               if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0)
-                                       continue;
-                               if (xfs_ipincount(ip) ||
-                                   !xfs_iflock_nowait(ip)) {
-                                       xfs_iunlock(ip, XFS_ILOCK_EXCL);
-                                       continue;
-                               }
+restart:
+       XFS_MOUNT_ILOCK(mp);
+       list_for_each_entry_safe(ip, n, &mp->m_del_inodes, i_reclaim) {
+               if (noblock) {
+                       if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0)
+                               continue;
+                       if (xfs_ipincount(ip) ||
+                           !xfs_iflock_nowait(ip)) {
+                               xfs_iunlock(ip, XFS_ILOCK_EXCL);
+                               continue;
                        }
-                       XFS_MOUNT_IUNLOCK(mp);
-                       if (xfs_finish_reclaim(ip, noblock,
-                                       XFS_IFLUSH_DELWRI_ELSE_ASYNC))
-                               delay(1);
-                       purged = 1;
-                       break;
                }
-
-               done = !purged;
+               XFS_MOUNT_IUNLOCK(mp);
+               if (xfs_finish_reclaim(ip, noblock, mode))
+                       delay(1);
+               goto restart;
        }
-
        XFS_MOUNT_IUNLOCK(mp);
        return 0;
 }
@@ -3152,6 +3154,13 @@ error1:  /* Just cancel transaction */
 /*
  * Zero file bytes between startoff and endoff inclusive.
  * The iolock is held exclusive and no blocks are buffered.
+ *
+ * This function is used by xfs_free_file_space() to zero
+ * partial blocks when the range to free is not block aligned.
+ * When unreserving space with boundaries that are not block
+ * aligned we round up the start and round down the end
+ * boundaries and then use this function to zero the parts of
+ * the blocks that got dropped during the rounding.
  */
 STATIC int
 xfs_zero_remaining_bytes(
@@ -3168,6 +3177,17 @@ xfs_zero_remaining_bytes(
        int                     nimap;
        int                     error = 0;
 
+       /*
+        * Avoid doing I/O beyond eof - it's not necessary
+        * since nothing can read beyond eof.  The space will
+        * be zeroed when the file is extended anyway.
+        */
+       if (startoff >= ip->i_size)
+               return 0;
+
+       if (endoff > ip->i_size)
+               endoff = ip->i_size;
+
        bp = xfs_buf_get_noaddr(mp->m_sb.sb_blocksize,
                                XFS_IS_REALTIME_INODE(ip) ?
                                mp->m_rtdev_targp : mp->m_ddev_targp);