Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3608871imm; Mon, 15 Oct 2018 00:42:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV620O0UhCn7IY9pLMwoQ2a8p0B0TUHjDh9Wf8FDzbgijwBBeQZQZZyrFHr4RrFiuPPeNS0kz X-Received: by 2002:a63:6c84:: with SMTP id h126-v6mr15112926pgc.237.1539589336246; Mon, 15 Oct 2018 00:42:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539589336; cv=none; d=google.com; s=arc-20160816; b=0RuAJ85HxEIf6my4l3+zIMjfMPOADgxEAocfjtKQA+TJPszhU61/e1sYCAcEiIcSSS tAbH4yHsNzhERAIwv5eBA5P//plsJkkG7PG+8nMUXfqb5Mx4pmCZDwWF2zOeohLxOATh LM3QA7d3cUfeJx42IxsGNM0sPsYCv7waXsUD98iq4pvtC3KdU9aKsMwHp29pfnb0rnBg 7HamDM0ljDjYFTfdGUwhJ6hI8wOWn7jovubapnrTIq4deBniPSjjOjHBMj6IbH1fw0SD GwlRQEaaAuFCOzMTkF2NDd0exQq18ckAwmqWySlSQCWzjA5b8FiVgxA542Vdpf4KC0fL 5ZRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=fBJ66krlGrouxCseStyvb7DrCNGKzVd4Zpba9z9iMy0=; b=bELSqooDX2kAfyib0+AxFEno/LwF/YfJ3Oh2DDKTniBrV+DTfSP6S8FU/+BQamDmA6 IEKKO5W2io9lSYB96HItw2rEkD0e/OIJ6W1xi/f1g7kdh30zrVOEPrzjNzNHjcxycX/k DyWO6yhwGFmzP5l9amyUKRlaIhw1z8unFekKSaOemI1oCBRBpNneG+SCGzPKap1F+ZyY YQy1liW4IM4KbLOrbfVzTWeDClK83a6IhQ3tS/XMhZblogfCVsKTH6ei9YV5QiSEiaAP iC5O+3KpQ/U0XcZ4925s/IyXp6vyPyFWxEG+ifG1oNFkyfuImezrKREcIkz9xHVlmUcE VJLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2-v6si9933335pgc.570.2018.10.15.00.42.01; Mon, 15 Oct 2018 00:42:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726638AbeJOPYZ (ORCPT + 99 others); Mon, 15 Oct 2018 11:24:25 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:43313 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726098AbeJOPYZ (ORCPT ); Mon, 15 Oct 2018 11:24:25 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 90C521CDC8C3B; Mon, 15 Oct 2018 15:40:17 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.399.0; Mon, 15 Oct 2018 15:40:10 +0800 From: ZhuangShengen To: , , CC: , , , , Subject: [PATCH] jffs2: modify the mtime and ctime when truncate file Date: Mon, 15 Oct 2018 15:42:01 +0800 Message-ID: <1539589321-103638-1-git-send-email-zhuangshengen@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The syscall truncate don't modify the mtime or ctime of the file. The reason is that it only check the ATTR_MTIME or ATTR_CTIME flag in function jffs2_do_setattr,and the syscall truncate has not set these two flags in VFS layer. Fix the problem by checking the ATTR_SIZE flag when modify the mtime or ctime of the file in jffs2_do_setattr. This fix solve the same problem with commit 3972f2603d85 ("btrfs: update timestamps on truncate()") Signed-off-by: ZhuangShengen --- fs/jffs2/fs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index eab04ec..98261f6 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c @@ -113,8 +113,10 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) ri->isize = cpu_to_je32((ivalid & ATTR_SIZE)?iattr->ia_size:inode->i_size); ri->atime = cpu_to_je32(I_SEC((ivalid & ATTR_ATIME)?iattr->ia_atime:inode->i_atime)); - ri->mtime = cpu_to_je32(I_SEC((ivalid & ATTR_MTIME)?iattr->ia_mtime:inode->i_mtime)); - ri->ctime = cpu_to_je32(I_SEC((ivalid & ATTR_CTIME)?iattr->ia_ctime:inode->i_ctime)); + ri->mtime = cpu_to_je32(I_SEC((ivalid & (ATTR_SIZE | ATTR_MTIME)) ? + iattr->ia_mtime:inode->i_mtime)); + ri->ctime = cpu_to_je32(I_SEC((ivalid & (ATTR_SIZE | ATTR_CTIME)) ? + iattr->ia_ctime:inode->i_ctime)); ri->offset = cpu_to_je32(0); ri->csize = ri->dsize = cpu_to_je32(mdatalen); -- 2.7.4