cregit-Linux how code gets into the kernel

Release 4.18 fs/ocfs2/mmap.c

Directory: fs/ocfs2
/* -*- mode: c; c-basic-offset: 8; -*-
 * vim: noexpandtab sw=8 ts=8 sts=0:
 *
 * mmap.c
 *
 * Code to deal with the mess that is clustered mmap.
 *
 * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 021110-1307, USA.
 */

#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) { struct vm_area_struct *vma = vmf->vma; sigset_t oldset; vm_fault_t ret; ocfs2_block_signals(&oldset); ret = filemap_fault(vmf); ocfs2_unblock_signals(&oldset); trace_ocfs2_fault(OCFS2_I(vma->vm_file->f_mapping->host)->ip_blkno, vma, vmf->page, vmf->pgoff); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Mark Fasheh3243.24%112.50%
Tao Ma1824.32%225.00%
Dave Jiang1114.86%112.50%
Nicholas Piggin912.16%225.00%
Souptick Joarder22.70%112.50%
Joel Becker22.70%112.50%
Total74100.00%8100.00%


static vm_fault_t __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh, struct page *page) { 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 = page_offset(page); unsigned int len = PAGE_SIZE; pgoff_t last_index; struct page *locked_page = 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 bebongs 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 ((page->mapping != inode->i_mapping) || (!PageUptodate(page)) || (page_offset(page) >= 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 (page->index == last_index) len = ((size - 1) & ~PAGE_MASK) + 1; err = ocfs2_write_begin_nolock(mapping, pos, len, OCFS2_WRITE_MMAP, &locked_page, &fsdata, di_bh, page); if (err) { if (err != -ENOSPC) mlog_errno(err); ret = vmf_error(err); goto out; } if (!locked_page) { ret = VM_FAULT_NOPAGE; goto out; } err = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata); BUG_ON(err != len); ret = VM_FAULT_LOCKED; out: return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Mark Fasheh15060.73%323.08%
Wengang Wang3815.38%17.69%
Tao Ma218.50%215.38%
Souptick Joarder145.67%17.69%
Sunil Mushran93.64%17.69%
Tiger Yang52.02%17.69%
Nicholas Piggin31.21%17.69%
Kirill A. Shutemov31.21%17.69%
Al Viro31.21%17.69%
Ryan Ding10.40%17.69%
Total247100.00%13100.00%


static vm_fault_t ocfs2_page_mkwrite(struct vm_fault *vmf) { struct page *page = vmf->page; struct inode *inode = file_inode(vmf->vma->vm_file); struct buffer_head *di_bh = NULL; sigset_t oldset; int err; vm_fault_t ret; sb_start_pagefault(inode->i_sb); ocfs2_block_signals(&oldset); /* * The cluster locks taken will block a truncate from another * node. Taking the data lock will also ensure that we don't * attempt page truncation as part of a downconvert. */ err = ocfs2_inode_lock(inode, &di_bh, 1); if (err < 0) { mlog_errno(err); ret = vmf_error(err); goto out; } /* * The alloc sem should be enough to serialize with * ocfs2_truncate_file() changing i_size as well as any thread * modifying the inode btree. */ down_write(&OCFS2_I(inode)->ip_alloc_sem); ret = __ocfs2_page_mkwrite(vmf->vma->vm_file, di_bh, page); up_write(&OCFS2_I(inode)->ip_alloc_sem); brelse(di_bh); ocfs2_inode_unlock(inode, 1); out: ocfs2_unblock_signals(&oldset); sb_end_pagefault(inode->i_sb); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Mark Fasheh11669.46%327.27%
Jan Kara1710.18%218.18%
Souptick Joarder116.59%19.09%
Nicholas Piggin116.59%19.09%
Dave Jiang42.40%19.09%
Al Viro31.80%19.09%
Tao Ma31.80%19.09%
Joel Becker21.20%19.09%
Total167100.00%11100.00%

static const struct vm_operations_struct ocfs2_file_vm_ops = { .fault = ocfs2_fault, .page_mkwrite = ocfs2_page_mkwrite, };
int ocfs2_mmap(struct file *file, struct vm_area_struct *vma) { int ret = 0, lock_level = 0; ret = ocfs2_inode_lock_atime(file_inode(file), file->f_path.mnt, &lock_level, 1); if (ret < 0) { mlog_errno(ret); goto out; } ocfs2_inode_unlock(file_inode(file), lock_level); out: vma->vm_ops = &ocfs2_file_vm_ops; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Mark Fasheh3946.99%337.50%
Tiger Yang3238.55%112.50%
Al Viro910.84%225.00%
Gang He22.41%112.50%
Christoph Hellwig11.20%112.50%
Total83100.00%8100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Mark Fasheh39561.91%414.81%
Tao Ma457.05%414.81%
Wengang Wang385.96%13.70%
Tiger Yang375.80%13.70%
Souptick Joarder274.23%13.70%
Nicholas Piggin253.92%414.81%
Jan Kara172.66%27.41%
Dave Jiang152.35%13.70%
Al Viro152.35%27.41%
Sunil Mushran91.41%13.70%
Joel Becker71.10%13.70%
Kirill A. Shutemov30.47%13.70%
Gang He20.31%13.70%
Christoph Hellwig10.16%13.70%
Alexey Dobriyan10.16%13.70%
Ryan Ding10.16%13.70%
Total638100.00%27100.00%
Directory: fs/ocfs2
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.