fs/gfs2/glock.c
Source file repositories/reference/linux-study-clean/fs/gfs2/glock.c
File Facts
- System
- Linux kernel
- Corpus path
fs/gfs2/glock.c- Extension
.c- Size
- 71641 bytes
- Lines
- 2846
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/sched.hlinux/slab.hlinux/spinlock.hlinux/buffer_head.hlinux/delay.hlinux/sort.hlinux/hash.hlinux/jhash.hlinux/kallsyms.hlinux/gfs2_ondisk.hlinux/list.hlinux/wait.hlinux/module.hlinux/uaccess.hlinux/seq_file.hlinux/debugfs.hlinux/kthread.hlinux/freezer.hlinux/workqueue.hlinux/jiffies.hlinux/rcupdate.hlinux/rculist_bl.hlinux/bit_spinlock.hlinux/percpu.hlinux/list_sort.hlinux/lockref.hlinux/rhashtable.hlinux/pid_namespace.hlinux/file.hlinux/random.hgfs2.hincore.h
Detected Declarations
struct gfs2_glock_iterstruct wait_glock_queuestruct gfs2_glockfd_iterfunction glock_wake_functionfunction wake_up_glockfunction gfs2_glock_deallocfunction __gfs2_glock_freefunction gfs2_glock_freefunction gfs2_glock_free_laterfunction gfs2_free_dead_glocksfunction gfs2_glock_holdfunction gfs2_glock_add_to_lrufunction gfs2_glock_remove_from_lrufunction gfs2_glock_queue_workfunction __gfs2_glock_putfunction __gfs2_glock_put_or_lockfunction gfs2_glock_putfunction gfs2_glock_put_asyncfunction may_grantfunction gfs2_holder_wakefunction do_errorfunction list_for_each_entry_safefunction gfs2_instantiatefunction do_promotefunction list_for_each_entryfunction state_changefunction gfs2_set_demotefunction gfs2_demote_wakefunction finish_xmotefunction do_xmotefunction run_queuefunction glock_set_objectfunction glock_clear_objectfunction gfs2_inode_remember_deletefunction gfs2_inode_already_deletedfunction gfs2_glock_pokefunction gfs2_try_to_evictfunction gfs2_queue_try_to_evictfunction gfs2_queue_verify_deletefunction delete_work_funcfunction glock_work_funcfunction gfs2_glock_getfunction __gfs2_holder_initfunction gfs2_holder_reinitfunction gfs2_holder_uninitfunction gfs2_glock_update_hold_timefunction failedfunction gfs2_glock_wait
Annotated Snippet
static const struct file_operations gfs2_glocks_fops = {
.owner = THIS_MODULE,
.open = gfs2_glocks_open,
.read = seq_read,
.llseek = seq_lseek,
.release = gfs2_glocks_release,
};
static const struct file_operations gfs2_glstats_fops = {
.owner = THIS_MODULE,
.open = gfs2_glstats_open,
.read = seq_read,
.llseek = seq_lseek,
.release = gfs2_glocks_release,
};
struct gfs2_glockfd_iter {
struct super_block *sb;
unsigned int tgid;
struct task_struct *task;
unsigned int fd;
struct file *file;
};
static struct task_struct *gfs2_glockfd_next_task(struct gfs2_glockfd_iter *i)
{
struct pid_namespace *ns = task_active_pid_ns(current);
struct pid *pid;
if (i->task)
put_task_struct(i->task);
rcu_read_lock();
retry:
i->task = NULL;
pid = find_ge_pid(i->tgid, ns);
if (pid) {
i->tgid = pid_nr_ns(pid, ns);
i->task = pid_task(pid, PIDTYPE_TGID);
if (!i->task) {
i->tgid++;
goto retry;
}
get_task_struct(i->task);
}
rcu_read_unlock();
return i->task;
}
static struct file *gfs2_glockfd_next_file(struct gfs2_glockfd_iter *i)
{
if (i->file) {
fput(i->file);
i->file = NULL;
}
for(;; i->fd++) {
i->file = fget_task_next(i->task, &i->fd);
if (!i->file) {
i->fd = 0;
break;
}
if (file_inode(i->file)->i_sb == i->sb)
break;
fput(i->file);
}
return i->file;
}
static void *gfs2_glockfd_seq_start(struct seq_file *seq, loff_t *pos)
{
struct gfs2_glockfd_iter *i = seq->private;
if (*pos)
return NULL;
while (gfs2_glockfd_next_task(i)) {
if (gfs2_glockfd_next_file(i))
return i;
i->tgid++;
}
return NULL;
}
static void *gfs2_glockfd_seq_next(struct seq_file *seq, void *iter_ptr,
loff_t *pos)
{
struct gfs2_glockfd_iter *i = seq->private;
Annotation
- Immediate include surface: `linux/sched.h`, `linux/slab.h`, `linux/spinlock.h`, `linux/buffer_head.h`, `linux/delay.h`, `linux/sort.h`, `linux/hash.h`, `linux/jhash.h`.
- Detected declarations: `struct gfs2_glock_iter`, `struct wait_glock_queue`, `struct gfs2_glockfd_iter`, `function glock_wake_function`, `function wake_up_glock`, `function gfs2_glock_dealloc`, `function __gfs2_glock_free`, `function gfs2_glock_free`, `function gfs2_glock_free_later`, `function gfs2_free_dead_glocks`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern 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.