mm/shmem_quota.c
Source file repositories/reference/linux-study-clean/mm/shmem_quota.c
File Facts
- System
- Linux kernel
- Corpus path
mm/shmem_quota.c- Extension
.c- Size
- 9619 bytes
- Lines
- 352
- Domain
- Core OS
- Bucket
- Memory Management
- 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.
- 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/fs.hlinux/mount.hlinux/kernel.hlinux/init.hlinux/module.hlinux/slab.hlinux/rbtree.hlinux/shmem_fs.hlinux/quotaops.hlinux/quota.h
Detected Declarations
struct quota_idfunction shmem_check_quota_filefunction shmem_read_file_infofunction shmem_write_file_infofunction shmem_free_file_infofunction shmem_get_next_idfunction shmem_acquire_dquotfunction shmem_is_empty_dquotfunction shmem_release_dquotfunction shmem_mark_dquot_dirtyfunction shmem_dquot_write_info
Annotated Snippet
struct quota_id {
struct rb_node node;
qid_t id;
qsize_t bhardlimit;
qsize_t bsoftlimit;
qsize_t ihardlimit;
qsize_t isoftlimit;
};
static int shmem_check_quota_file(struct super_block *sb, int type)
{
/* There is no real quota file, nothing to do */
return 1;
}
/*
* There is no real quota file. Just allocate rb_root for quota ids and
* set limits
*/
static int shmem_read_file_info(struct super_block *sb, int type)
{
struct quota_info *dqopt = sb_dqopt(sb);
struct mem_dqinfo *info = &dqopt->info[type];
info->dqi_priv = kzalloc_obj(struct rb_root, GFP_NOFS);
if (!info->dqi_priv)
return -ENOMEM;
info->dqi_max_spc_limit = SHMEM_QUOTA_MAX_SPC_LIMIT;
info->dqi_max_ino_limit = SHMEM_QUOTA_MAX_INO_LIMIT;
info->dqi_bgrace = SHMEM_MAX_DQ_TIME;
info->dqi_igrace = SHMEM_MAX_IQ_TIME;
info->dqi_flags = 0;
return 0;
}
static int shmem_write_file_info(struct super_block *sb, int type)
{
/* There is no real quota file, nothing to do */
return 0;
}
/*
* Free all the quota_id entries in the rb tree and rb_root.
*/
static int shmem_free_file_info(struct super_block *sb, int type)
{
struct mem_dqinfo *info = &sb_dqopt(sb)->info[type];
struct rb_root *root = info->dqi_priv;
struct quota_id *entry;
struct rb_node *node;
info->dqi_priv = NULL;
node = rb_first(root);
while (node) {
entry = rb_entry(node, struct quota_id, node);
node = rb_next(&entry->node);
rb_erase(&entry->node, root);
kfree(entry);
}
kfree(root);
return 0;
}
static int shmem_get_next_id(struct super_block *sb, struct kqid *qid)
{
struct mem_dqinfo *info = sb_dqinfo(sb, qid->type);
struct rb_node *node;
qid_t id = from_kqid(&init_user_ns, *qid);
struct quota_info *dqopt = sb_dqopt(sb);
struct quota_id *entry = NULL;
int ret = 0;
if (!sb_has_quota_active(sb, qid->type))
return -ESRCH;
down_read(&dqopt->dqio_sem);
node = ((struct rb_root *)info->dqi_priv)->rb_node;
while (node) {
entry = rb_entry(node, struct quota_id, node);
if (id < entry->id)
node = node->rb_left;
else if (id > entry->id)
node = node->rb_right;
else
Annotation
- Immediate include surface: `linux/errno.h`, `linux/fs.h`, `linux/mount.h`, `linux/kernel.h`, `linux/init.h`, `linux/module.h`, `linux/slab.h`, `linux/rbtree.h`.
- Detected declarations: `struct quota_id`, `function shmem_check_quota_file`, `function shmem_read_file_info`, `function shmem_write_file_info`, `function shmem_free_file_info`, `function shmem_get_next_id`, `function shmem_acquire_dquot`, `function shmem_is_empty_dquot`, `function shmem_release_dquot`, `function shmem_mark_dquot_dirty`.
- Atlas domain: Core OS / Memory Management.
- 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.