linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch -next] ext4: locking issue on error path
@ 2012-07-17  6:31 Dan Carpenter
  2012-07-17  8:13 ` Zheng Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2012-07-17  6:31 UTC (permalink / raw)
  To: Theodore Ts'o, Zheng Liu
  Cc: Andreas Dilger, linux-ext4, linux-kernel, kernel-janitors

We recently changed how the locking worked here, but this error path was
missed.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 8c84070..2728fb7 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3031,8 +3031,10 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
 		if (!is_sync_kiocb(iocb)) {
 			ext4_io_end_t *io_end =
 				ext4_init_io_end(inode, GFP_NOFS);
-			if (!io_end)
-				return -ENOMEM;
+			if (!io_end) {
+				ret = -ENOMEM;
+				goto retake_lock;
+			}
 			io_end->flag |= EXT4_IO_END_DIRECT;
 			iocb->private = io_end;
 			/*
@@ -3094,6 +3096,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
 			ext4_clear_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN);
 		}
 
+retake_lock:
 		/* take i_mutex locking again if we do a ovewrite dio */
 		if (overwrite) {
 			up_read(&EXT4_I(inode)->i_data_sem);

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

* Re: [patch -next] ext4: locking issue on error path
  2012-07-17  6:31 [patch -next] ext4: locking issue on error path Dan Carpenter
@ 2012-07-17  8:13 ` Zheng Liu
  2012-07-23  0:20   ` Theodore Ts'o
  0 siblings, 1 reply; 3+ messages in thread
From: Zheng Liu @ 2012-07-17  8:13 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Theodore Ts'o, Zheng Liu, Andreas Dilger, linux-ext4,
	linux-kernel, kernel-janitors

On Tue, Jul 17, 2012 at 09:31:06AM +0300, Dan Carpenter wrote:
> We recently changed how the locking worked here, but this error path was
> missed.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Sorry, it is my fault.  Thanks for pointing out this bug.

Regards,
Zheng

> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 8c84070..2728fb7 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3031,8 +3031,10 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
>  		if (!is_sync_kiocb(iocb)) {
>  			ext4_io_end_t *io_end =
>  				ext4_init_io_end(inode, GFP_NOFS);
> -			if (!io_end)
> -				return -ENOMEM;
> +			if (!io_end) {
> +				ret = -ENOMEM;
> +				goto retake_lock;
> +			}
>  			io_end->flag |= EXT4_IO_END_DIRECT;
>  			iocb->private = io_end;
>  			/*
> @@ -3094,6 +3096,7 @@ static ssize_t ext4_ext_direct_IO(int rw, struct kiocb *iocb,
>  			ext4_clear_inode_state(inode, EXT4_STATE_DIO_UNWRITTEN);
>  		}
>  
> +retake_lock:
>  		/* take i_mutex locking again if we do a ovewrite dio */
>  		if (overwrite) {
>  			up_read(&EXT4_I(inode)->i_data_sem);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [patch -next] ext4: locking issue on error path
  2012-07-17  8:13 ` Zheng Liu
@ 2012-07-23  0:20   ` Theodore Ts'o
  0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2012-07-23  0:20 UTC (permalink / raw)
  To: Dan Carpenter, Zheng Liu, Andreas Dilger, linux-ext4,
	linux-kernel, kernel-janitors

On Tue, Jul 17, 2012 at 04:13:51PM +0800, Zheng Liu wrote:
> On Tue, Jul 17, 2012 at 09:31:06AM +0300, Dan Carpenter wrote:
> > We recently changed how the locking worked here, but this error path was
> > missed.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Sorry, it is my fault.  Thanks for pointing out this bug.

Since this patch hadn't been promoted past the master branch pointer
(it was only in the dev branch, which can be rebased), I've merged
this fix up with Zheng's original patch.

Dan, may thanks for finding and pointing it out!!

					- Ted

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

end of thread, other threads:[~2012-07-23  0:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-17  6:31 [patch -next] ext4: locking issue on error path Dan Carpenter
2012-07-17  8:13 ` Zheng Liu
2012-07-23  0:20   ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).