From mboxrd@z Thu Jan 1 00:00:00 1970 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-Type: text/plain; charset=us-ascii 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 -- 2.25.1 From mboxrd@z Thu Jan 1 00:00:00 1970 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 9FDD4C433F5 for ; Mon, 28 Feb 2022 08:43:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1DB368D0002; Mon, 28 Feb 2022 03:43:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 18BB58D0001; Mon, 28 Feb 2022 03:43:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 07A2D8D0002; Mon, 28 Feb 2022 03:43:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id ED84D8D0001 for ; Mon, 28 Feb 2022 03:43:05 -0500 (EST) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id AAE66181951E0 for ; Mon, 28 Feb 2022 08:43:05 +0000 (UTC) X-FDA: 79191548730.31.F86501C Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by imf20.hostedemail.com (Postfix) with ESMTP id 0BDD91C0006 for ; Mon, 28 Feb 2022 08:43:04 +0000 (UTC) Received: by mail-wr1-f49.google.com with SMTP id d17so14118623wrc.9 for ; Mon, 28 Feb 2022 00:43:04 -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:reply-to:references:mime-version :content-disposition; bh=gF2h43IPb7uVz7qOwzCRk0sOsMdTB9uSAj1/EGBvwDM=; b=CuQYnp8lI6hR/debPsdD0hxe5bX78+NWDYQCs5+KPqYC0en9yIw9DOdeg40u4cDyKX 1TKa2OscAbwonNI/NDNw7hQoXIhVACqDlxwIFN5Cb+R3QyFQrjzKO2UTBP06goYyG9s9 FAU40ylTzi6VE3cu+eOH5xRXoLmScTJ1GQl4Y= 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:reply-to :references:mime-version:content-disposition; bh=gF2h43IPb7uVz7qOwzCRk0sOsMdTB9uSAj1/EGBvwDM=; b=UJlJcZc/CGaPzn3n81rV5SbKZ3ABS2cvN0vOwksqyvPWEgHm3fc8bE1lhnbquzNRyg TSVi4zerxJiCmLrx2mh73hsS2ezhNHuRAbVqWrLPWOjAqhFO/zLrDJIjsjmJH16M1PYp eB5gr4qKzeEfKNEdttyfI1tS1V70ynMxb7DrYKU+/tGVJmDNPFGeqAONcIh78oWJvftT lsaBLDlY4BFlKKvkZCuM31+GJqXja6HrmmPbgPkNj8kD9FU7ePzDl+LkDxNB3RQmDGl/ Z8ycmE//9JEtzlBMnGtCMoj8wc0HMsohoexoleuRTQYK5z2vJX7mXODKULIfRrodnNeA 8ITg== X-Gm-Message-State: AOAM532EcZm+OiY40Zd6u0LRX/i50xiwt7ggde6MdgGeXmgwNBHujKC2 RlIE8B+PJqxJIDmddr+HLLPEmA== X-Google-Smtp-Source: ABdhPJwtiLVK/US2TGE5RK8XE5mxaMTZakxwCktoyfkqJgl1SV46lQW35ewBRwYBzi6hgr49/vQYEA== X-Received: by 2002:adf:f711:0:b0:1ed:ab16:12e6 with SMTP id r17-20020adff711000000b001edab1612e6mr14764521wrp.534.1646037783516; Mon, 28 Feb 2022 00:43:03 -0800 (PST) Received: from xavier-xps ([2a01:e0a:830:d971:a8a3:7a18:7fc0:8070]) by smtp.gmail.com with ESMTPSA id v11-20020adfe4cb000000b001e62a8914c7sm9721083wrm.59.2022.02.28.00.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 00:43:02 -0800 (PST) Date: Mon, 28 Feb 2022 09:43:01 +0100 From: Xavier Roche To: torvalds@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Hugh Dickins , Andrew Morton , Jean Delvare , Xavier Roche , linux-mm@kvack.org Subject: [PATCH v3] tmpfs: support for file creation time Message-ID: <20220211213628.GA1919658@xavier-xps> Reply-To: b954973a-b8d1-cab8-63bd-6ea8063de3@google.com References: <20220211213628.GA1919658@xavier-xps> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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) X-Rspamd-Queue-Id: 0BDD91C0006 X-Stat-Signature: kgxnsymzqji4sg9aiqqtje7ynrmd3mes X-Rspam-User: Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=algolia.com header.s=google header.b=CuQYnp8l; dmarc=pass (policy=reject) header.from=algolia.com; spf=pass (imf20.hostedemail.com: domain of xavier.roche@algolia.com designates 209.85.221.49 as permitted sender) smtp.mailfrom=xavier.roche@algolia.com X-Rspamd-Server: rspam03 X-HE-Tag: 1646037784-837577 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: Message-ID: <20220228084301.dvUOzmZK9DsNAryaej5DtOvamAU6IKBI9nRKb7TwvP0@z> Various filesystems (including ext4) now support file creation time. This patch adds such support for tmpfs-based filesystems. Signed-off-by: Xavier Roche Signed-off-by: Hugh Dickins Signed-off-by: Andrew Morton Tested-by: Jean Delvare Reviewed-by: Jean Delvare Cc: Xavier Roche Cc: Jean Delvare --- include/linux/shmem_fs.h | 1 + mm/shmem.c | 11 +++++++++++ 2 files changed, 12 insertions(+) Index: linux/include/linux/shmem_fs.h =================================================================== --- linux.orig/include/linux/shmem_fs.h +++ linux/include/linux/shmem_fs.h @@ -24,6 +24,7 @@ struct shmem_inode_info { struct shared_policy policy; /* NUMA memory alloc policy */ struct simple_xattrs xattrs; /* list of xattrs */ atomic_t stop_eviction; /* hold when working on inode */ + struct timespec64 i_crtime; /* file creation time */ struct inode vfs_inode; }; Index: linux/mm/shmem.c =================================================================== --- linux.orig/mm/shmem.c +++ linux/mm/shmem.c @@ -476,6 +476,8 @@ bool shmem_is_huge(struct vm_area_struct { loff_t i_size; + if (!S_ISREG(inode->i_mode)) + return false; if (shmem_huge == SHMEM_HUGE_DENY) return false; if (vma && ((vma->vm_flags & VM_NOHUGEPAGE) || @@ -1061,6 +1063,12 @@ static int shmem_getattr(struct user_nam 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; } @@ -1854,9 +1862,6 @@ repeat: return 0; } - /* Never use a huge page for shmem_symlink() */ - if (S_ISLNK(inode->i_mode)) - goto alloc_nohuge; if (!shmem_is_huge(vma, inode, index)) goto alloc_nohuge; @@ -2265,6 +2270,7 @@ static struct inode *shmem_get_inode(str 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 +3202,7 @@ static ssize_t shmem_listxattr(struct de #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 +3210,7 @@ static const struct inode_operations shm }; 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 +3798,7 @@ static const struct inode_operations shm 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 +3820,7 @@ static const struct inode_operations shm }; static const struct inode_operations shmem_special_inode_operations = { + .getattr = shmem_getattr, #ifdef CONFIG_TMPFS_XATTR .listxattr = shmem_listxattr, #endif