All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] fs: ocfs2: Adding new return type vm_fault_t
@ 2018-05-23 15:32 Souptick Joarder
  2018-05-30 11:40 ` Souptick Joarder
  2018-06-01 23:47   ` [Ocfs2-devel] " Andrew Morton
  0 siblings, 2 replies; 7+ messages in thread
From: Souptick Joarder @ 2018-05-23 15:32 UTC (permalink / raw)
  To: mfasheh, jlbec, willy; +Cc: ocfs2-devel, linux-kernel

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 1c8f422059ae ("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()

Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
---
 fs/ocfs2/mmap.c | 44 ++++++++++++++++++++------------------------
 1 file changed, 20 insertions(+), 24 deletions(-)

diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
index fb9a20e..036177e 100644
--- a/fs/ocfs2/mmap.c
+++ b/fs/ocfs2/mmap.c
@@ -44,11 +44,11 @@
 #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;
 	sigset_t oldset;
-	int ret;
+	vm_fault_t ret;
 
 	ocfs2_block_signals(&oldset);
 	ret = filemap_fault(vmf);
@@ -59,10 +59,11 @@ static int ocfs2_fault(struct vm_fault *vmf)
 	return ret;
 }
 
-static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh,
-				struct page *page)
+static vm_fault_t __ocfs2_page_mkwrite(struct file *file,
+			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 address_space *mapping = inode->i_mapping;
 	loff_t pos = page_offset(page);
@@ -105,15 +106,12 @@ static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh,
 	if (page->index == last_index)
 		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);
-	if (ret) {
-		if (ret != -ENOSPC)
-			mlog_errno(ret);
-		if (ret == -ENOMEM)
-			ret = VM_FAULT_OOM;
-		else
-			ret = VM_FAULT_SIGBUS;
+	if (err) {
+		if (err != -ENOSPC)
+			mlog_errno(err);
+		ret = vmf_error(err);
 		goto out;
 	}
 
@@ -121,20 +119,21 @@ static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh,
 		ret = VM_FAULT_NOPAGE;
 		goto out;
 	}
-	ret = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata);
-	BUG_ON(ret != len);
+	err = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata);
+	WARN_ON(err != len);
 	ret = VM_FAULT_LOCKED;
 out:
 	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 inode *inode = file_inode(vmf->vma->vm_file);
 	struct buffer_head *di_bh = NULL;
 	sigset_t oldset;
-	int ret;
+	int err;
+	vm_fault_t ret;
 
 	sb_start_pagefault(inode->i_sb);
 	ocfs2_block_signals(&oldset);
@@ -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
 	 * attempt page truncation as part of a downconvert.
 	 */
-	ret = ocfs2_inode_lock(inode, &di_bh, 1);
-	if (ret < 0) {
-		mlog_errno(ret);
-		if (ret == -ENOMEM)
-			ret = VM_FAULT_OOM;
-		else
-			ret = VM_FAULT_SIGBUS;
+	err = ocfs2_inode_lock(inode, &di_bh, 1);
+	if (err < 0) {
+		mlog_errno(err);
+		ret = vmf_error(err);
 		goto out;
 	}
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] fs: ocfs2: Adding new return type vm_fault_t
  2018-05-23 15:32 [PATCH v2] fs: ocfs2: Adding new return type vm_fault_t Souptick Joarder
@ 2018-05-30 11:40 ` Souptick Joarder
  2018-06-01 23:47   ` [Ocfs2-devel] " Andrew Morton
  1 sibling, 0 replies; 7+ messages in thread
From: Souptick Joarder @ 2018-05-30 11:40 UTC (permalink / raw)
  To: mfasheh, Joel Becker, Matthew Wilcox; +Cc: ocfs2-devel, linux-kernel

On Wed, May 23, 2018 at 9:02 PM, Souptick Joarder <jrdr.linux@gmail.com> wrote:
> 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 1c8f422059ae ("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()
>
> Signed-off-by: Souptick Joarder <jrdr.linux@gmail.com>
> Reviewed-by: Matthew Wilcox <mawilcox@microsoft.com>
> ---
>  fs/ocfs2/mmap.c | 44 ++++++++++++++++++++------------------------
>  1 file changed, 20 insertions(+), 24 deletions(-)
>
> diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c
> index fb9a20e..036177e 100644
> --- a/fs/ocfs2/mmap.c
> +++ b/fs/ocfs2/mmap.c
> @@ -44,11 +44,11 @@
>  #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;
>         sigset_t oldset;
> -       int ret;
> +       vm_fault_t ret;
>
>         ocfs2_block_signals(&oldset);
>         ret = filemap_fault(vmf);
> @@ -59,10 +59,11 @@ static int ocfs2_fault(struct vm_fault *vmf)
>         return ret;
>  }
>
> -static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh,
> -                               struct page *page)
> +static vm_fault_t __ocfs2_page_mkwrite(struct file *file,
> +                       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 address_space *mapping = inode->i_mapping;
>         loff_t pos = page_offset(page);
> @@ -105,15 +106,12 @@ static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh,
>         if (page->index == last_index)
>                 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);
> -       if (ret) {
> -               if (ret != -ENOSPC)
> -                       mlog_errno(ret);
> -               if (ret == -ENOMEM)
> -                       ret = VM_FAULT_OOM;
> -               else
> -                       ret = VM_FAULT_SIGBUS;
> +       if (err) {
> +               if (err != -ENOSPC)
> +                       mlog_errno(err);
> +               ret = vmf_error(err);
>                 goto out;
>         }
>
> @@ -121,20 +119,21 @@ static int __ocfs2_page_mkwrite(struct file *file, struct buffer_head *di_bh,
>                 ret = VM_FAULT_NOPAGE;
>                 goto out;
>         }
> -       ret = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata);
> -       BUG_ON(ret != len);
> +       err = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata);
> +       WARN_ON(err != len);
>         ret = VM_FAULT_LOCKED;
>  out:
>         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 inode *inode = file_inode(vmf->vma->vm_file);
>         struct buffer_head *di_bh = NULL;
>         sigset_t oldset;
> -       int ret;
> +       int err;
> +       vm_fault_t ret;
>
>         sb_start_pagefault(inode->i_sb);
>         ocfs2_block_signals(&oldset);
> @@ -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
>          * attempt page truncation as part of a downconvert.
>          */
> -       ret = ocfs2_inode_lock(inode, &di_bh, 1);
> -       if (ret < 0) {
> -               mlog_errno(ret);
> -               if (ret == -ENOMEM)
> -                       ret = VM_FAULT_OOM;
> -               else
> -                       ret = VM_FAULT_SIGBUS;
> +       err = ocfs2_inode_lock(inode, &di_bh, 1);
> +       if (err < 0) {
> +               mlog_errno(err);
> +               ret = vmf_error(err);
>                 goto out;
>         }
>
> --
> 1.9.1
>

Any comment for this patch ? We would like to
get this patch in queue for 4.18.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] fs: ocfs2: Adding new return type vm_fault_t
  2018-05-23 15:32 [PATCH v2] fs: ocfs2: Adding new return type vm_fault_t Souptick Joarder
@ 2018-06-01 23:47   ` Andrew Morton
  2018-06-01 23:47   ` [Ocfs2-devel] " Andrew Morton
  1 sibling, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2018-06-01 23:47 UTC (permalink / raw)
  To: Souptick Joarder; +Cc: mfasheh, jlbec, willy, ocfs2-devel, linux-kernel

On Wed, 23 May 2018 21:02:58 +0530 Souptick Joarder <jrdr.linux@gmail.com> wrote:

> 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 1c8f422059ae ("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()

err, no, I'll revert that part.

It could be that if this assertion triggers then filesystem corruption
would ensue, in which case a BUG_ON() is the appropriate handling. 
Such a change should be submitted separately, please.

--- a/fs/ocfs2/mmap.c~fs-ocfs2-adding-new-return-type-vm_fault_t-fix
+++ a/fs/ocfs2/mmap.c
@@ -120,7 +120,7 @@ static vm_fault_t __ocfs2_page_mkwrite(s
 		goto out;
 	}
 	err = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata);
-	WARN_ON(err != len);
+	BUG_ON(err != len);
 	ret = VM_FAULT_LOCKED;
 out:
 	return ret;
_

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH v2] fs: ocfs2: Adding new return type vm_fault_t
@ 2018-06-01 23:47   ` Andrew Morton
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2018-06-01 23:47 UTC (permalink / raw)
  To: Souptick Joarder; +Cc: mfasheh, jlbec, willy, ocfs2-devel, linux-kernel

On Wed, 23 May 2018 21:02:58 +0530 Souptick Joarder <jrdr.linux@gmail.com> wrote:

> 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 1c8f422059ae ("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()

err, no, I'll revert that part.

It could be that if this assertion triggers then filesystem corruption
would ensue, in which case a BUG_ON() is the appropriate handling. 
Such a change should be submitted separately, please.

--- a/fs/ocfs2/mmap.c~fs-ocfs2-adding-new-return-type-vm_fault_t-fix
+++ a/fs/ocfs2/mmap.c
@@ -120,7 +120,7 @@ static vm_fault_t __ocfs2_page_mkwrite(s
 		goto out;
 	}
 	err = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata);
-	WARN_ON(err != len);
+	BUG_ON(err != len);
 	ret = VM_FAULT_LOCKED;
 out:
 	return ret;
_

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] fs: ocfs2: Adding new return type vm_fault_t
  2018-06-01 23:47   ` [Ocfs2-devel] " Andrew Morton
  (?)
@ 2018-06-02  6:16   ` Souptick Joarder
  2018-06-04 23:05       ` [Ocfs2-devel] " Andrew Morton
  -1 siblings, 1 reply; 7+ messages in thread
From: Souptick Joarder @ 2018-06-02  6:16 UTC (permalink / raw)
  To: Andrew Morton
  Cc: mfasheh, Joel Becker, Matthew Wilcox, ocfs2-devel, linux-kernel

On Sat, Jun 2, 2018 at 5:17 AM, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Wed, 23 May 2018 21:02:58 +0530 Souptick Joarder <jrdr.linux@gmail.com> wrote:
>
>> 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 1c8f422059ae ("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()
>
> err, no, I'll revert that part.
>
> It could be that if this assertion triggers then filesystem corruption
> would ensue, in which case a BUG_ON() is the appropriate handling.
> Such a change should be submitted separately, please.
>

In few places checkpatch.pl throwing warning to replace BUG_ON()
with WARN_ON(). Shall we ignore these warning or it will vary across
patches ?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] fs: ocfs2: Adding new return type vm_fault_t
  2018-06-02  6:16   ` Souptick Joarder
@ 2018-06-04 23:05       ` Andrew Morton
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2018-06-04 23:05 UTC (permalink / raw)
  To: Souptick Joarder
  Cc: mfasheh, Joel Becker, Matthew Wilcox, ocfs2-devel, linux-kernel

On Sat, 2 Jun 2018 11:46:17 +0530 Souptick Joarder <jrdr.linux@gmail.com> wrote:

> On Sat, Jun 2, 2018 at 5:17 AM, Andrew Morton <akpm@linux-foundation.org> wrote:
> > On Wed, 23 May 2018 21:02:58 +0530 Souptick Joarder <jrdr.linux@gmail.com> wrote:
> >
> >> 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 1c8f422059ae ("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()
> >
> > err, no, I'll revert that part.
> >
> > It could be that if this assertion triggers then filesystem corruption
> > would ensue, in which case a BUG_ON() is the appropriate handling.
> > Such a change should be submitted separately, please.
> >
> 
> In few places checkpatch.pl throwing warning to replace BUG_ON()
> with WARN_ON(). Shall we ignore these warning or it will vary across
> patches ?

Such changes are unrelated to the vm_fault_t migration, so please don't
make them in this context.

It is true that we tend to be too eager to use BUG_ON(), but addressing
such things should be done one-at-a-time, as a separate project.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Ocfs2-devel] [PATCH v2] fs: ocfs2: Adding new return type vm_fault_t
@ 2018-06-04 23:05       ` Andrew Morton
  0 siblings, 0 replies; 7+ messages in thread
From: Andrew Morton @ 2018-06-04 23:05 UTC (permalink / raw)
  To: Souptick Joarder
  Cc: mfasheh, Joel Becker, Matthew Wilcox, ocfs2-devel, linux-kernel

On Sat, 2 Jun 2018 11:46:17 +0530 Souptick Joarder <jrdr.linux@gmail.com> wrote:

> On Sat, Jun 2, 2018 at 5:17 AM, Andrew Morton <akpm@linux-foundation.org> wrote:
> > On Wed, 23 May 2018 21:02:58 +0530 Souptick Joarder <jrdr.linux@gmail.com> wrote:
> >
> >> 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 1c8f422059ae ("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()
> >
> > err, no, I'll revert that part.
> >
> > It could be that if this assertion triggers then filesystem corruption
> > would ensue, in which case a BUG_ON() is the appropriate handling.
> > Such a change should be submitted separately, please.
> >
> 
> In few places checkpatch.pl throwing warning to replace BUG_ON()
> with WARN_ON(). Shall we ignore these warning or it will vary across
> patches ?

Such changes are unrelated to the vm_fault_t migration, so please don't
make them in this context.

It is true that we tend to be too eager to use BUG_ON(), but addressing
such things should be done one-at-a-time, as a separate project.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-06-04 23:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-23 15:32 [PATCH v2] fs: ocfs2: Adding new return type vm_fault_t Souptick Joarder
2018-05-30 11:40 ` Souptick Joarder
2018-06-01 23:47 ` Andrew Morton
2018-06-01 23:47   ` [Ocfs2-devel] " Andrew Morton
2018-06-02  6:16   ` Souptick Joarder
2018-06-04 23:05     ` Andrew Morton
2018-06-04 23:05       ` [Ocfs2-devel] " Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.