From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from verein.lst.de ([213.95.11.211]:53311 "EHLO newverein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750871AbeE2GBx (ORCPT ); Tue, 29 May 2018 02:01:53 -0400 Date: Tue, 29 May 2018 08:08:02 +0200 From: Christoph Hellwig To: Al Viro Cc: linux-fsdevel@vger.kernel.org, Christoph Hellwig Subject: Re: [PATCH v2 1/6] aio: take list removal to (some) callers of aio_complete() Message-ID: <20180529060802.GA31534@lst.de> References: <20180528175430.GC30522@ZenIV.linux.org.uk> <20180528175707.10926-1-viro@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180528175707.10926-1-viro@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, May 28, 2018 at 06:57:02PM +0100, Al Viro wrote: > From: Al Viro > > We really want iocb out of io_cancel(2) reach before we start tearing > it down. A little helper would be useful, better naming for it welcome: diff --git a/fs/aio.c b/fs/aio.c index f95b167801c2..ae5977563b7e 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1390,18 +1390,22 @@ SYSCALL_DEFINE1(io_destroy, aio_context_t, ctx) return -EINVAL; } +static void aio_remove_iocb(struct aio_kiocb *iocb) +{ + struct kioctx *ctx = iocb->ki_ctx; + unsigned long flags; + + spin_lock_irqsave(&ctx->ctx_lock, flags); + list_del(&iocb->ki_list); + spin_unlock_irqrestore(&ctx->ctx_lock, flags); +} + static void aio_complete_rw(struct kiocb *kiocb, long res, long res2) { struct aio_kiocb *iocb = container_of(kiocb, struct aio_kiocb, rw); - if (!list_empty_careful(&iocb->ki_list)) { - struct kioctx *ctx = iocb->ki_ctx; - unsigned long flags; - - spin_lock_irqsave(&ctx->ctx_lock, flags); - list_del(&iocb->ki_list); - spin_unlock_irqrestore(&ctx->ctx_lock, flags); - } + if (!list_empty_careful(&iocb->ki_list)) + aio_remove_iocb(iocb); if (kiocb->ki_flags & IOCB_WRITE) { struct inode *inode = file_inode(kiocb->ki_filp); @@ -1605,15 +1609,8 @@ static void aio_poll_work(struct work_struct *work) { struct aio_kiocb *iocb = container_of(work, struct aio_kiocb, poll.work); - if (!list_empty_careful(&iocb->ki_list)) { - struct kioctx *ctx = iocb->ki_ctx; - unsigned long flags; - - spin_lock_irqsave(&ctx->ctx_lock, flags); - list_del(&iocb->ki_list); - spin_unlock_irqrestore(&ctx->ctx_lock, flags); - } - + if (!list_empty_careful(&iocb->ki_list)) + aio_remove_iocb(iocb); __aio_poll_complete(iocb, iocb->poll.events); }