Skip to content

Commit 28e3352

Browse files
committed
Merge tag 'xfs-6.3-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs updates from Darrick Wong: "There's a couple of bug fixes, some cleanups for inconsistent variable names and reduction of struct boxing and unboxing in the logging code. More work is pending, which will begin reworking allocation group lifetimes and finally replace confusing indirect calls to the allocator with actual ... function calls. But I want to let that experience another week of testing. Summary: - Eliminate repeated boxing and unboxing of log item parameters - Clean up some confusing variable names in the log item code - Fix a deadlock when doing unwritten extent conversion that causes a bmbt split when there are sustained memory shortages and the worker pool runs out of worker threads - Fix the panic_mask debug knob not being able to trigger on verifier errors - Constify kobj_type objects" * tag 'xfs-6.3-merge-2' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: revert commit 8954c44 xfs: make kobj_type structures constant xfs: allow setting full range of panic tags xfs: don't use BMBT btree split workers for IO completion xfs: fix confusing variable names in xfs_refcount_item.c xfs: pass refcount intent directly through the log intent code xfs: fix confusing variable names in xfs_rmap_item.c xfs: pass rmap space mapping directly through the log intent code xfs: fix confusing xfs_extent_item variable names xfs: pass xfs_extent_free_item directly through the log intent code xfs: fix confusing variable names in xfs_bmap_item.c xfs: pass the xfs_bmbt_irec directly through the log intent code xfs: use strscpy() to instead of strncpy()
2 parents d151e8b + dd07bb8 commit 28e3352

19 files changed

+376
-411
lines changed

Documentation/admin-guide/xfs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ The following sysctls are available for the XFS filesystem:
296296
XFS_ERRLEVEL_LOW: 1
297297
XFS_ERRLEVEL_HIGH: 5
298298

299-
fs.xfs.panic_mask (Min: 0 Default: 0 Max: 256)
299+
fs.xfs.panic_mask (Min: 0 Default: 0 Max: 511)
300300
Causes certain error conditions to call BUG(). Value is a bitmask;
301301
OR together the tags which represent errors which should cause panics:
302302

fs/xfs/libxfs/xfs_alloc.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,20 +2472,20 @@ xfs_defer_agfl_block(
24722472
struct xfs_owner_info *oinfo)
24732473
{
24742474
struct xfs_mount *mp = tp->t_mountp;
2475-
struct xfs_extent_free_item *new; /* new element */
2475+
struct xfs_extent_free_item *xefi;
24762476

24772477
ASSERT(xfs_extfree_item_cache != NULL);
24782478
ASSERT(oinfo != NULL);
24792479

2480-
new = kmem_cache_zalloc(xfs_extfree_item_cache,
2480+
xefi = kmem_cache_zalloc(xfs_extfree_item_cache,
24812481
GFP_KERNEL | __GFP_NOFAIL);
2482-
new->xefi_startblock = XFS_AGB_TO_FSB(mp, agno, agbno);
2483-
new->xefi_blockcount = 1;
2484-
new->xefi_owner = oinfo->oi_owner;
2482+
xefi->xefi_startblock = XFS_AGB_TO_FSB(mp, agno, agbno);
2483+
xefi->xefi_blockcount = 1;
2484+
xefi->xefi_owner = oinfo->oi_owner;
24852485

24862486
trace_xfs_agfl_free_defer(mp, agno, 0, agbno, 1);
24872487

2488-
xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_AGFL_FREE, &new->xefi_list);
2488+
xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_AGFL_FREE, &xefi->xefi_list);
24892489
}
24902490

24912491
/*
@@ -2500,7 +2500,7 @@ __xfs_free_extent_later(
25002500
const struct xfs_owner_info *oinfo,
25012501
bool skip_discard)
25022502
{
2503-
struct xfs_extent_free_item *new; /* new element */
2503+
struct xfs_extent_free_item *xefi;
25042504
#ifdef DEBUG
25052505
struct xfs_mount *mp = tp->t_mountp;
25062506
xfs_agnumber_t agno;
@@ -2519,27 +2519,27 @@ __xfs_free_extent_later(
25192519
#endif
25202520
ASSERT(xfs_extfree_item_cache != NULL);
25212521

2522-
new = kmem_cache_zalloc(xfs_extfree_item_cache,
2522+
xefi = kmem_cache_zalloc(xfs_extfree_item_cache,
25232523
GFP_KERNEL | __GFP_NOFAIL);
2524-
new->xefi_startblock = bno;
2525-
new->xefi_blockcount = (xfs_extlen_t)len;
2524+
xefi->xefi_startblock = bno;
2525+
xefi->xefi_blockcount = (xfs_extlen_t)len;
25262526
if (skip_discard)
2527-
new->xefi_flags |= XFS_EFI_SKIP_DISCARD;
2527+
xefi->xefi_flags |= XFS_EFI_SKIP_DISCARD;
25282528
if (oinfo) {
25292529
ASSERT(oinfo->oi_offset == 0);
25302530

25312531
if (oinfo->oi_flags & XFS_OWNER_INFO_ATTR_FORK)
2532-
new->xefi_flags |= XFS_EFI_ATTR_FORK;
2532+
xefi->xefi_flags |= XFS_EFI_ATTR_FORK;
25332533
if (oinfo->oi_flags & XFS_OWNER_INFO_BMBT_BLOCK)
2534-
new->xefi_flags |= XFS_EFI_BMBT_BLOCK;
2535-
new->xefi_owner = oinfo->oi_owner;
2534+
xefi->xefi_flags |= XFS_EFI_BMBT_BLOCK;
2535+
xefi->xefi_owner = oinfo->oi_owner;
25362536
} else {
2537-
new->xefi_owner = XFS_RMAP_OWN_NULL;
2537+
xefi->xefi_owner = XFS_RMAP_OWN_NULL;
25382538
}
25392539
trace_xfs_bmap_free_defer(tp->t_mountp,
25402540
XFS_FSB_TO_AGNO(tp->t_mountp, bno), 0,
25412541
XFS_FSB_TO_AGBNO(tp->t_mountp, bno), len);
2542-
xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_FREE, &new->xefi_list);
2542+
xfs_defer_add(tp, XFS_DEFER_OPS_TYPE_FREE, &xefi->xefi_list);
25432543
}
25442544

25452545
#ifdef DEBUG

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6146,39 +6146,37 @@ xfs_bmap_unmap_extent(
61466146
int
61476147
xfs_bmap_finish_one(
61486148
struct xfs_trans *tp,
6149-
struct xfs_inode *ip,
6150-
enum xfs_bmap_intent_type type,
6151-
int whichfork,
6152-
xfs_fileoff_t startoff,
6153-
xfs_fsblock_t startblock,
6154-
xfs_filblks_t *blockcount,
6155-
xfs_exntst_t state)
6149+
struct xfs_bmap_intent *bi)
61566150
{
6151+
struct xfs_bmbt_irec *bmap = &bi->bi_bmap;
61576152
int error = 0;
61586153

61596154
ASSERT(tp->t_firstblock == NULLFSBLOCK);
61606155

61616156
trace_xfs_bmap_deferred(tp->t_mountp,
6162-
XFS_FSB_TO_AGNO(tp->t_mountp, startblock), type,
6163-
XFS_FSB_TO_AGBNO(tp->t_mountp, startblock),
6164-
ip->i_ino, whichfork, startoff, *blockcount, state);
6157+
XFS_FSB_TO_AGNO(tp->t_mountp, bmap->br_startblock),
6158+
bi->bi_type,
6159+
XFS_FSB_TO_AGBNO(tp->t_mountp, bmap->br_startblock),
6160+
bi->bi_owner->i_ino, bi->bi_whichfork,
6161+
bmap->br_startoff, bmap->br_blockcount,
6162+
bmap->br_state);
61656163

6166-
if (WARN_ON_ONCE(whichfork != XFS_DATA_FORK))
6164+
if (WARN_ON_ONCE(bi->bi_whichfork != XFS_DATA_FORK))
61676165
return -EFSCORRUPTED;
61686166

61696167
if (XFS_TEST_ERROR(false, tp->t_mountp,
61706168
XFS_ERRTAG_BMAP_FINISH_ONE))
61716169
return -EIO;
61726170

6173-
switch (type) {
6171+
switch (bi->bi_type) {
61746172
case XFS_BMAP_MAP:
6175-
error = xfs_bmapi_remap(tp, ip, startoff, *blockcount,
6176-
startblock, 0);
6177-
*blockcount = 0;
6173+
error = xfs_bmapi_remap(tp, bi->bi_owner, bmap->br_startoff,
6174+
bmap->br_blockcount, bmap->br_startblock, 0);
6175+
bmap->br_blockcount = 0;
61786176
break;
61796177
case XFS_BMAP_UNMAP:
6180-
error = __xfs_bunmapi(tp, ip, startoff, blockcount,
6181-
XFS_BMAPI_REMAP, 1);
6178+
error = __xfs_bunmapi(tp, bi->bi_owner, bmap->br_startoff,
6179+
&bmap->br_blockcount, XFS_BMAPI_REMAP, 1);
61826180
break;
61836181
default:
61846182
ASSERT(0);

fs/xfs/libxfs/xfs_bmap.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,7 @@ struct xfs_bmap_intent {
234234
struct xfs_bmbt_irec bi_bmap;
235235
};
236236

237-
int xfs_bmap_finish_one(struct xfs_trans *tp, struct xfs_inode *ip,
238-
enum xfs_bmap_intent_type type, int whichfork,
239-
xfs_fileoff_t startoff, xfs_fsblock_t startblock,
240-
xfs_filblks_t *blockcount, xfs_exntst_t state);
237+
int xfs_bmap_finish_one(struct xfs_trans *tp, struct xfs_bmap_intent *bi);
241238
void xfs_bmap_map_extent(struct xfs_trans *tp, struct xfs_inode *ip,
242239
struct xfs_bmbt_irec *imap);
243240
void xfs_bmap_unmap_extent(struct xfs_trans *tp, struct xfs_inode *ip,

fs/xfs/libxfs/xfs_btree.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,9 +2913,22 @@ xfs_btree_split_worker(
29132913
}
29142914

29152915
/*
2916-
* BMBT split requests often come in with little stack to work on. Push
2916+
* BMBT split requests often come in with little stack to work on so we push
29172917
* them off to a worker thread so there is lots of stack to use. For the other
29182918
* btree types, just call directly to avoid the context switch overhead here.
2919+
*
2920+
* Care must be taken here - the work queue rescuer thread introduces potential
2921+
* AGF <> worker queue deadlocks if the BMBT block allocation has to lock new
2922+
* AGFs to allocate blocks. A task being run by the rescuer could attempt to
2923+
* lock an AGF that is already locked by a task queued to run by the rescuer,
2924+
* resulting in an ABBA deadlock as the rescuer cannot run the lock holder to
2925+
* release it until the current thread it is running gains the lock.
2926+
*
2927+
* To avoid this issue, we only ever queue BMBT splits that don't have an AGF
2928+
* already locked to allocate from. The only place that doesn't hold an AGF
2929+
* locked is unwritten extent conversion at IO completion, but that has already
2930+
* been offloaded to a worker thread and hence has no stack consumption issues
2931+
* we have to worry about.
29192932
*/
29202933
STATIC int /* error */
29212934
xfs_btree_split(
@@ -2929,7 +2942,8 @@ xfs_btree_split(
29292942
struct xfs_btree_split_args args;
29302943
DECLARE_COMPLETION_ONSTACK(done);
29312944

2932-
if (cur->bc_btnum != XFS_BTNUM_BMAP)
2945+
if (cur->bc_btnum != XFS_BTNUM_BMAP ||
2946+
cur->bc_tp->t_firstblock == NULLFSBLOCK)
29332947
return __xfs_btree_split(cur, level, ptrp, key, curp, stat);
29342948

29352949
args.cur = cur;

fs/xfs/libxfs/xfs_refcount.c

Lines changed: 43 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,37 +1213,33 @@ xfs_refcount_adjust_extents(
12131213
STATIC int
12141214
xfs_refcount_adjust(
12151215
struct xfs_btree_cur *cur,
1216-
xfs_agblock_t agbno,
1217-
xfs_extlen_t aglen,
1218-
xfs_agblock_t *new_agbno,
1219-
xfs_extlen_t *new_aglen,
1216+
xfs_agblock_t *agbno,
1217+
xfs_extlen_t *aglen,
12201218
enum xfs_refc_adjust_op adj)
12211219
{
12221220
bool shape_changed;
12231221
int shape_changes = 0;
12241222
int error;
12251223

1226-
*new_agbno = agbno;
1227-
*new_aglen = aglen;
12281224
if (adj == XFS_REFCOUNT_ADJUST_INCREASE)
1229-
trace_xfs_refcount_increase(cur->bc_mp, cur->bc_ag.pag->pag_agno,
1230-
agbno, aglen);
1225+
trace_xfs_refcount_increase(cur->bc_mp,
1226+
cur->bc_ag.pag->pag_agno, *agbno, *aglen);
12311227
else
1232-
trace_xfs_refcount_decrease(cur->bc_mp, cur->bc_ag.pag->pag_agno,
1233-
agbno, aglen);
1228+
trace_xfs_refcount_decrease(cur->bc_mp,
1229+
cur->bc_ag.pag->pag_agno, *agbno, *aglen);
12341230

12351231
/*
12361232
* Ensure that no rcextents cross the boundary of the adjustment range.
12371233
*/
12381234
error = xfs_refcount_split_extent(cur, XFS_REFC_DOMAIN_SHARED,
1239-
agbno, &shape_changed);
1235+
*agbno, &shape_changed);
12401236
if (error)
12411237
goto out_error;
12421238
if (shape_changed)
12431239
shape_changes++;
12441240

12451241
error = xfs_refcount_split_extent(cur, XFS_REFC_DOMAIN_SHARED,
1246-
agbno + aglen, &shape_changed);
1242+
*agbno + *aglen, &shape_changed);
12471243
if (error)
12481244
goto out_error;
12491245
if (shape_changed)
@@ -1253,7 +1249,7 @@ xfs_refcount_adjust(
12531249
* Try to merge with the left or right extents of the range.
12541250
*/
12551251
error = xfs_refcount_merge_extents(cur, XFS_REFC_DOMAIN_SHARED,
1256-
new_agbno, new_aglen, adj, &shape_changed);
1252+
agbno, aglen, adj, &shape_changed);
12571253
if (error)
12581254
goto out_error;
12591255
if (shape_changed)
@@ -1262,7 +1258,7 @@ xfs_refcount_adjust(
12621258
cur->bc_ag.refc.shape_changes++;
12631259

12641260
/* Now that we've taken care of the ends, adjust the middle extents */
1265-
error = xfs_refcount_adjust_extents(cur, new_agbno, new_aglen, adj);
1261+
error = xfs_refcount_adjust_extents(cur, agbno, aglen, adj);
12661262
if (error)
12671263
goto out_error;
12681264

@@ -1298,21 +1294,20 @@ xfs_refcount_finish_one_cleanup(
12981294
static inline int
12991295
xfs_refcount_continue_op(
13001296
struct xfs_btree_cur *cur,
1301-
xfs_fsblock_t startblock,
1302-
xfs_agblock_t new_agbno,
1303-
xfs_extlen_t new_len,
1304-
xfs_fsblock_t *new_fsbno)
1297+
struct xfs_refcount_intent *ri,
1298+
xfs_agblock_t new_agbno)
13051299
{
13061300
struct xfs_mount *mp = cur->bc_mp;
13071301
struct xfs_perag *pag = cur->bc_ag.pag;
13081302

1309-
if (XFS_IS_CORRUPT(mp, !xfs_verify_agbext(pag, new_agbno, new_len)))
1303+
if (XFS_IS_CORRUPT(mp, !xfs_verify_agbext(pag, new_agbno,
1304+
ri->ri_blockcount)))
13101305
return -EFSCORRUPTED;
13111306

1312-
*new_fsbno = XFS_AGB_TO_FSB(mp, pag->pag_agno, new_agbno);
1307+
ri->ri_startblock = XFS_AGB_TO_FSB(mp, pag->pag_agno, new_agbno);
13131308

1314-
ASSERT(xfs_verify_fsbext(mp, *new_fsbno, new_len));
1315-
ASSERT(pag->pag_agno == XFS_FSB_TO_AGNO(mp, *new_fsbno));
1309+
ASSERT(xfs_verify_fsbext(mp, ri->ri_startblock, ri->ri_blockcount));
1310+
ASSERT(pag->pag_agno == XFS_FSB_TO_AGNO(mp, ri->ri_startblock));
13161311

13171312
return 0;
13181313
}
@@ -1327,29 +1322,24 @@ xfs_refcount_continue_op(
13271322
int
13281323
xfs_refcount_finish_one(
13291324
struct xfs_trans *tp,
1330-
enum xfs_refcount_intent_type type,
1331-
xfs_fsblock_t startblock,
1332-
xfs_extlen_t blockcount,
1333-
xfs_fsblock_t *new_fsb,
1334-
xfs_extlen_t *new_len,
1325+
struct xfs_refcount_intent *ri,
13351326
struct xfs_btree_cur **pcur)
13361327
{
13371328
struct xfs_mount *mp = tp->t_mountp;
13381329
struct xfs_btree_cur *rcur;
13391330
struct xfs_buf *agbp = NULL;
13401331
int error = 0;
13411332
xfs_agblock_t bno;
1342-
xfs_agblock_t new_agbno;
13431333
unsigned long nr_ops = 0;
13441334
int shape_changes = 0;
13451335
struct xfs_perag *pag;
13461336

1347-
pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, startblock));
1348-
bno = XFS_FSB_TO_AGBNO(mp, startblock);
1337+
pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, ri->ri_startblock));
1338+
bno = XFS_FSB_TO_AGBNO(mp, ri->ri_startblock);
13491339

1350-
trace_xfs_refcount_deferred(mp, XFS_FSB_TO_AGNO(mp, startblock),
1351-
type, XFS_FSB_TO_AGBNO(mp, startblock),
1352-
blockcount);
1340+
trace_xfs_refcount_deferred(mp, XFS_FSB_TO_AGNO(mp, ri->ri_startblock),
1341+
ri->ri_type, XFS_FSB_TO_AGBNO(mp, ri->ri_startblock),
1342+
ri->ri_blockcount);
13531343

13541344
if (XFS_TEST_ERROR(false, mp, XFS_ERRTAG_REFCOUNT_FINISH_ONE)) {
13551345
error = -EIO;
@@ -1380,42 +1370,42 @@ xfs_refcount_finish_one(
13801370
}
13811371
*pcur = rcur;
13821372

1383-
switch (type) {
1373+
switch (ri->ri_type) {
13841374
case XFS_REFCOUNT_INCREASE:
1385-
error = xfs_refcount_adjust(rcur, bno, blockcount, &new_agbno,
1386-
new_len, XFS_REFCOUNT_ADJUST_INCREASE);
1375+
error = xfs_refcount_adjust(rcur, &bno, &ri->ri_blockcount,
1376+
XFS_REFCOUNT_ADJUST_INCREASE);
13871377
if (error)
13881378
goto out_drop;
1389-
if (*new_len > 0)
1390-
error = xfs_refcount_continue_op(rcur, startblock,
1391-
new_agbno, *new_len, new_fsb);
1379+
if (ri->ri_blockcount > 0)
1380+
error = xfs_refcount_continue_op(rcur, ri, bno);
13921381
break;
13931382
case XFS_REFCOUNT_DECREASE:
1394-
error = xfs_refcount_adjust(rcur, bno, blockcount, &new_agbno,
1395-
new_len, XFS_REFCOUNT_ADJUST_DECREASE);
1383+
error = xfs_refcount_adjust(rcur, &bno, &ri->ri_blockcount,
1384+
XFS_REFCOUNT_ADJUST_DECREASE);
13961385
if (error)
13971386
goto out_drop;
1398-
if (*new_len > 0)
1399-
error = xfs_refcount_continue_op(rcur, startblock,
1400-
new_agbno, *new_len, new_fsb);
1387+
if (ri->ri_blockcount > 0)
1388+
error = xfs_refcount_continue_op(rcur, ri, bno);
14011389
break;
14021390
case XFS_REFCOUNT_ALLOC_COW:
1403-
*new_fsb = startblock + blockcount;
1404-
*new_len = 0;
1405-
error = __xfs_refcount_cow_alloc(rcur, bno, blockcount);
1391+
error = __xfs_refcount_cow_alloc(rcur, bno, ri->ri_blockcount);
1392+
if (error)
1393+
goto out_drop;
1394+
ri->ri_blockcount = 0;
14061395
break;
14071396
case XFS_REFCOUNT_FREE_COW:
1408-
*new_fsb = startblock + blockcount;
1409-
*new_len = 0;
1410-
error = __xfs_refcount_cow_free(rcur, bno, blockcount);
1397+
error = __xfs_refcount_cow_free(rcur, bno, ri->ri_blockcount);
1398+
if (error)
1399+
goto out_drop;
1400+
ri->ri_blockcount = 0;
14111401
break;
14121402
default:
14131403
ASSERT(0);
14141404
error = -EFSCORRUPTED;
14151405
}
1416-
if (!error && *new_len > 0)
1417-
trace_xfs_refcount_finish_one_leftover(mp, pag->pag_agno, type,
1418-
bno, blockcount, new_agbno, *new_len);
1406+
if (!error && ri->ri_blockcount > 0)
1407+
trace_xfs_refcount_finish_one_leftover(mp, pag->pag_agno,
1408+
ri->ri_type, bno, ri->ri_blockcount);
14191409
out_drop:
14201410
xfs_perag_put(pag);
14211411
return error;

fs/xfs/libxfs/xfs_refcount.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,7 @@ void xfs_refcount_decrease_extent(struct xfs_trans *tp,
7575
extern void xfs_refcount_finish_one_cleanup(struct xfs_trans *tp,
7676
struct xfs_btree_cur *rcur, int error);
7777
extern int xfs_refcount_finish_one(struct xfs_trans *tp,
78-
enum xfs_refcount_intent_type type, xfs_fsblock_t startblock,
79-
xfs_extlen_t blockcount, xfs_fsblock_t *new_fsb,
80-
xfs_extlen_t *new_len, struct xfs_btree_cur **pcur);
78+
struct xfs_refcount_intent *ri, struct xfs_btree_cur **pcur);
8179

8280
extern int xfs_refcount_find_shared(struct xfs_btree_cur *cur,
8381
xfs_agblock_t agbno, xfs_extlen_t aglen, xfs_agblock_t *fbno,

0 commit comments

Comments
 (0)