From patchwork Sat Jan 12 21:29:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10761097 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 4409E746 for ; Sat, 12 Jan 2019 21:30:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3823B2901C for ; Sat, 12 Jan 2019 21:30:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C6652904F; Sat, 12 Jan 2019 21:30:25 +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=unavailable 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 CAFA12901C for ; Sat, 12 Jan 2019 21:30:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726574AbfALVaX (ORCPT ); Sat, 12 Jan 2019 16:30:23 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:42063 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726547AbfALVaX (ORCPT ); Sat, 12 Jan 2019 16:30:23 -0500 Received: by mail-pg1-f194.google.com with SMTP id d72so7785551pga.9 for ; Sat, 12 Jan 2019 13:30:22 -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=AAKxls5Es8ExKqpwMiUOBUcGduRQU3BNIbRWpRo7VtQ=; b=gpSSOGxgIEn2qmUpaDMDasAgpRZt4HpFc3bEmUg4SbTxyEiA6gi4La+rYe7a7YU0k/ kwcccd8qW08Qk2crkbTmg2KZ5CkHBauOOrcq/sKnXfyYirD/lNc1wGVnJUH2slUlVTMg Siz0nZpfdNwOH2J3jaPBvIGPKXFPRKX2yyj9pS7qoa4qWjOZaU69oPqFs/y9KuJE/lkE XlcxJxHN6woxZU4k0nJ+YzfVc3ZuKuAVNqVNQzmkKJ2PYuRX06haNxGuB80Rzk/v5zOF KUk9479hFx3yvqk2iYQ8/dwy0/7IMYjNGDsIcfoHDjqyhISscigI3AST9Zz6Y7v1LbaY Cafg== 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=AAKxls5Es8ExKqpwMiUOBUcGduRQU3BNIbRWpRo7VtQ=; b=A0p2/Eobaq5zOZTzYW/+g6T1lXqxu4LPXjsYeBOmeBjcOrMfUkaazvP2QWZLMQTZuE QWaPgBVeAhF0wlA6fGnNSiQntxmUIw3K75hhIwDSk6uVwGncVHVsWYi+65X8q6uyvz6T IdoTJ6t0GZ+5CQibQGo3gFR7ht878mw5L6qZs2pXvxEpGmfe5eV/Pw2vuO4irzHlKK/H ZHW+wYw0ywm4yWssg48B5jpXVBX5sSYaxikizrzf4lKlM7SOLXKhiBK3f5lMMGVEAWiX SRek0JEPSRexd333UbKlxn/N1gvffLE5d0f1Hg12b9omPUBn4ApZkQU8wskxygxWomSP A9oA== X-Gm-Message-State: AJcUukfmdEyA/Jd4QvntU6oHA8DO3W3Xz/vlSF+I1SMw+LedEjed9CKr DUtTDxU4aTKMeE5rWMSf2PFa1/gYTkS35g== X-Google-Smtp-Source: ALg8bN50vz8qqguarHVsPWJG2FG95KrCg0wsoXqCkboquEDqWmxk1qNETLttB5B5Fh8jwvjKq7v0Rg== X-Received: by 2002:a63:fe0a:: with SMTP id p10mr15655759pgh.265.1547328621707; Sat, 12 Jan 2019 13:30:21 -0800 (PST) Received: from x1.localdomain (66.29.188.166.static.utbb.net. [66.29.188.166]) by smtp.gmail.com with ESMTPSA id y6sm151629818pfd.104.2019.01.12.13.30.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 12 Jan 2019 13:30:20 -0800 (PST) From: Jens Axboe To: linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, linux-block@vger.kernel.org, linux-arch@vger.kernel.org Cc: hch@lst.de, jmoyer@redhat.com, avi@scylladb.com, Jens Axboe Subject: [PATCH 01/16] fs: add an iopoll method to struct file_operations Date: Sat, 12 Jan 2019 14:29:56 -0700 Message-Id: <20190112213011.1439-2-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190112213011.1439-1-axboe@kernel.dk> References: <20190112213011.1439-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 8dc8e9c2913f..761c6fd24a53 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 811c77743dad..ccb0b7a63aa5 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) @@ -1786,6 +1787,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 *);