From patchwork Thu Jun 18 14:43:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 11612351 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4FD05913 for ; Thu, 18 Jun 2020 14:44:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1CA2920888 for ; Thu, 18 Jun 2020 14:44:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel-dk.20150623.gappssmtp.com header.i=@kernel-dk.20150623.gappssmtp.com header.b="bUiZ2Fxa" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CA2920888 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CBD1A8D0026; Thu, 18 Jun 2020 10:44:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C1C1F8D0018; Thu, 18 Jun 2020 10:44:20 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B31688D0026; Thu, 18 Jun 2020 10:44:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0191.hostedemail.com [216.40.44.191]) by kanga.kvack.org (Postfix) with ESMTP id 8C9A38D0018 for ; Thu, 18 Jun 2020 10:44:20 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 449951498EF for ; Thu, 18 Jun 2020 14:44:20 +0000 (UTC) X-FDA: 76942603080.02.glue33_0303ab226e11 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin02.hostedemail.com (Postfix) with ESMTP id 15D9DAA249 for ; Thu, 18 Jun 2020 14:44:20 +0000 (UTC) X-Spam-Summary: 2,0,0,adfaff542ccc240b,d41d8cd98f00b204,axboe@kernel.dk,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1431:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3867:3868:3870:3872:3874:5007:6261:6653:10004:11026:11473:11658:11914:12043:12114:12291:12438:12517:12519:12555:12895:13069:13311:13357:13894:14096:14181:14384:14394:14721:21080:21324:21444:21451:21627:21990:30054,0,RBL:209.85.215.195:@kernel.dk:.lbl8.mailshell.net-62.2.0.100 66.100.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: glue33_0303ab226e11 X-Filterd-Recvd-Size: 4461 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Thu, 18 Jun 2020 14:44:19 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id h10so2988001pgq.10 for ; Thu, 18 Jun 2020 07:44:19 -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:reply-to :mime-version:content-transfer-encoding; bh=qG+PVAwYXEH3Rowu54+BkyZS7fslCJIulLcAGKfzRB8=; b=bUiZ2FxaCsZtyTAaJBoFcJMrX/CUga9qC0v2B0H5JcW44TVjLNQskpGK86a5Zb631M p0I2rj2UBPJFfNusO9HGLjnYw/iM43LqQ928bwfe2TjZbjF/4Hg7nfa5uPlMNvTn3vO1 apcy+p2q8hky9Ls8gdUEdvgAwIA3LtH/8apm463k0TATUTGX0gwMdBhkDB52mw3XPrHh GrIGx+AghUZ13e4QtMHcv9dXOv4lssAk0Hv512Bg1on9er9ClFRT03k4kQjM4RRxOSPW 6hvmoIIT3WZGyFLsTEshOvym+xTAnpq2veuMMOcqepVgDlq37cK5gOQh2kGyUaORNsIr A/uw== 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:reply-to:mime-version:content-transfer-encoding; bh=qG+PVAwYXEH3Rowu54+BkyZS7fslCJIulLcAGKfzRB8=; b=YP/iEqaCDNIYDvm3PdD0jau8ypc6LYK18jzohQMQJvsD+OUaqE7x2oSIBgMs75Jtkd Oi6Qek8zmI2M16aJdoi4x7NbC0b5wRTa0xr9F8rNGYBKqL/brM8G4TiLgIj9eAP2tByb xRZB+jXugAEI4Ah5+AuGNO8w1LVFxFGtHxmcTP8T36OxmYqSb36njysO3SPlBC9uQ8+u PzSkzRXHiuZxLnE8scyiNWCFKfT8AuwpmlW9VYvpkjlBmiWhnAJthBmtRffe9mZ3ssDS bD0w74Q9ISjj7cjLrVp4aIf6h6TcpYJxp4TaDmnL2Dth5DdFK9aEgXkzXEC4nsFh7Zs+ fryQ== X-Gm-Message-State: AOAM533QFS2dY/gqLQkVo2LJa2pL4tfmVHu2vMHlSqXNnvaLA2NaSTAg FvZ8HLWbl6OlVy38O0MfrlgtJw== X-Google-Smtp-Source: ABdhPJzzGfgUvN38nQlE0ltPql9r24L3d5fAFgRA+DRt5giXUwPYRi3iuK4YpxPwlcYuqcOquHT1Ag== X-Received: by 2002:a62:7e95:: with SMTP id z143mr3898104pfc.108.1592491458734; Thu, 18 Jun 2020 07:44:18 -0700 (PDT) Received: from x1.localdomain ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id g9sm3127197pfm.151.2020.06.18.07.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jun 2020 07:44:18 -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 , Johannes Weiner Subject: [PATCH 14/15] mm: add kiocb_wait_page_queue_init() helper Date: Thu, 18 Jun 2020 08:43:54 -0600 Message-Id: <20200618144355.17324-15-axboe@kernel.dk> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200618144355.17324-1-axboe@kernel.dk> References: <20200618144355.17324-1-axboe@kernel.dk> Reply-To: "[PATCHSET v7 0/15]"@smtpin02.hostedemail.com, Add@smtpin02.hostedemail.com, support@smtpin02.hostedemail.com, for@smtpin02.hostedemail.com, async@smtpin02.hostedemail.com, buffered@smtpin02.hostedemail.com, reads@smtpin02.hostedemail.com MIME-Version: 1.0 X-Rspamd-Queue-Id: 15D9DAA249 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. Acked-by: Johannes Weiner 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 e053e1d9a4d7..7386bc67cc5a 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -533,6 +533,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);