From: "Manish Katiyar" <mkatiyar@gmail.com>
To: "Marco Stornelli" <marco.stornelli@coritel.it>
Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vfs: added better file aio_read aio_write operations presence check
Date: Tue, 16 Sep 2008 17:01:04 +0530 [thread overview]
Message-ID: <ea11fea30809160431v50f4d48i22a9dddf496aea34@mail.gmail.com> (raw)
In-Reply-To: <48CF94DE.7020209@coritel.it>
On Tue, Sep 16, 2008 at 4:43 PM, Marco Stornelli
<marco.stornelli@coritel.it> wrote:
> BUG_ON it was a way to say: "hey you've used the do_sync_read/write as
> read/write operation but you don't specified an aio_read/write", but
> your solutions it's good too.
Looks like I made some copy paste error while sending the patch. Below
is the updated one.
Signed-off-by: Manish Katiyar <mkatiyar@gmail.com>
---
fs/read_write.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/fs/read_write.c b/fs/read_write.c
index 9ba495d..b89b707 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -225,7 +225,10 @@ ssize_t do_sync_read(struct file *filp, char
__user *buf, size_t len, loff_t *pp
kiocb.ki_left = len;
for (;;) {
- ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
+ if (filp->f_op->aio_read)
+ ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
+ else
+ ret = generic_file_aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
if (ret != -EIOCBRETRY)
break;
wait_on_retry_sync_kiocb(&kiocb);
@@ -280,7 +283,10 @@ ssize_t do_sync_write(struct file *filp, const
char __user *buf, size_t len, lof
kiocb.ki_left = len;
for (;;) {
- ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
+ if (filp->f_op->aio_write)
+ ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
+ else
+ ret = generic_file_aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
if (ret != -EIOCBRETRY)
break;
wait_on_retry_sync_kiocb(&kiocb);
--
1.5.4.3
Thanks -
Manish
>
> Manish Katiyar ha scritto:
>> On Tue, Sep 16, 2008 at 2:59 PM, Marco Stornelli
>> <marco.stornelli@coritel.it> wrote:
>>> From: Marco Stornelli <marco.stornelli@gmail.com>
>>>
>>> If a filesystem in the file operations specifies for read and write operations only do_sync_read and do_sync_write without
>>> init aio_read and aio_write, there will be a kernel oops, because the vfs code check the presence of (to read for example)
>>> read OR aio_read method, then it calls read if it's pointer is not null. It's not sufficient because if the read function is
>>> actually a do_sync_read, it calls aio_read but without checking the presence. I think a BUG_ON check can be more useful.
>>
>> Instead of doing a BUG_ON() why can't we simply fall back to the
>> generic_aio functions since most of the fs tend to do so as below.
>>
>>
>> Signed-off-by: Manish Katiyar <mkatiyar@gmail.com>
>>
>> ---
>> fs/read_write.c | 10 ++++++++--
>> 1 files changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/read_write.c b/fs/read_write.c
>> index 9ba495d..5439bc4 100644
>> --- a/fs/read_write.c
>> +++ b/fs/read_write.c
>> @@ -225,7 +225,11 @@ ssize_t do_sync_read(struct file *filp, char
>> __user *buf, size_t len, loff_t *pp
>> kiocb.ki_left = len;
>>
>> for (;;) {
>> - ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
>> + if (filp->f_op->aio_read)
>> + ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
>> + else
>> + ret = generic_file_aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
>> if (ret != -EIOCBRETRY)
>> break;
>> wait_on_retry_sync_kiocb(&kiocb);
>> @@ -280,7 +284,10 @@ ssize_t do_sync_write(struct file *filp, const
>> char __user *buf, size_t len, lof
>> kiocb.ki_left = len;
>>
>> for (;;) {
>> - ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
>> + if (filp->f_op->aio_write)
>> + ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
>> + else
>> + ret = generic_file_aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
>> if (ret != -EIOCBRETRY)
>> break;
>> wait_on_retry_sync_kiocb(&kiocb);
>
>
next prev parent reply other threads:[~2008-09-16 11:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-16 9:29 [PATCH] vfs: added better file aio_read aio_write operations presence check Marco Stornelli
2008-09-16 11:03 ` Manish Katiyar
2008-09-16 11:13 ` Marco Stornelli
2008-09-16 11:31 ` Manish Katiyar [this message]
2008-09-16 16:36 ` Christoph Hellwig
[not found] <bcF2N-29W-1@gated-at.bofh.it>
[not found] ` <bcGBv-4eJ-1@gated-at.bofh.it>
2008-09-16 15:36 ` Bodo Eggert
2008-09-16 15:41 ` Matthew Wilcox
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=ea11fea30809160431v50f4d48i22a9dddf496aea34@mail.gmail.com \
--to=mkatiyar@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marco.stornelli@coritel.it \
--cc=viro@zeniv.linux.org.uk \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox