fs/ocfs2/mmap.c
Source file repositories/reference/linux-study-clean/fs/ocfs2/mmap.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ocfs2/mmap.c- Extension
.c- Size
- 4392 bytes
- Lines
- 178
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- 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.
- 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/fs.hlinux/types.hlinux/highmem.hlinux/pagemap.hlinux/uio.hlinux/signal.hlinux/rbtree.hcluster/masklog.hocfs2.haops.hdlmglue.hfile.hinode.hmmap.hsuper.hocfs2_trace.h
Detected Declarations
function Copyrightfunction __ocfs2_page_mkwritefunction ocfs2_page_mkwritefunction ocfs2_mmap_prepare
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* mmap.c
*
* Code to deal with the mess that is clustered mmap.
*
* Copyright (C) 2002, 2004 Oracle. All rights reserved.
*/
#include <linux/fs.h>
#include <linux/types.h>
#include <linux/highmem.h>
#include <linux/pagemap.h>
#include <linux/uio.h>
#include <linux/signal.h>
#include <linux/rbtree.h>
#include <cluster/masklog.h>
#include "ocfs2.h"
#include "aops.h"
#include "dlmglue.h"
#include "file.h"
#include "inode.h"
#include "mmap.h"
#include "super.h"
#include "ocfs2_trace.h"
static vm_fault_t ocfs2_fault(struct vm_fault *vmf)
{
unsigned long long ip_blkno =
OCFS2_I(file_inode(vmf->vma->vm_file))->ip_blkno;
sigset_t oldset;
vm_fault_t ret;
ocfs2_block_signals(&oldset);
ret = filemap_fault(vmf);
ocfs2_unblock_signals(&oldset);
trace_ocfs2_fault(ip_blkno, vmf->page, vmf->pgoff);
return ret;
}
static vm_fault_t __ocfs2_page_mkwrite(struct file *file,
struct buffer_head *di_bh, struct folio *folio)
{
int err;
vm_fault_t ret = VM_FAULT_NOPAGE;
struct inode *inode = file_inode(file);
struct address_space *mapping = inode->i_mapping;
loff_t pos = folio_pos(folio);
unsigned int len = PAGE_SIZE;
pgoff_t last_index;
struct folio *locked_folio = NULL;
void *fsdata;
loff_t size = i_size_read(inode);
last_index = (size - 1) >> PAGE_SHIFT;
/*
* There are cases that lead to the page no longer belonging to the
* mapping.
* 1) pagecache truncates locally due to memory pressure.
* 2) pagecache truncates when another is taking EX lock against
* inode lock. see ocfs2_data_convert_worker.
*
* The i_size check doesn't catch the case where nodes truncated and
* then re-extended the file. We'll re-check the page mapping after
* taking the page lock inside of ocfs2_write_begin_nolock().
*
* Let VM retry with these cases.
*/
if ((folio->mapping != inode->i_mapping) ||
!folio_test_uptodate(folio) ||
(pos >= size))
goto out;
/*
* Call ocfs2_write_begin() and ocfs2_write_end() to take
* advantage of the allocation code there. We pass a write
* length of the whole page (chopped to i_size) to make sure
* the whole thing is allocated.
*
* Since we know the page is up to date, we don't have to
* worry about ocfs2_write_begin() skipping some buffer reads
* because the "write" would invalidate their data.
*/
if (folio->index == last_index)
len = ((size - 1) & ~PAGE_MASK) + 1;
Annotation
- Immediate include surface: `linux/fs.h`, `linux/types.h`, `linux/highmem.h`, `linux/pagemap.h`, `linux/uio.h`, `linux/signal.h`, `linux/rbtree.h`, `cluster/masklog.h`.
- Detected declarations: `function Copyright`, `function __ocfs2_page_mkwrite`, `function ocfs2_page_mkwrite`, `function ocfs2_mmap_prepare`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.