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: 96240 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1062673vqo; Fri, 19 May 2023 01:03:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4TpGMWCEwtLf4yxY2ZjYtGKNdh+0rwAj6LU0bkqIoqTSgBUFmrx8zSLTdUMfw5PiU4WB/T X-Received: by 2002:a05:6a20:2d0b:b0:100:bda9:4b1b with SMTP id g11-20020a056a202d0b00b00100bda94b1bmr1255501pzl.37.1684483406299; Fri, 19 May 2023 01:03:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684483406; cv=none; d=google.com; s=arc-20160816; b=sf85kirfJ/RHLqRrSTTBnC7Qg7B47oEGPyJxqrBEUTKLhOWBevinfFhzMXtsHxXcQ/ Gu29rIox8+cNG3Dt9eklwyrFxzXKLWkDaf6IzHfnUjB4S2tDbPmAl8pMlW+JlXq1q0+1 Y4BkI2gTmjuGT5q1+2eRbW92rq5GClOYkQ96zjbKNxw831XeOGY7k83gQ45Gq2Zb3tg/ ORdtAGDqmK0bIAHWlGgS+0QOJoaGDITjN5JemmXBbduqUvM3mBkLAFaLGAt/shdRdDLJ 6vR076Bp1FbVFIg4qpgJHC/9w4v7LjFis1tSxIe7dKdXUjZwymQBeOfDfWmgaGXvZoHQ 3s9Q== 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=/4iKO0WOSo1UJaMQGu6hpLFM8tphuArX0rBWtTeeSuo=; b=fgnxDxnf38hgRcufcl3f1MTwOSsgM/I0ZpPnpGzdAHg5w8VBIUYK60diDu4HQ9kbZo hCT7VcCMunMJuwkymNxYFvzzhPfgBpCX75c4DLUlXQNCHCBYuuZzq9N8ayeVK2v0YwUG zGhRotWvSKOWDHUfIB5626eoeXtqL6v30aaNaDp8XAS6Rqxqfg/ya5o0JfjqaP1+XvH9 dvyOrUAG5Pjh0ckQue5Di+W0168jd7IzZ/E/pNOx1+2Ovby74FUDAPHtObXw9VOrZmfF zrfRKi/b9hepmTMxdP574T5e+ezhRri/BSnzbzMIj5aaP+Y54YTlWqqvnhoTcahc5b0v 9A2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K9o80uau; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g2-20020aa796a2000000b0064d1a09fa3fsi716704pfk.293.2023.05.19.01.03.14; Fri, 19 May 2023 01:03:26 -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=K9o80uau; 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 S231440AbjESHnw (ORCPT + 99 others); Fri, 19 May 2023 03:43:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231215AbjESHm7 (ORCPT ); Fri, 19 May 2023 03:42:59 -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 F03F3198C for ; Fri, 19 May 2023 00:41:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684482113; 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=K9o80uaup8/jTx31Q7eRAjBkysMAnUFzY0ZcePKMGhaRs4FQaOKvXkO3gMgWoJuZdWP2E/ lpvpib534GtunAgJ+7438LECHGBxJBtkPwWL8iTIKzOPWPckuyTiUqtNjiQ8lTLFc+fETS Abrzzpz2RjEALmo9PIlR2m7ZH5SK7Qo= 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-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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766308872245179362?= X-GMAIL-MSGID: =?utf-8?q?1766308872245179362?= 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, };