Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp2239128pxx; Sat, 31 Oct 2020 12:53:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhXwsY4h7JgDyicJe2XpoKmnKn6HgVevnZpyIZ2cq75+WkqAsliCqAefsl+3/WB9KiXlQT X-Received: by 2002:a17:906:c095:: with SMTP id f21mr8709963ejz.108.1604174032168; Sat, 31 Oct 2020 12:53:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604174032; cv=none; d=google.com; s=arc-20160816; b=MoapD9iSBPMckqtUvKunu25PWzHNAuX1wVcSJUX90lIf11MM4Tc1GYZUge0va1c1+b V3//UcFD5I2wgYW+BL5rIiifFEwXzrwPFX316Eq9elVhRhpnzvgVcRuwG6zJFpJjJLEl cux+m7k43K9X78N80Ocr9cA2M8NJp1CQEF8IDF9PfD76VZoZq/DZiDrIhPzciymmTdmI 6umreZFsyYDnu0KjcIfx8yHJ0uABiHGZcwqzNTpFT36vl6SwzErIhzBRJt/IQgA/ilt2 dtibGmzqCEYR1V2wZhFxAfoXArYNobFTmoGgaUoO6st3TDNm1G1xJdiliNClpIjc1Rja wkoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=Y3+Vr/7VfjoQve6rX9Ou7rfg3kCgfxLd0wjV4hIjteU=; b=PN/rMktLNrtg0vcieMIEOgXYL7z87sF92FkL4B6MlKiwSy6HLoNS4RHI6iS15W9o3T OWS88XE+kpDfGSwIwfo35P31jbey4IVPYbudDfL7uoP8igC6oq7nkpwKQqzioaknBeB1 6DNkl1d1q22bCWmpVJ674okQpJVW0OUi8514K7NeFBw42GiCdIe04FEvrc/5JZohv1oq 0R4MIFDo+4yYg21IV03tavcVIlYkT8+562VP1AfifcYk8XJ7zu8SUFycphSj7d5N2hG+ SAVoWujtZ9mDX5Gu+khubEbYzd6S/8FJvvmrTQynKUCl1s8RbsEObjfTZGVAfI1V3Neo xh8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=WK9FE9kM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b5si6917511eju.428.2020.10.31.12.53.29; Sat, 31 Oct 2020 12:53:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@aol.com header.s=a2048 header.b=WK9FE9kM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=aol.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728488AbgJaTvV (ORCPT + 99 others); Sat, 31 Oct 2020 15:51:21 -0400 Received: from sonic303-25.consmr.mail.gq1.yahoo.com ([98.137.64.206]:37223 "EHLO sonic303-25.consmr.mail.gq1.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728483AbgJaTvV (ORCPT ); Sat, 31 Oct 2020 15:51:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1604173880; bh=Y3+Vr/7VfjoQve6rX9Ou7rfg3kCgfxLd0wjV4hIjteU=; h=From:To:Cc:Subject:Date:References:From:Subject; b=WK9FE9kMmxwDjyvub1HmPSXZ5ayOYWE+W8OVc1S0lQqd1DnLegCRdfbOKkEwzB5aS4gE5Z3X/1TPj2OpdhkCL8Jan35aQJUVGg2Asgl/aMs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4kcbY.6PWHUInVAKX.GCjHcrxRllfPK00wwRTVn5pxsESD9U UfwF9rGUwp.no1BlKKK9CkmfYYu4qzpNXxWwDNKraHH8qsKSwEJebvQr6fcyiOqpOogs3YIumTzs 8Lv_ZmgkH23LXeW5SwtFQx5rJ_j6EBAScH7VdT1FOFAdvaqlGAN8ajFqaHSJvFdkqLIu904V7KM8 qH94HP03m3dgYxtccFsLdCrxaPP13bXJh_WqVwJenN7mYa26t9DUmkPgsQQNrG.cGR6m4SRrMAkw 5wsDsGxI3j.2vIIm.A9WtucGe3xSssylo0oL9jxouaG8vB41c5hGFhEfOx0zhK8rERGswO_mneAx M6mJu.sAEf0pxXFmyF73mIchpBtCky1bEEJcgfmODG6CqSf1FcM4AQFF3I64UaecBwrN_GE24AJZ aQewVKCjcBOUdfDW6casg9Ie0R2rbMNTC0iCh5BaUfMknsUIOzY5r6hQL3DSdOXwGTQA- Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.gq1.yahoo.com with HTTP; Sat, 31 Oct 2020 19:51:20 +0000 Received: by smtp401.mail.ir2.yahoo.com (VZM Hermes SMTP Server) with ESMTPA ID 96f200b13834f92880e94edd3139f03c; Sat, 31 Oct 2020 19:51:15 +0000 (UTC) From: Gao Xiang To: linux-erofs@lists.ozlabs.org, Chao Yu , Chao Yu Cc: LKML , Gao Xiang , nl6720 , stable Subject: [PATCH] erofs: derive atime instead of leaving it empty Date: Sun, 1 Nov 2020 03:51:02 +0800 Message-Id: <20201031195102.21221-1-hsiangkao@aol.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit References: <20201031195102.21221-1-hsiangkao.ref@aol.com> Content-Length: 2818 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gao Xiang EROFS has _only one_ ondisk timestamp (ctime is currently documented and recorded, we might also record mtime instead with a new compat feature if needed) for each extended inode since EROFS isn't mainly for archival purposes so no need to keep all timestamps on disk especially for Android scenarios due to security concerns. Also, romfs/cramfs don't have their own on-disk timestamp, and squashfs only records mtime instead. Let's also derive access time from ondisk timestamp rather than leaving it empty, and if mtime/atime for each file are really needed for specific scenarios as well, we can also use xattrs to record them then. Reported-by: nl6720 [ Gao Xiang: It'd be better to backport for user-friendly concern. ] Fixes: 431339ba9042 ("staging: erofs: add inode operations") Cc: stable # 4.19+ Signed-off-by: Gao Xiang --- fs/erofs/inode.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c index 139d0bed42f8..3e21c0e8adae 100644 --- a/fs/erofs/inode.c +++ b/fs/erofs/inode.c @@ -107,11 +107,9 @@ static struct page *erofs_read_inode(struct inode *inode, i_gid_write(inode, le32_to_cpu(die->i_gid)); set_nlink(inode, le32_to_cpu(die->i_nlink)); - /* ns timestamp */ - inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = - le64_to_cpu(die->i_ctime); - inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = - le32_to_cpu(die->i_ctime_nsec); + /* extended inode has its own timestamp */ + inode->i_ctime.tv_sec = le64_to_cpu(die->i_ctime); + inode->i_ctime.tv_nsec = le32_to_cpu(die->i_ctime_nsec); inode->i_size = le64_to_cpu(die->i_size); @@ -149,11 +147,9 @@ static struct page *erofs_read_inode(struct inode *inode, i_gid_write(inode, le16_to_cpu(dic->i_gid)); set_nlink(inode, le16_to_cpu(dic->i_nlink)); - /* use build time to derive all file time */ - inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = - sbi->build_time; - inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = - sbi->build_time_nsec; + /* use build time for compact inodes */ + inode->i_ctime.tv_sec = sbi->build_time; + inode->i_ctime.tv_nsec = sbi->build_time_nsec; inode->i_size = le32_to_cpu(dic->i_size); if (erofs_inode_is_data_compressed(vi->datalayout)) @@ -167,6 +163,11 @@ static struct page *erofs_read_inode(struct inode *inode, goto err_out; } + inode->i_mtime.tv_sec = inode->i_ctime.tv_sec; + inode->i_atime.tv_sec = inode->i_ctime.tv_sec; + inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec; + inode->i_atime.tv_nsec = inode->i_ctime.tv_nsec; + if (!nblks) /* measure inode.i_blocks as generic filesystems */ inode->i_blocks = roundup(inode->i_size, EROFS_BLKSIZ) >> 9; -- 2.24.0