Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'xfs-4.17-merge-4' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux

Pull more xfs updates from Darrick Wong:
"Most of these are code cleanups, but there are a couple of notable
use-after-free bug fixes.

This series has been run through a full xfstests run over the week and
through a quick xfstests run against this morning's master, with no
major failures reported.

- clean up unnecessary function call parameters

- fix a use-after-free bug when aborting logging intents

- refactor filestreams state data to avoid use-after-free bug

- fix incorrect removal of cow extents when truncating extended
attributes.

- refactor open-coded __set_page_dirty in favor of using vfs
function.

- fix a deadlock when fstrim and fs shutdown race"

* tag 'xfs-4.17-merge-4' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
Force log to disk before reading the AGF during a fstrim
Export __set_page_dirty
xfs: only cancel cow blocks when truncating the data fork
xfs: non-scrub - remove unused function parameters
xfs: remove filestream item xfs_inode reference
xfs: fix intent use-after-free on abort
xfs: Remove "committed" argument of xfs_dir_ialloc

+172 -205
+2 -4
fs/xfs/libxfs/xfs_alloc.c
··· 1947 1947 xfs_alloc_compute_maxlevels( 1948 1948 xfs_mount_t *mp) /* file system mount structure */ 1949 1949 { 1950 - mp->m_ag_maxlevels = xfs_btree_compute_maxlevels(mp, mp->m_alloc_mnr, 1950 + mp->m_ag_maxlevels = xfs_btree_compute_maxlevels(mp->m_alloc_mnr, 1951 1951 (mp->m_sb.sb_agblocks + 1) / 2); 1952 1952 } 1953 1953 ··· 1959 1959 */ 1960 1960 xfs_extlen_t 1961 1961 xfs_alloc_longest_free_extent( 1962 - struct xfs_mount *mp, 1963 1962 struct xfs_perag *pag, 1964 1963 xfs_extlen_t need, 1965 1964 xfs_extlen_t reserved) ··· 2037 2038 2038 2039 /* do we have enough contiguous free space for the allocation? */ 2039 2040 alloc_len = args->minlen + (args->alignment - 1) + args->minalignslop; 2040 - longest = xfs_alloc_longest_free_extent(args->mp, pag, min_free, 2041 - reservation); 2041 + longest = xfs_alloc_longest_free_extent(pag, min_free, reservation); 2042 2042 if (longest < alloc_len) 2043 2043 return false; 2044 2044
+2 -3
fs/xfs/libxfs/xfs_alloc.h
··· 116 116 unsigned int xfs_alloc_set_aside(struct xfs_mount *mp); 117 117 unsigned int xfs_alloc_ag_max_usable(struct xfs_mount *mp); 118 118 119 - xfs_extlen_t xfs_alloc_longest_free_extent(struct xfs_mount *mp, 120 - struct xfs_perag *pag, xfs_extlen_t need, 121 - xfs_extlen_t reserved); 119 + xfs_extlen_t xfs_alloc_longest_free_extent(struct xfs_perag *pag, 120 + xfs_extlen_t need, xfs_extlen_t reserved); 122 121 unsigned int xfs_alloc_min_freelist(struct xfs_mount *mp, 123 122 struct xfs_perag *pag); 124 123
+1 -2
fs/xfs/libxfs/xfs_bmap.c
··· 3225 3225 } 3226 3226 } 3227 3227 3228 - longest = xfs_alloc_longest_free_extent(mp, pag, 3228 + longest = xfs_alloc_longest_free_extent(pag, 3229 3229 xfs_alloc_min_freelist(mp, pag), 3230 3230 xfs_ag_resv_needed(pag, XFS_AG_RESV_NONE)); 3231 3231 if (*blen < longest) ··· 5667 5667 xfs_fileoff_t *next_fsb, 5668 5668 xfs_fileoff_t offset_shift_fsb, 5669 5669 bool *done, 5670 - xfs_fileoff_t stop_fsb, 5671 5670 xfs_fsblock_t *firstblock, 5672 5671 struct xfs_defer_ops *dfops) 5673 5672 {
+1 -1
fs/xfs/libxfs/xfs_bmap.h
··· 228 228 uint xfs_default_attroffset(struct xfs_inode *ip); 229 229 int xfs_bmap_collapse_extents(struct xfs_trans *tp, struct xfs_inode *ip, 230 230 xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb, 231 - bool *done, xfs_fileoff_t stop_fsb, xfs_fsblock_t *firstblock, 231 + bool *done, xfs_fsblock_t *firstblock, 232 232 struct xfs_defer_ops *dfops); 233 233 int xfs_bmap_insert_extents(struct xfs_trans *tp, struct xfs_inode *ip, 234 234 xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
-2
fs/xfs/libxfs/xfs_btree.c
··· 4531 4531 */ 4532 4532 uint 4533 4533 xfs_btree_compute_maxlevels( 4534 - struct xfs_mount *mp, 4535 4534 uint *limits, 4536 4535 unsigned long len) 4537 4536 { ··· 4838 4839 */ 4839 4840 xfs_extlen_t 4840 4841 xfs_btree_calc_size( 4841 - struct xfs_mount *mp, 4842 4842 uint *limits, 4843 4843 unsigned long long len) 4844 4844 {
+2 -4
fs/xfs/libxfs/xfs_btree.h
··· 481 481 xfs_failaddr_t xfs_btree_lblock_verify(struct xfs_buf *bp, 482 482 unsigned int max_recs); 483 483 484 - uint xfs_btree_compute_maxlevels(struct xfs_mount *mp, uint *limits, 485 - unsigned long len); 486 - xfs_extlen_t xfs_btree_calc_size(struct xfs_mount *mp, uint *limits, 487 - unsigned long long len); 484 + uint xfs_btree_compute_maxlevels(uint *limits, unsigned long len); 485 + xfs_extlen_t xfs_btree_calc_size(uint *limits, unsigned long long len); 488 486 489 487 /* return codes */ 490 488 #define XFS_BTREE_QUERY_RANGE_CONTINUE 0 /* keep iterating */
+1 -1
fs/xfs/libxfs/xfs_ialloc.c
··· 2406 2406 uint inodes; 2407 2407 2408 2408 inodes = (1LL << XFS_INO_AGINO_BITS(mp)) >> XFS_INODES_PER_CHUNK_LOG; 2409 - mp->m_in_maxlevels = xfs_btree_compute_maxlevels(mp, mp->m_inobt_mnr, 2409 + mp->m_in_maxlevels = xfs_btree_compute_maxlevels(mp->m_inobt_mnr, 2410 2410 inodes); 2411 2411 } 2412 2412
+1 -1
fs/xfs/libxfs/xfs_ialloc_btree.c
··· 556 556 if (mp->m_inobt_mxr[0] == 0) 557 557 return 0; 558 558 559 - return xfs_btree_calc_size(mp, mp->m_inobt_mnr, 559 + return xfs_btree_calc_size(mp->m_inobt_mnr, 560 560 (uint64_t)mp->m_sb.sb_agblocks * mp->m_sb.sb_inopblock / 561 561 XFS_INODES_PER_CHUNK); 562 562 }
+8 -14
fs/xfs/libxfs/xfs_refcount.c
··· 351 351 struct xfs_refcount_irec *center, 352 352 struct xfs_refcount_irec *right, 353 353 unsigned long long extlen, 354 - xfs_agblock_t *agbno, 355 354 xfs_extlen_t *aglen) 356 355 { 357 356 int error; ··· 470 471 struct xfs_btree_cur *cur, 471 472 struct xfs_refcount_irec *right, 472 473 struct xfs_refcount_irec *cright, 473 - xfs_agblock_t *agbno, 474 474 xfs_extlen_t *aglen) 475 475 { 476 476 int error; ··· 747 749 ulen < MAXREFCEXTLEN) { 748 750 *shape_changed = true; 749 751 return xfs_refcount_merge_center_extents(cur, &left, &cleft, 750 - &right, ulen, agbno, aglen); 752 + &right, ulen, aglen); 751 753 } 752 754 753 755 /* Try to merge left and cleft. */ ··· 776 778 ulen < MAXREFCEXTLEN) { 777 779 *shape_changed = true; 778 780 return xfs_refcount_merge_right_extent(cur, &right, &cright, 779 - agbno, aglen); 781 + aglen); 780 782 } 781 783 782 784 return error; ··· 1354 1356 struct xfs_btree_cur *cur, 1355 1357 xfs_agblock_t agbno, 1356 1358 xfs_extlen_t aglen, 1357 - enum xfs_refc_adjust_op adj, 1358 - struct xfs_defer_ops *dfops, 1359 - struct xfs_owner_info *oinfo) 1359 + enum xfs_refc_adjust_op adj) 1360 1360 { 1361 1361 struct xfs_refcount_irec ext, tmp; 1362 1362 int error; ··· 1433 1437 struct xfs_btree_cur *cur, 1434 1438 xfs_agblock_t agbno, 1435 1439 xfs_extlen_t aglen, 1436 - enum xfs_refc_adjust_op adj, 1437 - struct xfs_defer_ops *dfops) 1440 + enum xfs_refc_adjust_op adj) 1438 1441 { 1439 1442 bool shape_changed; 1440 1443 int error; ··· 1460 1465 goto out_error; 1461 1466 1462 1467 /* Now that we've taken care of the ends, adjust the middle extents */ 1463 - error = xfs_refcount_adjust_cow_extents(cur, agbno, aglen, adj, 1464 - dfops, NULL); 1468 + error = xfs_refcount_adjust_cow_extents(cur, agbno, aglen, adj); 1465 1469 if (error) 1466 1470 goto out_error; 1467 1471 ··· 1487 1493 1488 1494 /* Add refcount btree reservation */ 1489 1495 return xfs_refcount_adjust_cow(rcur, agbno, aglen, 1490 - XFS_REFCOUNT_ADJUST_COW_ALLOC, dfops); 1496 + XFS_REFCOUNT_ADJUST_COW_ALLOC); 1491 1497 } 1492 1498 1493 1499 /* ··· 1505 1511 1506 1512 /* Remove refcount btree reservation */ 1507 1513 return xfs_refcount_adjust_cow(rcur, agbno, aglen, 1508 - XFS_REFCOUNT_ADJUST_COW_FREE, dfops); 1514 + XFS_REFCOUNT_ADJUST_COW_FREE); 1509 1515 } 1510 1516 1511 1517 /* Record a CoW staging extent in the refcount btree. */ ··· 1562 1568 /* Stuff an extent on the recovery list. */ 1563 1569 STATIC int 1564 1570 xfs_refcount_recover_extent( 1565 - struct xfs_btree_cur *cur, 1571 + struct xfs_btree_cur *cur, 1566 1572 union xfs_btree_rec *rec, 1567 1573 void *priv) 1568 1574 {
+2 -3
fs/xfs/libxfs/xfs_refcount_btree.c
··· 373 373 */ 374 374 int 375 375 xfs_refcountbt_maxrecs( 376 - struct xfs_mount *mp, 377 376 int blocklen, 378 377 bool leaf) 379 378 { ··· 389 390 xfs_refcountbt_compute_maxlevels( 390 391 struct xfs_mount *mp) 391 392 { 392 - mp->m_refc_maxlevels = xfs_btree_compute_maxlevels(mp, 393 + mp->m_refc_maxlevels = xfs_btree_compute_maxlevels( 393 394 mp->m_refc_mnr, mp->m_sb.sb_agblocks); 394 395 } 395 396 ··· 399 400 struct xfs_mount *mp, 400 401 unsigned long long len) 401 402 { 402 - return xfs_btree_calc_size(mp, mp->m_refc_mnr, len); 403 + return xfs_btree_calc_size(mp->m_refc_mnr, len); 403 404 } 404 405 405 406 /*
+1 -2
fs/xfs/libxfs/xfs_refcount_btree.h
··· 60 60 extern struct xfs_btree_cur *xfs_refcountbt_init_cursor(struct xfs_mount *mp, 61 61 struct xfs_trans *tp, struct xfs_buf *agbp, xfs_agnumber_t agno, 62 62 struct xfs_defer_ops *dfops); 63 - extern int xfs_refcountbt_maxrecs(struct xfs_mount *mp, int blocklen, 64 - bool leaf); 63 + extern int xfs_refcountbt_maxrecs(int blocklen, bool leaf); 65 64 extern void xfs_refcountbt_compute_maxlevels(struct xfs_mount *mp); 66 65 67 66 extern xfs_extlen_t xfs_refcountbt_calc_size(struct xfs_mount *mp,
+1 -2
fs/xfs/libxfs/xfs_rmap.c
··· 376 376 struct xfs_mount *mp, 377 377 uint64_t ltoff, 378 378 struct xfs_rmap_irec *rec, 379 - xfs_fsblock_t bno, 380 379 xfs_filblks_t len, 381 380 uint64_t owner, 382 381 uint64_t offset, ··· 518 519 bno + len, out_error); 519 520 520 521 /* Check owner information. */ 521 - error = xfs_rmap_free_check_owner(mp, ltoff, &ltrec, bno, len, owner, 522 + error = xfs_rmap_free_check_owner(mp, ltoff, &ltrec, len, owner, 522 523 offset, flags); 523 524 if (error) 524 525 goto out_error;
+2 -3
fs/xfs/libxfs/xfs_rmap_btree.c
··· 499 499 */ 500 500 int 501 501 xfs_rmapbt_maxrecs( 502 - struct xfs_mount *mp, 503 502 int blocklen, 504 503 int leaf) 505 504 { ··· 533 534 if (xfs_sb_version_hasreflink(&mp->m_sb)) 534 535 mp->m_rmap_maxlevels = XFS_BTREE_MAXLEVELS; 535 536 else 536 - mp->m_rmap_maxlevels = xfs_btree_compute_maxlevels(mp, 537 + mp->m_rmap_maxlevels = xfs_btree_compute_maxlevels( 537 538 mp->m_rmap_mnr, mp->m_sb.sb_agblocks); 538 539 } 539 540 ··· 543 544 struct xfs_mount *mp, 544 545 unsigned long long len) 545 546 { 546 - return xfs_btree_calc_size(mp, mp->m_rmap_mnr, len); 547 + return xfs_btree_calc_size(mp->m_rmap_mnr, len); 547 548 } 548 549 549 550 /*
+1 -1
fs/xfs/libxfs/xfs_rmap_btree.h
··· 55 55 struct xfs_btree_cur *xfs_rmapbt_init_cursor(struct xfs_mount *mp, 56 56 struct xfs_trans *tp, struct xfs_buf *bp, 57 57 xfs_agnumber_t agno); 58 - int xfs_rmapbt_maxrecs(struct xfs_mount *mp, int blocklen, int leaf); 58 + int xfs_rmapbt_maxrecs(int blocklen, int leaf); 59 59 extern void xfs_rmapbt_compute_maxlevels(struct xfs_mount *mp); 60 60 61 61 extern xfs_extlen_t xfs_rmapbt_calc_size(struct xfs_mount *mp,
+4 -6
fs/xfs/libxfs/xfs_sb.c
··· 756 756 mp->m_bmap_dmnr[0] = mp->m_bmap_dmxr[0] / 2; 757 757 mp->m_bmap_dmnr[1] = mp->m_bmap_dmxr[1] / 2; 758 758 759 - mp->m_rmap_mxr[0] = xfs_rmapbt_maxrecs(mp, sbp->sb_blocksize, 1); 760 - mp->m_rmap_mxr[1] = xfs_rmapbt_maxrecs(mp, sbp->sb_blocksize, 0); 759 + mp->m_rmap_mxr[0] = xfs_rmapbt_maxrecs(sbp->sb_blocksize, 1); 760 + mp->m_rmap_mxr[1] = xfs_rmapbt_maxrecs(sbp->sb_blocksize, 0); 761 761 mp->m_rmap_mnr[0] = mp->m_rmap_mxr[0] / 2; 762 762 mp->m_rmap_mnr[1] = mp->m_rmap_mxr[1] / 2; 763 763 764 - mp->m_refc_mxr[0] = xfs_refcountbt_maxrecs(mp, sbp->sb_blocksize, 765 - true); 766 - mp->m_refc_mxr[1] = xfs_refcountbt_maxrecs(mp, sbp->sb_blocksize, 767 - false); 764 + mp->m_refc_mxr[0] = xfs_refcountbt_maxrecs(sbp->sb_blocksize, true); 765 + mp->m_refc_mxr[1] = xfs_refcountbt_maxrecs(sbp->sb_blocksize, false); 768 766 mp->m_refc_mnr[0] = mp->m_refc_mxr[0] / 2; 769 767 mp->m_refc_mnr[1] = mp->m_refc_mxr[1] / 2; 770 768
+4 -6
fs/xfs/libxfs/xfs_trans_resv.c
··· 734 734 * the xfs_disk_dquot_t: sizeof(struct xfs_disk_dquot) 735 735 */ 736 736 STATIC uint 737 - xfs_calc_qm_setqlim_reservation( 738 - struct xfs_mount *mp) 737 + xfs_calc_qm_setqlim_reservation(void) 739 738 { 740 739 return xfs_calc_buf_res(1, sizeof(struct xfs_disk_dquot)); 741 740 } ··· 771 772 * the xfs_qoff_logitem_t: sizeof(struct xfs_qoff_logitem) * 2 772 773 */ 773 774 STATIC uint 774 - xfs_calc_qm_quotaoff_end_reservation( 775 - struct xfs_mount *mp) 775 + xfs_calc_qm_quotaoff_end_reservation(void) 776 776 { 777 777 return sizeof(struct xfs_qoff_logitem) * 2; 778 778 } ··· 875 877 * The following transactions are logged in logical format with 876 878 * a default log count. 877 879 */ 878 - resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation(mp); 880 + resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation(); 879 881 resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT; 880 882 881 883 resp->tr_qm_quotaoff.tr_logres = xfs_calc_qm_quotaoff_reservation(mp); 882 884 resp->tr_qm_quotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT; 883 885 884 886 resp->tr_qm_equotaoff.tr_logres = 885 - xfs_calc_qm_quotaoff_end_reservation(mp); 887 + xfs_calc_qm_quotaoff_end_reservation(); 886 888 resp->tr_qm_equotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT; 887 889 888 890 resp->tr_sb.tr_logres = xfs_calc_sb_reservation(mp);
+20 -19
fs/xfs/xfs_bmap_item.c
··· 53 53 kmem_zone_free(xfs_bui_zone, buip); 54 54 } 55 55 56 + /* 57 + * Freeing the BUI requires that we remove it from the AIL if it has already 58 + * been placed there. However, the BUI may not yet have been placed in the AIL 59 + * when called by xfs_bui_release() from BUD processing due to the ordering of 60 + * committed vs unpin operations in bulk insert operations. Hence the reference 61 + * count to ensure only the last caller frees the BUI. 62 + */ 63 + void 64 + xfs_bui_release( 65 + struct xfs_bui_log_item *buip) 66 + { 67 + ASSERT(atomic_read(&buip->bui_refcount) > 0); 68 + if (atomic_dec_and_test(&buip->bui_refcount)) { 69 + xfs_trans_ail_remove(&buip->bui_item, SHUTDOWN_LOG_IO_ERROR); 70 + xfs_bui_item_free(buip); 71 + } 72 + } 73 + 74 + 56 75 STATIC void 57 76 xfs_bui_item_size( 58 77 struct xfs_log_item *lip, ··· 161 142 struct xfs_log_item *lip) 162 143 { 163 144 if (lip->li_flags & XFS_LI_ABORTED) 164 - xfs_bui_item_free(BUI_ITEM(lip)); 145 + xfs_bui_release(BUI_ITEM(lip)); 165 146 } 166 147 167 148 /* ··· 223 204 atomic_set(&buip->bui_refcount, 2); 224 205 225 206 return buip; 226 - } 227 - 228 - /* 229 - * Freeing the BUI requires that we remove it from the AIL if it has already 230 - * been placed there. However, the BUI may not yet have been placed in the AIL 231 - * when called by xfs_bui_release() from BUD processing due to the ordering of 232 - * committed vs unpin operations in bulk insert operations. Hence the reference 233 - * count to ensure only the last caller frees the BUI. 234 - */ 235 - void 236 - xfs_bui_release( 237 - struct xfs_bui_log_item *buip) 238 - { 239 - ASSERT(atomic_read(&buip->bui_refcount) > 0); 240 - if (atomic_dec_and_test(&buip->bui_refcount)) { 241 - xfs_trans_ail_remove(&buip->bui_item, SHUTDOWN_LOG_IO_ERROR); 242 - xfs_bui_item_free(buip); 243 - } 244 207 } 245 208 246 209 static inline struct xfs_bud_log_item *BUD_ITEM(struct xfs_log_item *lip)
+1 -2
fs/xfs/xfs_bmap_util.c
··· 1326 1326 int error; 1327 1327 struct xfs_defer_ops dfops; 1328 1328 xfs_fsblock_t first_block; 1329 - xfs_fileoff_t stop_fsb = XFS_B_TO_FSB(mp, VFS_I(ip)->i_size); 1330 1329 xfs_fileoff_t next_fsb = XFS_B_TO_FSB(mp, offset + len); 1331 1330 xfs_fileoff_t shift_fsb = XFS_B_TO_FSB(mp, len); 1332 1331 uint resblks = XFS_DIOSTRAT_SPACE_RES(mp, 0); ··· 1360 1361 1361 1362 xfs_defer_init(&dfops, &first_block); 1362 1363 error = xfs_bmap_collapse_extents(tp, ip, &next_fsb, shift_fsb, 1363 - &done, stop_fsb, &first_block, &dfops); 1364 + &done, &first_block, &dfops); 1364 1365 if (error) 1365 1366 goto out_bmap_cancel; 1366 1367
-1
fs/xfs/xfs_buf.c
··· 1754 1754 1755 1755 void 1756 1756 xfs_free_buftarg( 1757 - struct xfs_mount *mp, 1758 1757 struct xfs_buftarg *btp) 1759 1758 { 1760 1759 unregister_shrinker(&btp->bt_shrinker);
+1 -1
fs/xfs/xfs_buf.h
··· 388 388 */ 389 389 extern xfs_buftarg_t *xfs_alloc_buftarg(struct xfs_mount *, 390 390 struct block_device *, struct dax_device *); 391 - extern void xfs_free_buftarg(struct xfs_mount *, struct xfs_buftarg *); 391 + extern void xfs_free_buftarg(struct xfs_buftarg *); 392 392 extern void xfs_wait_buftarg(xfs_buftarg_t *); 393 393 extern int xfs_setsize_buftarg(xfs_buftarg_t *, unsigned int); 394 394
+7 -7
fs/xfs/xfs_discard.c
··· 50 50 51 51 pag = xfs_perag_get(mp, agno); 52 52 53 + /* 54 + * Force out the log. This means any transactions that might have freed 55 + * space before we take the AGF buffer lock are now on disk, and the 56 + * volatile disk cache is flushed. 57 + */ 58 + xfs_log_force(mp, XFS_LOG_SYNC); 59 + 53 60 error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp); 54 61 if (error || !agbp) 55 62 goto out_put_perag; 56 63 57 64 cur = xfs_allocbt_init_cursor(mp, NULL, agbp, agno, XFS_BTNUM_CNT); 58 - 59 - /* 60 - * Force out the log. This means any transactions that might have freed 61 - * space before we took the AGF buffer lock are now on disk, and the 62 - * volatile disk cache is flushed. 63 - */ 64 - xfs_log_force(mp, XFS_LOG_SYNC); 65 65 66 66 /* 67 67 * Look up the longest btree in the AGF and start with it.
+19 -19
fs/xfs/xfs_extfree_item.c
··· 51 51 } 52 52 53 53 /* 54 + * Freeing the efi requires that we remove it from the AIL if it has already 55 + * been placed there. However, the EFI may not yet have been placed in the AIL 56 + * when called by xfs_efi_release() from EFD processing due to the ordering of 57 + * committed vs unpin operations in bulk insert operations. Hence the reference 58 + * count to ensure only the last caller frees the EFI. 59 + */ 60 + void 61 + xfs_efi_release( 62 + struct xfs_efi_log_item *efip) 63 + { 64 + ASSERT(atomic_read(&efip->efi_refcount) > 0); 65 + if (atomic_dec_and_test(&efip->efi_refcount)) { 66 + xfs_trans_ail_remove(&efip->efi_item, SHUTDOWN_LOG_IO_ERROR); 67 + xfs_efi_item_free(efip); 68 + } 69 + } 70 + 71 + /* 54 72 * This returns the number of iovecs needed to log the given efi item. 55 73 * We only need 1 iovec for an efi item. It just logs the efi_log_format 56 74 * structure. ··· 169 151 struct xfs_log_item *lip) 170 152 { 171 153 if (lip->li_flags & XFS_LI_ABORTED) 172 - xfs_efi_item_free(EFI_ITEM(lip)); 154 + xfs_efi_release(EFI_ITEM(lip)); 173 155 } 174 156 175 157 /* ··· 295 277 return 0; 296 278 } 297 279 return -EFSCORRUPTED; 298 - } 299 - 300 - /* 301 - * Freeing the efi requires that we remove it from the AIL if it has already 302 - * been placed there. However, the EFI may not yet have been placed in the AIL 303 - * when called by xfs_efi_release() from EFD processing due to the ordering of 304 - * committed vs unpin operations in bulk insert operations. Hence the reference 305 - * count to ensure only the last caller frees the EFI. 306 - */ 307 - void 308 - xfs_efi_release( 309 - struct xfs_efi_log_item *efip) 310 - { 311 - ASSERT(atomic_read(&efip->efi_refcount) > 0); 312 - if (atomic_dec_and_test(&efip->efi_refcount)) { 313 - xfs_trans_ail_remove(&efip->efi_item, SHUTDOWN_LOG_IO_ERROR); 314 - xfs_efi_item_free(efip); 315 - } 316 280 } 317 281 318 282 static inline struct xfs_efd_log_item *EFD_ITEM(struct xfs_log_item *lip)
+10 -11
fs/xfs/xfs_filestream.c
··· 34 34 35 35 struct xfs_fstrm_item { 36 36 struct xfs_mru_cache_elem mru; 37 - struct xfs_inode *ip; 38 37 xfs_agnumber_t ag; /* AG in use for this directory */ 39 38 }; 40 39 ··· 121 122 122 123 static void 123 124 xfs_fstrm_free_func( 125 + void *data, 124 126 struct xfs_mru_cache_elem *mru) 125 127 { 128 + struct xfs_mount *mp = data; 126 129 struct xfs_fstrm_item *item = 127 130 container_of(mru, struct xfs_fstrm_item, mru); 128 131 129 - xfs_filestream_put_ag(item->ip->i_mount, item->ag); 130 - 131 - trace_xfs_filestream_free(item->ip, item->ag); 132 + xfs_filestream_put_ag(mp, item->ag); 133 + trace_xfs_filestream_free(mp, mru->key, item->ag); 132 134 133 135 kmem_free(item); 134 136 } ··· 165 165 trylock = XFS_ALLOC_FLAG_TRYLOCK; 166 166 167 167 for (nscan = 0; 1; nscan++) { 168 - trace_xfs_filestream_scan(ip, ag); 168 + trace_xfs_filestream_scan(mp, ip->i_ino, ag); 169 169 170 170 pag = xfs_perag_get(mp, ag); 171 171 ··· 198 198 goto next_ag; 199 199 } 200 200 201 - longest = xfs_alloc_longest_free_extent(mp, pag, 201 + longest = xfs_alloc_longest_free_extent(pag, 202 202 xfs_alloc_min_freelist(mp, pag), 203 203 xfs_ag_resv_needed(pag, XFS_AG_RESV_NONE)); 204 204 if (((minlen && longest >= minlen) || ··· 265 265 goto out_put_ag; 266 266 267 267 item->ag = *agp; 268 - item->ip = ip; 269 268 270 269 err = xfs_mru_cache_insert(mp->m_filestream, ip->i_ino, &item->mru); 271 270 if (err) { ··· 332 333 ag = container_of(mru, struct xfs_fstrm_item, mru)->ag; 333 334 xfs_mru_cache_done(mp->m_filestream); 334 335 335 - trace_xfs_filestream_lookup(ip, ag); 336 + trace_xfs_filestream_lookup(mp, ip->i_ino, ag); 336 337 goto out; 337 338 } 338 339 ··· 398 399 * Only free the item here so we skip over the old AG earlier. 399 400 */ 400 401 if (mru) 401 - xfs_fstrm_free_func(mru); 402 + xfs_fstrm_free_func(mp, mru); 402 403 403 404 IRELE(pip); 404 405 exit: ··· 425 426 * timer tunable to within about 10 percent. This requires at least 10 426 427 * groups. 427 428 */ 428 - return xfs_mru_cache_create(&mp->m_filestream, xfs_fstrm_centisecs * 10, 429 - 10, xfs_fstrm_free_func); 429 + return xfs_mru_cache_create(&mp->m_filestream, mp, 430 + xfs_fstrm_centisecs * 10, 10, xfs_fstrm_free_func); 430 431 } 431 432 432 433 void
+12 -19
fs/xfs/xfs_inode.c
··· 972 972 xfs_nlink_t nlink, 973 973 dev_t rdev, 974 974 prid_t prid, /* project id */ 975 - xfs_inode_t **ipp, /* pointer to inode; it will be 975 + xfs_inode_t **ipp) /* pointer to inode; it will be 976 976 locked. */ 977 - int *committed) 978 - 979 977 { 980 978 xfs_trans_t *tp; 981 979 xfs_inode_t *ip; ··· 1048 1050 } 1049 1051 1050 1052 code = xfs_trans_roll(&tp); 1051 - if (committed != NULL) 1052 - *committed = 1; 1053 1053 1054 1054 /* 1055 1055 * Re-attach the quota info that we detached from prev trx. ··· 1084 1088 } 1085 1089 ASSERT(!ialloc_context && ip); 1086 1090 1087 - } else { 1088 - if (committed != NULL) 1089 - *committed = 0; 1090 1091 } 1091 1092 1092 1093 *ipp = ip; ··· 1210 1217 * entry pointing to them, but a directory also the "." entry 1211 1218 * pointing to itself. 1212 1219 */ 1213 - error = xfs_dir_ialloc(&tp, dp, mode, is_dir ? 2 : 1, rdev, prid, &ip, 1214 - NULL); 1220 + error = xfs_dir_ialloc(&tp, dp, mode, is_dir ? 2 : 1, rdev, prid, &ip); 1215 1221 if (error) 1216 1222 goto out_trans_cancel; 1217 1223 ··· 1301 1309 int 1302 1310 xfs_create_tmpfile( 1303 1311 struct xfs_inode *dp, 1304 - struct dentry *dentry, 1305 1312 umode_t mode, 1306 1313 struct xfs_inode **ipp) 1307 1314 { ··· 1342 1351 if (error) 1343 1352 goto out_trans_cancel; 1344 1353 1345 - error = xfs_dir_ialloc(&tp, dp, mode, 1, 0, prid, &ip, NULL); 1354 + error = xfs_dir_ialloc(&tp, dp, mode, 1, 0, prid, &ip); 1346 1355 if (error) 1347 1356 goto out_trans_cancel; 1348 1357 ··· 1602 1611 goto out; 1603 1612 } 1604 1613 1605 - /* Remove all pending CoW reservations. */ 1606 - error = xfs_reflink_cancel_cow_blocks(ip, &tp, first_unmap_block, 1607 - last_block, true); 1608 - if (error) 1609 - goto out; 1614 + if (whichfork == XFS_DATA_FORK) { 1615 + /* Remove all pending CoW reservations. */ 1616 + error = xfs_reflink_cancel_cow_blocks(ip, &tp, 1617 + first_unmap_block, last_block, true); 1618 + if (error) 1619 + goto out; 1610 1620 1611 - xfs_itruncate_clear_reflink_flags(ip); 1621 + xfs_itruncate_clear_reflink_flags(ip); 1622 + } 1612 1623 1613 1624 /* 1614 1625 * Always re-log the inode so that our permanent transaction can keep ··· 2896 2903 struct xfs_inode *tmpfile; 2897 2904 int error; 2898 2905 2899 - error = xfs_create_tmpfile(dp, NULL, S_IFCHR | WHITEOUT_MODE, &tmpfile); 2906 + error = xfs_create_tmpfile(dp, S_IFCHR | WHITEOUT_MODE, &tmpfile); 2900 2907 if (error) 2901 2908 return error; 2902 2909
+3 -3
fs/xfs/xfs_inode.h
··· 393 393 struct xfs_inode **ipp, struct xfs_name *ci_name); 394 394 int xfs_create(struct xfs_inode *dp, struct xfs_name *name, 395 395 umode_t mode, dev_t rdev, struct xfs_inode **ipp); 396 - int xfs_create_tmpfile(struct xfs_inode *dp, struct dentry *dentry, 397 - umode_t mode, struct xfs_inode **ipp); 396 + int xfs_create_tmpfile(struct xfs_inode *dp, umode_t mode, 397 + struct xfs_inode **ipp); 398 398 int xfs_remove(struct xfs_inode *dp, struct xfs_name *name, 399 399 struct xfs_inode *ip); 400 400 int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip, ··· 431 431 432 432 int xfs_dir_ialloc(struct xfs_trans **, struct xfs_inode *, umode_t, 433 433 xfs_nlink_t, dev_t, prid_t, 434 - struct xfs_inode **, int *); 434 + struct xfs_inode **); 435 435 436 436 /* from xfs_file.c */ 437 437 enum xfs_prealloc_flags {
+1 -1
fs/xfs/xfs_iops.c
··· 177 177 if (!tmpfile) { 178 178 error = xfs_create(XFS_I(dir), &name, mode, rdev, &ip); 179 179 } else { 180 - error = xfs_create_tmpfile(XFS_I(dir), dentry, mode, &ip); 180 + error = xfs_create_tmpfile(XFS_I(dir), mode, &ip); 181 181 } 182 182 if (unlikely(error)) 183 183 goto out_free_acl;
-1
fs/xfs/xfs_log.c
··· 560 560 */ 561 561 int 562 562 xfs_log_notify( 563 - struct xfs_mount *mp, 564 563 struct xlog_in_core *iclog, 565 564 xfs_log_callback_t *cb) 566 565 {
+1 -2
fs/xfs/xfs_log.h
··· 141 141 xfs_lsn_t xlog_assign_tail_lsn(struct xfs_mount *mp); 142 142 xfs_lsn_t xlog_assign_tail_lsn_locked(struct xfs_mount *mp); 143 143 void xfs_log_space_wake(struct xfs_mount *mp); 144 - int xfs_log_notify(struct xfs_mount *mp, 145 - struct xlog_in_core *iclog, 144 + int xfs_log_notify(struct xlog_in_core *iclog, 146 145 struct xfs_log_callback *callback_entry); 147 146 int xfs_log_release_iclog(struct xfs_mount *mp, 148 147 struct xlog_in_core *iclog);
+1 -1
fs/xfs/xfs_log_cil.c
··· 848 848 /* attach all the transactions w/ busy extents to iclog */ 849 849 ctx->log_cb.cb_func = xlog_cil_committed; 850 850 ctx->log_cb.cb_arg = ctx; 851 - error = xfs_log_notify(log->l_mp, commit_iclog, &ctx->log_cb); 851 + error = xfs_log_notify(commit_iclog, &ctx->log_cb); 852 852 if (error) 853 853 goto out_abort; 854 854
+5 -3
fs/xfs/xfs_mru_cache.c
··· 112 112 xfs_mru_cache_free_func_t free_func; /* Function pointer for freeing. */ 113 113 struct delayed_work work; /* Workqueue data for reaping. */ 114 114 unsigned int queued; /* work has been queued */ 115 + void *data; 115 116 }; 116 117 117 118 static struct workqueue_struct *xfs_mru_reap_wq; ··· 260 259 261 260 list_for_each_entry_safe(elem, next, &tmp, list_node) { 262 261 list_del_init(&elem->list_node); 263 - mru->free_func(elem); 262 + mru->free_func(mru->data, elem); 264 263 } 265 264 266 265 spin_lock(&mru->lock); ··· 327 326 int 328 327 xfs_mru_cache_create( 329 328 struct xfs_mru_cache **mrup, 329 + void *data, 330 330 unsigned int lifetime_ms, 331 331 unsigned int grp_count, 332 332 xfs_mru_cache_free_func_t free_func) ··· 371 369 372 370 mru->grp_time = grp_time; 373 371 mru->free_func = free_func; 374 - 372 + mru->data = data; 375 373 *mrup = mru; 376 374 377 375 exit: ··· 494 492 495 493 elem = xfs_mru_cache_remove(mru, key); 496 494 if (elem) 497 - mru->free_func(elem); 495 + mru->free_func(mru->data, elem); 498 496 } 499 497 500 498 /*
+4 -4
fs/xfs/xfs_mru_cache.h
··· 26 26 }; 27 27 28 28 /* Function pointer type for callback to free a client's data pointer. */ 29 - typedef void (*xfs_mru_cache_free_func_t)(struct xfs_mru_cache_elem *elem); 29 + typedef void (*xfs_mru_cache_free_func_t)(void *, struct xfs_mru_cache_elem *); 30 30 31 31 int xfs_mru_cache_init(void); 32 32 void xfs_mru_cache_uninit(void); 33 - int xfs_mru_cache_create(struct xfs_mru_cache **mrup, unsigned int lifetime_ms, 34 - unsigned int grp_count, 35 - xfs_mru_cache_free_func_t free_func); 33 + int xfs_mru_cache_create(struct xfs_mru_cache **mrup, void *data, 34 + unsigned int lifetime_ms, unsigned int grp_count, 35 + xfs_mru_cache_free_func_t free_func); 36 36 void xfs_mru_cache_destroy(struct xfs_mru_cache *mru); 37 37 int xfs_mru_cache_insert(struct xfs_mru_cache *mru, unsigned long key, 38 38 struct xfs_mru_cache_elem *elem);
+1 -3
fs/xfs/xfs_qm.c
··· 748 748 { 749 749 xfs_trans_t *tp; 750 750 int error; 751 - int committed; 752 751 bool need_alloc = true; 753 752 754 753 *ip = NULL; ··· 787 788 return error; 788 789 789 790 if (need_alloc) { 790 - error = xfs_dir_ialloc(&tp, NULL, S_IFREG, 1, 0, 0, ip, 791 - &committed); 791 + error = xfs_dir_ialloc(&tp, NULL, S_IFREG, 1, 0, 0, ip); 792 792 if (error) { 793 793 xfs_trans_cancel(tp); 794 794 return error;
+20 -19
fs/xfs/xfs_refcount_item.c
··· 52 52 kmem_zone_free(xfs_cui_zone, cuip); 53 53 } 54 54 55 + /* 56 + * Freeing the CUI requires that we remove it from the AIL if it has already 57 + * been placed there. However, the CUI may not yet have been placed in the AIL 58 + * when called by xfs_cui_release() from CUD processing due to the ordering of 59 + * committed vs unpin operations in bulk insert operations. Hence the reference 60 + * count to ensure only the last caller frees the CUI. 61 + */ 62 + void 63 + xfs_cui_release( 64 + struct xfs_cui_log_item *cuip) 65 + { 66 + ASSERT(atomic_read(&cuip->cui_refcount) > 0); 67 + if (atomic_dec_and_test(&cuip->cui_refcount)) { 68 + xfs_trans_ail_remove(&cuip->cui_item, SHUTDOWN_LOG_IO_ERROR); 69 + xfs_cui_item_free(cuip); 70 + } 71 + } 72 + 73 + 55 74 STATIC void 56 75 xfs_cui_item_size( 57 76 struct xfs_log_item *lip, ··· 160 141 struct xfs_log_item *lip) 161 142 { 162 143 if (lip->li_flags & XFS_LI_ABORTED) 163 - xfs_cui_item_free(CUI_ITEM(lip)); 144 + xfs_cui_release(CUI_ITEM(lip)); 164 145 } 165 146 166 147 /* ··· 228 209 atomic_set(&cuip->cui_refcount, 2); 229 210 230 211 return cuip; 231 - } 232 - 233 - /* 234 - * Freeing the CUI requires that we remove it from the AIL if it has already 235 - * been placed there. However, the CUI may not yet have been placed in the AIL 236 - * when called by xfs_cui_release() from CUD processing due to the ordering of 237 - * committed vs unpin operations in bulk insert operations. Hence the reference 238 - * count to ensure only the last caller frees the CUI. 239 - */ 240 - void 241 - xfs_cui_release( 242 - struct xfs_cui_log_item *cuip) 243 - { 244 - ASSERT(atomic_read(&cuip->cui_refcount) > 0); 245 - if (atomic_dec_and_test(&cuip->cui_refcount)) { 246 - xfs_trans_ail_remove(&cuip->cui_item, SHUTDOWN_LOG_IO_ERROR); 247 - xfs_cui_item_free(cuip); 248 - } 249 212 } 250 213 251 214 static inline struct xfs_cud_log_item *CUD_ITEM(struct xfs_log_item *lip)
+19 -19
fs/xfs/xfs_rmap_item.c
··· 52 52 kmem_zone_free(xfs_rui_zone, ruip); 53 53 } 54 54 55 + /* 56 + * Freeing the RUI requires that we remove it from the AIL if it has already 57 + * been placed there. However, the RUI may not yet have been placed in the AIL 58 + * when called by xfs_rui_release() from RUD processing due to the ordering of 59 + * committed vs unpin operations in bulk insert operations. Hence the reference 60 + * count to ensure only the last caller frees the RUI. 61 + */ 62 + void 63 + xfs_rui_release( 64 + struct xfs_rui_log_item *ruip) 65 + { 66 + ASSERT(atomic_read(&ruip->rui_refcount) > 0); 67 + if (atomic_dec_and_test(&ruip->rui_refcount)) { 68 + xfs_trans_ail_remove(&ruip->rui_item, SHUTDOWN_LOG_IO_ERROR); 69 + xfs_rui_item_free(ruip); 70 + } 71 + } 72 + 55 73 STATIC void 56 74 xfs_rui_item_size( 57 75 struct xfs_log_item *lip, ··· 159 141 struct xfs_log_item *lip) 160 142 { 161 143 if (lip->li_flags & XFS_LI_ABORTED) 162 - xfs_rui_item_free(RUI_ITEM(lip)); 144 + xfs_rui_release(RUI_ITEM(lip)); 163 145 } 164 146 165 147 /* ··· 249 231 250 232 memcpy(dst_rui_fmt, src_rui_fmt, len); 251 233 return 0; 252 - } 253 - 254 - /* 255 - * Freeing the RUI requires that we remove it from the AIL if it has already 256 - * been placed there. However, the RUI may not yet have been placed in the AIL 257 - * when called by xfs_rui_release() from RUD processing due to the ordering of 258 - * committed vs unpin operations in bulk insert operations. Hence the reference 259 - * count to ensure only the last caller frees the RUI. 260 - */ 261 - void 262 - xfs_rui_release( 263 - struct xfs_rui_log_item *ruip) 264 - { 265 - ASSERT(atomic_read(&ruip->rui_refcount) > 0); 266 - if (atomic_dec_and_test(&ruip->rui_refcount)) { 267 - xfs_trans_ail_remove(&ruip->rui_item, SHUTDOWN_LOG_IO_ERROR); 268 - xfs_rui_item_free(ruip); 269 - } 270 234 } 271 235 272 236 static inline struct xfs_rud_log_item *RUD_ITEM(struct xfs_log_item *lip)
+6 -7
fs/xfs/xfs_super.c
··· 722 722 struct block_device *logdev = mp->m_logdev_targp->bt_bdev; 723 723 struct dax_device *dax_logdev = mp->m_logdev_targp->bt_daxdev; 724 724 725 - xfs_free_buftarg(mp, mp->m_logdev_targp); 725 + xfs_free_buftarg(mp->m_logdev_targp); 726 726 xfs_blkdev_put(logdev); 727 727 fs_put_dax(dax_logdev); 728 728 } ··· 730 730 struct block_device *rtdev = mp->m_rtdev_targp->bt_bdev; 731 731 struct dax_device *dax_rtdev = mp->m_rtdev_targp->bt_daxdev; 732 732 733 - xfs_free_buftarg(mp, mp->m_rtdev_targp); 733 + xfs_free_buftarg(mp->m_rtdev_targp); 734 734 xfs_blkdev_put(rtdev); 735 735 fs_put_dax(dax_rtdev); 736 736 } 737 - xfs_free_buftarg(mp, mp->m_ddev_targp); 737 + xfs_free_buftarg(mp->m_ddev_targp); 738 738 fs_put_dax(dax_ddev); 739 739 } 740 740 ··· 808 808 809 809 out_free_rtdev_targ: 810 810 if (mp->m_rtdev_targp) 811 - xfs_free_buftarg(mp, mp->m_rtdev_targp); 811 + xfs_free_buftarg(mp->m_rtdev_targp); 812 812 out_free_ddev_targ: 813 - xfs_free_buftarg(mp, mp->m_ddev_targp); 813 + xfs_free_buftarg(mp->m_ddev_targp); 814 814 out_close_rtdev: 815 815 xfs_blkdev_put(rtdev); 816 816 fs_put_dax(dax_rtdev); ··· 1247 1247 STATIC int 1248 1248 xfs_test_remount_options( 1249 1249 struct super_block *sb, 1250 - struct xfs_mount *mp, 1251 1250 char *options) 1252 1251 { 1253 1252 int error = 0; ··· 1277 1278 int error; 1278 1279 1279 1280 /* First, check for complete junk; i.e. invalid options */ 1280 - error = xfs_test_remount_options(sb, mp, options); 1281 + error = xfs_test_remount_options(sb, options); 1281 1282 if (error) 1282 1283 return error; 1283 1284
+1 -1
fs/xfs/xfs_symlink.c
··· 264 264 * Allocate an inode for the symlink. 265 265 */ 266 266 error = xfs_dir_ialloc(&tp, dp, S_IFLNK | (mode & ~S_IFMT), 1, 0, 267 - prid, &ip, NULL); 267 + prid, &ip); 268 268 if (error) 269 269 goto out_trans_cancel; 270 270
+7 -7
fs/xfs/xfs_trace.h
··· 506 506 DEFINE_BUF_ITEM_EVENT(xfs_trans_binval); 507 507 508 508 DECLARE_EVENT_CLASS(xfs_filestream_class, 509 - TP_PROTO(struct xfs_inode *ip, xfs_agnumber_t agno), 510 - TP_ARGS(ip, agno), 509 + TP_PROTO(struct xfs_mount *mp, xfs_ino_t ino, xfs_agnumber_t agno), 510 + TP_ARGS(mp, ino, agno), 511 511 TP_STRUCT__entry( 512 512 __field(dev_t, dev) 513 513 __field(xfs_ino_t, ino) ··· 515 515 __field(int, streams) 516 516 ), 517 517 TP_fast_assign( 518 - __entry->dev = VFS_I(ip)->i_sb->s_dev; 519 - __entry->ino = ip->i_ino; 518 + __entry->dev = mp->m_super->s_dev; 519 + __entry->ino = ino; 520 520 __entry->agno = agno; 521 - __entry->streams = xfs_filestream_peek_ag(ip->i_mount, agno); 521 + __entry->streams = xfs_filestream_peek_ag(mp, agno); 522 522 ), 523 523 TP_printk("dev %d:%d ino 0x%llx agno %u streams %d", 524 524 MAJOR(__entry->dev), MINOR(__entry->dev), ··· 528 528 ) 529 529 #define DEFINE_FILESTREAM_EVENT(name) \ 530 530 DEFINE_EVENT(xfs_filestream_class, name, \ 531 - TP_PROTO(struct xfs_inode *ip, xfs_agnumber_t agno), \ 532 - TP_ARGS(ip, agno)) 531 + TP_PROTO(struct xfs_mount *mp, xfs_ino_t ino, xfs_agnumber_t agno), \ 532 + TP_ARGS(mp, ino, agno)) 533 533 DEFINE_FILESTREAM_EVENT(xfs_filestream_free); 534 534 DEFINE_FILESTREAM_EVENT(xfs_filestream_lookup); 535 535 DEFINE_FILESTREAM_EVENT(xfs_filestream_scan);