Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp263845ybm; Tue, 26 May 2020 16:21:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqSS1YcAX5R9ZLizGFMJOn6745eIuxbIA/X0JK27LC7xojL6gFGQXb3HebFtV611cNqQQc X-Received: by 2002:a05:6402:17ba:: with SMTP id j26mr9473627edy.324.1590535262523; Tue, 26 May 2020 16:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590535262; cv=none; d=google.com; s=arc-20160816; b=FZrnIdT5wixldpXwS2PGxvpiyJRQJqDrpWPKeQUw1kw1FGoCKUTJSApHKOki9PH1co jGbA2JsTWoLg5deJnl0SFU7feE6aeoT1f+kVp+lk+RM2WTjQbBxhXkaeABuaKivPCBwY /qA82FPkdrzjfeHduc8wdJzJdPLKcxuI3NPcWdNIPxEaapBFJAVG/iSStJBll2Um6Nea U4lcUv4F5GogyzDz0h8YwwQMmk5PK6hNFbhe6fORdk6kThVAR2ePLAiXSr5dHk4xviwd CkG8yXoxOjQ1jMChpEM2BKmBxqWO/lgcPspwx+foyDJ7vhU3tlORxc0KzegEQrE51vAz 8J8Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=egusxH2Kf4IsegITvpm+Q3F8VxKliDk7k1e8lkissGM=; b=bKcViV/whJe25dEhDjQr34EY5anFhPFBdXzjrYqRlt4ajHHWMEhEBAiFzxSq6DMVBP j3aMHmy+ZdsH6ZvpAN070xDIYGUmZHsglyEs2+dXJUsJLgOzf5YFQo6WOhudtan7sNsl Cm4sTyMNHwD9oSY9zR+b8c3fgJbGmjavyovvbvASP9+FK16bwj1c7WXhFPc5QMBVUR6C lEif67lmuhJDncyAa2ztyarslEzLirm6gJ+aW/LVypSYcmLJG2aJmmTKU30fNVArUVFd BUMLRKCn7pdyhbjPIfTHFMycBOf9GlPnnJaEq7nfP9t3kl38YpVuZM3/GMHqMuy6d5a7 FuSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=MLDFg6dO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i18si728494ejx.488.2020.05.26.16.20.39; Tue, 26 May 2020 16:21:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=MLDFg6dO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390341AbgEZTv4 (ORCPT + 99 others); Tue, 26 May 2020 15:51:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389869AbgEZTvn (ORCPT ); Tue, 26 May 2020 15:51:43 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72D7EC03E96E for ; Tue, 26 May 2020 12:51:42 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id t7so9113885plr.0 for ; Tue, 26 May 2020 12:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=egusxH2Kf4IsegITvpm+Q3F8VxKliDk7k1e8lkissGM=; b=MLDFg6dOL3wi94Sm49zoJiHajT2Z6Uem1NGpbbefsORGLMzmbgt6H7oJbyNaRmzLhC 8Gf5ZNcnIwrFrsP15fHb8Hmk8a2hfjKN86KGFvtSh4PMPlyXApwguNjE2pUXQI5wzJ0a rImtmWOl8q0Gt2VD5UOeqH755bpc04N3G1iq2vwGTCann04vKvGxeoLEFP4xQ4fRN5L5 Wg9gBx9FYIQvKM0euflOkFd88eUTLbrv+ERHN3wTJKYKJYMp38rMrtrLJwTNL4ghE1HN EtuRhPWgN+n1jwAN6pgdhE4EdIt7SHFVS5ROARRrp8WYRbT1BdjRgRCf0aEwWTyQqK88 EjdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=egusxH2Kf4IsegITvpm+Q3F8VxKliDk7k1e8lkissGM=; b=Boryl4nny5FT3uSIvONcH0kkbPGomPA7INcHeZ5eOOKC0nNC0YfHz9kP18DxUG1tqO hjru9CAdkFArhBENPESUR1Qkhd33cwC+hQWndEZA0ZqPsoguacimgKvQIFBDHVIWkrWw RWvxKDyF2CuKks1/XYzgPG5pO8hElGzad0IvqqOtsEUuR2PQ9IGwYmI927+47LXb5hfr 6kMUy3K4gojdjVJpBE+ebprJdGXr4Zcu45SuPSMf+Eega3qDwBqEAccj9TLsjON0DaoP vCTL/mQSapo3xtZtpTg3jl2B886k6mAki8hXguHlyAixdSt+5PRtNxMIOygKmW2cVXg0 0j8Q== X-Gm-Message-State: AOAM530yXFq6OS7EdtlawVh+hSK8mjA6afM3FmhrBP1CmRYSWbe/6pxF UXNun83D1n2X7m4LmmeWTu8+3cPuzM/zwA== X-Received: by 2002:a17:902:b289:: with SMTP id u9mr2621523plr.138.1590522701930; Tue, 26 May 2020 12:51:41 -0700 (PDT) Received: from x1.lan ([2605:e000:100e:8c61:94bb:59d2:caf6:70e1]) by smtp.gmail.com with ESMTPSA id c184sm313943pfc.57.2020.05.26.12.51.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 12:51:41 -0700 (PDT) From: Jens Axboe To: io-uring@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, Jens Axboe Subject: [PATCH 11/12] mm: add kiocb_wait_page_queue_init() helper Date: Tue, 26 May 2020 13:51:22 -0600 Message-Id: <20200526195123.29053-12-axboe@kernel.dk> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526195123.29053-1-axboe@kernel.dk> References: <20200526195123.29053-1-axboe@kernel.dk> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Checks if the file supports it, and initializes the values that we need. Caller passes in 'data' pointer, if any, and the callback function to be used. Signed-off-by: Jens Axboe --- include/linux/pagemap.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index d3e63c9c61ae..8b65420410ee 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -493,6 +493,27 @@ static inline int wake_page_match(struct wait_page_queue *wait_page, return 1; } +static inline int kiocb_wait_page_queue_init(struct kiocb *kiocb, + struct wait_page_queue *wait, + wait_queue_func_t func, + void *data) +{ + /* Can't support async wakeup with polled IO */ + if (kiocb->ki_flags & IOCB_HIPRI) + return -EINVAL; + if (kiocb->ki_filp->f_mode & FMODE_BUF_RASYNC) { + wait->wait.func = func; + wait->wait.private = data; + wait->wait.flags = 0; + INIT_LIST_HEAD(&wait->wait.entry); + kiocb->ki_flags |= IOCB_WAITQ; + kiocb->ki_waitq = wait; + return 0; + } + + return -EOPNOTSUPP; +} + extern void __lock_page(struct page *page); extern int __lock_page_killable(struct page *page); extern int __lock_page_async(struct page *page, struct wait_page_queue *wait); -- 2.26.2