Skip to content

Commit 849a4f0

Browse files
committed
Merge tag 'xfs-6.4-rc1-fixes' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs bug fixes from Dave Chinner: "Largely minor bug fixes and cleanups, th emost important of which are probably the fixes for regressions in the extent allocation code: - fixes for inode garbage collection shutdown racing with work queue updates - ensure inodegc workers run on the CPU they are supposed to - disable counter scrubbing until we can exclusively freeze the filesystem from the kernel - regression fixes for new allocation related bugs - a couple of minor cleanups" * tag 'xfs-6.4-rc1-fixes' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: fix xfs_inodegc_stop racing with mod_delayed_work xfs: disable reaping in fscounters scrub xfs: check that per-cpu inodegc workers actually run on that cpu xfs: explicitly specify cpu when forcing inodegc delayed work to run immediately xfs: fix negative array access in xfs_getbmap xfs: don't allocate into the data fork for an unshare request xfs: flush dirty data and drain directios before scrubbing cow fork xfs: set bnobt/cntbt numrecs correctly when formatting new AGs xfs: don't unconditionally null args->pag in xfs_bmap_btalloc_at_eof
2 parents 105131d + 2254a73 commit 849a4f0

File tree

14 files changed

+65
-63
lines changed

14 files changed

+65
-63
lines changed

fs/xfs/libxfs/xfs_ag.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -495,10 +495,12 @@ xfs_freesp_init_recs(
495495
ASSERT(start >= mp->m_ag_prealloc_blocks);
496496
if (start != mp->m_ag_prealloc_blocks) {
497497
/*
498-
* Modify first record to pad stripe align of log
498+
* Modify first record to pad stripe align of log and
499+
* bump the record count.
499500
*/
500501
arec->ar_blockcount = cpu_to_be32(start -
501502
mp->m_ag_prealloc_blocks);
503+
be16_add_cpu(&block->bb_numrecs, 1);
502504
nrec = arec + 1;
503505

504506
/*
@@ -509,7 +511,6 @@ xfs_freesp_init_recs(
509511
be32_to_cpu(arec->ar_startblock) +
510512
be32_to_cpu(arec->ar_blockcount));
511513
arec = nrec;
512-
be16_add_cpu(&block->bb_numrecs, 1);
513514
}
514515
/*
515516
* Change record start to after the internal log
@@ -518,15 +519,13 @@ xfs_freesp_init_recs(
518519
}
519520

520521
/*
521-
* Calculate the record block count and check for the case where
522-
* the log might have consumed all available space in the AG. If
523-
* so, reset the record count to 0 to avoid exposure of an invalid
524-
* record start block.
522+
* Calculate the block count of this record; if it is nonzero,
523+
* increment the record count.
525524
*/
526525
arec->ar_blockcount = cpu_to_be32(id->agsize -
527526
be32_to_cpu(arec->ar_startblock));
528-
if (!arec->ar_blockcount)
529-
block->bb_numrecs = 0;
527+
if (arec->ar_blockcount)
528+
be16_add_cpu(&block->bb_numrecs, 1);
530529
}
531530

532531
/*
@@ -538,7 +537,7 @@ xfs_bnoroot_init(
538537
struct xfs_buf *bp,
539538
struct aghdr_init_data *id)
540539
{
541-
xfs_btree_init_block(mp, bp, XFS_BTNUM_BNO, 0, 1, id->agno);
540+
xfs_btree_init_block(mp, bp, XFS_BTNUM_BNO, 0, 0, id->agno);
542541
xfs_freesp_init_recs(mp, bp, id);
543542
}
544543

@@ -548,7 +547,7 @@ xfs_cntroot_init(
548547
struct xfs_buf *bp,
549548
struct aghdr_init_data *id)
550549
{
551-
xfs_btree_init_block(mp, bp, XFS_BTNUM_CNT, 0, 1, id->agno);
550+
xfs_btree_init_block(mp, bp, XFS_BTNUM_CNT, 0, 0, id->agno);
552551
xfs_freesp_init_recs(mp, bp, id);
553552
}
554553

fs/xfs/libxfs/xfs_bmap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3494,8 +3494,10 @@ xfs_bmap_btalloc_at_eof(
34943494
if (!caller_pag)
34953495
args->pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, ap->blkno));
34963496
error = xfs_alloc_vextent_exact_bno(args, ap->blkno);
3497-
if (!caller_pag)
3497+
if (!caller_pag) {
34983498
xfs_perag_put(args->pag);
3499+
args->pag = NULL;
3500+
}
34993501
if (error)
35003502
return error;
35013503

@@ -3505,7 +3507,6 @@ xfs_bmap_btalloc_at_eof(
35053507
* Exact allocation failed. Reset to try an aligned allocation
35063508
* according to the original allocation specification.
35073509
*/
3508-
args->pag = NULL;
35093510
args->alignment = stripe_align;
35103511
args->minlen = nextminlen;
35113512
args->minalignslop = 0;

fs/xfs/scrub/bmap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ xchk_setup_inode_bmap(
4242
xfs_ilock(sc->ip, XFS_IOLOCK_EXCL);
4343

4444
/*
45-
* We don't want any ephemeral data fork updates sitting around
45+
* We don't want any ephemeral data/cow fork updates sitting around
4646
* while we inspect block mappings, so wait for directio to finish
4747
* and flush dirty data if we have delalloc reservations.
4848
*/
4949
if (S_ISREG(VFS_I(sc->ip)->i_mode) &&
50-
sc->sm->sm_type == XFS_SCRUB_TYPE_BMBTD) {
50+
sc->sm->sm_type != XFS_SCRUB_TYPE_BMBTA) {
5151
struct address_space *mapping = VFS_I(sc->ip)->i_mapping;
5252

5353
sc->ilock_flags |= XFS_MMAPLOCK_EXCL;

fs/xfs/scrub/common.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,32 +1164,6 @@ xchk_metadata_inode_forks(
11641164
return 0;
11651165
}
11661166

1167-
/* Pause background reaping of resources. */
1168-
void
1169-
xchk_stop_reaping(
1170-
struct xfs_scrub *sc)
1171-
{
1172-
sc->flags |= XCHK_REAPING_DISABLED;
1173-
xfs_blockgc_stop(sc->mp);
1174-
xfs_inodegc_stop(sc->mp);
1175-
}
1176-
1177-
/* Restart background reaping of resources. */
1178-
void
1179-
xchk_start_reaping(
1180-
struct xfs_scrub *sc)
1181-
{
1182-
/*
1183-
* Readonly filesystems do not perform inactivation or speculative
1184-
* preallocation, so there's no need to restart the workers.
1185-
*/
1186-
if (!xfs_is_readonly(sc->mp)) {
1187-
xfs_inodegc_start(sc->mp);
1188-
xfs_blockgc_start(sc->mp);
1189-
}
1190-
sc->flags &= ~XCHK_REAPING_DISABLED;
1191-
}
1192-
11931167
/*
11941168
* Enable filesystem hooks (i.e. runtime code patching) before starting a scrub
11951169
* operation. Callers must not hold any locks that intersect with the CPU

fs/xfs/scrub/common.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ static inline bool xchk_skip_xref(struct xfs_scrub_metadata *sm)
156156
}
157157

158158
int xchk_metadata_inode_forks(struct xfs_scrub *sc);
159-
void xchk_stop_reaping(struct xfs_scrub *sc);
160-
void xchk_start_reaping(struct xfs_scrub *sc);
161159

162160
/*
163161
* Setting up a hook to wait for intents to drain is costly -- we have to take

fs/xfs/scrub/fscounters.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,6 @@ xchk_setup_fscounters(
150150
if (error)
151151
return error;
152152

153-
/*
154-
* Pause background reclaim while we're scrubbing to reduce the
155-
* likelihood of background perturbations to the counters throwing off
156-
* our calculations.
157-
*/
158-
xchk_stop_reaping(sc);
159-
160153
return xchk_trans_alloc(sc, 0);
161154
}
162155

@@ -453,6 +446,12 @@ xchk_fscounters(
453446
if (frextents > mp->m_sb.sb_rextents)
454447
xchk_set_corrupt(sc);
455448

449+
/*
450+
* XXX: We can't quiesce percpu counter updates, so exit early.
451+
* This can be re-enabled when we gain exclusive freeze functionality.
452+
*/
453+
return 0;
454+
456455
/*
457456
* If ifree exceeds icount by more than the minimum variance then
458457
* something's probably wrong with the counters.

fs/xfs/scrub/scrub.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ xchk_teardown(
186186
}
187187
if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR)
188188
mnt_drop_write_file(sc->file);
189-
if (sc->flags & XCHK_REAPING_DISABLED)
190-
xchk_start_reaping(sc);
191189
if (sc->buf) {
192190
if (sc->buf_cleanup)
193191
sc->buf_cleanup(sc->buf);

fs/xfs/scrub/scrub.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ struct xfs_scrub {
106106

107107
/* XCHK state flags grow up from zero, XREP state flags grown down from 2^31 */
108108
#define XCHK_TRY_HARDER (1 << 0) /* can't get resources, try again */
109-
#define XCHK_REAPING_DISABLED (1 << 1) /* background block reaping paused */
110109
#define XCHK_FSGATES_DRAIN (1 << 2) /* defer ops draining enabled */
111110
#define XCHK_NEED_DRAIN (1 << 3) /* scrub needs to drain defer ops */
112111
#define XREP_ALREADY_FIXED (1 << 31) /* checking our repair work */

fs/xfs/scrub/trace.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ TRACE_DEFINE_ENUM(XFS_SCRUB_TYPE_FSCOUNTERS);
9898

9999
#define XFS_SCRUB_STATE_STRINGS \
100100
{ XCHK_TRY_HARDER, "try_harder" }, \
101-
{ XCHK_REAPING_DISABLED, "reaping_disabled" }, \
102101
{ XCHK_FSGATES_DRAIN, "fsgates_drain" }, \
103102
{ XCHK_NEED_DRAIN, "need_drain" }, \
104103
{ XREP_ALREADY_FIXED, "already_fixed" }

fs/xfs/xfs_bmap_util.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,9 @@ xfs_getbmap(
558558
if (!xfs_iext_next_extent(ifp, &icur, &got)) {
559559
xfs_fileoff_t end = XFS_B_TO_FSB(mp, XFS_ISIZE(ip));
560560

561-
out[bmv->bmv_entries - 1].bmv_oflags |= BMV_OF_LAST;
561+
if (bmv->bmv_entries > 0)
562+
out[bmv->bmv_entries - 1].bmv_oflags |=
563+
BMV_OF_LAST;
562564

563565
if (whichfork != XFS_ATTR_FORK && bno < end &&
564566
!xfs_getbmap_full(bmv)) {

0 commit comments

Comments
 (0)