Skip to content
Snippets Groups Projects
Select Git revision
  • 931e80e4b3263db75c8e34f078d22f11bbabd3a3
  • vme-testing default
  • ci-test
  • master
  • remoteproc
  • am625-sk-ov5640
  • pcal6534-upstreaming
  • lps22df-upstreaming
  • msc-upstreaming
  • imx8mp
  • iio/noa1305
  • vme-next
  • vme-next-4.14-rc4
  • v4.14-rc4
  • v4.14-rc3
  • v4.14-rc2
  • v4.14-rc1
  • v4.13
  • vme-next-4.13-rc7
  • v4.13-rc7
  • v4.13-rc6
  • v4.13-rc5
  • v4.13-rc4
  • v4.13-rc3
  • v4.13-rc2
  • v4.13-rc1
  • v4.12
  • v4.12-rc7
  • v4.12-rc6
  • v4.12-rc5
  • v4.12-rc4
  • v4.12-rc3
32 results

filemap.c

Blame
  • file.c 4.06 KiB
    /*
     * file.c - NILFS regular file handling primitives including fsync().
     *
     * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
     *
     * 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.
     *
     * Written by Amagai Yoshiji and Ryusuke Konishi.
     */
    
    #include <linux/fs.h>
    #include <linux/mm.h>
    #include <linux/writeback.h>
    #include "nilfs.h"
    #include "segment.h"
    
    int nilfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
    {
    	/*
    	 * Called from fsync() system call
    	 * This is the only entry point that can catch write and synch
    	 * timing for both data blocks and intermediate blocks.
    	 *
    	 * This function should be implemented when the writeback function
    	 * will be implemented.
    	 */
    	struct the_nilfs *nilfs;
    	struct inode *inode = file->f_mapping->host;
    	int err = 0;
    
    	if (nilfs_inode_dirty(inode)) {
    		if (datasync)
    			err = nilfs_construct_dsync_segment(inode->i_sb, inode,
    							    start, end);
    		else
    			err = nilfs_construct_segment(inode->i_sb);
    	}
    
    	nilfs = inode->i_sb->s_fs_info;
    	if (!err)
    		err = nilfs_flush_device(nilfs);
    
    	return err;
    }
    
    static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf)
    {
    	struct vm_area_struct *vma = vmf->vma;
    	struct page *page = vmf->page;
    	struct inode *inode = file_inode(vma->vm_file);
    	struct nilfs_transaction_info ti;
    	int ret = 0;
    
    	if (unlikely(nilfs_near_disk_full(inode->i_sb->s_fs_info)))
    		return VM_FAULT_SIGBUS; /* -ENOSPC */
    
    	sb_start_pagefault(inode->i_sb);
    	lock_page(page);
    	if (page->mapping != inode->i_mapping ||
    	    page_offset(page) >= i_size_read(inode) || !PageUptodate(page)) {
    		unlock_page(page);
    		ret = -EFAULT;	/* make the VM retry the fault */