All of lore.kernel.org
 help / color / mirror / Atom feed
From: gurudas pai <gurudas.pai@oracle.com>
To: Joe Jin <joe.jin@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	torvalds@linux-foundation.org, jens.axboe@oracle.com,
	linux-kernel@vger.kernel.org, wen.gang.wang@oracle.com,
	Badari Pulavarty <pbadari@us.ibm.com>,
	Zach Brown <zach.brown@oracle.com>
Subject: Re: [PATCH] add check do_direct_IO() return val
Date: Fri, 27 Jul 2007 18:07:13 +0530	[thread overview]
Message-ID: <46A9E6F9.20603@oracle.com> (raw)
In-Reply-To: <20070727071547.GA25084@joejin-pc.cn.oracle.com>


Joe Jin wrote:
>> I think we still want to run dio_cleanup() if do_direct_IO() failed? 
>> Otherwise we can leak pages.
>>
>> And there's nothing special about EFAULT or ENOMEM here: if do_direct_IO()
>> returns any error then that's it: we bale out, yes?
>>
>
> Yes, I think we'll out from here if get EFAULT/ENOMEM error, also maybe -EIO
> return, return diretly should ok.
>
>> In fact I'm suspecting that this is what the code in there used to do. 
>> Something like:
>>
>> 	for (...) {
>> 		...
>> 		ret = do_direct_IO(...);
>> 		...
>> 		if (ret) {
>> 			dio_dleanup(dio);
>> 			break
>> 		}
>> 	}
>> 	return ret;
>>
>
> Yes, we need call dio_cleanup() to release page cache, I lost it.
>
> However, we need do more while return -ENOTBLK, right?
> so I think the patch maybe like following:
>
>
> --- linux-2.6.22/fs/direct-io.c.orig	2007-07-27 14:39:15.000000000 +0800
> +++ linux-2.6.22/fs/direct-io.c	2007-07-27 15:08:58.000000000 +0800
> @@ -1032,18 +1032,19 @@ direct_io_worker(int rw, struct kiocb *i
>  					blkbits);
>  
>  		if (ret) {
> +			if (ret == -ENOTBLK && (rw & WRITE)) {
> +				/*
> +				 * The remaining part of the request will be
> +				 * be handled by buffered I/O when we return
> +				 */
> +				ret = 0;
> +				break;
> +			}
>  			dio_cleanup(dio);
> -			break;
> +			goto out;
>  		}
>  	} /* end iovec loop */
>  
> -	if (ret == -ENOTBLK && (rw & WRITE)) {
> -		/*
> -		 * The remaining part of the request will be
> -		 * be handled by buffered I/O when we return
> -		 */
> -		ret = 0;
> -	}
>  	/*
>  	 * There may be some unwritten disk at the end of a part-written
>  	 * fs-block-sized block.  Go zero that now.
>
>
>
>
>> _
>>
>> However I'd like to ask you guys to carefully review and test that please.
>>
> Gurudas, would you please give more test of this patch?
I tested Andrew's patch and panic was gone but got few ENOTBLK.
So I tried with Joe's patch , both panic and ENOTBLK are gone now.
But in Joe's patch if (ret == -ENOTBLK && (rw & WRITE)), dio_cleanup(dio)
was not getting called because of break. So I moved dio_cleanup just 
after if (ret).
I tested with this patch, both panic and ENOTBLK are gone now.


Here is the modified patch:

--- linux-2.6.22/fs/direct-io.c.orig 2007-07-27 03:06:39.000000000 -0700
+++ linux-2.6.22/fs/direct-io.c 2007-07-27 03:24:55.000000000 -0700
@@ -1033,17 +1033,18 @@

if (ret) {
dio_cleanup(dio);
- break;
+ if (ret == -ENOTBLK && (rw & WRITE)) {
+ /*
+ * The remaining part of the request will be
+ * be handled by buffered I/O when we return
+ */
+ ret = 0;
+ break;
+ }
+ goto out;
}
} /* end iovec loop */

- if (ret == -ENOTBLK && (rw & WRITE)) {
- /*
- * The remaining part of the request will be
- * be handled by buffered I/O when we return
- */
- ret = 0;
- }
/*
* There may be some unwritten disk at the end of a part-written
* fs-block-sized block. Go zero that now.
@@ -1112,7 +1113,7 @@
kfree(dio);
} else
BUG_ON(ret != -EIOCBQUEUED);
-
+out:
return ret;
}



  parent reply	other threads:[~2007-07-27 12:38 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-26  9:04 [PATCH] add check do_direct_IO() return val Joe Jin
2007-07-27  5:13 ` Andrew Morton
2007-07-27  7:15   ` Joe Jin
2007-07-27  7:31     ` Dave Young
2007-07-27  7:44       ` Joe Jin
2007-07-27 12:37     ` gurudas pai [this message]
2007-07-28  3:47       ` Joe Jin
2007-07-30 20:53         ` Andrew Morton
2007-07-30 21:09           ` Zach Brown
2007-07-30 21:24           ` Badari Pulavarty
2007-07-30 21:45             ` Zach Brown
2007-07-30 21:58               ` Badari Pulavarty
2007-07-30 21:58                 ` Zach Brown
2007-07-30 23:38                 ` Zach Brown
2007-07-31  0:15                   ` Badari Pulavarty
2007-07-31  0:17                   ` Badari Pulavarty
2007-07-31  0:53                   ` Joe Jin
2007-07-31  3:45                     ` Badari
2007-07-31  4:35                       ` Joe Jin
2007-07-31  5:01                         ` Badari
2007-07-31 22:25                         ` Badari Pulavarty
2007-07-31 22:34                           ` Andrew Morton
2007-07-31 22:59                             ` Linus Torvalds
2007-07-31 23:16                               ` Zach Brown
2007-08-01  1:36                               ` Joe Jin
2007-08-01 11:40                                 ` gurudas pai
2007-07-31 23:04                             ` Badari Pulavarty
2007-07-31 23:14                           ` Zach Brown
2007-08-01  1:11                           ` Joe Jin
2007-07-27  8:09   ` gurudas pai
2007-07-27  5:13 ` wengang wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46A9E6F9.20603@oracle.com \
    --to=gurudas.pai@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=jens.axboe@oracle.com \
    --cc=joe.jin@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbadari@us.ibm.com \
    --cc=torvalds@linux-foundation.org \
    --cc=wen.gang.wang@oracle.com \
    --cc=zach.brown@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.