aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c36
-rw-r--r--fs/xfs/libxfs/xfs_refcount.c9
-rw-r--r--fs/xfs/libxfs/xfs_rmap.c33
-rw-r--r--fs/xfs/libxfs/xfs_rmap.h10
4 files changed, 36 insertions, 52 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 65f4348af9ae..e82a3ff345af 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -1985,11 +1985,8 @@ xfs_bmap_add_extent_delay_real(
1985 } 1985 }
1986 1986
1987 /* add reverse mapping unless caller opted out */ 1987 /* add reverse mapping unless caller opted out */
1988 if (!(bma->flags & XFS_BMAPI_NORMAP)) { 1988 if (!(bma->flags & XFS_BMAPI_NORMAP))
1989 error = xfs_rmap_map_extent(bma->tp, bma->ip, whichfork, new); 1989 xfs_rmap_map_extent(bma->tp, bma->ip, whichfork, new);
1990 if (error)
1991 goto done;
1992 }
1993 1990
1994 /* convert to a btree if necessary */ 1991 /* convert to a btree if necessary */
1995 if (xfs_bmap_needs_btree(bma->ip, whichfork)) { 1992 if (xfs_bmap_needs_btree(bma->ip, whichfork)) {
@@ -2471,9 +2468,7 @@ xfs_bmap_add_extent_unwritten_real(
2471 } 2468 }
2472 2469
2473 /* update reverse mappings */ 2470 /* update reverse mappings */
2474 error = xfs_rmap_convert_extent(mp, tp, ip, whichfork, new); 2471 xfs_rmap_convert_extent(mp, tp, ip, whichfork, new);
2475 if (error)
2476 goto done;
2477 2472
2478 /* convert to a btree if necessary */ 2473 /* convert to a btree if necessary */
2479 if (xfs_bmap_needs_btree(ip, whichfork)) { 2474 if (xfs_bmap_needs_btree(ip, whichfork)) {
@@ -2832,11 +2827,8 @@ xfs_bmap_add_extent_hole_real(
2832 } 2827 }
2833 2828
2834 /* add reverse mapping unless caller opted out */ 2829 /* add reverse mapping unless caller opted out */
2835 if (!(flags & XFS_BMAPI_NORMAP)) { 2830 if (!(flags & XFS_BMAPI_NORMAP))
2836 error = xfs_rmap_map_extent(tp, ip, whichfork, new); 2831 xfs_rmap_map_extent(tp, ip, whichfork, new);
2837 if (error)
2838 goto done;
2839 }
2840 2832
2841 /* convert to a btree if necessary */ 2833 /* convert to a btree if necessary */
2842 if (xfs_bmap_needs_btree(ip, whichfork)) { 2834 if (xfs_bmap_needs_btree(ip, whichfork)) {
@@ -5149,9 +5141,7 @@ xfs_bmap_del_extent_real(
5149 } 5141 }
5150 5142
5151 /* remove reverse mapping */ 5143 /* remove reverse mapping */
5152 error = xfs_rmap_unmap_extent(tp, ip, whichfork, del); 5144 xfs_rmap_unmap_extent(tp, ip, whichfork, del);
5153 if (error)
5154 goto done;
5155 5145
5156 /* 5146 /*
5157 * If we need to, add to list of extents to delete. 5147 * If we need to, add to list of extents to delete.
@@ -5651,12 +5641,11 @@ done:
5651 &new); 5641 &new);
5652 5642
5653 /* update reverse mapping. rmap functions merge the rmaps for us */ 5643 /* update reverse mapping. rmap functions merge the rmaps for us */
5654 error = xfs_rmap_unmap_extent(tp, ip, whichfork, got); 5644 xfs_rmap_unmap_extent(tp, ip, whichfork, got);
5655 if (error)
5656 return error;
5657 memcpy(&new, got, sizeof(new)); 5645 memcpy(&new, got, sizeof(new));
5658 new.br_startoff = left->br_startoff + left->br_blockcount; 5646 new.br_startoff = left->br_startoff + left->br_blockcount;
5659 return xfs_rmap_map_extent(tp, ip, whichfork, &new); 5647 xfs_rmap_map_extent(tp, ip, whichfork, &new);
5648 return 0;
5660} 5649}
5661 5650
5662static int 5651static int
@@ -5695,10 +5684,9 @@ xfs_bmap_shift_update_extent(
5695 got); 5684 got);
5696 5685
5697 /* update reverse mapping */ 5686 /* update reverse mapping */
5698 error = xfs_rmap_unmap_extent(tp, ip, whichfork, &prev); 5687 xfs_rmap_unmap_extent(tp, ip, whichfork, &prev);
5699 if (error) 5688 xfs_rmap_map_extent(tp, ip, whichfork, got);
5700 return error; 5689 return 0;
5701 return xfs_rmap_map_extent(tp, ip, whichfork, got);
5702} 5690}
5703 5691
5704int 5692int
diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c
index 14b9e3e056cc..a5edac834843 100644
--- a/fs/xfs/libxfs/xfs_refcount.c
+++ b/fs/xfs/libxfs/xfs_refcount.c
@@ -1558,8 +1558,9 @@ xfs_refcount_alloc_cow_extent(
1558 return error; 1558 return error;
1559 1559
1560 /* Add rmap entry */ 1560 /* Add rmap entry */
1561 return xfs_rmap_alloc_extent(tp, XFS_FSB_TO_AGNO(mp, fsb), 1561 xfs_rmap_alloc_extent(tp, XFS_FSB_TO_AGNO(mp, fsb),
1562 XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW); 1562 XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW);
1563 return 0;
1563} 1564}
1564 1565
1565/* Forget a CoW staging event in the refcount btree. */ 1566/* Forget a CoW staging event in the refcount btree. */
@@ -1570,17 +1571,13 @@ xfs_refcount_free_cow_extent(
1570 xfs_extlen_t len) 1571 xfs_extlen_t len)
1571{ 1572{
1572 struct xfs_mount *mp = tp->t_mountp; 1573 struct xfs_mount *mp = tp->t_mountp;
1573 int error;
1574 1574
1575 if (!xfs_sb_version_hasreflink(&mp->m_sb)) 1575 if (!xfs_sb_version_hasreflink(&mp->m_sb))
1576 return 0; 1576 return 0;
1577 1577
1578 /* Remove rmap entry */ 1578 /* Remove rmap entry */
1579 error = xfs_rmap_free_extent(tp, XFS_FSB_TO_AGNO(mp, fsb), 1579 xfs_rmap_free_extent(tp, XFS_FSB_TO_AGNO(mp, fsb),
1580 XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW); 1580 XFS_FSB_TO_AGBNO(mp, fsb), len, XFS_RMAP_OWN_COW);
1581 if (error)
1582 return error;
1583
1584 return __xfs_refcount_add(tp, XFS_REFCOUNT_FREE_COW, fsb, len); 1581 return __xfs_refcount_add(tp, XFS_REFCOUNT_FREE_COW, fsb, len);
1585} 1582}
1586 1583
diff --git a/fs/xfs/libxfs/xfs_rmap.c b/fs/xfs/libxfs/xfs_rmap.c
index 0769aca4192b..28c87ead80ba 100644
--- a/fs/xfs/libxfs/xfs_rmap.c
+++ b/fs/xfs/libxfs/xfs_rmap.c
@@ -2268,7 +2268,7 @@ xfs_rmap_update_is_needed(
2268 * Record a rmap intent; the list is kept sorted first by AG and then by 2268 * Record a rmap intent; the list is kept sorted first by AG and then by
2269 * increasing age. 2269 * increasing age.
2270 */ 2270 */
2271static int 2271static void
2272__xfs_rmap_add( 2272__xfs_rmap_add(
2273 struct xfs_trans *tp, 2273 struct xfs_trans *tp,
2274 enum xfs_rmap_intent_type type, 2274 enum xfs_rmap_intent_type type,
@@ -2295,11 +2295,10 @@ __xfs_rmap_add(
2295 ri->ri_bmap = *bmap; 2295 ri->ri_bmap = *bmap;
2296 2296
2297 xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_RMAP, &ri->ri_list); 2297 xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_RMAP, &ri->ri_list);
2298 return 0;
2299} 2298}
2300 2299
2301/* Map an extent into a file. */ 2300/* Map an extent into a file. */
2302int 2301void
2303xfs_rmap_map_extent( 2302xfs_rmap_map_extent(
2304 struct xfs_trans *tp, 2303 struct xfs_trans *tp,
2305 struct xfs_inode *ip, 2304 struct xfs_inode *ip,
@@ -2307,15 +2306,15 @@ xfs_rmap_map_extent(
2307 struct xfs_bmbt_irec *PREV) 2306 struct xfs_bmbt_irec *PREV)
2308{ 2307{
2309 if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork)) 2308 if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork))
2310 return 0; 2309 return;
2311 2310
2312 return __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ? 2311 __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ?
2313 XFS_RMAP_MAP_SHARED : XFS_RMAP_MAP, ip->i_ino, 2312 XFS_RMAP_MAP_SHARED : XFS_RMAP_MAP, ip->i_ino,
2314 whichfork, PREV); 2313 whichfork, PREV);
2315} 2314}
2316 2315
2317/* Unmap an extent out of a file. */ 2316/* Unmap an extent out of a file. */
2318int 2317void
2319xfs_rmap_unmap_extent( 2318xfs_rmap_unmap_extent(
2320 struct xfs_trans *tp, 2319 struct xfs_trans *tp,
2321 struct xfs_inode *ip, 2320 struct xfs_inode *ip,
@@ -2323,9 +2322,9 @@ xfs_rmap_unmap_extent(
2323 struct xfs_bmbt_irec *PREV) 2322 struct xfs_bmbt_irec *PREV)
2324{ 2323{
2325 if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork)) 2324 if (!xfs_rmap_update_is_needed(tp->t_mountp, whichfork))
2326 return 0; 2325 return;
2327 2326
2328 return __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ? 2327 __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ?
2329 XFS_RMAP_UNMAP_SHARED : XFS_RMAP_UNMAP, ip->i_ino, 2328 XFS_RMAP_UNMAP_SHARED : XFS_RMAP_UNMAP, ip->i_ino,
2330 whichfork, PREV); 2329 whichfork, PREV);
2331} 2330}
@@ -2336,7 +2335,7 @@ xfs_rmap_unmap_extent(
2336 * Note that tp can be NULL here as no transaction is used for COW fork 2335 * Note that tp can be NULL here as no transaction is used for COW fork
2337 * unwritten conversion. 2336 * unwritten conversion.
2338 */ 2337 */
2339int 2338void
2340xfs_rmap_convert_extent( 2339xfs_rmap_convert_extent(
2341 struct xfs_mount *mp, 2340 struct xfs_mount *mp,
2342 struct xfs_trans *tp, 2341 struct xfs_trans *tp,
@@ -2345,15 +2344,15 @@ xfs_rmap_convert_extent(
2345 struct xfs_bmbt_irec *PREV) 2344 struct xfs_bmbt_irec *PREV)
2346{ 2345{
2347 if (!xfs_rmap_update_is_needed(mp, whichfork)) 2346 if (!xfs_rmap_update_is_needed(mp, whichfork))
2348 return 0; 2347 return;
2349 2348
2350 return __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ? 2349 __xfs_rmap_add(tp, xfs_is_reflink_inode(ip) ?
2351 XFS_RMAP_CONVERT_SHARED : XFS_RMAP_CONVERT, ip->i_ino, 2350 XFS_RMAP_CONVERT_SHARED : XFS_RMAP_CONVERT, ip->i_ino,
2352 whichfork, PREV); 2351 whichfork, PREV);
2353} 2352}
2354 2353
2355/* Schedule the creation of an rmap for non-file data. */ 2354/* Schedule the creation of an rmap for non-file data. */
2356int 2355void
2357xfs_rmap_alloc_extent( 2356xfs_rmap_alloc_extent(
2358 struct xfs_trans *tp, 2357 struct xfs_trans *tp,
2359 xfs_agnumber_t agno, 2358 xfs_agnumber_t agno,
@@ -2364,18 +2363,18 @@ xfs_rmap_alloc_extent(
2364 struct xfs_bmbt_irec bmap; 2363 struct xfs_bmbt_irec bmap;
2365 2364
2366 if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK)) 2365 if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK))
2367 return 0; 2366 return;
2368 2367
2369 bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno); 2368 bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno);
2370 bmap.br_blockcount = len; 2369 bmap.br_blockcount = len;
2371 bmap.br_startoff = 0; 2370 bmap.br_startoff = 0;
2372 bmap.br_state = XFS_EXT_NORM; 2371 bmap.br_state = XFS_EXT_NORM;
2373 2372
2374 return __xfs_rmap_add(tp, XFS_RMAP_ALLOC, owner, XFS_DATA_FORK, &bmap); 2373 __xfs_rmap_add(tp, XFS_RMAP_ALLOC, owner, XFS_DATA_FORK, &bmap);
2375} 2374}
2376 2375
2377/* Schedule the deletion of an rmap for non-file data. */ 2376/* Schedule the deletion of an rmap for non-file data. */
2378int 2377void
2379xfs_rmap_free_extent( 2378xfs_rmap_free_extent(
2380 struct xfs_trans *tp, 2379 struct xfs_trans *tp,
2381 xfs_agnumber_t agno, 2380 xfs_agnumber_t agno,
@@ -2386,14 +2385,14 @@ xfs_rmap_free_extent(
2386 struct xfs_bmbt_irec bmap; 2385 struct xfs_bmbt_irec bmap;
2387 2386
2388 if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK)) 2387 if (!xfs_rmap_update_is_needed(tp->t_mountp, XFS_DATA_FORK))
2389 return 0; 2388 return;
2390 2389
2391 bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno); 2390 bmap.br_startblock = XFS_AGB_TO_FSB(tp->t_mountp, agno, bno);
2392 bmap.br_blockcount = len; 2391 bmap.br_blockcount = len;
2393 bmap.br_startoff = 0; 2392 bmap.br_startoff = 0;
2394 bmap.br_state = XFS_EXT_NORM; 2393 bmap.br_state = XFS_EXT_NORM;
2395 2394
2396 return __xfs_rmap_add(tp, XFS_RMAP_FREE, owner, XFS_DATA_FORK, &bmap); 2395 __xfs_rmap_add(tp, XFS_RMAP_FREE, owner, XFS_DATA_FORK, &bmap);
2397} 2396}
2398 2397
2399/* Compare rmap records. Returns -1 if a < b, 1 if a > b, and 0 if equal. */ 2398/* Compare rmap records. Returns -1 if a < b, 1 if a > b, and 0 if equal. */
diff --git a/fs/xfs/libxfs/xfs_rmap.h b/fs/xfs/libxfs/xfs_rmap.h
index e21ed0294e5c..0c2c3cb73429 100644
--- a/fs/xfs/libxfs/xfs_rmap.h
+++ b/fs/xfs/libxfs/xfs_rmap.h
@@ -161,16 +161,16 @@ struct xfs_rmap_intent {
161}; 161};
162 162
163/* functions for updating the rmapbt based on bmbt map/unmap operations */ 163/* functions for updating the rmapbt based on bmbt map/unmap operations */
164int xfs_rmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip, 164void xfs_rmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
165 int whichfork, struct xfs_bmbt_irec *imap); 165 int whichfork, struct xfs_bmbt_irec *imap);
166int xfs_rmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip, 166void xfs_rmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,
167 int whichfork, struct xfs_bmbt_irec *imap); 167 int whichfork, struct xfs_bmbt_irec *imap);
168int xfs_rmap_convert_extent(struct xfs_mount *mp, struct xfs_trans *tp, 168void xfs_rmap_convert_extent(struct xfs_mount *mp, struct xfs_trans *tp,
169 struct xfs_inode *ip, int whichfork, 169 struct xfs_inode *ip, int whichfork,
170 struct xfs_bmbt_irec *imap); 170 struct xfs_bmbt_irec *imap);
171int xfs_rmap_alloc_extent(struct xfs_trans *tp, xfs_agnumber_t agno, 171void xfs_rmap_alloc_extent(struct xfs_trans *tp, xfs_agnumber_t agno,
172 xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner); 172 xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner);
173int xfs_rmap_free_extent(struct xfs_trans *tp, xfs_agnumber_t agno, 173void xfs_rmap_free_extent(struct xfs_trans *tp, xfs_agnumber_t agno,
174 xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner); 174 xfs_agblock_t bno, xfs_extlen_t len, uint64_t owner);
175 175
176void xfs_rmap_finish_one_cleanup(struct xfs_trans *tp, 176void xfs_rmap_finish_one_cleanup(struct xfs_trans *tp,