fs/quota/dquot.c
Source file repositories/reference/linux-study-clean/fs/quota/dquot.c
File Facts
- System
- Linux kernel
- Corpus path
fs/quota/dquot.c- Extension
.c- Size
- 84353 bytes
- Lines
- 3076
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/kernel.hlinux/fs.hlinux/mount.hlinux/mm.hlinux/time.hlinux/types.hlinux/string.hlinux/fcntl.hlinux/stat.hlinux/tty.hlinux/file.hlinux/slab.hlinux/sysctl.hlinux/init.hlinux/module.hlinux/proc_fs.hlinux/security.hlinux/sched.hlinux/cred.hlinux/kmod.hlinux/namei.hlinux/capability.hlinux/quotaops.hlinux/blkdev.hlinux/sched/mm.hlinux/uaccess.h
Detected Declarations
struct dquot_warnfunction __quota_errorfunction register_quota_formatfunction unregister_quota_formatfunction put_quota_formatfunction hashfnfunction insert_dquot_hashfunction remove_dquot_hashfunction put_dquot_lastfunction put_releasing_dquotsfunction remove_free_dquotfunction put_inusefunction remove_inusefunction wait_on_dquotfunction dquot_activefunction dquot_dirtyfunction mark_dquot_dirtyfunction dquot_mark_dquot_dirtyfunction mark_all_dquot_dirtyfunction dqput_allfunction clear_dquot_dirtyfunction mark_info_dirtyfunction dquot_acquirefunction dquot_commitfunction dquot_releasefunction dquot_destroyfunction do_destroy_dquotfunction prune_icachefunction dquot_scan_activefunction dquot_write_dquotfunction dquot_writeback_dquotsfunction dquot_quota_syncfunction dqcache_shrink_scanfunction dqcache_shrink_countfunction quota_release_workfnfunction invalidate_dquotsfunction dqputfunction dqinit_neededfunction add_dquot_reffunction remove_dquot_reffunction drop_dquot_reffunction dquot_free_reserved_spacefunction dquot_decr_inodesfunction dquot_decr_spacefunction warning_issuedfunction need_print_warningfunction print_warningfunction prepare_warning
Annotated Snippet
struct dquot_warn {
struct super_block *w_sb;
struct kqid w_dq_id;
short w_type;
};
static int warning_issued(struct dquot *dquot, const int warntype)
{
int flag = (warntype == QUOTA_NL_BHARDWARN ||
warntype == QUOTA_NL_BSOFTLONGWARN) ? DQ_BLKS_B :
((warntype == QUOTA_NL_IHARDWARN ||
warntype == QUOTA_NL_ISOFTLONGWARN) ? DQ_INODES_B : 0);
if (!flag)
return 0;
return test_and_set_bit(flag, &dquot->dq_flags);
}
#ifdef CONFIG_PRINT_QUOTA_WARNING
static int flag_print_warnings = 1;
static int need_print_warning(struct dquot_warn *warn)
{
if (!flag_print_warnings)
return 0;
switch (warn->w_dq_id.type) {
case USRQUOTA:
return uid_eq(current_fsuid(), warn->w_dq_id.uid);
case GRPQUOTA:
return in_group_p(warn->w_dq_id.gid);
case PRJQUOTA:
return 1;
}
return 0;
}
/* Print warning to user which exceeded quota */
static void print_warning(struct dquot_warn *warn)
{
char *msg = NULL;
struct tty_struct *tty;
int warntype = warn->w_type;
if (warntype == QUOTA_NL_IHARDBELOW ||
warntype == QUOTA_NL_ISOFTBELOW ||
warntype == QUOTA_NL_BHARDBELOW ||
warntype == QUOTA_NL_BSOFTBELOW || !need_print_warning(warn))
return;
tty = get_current_tty();
if (!tty)
return;
tty_write_message(tty, warn->w_sb->s_id);
if (warntype == QUOTA_NL_ISOFTWARN || warntype == QUOTA_NL_BSOFTWARN)
tty_write_message(tty, ": warning, ");
else
tty_write_message(tty, ": write failed, ");
tty_write_message(tty, quotatypes[warn->w_dq_id.type]);
switch (warntype) {
case QUOTA_NL_IHARDWARN:
msg = " file limit reached.\r\n";
break;
case QUOTA_NL_ISOFTLONGWARN:
msg = " file quota exceeded too long.\r\n";
break;
case QUOTA_NL_ISOFTWARN:
msg = " file quota exceeded.\r\n";
break;
case QUOTA_NL_BHARDWARN:
msg = " block limit reached.\r\n";
break;
case QUOTA_NL_BSOFTLONGWARN:
msg = " block quota exceeded too long.\r\n";
break;
case QUOTA_NL_BSOFTWARN:
msg = " block quota exceeded.\r\n";
break;
}
tty_write_message(tty, msg);
tty_kref_put(tty);
}
#endif
static void prepare_warning(struct dquot_warn *warn, struct dquot *dquot,
int warntype)
{
if (warning_issued(dquot, warntype))
return;
warn->w_type = warntype;
Annotation
- Immediate include surface: `linux/errno.h`, `linux/kernel.h`, `linux/fs.h`, `linux/mount.h`, `linux/mm.h`, `linux/time.h`, `linux/types.h`, `linux/string.h`.
- Detected declarations: `struct dquot_warn`, `function __quota_error`, `function register_quota_format`, `function unregister_quota_format`, `function put_quota_format`, `function hashfn`, `function insert_dquot_hash`, `function remove_dquot_hash`, `function put_dquot_last`, `function put_releasing_dquots`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration 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.