[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180330071408.GB17095@lst.de>
Date: Fri, 30 Mar 2018 09:14:08 +0200
From: Christoph Hellwig <hch@....de>
To: Al Viro <viro@...IV.linux.org.uk>
Cc: Christoph Hellwig <hch@....de>, Avi Kivity <avi@...lladb.com>,
linux-aio@...ck.org, linux-fsdevel@...r.kernel.org,
netdev@...r.kernel.org, linux-api@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 07/30] aio: add delayed cancel support
On Thu, Mar 29, 2018 at 11:35:00PM +0100, Al Viro wrote:
> Uh-oh... What happens to existing users of kiocb_set_cancel_fn() now?
> AFAICS, those guys will *not* get aio_kiocb freed at all in case of
> io_cancel(2). Look: we mark them with AIO_IOCB_CANCELLED and
> call whatever ->ki_cancel() the driver has set. Later the damn
> thing calls ->ki_complete() (i.e. aio_complete_rw()), which calls
> aio_complete(iocb, res, res2, 0) and gets false. Nothing's freed,
> struct file is leaked.
True, we'd need a complete call from it.
> Frankly, the more I look at that, the less I like what you've done
> with ->ki_cancel() overloading. In regular case it's just accelerating
> the call of ->ki_complete(), which will do freeing. Here you have
> ->ki_cancel() free the damn thing, with the resulting need to play
> silly buggers with locking, freeing logics in aio_complete(), etc.
I don't really like it all that much either, but I also think the
current model is pretty broken - called under spinlock with irqs
disabled is not even what the current users expect. Second issue
with the existing ki_cancel is that kiocb_set_cancel_fn operates
on a kiocb, but expects that to be embedded in an aio_kiocb, which
might not always be the case, althought in-kernel I/O is unlikely to
be used on them. And based on all of these I bet gadget aio cancel
is basically untested.
Anyway, I guess splitting poll direct cancel out in a way that doesn't
overload ->ki_cancel might be a good idea. It all is inside aio.c
so simply switching on the opcode similar to the submission path
might be one option, or having separate methods. Moving ki_cancel
to kiocb would also solve above mismatch issue.
Powered by blists - more mailing lists