From patchwork Fri Nov 30 16:56:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10706737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7285513A4 for ; Fri, 30 Nov 2018 16:56:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62512303D2 for ; Fri, 30 Nov 2018 16:56:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56B5130415; Fri, 30 Nov 2018 16:56:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3516303D2 for ; Fri, 30 Nov 2018 16:56:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726840AbeLAEGv (ORCPT ); Fri, 30 Nov 2018 23:06:51 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:37135 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726645AbeLAEGv (ORCPT ); Fri, 30 Nov 2018 23:06:51 -0500 Received: by mail-io1-f68.google.com with SMTP id a3so5074555ioc.4 for ; Fri, 30 Nov 2018 08:56:55 -0800 (PST) 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; bh=uEeDBkOwPid70UEg8pUacK6i7pi0+OoFq4mtLStZsZw=; b=f5taqLSyd9amqf+/notpD8cM/uAHKrvFZ1+1t1oNMkXdH/u6ERvkkIhUfui86QDSVB RhlMR4NqYDIZyLECu/iRSKGPc0JTvyHkmrSR3afNRb5g2kJSadGl01Db/HrSJmy7UYnf +ovSEBBjmj9PUNDHtG/mrFTADwbXMvCtdN7vODRqi9/O7iz4LvaxTlNbUnvwmvZnlac2 pdauQFUFS70yBqHA84CfMKNhyNdThAaz2M0ZnW0kztaku0z1Nfv2OUsxX6j5VCOQU7t5 5wtJXdI8d/OwSLLdQ1mVMFtLURn6RS4ETyHuJLwZWCzYlzAsEb9z9QeXEIeYenvlp4K6 55Kw== 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; bh=uEeDBkOwPid70UEg8pUacK6i7pi0+OoFq4mtLStZsZw=; b=IwSA91T+d8HV80uJSQxwNqdaAi2pJFK8uavo8NBswHPlzOLt+x4+4epnSvQYaiPPm0 URRJJu4yWGcfuRJs4u8CM/bmZaXomDt5t8gqfhxkHYyTpetNTslkJKIxMbomluGCp104 TrOidXHNm4HX0kOvrEfRppWmNwu+OQTmDWy0UxcBFtmoMTgrYvnhCtD5XpQKzzn1gP7e sYxq/tqd4IVxMvBeiZiN6m/2XvvNr2upgeiK52KIrPQvObQPrI/M/D9gYYl9Od5pAa5h OfO+AAGnY+LVdZUC7EY3awJqcUKsbbJrVbw5oXUfEs2FEEikwXWmmeAlk2Z9JpzvcwCK i3uw== X-Gm-Message-State: AA+aEWafuQRIsng+DmHgxUt4rY4GM7NebvoJS3XjNeny77tbsL/xvmJk veLffqr5O8TpmeXegtA9ildZOQ== X-Google-Smtp-Source: AFSGD/VCaBbQ1iMBZWcXa71Z3wKiswhL1TGQNN8LHLMVoyyOS6f1Q69UGtAsdgT7gTPk8FWpQmuHzQ== X-Received: by 2002:a6b:9207:: with SMTP id u7mr5321601iod.286.1543597015179; Fri, 30 Nov 2018 08:56:55 -0800 (PST) Received: from localhost.localdomain ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id j133sm2979447itj.16.2018.11.30.08.56.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Nov 2018 08:56:54 -0800 (PST) From: Jens Axboe To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org Cc: hch@lst.de, Jens Axboe Subject: [PATCH 03/27] fs: add an iopoll method to struct file_operations Date: Fri, 30 Nov 2018 09:56:22 -0700 Message-Id: <20181130165646.27341-4-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181130165646.27341-1-axboe@kernel.dk> References: <20181130165646.27341-1-axboe@kernel.dk> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christoph Hellwig This new methods is used to explicitly poll for I/O completion for an iocb. It must be called for any iocb submitted asynchronously (that is with a non-null ki_complete) which has the IOCB_HIPRI flag set. The method is assisted by a new ki_cookie field in struct iocb to store the polling cookie. TODO: we can probably union ki_cookie with the existing hint and I/O priority fields to avoid struct kiocb growth. Reviewed-by: Johannes Thumshirn Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe --- Documentation/filesystems/vfs.txt | 3 +++ include/linux/fs.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 5f71a252e2e0..d9dc5e4d82b9 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -857,6 +857,7 @@ struct file_operations { ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); ssize_t (*read_iter) (struct kiocb *, struct iov_iter *); ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); + int (*iopoll)(struct kiocb *kiocb, bool spin); int (*iterate) (struct file *, struct dir_context *); int (*iterate_shared) (struct file *, struct dir_context *); __poll_t (*poll) (struct file *, struct poll_table_struct *); @@ -902,6 +903,8 @@ otherwise noted. write_iter: possibly asynchronous write with iov_iter as source + iopoll: called when aio wants to poll for completions on HIPRI iocbs + iterate: called when the VFS needs to read the directory contents iterate_shared: called when the VFS needs to read the directory contents diff --git a/include/linux/fs.h b/include/linux/fs.h index a1ab233e6469..6a5f71f8ae06 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -310,6 +310,7 @@ struct kiocb { int ki_flags; u16 ki_hint; u16 ki_ioprio; /* See linux/ioprio.h */ + unsigned int ki_cookie; /* for ->iopoll */ } __randomize_layout; static inline bool is_sync_kiocb(struct kiocb *kiocb) @@ -1781,6 +1782,7 @@ struct file_operations { ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *); ssize_t (*read_iter) (struct kiocb *, struct iov_iter *); ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); + int (*iopoll)(struct kiocb *kiocb, bool spin); int (*iterate) (struct file *, struct dir_context *); int (*iterate_shared) (struct file *, struct dir_context *); __poll_t (*poll) (struct file *, struct poll_table_struct *);