Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Iliopoulos <ailiopoulos@suse.com>2019-03-20 01:12:29 +0100
committerAnthony Iliopoulos <ailiopoulos@suse.com>2019-03-20 01:12:29 +0100
commit76eca08c721340f5650a63303ea59ff900307f68 (patch)
tree7bfa1cff253de950570cade57f7f6dfef3e15ebe
parent9de815a63c4aa747882525d63e0557172bc93f6c (diff)
- xfs: rewrite xfs_dq_get_next_id using xfs_iext_lookup_extent
(bsc#1070995). - Refresh patches.fixes/0059-xfs-introduce-the-xfs_iext_cursor-abstraction.patch.
-rw-r--r--patches.fixes/0059-xfs-introduce-the-xfs_iext_cursor-abstraction.patch418
-rw-r--r--patches.fixes/xfs-rewrite-xfs_dq_get_next_id-using-xfs_iext_lookup.patch153
-rw-r--r--series.conf1
3 files changed, 362 insertions, 210 deletions
diff --git a/patches.fixes/0059-xfs-introduce-the-xfs_iext_cursor-abstraction.patch b/patches.fixes/0059-xfs-introduce-the-xfs_iext_cursor-abstraction.patch
index 2d308db526..48355534ae 100644
--- a/patches.fixes/0059-xfs-introduce-the-xfs_iext_cursor-abstraction.patch
+++ b/patches.fixes/0059-xfs-introduce-the-xfs_iext_cursor-abstraction.patch
@@ -1,4 +1,4 @@
-From 5b402b294bc1568dda78c17166242a54afffcc61 Mon Sep 17 00:00:00 2001
+From b2b1712a640824e7c131bfdd2585d57bf8ccb39a Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Fri, 3 Nov 2017 10:34:43 -0700
Subject: [PATCH 59/77] xfs: introduce the xfs_iext_cursor abstraction
@@ -23,23 +23,22 @@ Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Nikolay Borisov <nborisov@suse.com>
---
- fs/xfs/libxfs/xfs_bmap.c | 441 ++++++++++++++++++++---------------------
- fs/xfs/libxfs/xfs_bmap.h | 12 +-
- fs/xfs/libxfs/xfs_inode_fork.c | 75 +++----
- fs/xfs/libxfs/xfs_inode_fork.h | 87 +++++++-
- fs/xfs/libxfs/xfs_types.h | 3 +
- fs/xfs/xfs_bmap_util.c | 12 +-
- fs/xfs/xfs_dir2_readdir.c | 8 +-
- fs/xfs/xfs_iomap.c | 14 +-
- fs/xfs/xfs_reflink.c | 50 ++---
- fs/xfs/xfs_trace.h | 12 +-
- 10 files changed, 392 insertions(+), 322 deletions(-)
+ fs/xfs/libxfs/xfs_bmap.c | 441 +++++++++++++++++++----------------------
+ fs/xfs/libxfs/xfs_bmap.h | 12 -
+ fs/xfs/libxfs/xfs_inode_fork.c | 75 +++---
+ fs/xfs/libxfs/xfs_inode_fork.h | 87 +++++++-
+ fs/xfs/libxfs/xfs_types.h | 3
+ fs/xfs/xfs_bmap_util.c | 12 -
+ fs/xfs/xfs_dir2_readdir.c | 8
+ fs/xfs/xfs_dquot.c | 4
+ fs/xfs/xfs_iomap.c | 14 -
+ fs/xfs/xfs_reflink.c | 50 ++--
+ fs/xfs/xfs_trace.h | 12 -
+ 11 files changed, 394 insertions(+), 324 deletions(-)
-diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
-index 30b6127b821c..c0e20c6b8815 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
-@@ -684,8 +684,9 @@ xfs_bmap_extents_to_btree(
+@@ -684,8 +684,9 @@
xfs_bmbt_key_t *kp; /* root block key pointer */
xfs_mount_t *mp; /* mount structure */
xfs_bmbt_ptr_t *pp; /* root block address pointer */
@@ -50,7 +49,7 @@ index 30b6127b821c..c0e20c6b8815 100644
mp = ip->i_mount;
ASSERT(whichfork != XFS_COW_FORK);
-@@ -768,7 +769,7 @@ xfs_bmap_extents_to_btree(
+@@ -764,7 +765,7 @@
XFS_BTNUM_BMAP, 0, 0, ip->i_ino,
XFS_BTREE_LONG_PTRS);
@@ -59,7 +58,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (isnullstartblock(rec.br_startblock))
continue;
arp = XFS_BMBT_REC_ADDR(mp, ablock, 1 + cnt);
-@@ -844,6 +845,7 @@ xfs_bmap_local_to_extents(
+@@ -840,6 +841,7 @@
xfs_alloc_arg_t args; /* allocation arguments */
xfs_buf_t *bp; /* buffer for extent block */
struct xfs_bmbt_irec rec;
@@ -67,7 +66,7 @@ index 30b6127b821c..c0e20c6b8815 100644
/*
* We don't want to deal with the case of keeping inode data inline yet.
-@@ -910,7 +912,8 @@ xfs_bmap_local_to_extents(
+@@ -906,7 +908,8 @@
rec.br_startblock = args.fsbno;
rec.br_blockcount = 1;
rec.br_state = XFS_EXT_NORM;
@@ -77,7 +76,7 @@ index 30b6127b821c..c0e20c6b8815 100644
XFS_IFORK_NEXT_SET(ip, whichfork, 1);
ip->i_d.di_nblocks = 1;
-@@ -1190,6 +1193,7 @@ xfs_iread_extents(
+@@ -1186,6 +1189,7 @@
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
xfs_extnum_t nextents = XFS_IFORK_NEXTENTS(ip, whichfork);
struct xfs_btree_block *block = ifp->if_broot;
@@ -85,7 +84,7 @@ index 30b6127b821c..c0e20c6b8815 100644
xfs_fsblock_t bno;
struct xfs_buf *bp;
xfs_extnum_t i, j;
-@@ -1239,6 +1243,7 @@ xfs_iread_extents(
+@@ -1235,6 +1239,7 @@
* Here with bp and block set to the leftmost leaf node in the tree.
*/
i = 0;
@@ -93,7 +92,7 @@ index 30b6127b821c..c0e20c6b8815 100644
/*
* Loop over all leaf nodes. Copy information to the extent records.
-@@ -1280,7 +1285,8 @@ xfs_iread_extents(
+@@ -1276,7 +1281,8 @@
}
trp->l0 = be64_to_cpu(frp->l0);
trp->l1 = be64_to_cpu(frp->l1);
@@ -103,7 +102,7 @@ index 30b6127b821c..c0e20c6b8815 100644
}
xfs_trans_brelse(tp, bp);
bno = nextbno;
-@@ -1328,7 +1334,7 @@ xfs_bmap_first_unused(
+@@ -1324,7 +1330,7 @@
{
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
struct xfs_bmbt_irec got;
@@ -112,7 +111,7 @@ index 30b6127b821c..c0e20c6b8815 100644
xfs_fileoff_t lastaddr = 0;
xfs_fileoff_t lowest, max;
int error;
-@@ -1349,7 +1355,7 @@ xfs_bmap_first_unused(
+@@ -1345,7 +1351,7 @@
}
lowest = max = *first_unused;
@@ -121,7 +120,7 @@ index 30b6127b821c..c0e20c6b8815 100644
/*
* See if the hole before this extent will work.
*/
-@@ -1379,7 +1385,7 @@ xfs_bmap_last_before(
+@@ -1375,7 +1381,7 @@
{
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
struct xfs_bmbt_irec got;
@@ -130,7 +129,7 @@ index 30b6127b821c..c0e20c6b8815 100644
int error;
switch (XFS_IFORK_FORMAT(ip, whichfork)) {
-@@ -1399,7 +1405,7 @@ xfs_bmap_last_before(
+@@ -1395,7 +1401,7 @@
return error;
}
@@ -139,7 +138,7 @@ index 30b6127b821c..c0e20c6b8815 100644
*last_block = 0;
return 0;
}
-@@ -1413,8 +1419,8 @@ xfs_bmap_last_extent(
+@@ -1409,8 +1415,8 @@
int *is_empty)
{
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
@@ -149,7 +148,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
error = xfs_iread_extents(tp, ip, whichfork);
-@@ -1422,14 +1428,11 @@ xfs_bmap_last_extent(
+@@ -1418,14 +1424,11 @@
return error;
}
@@ -168,7 +167,7 @@ index 30b6127b821c..c0e20c6b8815 100644
return 0;
}
-@@ -1517,6 +1520,7 @@ xfs_bmap_one_block(
+@@ -1513,6 +1516,7 @@
xfs_ifork_t *ifp; /* inode fork pointer */
int rval; /* return value */
xfs_bmbt_irec_t s; /* internal version of extent */
@@ -176,7 +175,7 @@ index 30b6127b821c..c0e20c6b8815 100644
#ifndef DEBUG
if (whichfork == XFS_DATA_FORK)
-@@ -1528,7 +1532,8 @@ xfs_bmap_one_block(
+@@ -1524,7 +1528,8 @@
return 0;
ifp = XFS_IFORK_PTR(ip, whichfork);
ASSERT(ifp->if_flags & XFS_IFEXTENTS);
@@ -186,7 +185,7 @@ index 30b6127b821c..c0e20c6b8815 100644
rval = s.br_startoff == 0 && s.br_blockcount == 1;
if (rval && whichfork == XFS_DATA_FORK)
ASSERT(XFS_ISIZE(ip) == ip->i_mount->m_sb.sb_blocksize);
-@@ -1570,8 +1575,6 @@ xfs_bmap_add_extent_delay_real(
+@@ -1566,8 +1571,6 @@
nextents = (whichfork == XFS_COW_FORK ? &bma->ip->i_cnextents :
&bma->ip->i_d.di_nextents);
@@ -195,7 +194,7 @@ index 30b6127b821c..c0e20c6b8815 100644
ASSERT(!isnullstartblock(new->br_startblock));
ASSERT(!bma->cur ||
(bma->cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL));
-@@ -1585,7 +1588,7 @@ xfs_bmap_add_extent_delay_real(
+@@ -1581,7 +1584,7 @@
/*
* Set up a bunch of variables to make the tests simpler.
*/
@@ -204,7 +203,7 @@ index 30b6127b821c..c0e20c6b8815 100644
new_endoff = new->br_startoff + new->br_blockcount;
ASSERT(isnullstartblock(PREV.br_startblock));
ASSERT(PREV.br_startoff <= new->br_startoff);
-@@ -1607,10 +1610,8 @@ xfs_bmap_add_extent_delay_real(
+@@ -1603,10 +1606,8 @@
* Check and set flags if this segment has a left neighbor.
* Don't set contiguous if the combined extent would be too large.
*/
@@ -216,7 +215,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (isnullstartblock(LEFT.br_startblock))
state |= BMAP_LEFT_DELAY;
}
-@@ -1627,10 +1628,8 @@ xfs_bmap_add_extent_delay_real(
+@@ -1623,10 +1624,8 @@
* Don't set contiguous if the combined extent would be too large.
* Also check for all-three-contiguous being too large.
*/
@@ -228,7 +227,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (isnullstartblock(RIGHT.br_startblock))
state |= BMAP_RIGHT_DELAY;
}
-@@ -1662,9 +1661,9 @@ xfs_bmap_add_extent_delay_real(
+@@ -1658,9 +1657,9 @@
*/
LEFT.br_blockcount += PREV.br_blockcount + RIGHT.br_blockcount;
@@ -241,7 +240,7 @@ index 30b6127b821c..c0e20c6b8815 100644
(*nextents)--;
if (bma->cur == NULL)
-@@ -1697,9 +1696,9 @@ xfs_bmap_add_extent_delay_real(
+@@ -1693,9 +1692,9 @@
old = LEFT;
LEFT.br_blockcount += PREV.br_blockcount;
@@ -254,7 +253,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (bma->cur == NULL)
rval = XFS_ILOG_DEXT;
-@@ -1723,10 +1722,10 @@ xfs_bmap_add_extent_delay_real(
+@@ -1719,10 +1718,10 @@
PREV.br_startblock = new->br_startblock;
PREV.br_blockcount += RIGHT.br_blockcount;
@@ -269,7 +268,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (bma->cur == NULL)
rval = XFS_ILOG_DEXT;
-@@ -1750,7 +1749,7 @@ xfs_bmap_add_extent_delay_real(
+@@ -1746,7 +1745,7 @@
*/
PREV.br_startblock = new->br_startblock;
PREV.br_state = new->br_state;
@@ -278,7 +277,7 @@ index 30b6127b821c..c0e20c6b8815 100644
(*nextents)++;
if (bma->cur == NULL)
-@@ -1784,9 +1783,9 @@ xfs_bmap_add_extent_delay_real(
+@@ -1780,9 +1779,9 @@
PREV.br_startoff += new->br_blockcount;
PREV.br_startblock = nullstartblock(da_new);
@@ -291,7 +290,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (bma->cur == NULL)
rval = XFS_ILOG_DEXT;
-@@ -1800,7 +1799,6 @@ xfs_bmap_add_extent_delay_real(
+@@ -1796,7 +1795,6 @@
if (error)
goto done;
}
@@ -299,7 +298,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case BMAP_LEFT_FILLING:
-@@ -1808,7 +1806,7 @@ xfs_bmap_add_extent_delay_real(
+@@ -1804,7 +1802,7 @@
* Filling in the first part of a previous delayed allocation.
* The left neighbor is not contiguous.
*/
@@ -308,7 +307,7 @@ index 30b6127b821c..c0e20c6b8815 100644
(*nextents)++;
if (bma->cur == NULL)
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
-@@ -1841,7 +1839,9 @@ xfs_bmap_add_extent_delay_real(
+@@ -1837,7 +1835,9 @@
PREV.br_startoff = new_endoff;
PREV.br_blockcount = temp;
PREV.br_startblock = nullstartblock(da_new);
@@ -319,7 +318,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG:
-@@ -1874,9 +1874,9 @@ xfs_bmap_add_extent_delay_real(
+@@ -1870,9 +1870,9 @@
PREV.br_blockcount = temp;
PREV.br_startblock = nullstartblock(da_new);
@@ -332,7 +331,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case BMAP_RIGHT_FILLING:
-@@ -1884,7 +1884,7 @@ xfs_bmap_add_extent_delay_real(
+@@ -1880,7 +1880,7 @@
* Filling in the last part of a previous delayed allocation.
* The right neighbor is not contiguous.
*/
@@ -341,7 +340,7 @@ index 30b6127b821c..c0e20c6b8815 100644
(*nextents)++;
if (bma->cur == NULL)
rval = XFS_ILOG_CORE | XFS_ILOG_DEXT;
-@@ -1916,9 +1916,8 @@ xfs_bmap_add_extent_delay_real(
+@@ -1912,9 +1912,8 @@
PREV.br_startblock = nullstartblock(da_new);
PREV.br_blockcount = temp;
@@ -353,7 +352,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case 0:
-@@ -1961,10 +1960,11 @@ xfs_bmap_add_extent_delay_real(
+@@ -1957,10 +1956,11 @@
PREV.br_startblock =
nullstartblock(xfs_bmap_worst_indlen(bma->ip,
PREV.br_blockcount));
@@ -367,7 +366,7 @@ index 30b6127b821c..c0e20c6b8815 100644
(*nextents)++;
if (bma->cur == NULL)
-@@ -1992,7 +1992,6 @@ xfs_bmap_add_extent_delay_real(
+@@ -1988,7 +1988,6 @@
da_new = startblockval(PREV.br_startblock) +
startblockval(RIGHT.br_startblock);
@@ -375,7 +374,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG | BMAP_RIGHT_CONTIG:
-@@ -2056,7 +2055,7 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2052,7 +2051,7 @@
struct xfs_trans *tp,
xfs_inode_t *ip, /* incore inode pointer */
int whichfork,
@@ -384,7 +383,7 @@ index 30b6127b821c..c0e20c6b8815 100644
xfs_btree_cur_t **curp, /* if *curp is null, not a btree */
xfs_bmbt_irec_t *new, /* new data to add to file extents */
xfs_fsblock_t *first, /* pointer to firstblock variable */
-@@ -2080,8 +2079,6 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2076,8 +2075,6 @@
cur = *curp;
ifp = XFS_IFORK_PTR(ip, whichfork);
@@ -393,7 +392,7 @@ index 30b6127b821c..c0e20c6b8815 100644
ASSERT(!isnullstartblock(new->br_startblock));
XFS_STATS_INC(mp, xs_add_exlist);
-@@ -2094,7 +2091,7 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2090,7 +2087,7 @@
* Set up a bunch of variables to make the tests simpler.
*/
error = 0;
@@ -402,7 +401,7 @@ index 30b6127b821c..c0e20c6b8815 100644
ASSERT(new->br_state != PREV.br_state);
new_endoff = new->br_startoff + new->br_blockcount;
ASSERT(PREV.br_startoff <= new->br_startoff);
-@@ -2113,10 +2110,8 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2109,10 +2106,8 @@
* Check and set flags if this segment has a left neighbor.
* Don't set contiguous if the combined extent would be too large.
*/
@@ -414,7 +413,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (isnullstartblock(LEFT.br_startblock))
state |= BMAP_LEFT_DELAY;
}
-@@ -2133,9 +2128,8 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2129,9 +2124,8 @@
* Don't set contiguous if the combined extent would be too large.
* Also check for all-three-contiguous being too large.
*/
@@ -425,7 +424,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (isnullstartblock(RIGHT.br_startblock))
state |= BMAP_RIGHT_DELAY;
}
-@@ -2166,9 +2160,9 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2162,9 +2156,9 @@
*/
LEFT.br_blockcount += PREV.br_blockcount + RIGHT.br_blockcount;
@@ -438,7 +437,7 @@ index 30b6127b821c..c0e20c6b8815 100644
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) - 2);
if (cur == NULL)
-@@ -2204,9 +2198,9 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2200,9 +2194,9 @@
*/
LEFT.br_blockcount += PREV.br_blockcount;
@@ -451,7 +450,7 @@ index 30b6127b821c..c0e20c6b8815 100644
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) - 1);
if (cur == NULL)
-@@ -2237,10 +2231,10 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2233,10 +2227,10 @@
PREV.br_blockcount += RIGHT.br_blockcount;
PREV.br_state = new->br_state;
@@ -466,7 +465,7 @@ index 30b6127b821c..c0e20c6b8815 100644
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) - 1);
-@@ -2271,7 +2265,7 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2267,7 +2261,7 @@
* the new one.
*/
PREV.br_state = new->br_state;
@@ -475,7 +474,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (cur == NULL)
rval = XFS_ILOG_DEXT;
-@@ -2299,9 +2293,9 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2295,9 +2289,9 @@
PREV.br_startblock += new->br_blockcount;
PREV.br_blockcount -= new->br_blockcount;
@@ -488,7 +487,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (cur == NULL)
rval = XFS_ILOG_DEXT;
-@@ -2333,8 +2327,8 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2329,8 +2323,8 @@
PREV.br_startblock += new->br_blockcount;
PREV.br_blockcount -= new->br_blockcount;
@@ -499,7 +498,7 @@ index 30b6127b821c..c0e20c6b8815 100644
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) + 1);
if (cur == NULL)
-@@ -2367,9 +2361,9 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2363,9 +2357,9 @@
RIGHT.br_startblock = new->br_startblock;
RIGHT.br_blockcount += new->br_blockcount;
@@ -512,7 +511,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (cur == NULL)
rval = XFS_ILOG_DEXT;
-@@ -2399,9 +2393,9 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2395,9 +2389,9 @@
old = PREV;
PREV.br_blockcount -= new->br_blockcount;
@@ -525,7 +524,7 @@ index 30b6127b821c..c0e20c6b8815 100644
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) + 1);
-@@ -2442,9 +2436,9 @@ xfs_bmap_add_extent_unwritten_real(
+@@ -2438,9 +2432,9 @@
r[1].br_startblock = new->br_startblock + new->br_blockcount;
r[1].br_state = PREV.br_state;
@@ -538,7 +537,7 @@ index 30b6127b821c..c0e20c6b8815 100644
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) + 2);
-@@ -2533,7 +2527,7 @@ STATIC void
+@@ -2529,7 +2523,7 @@
xfs_bmap_add_extent_hole_delay(
xfs_inode_t *ip, /* incore inode pointer */
int whichfork,
@@ -547,7 +546,7 @@ index 30b6127b821c..c0e20c6b8815 100644
xfs_bmbt_irec_t *new) /* new data to add to file extents */
{
xfs_ifork_t *ifp; /* inode fork pointer */
-@@ -2550,10 +2544,8 @@ xfs_bmap_add_extent_hole_delay(
+@@ -2546,10 +2540,8 @@
/*
* Check and set flags if this segment has a left neighbor
*/
@@ -559,7 +558,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (isnullstartblock(left.br_startblock))
state |= BMAP_LEFT_DELAY;
}
-@@ -2562,10 +2554,8 @@ xfs_bmap_add_extent_hole_delay(
+@@ -2558,10 +2550,8 @@
* Check and set flags if the current (right) segment exists.
* If it doesn't exist, we're converting the hole at end-of-file.
*/
@@ -571,7 +570,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (isnullstartblock(right.br_startblock))
state |= BMAP_RIGHT_DELAY;
}
-@@ -2608,9 +2598,9 @@ xfs_bmap_add_extent_hole_delay(
+@@ -2604,9 +2594,9 @@
left.br_startblock = nullstartblock(newlen);
left.br_blockcount = temp;
@@ -584,7 +583,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case BMAP_LEFT_CONTIG:
-@@ -2628,8 +2618,8 @@ xfs_bmap_add_extent_hole_delay(
+@@ -2624,8 +2614,8 @@
left.br_blockcount = temp;
left.br_startblock = nullstartblock(newlen);
@@ -595,7 +594,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case BMAP_RIGHT_CONTIG:
-@@ -2646,7 +2636,7 @@ xfs_bmap_add_extent_hole_delay(
+@@ -2642,7 +2632,7 @@
right.br_startoff = new->br_startoff;
right.br_startblock = nullstartblock(newlen);
right.br_blockcount = temp;
@@ -604,7 +603,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case 0:
-@@ -2656,7 +2646,7 @@ xfs_bmap_add_extent_hole_delay(
+@@ -2652,7 +2642,7 @@
* Insert a new entry.
*/
oldlen = newlen = 0;
@@ -613,7 +612,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
}
if (oldlen != newlen) {
-@@ -2677,7 +2667,7 @@ xfs_bmap_add_extent_hole_real(
+@@ -2673,7 +2663,7 @@
struct xfs_trans *tp,
struct xfs_inode *ip,
int whichfork,
@@ -622,7 +621,7 @@ index 30b6127b821c..c0e20c6b8815 100644
struct xfs_btree_cur **curp,
struct xfs_bmbt_irec *new,
xfs_fsblock_t *first,
-@@ -2695,8 +2685,6 @@ xfs_bmap_add_extent_hole_real(
+@@ -2691,8 +2681,6 @@
int state = xfs_bmap_fork_to_state(whichfork);
struct xfs_bmbt_irec old;
@@ -631,7 +630,7 @@ index 30b6127b821c..c0e20c6b8815 100644
ASSERT(!isnullstartblock(new->br_startblock));
ASSERT(!cur || !(cur->bc_private.b.flags & XFS_BTCUR_BPRV_WASDEL));
-@@ -2705,9 +2693,8 @@ xfs_bmap_add_extent_hole_real(
+@@ -2701,9 +2689,8 @@
/*
* Check and set flags if this segment has a left neighbor.
*/
@@ -642,7 +641,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (isnullstartblock(left.br_startblock))
state |= BMAP_LEFT_DELAY;
}
-@@ -2716,9 +2703,8 @@ xfs_bmap_add_extent_hole_real(
+@@ -2712,9 +2699,8 @@
* Check and set flags if this segment has a current value.
* Not true if we're inserting into the "hole" at eof.
*/
@@ -653,7 +652,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (isnullstartblock(right.br_startblock))
state |= BMAP_RIGHT_DELAY;
}
-@@ -2757,9 +2743,9 @@ xfs_bmap_add_extent_hole_real(
+@@ -2753,9 +2739,9 @@
*/
left.br_blockcount += new->br_blockcount + right.br_blockcount;
@@ -666,7 +665,7 @@ index 30b6127b821c..c0e20c6b8815 100644
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) - 1);
-@@ -2794,8 +2780,8 @@ xfs_bmap_add_extent_hole_real(
+@@ -2790,8 +2776,8 @@
old = left;
left.br_blockcount += new->br_blockcount;
@@ -677,7 +676,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (cur == NULL) {
rval = xfs_ilog_fext(whichfork);
-@@ -2822,7 +2808,7 @@ xfs_bmap_add_extent_hole_real(
+@@ -2818,7 +2804,7 @@
right.br_startoff = new->br_startoff;
right.br_startblock = new->br_startblock;
right.br_blockcount += new->br_blockcount;
@@ -686,7 +685,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (cur == NULL) {
rval = xfs_ilog_fext(whichfork);
-@@ -2844,7 +2830,7 @@ xfs_bmap_add_extent_hole_real(
+@@ -2840,7 +2826,7 @@
* real allocation.
* Insert a new entry.
*/
@@ -695,7 +694,7 @@ index 30b6127b821c..c0e20c6b8815 100644
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) + 1);
if (cur == NULL) {
-@@ -3794,7 +3780,7 @@ xfs_bmapi_read(
+@@ -3790,7 +3776,7 @@
struct xfs_bmbt_irec got;
xfs_fileoff_t obno;
xfs_fileoff_t end;
@@ -704,7 +703,7 @@ index 30b6127b821c..c0e20c6b8815 100644
int error;
bool eof = false;
int n = 0;
-@@ -3836,7 +3822,7 @@ xfs_bmapi_read(
+@@ -3832,7 +3818,7 @@
return error;
}
@@ -713,7 +712,7 @@ index 30b6127b821c..c0e20c6b8815 100644
eof = true;
end = bno + len;
obno = bno;
-@@ -3868,7 +3854,7 @@ xfs_bmapi_read(
+@@ -3864,7 +3850,7 @@
break;
/* Else go on to the next record. */
@@ -722,7 +721,7 @@ index 30b6127b821c..c0e20c6b8815 100644
eof = true;
}
*nmap = n;
-@@ -3896,7 +3882,7 @@ xfs_bmapi_reserve_delalloc(
+@@ -3892,7 +3878,7 @@
xfs_filblks_t len,
xfs_filblks_t prealloc,
struct xfs_bmbt_irec *got,
@@ -731,7 +730,7 @@ index 30b6127b821c..c0e20c6b8815 100644
int eof)
{
struct xfs_mount *mp = ip->i_mount;
-@@ -3926,7 +3912,7 @@ xfs_bmapi_reserve_delalloc(
+@@ -3922,7 +3908,7 @@
if (extsz) {
struct xfs_bmbt_irec prev;
@@ -740,7 +739,7 @@ index 30b6127b821c..c0e20c6b8815 100644
prev.br_startoff = NULLFILEOFF;
error = xfs_bmap_extsize_align(mp, got, &prev, extsz, rt, eof,
-@@ -3975,7 +3961,7 @@ xfs_bmapi_reserve_delalloc(
+@@ -3971,7 +3957,7 @@
got->br_blockcount = alen;
got->br_state = XFS_EXT_NORM;
@@ -749,7 +748,7 @@ index 30b6127b821c..c0e20c6b8815 100644
/*
* Tag the inode if blocks were preallocated. Note that COW fork
-@@ -4020,8 +4006,7 @@ xfs_bmapi_allocate(
+@@ -4016,8 +4002,7 @@
if (bma->wasdel) {
bma->length = (xfs_extlen_t)bma->got.br_blockcount;
bma->offset = bma->got.br_startoff;
@@ -759,7 +758,7 @@ index 30b6127b821c..c0e20c6b8815 100644
} else {
bma->length = XFS_FILBLKS_MIN(bma->length, MAXEXTLEN);
if (!bma->eof)
-@@ -4106,7 +4091,7 @@ xfs_bmapi_allocate(
+@@ -4102,7 +4087,7 @@
error = xfs_bmap_add_extent_delay_real(bma, whichfork);
else
error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip,
@@ -768,7 +767,7 @@ index 30b6127b821c..c0e20c6b8815 100644
bma->firstblock, bma->dfops, &bma->logflags);
bma->logflags |= tmp_logflags;
-@@ -4118,7 +4103,7 @@ xfs_bmapi_allocate(
+@@ -4114,7 +4099,7 @@
* or xfs_bmap_add_extent_hole_real might have merged it into one of
* the neighbouring ones.
*/
@@ -777,7 +776,7 @@ index 30b6127b821c..c0e20c6b8815 100644
ASSERT(bma->got.br_startoff <= bma->offset);
ASSERT(bma->got.br_startoff + bma->got.br_blockcount >=
-@@ -4176,8 +4161,8 @@ xfs_bmapi_convert_unwritten(
+@@ -4172,8 +4157,8 @@
}
error = xfs_bmap_add_extent_unwritten_real(bma->tp, bma->ip, whichfork,
@@ -788,7 +787,7 @@ index 30b6127b821c..c0e20c6b8815 100644
/*
* Log the inode core unconditionally in the unwritten extent conversion
* path because the conversion might not have done so (e.g., if the
-@@ -4199,7 +4184,7 @@ xfs_bmapi_convert_unwritten(
+@@ -4195,7 +4180,7 @@
* xfs_bmap_add_extent_unwritten_real might have merged it into one
* of the neighbouring ones.
*/
@@ -797,7 +796,7 @@ index 30b6127b821c..c0e20c6b8815 100644
/*
* We may have combined previously unwritten space with written space,
-@@ -4318,9 +4303,9 @@ xfs_bmapi_write(
+@@ -4314,9 +4299,9 @@
end = bno + len;
obno = bno;
@@ -809,7 +808,7 @@ index 30b6127b821c..c0e20c6b8815 100644
bma.prev.br_startoff = NULLFILEOFF;
bma.tp = tp;
bma.ip = ip;
-@@ -4425,7 +4410,7 @@ xfs_bmapi_write(
+@@ -4421,7 +4406,7 @@
/* Else go on to the next record. */
bma.prev = bma.got;
@@ -818,7 +817,7 @@ index 30b6127b821c..c0e20c6b8815 100644
eof = true;
}
*nmap = n;
-@@ -4498,7 +4483,7 @@ xfs_bmapi_remap(
+@@ -4494,7 +4479,7 @@
struct xfs_btree_cur *cur = NULL;
xfs_fsblock_t firstblock = NULLFSBLOCK;
struct xfs_bmbt_irec got;
@@ -827,7 +826,7 @@ index 30b6127b821c..c0e20c6b8815 100644
int logflags = 0, error;
ASSERT(len > 0);
-@@ -4522,7 +4507,7 @@ xfs_bmapi_remap(
+@@ -4518,7 +4503,7 @@
return error;
}
@@ -836,7 +835,7 @@ index 30b6127b821c..c0e20c6b8815 100644
/* make sure we only reflink into a hole. */
ASSERT(got.br_startoff > bno);
ASSERT(got.br_startoff - bno >= len);
-@@ -4543,8 +4528,8 @@ xfs_bmapi_remap(
+@@ -4539,8 +4524,8 @@
got.br_blockcount = len;
got.br_state = XFS_EXT_NORM;
@@ -847,7 +846,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (error)
goto error0;
-@@ -4660,7 +4645,7 @@ int
+@@ -4656,7 +4641,7 @@
xfs_bmap_del_extent_delay(
struct xfs_inode *ip,
int whichfork,
@@ -856,7 +855,7 @@ index 30b6127b821c..c0e20c6b8815 100644
struct xfs_bmbt_irec *got,
struct xfs_bmbt_irec *del)
{
-@@ -4682,8 +4667,6 @@ xfs_bmap_del_extent_delay(
+@@ -4678,8 +4663,6 @@
da_old = startblockval(got->br_startblock);
da_new = 0;
@@ -865,7 +864,7 @@ index 30b6127b821c..c0e20c6b8815 100644
ASSERT(del->br_blockcount > 0);
ASSERT(got->br_startoff <= del->br_startoff);
ASSERT(got_endoff >= del_endoff);
-@@ -4717,8 +4700,8 @@ xfs_bmap_del_extent_delay(
+@@ -4713,8 +4696,8 @@
/*
* Matches the whole extent. Delete the entry.
*/
@@ -876,7 +875,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case BMAP_LEFT_FILLING:
/*
-@@ -4729,7 +4712,7 @@ xfs_bmap_del_extent_delay(
+@@ -4725,7 +4708,7 @@
da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip,
got->br_blockcount), da_old);
got->br_startblock = nullstartblock((int)da_new);
@@ -885,7 +884,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case BMAP_RIGHT_FILLING:
/*
-@@ -4739,7 +4722,7 @@ xfs_bmap_del_extent_delay(
+@@ -4735,7 +4718,7 @@
da_new = XFS_FILBLKS_MIN(xfs_bmap_worst_indlen(ip,
got->br_blockcount), da_old);
got->br_startblock = nullstartblock((int)da_new);
@@ -894,7 +893,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case 0:
/*
-@@ -4767,9 +4750,9 @@ xfs_bmap_del_extent_delay(
+@@ -4763,9 +4746,9 @@
new.br_state = got->br_state;
new.br_startblock = nullstartblock((int)new_indlen);
@@ -907,7 +906,7 @@ index 30b6127b821c..c0e20c6b8815 100644
da_new = got_indlen + new_indlen - stolen;
del->br_blockcount -= stolen;
-@@ -4788,7 +4771,7 @@ xfs_bmap_del_extent_delay(
+@@ -4784,7 +4767,7 @@
void
xfs_bmap_del_extent_cow(
struct xfs_inode *ip,
@@ -916,7 +915,7 @@ index 30b6127b821c..c0e20c6b8815 100644
struct xfs_bmbt_irec *got,
struct xfs_bmbt_irec *del)
{
-@@ -4803,8 +4786,6 @@ xfs_bmap_del_extent_cow(
+@@ -4799,8 +4782,6 @@
del_endoff = del->br_startoff + del->br_blockcount;
got_endoff = got->br_startoff + got->br_blockcount;
@@ -925,7 +924,7 @@ index 30b6127b821c..c0e20c6b8815 100644
ASSERT(del->br_blockcount > 0);
ASSERT(got->br_startoff <= del->br_startoff);
ASSERT(got_endoff >= del_endoff);
-@@ -4820,8 +4801,8 @@ xfs_bmap_del_extent_cow(
+@@ -4816,8 +4797,8 @@
/*
* Matches the whole extent. Delete the entry.
*/
@@ -936,7 +935,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case BMAP_LEFT_FILLING:
/*
-@@ -4830,14 +4811,14 @@ xfs_bmap_del_extent_cow(
+@@ -4826,14 +4807,14 @@
got->br_startoff = del_endoff;
got->br_blockcount -= del->br_blockcount;
got->br_startblock = del->br_startblock + del->br_blockcount;
@@ -953,7 +952,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
case 0:
/*
-@@ -4850,9 +4831,9 @@ xfs_bmap_del_extent_cow(
+@@ -4846,9 +4827,9 @@
new.br_state = got->br_state;
new.br_startblock = del->br_startblock + del->br_blockcount;
@@ -966,7 +965,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
}
}
-@@ -4865,7 +4846,7 @@ STATIC int /* error */
+@@ -4861,7 +4842,7 @@
xfs_bmap_del_extent_real(
xfs_inode_t *ip, /* incore inode pointer */
xfs_trans_t *tp, /* current transaction pointer */
@@ -975,7 +974,7 @@ index 30b6127b821c..c0e20c6b8815 100644
struct xfs_defer_ops *dfops, /* list of extents to be freed */
xfs_btree_cur_t *cur, /* if null, not a btree */
xfs_bmbt_irec_t *del, /* data to remove from extents */
-@@ -4894,9 +4875,8 @@ xfs_bmap_del_extent_real(
+@@ -4890,9 +4871,8 @@
XFS_STATS_INC(mp, xs_del_exlist);
ifp = XFS_IFORK_PTR(ip, whichfork);
@@ -986,7 +985,7 @@ index 30b6127b821c..c0e20c6b8815 100644
ASSERT(got.br_startoff <= del->br_startoff);
del_endoff = del->br_startoff + del->br_blockcount;
got_endoff = got.br_startoff + got.br_blockcount;
-@@ -4961,9 +4941,8 @@ xfs_bmap_del_extent_real(
+@@ -4957,9 +4937,8 @@
/*
* Matches the whole extent. Delete the entry.
*/
@@ -998,7 +997,7 @@ index 30b6127b821c..c0e20c6b8815 100644
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) - 1);
flags |= XFS_ILOG_CORE;
-@@ -4982,7 +4961,7 @@ xfs_bmap_del_extent_real(
+@@ -4978,7 +4957,7 @@
got.br_startoff = del_endoff;
got.br_startblock = del_endblock;
got.br_blockcount -= del->br_blockcount;
@@ -1007,7 +1006,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (!cur) {
flags |= xfs_ilog_fext(whichfork);
break;
-@@ -4996,7 +4975,7 @@ xfs_bmap_del_extent_real(
+@@ -4992,7 +4971,7 @@
* Deleting the last part of the extent.
*/
got.br_blockcount -= del->br_blockcount;
@@ -1016,7 +1015,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (!cur) {
flags |= xfs_ilog_fext(whichfork);
break;
-@@ -5012,7 +4991,7 @@ xfs_bmap_del_extent_real(
+@@ -5008,7 +4987,7 @@
old = got;
got.br_blockcount = del->br_startoff - got.br_startoff;
@@ -1025,7 +1024,7 @@ index 30b6127b821c..c0e20c6b8815 100644
new.br_startoff = del_endoff;
new.br_blockcount = got_endoff - del_endoff;
-@@ -5056,7 +5035,7 @@ xfs_bmap_del_extent_real(
+@@ -5052,7 +5031,7 @@
* Reset the extent record back
* to the original value.
*/
@@ -1034,7 +1033,7 @@ index 30b6127b821c..c0e20c6b8815 100644
flags = 0;
error = -ENOSPC;
goto done;
-@@ -5066,8 +5045,8 @@ xfs_bmap_del_extent_real(
+@@ -5062,8 +5041,8 @@
flags |= xfs_ilog_fext(whichfork);
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) + 1);
@@ -1045,7 +1044,7 @@ index 30b6127b821c..c0e20c6b8815 100644
break;
}
-@@ -5130,7 +5109,6 @@ __xfs_bunmapi(
+@@ -5126,7 +5105,6 @@
xfs_bmbt_irec_t got; /* current extent record */
xfs_ifork_t *ifp; /* inode fork pointer */
int isrt; /* freeing in rt area */
@@ -1053,7 +1052,7 @@ index 30b6127b821c..c0e20c6b8815 100644
int logflags; /* transaction logging flags */
xfs_extlen_t mod; /* rt extent offset */
xfs_mount_t *mp; /* mount structure */
-@@ -5140,6 +5118,8 @@ __xfs_bunmapi(
+@@ -5136,6 +5114,8 @@
xfs_fsblock_t sum;
xfs_filblks_t len = *rlen; /* length to unmap in file */
xfs_fileoff_t end;
@@ -1062,7 +1061,7 @@ index 30b6127b821c..c0e20c6b8815 100644
trace_xfs_bunmap(ip, start, len, flags, _RET_IP_);
-@@ -5172,7 +5152,7 @@ __xfs_bunmapi(
+@@ -5168,7 +5148,7 @@
isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip);
end = start + len;
@@ -1071,7 +1070,7 @@ index 30b6127b821c..c0e20c6b8815 100644
*rlen = 0;
return 0;
}
-@@ -5199,16 +5179,16 @@ __xfs_bunmapi(
+@@ -5195,16 +5175,16 @@
}
extno = 0;
@@ -1093,7 +1092,7 @@ index 30b6127b821c..c0e20c6b8815 100644
}
/*
* Is the last block of this extent before the range
-@@ -5253,10 +5233,10 @@ __xfs_bunmapi(
+@@ -5249,10 +5229,10 @@
ASSERT(end >= mod);
end -= mod > del.br_blockcount ?
del.br_blockcount : mod;
@@ -1108,7 +1107,7 @@ index 30b6127b821c..c0e20c6b8815 100644
}
continue;
}
-@@ -5277,7 +5257,7 @@ __xfs_bunmapi(
+@@ -5273,7 +5253,7 @@
}
del.br_state = XFS_EXT_UNWRITTEN;
error = xfs_bmap_add_extent_unwritten_real(tp, ip,
@@ -1117,7 +1116,7 @@ index 30b6127b821c..c0e20c6b8815 100644
firstblock, dfops, &logflags);
if (error)
goto error0;
-@@ -5304,8 +5284,11 @@ __xfs_bunmapi(
+@@ -5300,8 +5280,11 @@
*/
ASSERT(end >= del.br_blockcount);
end -= del.br_blockcount;
@@ -1131,7 +1130,7 @@ index 30b6127b821c..c0e20c6b8815 100644
continue;
} else if (del.br_state == XFS_EXT_UNWRITTEN) {
struct xfs_bmbt_irec prev;
-@@ -5316,8 +5299,8 @@ __xfs_bunmapi(
+@@ -5312,8 +5295,8 @@
* Unwrite the killed part of that one and
* try again.
*/
@@ -1142,7 +1141,7 @@ index 30b6127b821c..c0e20c6b8815 100644
ASSERT(prev.br_state == XFS_EXT_NORM);
ASSERT(!isnullstartblock(prev.br_startblock));
ASSERT(del.br_startblock ==
-@@ -5329,9 +5312,8 @@ __xfs_bunmapi(
+@@ -5325,9 +5308,8 @@
prev.br_startoff = start;
}
prev.br_state = XFS_EXT_UNWRITTEN;
@@ -1153,7 +1152,7 @@ index 30b6127b821c..c0e20c6b8815 100644
&prev, firstblock, dfops,
&logflags);
if (error)
-@@ -5341,7 +5323,7 @@ __xfs_bunmapi(
+@@ -5337,7 +5319,7 @@
ASSERT(del.br_state == XFS_EXT_NORM);
del.br_state = XFS_EXT_UNWRITTEN;
error = xfs_bmap_add_extent_unwritten_real(tp,
@@ -1162,7 +1161,7 @@ index 30b6127b821c..c0e20c6b8815 100644
&del, firstblock, dfops,
&logflags);
if (error)
-@@ -5351,10 +5333,10 @@ __xfs_bunmapi(
+@@ -5347,10 +5329,10 @@
}
if (wasdel) {
@@ -1175,7 +1174,7 @@ index 30b6127b821c..c0e20c6b8815 100644
cur, &del, &tmp_logflags, whichfork,
flags);
logflags |= tmp_logflags;
-@@ -5369,15 +5351,16 @@ __xfs_bunmapi(
+@@ -5365,15 +5347,16 @@
* If not done go on to the next (previous) record.
*/
if (end != (xfs_fileoff_t)-1 && end >= start) {
@@ -1197,7 +1196,7 @@ index 30b6127b821c..c0e20c6b8815 100644
*rlen = 0;
else
*rlen = end - start + 1;
-@@ -5498,7 +5481,7 @@ xfs_bmse_merge(
+@@ -5494,7 +5477,7 @@
struct xfs_inode *ip,
int whichfork,
xfs_fileoff_t shift, /* shift fsb */
@@ -1206,7 +1205,7 @@ index 30b6127b821c..c0e20c6b8815 100644
struct xfs_bmbt_irec *got, /* extent to shift */
struct xfs_bmbt_irec *left, /* preceding extent */
struct xfs_btree_cur *cur,
-@@ -5553,10 +5536,10 @@ xfs_bmse_merge(
+@@ -5549,10 +5532,10 @@
return error;
done:
@@ -1221,7 +1220,7 @@ index 30b6127b821c..c0e20c6b8815 100644
/* update reverse mapping */
error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, got);
-@@ -5572,7 +5555,7 @@ static int
+@@ -5568,7 +5551,7 @@
xfs_bmap_shift_update_extent(
struct xfs_inode *ip,
int whichfork,
@@ -1230,7 +1229,7 @@ index 30b6127b821c..c0e20c6b8815 100644
struct xfs_bmbt_irec *got,
struct xfs_btree_cur *cur,
int *logflags,
-@@ -5600,7 +5583,8 @@ xfs_bmap_shift_update_extent(
+@@ -5596,7 +5579,8 @@
*logflags |= XFS_ILOG_DEXT;
}
@@ -1240,7 +1239,7 @@ index 30b6127b821c..c0e20c6b8815 100644
/* update reverse mapping */
error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, &prev);
-@@ -5625,7 +5609,7 @@ xfs_bmap_collapse_extents(
+@@ -5621,7 +5605,7 @@
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
struct xfs_btree_cur *cur = NULL;
struct xfs_bmbt_irec got, prev;
@@ -1249,7 +1248,7 @@ index 30b6127b821c..c0e20c6b8815 100644
xfs_fileoff_t new_startoff;
int error = 0;
int logflags = 0;
-@@ -5656,14 +5640,14 @@ xfs_bmap_collapse_extents(
+@@ -5652,14 +5636,14 @@
cur->bc_private.b.flags = 0;
}
@@ -1266,7 +1265,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (new_startoff < prev.br_startoff + prev.br_blockcount) {
error = -EINVAL;
goto del_cursor;
-@@ -5671,8 +5655,8 @@ xfs_bmap_collapse_extents(
+@@ -5667,8 +5651,8 @@
if (xfs_bmse_can_merge(&prev, &got, offset_shift_fsb)) {
error = xfs_bmse_merge(ip, whichfork, offset_shift_fsb,
@@ -1277,7 +1276,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (error)
goto del_cursor;
goto done;
-@@ -5684,15 +5668,15 @@ xfs_bmap_collapse_extents(
+@@ -5680,15 +5664,15 @@
}
}
@@ -1298,7 +1297,7 @@ index 30b6127b821c..c0e20c6b8815 100644
}
*next_fsb = got.br_startoff;
-@@ -5721,7 +5705,7 @@ xfs_bmap_insert_extents(
+@@ -5717,7 +5701,7 @@
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
struct xfs_btree_cur *cur = NULL;
struct xfs_bmbt_irec got, next;
@@ -1307,7 +1306,7 @@ index 30b6127b821c..c0e20c6b8815 100644
xfs_fileoff_t new_startoff;
int error = 0;
int logflags = 0;
-@@ -5753,15 +5737,14 @@ xfs_bmap_insert_extents(
+@@ -5749,15 +5733,14 @@
}
if (*next_fsb == NULLFSBLOCK) {
@@ -1326,7 +1325,7 @@ index 30b6127b821c..c0e20c6b8815 100644
*done = true;
goto del_cursor;
}
-@@ -5774,7 +5757,7 @@ xfs_bmap_insert_extents(
+@@ -5770,7 +5753,7 @@
}
new_startoff = got.br_startoff + offset_shift_fsb;
@@ -1335,7 +1334,7 @@ index 30b6127b821c..c0e20c6b8815 100644
if (new_startoff + got.br_blockcount > next.br_startoff) {
error = -EINVAL;
goto del_cursor;
-@@ -5790,12 +5773,12 @@ xfs_bmap_insert_extents(
+@@ -5786,12 +5769,12 @@
WARN_ON_ONCE(1);
}
@@ -1351,7 +1350,7 @@ index 30b6127b821c..c0e20c6b8815 100644
stop_fsb >= got.br_startoff + got.br_blockcount) {
*done = true;
goto del_cursor;
-@@ -5812,10 +5795,10 @@ xfs_bmap_insert_extents(
+@@ -5808,10 +5791,10 @@
}
/*
@@ -1366,7 +1365,7 @@ index 30b6127b821c..c0e20c6b8815 100644
*/
STATIC int
xfs_bmap_split_extent_at(
-@@ -5832,7 +5815,7 @@ xfs_bmap_split_extent_at(
+@@ -5828,7 +5811,7 @@
struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp;
xfs_fsblock_t gotblkcnt; /* new block count for got */
@@ -1375,7 +1374,7 @@ index 30b6127b821c..c0e20c6b8815 100644
int error = 0;
int logflags = 0;
int i = 0;
-@@ -5860,7 +5843,7 @@ xfs_bmap_split_extent_at(
+@@ -5856,7 +5839,7 @@
/*
* If there are not extents, or split_fsb lies in a hole we are done.
*/
@@ -1384,7 +1383,7 @@ index 30b6127b821c..c0e20c6b8815 100644
got.br_startoff >= split_fsb)
return 0;
-@@ -5882,8 +5865,8 @@ xfs_bmap_split_extent_at(
+@@ -5878,8 +5861,8 @@
}
got.br_blockcount = gotblkcnt;
@@ -1395,7 +1394,7 @@ index 30b6127b821c..c0e20c6b8815 100644
logflags = XFS_ILOG_CORE;
if (cur) {
-@@ -5894,8 +5877,8 @@ xfs_bmap_split_extent_at(
+@@ -5890,8 +5873,8 @@
logflags |= XFS_ILOG_DEXT;
/* Add new extent */
@@ -1406,11 +1405,9 @@ index 30b6127b821c..c0e20c6b8815 100644
XFS_IFORK_NEXT_SET(ip, whichfork,
XFS_IFORK_NEXTENTS(ip, whichfork) + 1);
-diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
-index 8c10a4c074d5..af64e90a9f03 100644
--- a/fs/xfs/libxfs/xfs_bmap.h
+++ b/fs/xfs/libxfs/xfs_bmap.h
-@@ -43,7 +43,7 @@ struct xfs_bmalloca {
+@@ -43,7 +43,7 @@
xfs_fsblock_t blkno; /* starting block of new extent */
struct xfs_btree_cur *cur; /* btree cursor */
@@ -1419,7 +1416,7 @@ index 8c10a4c074d5..af64e90a9f03 100644
int nallocs;/* number of extents alloc'd */
int logflags;/* flags for transaction logging */
-@@ -216,10 +216,11 @@ int xfs_bunmapi(struct xfs_trans *tp, struct xfs_inode *ip,
+@@ -216,10 +216,11 @@
xfs_extnum_t nexts, xfs_fsblock_t *firstblock,
struct xfs_defer_ops *dfops, int *done);
int xfs_bmap_del_extent_delay(struct xfs_inode *ip, int whichfork,
@@ -1434,7 +1431,7 @@ index 8c10a4c074d5..af64e90a9f03 100644
uint xfs_default_attroffset(struct xfs_inode *ip);
int xfs_bmap_collapse_extents(struct xfs_trans *tp, struct xfs_inode *ip,
xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
-@@ -232,7 +233,8 @@ int xfs_bmap_insert_extents(struct xfs_trans *tp, struct xfs_inode *ip,
+@@ -232,7 +233,8 @@
int xfs_bmap_split_extent(struct xfs_inode *ip, xfs_fileoff_t split_offset);
int xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc,
@@ -1444,11 +1441,9 @@ index 8c10a4c074d5..af64e90a9f03 100644
enum xfs_bmap_intent_type {
XFS_BMAP_MAP = 1,
-diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c
-index 7dd77b497fc2..61d02b708a6b 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.c
+++ b/fs/xfs/libxfs/xfs_inode_fork.c
-@@ -343,6 +343,7 @@ xfs_iformat_extents(
+@@ -343,6 +343,7 @@
int state = xfs_bmap_fork_to_state(whichfork);
int nex = XFS_DFORK_NEXTENTS(dip, whichfork);
int size = nex * sizeof(xfs_bmbt_rec_t);
@@ -1456,7 +1451,7 @@ index 7dd77b497fc2..61d02b708a6b 100644
struct xfs_bmbt_rec *dp;
int i;
-@@ -369,16 +370,21 @@ xfs_iformat_extents(
+@@ -369,16 +370,21 @@
ifp->if_bytes = size;
if (size) {
dp = (xfs_bmbt_rec_t *) XFS_DFORK_PTR(dip, whichfork);
@@ -1479,7 +1474,7 @@ index 7dd77b497fc2..61d02b708a6b 100644
}
}
ifp->if_flags |= XFS_IFEXTENTS;
-@@ -739,17 +745,18 @@ xfs_iextents_copy(
+@@ -739,17 +745,18 @@
{
int state = xfs_bmap_fork_to_state(whichfork);
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, whichfork);
@@ -1501,7 +1496,7 @@ index 7dd77b497fc2..61d02b708a6b 100644
ASSERT(xfs_bmbt_validate_extent(ip->i_mount, whichfork, dp));
copied += sizeof(struct xfs_bmbt_rec);
dp++;
-@@ -894,7 +901,7 @@ xfs_iext_state_to_fork(
+@@ -894,7 +901,7 @@
void
xfs_iext_insert(
xfs_inode_t *ip, /* incore inode pointer */
@@ -1510,7 +1505,7 @@ index 7dd77b497fc2..61d02b708a6b 100644
xfs_extnum_t count, /* number of inserted items */
xfs_bmbt_irec_t *new, /* items to insert */
int state) /* type of extent conversion */
-@@ -902,12 +909,12 @@ xfs_iext_insert(
+@@ -902,12 +909,12 @@
xfs_ifork_t *ifp = xfs_iext_state_to_fork(ip, state);
xfs_extnum_t i; /* extent record index */
@@ -1527,7 +1522,7 @@ index 7dd77b497fc2..61d02b708a6b 100644
}
/*
-@@ -1145,7 +1152,7 @@ xfs_iext_add_indirect_multi(
+@@ -1145,7 +1152,7 @@
void
xfs_iext_remove(
xfs_inode_t *ip, /* incore inode pointer */
@@ -1536,7 +1531,7 @@ index 7dd77b497fc2..61d02b708a6b 100644
int ext_diff, /* number of extents to remove */
int state) /* type of extent conversion */
{
-@@ -1153,7 +1160,7 @@ xfs_iext_remove(
+@@ -1153,7 +1160,7 @@
xfs_extnum_t nextents; /* number of extents in file */
int new_size; /* size of extents after removal */
@@ -1545,7 +1540,7 @@ index 7dd77b497fc2..61d02b708a6b 100644
ASSERT(ext_diff > 0);
nextents = xfs_iext_count(ifp);
-@@ -1162,11 +1169,11 @@ xfs_iext_remove(
+@@ -1162,11 +1169,11 @@
if (new_size == 0) {
xfs_iext_destroy(ifp);
} else if (ifp->if_flags & XFS_IFEXTIREC) {
@@ -1560,7 +1555,7 @@ index 7dd77b497fc2..61d02b708a6b 100644
}
ifp->if_bytes = new_size;
}
-@@ -1913,26 +1920,26 @@ xfs_ifork_init_cow(
+@@ -1913,26 +1920,26 @@
* Lookup the extent covering bno.
*
* If there is an extent covering bno return the extent index, and store the
@@ -1593,7 +1588,7 @@ index 7dd77b497fc2..61d02b708a6b 100644
if (!ep)
return false;
xfs_bmbt_get_all(ep, gotp);
-@@ -1948,31 +1955,31 @@ xfs_iext_lookup_extent_before(
+@@ -1948,31 +1955,31 @@
struct xfs_inode *ip,
struct xfs_ifork *ifp,
xfs_fileoff_t *end,
@@ -1633,7 +1628,7 @@ index 7dd77b497fc2..61d02b708a6b 100644
return true;
}
-@@ -1980,15 +1987,15 @@ void
+@@ -1980,15 +1987,15 @@
xfs_iext_update_extent(
struct xfs_inode *ip,
int state,
@@ -1655,11 +1650,9 @@ index 7dd77b497fc2..61d02b708a6b 100644
+ xfs_bmbt_set_all(xfs_iext_get_ext(ifp, cur->idx), gotp);
+ trace_xfs_bmap_post_update(ip, cur, state, _RET_IP_);
}
-diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
-index 113fd42ec36d..d454161793e2 100644
--- a/fs/xfs/libxfs/xfs_inode_fork.h
+++ b/fs/xfs/libxfs/xfs_inode_fork.h
-@@ -151,12 +151,13 @@ void xfs_init_local_fork(struct xfs_inode *, int, const void *, int);
+@@ -151,12 +151,13 @@
struct xfs_bmbt_rec_host *
xfs_iext_get_ext(struct xfs_ifork *, xfs_extnum_t);
xfs_extnum_t xfs_iext_count(struct xfs_ifork *);
@@ -1676,7 +1669,7 @@ index 113fd42ec36d..d454161793e2 100644
void xfs_iext_remove_inline(struct xfs_ifork *, xfs_extnum_t, int);
void xfs_iext_remove_direct(struct xfs_ifork *, xfs_extnum_t, int);
void xfs_iext_remove_indirect(struct xfs_ifork *, xfs_extnum_t, int);
-@@ -182,15 +183,85 @@ void xfs_iext_irec_update_extoffs(struct xfs_ifork *, int, int);
+@@ -182,15 +183,85 @@
bool xfs_iext_lookup_extent(struct xfs_inode *ip,
struct xfs_ifork *ifp, xfs_fileoff_t bno,
@@ -1767,11 +1760,9 @@ index 113fd42ec36d..d454161793e2 100644
extern struct kmem_zone *xfs_ifork_zone;
-diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h
-index 0220159bd463..91d61a2dba59 100644
--- a/fs/xfs/libxfs/xfs_types.h
+++ b/fs/xfs/libxfs/xfs_types.h
-@@ -136,5 +136,8 @@ typedef uint32_t xfs_dqid_t;
+@@ -136,5 +136,8 @@
#define XFS_NBWORD (1 << XFS_NBWORDLOG)
#define XFS_WORDMASK ((1 << XFS_WORDLOG) - 1)
@@ -1780,11 +1771,9 @@ index 0220159bd463..91d61a2dba59 100644
+};
#endif /* __XFS_TYPES_H__ */
-diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
-index 3709cccc79cd..d5158f5cce35 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
-@@ -228,15 +228,17 @@ xfs_bmap_count_leaves(
+@@ -228,15 +228,17 @@
struct xfs_ifork *ifp,
xfs_filblks_t *count)
{
@@ -1804,7 +1793,7 @@ index 3709cccc79cd..d5158f5cce35 100644
return numrecs;
}
-@@ -507,7 +509,7 @@ xfs_getbmap(
+@@ -507,7 +509,7 @@
struct xfs_ifork *ifp;
struct xfs_bmbt_irec got, rec;
xfs_filblks_t len;
@@ -1813,7 +1802,7 @@ index 3709cccc79cd..d5158f5cce35 100644
if (bmv->bmv_iflags & ~BMV_IF_VALID)
return -EINVAL;
-@@ -611,7 +613,7 @@ xfs_getbmap(
+@@ -611,7 +613,7 @@
goto out_unlock_ilock;
}
@@ -1822,7 +1811,7 @@ index 3709cccc79cd..d5158f5cce35 100644
/*
* Report a whole-file hole if the delalloc flag is set to
* stay compatible with the old implementation.
-@@ -650,7 +652,7 @@ xfs_getbmap(
+@@ -650,7 +652,7 @@
goto out_unlock_ilock;
} while (xfs_getbmap_next_rec(&rec, bno));
@@ -1831,11 +1820,9 @@ index 3709cccc79cd..d5158f5cce35 100644
xfs_fileoff_t end = XFS_B_TO_FSB(mp, XFS_ISIZE(ip));
out[bmv->bmv_entries - 1].bmv_oflags |= BMV_OF_LAST;
-diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
-index ede4790753bc..ba35c0d0241e 100644
--- a/fs/xfs/xfs_dir2_readdir.c
+++ b/fs/xfs/xfs_dir2_readdir.c
-@@ -266,7 +266,7 @@ xfs_dir2_leaf_readbuf(
+@@ -266,7 +266,7 @@
xfs_dablk_t next_ra;
xfs_dablk_t map_off;
xfs_dablk_t last_da;
@@ -1844,7 +1831,7 @@ index ede4790753bc..ba35c0d0241e 100644
int ra_want;
int error = 0;
-@@ -283,7 +283,7 @@ xfs_dir2_leaf_readbuf(
+@@ -283,7 +283,7 @@
*/
last_da = xfs_dir2_byte_to_da(geo, XFS_DIR2_LEAF_OFFSET);
map_off = xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, *cur_off));
@@ -1853,7 +1840,7 @@ index ede4790753bc..ba35c0d0241e 100644
goto out;
if (map.br_startoff >= last_da)
goto out;
-@@ -311,7 +311,7 @@ xfs_dir2_leaf_readbuf(
+@@ -311,7 +311,7 @@
if (next_ra >= last_da)
goto out_no_ra;
if (map.br_blockcount < geo->fsbcount &&
@@ -1862,7 +1849,7 @@ index ede4790753bc..ba35c0d0241e 100644
goto out_no_ra;
if (map.br_startoff >= last_da)
goto out_no_ra;
-@@ -334,7 +334,7 @@ xfs_dir2_leaf_readbuf(
+@@ -334,7 +334,7 @@
ra_want -= geo->fsbcount;
next_ra += geo->fsbcount;
}
@@ -1871,11 +1858,29 @@ index ede4790753bc..ba35c0d0241e 100644
*ra_blk = last_da;
break;
}
-diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
-index 11fd071fed32..de747e1f71b5 100644
+--- a/fs/xfs/xfs_dquot.c
++++ b/fs/xfs/xfs_dquot.c
+@@ -703,7 +703,7 @@
+ xfs_dqid_t next_id = *id + 1; /* simple advance */
+ uint lock_flags;
+ struct xfs_bmbt_irec got;
+- xfs_extnum_t idx;
++ struct xfs_iext_cursor cur;
+ xfs_fsblock_t start;
+ int error = 0;
+
+@@ -727,7 +727,7 @@
+ return error;
+ }
+
+- if (xfs_iext_lookup_extent(quotip, &quotip->i_df, start, &idx, &got))
++ if (xfs_iext_lookup_extent(quotip, &quotip->i_df, start, &cur, &got))
+ *id = got.br_startoff * mp->m_quotainfo->qi_dqperchunk;
+ else
+ error = -ENOENT;
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
-@@ -390,7 +390,7 @@ xfs_iomap_prealloc_size(
+@@ -389,7 +389,7 @@
struct xfs_inode *ip,
loff_t offset,
loff_t count,
@@ -1884,7 +1889,7 @@ index 11fd071fed32..de747e1f71b5 100644
{
struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
-@@ -415,7 +415,7 @@ xfs_iomap_prealloc_size(
+@@ -414,7 +414,7 @@
*/
if ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ||
XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, mp->m_dalign) ||
@@ -1893,7 +1898,7 @@ index 11fd071fed32..de747e1f71b5 100644
prev.br_startoff + prev.br_blockcount < offset_fsb)
return mp->m_writeio_blocks;
-@@ -534,7 +534,7 @@ xfs_file_iomap_begin_delay(
+@@ -533,7 +533,7 @@
xfs_fileoff_t end_fsb;
int error = 0, eof = 0;
struct xfs_bmbt_irec got;
@@ -1902,7 +1907,7 @@ index 11fd071fed32..de747e1f71b5 100644
xfs_fsblock_t prealloc_blocks = 0;
ASSERT(!XFS_IS_REALTIME_INODE(ip));
-@@ -559,7 +559,7 @@ xfs_file_iomap_begin_delay(
+@@ -558,7 +558,7 @@
goto out_unlock;
}
@@ -1911,7 +1916,7 @@ index 11fd071fed32..de747e1f71b5 100644
if (!eof && got.br_startoff <= offset_fsb) {
if (xfs_is_reflink_inode(ip)) {
bool shared;
-@@ -593,7 +593,8 @@ xfs_file_iomap_begin_delay(
+@@ -592,7 +592,8 @@
end_fsb = min(XFS_B_TO_FSB(mp, offset + count), maxbytes_fsb);
if (eof) {
@@ -1921,7 +1926,7 @@ index 11fd071fed32..de747e1f71b5 100644
if (prealloc_blocks) {
xfs_extlen_t align;
xfs_off_t end_offset;
-@@ -615,7 +616,8 @@ xfs_file_iomap_begin_delay(
+@@ -614,7 +615,8 @@
retry:
error = xfs_bmapi_reserve_delalloc(ip, XFS_DATA_FORK, offset_fsb,
@@ -1931,11 +1936,9 @@ index 11fd071fed32..de747e1f71b5 100644
switch (error) {
case 0:
break;
-diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
-index 81ace8fb0379..7b0fec970185 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
-@@ -270,7 +270,7 @@ xfs_reflink_reserve_cow(
+@@ -270,7 +270,7 @@
struct xfs_bmbt_irec got;
int error = 0;
bool eof = false, trimmed;
@@ -1944,7 +1947,7 @@ index 81ace8fb0379..7b0fec970185 100644
/*
* Search the COW fork extent list first. This serves two purposes:
-@@ -281,7 +281,7 @@ xfs_reflink_reserve_cow(
+@@ -281,7 +281,7 @@
* tree.
*/
@@ -1953,7 +1956,7 @@ index 81ace8fb0379..7b0fec970185 100644
eof = true;
if (!eof && got.br_startoff <= imap->br_startoff) {
trace_xfs_reflink_cow_found(ip, imap);
-@@ -309,7 +309,7 @@ xfs_reflink_reserve_cow(
+@@ -309,7 +309,7 @@
return error;
error = xfs_bmapi_reserve_delalloc(ip, XFS_COW_FORK, imap->br_startoff,
@@ -1962,7 +1965,7 @@ index 81ace8fb0379..7b0fec970185 100644
if (error == -ENOSPC || error == -EDQUOT)
trace_xfs_reflink_cow_enospc(ip, imap);
if (error)
-@@ -356,16 +356,16 @@ xfs_reflink_convert_cow(
+@@ -356,16 +356,16 @@
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset);
xfs_fileoff_t end_fsb = XFS_B_TO_FSB(mp, offset + count);
@@ -1982,7 +1985,7 @@ index 81ace8fb0379..7b0fec970185 100644
error = xfs_reflink_convert_cow_extent(ip, &got, offset_fsb,
end_fsb - offset_fsb, &dfops);
if (error)
-@@ -396,7 +396,7 @@ xfs_reflink_allocate_cow(
+@@ -396,7 +396,7 @@
bool trimmed;
xfs_filblks_t resaligned;
xfs_extlen_t resblks = 0;
@@ -1991,7 +1994,7 @@ index 81ace8fb0379..7b0fec970185 100644
retry:
ASSERT(xfs_is_reflink_inode(ip));
-@@ -406,7 +406,7 @@ xfs_reflink_allocate_cow(
+@@ -406,7 +406,7 @@
* Even if the extent is not shared we might have a preallocation for
* it in the COW fork. If so use it.
*/
@@ -2000,7 +2003,7 @@ index 81ace8fb0379..7b0fec970185 100644
got.br_startoff <= offset_fsb) {
*shared = true;
-@@ -493,13 +493,13 @@ xfs_reflink_find_cow_mapping(
+@@ -493,13 +493,13 @@
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
xfs_fileoff_t offset_fsb;
struct xfs_bmbt_irec got;
@@ -2016,7 +2019,7 @@ index 81ace8fb0379..7b0fec970185 100644
return false;
if (got.br_startoff > offset_fsb)
return false;
-@@ -521,18 +521,18 @@ xfs_reflink_trim_irec_to_next_cow(
+@@ -521,18 +521,18 @@
{
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
struct xfs_bmbt_irec got;
@@ -2038,7 +2041,7 @@ index 81ace8fb0379..7b0fec970185 100644
return;
}
-@@ -559,14 +559,14 @@ xfs_reflink_cancel_cow_blocks(
+@@ -559,14 +559,14 @@
{
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_COW_FORK);
struct xfs_bmbt_irec got, del;
@@ -2055,7 +2058,7 @@ index 81ace8fb0379..7b0fec970185 100644
return 0;
while (got.br_startoff < end_fsb) {
-@@ -576,7 +576,7 @@ xfs_reflink_cancel_cow_blocks(
+@@ -576,7 +576,7 @@
if (isnullstartblock(del.br_startblock)) {
error = xfs_bmap_del_extent_delay(ip, XFS_COW_FORK,
@@ -2064,7 +2067,7 @@ index 81ace8fb0379..7b0fec970185 100644
if (error)
break;
} else if (del.br_state == XFS_EXT_UNWRITTEN || cancel_real) {
-@@ -606,10 +606,10 @@ xfs_reflink_cancel_cow_blocks(
+@@ -606,10 +606,10 @@
}
/* Remove the mapping from the CoW fork. */
@@ -2077,7 +2080,7 @@ index 81ace8fb0379..7b0fec970185 100644
break;
}
-@@ -694,7 +694,7 @@ xfs_reflink_end_cow(
+@@ -694,7 +694,7 @@
int error;
unsigned int resblks;
xfs_filblks_t rlen;
@@ -2086,7 +2089,7 @@ index 81ace8fb0379..7b0fec970185 100644
trace_xfs_reflink_end_cow(ip, offset, count);
-@@ -734,7 +734,7 @@ xfs_reflink_end_cow(
+@@ -734,7 +734,7 @@
* left by the time I/O completes for the loser of the race. In that
* case we are done.
*/
@@ -2095,7 +2098,7 @@ index 81ace8fb0379..7b0fec970185 100644
goto out_cancel;
/* Walk backwards until we're out of the I/O range... */
-@@ -742,9 +742,9 @@ xfs_reflink_end_cow(
+@@ -742,9 +742,9 @@
del = got;
xfs_trim_extent(&del, offset_fsb, end_fsb - offset_fsb);
@@ -2107,7 +2110,7 @@ index 81ace8fb0379..7b0fec970185 100644
goto next_extent;
}
-@@ -756,7 +756,7 @@ xfs_reflink_end_cow(
+@@ -756,7 +756,7 @@
* allocated but have not yet been involved in a write.
*/
if (got.br_state == XFS_EXT_UNWRITTEN) {
@@ -2116,7 +2119,7 @@ index 81ace8fb0379..7b0fec970185 100644
goto next_extent;
}
-@@ -787,13 +787,13 @@ xfs_reflink_end_cow(
+@@ -787,13 +787,13 @@
goto out_defer;
/* Remove the mapping from the CoW fork. */
@@ -2132,11 +2135,9 @@ index 81ace8fb0379..7b0fec970185 100644
break;
}
-diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h
-index d3698fb84ad6..02e044b8bee2 100644
--- a/fs/xfs/xfs_trace.h
+++ b/fs/xfs/xfs_trace.h
-@@ -258,9 +258,9 @@ TRACE_EVENT(xfs_iext_insert,
+@@ -258,9 +258,9 @@
);
DECLARE_EVENT_CLASS(xfs_bmap_class,
@@ -2148,7 +2149,7 @@ index d3698fb84ad6..02e044b8bee2 100644
TP_STRUCT__entry(
__field(dev_t, dev)
__field(xfs_ino_t, ino)
-@@ -277,10 +277,10 @@ DECLARE_EVENT_CLASS(xfs_bmap_class,
+@@ -277,10 +277,10 @@
struct xfs_bmbt_irec r;
ifp = xfs_iext_state_to_fork(ip, state);
@@ -2161,7 +2162,7 @@ index d3698fb84ad6..02e044b8bee2 100644
__entry->startoff = r.br_startoff;
__entry->startblock = r.br_startblock;
__entry->blockcount = r.br_blockcount;
-@@ -303,9 +303,9 @@ DECLARE_EVENT_CLASS(xfs_bmap_class,
+@@ -303,9 +303,9 @@
#define DEFINE_BMAP_EVENT(name) \
DEFINE_EVENT(xfs_bmap_class, name, \
@@ -2173,6 +2174,3 @@ index d3698fb84ad6..02e044b8bee2 100644
DEFINE_BMAP_EVENT(xfs_iext_remove);
DEFINE_BMAP_EVENT(xfs_bmap_pre_update);
DEFINE_BMAP_EVENT(xfs_bmap_post_update);
---
-2.7.4
-
diff --git a/patches.fixes/xfs-rewrite-xfs_dq_get_next_id-using-xfs_iext_lookup.patch b/patches.fixes/xfs-rewrite-xfs_dq_get_next_id-using-xfs_iext_lookup.patch
new file mode 100644
index 0000000000..8511bc482f
--- /dev/null
+++ b/patches.fixes/xfs-rewrite-xfs_dq_get_next_id-using-xfs_iext_lookup.patch
@@ -0,0 +1,153 @@
+From bda250dbaf39f67f8910e183853e4e6a9e5ce899 Mon Sep 17 00:00:00 2001
+From: Christoph Hellwig <hch@lst.de>
+Date: Thu, 29 Jun 2017 12:28:36 -0700
+Subject: [PATCH] xfs: rewrite xfs_dq_get_next_id using xfs_iext_lookup_extent
+Git-commit: bda250dbaf39f67f8910e183853e4e6a9e5ce899
+Patch-mainline: v4.13-rc1
+References: bsc#1070995
+
+This goes straight to a single lookup in the extent list and avoids a
+roundtrip through two layers that don't add any value for the simple
+quoata file that just has data or holes and no page cache, delayed
+allocation, unwritten extent or COW fork (which btw, doesn't seem to
+be handled by the existing SEEK HOLE/DATA code).
+
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Reviewed-by: Eric Sandeen <sandeen@redhat.com>
+Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
+Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
+Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>
+
+---
+ fs/xfs/xfs_dquot.c | 66 ++++++++++++++++++------------------------------------
+ 1 file changed, 22 insertions(+), 44 deletions(-)
+
+diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
+index 79668142afc1..8848b397e7a8 100644
+--- a/fs/xfs/xfs_dquot.c
++++ b/fs/xfs/xfs_dquot.c
+@@ -701,21 +701,18 @@ xfs_qm_dqread(
+ */
+ static int
+ xfs_dq_get_next_id(
+- xfs_mount_t *mp,
++ struct xfs_mount *mp,
+ uint type,
+- xfs_dqid_t *id,
+- loff_t eof)
++ xfs_dqid_t *id)
+ {
+- struct xfs_inode *quotip;
++ struct xfs_inode *quotip = xfs_quota_inode(mp, type);
++ xfs_dqid_t next_id = *id + 1; /* simple advance */
++ uint lock_flags;
++ struct xfs_bmbt_irec got;
++ xfs_extnum_t idx;
+ xfs_fsblock_t start;
+- loff_t offset;
+- uint lock;
+- xfs_dqid_t next_id;
+ int error = 0;
+
+- /* Simple advance */
+- next_id = *id + 1;
+-
+ /* If we'd wrap past the max ID, stop */
+ if (next_id < *id)
+ return -ENOENT;
+@@ -729,23 +726,20 @@ xfs_dq_get_next_id(
+ /* Nope, next_id is now past the current chunk, so find the next one */
+ start = (xfs_fsblock_t)next_id / mp->m_quotainfo->qi_dqperchunk;
+
+- quotip = xfs_quota_inode(mp, type);
+- lock = xfs_ilock_data_map_shared(quotip);
+-
+- offset = __xfs_seek_hole_data(VFS_I(quotip), XFS_FSB_TO_B(mp, start),
+- eof, SEEK_DATA);
+- if (offset < 0)
+- error = offset;
+-
+- xfs_iunlock(quotip, lock);
++ lock_flags = xfs_ilock_data_map_shared(quotip);
++ if (!(quotip->i_df.if_flags & XFS_IFEXTENTS)) {
++ error = xfs_iread_extents(NULL, quotip, XFS_DATA_FORK);
++ if (error)
++ return error;
++ }
+
+- /* -ENXIO is essentially "no more data" */
+- if (error)
+- return (error == -ENXIO ? -ENOENT: error);
++ if (xfs_iext_lookup_extent(quotip, &quotip->i_df, start, &idx, &got))
++ *id = got.br_startoff * mp->m_quotainfo->qi_dqperchunk;
++ else
++ error = -ENOENT;
++ xfs_iunlock(quotip, lock_flags);
+
+- /* Convert next data offset back to a quota id */
+- *id = XFS_B_TO_FSB(mp, offset) * mp->m_quotainfo->qi_dqperchunk;
+- return 0;
++ return error;
+ }
+
+ /*
+@@ -768,7 +762,6 @@ xfs_qm_dqget(
+ struct xfs_quotainfo *qi = mp->m_quotainfo;
+ struct radix_tree_root *tree = xfs_dquot_tree(qi, type);
+ struct xfs_dquot *dqp;
+- loff_t eof = 0;
+ int error;
+
+ ASSERT(XFS_IS_QUOTA_RUNNING(mp));
+@@ -796,21 +789,6 @@ xfs_qm_dqget(
+ }
+ #endif
+
+- /* Get the end of the quota file if we need it */
+- if (flags & XFS_QMOPT_DQNEXT) {
+- struct xfs_inode *quotip;
+- xfs_fileoff_t last;
+- uint lock_mode;
+-
+- quotip = xfs_quota_inode(mp, type);
+- lock_mode = xfs_ilock_data_map_shared(quotip);
+- error = xfs_bmap_last_offset(quotip, &last, XFS_DATA_FORK);
+- xfs_iunlock(quotip, lock_mode);
+- if (error)
+- return error;
+- eof = XFS_FSB_TO_B(mp, last);
+- }
+-
+ restart:
+ mutex_lock(&qi->qi_tree_lock);
+ dqp = radix_tree_lookup(tree, id);
+@@ -829,7 +807,7 @@ xfs_qm_dqget(
+ if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) {
+ xfs_dqunlock(dqp);
+ mutex_unlock(&qi->qi_tree_lock);
+- error = xfs_dq_get_next_id(mp, type, &id, eof);
++ error = xfs_dq_get_next_id(mp, type, &id);
+ if (error)
+ return error;
+ goto restart;
+@@ -864,7 +842,7 @@ xfs_qm_dqget(
+
+ /* If we are asked to find next active id, keep looking */
+ if (error == -ENOENT && (flags & XFS_QMOPT_DQNEXT)) {
+- error = xfs_dq_get_next_id(mp, type, &id, eof);
++ error = xfs_dq_get_next_id(mp, type, &id);
+ if (!error)
+ goto restart;
+ }
+@@ -923,7 +901,7 @@ xfs_qm_dqget(
+ if (flags & XFS_QMOPT_DQNEXT) {
+ if (XFS_IS_DQUOT_UNINITIALIZED(dqp)) {
+ xfs_qm_dqput(dqp);
+- error = xfs_dq_get_next_id(mp, type, &id, eof);
++ error = xfs_dq_get_next_id(mp, type, &id);
+ if (error)
+ return error;
+ goto restart;
+--
+2.16.4
+
diff --git a/series.conf b/series.conf
index 5da70910b1..aefb0cdee6 100644
--- a/series.conf
+++ b/series.conf
@@ -3559,6 +3559,7 @@
patches.fixes/xfs-remove-bli-from-AIL-before-release-on-transactio.patch
patches.fixes/xfs-remove-double-underscore-integer-types.patch
patches.fixes/xfs-check-if-an-inode-is-cached-and-allocated.patch
+ patches.fixes/xfs-rewrite-xfs_dq_get_next_id-using-xfs_iext_lookup.patch
patches.fixes/vfs-Add-page_cache_seek_hole_data-helper.patch
patches.fixes/vfs-Add-iomap_seek_hole-and-iomap_seek_data-helpers.patch
patches.fixes/xfs-Switch-to-iomap-for-SEEK_HOLE-SEEK_DATA.patch