From patchwork Sat May 20 00:00:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13248998 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 CB933C7EE2A for ; Sat, 20 May 2023 00:01:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F3EB28000E; Fri, 19 May 2023 20:01:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 57DE8280001; Fri, 19 May 2023 20:01:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D04F28000E; Fri, 19 May 2023 20:01:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 220FC280001 for ; Fri, 19 May 2023 20:01:55 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id F132A1C79C5 for ; Sat, 20 May 2023 00:01:54 +0000 (UTC) X-FDA: 80808680148.21.D0AAC74 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 392701A001F for ; Sat, 20 May 2023 00:01:52 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hqZ8/zFW"; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684540912; 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=zZb+7DwI4egZIrF5pxcV1ZQbliPAo6greLJudpvGjhA=; b=ynQcK69naYr5KMTLKZeCdcmJV8rno7LaelawoSWdghvHmI3VyQYVTx61bIHEsG21+X/+1A HmFxEzkLe17YYDC/WMnNyJToWP8p0jXpgKuvvKQlll2EZtEle8tMY5He/dYTmGP56/eU2J 2TwF8TRUOWPrgsdrGT0DxhTvSm+Bjuw= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hqZ8/zFW"; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684540912; a=rsa-sha256; cv=none; b=AWQxKaVLFOO2sLHiSVb3szBNP06LKvhs+IaPN97lPcuMIo+OhD6OkA66tbkf973OjOeFGI NdMvvmIr/jjiIaiPg3AsgL44F8sPkjEY/p58OyzV9jdfaMzf3rmGYs83/l4ycczs8Pa5EK RDUw2WnKrYmpZEnEU8BOgXxoFV8PEBs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684540911; 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=zZb+7DwI4egZIrF5pxcV1ZQbliPAo6greLJudpvGjhA=; b=hqZ8/zFWUuZlxZRMLFVe1W/DDXBoLSAtvS1R6Ao1dWFt0hpObVLSAH2O0XWeaq49HaruNV +GPN8KjMBFmZNXjT5RYIbqXPsqAE9O+lRheQUwHc+FNS7XQcxhqLzSSiGz1t9k9xFxN1NQ ZUAglNQEDypmuF5sA0Vn2C/blX2Ck+E= 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-513-G93-k9ToPbKP465srY7iiw-1; Fri, 19 May 2023 20:01:48 -0400 X-MC-Unique: G93-k9ToPbKP465srY7iiw-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 2F2AC85A5A8; Sat, 20 May 2023 00:01:47 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00F7E4F2DE0; Sat, 20 May 2023 00:01: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 , Tyler Hicks , ecryptfs@vger.kernel.org Subject: [PATCH v21 17/30] ecryptfs: Provide a splice-read stub Date: Sat, 20 May 2023 01:00:36 +0100 Message-Id: <20230520000049.2226926-18-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-Rspamd-Queue-Id: 392701A001F X-Rspam-User: X-Stat-Signature: hb97e5y3txa9xkepd5sz76irpodft9yi X-Rspamd-Server: rspam01 X-HE-Tag: 1684540912-22014 X-HE-Meta: U2FsdGVkX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MxtAo0H+WjpERk+EcI7Ia4xS8xsR1L5M3kCbomqqV1zRzMH6FKY3xkALUBUZUg815rihTHubdQVLXCeXDp2z2TlKVnbXPwIk1yGWx9FC6pUCXjHBq5Vf+CHDm4QgIHUPU2MdW/IvvrH7yQKmogYk/nUXAeG4n7bmbAxtzeUBNt+yqL89ksq7khSBoestMbas1fwcEX+SdwhL3v+/Sf5hZHXzNVAkjaN8kTwe8MIhkHIloAkZv9J5DsNm85sdd9USygAVm23Wy1WwFy8Nz7w6qLn9h+joJdzPkNtFVOZTdNHLy09i1/W7qh3hnt89mKeqJexy9rm73hNe84 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 ecryptfs to update the access time on the lower file after the operation. Splicing from a direct I/O fd will update the access time when ->read_iter() is called. Signed-off-by: David Howells cc: Christoph Hellwig cc: Al Viro cc: Jens Axboe cc: Tyler Hicks cc: ecryptfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-block@vger.kernel.org cc: linux-mm@kvack.org --- fs/ecryptfs/file.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 268b74499c28..284395587be0 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c @@ -44,6 +44,31 @@ static ssize_t ecryptfs_read_update_atime(struct kiocb *iocb, return rc; } +/* + * ecryptfs_splice_read_update_atime + * + * generic_file_splice_read updates the atime of upper layer inode. But, it + * doesn't give us a chance to update the atime of the lower layer inode. This + * function is a wrapper to generic_file_read. It updates the atime of the + * lower level inode if generic_file_read returns without any errors. This is + * to be used only for file reads. The function to be used for directory reads + * is ecryptfs_read. + */ +static ssize_t ecryptfs_splice_read_update_atime(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, + size_t len, unsigned int flags) +{ + ssize_t rc; + const struct path *path; + + rc = generic_file_splice_read(in, ppos, pipe, len, flags); + if (rc >= 0) { + path = ecryptfs_dentry_to_lower_path(in->f_path.dentry); + touch_atime(path); + } + return rc; +} + struct ecryptfs_getdents_callback { struct dir_context ctx; struct dir_context *caller; @@ -414,5 +439,5 @@ const struct file_operations ecryptfs_main_fops = { .release = ecryptfs_release, .fsync = ecryptfs_fsync, .fasync = ecryptfs_fasync, - .splice_read = generic_file_splice_read, + .splice_read = ecryptfs_splice_read_update_atime, };