Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp154238rwd; Fri, 19 May 2023 17:14:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Yv6EyOZHLJQms4az12bfzTVK75U0P1vso0TyWTUKuD8QsNbJH8kbiUxPFS/Jd8AQlgVkG X-Received: by 2002:a17:903:1112:b0:1ae:10b3:61e9 with SMTP id n18-20020a170903111200b001ae10b361e9mr4350811plh.65.1684541665028; Fri, 19 May 2023 17:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684541665; cv=none; d=google.com; s=arc-20160816; b=fIPtOsWsNnB9p1BWGjyxcs4XOalJRsHHYIZWXOFue0GjRofMcD3xm4ph6OIxwFJOg1 vr2HE+8zdsOqFZH4EkrC8MHgj3L51vfxZJMUR56f58VhpQS2KSkDvDlkF4xsPzLBlW89 Nso/RI3cJ+wxI2FH5QlV3gDHuYzhvoB0HE8S9VVj/UW+dPsCDXxD2K0K2/klIrll8zUm v3xTDWwPPNsfcuo28NFgWExQq+0neCEM5bu2Rap7j5aiEJ8jFBrWHJznwJZpBQL3Viul M61Qmoq1Ns9rRb07RAZYE7N7vkBkzb4tW6hcTo/dOcESsAgbE18m87pLjiFK2ZSvxQhv kBtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xweayQ6b4+yKTogEWKPvOcFVzWq2Z7yytw9vgW43n8c=; b=SGkMieKZUnDR/m0ntmvv7DWrK1/L45j8CHT5sTLH0bKhrZGYZzmmVjOV9aPw9BlUjY TIhRlLJzXMZmQIWCcEy4IHGgzlUfN74FsfVRRMQgatOfrozlGxhiXwlS1eDDlNH1wGLP pC7gHiwdbMNmyGq+xo7QnL47siLGMNrlCjheJjQNKhLyr77Yb4+jv6kejQWjEMWDby/0 XSXxdfqo98feI6c50v5IfQt4iP00W5iqQXy1XePWVfthVNXu9hgKVUbPsZYv71p/taoN s7X4W/lxlZW5HJ+V5LNp9XFpFjaeF5Vg/MfyYKW2NPJc9k/MHieejlrWld18+Tn3+/Xq ZuOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ARGRIDya; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ju9-20020a170903428900b001a81741ef8dsi189543plb.54.2023.05.19.17.14.10; Fri, 19 May 2023 17:14:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ARGRIDya; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232131AbjETAE6 (ORCPT + 99 others); Fri, 19 May 2023 20:04:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231405AbjETAD6 (ORCPT ); Fri, 19 May 2023 20:03:58 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 702341BCB for ; Fri, 19 May 2023 17:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xweayQ6b4+yKTogEWKPvOcFVzWq2Z7yytw9vgW43n8c=; b=ARGRIDyau0TuhD6c05X2Sx9/VT54CDmDywZUGFoAtRglJ+hWgiSaBwjsuMb+0mj/vamWZU 5vsKfr6NPu6oEXMWrvl1BX+EtdknnSPXCZS2FUJ5HQVT6CU/n1sVLvETFOPb5gIUowRNPe rDU2ZpN3syz3nB6M+WFE8ZnvZELFCzI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-241-5lqrDGK7M6yCYGGKczU41Q-1; Fri, 19 May 2023 20:02:09 -0400 X-MC-Unique: 5lqrDGK7M6yCYGGKczU41Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 72A7438035AA; Sat, 20 May 2023 00:02:08 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43E827C52; Sat, 20 May 2023 00:02:06 +0000 (UTC) From: David Howells To: Jens Axboe , Al Viro , Christoph Hellwig Cc: David Howells , Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , Christian Brauner , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , "Darrick J . Wong" , linux-xfs@vger.kernel.org Subject: [PATCH v21 24/30] xfs: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:43 +0100 Message-Id: <20230520000049.2226926-25-dhowells@redhat.com> In-Reply-To: <20230520000049.2226926-1-dhowells@redhat.com> References: <20230520000049.2226926-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Provide a splice_read stub for XFS. This does a stat count and a shutdown check before proceeding, then emits a new trace line and locks the inode across the call to filemap_splice_read() and adds to the stats afterwards. Splicing from direct I/O or DAX is handled by the caller. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Darrick J. Wong cc: linux-xfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/xfs/xfs_file.c | 30 +++++++++++++++++++++++++++++- fs/xfs/xfs_trace.h | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index aede746541f8..08d632668e94 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -306,6 +306,34 @@ xfs_file_read_iter( return ret; } +STATIC ssize_t +xfs_file_splice_read( + struct file *in, + loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, + unsigned int flags) +{ + struct inode *inode = file_inode(in); + struct xfs_inode *ip = XFS_I(inode); + struct xfs_mount *mp = ip->i_mount; + ssize_t ret = 0; + + XFS_STATS_INC(mp, xs_read_calls); + + if (xfs_is_shutdown(mp)) + return -EIO; + + trace_xfs_file_splice_read(ip, *ppos, len); + + xfs_ilock(ip, XFS_IOLOCK_SHARED); + ret = filemap_splice_read(in, ppos, pipe, len, flags); + xfs_iunlock(ip, XFS_IOLOCK_SHARED); + if (ret > 0) + XFS_STATS_ADD(mp, xs_read_bytes, ret); + return ret; +} + /* * Common pre-write limit and setup checks. * @@ -1423,7 +1451,7 @@ const struct file_operations xfs_file_operations = { .llseek = xfs_file_llseek, .read_iter = xfs_file_read_iter, .write_iter = xfs_file_write_iter, - .splice_read = generic_file_splice_read, + .splice_read = xfs_file_splice_read, .splice_write = iter_file_splice_write, .iopoll = iocb_bio_iopoll, .unlocked_ioctl = xfs_file_ioctl, diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index cd4ca5b1fcb0..4db669203149 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -1445,7 +1445,6 @@ DEFINE_RW_EVENT(xfs_file_direct_write); DEFINE_RW_EVENT(xfs_file_dax_write); DEFINE_RW_EVENT(xfs_reflink_bounce_dio_write); - DECLARE_EVENT_CLASS(xfs_imap_class, TP_PROTO(struct xfs_inode *ip, xfs_off_t offset, ssize_t count, int whichfork, struct xfs_bmbt_irec *irec), @@ -1535,6 +1534,7 @@ DEFINE_SIMPLE_IO_EVENT(xfs_zero_eof); DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write); DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_unwritten); DEFINE_SIMPLE_IO_EVENT(xfs_end_io_direct_write_append); +DEFINE_SIMPLE_IO_EVENT(xfs_file_splice_read); DECLARE_EVENT_CLASS(xfs_itrunc_class, TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size),