fs/xfs/xfs_trans_dquot.c
Source file repositories/reference/linux-study-clean/fs/xfs/xfs_trans_dquot.c
File Facts
- System
- Linux kernel
- Corpus path
fs/xfs/xfs_trans_dquot.c- Extension
.c- Size
- 26306 bytes
- Lines
- 1066
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xfs_platform.hxfs_fs.hxfs_shared.hxfs_format.hxfs_log_format.hxfs_trans_resv.hxfs_mount.hxfs_inode.hxfs_trans.hxfs_trans_priv.hxfs_quota.hxfs_qm.hxfs_trace.hxfs_error.hxfs_health.h
Detected Declarations
function xfs_trans_dqjoinfunction xfs_trans_log_dquotfunction xfs_trans_dup_dqinfofunction xfs_dqtrx_hook_disablefunction xfs_dqtrx_hook_enablefunction xfs_trans_mod_ino_dquotfunction xfs_dqtrx_hook_addfunction xfs_dqtrx_hook_delfunction xfs_dqtrx_hook_setupfunction xfs_trans_mod_dquot_byinofunction xfs_trans_get_dqtrxfunction xfs_trans_mod_sbfunction xfs_trans_dqlockedjoinfunction xfs_apply_quota_reservation_deltasfunction xfs_trans_apply_dquot_deltas_hookfunction xfs_trans_commitfunction xfs_trans_unreserve_and_mod_dquots_hookfunction incorefunction xfs_quota_warnfunction xfs_dqresv_checkfunction xfs_trans_dqresvfunction dquotfunction xfs_trans_reserve_quota_nblksfunction xfs_trans_reserve_quota_icreatefunction xfs_trans_alloc_dqinfofunction xfs_trans_free_dqinfofunction xfs_quota_reserve_blkres
Annotated Snippet
if (qtrx->qt_ino_res && delta > 0) {
qtrx->qt_ino_res_used += delta;
ASSERT(qtrx->qt_ino_res >= qtrx->qt_ino_res_used);
}
qtrx->qt_icount_delta += delta;
break;
/* rtblk reservation */
case XFS_TRANS_DQ_RES_RTBLKS:
qtrx->qt_rtblk_res += delta;
break;
/* rtblk count */
case XFS_TRANS_DQ_RTBCOUNT:
if (qtrx->qt_rtblk_res && delta > 0) {
qtrx->qt_rtblk_res_used += delta;
ASSERT(qtrx->qt_rtblk_res >= qtrx->qt_rtblk_res_used);
}
qtrx->qt_rtbcount_delta += delta;
break;
case XFS_TRANS_DQ_DELRTBCOUNT:
qtrx->qt_delrtb_delta += delta;
break;
default:
ASSERT(0);
}
trace_xfs_trans_mod_dquot_after(qtrx);
}
/*
* Given an array of dqtrx structures, lock all the dquots associated and join
* them to the transaction, provided they have been modified.
*/
STATIC void
xfs_trans_dqlockedjoin(
struct xfs_trans *tp,
struct xfs_dqtrx *q)
{
unsigned int i;
ASSERT(q[0].qt_dquot != NULL);
if (q[1].qt_dquot == NULL) {
mutex_lock(&q[0].qt_dquot->q_qlock);
xfs_trans_dqjoin(tp, q[0].qt_dquot);
} else if (q[2].qt_dquot == NULL) {
xfs_dqlock2(q[0].qt_dquot, q[1].qt_dquot);
xfs_trans_dqjoin(tp, q[0].qt_dquot);
xfs_trans_dqjoin(tp, q[1].qt_dquot);
} else {
xfs_dqlockn(q);
for (i = 0; i < XFS_QM_TRANS_MAXDQS; i++) {
if (q[i].qt_dquot == NULL)
break;
xfs_trans_dqjoin(tp, q[i].qt_dquot);
}
}
}
/* Apply dqtrx changes to the quota reservation counters. */
static inline void
xfs_apply_quota_reservation_deltas(
struct xfs_dquot_res *res,
uint64_t reserved,
int64_t res_used,
int64_t count_delta)
{
if (reserved != 0) {
/*
* Subtle math here: If reserved > res_used (the normal case),
* we're simply subtracting the unused transaction quota
* reservation from the dquot reservation.
*
* If, however, res_used > reserved, then we have allocated
* more quota blocks than were reserved for the transaction.
* We must add that excess to the dquot reservation since it
* tracks (usage + resv) and by definition we didn't reserve
* that excess.
*/
res->reserved -= abs(reserved - res_used);
} else if (count_delta != 0) {
/*
* These blks were never reserved, either inside a transaction
* or outside one (in a delayed allocation). Also, this isn't
* always a negative number since we sometimes deliberately
* skip quota reservations.
*/
res->reserved += count_delta;
Annotation
- Immediate include surface: `xfs_platform.h`, `xfs_fs.h`, `xfs_shared.h`, `xfs_format.h`, `xfs_log_format.h`, `xfs_trans_resv.h`, `xfs_mount.h`, `xfs_inode.h`.
- Detected declarations: `function xfs_trans_dqjoin`, `function xfs_trans_log_dquot`, `function xfs_trans_dup_dqinfo`, `function xfs_dqtrx_hook_disable`, `function xfs_dqtrx_hook_enable`, `function xfs_trans_mod_ino_dquot`, `function xfs_dqtrx_hook_add`, `function xfs_dqtrx_hook_del`, `function xfs_dqtrx_hook_setup`, `function xfs_trans_mod_dquot_byino`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.