From patchwork Fri May 19 07:40:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 96224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1057575vqo; Fri, 19 May 2023 00:51:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ638gOZ0HRH5urXTQQRGr7wZuff9Jk2i72D9LBRBSamwO3vnVB8kKueS35DVru7qpuTbL3f X-Received: by 2002:a17:902:f689:b0:1a0:7156:f8d1 with SMTP id l9-20020a170902f68900b001a07156f8d1mr2265358plg.19.1684482680904; Fri, 19 May 2023 00:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684482680; cv=none; d=google.com; s=arc-20160816; b=sXdxVj93nilpVlZHMs8Fwi+gvgjVe5RZgzLo20TRPCozasXdC6tUM6fPN+x1H0MJgJ LJ9GuTYon/2lV84dxE1u09tw7KmS0ElmvFTC8BRoB9ztn0WXmq8DtwHQcx50mASF5iGI rqh0rFWopXRnoH/CbU6EvOGfYmxvTR1TZy695/E+FRzWHQIF0010w11A9Ce1y993jOGI zvPzjt8wdRhWvGQ1qNQiOakSDNbgvkyF01MkJQxJsNS02rxVC3Br+Z9BALUdpO/xWIHk WzduIVfR9K/Ytwo63xm8/3AA9EaEI7SlLCF9XXPiC1vGSos8Vs8Bea9FEcY36ywPd8MJ xhaA== 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=VhlnyEb6mYomF+UXhy/zVZBJsDbPWQmGyqF6ugPT8o4=; b=NxYWC2ZuDeUsSRK7fIJ7mQkRoWdaHDvgy65qa3INDXCVJuxgaTSgv3uN7g+3m7AxZz ZtWGpWZ0+Yn5HDR4MEMhx5FY0vxjAAGg+YfgSBrO/zU+63lxScmWsIIyaWGglBVWM4E3 pJRfJfbQd+qJHoFGfbzcWbjih98GrKlrP661qFMD4Z/DqWIGolgQ9VudwNX1l1Ca61XG xMOrEHyo/7UPOXP5Q5kXROv+Q5sUG7/cmvQuNtrVsSVqMf0QhQeIVT3CExwgMHvd81Pr bOVRTSXHE+ODPTsiHUZDb+r1us80QJM5xusiLG1YcMPUwK0B4qgDc/eV6Vsvnce9r80K Owvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=g44LcoP0; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f2-20020a170902ce8200b001ae8b0f8491si40505plg.454.2023.05.19.00.51.08; Fri, 19 May 2023 00:51:20 -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=g44LcoP0; 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 S231400AbjESHnf (ORCPT + 99 others); Fri, 19 May 2023 03:43:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231299AbjESHmy (ORCPT ); Fri, 19 May 2023 03:42:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6DB3195 for ; Fri, 19 May 2023 00:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684482119; 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=VhlnyEb6mYomF+UXhy/zVZBJsDbPWQmGyqF6ugPT8o4=; b=g44LcoP0pNvLnM9peU51U9YnDZwpVJPFEcZEM8++6OjKYkVkiAg6OqWyVSUs+ueLPahJiF lqfnHo2rbpcG1vc6E1eI1TB2yoLypWgIwcLMDk1SxrhwTLuYaao55lFxa79uijCxIO1Nyu qy2Ey4WgPpdUBZlgGj1Jzl1akXDoqlA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-290-tq44QnmUO9KmQ-WGEl3PcA-1; Fri, 19 May 2023 03:41:53 -0400 X-MC-Unique: tq44QnmUO9KmQ-WGEl3PcA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7B949800B2A; Fri, 19 May 2023 07:41:52 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8AEB4F2DE0; Fri, 19 May 2023 07:41:49 +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 , "Theodore Ts'o" , Andreas Dilger , linux-ext4@vger.kernel.org Subject: [PATCH v20 15/32] ext4: Provide a splice-read stub Date: Fri, 19 May 2023 08:40:30 +0100 Message-Id: <20230519074047.1739879-16-dhowells@redhat.com> In-Reply-To: <20230519074047.1739879-1-dhowells@redhat.com> References: <20230519074047.1739879-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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, RCVD_IN_MSPIKE_H2,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766308111740396850?= X-GMAIL-MSGID: =?utf-8?q?1766308111740396850?= Provide a splice_read stub for Ext4. This does the inode shutdown check before proceeding. Splicing from DAX files is handled by generic_file_splice_read(). Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: "Theodore Ts'o" cc: Andreas Dilger cc: linux-ext4@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/ext4/file.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index d101b3b0c7da..9f8bbd9d131c 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -147,6 +147,17 @@ static ssize_t ext4_file_read_iter(struct kiocb *iocb, struct iov_iter *to) return generic_file_read_iter(iocb, to); } +static ssize_t ext4_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); + + if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) + return -EIO; + return generic_file_splice_read(in, ppos, pipe, len, flags); +} + /* * Called when an inode is released. Note that this is different * from ext4_file_open: open gets called at every open, but release @@ -957,7 +968,7 @@ const struct file_operations ext4_file_operations = { .release = ext4_release_file, .fsync = ext4_sync_file, .get_unmapped_area = thp_get_unmapped_area, - .splice_read = generic_file_splice_read, + .splice_read = ext4_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = ext4_fallocate, };