From patchwork Fri Feb 11 21:36:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Roche X-Patchwork-Id: 12743907 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 8A32CC433F5 for ; Fri, 11 Feb 2022 21:36:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D165F6B0073; Fri, 11 Feb 2022 16:36:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CC6A76B007B; Fri, 11 Feb 2022 16:36:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B66456B007D; Fri, 11 Feb 2022 16:36:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0092.hostedemail.com [216.40.44.92]) by kanga.kvack.org (Postfix) with ESMTP id A3F8D6B0073 for ; Fri, 11 Feb 2022 16:36:33 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 672A6181AC9C6 for ; Fri, 11 Feb 2022 21:36:33 +0000 (UTC) X-FDA: 79131808266.07.6F3CA18 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) by imf23.hostedemail.com (Postfix) with ESMTP id F3736140009 for ; Fri, 11 Feb 2022 21:36:32 +0000 (UTC) Received: by mail-wr1-f43.google.com with SMTP id k1so17297656wrd.8 for ; Fri, 11 Feb 2022 13:36:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=algolia.com; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=QoHkcZvCmcHF62oRV/Hm9AoyHlp+75nzlQs0pgmwqUI=; b=s8v8rMvQoML6oAH/jNhMegfoUndT2JSIU3CERlBOF4Oi6fm+u54Ix6EuMuVg+cksOH tKXO81zID1PUPvvqlxPXARkYJON2MJJRdri9oSaKO1Fw3+iVHcmmPwOyFrt8m9iALg7c GiqaZrocgto3SuwzrfUiTNa0NWRi/hcxIAxPw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=QoHkcZvCmcHF62oRV/Hm9AoyHlp+75nzlQs0pgmwqUI=; b=PYe2rkY6kv2JpWbFvxjK6gJz6PsiU5+Dl+3ihfXdXBmh45DgwY70o2HMUzJwWUgE2m NiO6Z1R/pZgh9T0p2F8ZsplR7oUdcYVHQZAin5HrfufouOsbhUtTcPnFeVgPDtMgehA6 Gp3PDdR7eQ0YGemKQUciWvW9BUmYbxugaPWXT+Bkrlw5esJ6L+2ss4bDfUM/iMiQzJ1n OiR4nrhv9WaYZce0nwCFRvG9wkzfnGOHYgK8DzAw3gG73ZYb65pL7/CweW7pAUx4hnCU KHLJHJA/NkcvAXAujw28O2uOul6VCs6qy1/4WmxTjdaRIJy2ucEOwdZN+bsn8YtJvVeR wqvg== X-Gm-Message-State: AOAM530u4ip0WZtN2sagTTKyTlZMaLfi2zUfF3VZD6iqMGhtmnqwUOZK JldWFKMCQ05GYvr93LPO46h7/Q== X-Google-Smtp-Source: ABdhPJwKq1doCFiVgUnyUmItCSHDL6e7xpBEp05K5zavzokjOh6gztQvmlDI3nsM1kotmCw6/9CABQ== X-Received: by 2002:a5d:64ad:: with SMTP id m13mr2785015wrp.671.1644615391604; Fri, 11 Feb 2022 13:36:31 -0800 (PST) Received: from xavier-xps ([2a01:e0a:830:d971:752e:e19b:a691:2171]) by smtp.gmail.com with ESMTPSA id r2sm13133308wrt.65.2022.02.11.13.36.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Feb 2022 13:36:30 -0800 (PST) Date: Fri, 11 Feb 2022 22:36:28 +0100 From: Xavier Roche To: linux-kernel@vger.kernel.org Cc: Hugh Dickins , Andrew Morton , Jean Delvare , Xavier Roche , linux-mm@kvack.org Subject: [PATCH v2] tmpfs: support for file creation time Message-ID: <20220211213628.GA1919658@xavier-xps> MIME-Version: 1.0 Content-Disposition: inline X-Rspamd-Queue-Id: F3736140009 X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=algolia.com header.s=google header.b=s8v8rMvQ; spf=pass (imf23.hostedemail.com: domain of xavier.roche@algolia.com designates 209.85.221.43 as permitted sender) smtp.mailfrom=xavier.roche@algolia.com; dmarc=pass (policy=reject) header.from=algolia.com X-Stat-Signature: gf1qh45ieyf9ar3837fx9andbmtxp9sk X-Rspamd-Server: rspam03 X-HE-Tag: 1644615392-387363 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: Various filesystems (including ext4) now support file creation time. This patch adds such support for tmpfs-based filesystems. Signed-off-by: Xavier Roche Tested-by: Jean Delvare Reviewed-by: Jean Delvare --- include/linux/shmem_fs.h | 1 + mm/shmem.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index e65b80ed09e7..29787767c3b9 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -25,6 +25,7 @@ struct shmem_inode_info { struct simple_xattrs xattrs; /* list of xattrs */ atomic_t stop_eviction; /* hold when working on inode */ struct inode vfs_inode; + struct timespec64 i_crtime; /* file creation time */ }; struct shmem_sb_info { diff --git a/mm/shmem.c b/mm/shmem.c index a09b29ec2b45..5a3907712c4f 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1061,6 +1061,12 @@ static int shmem_getattr(struct user_namespace *mnt_userns, if (shmem_is_huge(NULL, inode, 0)) stat->blksize = HPAGE_PMD_SIZE; + if ((request_mask & STATX_BTIME)) { + stat->result_mask |= STATX_BTIME; + stat->btime.tv_sec = info->i_crtime.tv_sec; + stat->btime.tv_nsec = info->i_crtime.tv_nsec; + } + return 0; } @@ -2265,6 +2271,7 @@ static struct inode *shmem_get_inode(struct super_block *sb, const struct inode atomic_set(&info->stop_eviction, 0); info->seals = F_SEAL_SEAL; info->flags = flags & VM_NORESERVE; + info->i_crtime = inode->i_mtime; INIT_LIST_HEAD(&info->shrinklist); INIT_LIST_HEAD(&info->swaplist); simple_xattrs_init(&info->xattrs); @@ -3196,6 +3203,7 @@ static ssize_t shmem_listxattr(struct dentry *dentry, char *buffer, size_t size) #endif /* CONFIG_TMPFS_XATTR */ static const struct inode_operations shmem_short_symlink_operations = { + .getattr = shmem_getattr, .get_link = simple_get_link, #ifdef CONFIG_TMPFS_XATTR .listxattr = shmem_listxattr, @@ -3203,6 +3211,7 @@ static const struct inode_operations shmem_short_symlink_operations = { }; static const struct inode_operations shmem_symlink_inode_operations = { + .getattr = shmem_getattr, .get_link = shmem_get_link, #ifdef CONFIG_TMPFS_XATTR .listxattr = shmem_listxattr, @@ -3790,6 +3799,7 @@ static const struct inode_operations shmem_inode_operations = { static const struct inode_operations shmem_dir_inode_operations = { #ifdef CONFIG_TMPFS + .getattr = shmem_getattr, .create = shmem_create, .lookup = simple_lookup, .link = shmem_link, @@ -3811,6 +3821,7 @@ static const struct inode_operations shmem_dir_inode_operations = { }; static const struct inode_operations shmem_special_inode_operations = { + .getattr = shmem_getattr, #ifdef CONFIG_TMPFS_XATTR .listxattr = shmem_listxattr, #endif