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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 069C4C433F5 for ; Fri, 11 Feb 2022 21:36:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353774AbiBKVgh (ORCPT ); Fri, 11 Feb 2022 16:36:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:51290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348044AbiBKVgf (ORCPT ); Fri, 11 Feb 2022 16:36:35 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B454C62 for ; Fri, 11 Feb 2022 13:36:33 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id o24so14645749wro.3 for ; Fri, 11 Feb 2022 13:36:33 -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=WrGLJoRHh84yW2NIr6+JvJkfodE81aAk0M3zThq8aDZZgaH1Zi5NYRJi5ysOo1fYCW NSlKovxHGZtOsBwX1dFslfRnZmOQgvOcO8dJjYrIeTY5r70gNRc3x+2SfeloeOvjzlkF hh6I5GYXZwehmnqW9UZsQ+52NaSlxsJafBQWmC1tsf+mCYwSc4JHk6Dw7BYmim0V2bhC bRIGzBVdGRv/jp7xf9PPCVQBmpLBmYvlOPoB9bsC7jmGcf1KqELdPMexlKBr6CH2Lu32 WdC2pSJJ0olBKM9TWatsRfk2VkHzbMWoXPZ6x1WbaC5OJrttS7QovnmdUKK5YZIIG8zG TScA== X-Gm-Message-State: AOAM531XLcZJHeOq00Tw4yxVhoeHZf3lxgXspk5OduxVnmo7euwACQ8z Vj2sZo983TwOY5PmgabjKMcuIaUEYvifeA== 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B06CC433F5 for ; Mon, 28 Feb 2022 08:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234060AbiB1Inr (ORCPT ); Mon, 28 Feb 2022 03:43:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229773AbiB1Ino (ORCPT ); Mon, 28 Feb 2022 03:43:44 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2B2F17E1C for ; Mon, 28 Feb 2022 00:43:04 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id r10so14182318wrp.3 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=uL3OtCHi4MOCLUeDDfLq//A11YMZ20Eox/0OPKULG6/X0nw8iRf+XySVJT8ARqEjpf H0PW0SumF/vGeIhNzj3DwMU8rm3kfMZLIHCCR7tRy+WvsRJg+yMRcUtZu1VANhOyENwg 6Dt6LovdyLqQ0Bwy1amG7rR5V2nJQVI/XmqYp6YInDYB0Si/P7d+fgWR729Idquo00JR 76vzFPC89deNHRWLzTRdYa9xcJf3orJPUxOvjH2XLj8U/uC6sJXxZGDhUZ9k5vPWAB8p Uw4pVXD0w6SdkSgKRLlkfoovmeT7Zx/klWAdzLdj5JtfcjWk37Hd8gzRbGWYfFZzs9FN cqLQ== X-Gm-Message-State: AOAM530LnfKzQ8+MOqywPaPbFIe55VRDFCW79jO1Uqa3XCPcwpqjOpGF ND6gvdXCZqP0bYDzj4Rje5TKaw== 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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