From patchwork Tue Dec 4 23:37:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10712717 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 9AB9B13AF for ; Tue, 4 Dec 2018 23:37:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D26529C06 for ; Tue, 4 Dec 2018 23:37:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81A4D29C44; Tue, 4 Dec 2018 23:37:41 +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 1332C29C06 for ; Tue, 4 Dec 2018 23:37:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726380AbeLDXhk (ORCPT ); Tue, 4 Dec 2018 18:37:40 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:34059 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725886AbeLDXhk (ORCPT ); Tue, 4 Dec 2018 18:37:40 -0500 Received: by mail-pf1-f194.google.com with SMTP id h3so9023093pfg.1 for ; Tue, 04 Dec 2018 15:37:39 -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=WM3qER6gZnamoCqOraZo0+l/uvpyWdqQYR1qkX5U0690qlTReyDJakw8A5TbrEFC91 9/2ZTF4qa9uRzE++BvFLqq7CxV6N5n9pEj8Y3YOZwtF4D+xhTNHP1TzeyUR+Oi97HGeJ 8zMWRhu+ulbnfqDvMO9dKy312MROBSOsbD7RxE+8hqBbCXMdScsupIThwZe2PLiRfTAy r6SShf0ONo/VuFRTWzy+nUxTFkzpaDEVOpTUb90Y0Lp2clvy2trniwPSaChQGfg8rykk McN29ee3Vv6rcZfx6h14HGJGbHwkQeydr0cFsrcZRDM1ZMiPxUwnSZhGFOuXSxXXqs3s IN8A== 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=qaU0p6IDxAok5GZLN1LLJ24GrEM4BDSelqHNcrLzSYPpbdtmVaN3vFuNep9Wr4I/1/ 0408MMvX77DzXwG5snKBHYcsgz2TGE8dHk+0GdPivvmyugCLGiqFCFIDK1oOBDsDkYbr YaR1Nsz9dIGCwrzt1E0amH2LUqt7r9QJBRYX6B1PUh3PnpSuN9yxAld8hrlWXK1Nd7eh LFtLViScK2ocuxzSkRMI+LfJwsXQFcfYEVehZBVMukvax3oVfKkdOYbtLKzQvZc8gGbB X7uk9/D9YtqQG3F95OifRND/dOXC2YJ3LMIITOCnYnicGigqHp7BrZeh1ir91BQWlZRX 68RA== X-Gm-Message-State: AA+aEWbTKebrTMjphYCLpTz9D2YzEJQKgdeAoWdeqGvPZhDN115eQdTq zmX3hWxLhOg1Cyb5N+ziletn2g== X-Google-Smtp-Source: AFSGD/X9dy6/YWg2RzhNc3aa1H+mjufewC9ndul5KGodYelxHwnfEYTEkn1ww/+Q93mf2xedOtMbKw== X-Received: by 2002:a62:a99:: with SMTP id 25mr21771482pfk.121.1543966659124; Tue, 04 Dec 2018 15:37:39 -0800 (PST) Received: from x1.localdomain (66.29.188.166.static.utbb.net. [66.29.188.166]) by smtp.gmail.com with ESMTPSA id t13sm22527635pgr.42.2018.12.04.15.37.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Dec 2018 15:37:38 -0800 (PST) From: Jens Axboe To: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-aio@kvack.org Cc: hch@lst.de, jmoyer@redhat.com, Jens Axboe Subject: [PATCH 01/26] fs: add an iopoll method to struct file_operations Date: Tue, 4 Dec 2018 16:37:04 -0700 Message-Id: <20181204233729.26776-2-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181204233729.26776-1-axboe@kernel.dk> References: <20181204233729.26776-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 *);