~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/xfs/scrub/fscounters_repair.c

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /*
  3  * Copyright (c) 2018-2024 Oracle.  All Rights Reserved.
  4  * Author: Darrick J. Wong <djwong@kernel.org>
  5  */
  6 #include "xfs.h"
  7 #include "xfs_fs.h"
  8 #include "xfs_shared.h"
  9 #include "xfs_format.h"
 10 #include "xfs_trans_resv.h"
 11 #include "xfs_mount.h"
 12 #include "xfs_defer.h"
 13 #include "xfs_btree.h"
 14 #include "xfs_bit.h"
 15 #include "xfs_log_format.h"
 16 #include "xfs_trans.h"
 17 #include "xfs_sb.h"
 18 #include "xfs_inode.h"
 19 #include "xfs_alloc.h"
 20 #include "xfs_ialloc.h"
 21 #include "xfs_rmap.h"
 22 #include "xfs_health.h"
 23 #include "scrub/xfs_scrub.h"
 24 #include "scrub/scrub.h"
 25 #include "scrub/common.h"
 26 #include "scrub/trace.h"
 27 #include "scrub/repair.h"
 28 #include "scrub/fscounters.h"
 29 
 30 /*
 31  * FS Summary Counters
 32  * ===================
 33  *
 34  * We correct errors in the filesystem summary counters by setting them to the
 35  * values computed during the obligatory scrub phase.  However, we must be
 36  * careful not to allow any other thread to change the counters while we're
 37  * computing and setting new values.  To achieve this, we freeze the
 38  * filesystem for the whole operation if the REPAIR flag is set.  The checking
 39  * function is stricter when we've frozen the fs.
 40  */
 41 
 42 /*
 43  * Reset the superblock counters.  Caller is responsible for freezing the
 44  * filesystem during the calculation and reset phases.
 45  */
 46 int
 47 xrep_fscounters(
 48         struct xfs_scrub        *sc)
 49 {
 50         struct xfs_mount        *mp = sc->mp;
 51         struct xchk_fscounters  *fsc = sc->buf;
 52 
 53         /*
 54          * Reinitialize the in-core counters from what we computed.  We froze
 55          * the filesystem, so there shouldn't be anyone else trying to modify
 56          * these counters.
 57          */
 58         if (!fsc->frozen) {
 59                 ASSERT(fsc->frozen);
 60                 return -EFSCORRUPTED;
 61         }
 62 
 63         trace_xrep_reset_counters(mp, fsc);
 64 
 65         percpu_counter_set(&mp->m_icount, fsc->icount);
 66         percpu_counter_set(&mp->m_ifree, fsc->ifree);
 67         percpu_counter_set(&mp->m_fdblocks, fsc->fdblocks);
 68 
 69         /*
 70          * Online repair is only supported on v5 file systems, which require
 71          * lazy sb counters and thus no update of sb_fdblocks here.  But as of
 72          * now we don't support lazy counting sb_frextents yet, and thus need
 73          * to also update it directly here.  And for that we need to keep
 74          * track of the delalloc reservations separately, as they are are
 75          * subtracted from m_frextents, but not included in sb_frextents.
 76          */
 77         percpu_counter_set(&mp->m_frextents,
 78                 fsc->frextents - fsc->frextents_delayed);
 79         mp->m_sb.sb_frextents = fsc->frextents;
 80 
 81         return 0;
 82 }
 83 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php