Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp145627rwd; Fri, 19 May 2023 17:05:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4PkqSzaTH9GonJUzlHjOsK3mchWnaEV1Qpsfkw7u1+OCdlS7i9r203EqOzUzkbA0H6W9ah X-Received: by 2002:a05:6a20:7345:b0:100:24d7:545b with SMTP id v5-20020a056a20734500b0010024d7545bmr3893799pzc.10.1684541106192; Fri, 19 May 2023 17:05:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684541106; cv=none; d=google.com; s=arc-20160816; b=GkDEwcou7cUjic9vi2HoVptN7zJZtCruFrIc6v8bpuG1ciVvnc1sW/EQmN6Nxn2BEt yVCclZcy1TY7qhmuG1KCc7SBdBD6Kp0gVp1a1acffXl0DCnImbV2XNTDlnQhjfKzJqbn ywHLc4UZtdEZB4hWXCrxovMyxLtGU4aKNKNbWypJTAxbQetXKcrGRvnXgo/O211a6AeL gHsWLpK12Cxm10DE1zKAeCj8Yaibw6MytjRsOn7wqtsuJIx+JAFDcRnzaY+0aZPUT/5w YuHPIINXFHVkkj1BtAD1HgNHCdI8Upk31izAWH/q7Zdry4E5+37IxFC44gi4BmfKChlx D/+g== 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=qie1g7ABANTtTR0bfsI5jgl8Vmls/curDgoBmVrj5jE=; b=HYyU7xc0xtl+Ks4UC7jAgf3+c51DVc/3p8100K9tjlBiIEdJ1KDhnXxAlX0nOwzpZt vWws8aZH2k0IYue7kKsqoHftQXB/B+HbMhgixGjYTqWDHKANtPh+DZyOeXPKNebPWSEJ e68n+skOvk7ChYe1JLye0kh9XtQy3Fk0vL4843FH/R6aah9MzvC/XeqtGUE8HpswPOuN Sczgwgox2tXMRM2cqj5KmmFoTIc4NgAQirj11+Do+V+oRDz5S/lHtDLOvA/sv4L1SrqR 4r0a8H3VJiQ4thjHeQDvJHseLdoPj/RjtRp8mFCBd2C5gliXdWukekImcdr1sH1UKys5 8m9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JirF27iT; 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 o25-20020aa79799000000b006455d53001fsi453304pfp.40.2023.05.19.17.04.50; Fri, 19 May 2023 17:05:06 -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=JirF27iT; 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 S231993AbjETAEe (ORCPT + 99 others); Fri, 19 May 2023 20:04:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231739AbjETADw (ORCPT ); Fri, 19 May 2023 20:03:52 -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 C0FF4198C for ; Fri, 19 May 2023 17:01:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540917; 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=qie1g7ABANTtTR0bfsI5jgl8Vmls/curDgoBmVrj5jE=; b=JirF27iTMDIvHdyPZTtT5XMB2ePkR5xgQ+ZZ6HXtYQVEKPmg+JSroF5MN2o/cEOqDqBZ8M BgsUVOiFtGyawFH54CNTMP+GtHOdsWXEL+bVzvBXhILJRRH2GbnWxW1fCrGWNkvqiXFNB4 fKoto9wIQZcAg+gH0hWfPPAjcKToYec= 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-561-EBYUT5fsO6CFgP7kQK6tFw-1; Fri, 19 May 2023 20:01:51 -0400 X-MC-Unique: EBYUT5fsO6CFgP7kQK6tFw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 84FD7296A609; Sat, 20 May 2023 00:01:50 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id D757CC154D1; Sat, 20 May 2023 00:01:47 +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 v21 18/30] ext4: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:37 +0100 Message-Id: <20230520000049.2226926-19-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.8 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-ext4@vger.kernel.org Provide a splice_read stub 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 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, };