From patchwork Sat May 20 00:00:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FE1AC77B7A for ; Sat, 20 May 2023 00:02:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EB67900007; Fri, 19 May 2023 20:01:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9755A900004; Fri, 19 May 2023 20:01:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EE23900007; Fri, 19 May 2023 20:01:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6A1A0900004 for ; Fri, 19 May 2023 20:01:59 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 3A7A4160B89 for ; Sat, 20 May 2023 00:01:59 +0000 (UTC) X-FDA: 80808680358.07.5C73AF5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 859E3A0004 for ; Sat, 20 May 2023 00:01:57 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fvGybMym; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684540917; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qie1g7ABANTtTR0bfsI5jgl8Vmls/curDgoBmVrj5jE=; b=8huWAvcVHsO+FJzfLgoaaSwtD0bb/YBWzokU/QYHfnib7jXNfqhOZ3nFh+p8zjgj/LqGw7 pPNDAeXH5GVxxIBbrMy24+RfX6vBnkpS/zdGm757oWsTq9YsOvmEb/FXsg+x5gby6icODC sBDSClN9Zw7B7Mgw16qu2yJhX5Jur1k= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fvGybMym; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540917; a=rsa-sha256; cv=none; b=zOOhugo7sPamnuVOwLhOwStY3AQApcCPJpbNVJj1CZHsztQM5Vo0XmvQdJUfRjPivfykWf HHXZXZ3HOW4KljrZKa2rom5TEKqEVikU1JsnCvr/DYhZhmM1dutLu2hU1kTqKzeo37jX0M fzB7LMZh4EDmwFP4xY1Ys1yKIAvxDZM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540916; 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=fvGybMymbrRhCRj1V3kTz+24RuywchDAyLnfzxzIA/dOZ3+256YNGl08FIlnTxFrxBDNW7 zn4/6lhBgdecjSq8KurnAUS7Osnu0H38iDZNZ6hUTvAaqnltD/hIHW/LTtxBRpuBGupzho O+ngdA5WjUnzFdDc1AYsjnfC5cigVAo= 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: 859E3A0004 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: pjmh6uehsx65n3833muuja8u4d5e4rei X-HE-Tag: 1684540917-526770 X-HE-Meta: U2FsdGVk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RA3pcPtRL6+AIoK3DUDuWiKpEBGXwZsysoD2A+N4UOnSh90CEWQPuWHFpA56ZsOjqn+lVZAakT7Xd/xXAmWYxxw8ZuuJknCfpUiM3R15BVzHI/NrBwa+tcrjVJr9gUBUwA+7o+INaWsPWhKd9Q+oYI1q2+Dp+np9EYJigHQDfPQLbVEHJS/sNJtUu3zTLyErQrzPzc2AfwuARx4zRbNwW5S5GDS/lIO6F7uS8PFz5mBCz5VNWQEA75av88+TmEB3G4WjrawFWk9RnwoxPLO+k0YRK/ujWgcSsigXO06hXUtj1ZJDSEMSHzLLX/+rjUJShd87rf/ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: Christoph Hellwig Acked-by: Theodore Ts'o --- 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, };