Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4810259yba; Tue, 30 Apr 2019 04:53:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMop2QEPV39IFuhZ96tsqs+bGgMmZgD5FDkh8YtWs7gxnUnUUcfbXL5cHuDHcY3vX3Xj+n X-Received: by 2002:a17:902:6809:: with SMTP id h9mr8319885plk.129.1556625217215; Tue, 30 Apr 2019 04:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556625217; cv=none; d=google.com; s=arc-20160816; b=ulVR3lCQLqWNpge7xA91yUZT0r0mblNzQw42Ymrj6Zcr71teNvY0S2Fvy6Ths+lEwR lBWGy0iyXUII9YE+pFTmBHdtCMAjJqtjbp0FVc9jqPwXKhhCHpdSsnVjv02tpTHtNM8i rUHfQEHs1ABzaFkvTJDQPLdbFQDfPax91vmJ0cDiQsnE29VEPTDowo/lBkTEOBCKuy70 g2BUmOz7Bu3h1TNJ3mYHJYXYRJnClu6xSwUPvicFSQQmtn4gQFiKJTAtTfQ9fQflrRVI pbz7X9xbsthZUVTZ9wO+EmDA/Byb2cok0ER19QmiPmUkKTdcz2HVfTr1sXLKI7J2bDe/ 2+vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LDrOyB0r6t8c9/iUMpYFKODpWd8fuc6u5Mcz1g43/mU=; b=bloWcCzcs3xjOOnV/fJAVZk9tEMmueXBhWV9PPOzAZ9oQqLUToufLLuQE56/lM4lsY YZz3IgFx7PaEIXptrRTM/WrdHhjHTtdQxjpu56SrHv7e3ykthPPFNBPIPpmLyAVN4FxX TiQIv8/80F+wzpnjg8mmFHeytFq7PTXAIHleO28PLraMwMt2fh/gbPpWs7YdPDtrBSSP aMkV0UJbdZCGqwBb0SDvPz9qKlXJWQosxp0zrbrp0vecj8khKEZ3hmuntG0UPfIZNqaz PxS9M1IJBD2sRhSVZtrJuCUhN3QPg5Cy56V4CBwvvo/+YnawsaBt2IU4qyHVedFGoHIb CPZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lVtO0hhC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i195si35624234pgd.521.2019.04.30.04.53.21; Tue, 30 Apr 2019 04:53:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lVtO0hhC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730881AbfD3Lug (ORCPT + 99 others); Tue, 30 Apr 2019 07:50:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:37588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731206AbfD3Lub (ORCPT ); Tue, 30 Apr 2019 07:50:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DB1FF2054F; Tue, 30 Apr 2019 11:50:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556625030; bh=62l78q4y2l6657LqOMaKarUovQIFpRJTX+xk06Kx7aI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lVtO0hhCgBu1Pd1x5t50S48CcHZEHXHFa1+podDSthnpYu/Xx1d8y8qEI5lxYIVpl pJY+XOfRA26GlHgC0BFgEYbLI8J93HpOyC6CJBUUQfJx/FZEHy3BHcH0xSwv2QJ0FW mbeyzSIVYFC21sxOUlyok34beELh8/1arkuW8AvI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Al Viro , Guenter Roeck Subject: [PATCH 5.0 65/89] aio: fold lookup_kiocb() into its sole caller Date: Tue, 30 Apr 2019 13:38:56 +0200 Message-Id: <20190430113612.765500173@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113609.741196396@linuxfoundation.org> References: <20190430113609.741196396@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro commit 833f4154ed560232120bc475935ee1d6a20e159f upstream. Signed-off-by: Al Viro Cc: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- fs/aio.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) --- a/fs/aio.c +++ b/fs/aio.c @@ -2002,24 +2002,6 @@ COMPAT_SYSCALL_DEFINE3(io_submit, compat } #endif -/* lookup_kiocb - * Finds a given iocb for cancellation. - */ -static struct aio_kiocb * -lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb) -{ - struct aio_kiocb *kiocb; - - assert_spin_locked(&ctx->ctx_lock); - - /* TODO: use a hash or array, this sucks. */ - list_for_each_entry(kiocb, &ctx->active_reqs, ki_list) { - if (kiocb->ki_user_iocb == iocb) - return kiocb; - } - return NULL; -} - /* sys_io_cancel: * Attempts to cancel an iocb previously passed to io_submit. If * the operation is successfully cancelled, the resulting event is @@ -2048,10 +2030,13 @@ SYSCALL_DEFINE3(io_cancel, aio_context_t return -EINVAL; spin_lock_irq(&ctx->ctx_lock); - kiocb = lookup_kiocb(ctx, iocb); - if (kiocb) { - ret = kiocb->ki_cancel(&kiocb->rw); - list_del_init(&kiocb->ki_list); + /* TODO: use a hash or array, this sucks. */ + list_for_each_entry(kiocb, &ctx->active_reqs, ki_list) { + if (kiocb->ki_user_iocb == iocb) { + ret = kiocb->ki_cancel(&kiocb->rw); + list_del_init(&kiocb->ki_list); + break; + } } spin_unlock_irq(&ctx->ctx_lock);