From patchwork Sat May 20 00:00:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 96681 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp42284vqo; Fri, 19 May 2023 17:05:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ61X89rjRWKe26mb+2ccLSHCCcbKRESSczcNqq90Q7E7RhKPMWRNklHTocRjderzWjhvgIL X-Received: by 2002:a17:90a:881:b0:253:510e:130a with SMTP id v1-20020a17090a088100b00253510e130amr4423815pjc.19.1684541132291; Fri, 19 May 2023 17:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684541132; cv=none; d=google.com; s=arc-20160816; b=u5eprRaiAb2SwnS14QRRqgJ/2+/6WcyMqxHgCs+5Zfqmdubw0Hgpp8z3H507lozDfV UVg2xxKR6QZjWGpx35PFTjb7ibeyqwjgNRGBK38JpA4mF9ZyA70FroSbs56VpqMIJbcD EOmKOLTP7D4E2DyrWuIrj5k7vSh67t9MTT1mO+nBebjGgY29vNWpGW8l9QbVIrJ/EtsY RFWL6pPYm7lEK+LGY3FJAJrALnkq5bfdkLIoLpjEfbSE2gb230o8BQbWRCz002nNwUhv L+djdNA7B1jqIqKMk6qB0ZPiLKppNawXAIxC8jo11mQpMR6svJGxDsRjrR+ZHjvOAQl3 mo4g== 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=6eCSJNH8vHFST21uMhvhB9UZGjvTsMZCtNRoglPFw+I=; b=iKLIGJhxbfRQup6wHcR4qpCdVeeq3E0upU6cf+pDe/JuxzrWv0gypL8KoGOQhrVCUq kjpOyuN3T5J7kSg0G7m338BEH/qPSf5mxQf661qwLLWnwKUnyM5gI4SDb9i94zCTDpIP f4VUds7PUA5EMRycTLqPsFRLpmSrcoGealf2qyXCVNs1eWczwEAPVJAlod3boER/tqdy pGTkQ633yHP5tpgfzv6mqhF2YndDlTH/+ULcJerGWM+PyvO3GeCBpsj+oY6HPggWlyal fhMYHycoGg3I6cu3uD5taFnaC3Q+b1X1iGBBn0bWydc7yeLZu1moHYftDCnXidZQn4XD ZUow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hoGhvvIj; 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 x24-20020a63db58000000b0051389efe297si453265pgi.265.2023.05.19.17.05.16; Fri, 19 May 2023 17:05:32 -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=hoGhvvIj; 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 S232041AbjETAEm (ORCPT + 99 others); Fri, 19 May 2023 20:04:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231693AbjETAD5 (ORCPT ); Fri, 19 May 2023 20:03:57 -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 6D16819A7 for ; Fri, 19 May 2023 17:02:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540924; 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=6eCSJNH8vHFST21uMhvhB9UZGjvTsMZCtNRoglPFw+I=; b=hoGhvvIjil7eOL8XoGbL+e1ihApUYKo/IzgT3URp2WQvsnsuO8nEuWDd++z+EZpI3MFd01 RXIs9CS8AsZBdr1sC4F4lusCJGk+yKQ+w1cieEDTfxVLRT3PBVHHCp7DMVVkH+1PhoK+QB WUa0fdG5FRBEgkvPyGDI9i1dj6/HohU= 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-518-Vi3VpzDTNn22brcNxkPP8Q-1; Fri, 19 May 2023 20:02:00 -0400 X-MC-Unique: Vi3VpzDTNn22brcNxkPP8Q-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 3A4411C05AEB; Sat, 20 May 2023 00:01:59 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C7A94F2DE2; Sat, 20 May 2023 00:01:56 +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 v21 21/30] ntfs3: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:40 +0100 Message-Id: <20230520000049.2226926-22-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.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=ham 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?1766369402230854851?= X-GMAIL-MSGID: =?utf-8?q?1766369402230854851?= 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 | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 9a3d55c367d9..667c9dc68b58 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -744,6 +744,35 @@ 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; + } + +#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 +1188,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,