Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp181557rwd; Fri, 19 May 2023 17:52:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4Jq/2VIWuXElJZSSXgabWX+ynuHyWkJJ4C6rbweZROMnlmyr7dGfOfCXuuQXN0AOIsfwjf X-Received: by 2002:a17:902:e848:b0:1ab:275:5abf with SMTP id t8-20020a170902e84800b001ab02755abfmr4680103plg.55.1684543930860; Fri, 19 May 2023 17:52:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684543930; cv=none; d=google.com; s=arc-20160816; b=CQk5BDFc5MavpCxpVTs5YA1/lhIFdBsOS94oR2qwki46f/smITJWLE7UTTTbzDX27S oPNkCemBJxsYMX9UMiJTuwwIrPhJMzD0EmTX5logo+a5vkryFqJkrKowvVDdpx0tLlJd fFEuxYvaH1a6ZHLsu9qk7YjTL7hHonLjsM/EXUBYNzcajTwgcagTT/svK9o4uz54KrHG bCtzHH1ZyMH1ftmvpzQzpYVzPBnGnphs+hPPmPDV4V5OevRUSqYwHZmnxfUg0zqXOmo+ lZrQ1E2/6avWV7NWs7515BN1K1aVrhoxZII5O9kN5EiBX+VGD4p+2gPFz/gunXXiaY3i JUtg== 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=zZb+7DwI4egZIrF5pxcV1ZQbliPAo6greLJudpvGjhA=; b=F0+ti/P70ws3RsHfSKNiTMeB5EP4kfG6RR5AY1tkmAGTmDgoRDryuTzrJbL58Bu+Lt DxLq7c8UMaT/KkF+H/jBorisTw7uLMZaBZ+0yr6zWFH6FczbTbn5DjedK4lDn13m/VDn zguoabVl+jvOKLkZySNPpVXcThQr4QkojCJ0AB7SnzLBtpjkQyiEyg6ruGS7MwtqT8by bUHRawXxzVLx9frP1pcG+DnkZDXt7H/GpzC7MGJCgz5njFCa05elCdk+oTxKtbd1bcK0 ipbDspluPjLqWlpehDmDhUQ5oPAEndOAJPT0b9XpWPFS0zHyTb/f/yAq2F5H62JTyC3P 60JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="hqZ8/zFW"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u10-20020a170902e80a00b001aafec82436si413185plg.204.2023.05.19.17.51.51; Fri, 19 May 2023 17:52:10 -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="hqZ8/zFW"; 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 S231803AbjETADz (ORCPT + 99 others); Fri, 19 May 2023 20:03:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbjETADa (ORCPT ); Fri, 19 May 2023 20:03:30 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 295871711 for ; Fri, 19 May 2023 17:01:52 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit 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, 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 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, };