include/linux/filelock.h
Source file repositories/reference/linux-study-clean/include/linux/filelock.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/filelock.h- Extension
.h- Size
- 16353 bytes
- Lines
- 617
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/nfs_fs_i.h
Detected Declarations
struct file_lockstruct file_leasestruct file_lock_operationsstruct lock_manager_operationsstruct lease_manager_operationsstruct lock_managerstruct netstruct file_lock_corestruct file_lockstruct file_leasestruct file_lock_contextstruct notifier_blockstruct files_structstruct files_structstruct delegated_inodestruct delegated_inodefunction lock_is_unlockfunction lock_is_readfunction lock_is_writefunction locks_wake_up_waiterfunction locks_wake_upfunction locks_can_async_lockfunction locks_inode_contextfunction fcntl_getlkfunction fcntl_setlkfunction fcntl_getlk64function fcntl_setlk64function fcntl_setleasefunction fcntl_getleasefunction fcntl_setdelegfunction fcntl_getdelegfunction lock_is_unlockfunction lock_is_readfunction lock_is_writefunction locks_wake_upfunction locks_init_leasefunction locks_copy_conflockfunction locks_copy_lockfunction locks_remove_posixfunction locks_remove_filefunction posix_test_lockfunction posix_lock_filefunction locks_delete_blockfunction vfs_test_lockfunction vfs_lock_filefunction vfs_cancel_lockfunction vfs_inode_has_locksfunction locks_lock_inode_wait
Annotated Snippet
static inline bool locks_can_async_lock(const struct file_operations *fops)
{
return !fops->lock || fops->fop_flags & FOP_ASYNC_LOCK;
}
/* fs/locks.c */
void locks_free_lock_context(struct inode *inode);
void locks_free_lock(struct file_lock *fl);
void locks_init_lock(struct file_lock *);
struct file_lock *locks_alloc_lock(void);
void locks_copy_lock(struct file_lock *, struct file_lock *);
void locks_copy_conflock(struct file_lock *, struct file_lock *);
void locks_remove_posix(struct file *, fl_owner_t);
void locks_remove_file(struct file *);
void locks_release_private(struct file_lock *);
void posix_test_lock(struct file *, struct file_lock *);
int posix_lock_file(struct file *, struct file_lock *, struct file_lock *);
int locks_delete_block(struct file_lock *);
int vfs_test_lock(struct file *, struct file_lock *);
int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *);
int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
bool vfs_inode_has_locks(struct inode *inode);
int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl);
void locks_init_lease(struct file_lease *);
void locks_free_lease(struct file_lease *fl);
struct file_lease *locks_alloc_lease(void);
int __break_lease(struct inode *inode, unsigned int flags);
void lease_get_mtime(struct inode *, struct timespec64 *time);
int generic_setlease(struct file *, int, struct file_lease **, void **priv);
int kernel_setlease(struct file *, int, struct file_lease **, void **);
int vfs_setlease(struct file *, int, struct file_lease **, void **);
int lease_modify(struct file_lease *, int, struct list_head *);
u32 inode_lease_ignore_mask(struct inode *inode);
struct notifier_block;
int lease_register_notifier(struct notifier_block *);
void lease_unregister_notifier(struct notifier_block *);
struct files_struct;
void show_fd_locks(struct seq_file *f,
struct file *filp, struct files_struct *files);
bool locks_owner_has_blockers(struct file_lock_context *flctx,
fl_owner_t owner);
static inline struct file_lock_context *
locks_inode_context(const struct inode *inode)
{
/*
* Paired with smp_store_release in locks_get_lock_context().
*
* Ensures ->i_flctx will be visible if we spotted the flag.
*/
if (likely(!(smp_load_acquire(&inode->i_opflags) & IOP_FLCTX)))
return NULL;
return READ_ONCE(inode->i_flctx);
}
#else /* !CONFIG_FILE_LOCKING */
static inline int fcntl_getlk(struct file *file, unsigned int cmd,
struct flock __user *user)
{
return -EINVAL;
}
static inline int fcntl_setlk(unsigned int fd, struct file *file,
unsigned int cmd, struct flock __user *user)
{
return -EACCES;
}
#if BITS_PER_LONG == 32
static inline int fcntl_getlk64(struct file *file, unsigned int cmd,
struct flock64 *user)
{
return -EINVAL;
}
static inline int fcntl_setlk64(unsigned int fd, struct file *file,
unsigned int cmd, struct flock64 *user)
{
return -EACCES;
}
#endif
static inline int fcntl_setlease(unsigned int fd, struct file *filp, int arg)
{
return -EINVAL;
}
static inline int fcntl_getlease(struct file *filp)
Annotation
- Immediate include surface: `linux/fs.h`, `linux/nfs_fs_i.h`.
- Detected declarations: `struct file_lock`, `struct file_lease`, `struct file_lock_operations`, `struct lock_manager_operations`, `struct lease_manager_operations`, `struct lock_manager`, `struct net`, `struct file_lock_core`, `struct file_lock`, `struct file_lease`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: pattern implementation candidate.
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.