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

TOMOYO Linux Cross Reference
Linux/fs/xfs/xfs_drain.h

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) 2022-2023 Oracle.  All Rights Reserved.
  4  * Author: Darrick J. Wong <djwong@kernel.org>
  5  */
  6 #ifndef XFS_DRAIN_H_
  7 #define XFS_DRAIN_H_
  8 
  9 struct xfs_perag;
 10 
 11 #ifdef CONFIG_XFS_DRAIN_INTENTS
 12 /*
 13  * Passive drain mechanism.  This data structure tracks a count of some items
 14  * and contains a waitqueue for callers who would like to wake up when the
 15  * count hits zero.
 16  */
 17 struct xfs_defer_drain {
 18         /* Number of items pending in some part of the filesystem. */
 19         atomic_t                dr_count;
 20 
 21         /* Queue to wait for dri_count to go to zero */
 22         struct wait_queue_head  dr_waiters;
 23 };
 24 
 25 void xfs_defer_drain_init(struct xfs_defer_drain *dr);
 26 void xfs_defer_drain_free(struct xfs_defer_drain *dr);
 27 
 28 void xfs_drain_wait_disable(void);
 29 void xfs_drain_wait_enable(void);
 30 
 31 /*
 32  * Deferred Work Intent Drains
 33  * ===========================
 34  *
 35  * When a writer thread executes a chain of log intent items, the AG header
 36  * buffer locks will cycle during a transaction roll to get from one intent
 37  * item to the next in a chain.  Although scrub takes all AG header buffer
 38  * locks, this isn't sufficient to guard against scrub checking an AG while
 39  * that writer thread is in the middle of finishing a chain because there's no
 40  * higher level locking primitive guarding allocation groups.
 41  *
 42  * When there's a collision, cross-referencing between data structures (e.g.
 43  * rmapbt and refcountbt) yields false corruption events; if repair is running,
 44  * this results in incorrect repairs, which is catastrophic.
 45  *
 46  * The solution is to the perag structure the count of active intents and make
 47  * scrub wait until it has both AG header buffer locks and the intent counter
 48  * reaches zero.  It is therefore critical that deferred work threads hold the
 49  * AGI or AGF buffers when decrementing the intent counter.
 50  *
 51  * Given a list of deferred work items, the deferred work manager will complete
 52  * a work item and all the sub-items that the parent item creates before moving
 53  * on to the next work item in the list.  This is also true for all levels of
 54  * sub-items.  Writer threads are permitted to queue multiple work items
 55  * targetting the same AG, so a deferred work item (such as a BUI) that creates
 56  * sub-items (such as RUIs) must bump the intent counter and maintain it until
 57  * the sub-items can themselves bump the intent counter.
 58  *
 59  * Therefore, the intent count tracks entire lifetimes of deferred work items.
 60  * All functions that create work items must increment the intent counter as
 61  * soon as the item is added to the transaction and cannot drop the counter
 62  * until the item is finished or cancelled.
 63  */
 64 struct xfs_perag *xfs_perag_intent_get(struct xfs_mount *mp,
 65                 xfs_fsblock_t fsbno);
 66 void xfs_perag_intent_put(struct xfs_perag *pag);
 67 
 68 void xfs_perag_intent_hold(struct xfs_perag *pag);
 69 void xfs_perag_intent_rele(struct xfs_perag *pag);
 70 
 71 int xfs_perag_intent_drain(struct xfs_perag *pag);
 72 bool xfs_perag_intent_busy(struct xfs_perag *pag);
 73 #else
 74 struct xfs_defer_drain { /* empty */ };
 75 
 76 #define xfs_defer_drain_free(dr)                ((void)0)
 77 #define xfs_defer_drain_init(dr)                ((void)0)
 78 
 79 #define xfs_perag_intent_get(mp, fsbno) \
 80         xfs_perag_get((mp), XFS_FSB_TO_AGNO(mp, fsbno))
 81 #define xfs_perag_intent_put(pag)               xfs_perag_put(pag)
 82 
 83 static inline void xfs_perag_intent_hold(struct xfs_perag *pag) { }
 84 static inline void xfs_perag_intent_rele(struct xfs_perag *pag) { }
 85 
 86 #endif /* CONFIG_XFS_DRAIN_INTENTS */
 87 
 88 #endif /* XFS_DRAIN_H_ */
 89 

~ [ 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