Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3851371pxb; Tue, 17 Nov 2020 05:23:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyXoseY58koG+72ry+81zQrW/N91JZKkH6tPeISPZVSkVCge+0HIafbnIYEwj6gotUe3biR X-Received: by 2002:a50:d582:: with SMTP id v2mr21316413edi.218.1605619415242; Tue, 17 Nov 2020 05:23:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605619415; cv=none; d=google.com; s=arc-20160816; b=Pmi+N6BetRNwxyG/N6EQPC6nt2g3VwLI4VsztSYjUet0BYNHhAPFTsLVIvPgpPmhti 5CTwwMTHIXGIJQLXXH0ydPmGQ/rImuT4Xix/gw5cDdW2f9Oi5WsLCQURDVfdaZGRx66v PwFKoKObFLbUqHJAYJeFgV4lwCQbN06F0Dr4pEdAjhTVhzwJXi30IFHx9ex4ToBb96Pi whPqO+D9FzXbJ2amQGyEiC8yMceWkxuUzv/Vu69Kgubb1sOkpSMYGIsgzHysKoUZgxv0 39kKbp7AwrCTY5ytP8b/s1UuKxbdAxbRlY3JDUC6TEd+ILQvPxFYMOYUSJ4vfTijUFRZ JwQQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u1/ISkztFkdwTlsNnarIMHp6XiDfa/is3+eyWavzhq8=; b=yM9dQSOrZqFEoc3RRquogm9EMHrQ6kAEpcalYdAtSCjKLoUj2bx+OqiMB12OD6dGAH K/WJTxIzfL3YTtVsrFcSPlmVfb9l8rhualrc1kGESY4r+iy3MYMSxDy6YTffE31Eb/hM NeoaIVdi4k85amhvKXwRuM2yEqKVefLjaiZ0f1vIgl+F3JZ9CeaE3U2rLptJRbHfnWh1 bvVI+FFg9M3CCTIYbEPxlpdqIrj8EWBCUfYKWjEV+bdHz02UE5PvvoC37Q1I/hv9nn3X oNID3A5FdI+KC88Bs1HmcVSxb/FnSmiZrBIIuJ1l/ESSntrHOEcQfqxOnM9zmYT2M2lj CE9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="hotGb/cp"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oa23si1246580ejb.707.2020.11.17.05.23.11; Tue, 17 Nov 2020 05:23:35 -0800 (PST) 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=@kernel.org header.s=default header.b="hotGb/cp"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730838AbgKQNVM (ORCPT + 99 others); Tue, 17 Nov 2020 08:21:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:54786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730835AbgKQNVI (ORCPT ); Tue, 17 Nov 2020 08:21:08 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 91E8A2463D; Tue, 17 Nov 2020 13:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619268; bh=EToaU/VKICbx+ZOTvHcjhyy5Bx3pOpF9ha4m/ozKKww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hotGb/cpHPHBYA3t2CpeKHQKBe57qBmBt9Vg2uiDO7Rdgob+coQaKFiXeOeCwajkS uQYDhUFIwPsbSrwMQNXOcQkMh0f1vshlngrJrug05iTJNulTfCJbpf2u6ZMfQn8IEX BslWinzZeDEnxo2JlqQ2mqnMi54bLlAnHgvu7GC0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, nl6720 , Chao Yu , Gao Xiang Subject: [PATCH 4.19 085/101] erofs: derive atime instead of leaving it empty Date: Tue, 17 Nov 2020 14:05:52 +0100 Message-Id: <20201117122117.267551596@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122113.128215851@linuxfoundation.org> References: <20201117122113.128215851@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gao Xiang commit d3938ee23e97bfcac2e0eb6b356875da73d700df upstream. 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. Link: https://lore.kernel.org/r/20201031195102.21221-1-hsiangkao@aol.com [ Gao Xiang: It'd be better to backport for user-friendly concern. ] Fixes: 431339ba9042 ("staging: erofs: add inode operations") Cc: stable # 4.19+ Reported-by: nl6720 Reviewed-by: Chao Yu [ Gao Xiang: Manually backport to 4.19.y due to trivial conflicts. ] Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/inode.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -53,11 +53,9 @@ static int read_inode(struct inode *inod i_gid_write(inode, le32_to_cpu(v2->i_gid)); set_nlink(inode, le32_to_cpu(v2->i_nlink)); - /* ns timestamp */ - inode->i_mtime.tv_sec = inode->i_ctime.tv_sec = - le64_to_cpu(v2->i_ctime); - inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = - le32_to_cpu(v2->i_ctime_nsec); + /* extended inode has its own timestamp */ + inode->i_ctime.tv_sec = le64_to_cpu(v2->i_ctime); + inode->i_ctime.tv_nsec = le32_to_cpu(v2->i_ctime_nsec); inode->i_size = le64_to_cpu(v2->i_size); } else if (__inode_version(advise) == EROFS_INODE_LAYOUT_V1) { @@ -83,11 +81,9 @@ static int read_inode(struct inode *inod i_gid_write(inode, le16_to_cpu(v1->i_gid)); set_nlink(inode, le16_to_cpu(v1->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(v1->i_size); } else { @@ -97,6 +93,11 @@ static int read_inode(struct inode *inod return -EIO; } + 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; + /* measure inode.i_blocks as the generic filesystem */ inode->i_blocks = ((inode->i_size - 1) >> 9) + 1; return 0;