Commit d7044263 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'xfs-6.3-fixes-3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-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
parents 4bdec23f 3cfb9290
...@@ -63,6 +63,7 @@ xfs-y += xfs_aops.o \ ...@@ -63,6 +63,7 @@ xfs-y += xfs_aops.o \
xfs_bmap_util.o \ xfs_bmap_util.o \
xfs_bio_io.o \ xfs_bio_io.o \
xfs_buf.o \ xfs_buf.o \
xfs_dahash_test.o \
xfs_dir2_readdir.o \ xfs_dir2_readdir.o \
xfs_discard.o \ xfs_discard.o \
xfs_error.o \ xfs_error.o \
......
...@@ -3255,6 +3255,8 @@ xfs_alloc_vextent_finish( ...@@ -3255,6 +3255,8 @@ xfs_alloc_vextent_finish(
XFS_STATS_INC(mp, xs_allocx); XFS_STATS_INC(mp, xs_allocx);
XFS_STATS_ADD(mp, xs_allocb, args->len); XFS_STATS_ADD(mp, xs_allocb, args->len);
trace_xfs_alloc_vextent_finish(args);
out_drop_perag: out_drop_perag:
if (drop_perag && args->pag) { if (drop_perag && args->pag) {
xfs_perag_rele(args->pag); xfs_perag_rele(args->pag);
...@@ -3279,8 +3281,14 @@ xfs_alloc_vextent_this_ag( ...@@ -3279,8 +3281,14 @@ xfs_alloc_vextent_this_ag(
xfs_agnumber_t minimum_agno; xfs_agnumber_t minimum_agno;
int error; int error;
ASSERT(args->pag != NULL);
ASSERT(args->pag->pag_agno == agno);
args->agno = agno; args->agno = agno;
args->agbno = 0; args->agbno = 0;
trace_xfs_alloc_vextent_this_ag(args);
error = xfs_alloc_vextent_check_args(args, XFS_AGB_TO_FSB(mp, agno, 0), error = xfs_alloc_vextent_check_args(args, XFS_AGB_TO_FSB(mp, agno, 0),
&minimum_agno); &minimum_agno);
if (error) { if (error) {
...@@ -3323,11 +3331,14 @@ xfs_alloc_vextent_iterate_ags( ...@@ -3323,11 +3331,14 @@ xfs_alloc_vextent_iterate_ags(
uint32_t flags) uint32_t flags)
{ {
struct xfs_mount *mp = args->mp; struct xfs_mount *mp = args->mp;
xfs_agnumber_t restart_agno = minimum_agno;
xfs_agnumber_t agno; xfs_agnumber_t agno;
int error = 0; int error = 0;
if (flags & XFS_ALLOC_FLAG_TRYLOCK)
restart_agno = 0;
restart: 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) { mp->m_sb.sb_agcount, agno, args->pag) {
args->agno = agno; args->agno = agno;
error = xfs_alloc_vextent_prepare_ag(args); error = xfs_alloc_vextent_prepare_ag(args);
...@@ -3366,6 +3377,7 @@ xfs_alloc_vextent_iterate_ags( ...@@ -3366,6 +3377,7 @@ xfs_alloc_vextent_iterate_ags(
*/ */
if (flags) { if (flags) {
flags = 0; flags = 0;
restart_agno = minimum_agno;
goto restart; goto restart;
} }
...@@ -3394,8 +3406,13 @@ xfs_alloc_vextent_start_ag( ...@@ -3394,8 +3406,13 @@ xfs_alloc_vextent_start_ag(
bool bump_rotor = false; bool bump_rotor = false;
int error; int error;
ASSERT(args->pag == NULL);
args->agno = NULLAGNUMBER; args->agno = NULLAGNUMBER;
args->agbno = NULLAGBLOCK; args->agbno = NULLAGBLOCK;
trace_xfs_alloc_vextent_first_ag(args);
error = xfs_alloc_vextent_check_args(args, target, &minimum_agno); error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
if (error) { if (error) {
if (error == -ENOSPC) if (error == -ENOSPC)
...@@ -3442,8 +3459,13 @@ xfs_alloc_vextent_first_ag( ...@@ -3442,8 +3459,13 @@ xfs_alloc_vextent_first_ag(
xfs_agnumber_t start_agno; xfs_agnumber_t start_agno;
int error; int error;
ASSERT(args->pag == NULL);
args->agno = NULLAGNUMBER; args->agno = NULLAGNUMBER;
args->agbno = NULLAGBLOCK; args->agbno = NULLAGBLOCK;
trace_xfs_alloc_vextent_start_ag(args);
error = xfs_alloc_vextent_check_args(args, target, &minimum_agno); error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
if (error) { if (error) {
if (error == -ENOSPC) if (error == -ENOSPC)
...@@ -3470,8 +3492,14 @@ xfs_alloc_vextent_exact_bno( ...@@ -3470,8 +3492,14 @@ xfs_alloc_vextent_exact_bno(
xfs_agnumber_t minimum_agno; xfs_agnumber_t minimum_agno;
int error; 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->agno = XFS_FSB_TO_AGNO(mp, target);
args->agbno = XFS_FSB_TO_AGBNO(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); error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
if (error) { if (error) {
if (error == -ENOSPC) if (error == -ENOSPC)
...@@ -3502,8 +3530,14 @@ xfs_alloc_vextent_near_bno( ...@@ -3502,8 +3530,14 @@ xfs_alloc_vextent_near_bno(
bool needs_perag = args->pag == NULL; bool needs_perag = args->pag == NULL;
int error; 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->agno = XFS_FSB_TO_AGNO(mp, target);
args->agbno = XFS_FSB_TO_AGBNO(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); error = xfs_alloc_vextent_check_args(args, target, &minimum_agno);
if (error) { if (error) {
if (error == -ENOSPC) if (error == -ENOSPC)
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (C) 2023 Oracle. All Rights Reserved.
* Author: Darrick J. Wong <djwong@kernel.org>
*/
#ifndef __XFS_DAHASH_TEST_H__
#define __XFS_DAHASH_TEST_H__
int xfs_dahash_test(void);
#endif /* __XFS_DAHASH_TEST_H__ */
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "xfs_attr_item.h" #include "xfs_attr_item.h"
#include "xfs_xattr.h" #include "xfs_xattr.h"
#include "xfs_iunlink_item.h" #include "xfs_iunlink_item.h"
#include "xfs_dahash_test.h"
#include <linux/magic.h> #include <linux/magic.h>
#include <linux/fs_context.h> #include <linux/fs_context.h>
...@@ -2286,6 +2287,10 @@ init_xfs_fs(void) ...@@ -2286,6 +2287,10 @@ init_xfs_fs(void)
xfs_check_ondisk_structs(); xfs_check_ondisk_structs();
error = xfs_dahash_test();
if (error)
return error;
printk(KERN_INFO XFS_VERSION_STRING " with " printk(KERN_INFO XFS_VERSION_STRING " with "
XFS_BUILD_OPTIONS " enabled\n"); XFS_BUILD_OPTIONS " enabled\n");
......
...@@ -1883,6 +1883,13 @@ DEFINE_ALLOC_EVENT(xfs_alloc_vextent_noagbp); ...@@ -1883,6 +1883,13 @@ DEFINE_ALLOC_EVENT(xfs_alloc_vextent_noagbp);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_loopfailed); DEFINE_ALLOC_EVENT(xfs_alloc_vextent_loopfailed);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_allfailed); DEFINE_ALLOC_EVENT(xfs_alloc_vextent_allfailed);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_this_ag);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_start_ag);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_first_ag);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_exact_bno);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_near_bno);
DEFINE_ALLOC_EVENT(xfs_alloc_vextent_finish);
TRACE_EVENT(xfs_alloc_cur_check, TRACE_EVENT(xfs_alloc_cur_check,
TP_PROTO(struct xfs_mount *mp, xfs_btnum_t btnum, xfs_agblock_t bno, TP_PROTO(struct xfs_mount *mp, xfs_btnum_t btnum, xfs_agblock_t bno,
xfs_extlen_t len, xfs_extlen_t diff, bool new), xfs_extlen_t len, xfs_extlen_t diff, bool new),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment