From patchwork Mon May 22 13:50:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250597 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 04561C77B73 for ; Mon, 22 May 2023 13:51:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 911E4280002; Mon, 22 May 2023 09:51:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C280280001; Mon, 22 May 2023 09:51:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78A32280002; Mon, 22 May 2023 09:51:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 66437280001 for ; Mon, 22 May 2023 09:51:41 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4350B1C6D45 for ; Mon, 22 May 2023 13:51:41 +0000 (UTC) X-FDA: 80818028802.26.BF93CC9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 4901C14001E for ; Mon, 22 May 2023 13:51:38 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BZKIK2rv; spf=pass (imf26.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=1684763499; 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=biWhCp40UoPe+CyS0Ztg+L+BfqL/s+IwYQGGzgJK6kA=; b=cqoj3YEqylcmv/boFkcxE64DS+2OXrxDV2vNAfQq8TXQiHE9Jjo+4RqWjI9J1aVBYwf6tt yAJIUCBOFpaWP/nkrrhxG6Xl6Pw5aD28m+6ykxBk4UrOOE4AynUbjsvGd7YORI1gsEQ1/K /xEWA2NzEOI6bc0cfPRfyFJ6uZA0AWE= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=BZKIK2rv; spf=pass (imf26.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=1684763499; a=rsa-sha256; cv=none; b=ULd2XUFS3sDHuFogb3wEUf9txV1yz2p26/XjCeKfQsh+6ZF1nh/t5wBVnMs4Ojc7+XDAjB URYSk5v8qdFeCcXiQjXU3pQ2gqPB1m6/Ss13IZsUuzFyYFh/ccitxgWj0PsJn5oxCBdXnv aXGITv+Z8YYAOlmc/rHWQ3Zn/6sajJE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684763498; 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=biWhCp40UoPe+CyS0Ztg+L+BfqL/s+IwYQGGzgJK6kA=; b=BZKIK2rvkymFSSGrNDWoDXlABsVpdviFM1UlquAXtu6MjlADtyUU6Y6dQtsq5cALdRov8a b8Q2aOMzIRln49jW4z+p4xxGelDZYKFR53+06kR8Z1QbbuwV+VWyOGzgccJKpLtY5qCA7K DsxqU6oGfXA23WkFQBenrnOic/OH1aA= 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-671-pS6JrZMuO7KdRfWYxzCxgw-1; Mon, 22 May 2023 09:51:33 -0400 X-MC-Unique: pS6JrZMuO7KdRfWYxzCxgw-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 0380C800BFF; Mon, 22 May 2023 13:51:32 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3683C1ED99; Mon, 22 May 2023 13:51:28 +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 v22 17/31] ecryptfs: Provide a splice-read wrapper Date: Mon, 22 May 2023 14:50:04 +0100 Message-Id: <20230522135018.2742245-18-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.8 X-Rspamd-Queue-Id: 4901C14001E X-Rspam-User: X-Stat-Signature: p4gokum4yi39ibynp75nxgbgkjynji61 X-Rspamd-Server: rspam01 X-HE-Tag: 1684763498-566099 X-HE-Meta: U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G+xqLdm/xIA3dyJ7oxlLxpzIY2mIsaMM6vD4efZOeHuvJjkmWpJ818IyCqZPsrOBkh1IjYhcdXC1Z9HSKGTac9GiI5r/Q3xo1w/w8vR3pq2ax0+zrdk3ZGFqlVJU6VImRy2eb8Q9GeylClhpHOjodk9YVa/aYLTwGBzJmT27J/dJ8jLxOnsGke3aLxS0S/oVZg72VZ8xJYq6DCqVPruvPaBH0dLmuAylSuPF+Zu0Esb3vVIScjDy5+56Y9cZovOMEiqS0aZwTf4VK/9uUCIlJtCTzlmmfIspY8GrbQtntaKGicnrrPR0mU/f/hJTdLnY9ZE5HHvg7xoFiSgNe1ZpW 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 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, };