From patchwork Fri May 19 07:40:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13247773 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 24EE0C7EE2C for ; Fri, 19 May 2023 07:42:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B83D590001A; Fri, 19 May 2023 03:42:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B349B900003; Fri, 19 May 2023 03:42:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AFBB90001A; Fri, 19 May 2023 03:42:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 88140900003 for ; Fri, 19 May 2023 03:42:10 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5480C409CA for ; Fri, 19 May 2023 07:42:10 +0000 (UTC) X-FDA: 80806211220.23.D6E734F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 8E5611A0015 for ; Fri, 19 May 2023 07:42:08 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fWKYlf9S; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1684482128; 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=MIKgygGFPP04jCWudTIx6Exr1BpE2idki489iWC06JA=; b=s4JP9l7jLo+rKCkv0q+qySkORURCBu9d+PFlGDBRSlc67LYlE9W0ciKZL+91xz1Ylh4zFf yp7OeoLMd3eR6YFrNN5obCIwqdIG53Yx/31+HT+/m+ADkjhsrFXCPtok/MWPYxYe8vy4Fs ohqckGxEdxii+CpDfDf8tR/GnSEFnv4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fWKYlf9S; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684482128; a=rsa-sha256; cv=none; b=Zk2yFBJ11AZXC6Ob0lfGBMTsan6WndvT7oPfUD9K3RQa7hqasLB+5v1+cHF9EB2akmNYgX ya58R7fjoCbVilogRdh0xM5auJwPgXFkNXWXYNAkagC5vCTGDM/nj04bbcWcCmGb+rQs1+ /LL9RQqRIXlquTnpwIvzy3x+AuHSFYQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684482128; 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=MIKgygGFPP04jCWudTIx6Exr1BpE2idki489iWC06JA=; b=fWKYlf9SfLfRFTbAO//ZuAUpo9j6xAMRkplXQTESAh5Hn8BtiSTFb/nkvxg2bc0iRoRzUY Owy0Q6ILjsKVVsqi1AfVrG1HOlaV9L/HbRPiTxA7LrYZcAM3OaxP7gCIO5HlQIgIvQ0nJb JvxLLDhwpHOAnrMrXVKUfN5DhzKgdzA= 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-76-BiSEfFWJO5ihxPcX24ACRw-1; Fri, 19 May 2023 03:42:03 -0400 X-MC-Unique: BiSEfFWJO5ihxPcX24ACRw-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 ADED48027F5; Fri, 19 May 2023 07:42:02 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BEDF40CFD45; Fri, 19 May 2023 07:41:59 +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 , Konstantin Komarov , ntfs3@lists.linux.dev Subject: [PATCH v20 18/32] ntfs3: Provide a splice-read stub Date: Fri, 19 May 2023 08:40:33 +0100 Message-Id: <20230519074047.1739879-19-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.1 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8E5611A0015 X-Stat-Signature: gbhywhttfoirntxrpubfsubuipbccte7 X-HE-Tag: 1684482128-927225 X-HE-Meta: U2FsdGVkX185rYZS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0dvoPIUFNOlM4+nOjzJ2I3dU3PIduP8CbjDRcVPSJ5PUdzFA6vq7dFGx9iQ2JiOpF82jJpiIKoZnRq5X7GkUthuC8QrzYwfY7Nx1+/kcpMIT+02uUymrWMQnU+PWJM+lkxM5ylSbTEorzQtzr9wKiSg/jAxVI4FjV5vnl8foJm7XbWAJ5+zrKvCiOuzufnnoyYbv4DgoYYGzN56vB4PgCSMQDFYrcDnxYq8p5CR5e50Vi+2tgW/QWtReTOSjhPSWHXWydFL8oRiDU5rNNWUhdFxf0C4B8k1174k2b1c/k4XWsYTgBm4zLJZMRPsYjcyfQQwEawTTZZIo 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 NTFS3 to perform various checks before allowing the operation to proceed. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Konstantin Komarov cc: ntfs3@lists.linux.dev cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/ntfs3/file.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 9a3d55c367d9..c27814946aa3 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -744,6 +744,40 @@ static ssize_t ntfs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) return generic_file_read_iter(iocb, iter); } +static ssize_t ntfs_file_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + struct inode *inode = in->f_mapping->host; + struct ntfs_inode *ni = ntfs_i(inode); + + if (is_encrypted(ni)) { + ntfs_inode_warn(inode, "encrypted i/o not supported"); + return -EOPNOTSUPP; + } + + if (is_compressed(ni) && (in->f_flags & O_DIRECT)) { + ntfs_inode_warn(inode, "direct i/o + compressed not supported"); + return -EOPNOTSUPP; + } + +#ifndef CONFIG_NTFS3_LZX_XPRESS + if (ni->ni_flags & NI_FLAG_COMPRESSED_MASK) { + ntfs_inode_warn( + inode, + "activate CONFIG_NTFS3_LZX_XPRESS to read external compressed files"); + return -EOPNOTSUPP; + } +#endif + + if (is_dedup(ni)) { + ntfs_inode_warn(inode, "read deduplicated not supported"); + return -EOPNOTSUPP; + } + + return generic_file_splice_read(in, ppos, pipe, len, flags); +} + /* * ntfs_get_frame_pages * @@ -1159,7 +1193,7 @@ const struct file_operations ntfs_file_operations = { #ifdef CONFIG_COMPAT .compat_ioctl = ntfs_compat_ioctl, #endif - .splice_read = generic_file_splice_read, + .splice_read = ntfs_file_splice_read, .mmap = ntfs_file_mmap, .open = ntfs_file_open, .fsync = generic_file_fsync,