From patchwork Mon May 22 13:50:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250601 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 227FFC77B75 for ; Mon, 22 May 2023 13:51:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B8344280001; Mon, 22 May 2023 09:51:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B32E1900006; Mon, 22 May 2023 09:51:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FAC2280001; Mon, 22 May 2023 09:51:57 -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 8E85A900006 for ; Mon, 22 May 2023 09:51:57 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 668A5A0348 for ; Mon, 22 May 2023 13:51:57 +0000 (UTC) X-FDA: 80818029474.22.C58FE57 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf21.hostedemail.com (Postfix) with ESMTP id A8B981C0006 for ; Mon, 22 May 2023 13:51:54 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=aeSp7X+o; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.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=1684763514; 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=vTrARcFdbC/vmS0maUQ9q741hTl6uEjvIQp7xTnb7lA=; b=r5RwQh1ci7uDTDIsExN8wGVguOyC+uWLkNcvBuBT5rytZDIcEETXEHYt0oCb0ixJhRKkvF mjUo7nIIZcXJjEEoTKmP7Z345eIUqjfrDFa9itsZRFaB0HE27oD4MHY5vWV2/+Es7tooHf E2HzVKVsUbCH7n3ix4hE0GAy5tIUZ1s= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=aeSp7X+o; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf21.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=1684763514; a=rsa-sha256; cv=none; b=R6vpADpPaEBtZk7KqmVUEspUK+5lZNERyMvkKG2RgrlqaD/NkS/llKKzW+F4KA3Jq0Gbyx qlgC2yxq6HToit9KljzBW8Nrq6efkUKn589YcWxfRuXMWyXgsQuLpP2UHJ/nb9d4UWwFrT fFXO5dreDG2x72enctPJfOMqesigJv4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763513; 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=vTrARcFdbC/vmS0maUQ9q741hTl6uEjvIQp7xTnb7lA=; b=aeSp7X+o+u040PQa6U55BXc/XR6VnJjtTeNJ0SUx2Qkjb1LVtYadTm+uWx6zbtiCknH+7S jbiJtjSrUMbne1wcKpTAF/bvKjTRq+0GNG5Rbk/AZ7gzICXXR9dvQED+gZx9U7FuzzbLF6 /IIzvChwIkCUg9xlD3lrdGYgG7+kBJw= 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-136-Wk6gk4jOMPyGatQd-7Opfg-1; Mon, 22 May 2023 09:51:49 -0400 X-MC-Unique: Wk6gk4jOMPyGatQd-7Opfg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 38C00802E58; Mon, 22 May 2023 13:51:48 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A9E4200AE6F; Mon, 22 May 2023 13:51:44 +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 v22 21/31] ntfs3: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:08 +0100 Message-Id: <20230522135018.2742245-22-dhowells@redhat.com> In-Reply-To: <20230522135018.2742245-1-dhowells@redhat.com> References: <20230522135018.2742245-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Rspamd-Queue-Id: A8B981C0006 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: e5ag47hzra4tofa437tefqjmak7h86q4 X-HE-Tag: 1684763514-196344 X-HE-Meta: U2FsdGVkX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7dezdR5b2GWcY1mkRoosHPwJ8cvDOEUdcpN1CJP4AXr5OVD5wSvF1HhjCwLj+7brI/YaCcMc91mutA2Sn9NohR1I7cj9UCd5xa65V5qIxa1WZUJNFPGT+Bng7lBxEjT8NHfwJNY1Wbk9hEy88ZAU7sUR5Lt13HdAGW3M9EDwygNTHZIl/d4yQmC/pUJj3B6wNEY0Kjjvsi/9eZX0U5fJB2LXYGqHcgttB1jxZlgaQxPVtmG/Ijsl2YVaJ+a7P8+F+aiI64JBaVDmy//akY8rZYmE8EssAb3 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 wrapper 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,