From patchwork Fri Dec 7 22:19:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10718835 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 B646218B8 for ; Fri, 7 Dec 2018 22:20:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8BA12F719 for ; Fri, 7 Dec 2018 22:20:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9CFE22F72F; Fri, 7 Dec 2018 22:20:27 +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 46CBE2F719 for ; Fri, 7 Dec 2018 22:20:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726079AbeLGWU0 (ORCPT ); Fri, 7 Dec 2018 17:20:26 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:32920 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726080AbeLGWU0 (ORCPT ); Fri, 7 Dec 2018 17:20:26 -0500 Received: by mail-pf1-f195.google.com with SMTP id c123so2583418pfb.0 for ; Fri, 07 Dec 2018 14:20:25 -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=1D3nPyQ0nmtuXSQzT0r6H2eH/pk5CTR8ogEP9fGDYBAbJaXJlF+G/eze0R7r66S4WS inXR9Wkkze+mm3X62672uu/UDW6lKce00Leu/+WmKk7XJfKmljq/spen1A+Ishm8oTsT Stf+mqVGzmOLw3XodKo2bY2SIoKlke41XM6AxEhVmOSR/wD8mIDa9UgiZdh0rVArT+QH SOe+iyl96m9a3iQ5jECj0mqRup21GMGUEWIU8gf5honqTjStcstYL8viNrHF1+2GieQy Emd6sVVeHnkKSy3XVp+j+p8PY6SfCaiTv9N28o0LpB4tuHdatdz5fnJ1GiyQiCdvaYeQ h/Rw== 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=sfnLJpe3+vh+IPMmGH3r1sEQo5y/HL+i/fA9yeX772EAsLjpMXlFkqquHQvct6apek mBWu+L6sXDsL50B2W8pugCWPqvYS/Va9tUKtEv11ql1clxvt0hDFU2oG9my9Rn2tbzwt 7U7vgLWpT2BaH7LK2//m1V34jqrMHKjFa/XDU/jzqowMexqD4lFsR/zat4kACBkd3h1L CDO0+8ZdcErqYABWx6b4djbyLFV8uF7qQ2BzjJVCb/rCGA/V9a4MFKmXTS0u7Y2yF/On xyW+f9L5aQfGU7zz2PijNUzbgeTc/R16hxpzc18qm00CXGy1CeiBP/3/3vTO/tzPRGXA 3QEQ== X-Gm-Message-State: AA+aEWZJwjYhsek2K1bd/2W5AuwvVTQxM2R6EGwfzz0qJ6ihzbXYxhif 9fmXmv+9B2vCHfC6P+XLivA4BySDWgw= X-Google-Smtp-Source: AFSGD/Vy2wqspFtiLNmMaxhXf5147i9wkZ9pN47HYa8PSKx3f5bJqpRfzhTn/iHazSEI0tv0ae8pvQ== X-Received: by 2002:a63:e001:: with SMTP id e1mr3519450pgh.39.1544221224991; Fri, 07 Dec 2018 14:20:24 -0800 (PST) Received: from x1.localdomain (66.29.188.166.static.utbb.net. [66.29.188.166]) by smtp.gmail.com with ESMTPSA id e9sm5282511pff.5.2018.12.07.14.20.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Dec 2018 14:20:23 -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, clm@fb.com, Jens Axboe Subject: [PATCH 01/26] fs: add an iopoll method to struct file_operations Date: Fri, 7 Dec 2018 15:19:51 -0700 Message-Id: <20181207222016.29387-2-axboe@kernel.dk> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181207222016.29387-1-axboe@kernel.dk> References: <20181207222016.29387-1-axboe@kernel.dk> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@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 *);