Skip to content

Commit

Permalink
Merge tag 'xfs-6.3-fixes-3' of git://git.kernel.org/pub/scm/fs/xfs/xf…
Browse files Browse the repository at this point in the history
…s-linux

Pull xfs fixes from Darrick Wong:
 "This batch started with some debugging enhancements to the new
  allocator refactoring that we put in 6.3-rc1 to assist developers in
  rebasing their dev branches.

  As for more serious code changes -- there's a bug fix to make the
  lockless allocator scan the whole filesystem before resorting to the
  locking allocator. We're also adding a selftest for the venerable
  directory/xattr hash function to make sure that it produces consistent
  results so that we can address any fallout as soon as possible.

   - Add a few debugging assertions so that people (me) trying to port
     code to the new allocator functions don't mess up the caller
     requirements

   - Relax some overly cautious lock ordering enforcement in the new
     allocator code, which means that file allocations will locklessly
     scan for the best space they can get before backing off to the
     traditional lock-and-really-get-it behavior

   - Add tracepoints to make it easier to trace the xfs allocator
     behavior

   - Actually test the dir/xattr hash algorithm to make sure it produces
     consistent results across all the platforms XFS supports"

* tag 'xfs-6.3-fixes-3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
  xfs: test dir/attr hash when loading module
  xfs: add tracepoints for each of the externally visible allocators
  xfs: walk all AGs if TRYLOCK passed to xfs_alloc_vextent_iterate_ags
  xfs: try to idiot-proof the allocators
  • Loading branch information
Linus Torvalds committed Mar 25, 2023
2 parents 4bdec23 + 3cfb929 commit d704426
Show file tree
Hide file tree
Showing 6 changed files with 722 additions and 1 deletion.
1 change: 1 addition & 0 deletions fs/xfs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ xfs-y += xfs_aops.o \
xfs_bmap_util.o \
xfs_bio_io.o \
xfs_buf.o \
xfs_dahash_test.o \
xfs_dir2_readdir.o \
xfs_discard.o \
xfs_error.o \
Expand Down
36 changes: 35 additions & 1 deletion fs/xfs/libxfs/xfs_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3255,6 +3255,8 @@ xfs_alloc_vextent_finish(
XFS_STATS_INC(mp, xs_allocx);
XFS_STATS_ADD(mp, xs_allocb, args->len);

trace_xfs_alloc_vextent_finish(args);

out_drop_perag:
if (drop_perag && args->pag) {
xfs_perag_rele(args->pag);
Expand All @@ -3279,8 +3281,14 @@ xfs_alloc_vextent_this_ag(
xfs_agnumber_t minimum_agno;
int error;

ASSERT(args->pag != NULL);
ASSERT(args->pag->pag_agno == agno);

args->agno = agno;
args->agbno = 0;

trace_xfs_alloc_vextent_this_ag(args);

error = xfs_alloc_vextent_check_args(args, XFS_AGB_TO_FSB(mp, agno, 0),
&minimum_agno);
if (error) {
Expand Down Expand Up @@ -3323,11 +3331,14 @@ xfs_alloc_vextent_iterate_ags(
uint32_t flags)
{
struct xfs_mount *mp = args->mp;
xfs_agnumber_t restart_agno = minimum_agno;
xfs_agnumber_t agno;
int error = 0;

if (flags & XFS_ALLOC_FLAG_TRYLOCK)
restart_agno = 0;
restart:
for_each_perag_wrap_range(mp, start_agno, minimum_agno,
for_each_perag_wrap_range(mp, start_agno, restart_agno,
mp->m_sb.sb_agcount, agno, args->pag) {
args->agno = agno;
error = xfs_alloc_vextent_prepare_ag(args);
Expand Down Expand Up @@ -3366,6 +3377,7 @@ xfs_alloc_vextent_iterate_ags(
*/
if (flags) {
flags = 0;
restart_agno = minimum_agno;
goto restart;
}

Expand Down Expand Up @@ -3394,8 +3406,13 @@ xfs_alloc_vextent_start_ag(
bool bump_rotor = false;
int error;

ASSERT(args->pag == NULL);

args->agno = NULLAGNUMBER;
args->agbno = NULLAGBLOCK;

trace_xfs_alloc_vextent_first_ag(args);

error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
if (error) {
if (error == -ENOSPC)
Expand Down Expand Up @@ -3442,8 +3459,13 @@ xfs_alloc_vextent_first_ag(
xfs_agnumber_t start_agno;
int error;

ASSERT(args->pag == NULL);

args->agno = NULLAGNUMBER;
args->agbno = NULLAGBLOCK;

trace_xfs_alloc_vextent_start_ag(args);

error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
if (error) {
if (error == -ENOSPC)
Expand All @@ -3470,8 +3492,14 @@ xfs_alloc_vextent_exact_bno(
xfs_agnumber_t minimum_agno;
int error;

ASSERT(args->pag != NULL);
ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));

args->agno = XFS_FSB_TO_AGNO(mp, target);
args->agbno = XFS_FSB_TO_AGBNO(mp, target);

trace_xfs_alloc_vextent_near_bno(args);

error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
if (error) {
if (error == -ENOSPC)
Expand Down Expand Up @@ -3502,8 +3530,14 @@ xfs_alloc_vextent_near_bno(
bool needs_perag = args->pag == NULL;
int error;

if (!needs_perag)
ASSERT(args->pag->pag_agno == XFS_FSB_TO_AGNO(mp, target));

args->agno = XFS_FSB_TO_AGNO(mp, target);
args->agbno = XFS_FSB_TO_AGBNO(mp, target);

trace_xfs_alloc_vextent_exact_bno(args);

error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
if (error) {
if (error == -ENOSPC)
Expand Down
Loading

0 comments on commit d704426

Please sign in to comment.