From patchwork Fri May 19 07:40:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13247769 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 7A490C77B7F for ; Fri, 19 May 2023 07:42:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1738C900016; Fri, 19 May 2023 03:42:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 12264900003; Fri, 19 May 2023 03:42:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F07F0900016; Fri, 19 May 2023 03:41:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DEEAE900003 for ; Fri, 19 May 2023 03:41:59 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id AEF021A09D0 for ; Fri, 19 May 2023 07:41:59 +0000 (UTC) X-FDA: 80806210758.29.F54CBA7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id DC1201C000D for ; Fri, 19 May 2023 07:41:57 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RjUwTfw4; spf=pass (imf20.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=1684482118; 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=/4iKO0WOSo1UJaMQGu6hpLFM8tphuArX0rBWtTeeSuo=; b=QDUikbAiZ1qANfGTbUAIx2aK/B0rNQIVHU8xDRvdAyQ4AW2zs5KzJfbuYPr99lXctCFLHD lho6PBlIruat/6yxaVORC0KPNf+ib+dFRlOL1Dc06NlpALsqA1PUit+45agOekXrt1+kd+ qbzrBFXfdilNMHGeoygXQpXYic9QKdo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684482118; a=rsa-sha256; cv=none; b=rXLDb6QsSLENa7PQB8uRqD2M192gdxT89zzZlaW4+3XMLz+FJOtVauKTXcTVgBzGvAFGik 6bMPxWhFw9W4tOaKoot28Pwm5gLAr0Ueo4qIOSmLHwc9S7KSV5kfbvhi0t4N0XhlUgKUHm UmJWDPrQ6Iy4s31FJFU6G00f6RhwZpY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RjUwTfw4; spf=pass (imf20.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684482117; 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=/4iKO0WOSo1UJaMQGu6hpLFM8tphuArX0rBWtTeeSuo=; b=RjUwTfw4TcmG/eSTagvVhVjRMCFC+AUMQ4KfyFL0+JjUyoWjr1M6H4sYXFIsFCre9UffoB L1GYsP+kxPkRWvpKTlx9UBOkgqyk1WoHjcIQuvVolDeClCjqlQcK/ohjVdRiRTgffIsfJ6 CJw3081niw7aP9rZFclmND2dhT7Crrg= 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-187-6zZLhNJbPDyDHIrP4_P9AQ-1; Fri, 19 May 2023 03:41:50 -0400 X-MC-Unique: 6zZLhNJbPDyDHIrP4_P9AQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1A33D29AB3F0; Fri, 19 May 2023 07:41:49 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 767167C2A; Fri, 19 May 2023 07:41:46 +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 v20 14/32] ecryptfs: Provide a splice-read stub Date: Fri, 19 May 2023 08:40:29 +0100 Message-Id: <20230519074047.1739879-15-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.5 X-Rspamd-Queue-Id: DC1201C000D X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 1uzrefchcb7bmzgni588ruczwq15eawu X-HE-Tag: 1684482117-934757 X-HE-Meta: U2FsdGVkX18y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GzKfm1QQXCfxz9bFbbv5L3+XxvtLZF4D/30jguxAt8PA1DHgXDCGIngEsnOPpVv02XKTjvSuhWSP1M8Xhw9oNRWPbpORAjrI3UuddMCnR01ZbdMvw7OIGevpU7X1PKCi6hE/2NwcM8JrfSzE/6qt87O6kf38EYnGb5X/29M8mXhG1o+mvAZGIpklW0Fi+84cUfa/sTj5ebGjPCA/skk2WO/S+vegUbB06gMMpWWzz06PYC9n/DhI2Pr861Ci5YObRpL26uVBehxq1w6Gt+ysq33Z+rtz3L3TL8ClaTbKsRFbr8z0ZYfAaOZjzUFFB7TG+UuIZ 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. 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, };