Skip to contentSkip to conversation

: Correct ambiguous errno of aio

RFC PATCH In review Yi Yang 3 participants 4 messages Aug 28, 2006

Subsystems (2)
lore
Share & tools
lore

Yi Yang

author
#0 lore raw

RFC PATCH 1/1 : Correct ambiguous errno of aio

In the current implementation of AIO, for the operation IOCB_CMD_FDSYNC and IOCB_CMD_FSYNC, the returned errno is -EINVAL although the kernel does know them, I think the correct errno should be -EOPNOTSUPP which means they aren't be implemented or supported.

Quoted 1 line

From the kernel source code, we can see they can be supported without

any code modification if a specific filesystem implements aio_fsync.

Another obvious problem is the function aio_fsync is as same as the function aio_fdsync, so they are duplicate, only one is enough.

Here this patch is.

fs/aio.c 2006-08-28 15:33:59.000000000 +0800 renamed from fs/aio.c.orig 2006-08-28 15:15:18.000000000 +0800 +0 -0
@@ -1363,20 +1363,10 @@ static ssize_t aio_pwrite(struct kiocb *

return ret;
}

-static ssize_t aio_fdsync(struct kiocb *iocb)
-{
- struct file *file = iocb->ki_filp;
- ssize_t ret = -EINVAL;
-
- if (file->f_op->aio_fsync)
- ret = file->f_op->aio_fsync(iocb, 1);
- return ret;
-}
-
static ssize_t aio_fsync(struct kiocb *iocb)
{
struct file *file = iocb->ki_filp;
- ssize_t ret = -EINVAL;
+ ssize_t ret = -EOPNOTSUPP;

if (file->f_op->aio_fsync)
ret = file->f_op->aio_fsync(iocb, 0);
@@ -1425,12 +1415,12 @@ static ssize_t aio_setup_iocb(struct kio kiocb->ki_retry = aio_pwrite;
break;
case IOCB_CMD_FDSYNC:
- ret = -EINVAL;
+ ret = -EOPNOTSUPP;
if (file->f_op->aio_fsync)
- kiocb->ki_retry = aio_fdsync;
+ kiocb->ki_retry = aio_fsync;
break;
case IOCB_CMD_FSYNC:
- ret = -EINVAL;
+ ret = -EOPNOTSUPP;
if (file->f_op->aio_fsync)
kiocb->ki_retry = aio_fsync;
break;

#1 lore raw
Quoted 4 lines · Yi Yang

In the current implementation of AIO, for the operation IOCB_CMD_FDSYNC and IOCB_CMD_FSYNC, the returned errno is -EINVAL although the kernel does know them, I think the correct errno should be -EOPNOTSUPP which means they aren't be implemented or supported.

Hi,

If I'm not mistaken, returning EINVAL conforms to POSIX, isn't it?
http://www.opengroup.org/onlinepubs/009695399/functions/fsync.html
Regards,
Frederik

author
#2 lore raw
Quoted 11 lines · Frederik Deweerdt
Quoted 5 lines · Yi Yang

In the current implementation of AIO, for the operation IOCB_CMD_FDSYNC and IOCB_CMD_FSYNC, the returned errno is -EINVAL although the kernel does know them, I think the correct errno should be -EOPNOTSUPP which means they aren't be implemented or supported.

Hi,

If I'm not mistaken, returning EINVAL conforms to POSIX, isn't it?

But POSIX also defined ENOTSUP which is equal to EOPNOTSUPP for linux.

Quoted 6 lines

http://www.opengroup.org/onlinepubs/009695399/functions/fsync.html
Regards,
Frederik

#3 lore raw
In reply to Yi Yang
Quoted 5 lines · On Mon, 28 Aug 2006 21:28:48 +0800 Yi Yang wrote:

In the current implementation of AIO, for the operation IOCB_CMD_FDSYNC and IOCB_CMD_FSYNC, the returned errno is -EINVAL although the kernel does know them, I think the correct errno should be -EOPNOTSUPP which means they aren't be implemented or supported.

Quoted 8 lines
Quoted 1 line

From the kernel source code, we can see they can be supported without

any code modification if a specific filesystem implements aio_fsync.

Another obvious problem is the function aio_fsync is as same as the function aio_fdsync, so they are duplicate, only one is enough.

Here this patch is.

gmail ate all of the tabs, maybe other whitespace problems.

Quoted 34 lines
fs/aio.c 2006-08-28 15:33:59.000000000 +0800 renamed from fs/aio.c.orig 2006-08-28 15:15:18.000000000 +0800 +1 -11
@@ -1363,20 +1363,10 @@ static ssize_t aio_pwrite(struct kiocb *
 return ret;
 }
 
-static ssize_t aio_fdsync(struct kiocb *iocb)
-{
- struct file *file = iocb->ki_filp;
- ssize_t ret = -EINVAL;
-
- if (file->f_op->aio_fsync)
- ret = file->f_op->aio_fsync(iocb, 1);
- return ret;
-}
-
 static ssize_t aio_fsync(struct kiocb *iocb)
 {
 struct file *file = iocb->ki_filp;
- ssize_t ret = -EINVAL;
+ ssize_t ret = -EOPNOTSUPP;
 
 if (file->f_op->aio_fsync)
 ret = file->f_op->aio_fsync(iocb, 0);
@@ -1425,12 +1415,12 @@ static ssize_t aio_setup_iocb(struct kio
 kiocb->ki_retry = aio_pwrite;
 break;

case IOCB_CMD_FDSYNC:
- ret = -EINVAL;
+ ret = -EOPNOTSUPP;
if (file->f_op->aio_fsync)
- kiocb->ki_retry = aio_fdsync;
+ kiocb->ki_retry = aio_fsync;

Quoted 8 lines

break;
case IOCB_CMD_FSYNC:
- ret = -EINVAL;
+ ret = -EOPNOTSUPP;
if (file->f_op->aio_fsync)
kiocb->ki_retry = aio_fsync;
break;
-

---
~Randy