xfs: improve busy extent sorting
authorChristoph Hellwig <hch@lst.de>
Tue, 7 Feb 2017 22:07:57 +0000 (14:07 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Thu, 9 Feb 2017 19:36:39 +0000 (11:36 -0800)
Sort busy extents by the full block number instead of just the AGNO so
that we can issue consecutive discard requests that the block layer could
merge (although we'll need additional block layer fixes for fast devices).

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/xfs_extent_busy.c

index 4d850e27095e835bea789baa043e16dbd3b4c621..ab062610234e072e20ee4530a740713733842d83 100644 (file)
@@ -656,9 +656,17 @@ xfs_extent_busy_wait_all(
 int
 xfs_extent_busy_ag_cmp(
        void                    *priv,
-       struct list_head        *a,
-       struct list_head        *b)
+       struct list_head        *l1,
+       struct list_head        *l2)
 {
-       return container_of(a, struct xfs_extent_busy, list)->agno -
-               container_of(b, struct xfs_extent_busy, list)->agno;
+       struct xfs_extent_busy  *b1 =
+               container_of(l1, struct xfs_extent_busy, list);
+       struct xfs_extent_busy  *b2 =
+               container_of(l2, struct xfs_extent_busy, list);
+       s32 diff;
+
+       diff = b1->agno - b2->agno;
+       if (!diff)
+               diff = b1->bno - b2->bno;
+       return diff;
 }