fs/backing-file.c
Source file repositories/reference/linux-study-clean/fs/backing-file.c
File Facts
- System
- Linux kernel
- Corpus path
fs/backing-file.c- Extension
.c- Size
- 8767 bytes
- Lines
- 367
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/backing-file.hlinux/splice.hlinux/mm.hlinux/security.hinternal.h
Detected Declarations
struct backing_aiofunction Copyrightfunction iocb_to_rw_flagsfunction backing_aio_putfunction backing_aio_cleanupfunction backing_aio_rw_completefunction backing_aio_complete_workfunction backing_aio_queue_completionfunction backing_aio_init_wqfunction do_backing_file_read_iterfunction backing_file_read_iterfunction do_backing_file_write_iterfunction backing_file_write_iterfunction backing_file_splice_readfunction backing_file_splice_writefunction scoped_with_credsfunction backing_file_mmapfunction scoped_with_credsfunction backing_aio_initmodule init backing_aio_initexport backing_file_openexport backing_tmpfile_openexport backing_file_read_iterexport backing_file_write_iterexport backing_file_splice_readexport backing_file_splice_writeexport backing_file_mmap
Annotated Snippet
error = vfs_open(real_path, f);
if (error) {
fput(f);
f = ERR_PTR(error);
}
return f;
}
EXPORT_SYMBOL_GPL(backing_file_open);
struct file *backing_tmpfile_open(const struct file *user_file, int flags,
const struct path *real_parentpath,
umode_t mode, const struct cred *cred)
{
struct mnt_idmap *real_idmap = mnt_idmap(real_parentpath->mnt);
const struct path *user_path = &user_file->f_path;
struct file *f;
int error;
f = alloc_empty_backing_file(flags, cred, user_file);
if (IS_ERR(f))
return f;
path_get(user_path);
backing_file_set_user_path(f, user_path);
error = vfs_tmpfile(real_idmap, real_parentpath, f, mode);
if (error) {
fput(f);
f = ERR_PTR(error);
}
return f;
}
EXPORT_SYMBOL(backing_tmpfile_open);
struct backing_aio {
struct kiocb iocb;
refcount_t ref;
struct kiocb *orig_iocb;
/* used for aio completion */
void (*end_write)(struct kiocb *iocb, ssize_t);
struct work_struct work;
long res;
};
static struct kmem_cache *backing_aio_cachep;
#define BACKING_IOCB_MASK \
(IOCB_NOWAIT | IOCB_HIPRI | IOCB_DSYNC | IOCB_SYNC | IOCB_APPEND)
static rwf_t iocb_to_rw_flags(int flags)
{
return (__force rwf_t)(flags & BACKING_IOCB_MASK);
}
static void backing_aio_put(struct backing_aio *aio)
{
if (refcount_dec_and_test(&aio->ref)) {
fput(aio->iocb.ki_filp);
kmem_cache_free(backing_aio_cachep, aio);
}
}
static void backing_aio_cleanup(struct backing_aio *aio, long res)
{
struct kiocb *iocb = &aio->iocb;
struct kiocb *orig_iocb = aio->orig_iocb;
orig_iocb->ki_pos = iocb->ki_pos;
if (aio->end_write)
aio->end_write(orig_iocb, res);
backing_aio_put(aio);
}
static void backing_aio_rw_complete(struct kiocb *iocb, long res)
{
struct backing_aio *aio = container_of(iocb, struct backing_aio, iocb);
struct kiocb *orig_iocb = aio->orig_iocb;
if (iocb->ki_flags & IOCB_WRITE)
kiocb_end_write(iocb);
backing_aio_cleanup(aio, res);
orig_iocb->ki_complete(orig_iocb, res);
}
static void backing_aio_complete_work(struct work_struct *work)
{
struct backing_aio *aio = container_of(work, struct backing_aio, work);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/backing-file.h`, `linux/splice.h`, `linux/mm.h`, `linux/security.h`, `internal.h`.
- Detected declarations: `struct backing_aio`, `function Copyright`, `function iocb_to_rw_flags`, `function backing_aio_put`, `function backing_aio_cleanup`, `function backing_aio_rw_complete`, `function backing_aio_complete_work`, `function backing_aio_queue_completion`, `function backing_aio_init_wq`, `function do_backing_file_read_iter`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration 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.