All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH] ocfs2: direct write will call ocfs2_rw_unlock() twice when doing aio+dio
@ 2015-08-24  7:09 Ryan Ding
  0 siblings, 0 replies; 4+ messages in thread
From: Ryan Ding @ 2015-08-24  7:09 UTC (permalink / raw)
  To: ocfs2-devel

Orabug: 21612107

Use wrong return value in ocfs2_file_write_iter(). This will cause
ocfs2_rw_unlock() be called both in write_iter & end_io, and trigger a BUG_ON.

This issue exist since commit 7da839c475894ea872ec909a5d2e83dddccff5be.

Signed-off-by: Ryan Ding <ryan.ding@oracle.com>
---
 fs/ocfs2/file.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 719f7f4..33efa33 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2372,6 +2372,20 @@ relock:
 	/* buffered aio wouldn't have proper lock coverage today */
 	BUG_ON(written == -EIOCBQUEUED && !(iocb->ki_flags & IOCB_DIRECT));
 
+	/*
+	 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
+	 * function pointer which is called when o_direct io completes so that
+	 * it can unlock our rw lock.
+	 * Unfortunately there are error cases which call end_io and others
+	 * that don't.  so we don't have to unlock the rw_lock if either an
+	 * async dio is going to do it in the future or an end_io after an
+	 * error has already done it.
+	 */
+	if ((written == -EIOCBQUEUED) || (!ocfs2_iocb_is_rw_locked(iocb))) {
+		rw_level = -1;
+		unaligned_dio = 0;
+	}
+
 	if (unlikely(written <= 0))
 		goto no_sync;
 
@@ -2396,20 +2410,6 @@ relock:
 	}
 
 no_sync:
-	/*
-	 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
-	 * function pointer which is called when o_direct io completes so that
-	 * it can unlock our rw lock.
-	 * Unfortunately there are error cases which call end_io and others
-	 * that don't.  so we don't have to unlock the rw_lock if either an
-	 * async dio is going to do it in the future or an end_io after an
-	 * error has already done it.
-	 */
-	if ((ret == -EIOCBQUEUED) || (!ocfs2_iocb_is_rw_locked(iocb))) {
-		rw_level = -1;
-		unaligned_dio = 0;
-	}
-
 	if (unaligned_dio) {
 		ocfs2_iocb_clear_unaligned_aio(iocb);
 		mutex_unlock(&OCFS2_I(inode)->ip_unaligned_aio);
-- 
1.7.1

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

* [Ocfs2-devel] [PATCH] ocfs2: direct write will call ocfs2_rw_unlock() twice when doing aio+dio
@ 2015-08-24  7:23 Ryan Ding
  2015-08-24  7:39 ` Junxiao Bi
  0 siblings, 1 reply; 4+ messages in thread
From: Ryan Ding @ 2015-08-24  7:23 UTC (permalink / raw)
  To: ocfs2-devel

Orabug: 21612107

Use wrong return value in ocfs2_file_write_iter(). This will cause
ocfs2_rw_unlock() be called both in write_iter & end_io, and trigger a BUG_ON.

This issue exist since commit 7da839c475894ea872ec909a5d2e83dddccff5be.

Signed-off-by: Ryan Ding <ryan.ding@oracle.com>
---
 fs/ocfs2/file.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 719f7f4..33efa33 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2372,6 +2372,20 @@ relock:
 	/* buffered aio wouldn't have proper lock coverage today */
 	BUG_ON(written == -EIOCBQUEUED && !(iocb->ki_flags & IOCB_DIRECT));
 
+	/*
+	 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
+	 * function pointer which is called when o_direct io completes so that
+	 * it can unlock our rw lock.
+	 * Unfortunately there are error cases which call end_io and others
+	 * that don't.  so we don't have to unlock the rw_lock if either an
+	 * async dio is going to do it in the future or an end_io after an
+	 * error has already done it.
+	 */
+	if ((written == -EIOCBQUEUED) || (!ocfs2_iocb_is_rw_locked(iocb))) {
+		rw_level = -1;
+		unaligned_dio = 0;
+	}
+
 	if (unlikely(written <= 0))
 		goto no_sync;
 
@@ -2396,20 +2410,6 @@ relock:
 	}
 
 no_sync:
-	/*
-	 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
-	 * function pointer which is called when o_direct io completes so that
-	 * it can unlock our rw lock.
-	 * Unfortunately there are error cases which call end_io and others
-	 * that don't.  so we don't have to unlock the rw_lock if either an
-	 * async dio is going to do it in the future or an end_io after an
-	 * error has already done it.
-	 */
-	if ((ret == -EIOCBQUEUED) || (!ocfs2_iocb_is_rw_locked(iocb))) {
-		rw_level = -1;
-		unaligned_dio = 0;
-	}
-
 	if (unaligned_dio) {
 		ocfs2_iocb_clear_unaligned_aio(iocb);
 		mutex_unlock(&OCFS2_I(inode)->ip_unaligned_aio);
-- 
1.7.1

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

* [Ocfs2-devel] [PATCH] ocfs2: direct write will call ocfs2_rw_unlock() twice when doing aio+dio
  2015-08-24  7:23 [Ocfs2-devel] [PATCH] ocfs2: direct write will call ocfs2_rw_unlock() twice when doing aio+dio Ryan Ding
@ 2015-08-24  7:39 ` Junxiao Bi
  2015-08-24 20:57   ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Junxiao Bi @ 2015-08-24  7:39 UTC (permalink / raw)
  To: ocfs2-devel

On 08/24/2015 03:23 PM, Ryan Ding wrote:
> Orabug: 21612107
> 
> Use wrong return value in ocfs2_file_write_iter(). This will cause
> ocfs2_rw_unlock() be called both in write_iter & end_io, and trigger a BUG_ON.
> 
> This issue exist since commit 7da839c475894ea872ec909a5d2e83dddccff5be.
Better say:
This issue is introduced by commit 7da839c47589 ("ocfs2: use
__generic_file_write_iter()") , or checkpatch will report a style error.
Other looks good.

Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>

Thanks,
Junxiao.
> 
> Signed-off-by: Ryan Ding <ryan.ding@oracle.com>
> ---
>  fs/ocfs2/file.c |   28 ++++++++++++++--------------
>  1 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index 719f7f4..33efa33 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -2372,6 +2372,20 @@ relock:
>  	/* buffered aio wouldn't have proper lock coverage today */
>  	BUG_ON(written == -EIOCBQUEUED && !(iocb->ki_flags & IOCB_DIRECT));
>  
> +	/*
> +	 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
> +	 * function pointer which is called when o_direct io completes so that
> +	 * it can unlock our rw lock.
> +	 * Unfortunately there are error cases which call end_io and others
> +	 * that don't.  so we don't have to unlock the rw_lock if either an
> +	 * async dio is going to do it in the future or an end_io after an
> +	 * error has already done it.
> +	 */
> +	if ((written == -EIOCBQUEUED) || (!ocfs2_iocb_is_rw_locked(iocb))) {
> +		rw_level = -1;
> +		unaligned_dio = 0;
> +	}
> +
>  	if (unlikely(written <= 0))
>  		goto no_sync;
>  
> @@ -2396,20 +2410,6 @@ relock:
>  	}
>  
>  no_sync:
> -	/*
> -	 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
> -	 * function pointer which is called when o_direct io completes so that
> -	 * it can unlock our rw lock.
> -	 * Unfortunately there are error cases which call end_io and others
> -	 * that don't.  so we don't have to unlock the rw_lock if either an
> -	 * async dio is going to do it in the future or an end_io after an
> -	 * error has already done it.
> -	 */
> -	if ((ret == -EIOCBQUEUED) || (!ocfs2_iocb_is_rw_locked(iocb))) {
> -		rw_level = -1;
> -		unaligned_dio = 0;
> -	}
> -
>  	if (unaligned_dio) {
>  		ocfs2_iocb_clear_unaligned_aio(iocb);
>  		mutex_unlock(&OCFS2_I(inode)->ip_unaligned_aio);
> 

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

* [Ocfs2-devel] [PATCH] ocfs2: direct write will call ocfs2_rw_unlock() twice when doing aio+dio
  2015-08-24  7:39 ` Junxiao Bi
@ 2015-08-24 20:57   ` Andrew Morton
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2015-08-24 20:57 UTC (permalink / raw)
  To: ocfs2-devel

On Mon, 24 Aug 2015 15:39:04 +0800 Junxiao Bi <junxiao.bi@oracle.com> wrote:

> On 08/24/2015 03:23 PM, Ryan Ding wrote:
> > Orabug: 21612107
> > 
> > Use wrong return value in ocfs2_file_write_iter(). This will cause
> > ocfs2_rw_unlock() be called both in write_iter & end_io, and trigger a BUG_ON.
> > 
> > This issue exist since commit 7da839c475894ea872ec909a5d2e83dddccff5be.
> Better say:
> This issue is introduced by commit 7da839c47589 ("ocfs2: use
> __generic_file_write_iter()") , or checkpatch will report a style error.
> Other looks good.
> 
> Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
> 

Also we've recently adopted the convention of using the "Fixes:" tag:
Fixes: 7da839c47589 ("ocfs2: use __generic_file_write_iter()")

And as the patch fixes a regression we should add the "Cc:
<stable@vger.kernel.org>" tag.

And we should the author of the bad patch for review (hi, Al).

I've made these changes and I'll get this patch into Linus this week,
for 4.2.


From: Ryan Ding <ryan.ding@oracle.com>
Subject: ocfs2: direct write will call ocfs2_rw_unlock() twice when doing aio+dio

Orabug: 21612107

ocfs2_file_write_iter() is usng the wrong return value ('written').  This
will cause ocfs2_rw_unlock() be called both in write_iter & end_io,
triggering a BUG_ON.

This issue was introduced by commit 7da839c47589 ("ocfs2: use
__generic_file_write_iter()").

Fixes: 7da839c47589 ("ocfs2: use __generic_file_write_iter()")
Signed-off-by: Ryan Ding <ryan.ding@oracle.com>
Reviewed-by: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/ocfs2/file.c |   28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff -puN fs/ocfs2/file.c~ocfs2-direct-write-will-call-ocfs2_rw_unlock-twice-when-doing-aiodio fs/ocfs2/file.c
--- a/fs/ocfs2/file.c~ocfs2-direct-write-will-call-ocfs2_rw_unlock-twice-when-doing-aiodio
+++ a/fs/ocfs2/file.c
@@ -2366,6 +2366,20 @@ relock:
 	/* buffered aio wouldn't have proper lock coverage today */
 	BUG_ON(written == -EIOCBQUEUED && !(iocb->ki_flags & IOCB_DIRECT));
 
+	/*
+	 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
+	 * function pointer which is called when o_direct io completes so that
+	 * it can unlock our rw lock.
+	 * Unfortunately there are error cases which call end_io and others
+	 * that don't.  so we don't have to unlock the rw_lock if either an
+	 * async dio is going to do it in the future or an end_io after an
+	 * error has already done it.
+	 */
+	if ((written == -EIOCBQUEUED) || (!ocfs2_iocb_is_rw_locked(iocb))) {
+		rw_level = -1;
+		unaligned_dio = 0;
+	}
+
 	if (unlikely(written <= 0))
 		goto no_sync;
 
@@ -2390,20 +2404,6 @@ relock:
 	}
 
 no_sync:
-	/*
-	 * deep in g_f_a_w_n()->ocfs2_direct_IO we pass in a ocfs2_dio_end_io
-	 * function pointer which is called when o_direct io completes so that
-	 * it can unlock our rw lock.
-	 * Unfortunately there are error cases which call end_io and others
-	 * that don't.  so we don't have to unlock the rw_lock if either an
-	 * async dio is going to do it in the future or an end_io after an
-	 * error has already done it.
-	 */
-	if ((ret == -EIOCBQUEUED) || (!ocfs2_iocb_is_rw_locked(iocb))) {
-		rw_level = -1;
-		unaligned_dio = 0;
-	}
-
 	if (unaligned_dio && ocfs2_iocb_is_unaligned_aio(iocb)) {
 		ocfs2_iocb_clear_unaligned_aio(iocb);
 		mutex_unlock(&OCFS2_I(inode)->ip_unaligned_aio);
_

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

end of thread, other threads:[~2015-08-24 20:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-24  7:23 [Ocfs2-devel] [PATCH] ocfs2: direct write will call ocfs2_rw_unlock() twice when doing aio+dio Ryan Ding
2015-08-24  7:39 ` Junxiao Bi
2015-08-24 20:57   ` Andrew Morton
  -- strict thread matches above, loose matches on Subject: below --
2015-08-24  7:09 Ryan Ding

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.