Commit c6137fe3 authored by Souptick Joarder's avatar Souptick Joarder Committed by Linus Torvalds

fs: ocfs2: use new return type vm_fault_t

Use new return type vm_fault_t for fault handler.  For now, this is just
documenting that the function returns a VM_FAULT value rather than an
errno.  Once all instances are converted, vm_fault_t will become a
distinct type.

Ref-> commit 1c8f4220 ("mm: change return type to vm_fault_t")

vmf_error() is the newly introduce inline function in 4.18.

Fix one checkpatch.pl warning by replacing BUG_ON() with WARN_ON()

[akpm@linux-foundation.org: undo BUG_ON->WARN_ON change]
Link: http://lkml.kernel.org/r/20180523153258.GA28451@jordon-HP-15-Notebook-PCSigned-off-by: default avatarSouptick Joarder <jrdr.linux@gmail.com>
Reviewed-by: default avatarMatthew Wilcox <mawilcox@microsoft.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Joseph Qi <jiangqi903@gmail.com>
Cc: Changwei Ge <ge.changwei@h3c.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 64202a21
...@@ -44,11 +44,11 @@ ...@@ -44,11 +44,11 @@
#include "ocfs2_trace.h" #include "ocfs2_trace.h"
static int ocfs2_fault(struct vm_fault *vmf) static vm_fault_t ocfs2_fault(struct vm_fault *vmf)
{ {
struct vm_area_struct *vma = vmf->vma; struct vm_area_struct *vma = vmf->vma;
sigset_t oldset; sigset_t oldset;
int ret; vm_fault_t ret;
ocfs2_block_signals(&oldset); ocfs2_block_signals(&oldset);
ret = filemap_fault(vmf); ret = filemap_fault(vmf);
...@@ -59,10 +59,11 @@ static int ocfs2_fault(struct vm_fault *vmf) ...@@ -59,10 +59,11 @@ static int ocfs2_fault(struct vm_fault *vmf)
return ret; return ret;
} }
static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh, static vm_fault_t __ocfs2_page_mkwrite(struct file *file,
struct page *page) struct buffer_head *di_bh, struct page *page)
{ {
int ret = VM_FAULT_NOPAGE; int err;
vm_fault_t ret = VM_FAULT_NOPAGE;
struct inode *inode = file_inode(file); struct inode *inode = file_inode(file);
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
loff_t pos = page_offset(page); loff_t pos = page_offset(page);
...@@ -105,15 +106,12 @@ static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh, ...@@ -105,15 +106,12 @@ static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh,
if (page->index == last_index) if (page->index == last_index)
len = ((size - 1) & ~PAGE_MASK) + 1; len = ((size - 1) & ~PAGE_MASK) + 1;
ret = ocfs2_write_begin_nolock(mapping, pos, len, OCFS2_WRITE_MMAP, err = ocfs2_write_begin_nolock(mapping, pos, len, OCFS2_WRITE_MMAP,
&locked_page, &fsdata, di_bh, page); &locked_page, &fsdata, di_bh, page);
if (ret) { if (err) {
if (ret != -ENOSPC) if (err != -ENOSPC)
mlog_errno(ret); mlog_errno(err);
if (ret == -ENOMEM) ret = vmf_error(err);
ret = VM_FAULT_OOM;
else
ret = VM_FAULT_SIGBUS;
goto out; goto out;
} }
...@@ -121,20 +119,21 @@ static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh, ...@@ -121,20 +119,21 @@ static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh,
ret = VM_FAULT_NOPAGE; ret = VM_FAULT_NOPAGE;
goto out; goto out;
} }
ret = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata); err = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata);
BUG_ON(ret != len); BUG_ON(err != len);
ret = VM_FAULT_LOCKED; ret = VM_FAULT_LOCKED;
out: out:
return ret; return ret;
} }
static int ocfs2_page_mkwrite(struct vm_fault *vmf) static vm_fault_t ocfs2_page_mkwrite(struct vm_fault *vmf)
{ {
struct page *page = vmf->page; struct page *page = vmf->page;
struct inode *inode = file_inode(vmf->vma->vm_file); struct inode *inode = file_inode(vmf->vma->vm_file);
struct buffer_head *di_bh = NULL; struct buffer_head *di_bh = NULL;
sigset_t oldset; sigset_t oldset;
int ret; int err;
vm_fault_t ret;
sb_start_pagefault(inode->i_sb); sb_start_pagefault(inode->i_sb);
ocfs2_block_signals(&oldset); ocfs2_block_signals(&oldset);
...@@ -144,13 +143,10 @@ static int ocfs2_page_mkwrite(struct vm_fault *vmf) ...@@ -144,13 +143,10 @@ static int ocfs2_page_mkwrite(struct vm_fault *vmf)
* node. Taking the data lock will also ensure that we don't * node. Taking the data lock will also ensure that we don't
* attempt page truncation as part of a downconvert. * attempt page truncation as part of a downconvert.
*/ */
ret = ocfs2_inode_lock(inode, &di_bh, 1); err = ocfs2_inode_lock(inode, &di_bh, 1);
if (ret < 0) { if (err < 0) {
mlog_errno(ret); mlog_errno(err);
if (ret == -ENOMEM) ret = vmf_error(err);
ret = VM_FAULT_OOM;
else
ret = VM_FAULT_SIGBUS;
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment