Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2963086rwd; Mon, 22 May 2023 06:55:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4p8VR1P13O+NdgL49aHQOYAP58iJPmWpvv3wDurXaIiNCUvLYsbAgMNd4SccQEVUGGs1PG X-Received: by 2002:a05:6a20:258e:b0:101:5037:7542 with SMTP id k14-20020a056a20258e00b0010150377542mr12580625pzd.10.1684763726424; Mon, 22 May 2023 06:55:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684763726; cv=none; d=google.com; s=arc-20160816; b=iHCxOBIAOa8GDPp1VeCr3tSq1z9rfpURpJfjjD7nbfMQuV87RVwRV13qliEyT59r5Q bkfb4BETPXo6b4bm/a3UuY3/l2uQs+xCk1axpNFTjrjMmy+bPFAPiOXyLN2evlG1JBiu Nfzz43RvF0ODu3dyOAT8bTpOpgV6uMgfniPX+1rX1McoW3k8NFevwQRPkHQ7k2myxd2P yRrfb9hbGYs1XH+i6odpBjb207ABy4XDv4haWc/es5BSY2pLfoBk25vIPtwI4+EztQyz bZLAlZUJDrnCD0yT54Lr+Q54eEZkfhzWgZZDCqkZ7WZNxYUGv4GT/sZUC/hm6Qb3TiBu gHZg== 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=k/c+R+8s2k3pMmNtZ3aOuXJCBbwfObn3G1z9h41bJkI=; b=nwZUmpGLIJgDCBixpOgGddy8B0RWOsf+VMUyzyRdwPacROMmyPN+c0BxM5kVJaO7gh sdXw/LrBzwJWF829uBSHa72sru0VdEd2shurx9sxMptctICdSxO1+aKt4O9k06d4q+w3 6lbAs7BLEqZGNm0MEJLInbMisVpIxorzc3YMiaXUJiks932zf1onghpBA6vk7eozEjkI BM8dAng39R8MSBMg2Q+YftiHJJHPu6n6cvB7m9zZMGADjSXTIsOtK7oOsMMdnwKZ4AW9 ZR0B11yELFdaK0yd7YIqm4AXOcm9HO2s3PQmJf+yZ+hNSSdkYWRNuwp+4f0T0GQX6yeu ljEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hjdXxxI1; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 bv63-20020a632e42000000b0050ac7d1b32asi2851793pgb.603.2023.05.22.06.55.10; Mon, 22 May 2023 06:55:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=hjdXxxI1; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 S234324AbjEVNyW (ORCPT + 99 others); Mon, 22 May 2023 09:54:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234168AbjEVNwx (ORCPT ); Mon, 22 May 2023 09:52:53 -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 E78FFE62 for ; Mon, 22 May 2023 06:51:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763501; 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=k/c+R+8s2k3pMmNtZ3aOuXJCBbwfObn3G1z9h41bJkI=; b=hjdXxxI1PAwmdF+Zl4F8OFTGN1CJlu59/tR9VY7drNh0S4c5m/MhEyH7JbVnKBsrFlaOv8 kf0v2n3T9JIDzle0ThI4qPmtBEOjNFkLhLjcNI3IgcxHGXZGD6tvnt/G2GHmQZ1wcz9X7E f0m2Oc33vPCFIDiBmJxB3WAcUx+DiZg= 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-423-NgNsZyJqPjue_3wdjfNq9A-1; Mon, 22 May 2023 09:51:37 -0400 X-MC-Unique: NgNsZyJqPjue_3wdjfNq9A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 86DD7281294A; Mon, 22 May 2023 13:51:36 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id B290540CFD47; Mon, 22 May 2023 13:51:33 +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 v22 18/31] ext4: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:05 +0100 Message-Id: <20230522135018.2742245-19-dhowells@redhat.com> In-Reply-To: <20230522135018.2742245-1-dhowells@redhat.com> References: <20230522135018.2742245-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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-ext4@vger.kernel.org Provide a splice_read wrapper for Ext4. This does the inode shutdown check before proceeding. Splicing from DAX files and O_DIRECT fds is handled by the caller. Signed-off-by: David Howells Reviewed-by: Christoph Hellwig Acked-by: Theodore Ts'o cc: Al Viro cc: Jens Axboe 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, };