aio: fix oops because of extra IO control block freeing.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 81 lines · Leonid Ananiev
From Leonid Ananiev
This patch finishes moving from using errno EIOCBRETRY to using flag in IO control block for aio retrying. After this change the process will be kicked for direct aio as it was for sync aio.
Signed-off-by Leonid Ananiev <[email protected]>The patch is applied to 2.6.20 or 2.6.21-rc2 diff -uprN -X linux-2.6.20-aio21/Documentation/dontdiff
linux-2.6.20-aio21/drivers/usb/gadget/inode.clinux-2.6.20-aio22/drivers/usb/gadget/inode.c
---linux-2.6.20-aio21/drivers/usb/gadget/inode.c2007-03-04
21:45:52.000000000 +0300
+++linux-2.6.20-aio22/drivers/usb/gadget/inode.c2007-03-05
18:19:35.000000000 +0300(quoted diff) +4
-1@@ -692,7 +692,10 @@ fail: kfree(priv); put_ep(epdata); } else - value = (iv ? -EIOCBRETRY : -EIOCBQUEUED); + if (iv) + kiocbSetPgBusy(iocb); + else + value = -EIOCBQUEUED; return value; }diff -uprN -X linux-2.6.20-aio21/Documentation/dontdiff
linux-2.6.20-aio21/fs/ocfs2/dlmglue.clinux-2.6.20-aio22/fs/ocfs2/dlmglue.c
---linux-2.6.20-aio21/fs/ocfs2/dlmglue.c2007-03-04 21:45:52.000000000
+0300
+++linux-2.6.20-aio22/fs/ocfs2/dlmglue.c2007-03-04 22:57:50.000000000
+0300(quoted diff) +1
-1@@ -1639,7 +1639,7 @@ int ocfs2_meta_lock_full(struct inode *i status = ocfs2_cluster_lock(osb, lockres, level, dlm_flags, arg_flags); if (status < 0) { - if (status != -EAGAIN && status != -EIOCBRETRY) + if (status != -EAGAIN) mlog_errno(status); goto bail; }diff -uprN -X linux-2.6.20-aio21/Documentation/dontdiff
linux-2.6.20-aio21/include/linux/aio.hlinux-2.6.20-aio22/include/linux/aio.h
---linux-2.6.20-aio21/include/linux/aio.h2007-03-04 21:46:45.000000000
+0300
+++linux-2.6.20-aio22/include/linux/aio.h2007-03-04 22:57:50.000000000
+0300(quoted diff) +0
-0@@ -79,15 +79,6 @@ struct kioctx; * not ask the method again -- ki_retry must ensure forward progress. * aio_complete() must be called once and only once in the future,multiple
* calls may result in undefined behaviour.
- *
- * Ifki_retryreturns-EIOCBRETRYit has made a promise thatkick_iocb()
- * will be called on the kiocb pointer in the future. This may happen
- * through generic helpers that associatekiocb->ki_waitwith a wait
- * queue head thatki_retryuses viacurrent->io_wait. It can also happen
- * with custom tracking and manual calls tokick_iocb(), though that is
- * discouraged. In either case,kick_iocb()must be called once and only
- * once.ki_retrymust ensure forward progress, the AIO core will wait
- * indefinitely forkick_iocb()to be called.
*/
struct kiocb {
structlist_headki_run_list;
diff -uprN -X linux-2.6.20-aio21/Documentation/dontdifflinux-2.6.20-aio21/include/linux/errno.hlinux-2.6.20-aio22/include/linux/errno.h
---linux-2.6.20-aio21/include/linux/errno.h2007-03-04
21:45:51.000000000 +0300
+++linux-2.6.20-aio22/include/linux/errno.h2007-03-04
22:57:50.000000000 +0300(quoted diff) +0
-0@@ -22,7 +22,6 @@ #define EBADTYPE 527 /* Type not supported by server */ #define EJUKEBOX 528 /* Request initiated, but will not completebefore timeout */
#define EIOCBQUEUED 529 /* iocb queued, will get completion event */
-#define EIOCBRETRY 530 /* iocb queued, will trigger a retry */
Quoted 1 line
#endif
Where is kiocbSetPgBusy() defined, and where in the documentation is it explained? For that matter, what is the reason for changing the return value at all?
And if you are going to change, why not make the return value something more logical? For instance, return 0 to indicate the iocb is complete and -EINPROGRESS to indicate another kick will occur.
Alan Stern
Quoted 3 lines
Where is
kiocbSetPgBusy()defined,
It is defined in include/linux/aio.h (introduced in [PATCH 1/3])
Quoted 1 line
and where in the documentation is it explained?
I will add a comment for kiocbSetPgBusy()in aio.h.
Quoted 1 line
For that matter, what is the reason for changing the return value at
all?
EIORETRY is not IO return value at all. It is processing stage. It conflicts with IO return value. That is why a flag in iocb is used. It should be noted that loop but not EIOCBRETRY was used for vector IO (mm/filemap.c)
Leonid
Quoted 6 lines
-----Original Message-----
From: Alan Stern [mailto:[email protected]]
Sent: Monday, March 05, 2007 10:36 PM
To: Ananiev, Leonid I
Cc: Kernel development list
Subject: Re: [PATCH 2/3] aio: fix oops because of extra IO control
block freeing.
Quoted 6 lines · Leonid Ananiev
Quoted 4 lines
From Leonid Ananiev
This patch finishes moving from using errno EIOCBRETRY to using flag
in
Quoted 1 line
Quoted 1 line
IO control block for aio retrying. After this change the process will
be
Quoted 24 lines
Quoted 24 lines
kicked for direct aio as it was for sync aio.
Signed-off-by Leonid Ananiev <[email protected]>The patch is applied to 2.6.20 or 2.6.21-rc2 diff -uprN -X linux-2.6.20-aio21/Documentation/dontdiff
linux-2.6.20-aio21/drivers/usb/gadget/inode.clinux-2.6.20-aio22/drivers/usb/gadget/inode.c
---linux-2.6.20-aio21/drivers/usb/gadget/inode.c2007-03-04
21:45:52.000000000 +0300
+++linux-2.6.20-aio22/drivers/usb/gadget/inode.c2007-03-05
18:19:35.000000000 +0300(quoted diff) +4
-1@@ -692,7 +692,10 @@ fail: kfree(priv); put_ep(epdata); } else - value = (iv ? -EIOCBRETRY : -EIOCBQUEUED); + if (iv) + kiocbSetPgBusy(iocb); + else + value = -EIOCBQUEUED; return value; }
Quoted 2 lines
Quoted 2 lines
diff -uprN -X linux-2.6.20-aio21/Documentation/dontdiff
linux-2.6.20-aio21/fs/ocfs2/dlmglue.c
linux-2.6.20-aio22/fs/ocfs2/dlmglue.c
Quoted 1 line
Quoted 1 line
---
linux-2.6.20-aio21/fs/ocfs2/dlmglue.c2007-03-04
21:45:52.000000000
Quoted 2 lines
Quoted 2 lines
+0300
+++linux-2.6.20-aio22/fs/ocfs2/dlmglue.c2007-03-04
22:57:50.000000000
Quoted 4 lines
Review int ocfs2_meta_lock_full(struct inode *i · line 1640
Quoted 4 lines
+0300
(quoted diff) +0
-0@@ -1639,7 +1639,7 @@ int ocfs2_meta_lock_full(struct inode *i status = ocfs2_cluster_lock(osb, lockres, level, dlm_flags,
arg_flags);
Quoted 10 lines
Quoted 10 lines
(quoted diff) +1
-1if (status < 0) { - if (status != -EAGAIN && status != -EIOCBRETRY) + if (status != -EAGAIN) mlog_errno(status); goto bail; }diff -uprN -X linux-2.6.20-aio21/Documentation/dontdiff
linux-2.6.20-aio21/include/linux/aio.hlinux-2.6.20-aio22/include/linux/aio.h
---linux-2.6.20-aio21/include/linux/aio.h2007-03-04
21:46:45.000000000
Quoted 2 lines
Quoted 2 lines
+0300
+++linux-2.6.20-aio22/include/linux/aio.h2007-03-04
22:57:50.000000000
Quoted 3 lines
Review struct kioctx; · line 79
Quoted 3 lines
+0300
(quoted diff) +0
-0@@ -79,15 +79,6 @@ struct kioctx; * not ask the method again -- ki_retry must ensure forward
progress.
Quoted 5 lines
Quoted 5 lines
(quoted diff) +0
-0* aio_complete() must be called once and only once in the future,multiple
* calls may result in undefined behaviour.
- *
- * Ifki_retryreturns-EIOCBRETRYit has made a promise that
kick_iocb()
Quoted 1 line
Quoted 1 line
- * will be called on the kiocb pointer in the future. This may
happen
Quoted 2 lines
Quoted 2 lines
- * through generic helpers that associate
kiocb->ki_waitwith a wait
- * queue head thatki_retryuses viacurrent->io_wait. It can also
happen
Quoted 1 line
Quoted 1 line
- * with custom tracking and manual calls to
kick_iocb(), though that
is
Quoted 1 line
Quoted 1 line
- * discouraged. In either case,
kick_iocb()must be called once and
only
Quoted 1 line
Quoted 1 line
- * once.
ki_retrymust ensure forward progress, the AIO core will
wait
Quoted 6 lines
Quoted 6 lines
- * indefinitely for
kick_iocb()to be called. */
struct kiocb {
structlist_headki_run_list;
diff -uprN -X linux-2.6.20-aio21/Documentation/dontdifflinux-2.6.20-aio21/include/linux/errno.h
Quoted 8 lines
Review line 23
Quoted 8 lines
linux-2.6.20-aio22/include/linux/errno.h
---linux-2.6.20-aio21/include/linux/errno.h2007-03-04
21:45:51.000000000 +0300
+++linux-2.6.20-aio22/include/linux/errno.h2007-03-04
22:57:50.000000000 +0300(quoted diff) +0
-0@@ -22,7 +22,6 @@ #define EBADTYPE 527 /* Type not supported by server */ #define EJUKEBOX 528 /* Request initiated, but will not
complete
Quoted 2 lines
Quoted 2 lines
before timeout */
#define EIOCBQUEUED 529 /* iocb queued, will get
completion event */
Quoted 10 lines
Quoted 3 lines
-#define EIOCBRETRY 530 /* iocb queued, will trigger a retry */
#endifWhere is
kiocbSetPgBusy()defined, and where in the documentation is it explained? For that matter, what is the reason for changing the return value at all?And if you are going to change, why not make the return value something more logical? For instance, return 0 to indicate the iocb is complete
and
Quoted 3 lines
-EINPROGRESSto indicate another kick will occur.Alan Stern
Quoted 5 lines · Leonid I
Quoted 3 lines
Where is
kiocbSetPgBusy()defined,It is defined in
include/linux/aio.h(introduced in [PATCH 1/3])Quoted 1 line
and where in the documentation is it explained?
Quoted 8 lines
I will add a comment for kiocbSetPgBusy()in
aio.h.Quoted 1 line
For that matter, what is the reason for changing the return value at
all?
EIORETRY is not IO return value at all. It is processing stage. It conflicts with IO return value. That is why a flag in iocb is used. It should be noted that loop but not EIOCBRETRY was used for vector IO (mm/filemap.c)
Okay. But I don't like the name. "kiocbSetPgBusy" might be meaningful to people who understand fs/aio.c, but it isn't meaningful to other people.
Could you add this to aio.h:
#define mark_iocb_not_complete(iocb) kiocbSetPgBusy(iocb)
That would be a lot easier to understand.
Alan Stern