From patchwork Fri Jul 13 14:47:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 141901 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp894347ljj; Fri, 13 Jul 2018 07:48:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe27E4jBUFL9x6Z9toi2URB/MFm/S4r19otlAjh3XQEOwUuWU7BCiemjjeMY3aYgryipRno X-Received: by 2002:a63:686:: with SMTP id 128-v6mr6340856pgg.338.1531493295681; Fri, 13 Jul 2018 07:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531493295; cv=none; d=google.com; s=arc-20160816; b=q8GwglD7i6pyXFv0web5k63nOXrSaVDnWuBNvs1CHJRkh+MtwHYm70bkJ9gfMDoZOU 72IiEE1l50rxxPOJdx4L/woEhi+D69WEPXFy05WsWVA8hJlnCKcq7LJEHJxfVN8fKBjh t4po+Leyrl8IJ7B1Q9G7dcxRJEkJevFsUftKmj9Lmd52Cb22pJGCt3qLEDpjsIJwlqhy FXjr+XjWwKfaszTy75o5sa4+t47f4L1LQsS5SF9Ppvih0j17tcjgQF3ideIJqvo2YbjO VekIZZEsXeVwpSrHXtLNcOeBuednupVJm3My6k//53UPI/b2fdWarf2jNYykQfR2Bc3d i3Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:message-id:date:subject:to:from:dkim-signature :arc-authentication-results; bh=71Be+Rn1OWzaGUpDZn665L5vPo/M73WfSzewuGz5afM=; b=Kx+sEx12RyMprhtS1KPeFA+hIC2Q01yempRzisiRa5oFeCAPA+p1y7sqk98FxBNNda SIjS8Jxae0xJ/h7oSQ2oWnzpZJhWUlZFoQkwFBmN6aNvLsVFdaTOvnn3A3TU7Y1fSLBN kVvrb/z3IIU97ep4NIv/VYLh+96Qb52XlgMOo9Q+2yRqM6So91ysgzIl0xacSI6QGuv7 NdIanreGj8uZrerWhl1KrMaNsL94O64pHC3qxdI6VgX8yX4g3WCAwb7pP81/s7AzgB2m pxM/erATrpkJ6g3xOZLarGs41zIn+cGs4/aXEkPYKvjimTtFbeHh8mmXfYyrmvjs7/I6 kvXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=poKDjXP4; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 38-v6si24004358pln.92.2018.07.13.07.48.15 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Jul 2018 07:48:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=poKDjXP4; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=71Be+Rn1OWzaGUpDZn665L5vPo/M73WfSzewuGz5afM=; b=poK DjXP45khP/mq/R1emXvindSblqEikWNQQ6R4evgXBnzpDQq781y0an2VK3Cxj9cG41FFdsMfRN/Oj RoVSNT6cl0paPiBaYCZci390oNj/0Xv205pi1Us4LAA9/7LA69UhE33mlyXPG4TUz2fb+f9HIyzhC Ov+gZ85hPmIwURM8usD8LLXxLnO017Ruj09/X4X/ERkGZGsg3PFukSHNZgQvj9Qd3MeVgx3Vh1CiT ubRuJT+FCKsVT7x0sIGJn+Po8gB80hQbQ7dd2Wv9wS3UG+1f+D0EmIX5EcatEeEgJzmhFBM0mmKqs XrtAwI8tGxa5k4GiBWPwCBh5chmMiqQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fdzMc-0008LT-ON; Fri, 13 Jul 2018 14:48:06 +0000 Received: from mout.kundenserver.de ([217.72.192.73]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fdzMZ-0008Ji-LZ for linux-mtd@lists.infradead.org; Fri, 13 Jul 2018 14:48:05 +0000 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LkPhj-1gBf5P2Y8Z-00cNRS; Fri, 13 Jul 2018 16:47:44 +0200 From: Arnd Bergmann To: Andrew Morton , Alexander Viro Subject: [PATCH 1/2] [RESEND] jffs2: use 64-bit intermediate timestamps Date: Fri, 13 Jul 2018 16:47:16 +0200 Message-Id: <20180713144739.3150217-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:bquNiAXXF6BO0bhvZwL7Y1JgIBk2VZhLKfL/YCepyWF/qlIGrk7 I8a5WmTIYWSGAdWCjdW+4yTGcV6MlS3UyJqJXKW3E7Ml1BpO8WYhQfUfUUENc4ZoY0P1VQL yi7V2mjQHiumcyr8Cc6F6rQgm+gHYv20F2EFs1qhNvMVoFRV5XrB0lFTjAh26Xl7i6GapTx YM9BjV0IMsaYI3zR1Nb1A== X-UI-Out-Filterresults: notjunk:1; V01:K0:Z2ux5Bt3bE4=:AREo9nQ+8r38kk1Agtyej2 lPgnFqyXWFlNOXHqBX1gDpOEOuRyCoG3bZOq4X0qTZ1zAJpkhbo3C5xQALmLhgnf0kmPCqwdk 7HEaKhoxGItNsVHmeGY01VvRVj+MnFmpZVO4b3cUOHPmDffbaU0/lvBUuHUfo7h6p28aEQ36T y8O2xaHkj/otk43vxkBbLXsYgDG6kCQ0pcv6ZDtPS4nKT1O4VRgkC35ZpJLjuhGk+hBCGtgmI ESb+BqQZnioNjl8qjMY29IxTU+Ml8PfKnf02gzDZ46khhmjT7gVJsw8hqgDKH7xF/7hEkqr+t NQdRQ+UrIh/aSrOtQYz1DGje5N0khi/z+h3vmO5+Kt5rwxS5ZZYsCjHsWLmWl0xMemit7kd91 hqzg9liqC1SY42NL9yF35RzHbdUbxcoE98bCYpl7hixmaV0T1cbYyhUCC/HXKTj4aA2E14/o6 ZLhHDaStDTcHUQMMp9VvVxxp1c/Sh8PmhHToTVGoCGTHDtD21LxXg1emfJy473DvhxlYNVVL+ /CRbRlP/Swqk3b7pyioilXjGMWYt071/1jGjqVBeozo0lrBA2bULEHSxxGZ4lLolaYtn9XbGS kjhWPZslG5e2tO89BozUpfSoREUKsQd9Isif4/hqFmIWOLqV8E4EcBNGvLWRQXpE0nDNFBClD 2qaoN2gRpRTusOWLneSONUy8xj5MEFpXBKAq8MIhNKHtX9XNcnsKVTlenZ9jcscGIkyA= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180713_074804_005041_3C9E798A X-CRM114-Status: GOOD ( 15.92 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [217.72.192.73 listed in list.dnswl.org] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Kara , Arnd Bergmann , y2038@lists.linaro.org, Richard Weinberger , linux-kernel@vger.kernel.org, David Howells , linux-mtd@lists.infradead.org, Deepa Dinamani , linux-fsdevel@vger.kernel.org, David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org The VFS now uses timespec64 timestamps consistently, but jffs2 still converts them to 32-bit numbers on the storage medium. As the helper functions for the conversion (get_seconds() and timespec_to_timespec64()) are now deprecated, let's change them over to the more modern replacements. This keeps the traditional interpretation of those values, where the on-disk 32-bit numbers are taken to be negative numbers, i.e. dates before 1970, on 32-bit machines, but future numbers past 2038 on 64-bit machines. Signed-off-by: Arnd Bergmann --- I originally sent these two patches on Jun 19, but got no reply aside from a harmless sparse warning reported by the kbuild test robot. Looking at the git history for jffs2, it seems that David Woodhouse hasn't applied any patches for over two years, so I suppose he's not taking these either. Al or Andrew, could you pick these up instead? --- fs/jffs2/dir.c | 32 ++++++++++++++++---------------- fs/jffs2/file.c | 6 +++--- fs/jffs2/fs.c | 12 ++++++------ fs/jffs2/os-linux.h | 3 ++- 4 files changed, 27 insertions(+), 26 deletions(-) -- 2.9.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c index b2944f9218f7..f20cff1194bb 100644 --- a/fs/jffs2/dir.c +++ b/fs/jffs2/dir.c @@ -201,7 +201,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry, if (ret) goto fail; - dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(je32_to_cpu(ri->ctime))); + dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(ri->ctime)); jffs2_free_raw_inode(ri); @@ -227,14 +227,14 @@ static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry) struct jffs2_inode_info *dir_f = JFFS2_INODE_INFO(dir_i); struct jffs2_inode_info *dead_f = JFFS2_INODE_INFO(d_inode(dentry)); int ret; - uint32_t now = get_seconds(); + uint32_t now = JFFS2_NOW(); ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, dentry->d_name.len, dead_f, now); if (dead_f->inocache) set_nlink(d_inode(dentry), dead_f->inocache->pino_nlink); if (!ret) - dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(now)); + dir_i->i_mtime = dir_i->i_ctime = ITIME(now); return ret; } /***********************************************************************/ @@ -260,7 +260,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de type = (d_inode(old_dentry)->i_mode & S_IFMT) >> 12; if (!type) type = DT_REG; - now = get_seconds(); + now = JFFS2_NOW(); ret = jffs2_do_link(c, dir_f, f->inocache->ino, type, dentry->d_name.name, dentry->d_name.len, now); if (!ret) { @@ -268,7 +268,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de set_nlink(d_inode(old_dentry), ++f->inocache->pino_nlink); mutex_unlock(&f->sem); d_instantiate(dentry, d_inode(old_dentry)); - dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(now)); + dir_i->i_mtime = dir_i->i_ctime = ITIME(now); ihold(d_inode(old_dentry)); } return ret; @@ -400,7 +400,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char rd->pino = cpu_to_je32(dir_i->i_ino); rd->version = cpu_to_je32(++dir_f->highest_version); rd->ino = cpu_to_je32(inode->i_ino); - rd->mctime = cpu_to_je32(get_seconds()); + rd->mctime = cpu_to_je32(JFFS2_NOW()); rd->nsize = namelen; rd->type = DT_LNK; rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); @@ -418,7 +418,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char goto fail; } - dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(je32_to_cpu(rd->mctime))); + dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime)); jffs2_free_raw_dirent(rd); @@ -543,7 +543,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, umode_t mode rd->pino = cpu_to_je32(dir_i->i_ino); rd->version = cpu_to_je32(++dir_f->highest_version); rd->ino = cpu_to_je32(inode->i_ino); - rd->mctime = cpu_to_je32(get_seconds()); + rd->mctime = cpu_to_je32(JFFS2_NOW()); rd->nsize = namelen; rd->type = DT_DIR; rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8)); @@ -561,7 +561,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, umode_t mode goto fail; } - dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(je32_to_cpu(rd->mctime))); + dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime)); inc_nlink(dir_i); jffs2_free_raw_dirent(rd); @@ -588,7 +588,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry) struct jffs2_inode_info *f = JFFS2_INODE_INFO(d_inode(dentry)); struct jffs2_full_dirent *fd; int ret; - uint32_t now = get_seconds(); + uint32_t now = JFFS2_NOW(); for (fd = f->dents ; fd; fd = fd->next) { if (fd->ino) @@ -598,7 +598,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry) ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name, dentry->d_name.len, f, now); if (!ret) { - dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(now)); + dir_i->i_mtime = dir_i->i_ctime = ITIME(now); clear_nlink(d_inode(dentry)); drop_nlink(dir_i); } @@ -712,7 +712,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode rd->pino = cpu_to_je32(dir_i->i_ino); rd->version = cpu_to_je32(++dir_f->highest_version); rd->ino = cpu_to_je32(inode->i_ino); - rd->mctime = cpu_to_je32(get_seconds()); + rd->mctime = cpu_to_je32(JFFS2_NOW()); rd->nsize = namelen; /* XXX: This is ugly. */ @@ -733,7 +733,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode goto fail; } - dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(je32_to_cpu(rd->mctime))); + dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime)); jffs2_free_raw_dirent(rd); @@ -797,7 +797,7 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, type = (d_inode(old_dentry)->i_mode & S_IFMT) >> 12; if (!type) type = DT_REG; - now = get_seconds(); + now = JFFS2_NOW(); ret = jffs2_do_link(c, JFFS2_INODE_INFO(new_dir_i), d_inode(old_dentry)->i_ino, type, new_dentry->d_name.name, new_dentry->d_name.len, now); @@ -853,14 +853,14 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry, * caller won't do it on its own since we are returning an error. */ d_invalidate(new_dentry); - new_dir_i->i_mtime = new_dir_i->i_ctime = timespec_to_timespec64(ITIME(now)); + new_dir_i->i_mtime = new_dir_i->i_ctime = ITIME(now); return ret; } if (d_is_dir(old_dentry)) drop_nlink(old_dir_i); - new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = timespec_to_timespec64(ITIME(now)); + new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = ITIME(now); return 0; } diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c index 481afd4c2e1a..7d8654a1472e 100644 --- a/fs/jffs2/file.c +++ b/fs/jffs2/file.c @@ -175,7 +175,7 @@ static int jffs2_write_begin(struct file *filp, struct address_space *mapping, ri.uid = cpu_to_je16(i_uid_read(inode)); ri.gid = cpu_to_je16(i_gid_read(inode)); ri.isize = cpu_to_je32(max((uint32_t)inode->i_size, pageofs)); - ri.atime = ri.ctime = ri.mtime = cpu_to_je32(get_seconds()); + ri.atime = ri.ctime = ri.mtime = cpu_to_je32(JFFS2_NOW()); ri.offset = cpu_to_je32(inode->i_size); ri.dsize = cpu_to_je32(pageofs - inode->i_size); ri.csize = cpu_to_je32(0); @@ -283,7 +283,7 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping, ri->uid = cpu_to_je16(i_uid_read(inode)); ri->gid = cpu_to_je16(i_gid_read(inode)); ri->isize = cpu_to_je32((uint32_t)inode->i_size); - ri->atime = ri->ctime = ri->mtime = cpu_to_je32(get_seconds()); + ri->atime = ri->ctime = ri->mtime = cpu_to_je32(JFFS2_NOW()); /* In 2.4, it was already kmapped by generic_file_write(). Doesn't hurt to do it again. The alternative is ifdefs, which are ugly. */ @@ -308,7 +308,7 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping, inode->i_size = pos + writtenlen; inode->i_blocks = (inode->i_size + 511) >> 9; - inode->i_ctime = inode->i_mtime = timespec_to_timespec64(ITIME(je32_to_cpu(ri->ctime))); + inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime)); } } diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index 0ecfb8ea38cd..eab04eca95a3 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c @@ -146,9 +146,9 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr) return PTR_ERR(new_metadata); } /* It worked. Update the inode */ - inode->i_atime = timespec_to_timespec64(ITIME(je32_to_cpu(ri->atime))); - inode->i_ctime = timespec_to_timespec64(ITIME(je32_to_cpu(ri->ctime))); - inode->i_mtime = timespec_to_timespec64(ITIME(je32_to_cpu(ri->mtime))); + inode->i_atime = ITIME(je32_to_cpu(ri->atime)); + inode->i_ctime = ITIME(je32_to_cpu(ri->ctime)); + inode->i_mtime = ITIME(je32_to_cpu(ri->mtime)); inode->i_mode = jemode_to_cpu(ri->mode); i_uid_write(inode, je16_to_cpu(ri->uid)); i_gid_write(inode, je16_to_cpu(ri->gid)); @@ -280,9 +280,9 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino) i_uid_write(inode, je16_to_cpu(latest_node.uid)); i_gid_write(inode, je16_to_cpu(latest_node.gid)); inode->i_size = je32_to_cpu(latest_node.isize); - inode->i_atime = timespec_to_timespec64(ITIME(je32_to_cpu(latest_node.atime))); - inode->i_mtime = timespec_to_timespec64(ITIME(je32_to_cpu(latest_node.mtime))); - inode->i_ctime = timespec_to_timespec64(ITIME(je32_to_cpu(latest_node.ctime))); + inode->i_atime = ITIME(je32_to_cpu(latest_node.atime)); + inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime)); + inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime)); set_nlink(inode, f->inocache->pino_nlink); diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h index c2fbec19c616..acbe1f722f2d 100644 --- a/fs/jffs2/os-linux.h +++ b/fs/jffs2/os-linux.h @@ -31,7 +31,8 @@ struct kvec; #define JFFS2_F_I_GID(f) (i_gid_read(OFNI_EDONI_2SFFJ(f))) #define JFFS2_F_I_RDEV(f) (OFNI_EDONI_2SFFJ(f)->i_rdev) -#define ITIME(sec) ((struct timespec){sec, 0}) +#define ITIME(sec) ((struct timespec64){(int32_t)sec, 0}) +#define JFFS2_NOW() (ktime_get_real_seconds()) #define I_SEC(tv) ((tv).tv_sec) #define JFFS2_F_I_CTIME(f) (OFNI_EDONI_2SFFJ(f)->i_ctime.tv_sec) #define JFFS2_F_I_MTIME(f) (OFNI_EDONI_2SFFJ(f)->i_mtime.tv_sec) From patchwork Fri Jul 13 14:47:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 141902 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp894531ljj; Fri, 13 Jul 2018 07:48:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeyznOV1EjA9iB92Pa8zLYa656qnay6ExHHdWUmegF8R5+4/QTXN63Spp+k5PPl8ezOCIRC X-Received: by 2002:a65:5545:: with SMTP id t5-v6mr6405429pgr.157.1531493304193; Fri, 13 Jul 2018 07:48:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531493304; cv=none; d=google.com; s=arc-20160816; b=W7KLeWf8xQ7DL/0ZDMq7HA6M3GK7F0C/dU/ZpJeuTnZavZtEcHEjBNbMb0L6sCEQR+ AUFw2UcDsWx7c4sM6o7d37EuXYcepqtFHk3BUCva26mV9bWDvkFt/5BeCWsbiRYlhoZj ksISt/m15Nd3NqtwrnZWxb6CkdydhpWnwx8BSX8LR0xmE+Q9h1X7C6Pvc1PYlmzJ/6AC HxmaE4i1GttxTUkuAT7RJRmLyOzMe4aKQqDrhy2RjIXev91Wx6J73nUJ2fnZyre655Sk nEZJzawwqwYw9GnxkxutYDCNKVng7SRyZE9Y40mowMuzg9ODo6C2wSS5P8MBGa/mfQ2p /QXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:arc-authentication-results; bh=7+q8EPEMEyvuPAZ5vwlbhoEpNu/mi9aoHXLuboP7Tsw=; b=YZ9f7+CBSU9JGUA6T/K0SzTYTvXvD1WmX5HV1aYYNrpgJAo+4TUd4PVwIfnF5E69jk dAH4fy1V+PLtD+eOnm9EgyiZ0bj6D5LG+c1TQcx0GH/gVtGahP2c7kzb7cMnmP50t6fY s1KDYPXygce1xAkszDUdEEzQm4AQsdZHKnBORI2n0sX26Oq46cq3YPXUXsK1hGtovO2x rrQnA/1CKILVvsf6cq13R0wcoLKG4CCvG4UMzw/z3jz8m7no2a6mamP0509ZCH8WTeuy S4Vxoq5b2Zeg5XV6/PV+/ps7n1RaT/8XR9VmQcTxB8bg8z+hl4bh60K8bnyXVtnP/nv8 v2XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=Ascdt03Y; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 188-v6si6387214pfg.154.2018.07.13.07.48.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Jul 2018 07:48:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=Ascdt03Y; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7+q8EPEMEyvuPAZ5vwlbhoEpNu/mi9aoHXLuboP7Tsw=; b=Ascdt03YyC54gSCTGTW3E9OVm0 kaQxZrLqH8Cc1JJBoTdVW9dDhttMJonEC+0dccrmOxlSs8dv+qGd6jATnB3IeXAXY6KB8axgV7sNm nRNIP18DoNBqJ8qDqzZv9qUBcPmQS1BPv4vkbglbvIex95XYCgdLProCXyWTJQSVNHqrc6pyY2Cdy hPoD4VapizTRSvEL+2ogkD/zJJnBq2+P3Fx5tlu1wWOl9EDEd+xB9rlNOnyLHg2Ie1sJdOVi8dNrD MkYmQ+kwSg/xfCIMDvj29WaTWmhJHJdNMBigYAm0JIasAImxkk6iH2MUJ+lJdIqY8U6LdVAoPZieE xYgf2vuw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fdzMm-00006Z-RL; Fri, 13 Jul 2018 14:48:16 +0000 Received: from mout.kundenserver.de ([212.227.17.24]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fdzMc-0008Ju-7A for linux-mtd@lists.infradead.org; Fri, 13 Jul 2018 14:48:08 +0000 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0Lecog-1gPdih0E2A-00qQL9; Fri, 13 Jul 2018 16:47:53 +0200 From: Arnd Bergmann To: Andrew Morton , Alexander Viro Subject: [PATCH 2/2] [RESEND] jffs2: use unsigned 32-bit timstamps consistently Date: Fri, 13 Jul 2018 16:47:17 +0200 Message-Id: <20180713144739.3150217-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180713144739.3150217-1-arnd@arndb.de> References: <20180713144739.3150217-1-arnd@arndb.de> X-Provags-ID: V03:K1:/io4Z9LvC9PS8hE8ttxo0Nqb0WWyAlsTbMMvof4RvXGCkWzM/Uy 4OoVeFPdI9rdfCsYno5WZKpnd+Tm/fPl6JJj8wNDZ/7Zax04Wj228ifBlVxkAIMjagUSZXr JiSr/uELFvv1wRDF6/8vi4/PgNHwI8BfcxifwyEwLLKhxfetiVOPJl58y0sX/cmso8Du7Dh p4VjEuU8oCqWI8P5ZiyYQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:MFniaDVfd1Q=:qSUkUQk2mQxt45m2kdcCxa 6u3Y+FTXV06+0HErp75R/ZhdU3ZJL5yxiqEoO4aZJe51RoChZtFkJjSc2fXs/aN7CMRT4/sd0 6Qau3Vu3WFnTk4fmZJ6RligHtx7kcKWE9xRgzp3SyTjWID0xadrpp9gdA+1unPd3Lj0Z7RFRy HNVxdF5y6kDY1D3945IsAb01emyLsZ1rlhN9UEF043Pi33baF18cyrc0YX0yT//V3S6shxHiB Eep2GjBlLCffy4AP3ISrFISFL08XYc9MsS/uv+1eog7qelLCCASd3ePlNxE3w4SdeclER71// r5tZEVS4rpZIbRW6rDGTgybCs1pkL9iJHQnfj3BzQTOQL40uWmiirQesC3AbME1KoLGqmZT8l 6zfV47NxrCknNQb3WGV1UcLLCOQQUw9BJUT2VgN++kfqdYz1C9TpXOyDQj6HnH5tLmVg4dfXM 6waIum2/DhnsfubtYkHt7DZ+f52LqpA9TZZTZu/4dhWN0dmO/atF7ryHrnrIEe7YXbERkMqfF N2mxkEfuxGetu4Jsl2ds1zpAFojm4akacZtmprUFn0IuRjmHO/cWzDvlWB7HohkqYitmpK53h qO76tY/UtlYTYpQy7a/fjBXAkj2WMar/Plqb/eIWIsGIion9aWO0FD9ozYlvwEMdmtFXAe1CR npjR5Po0wk4DeFiO1ZJJ4vv19qYIyxPNtQ0a2BLRu1Zkl1FudW3EuhwJ583vDvSD/RNM= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180713_074806_564410_78FB36FC X-CRM114-Status: GOOD ( 11.66 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.17.24 listed in list.dnswl.org] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , y2038@lists.linaro.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Most users of jffs2 are 32-bit systems that traditionally only support timestamps using a 32-bit signed time_t, in the range from years 1902 to 2038. On 64-bit systems, jffs2 however interpreted the same timestamps as unsigned values, reading back negative times (before 1970) as times between 2038 and 2106. Now that Linux supports 64-bit inode timestamps even on 32-bit systems, let's use the second interpretation everywhere to allow jffs2 to be used on 32-bit systems beyond 2038 without a fundamental change to the inode format. This has a slight risk of regressions, when existing files with timestamps before 1970 are present in file system images and are now interpreted as future time stamps. I considered moving the wraparound point a bit, e.g. to 1960, in order to deal with timestamps that ended up on Dec 31, 1969 due to incorrect timezone handling. However, this would complicate the implementation unnecessarily, so I went with the simplest possible method of extending the timestamps. Writing files with timestamps before 1970 or after 2106 now results in those times being clamped in the file system. Signed-off-by: Arnd Bergmann --- fs/jffs2/os-linux.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) -- 2.9.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h index acbe1f722f2d..a2dbbb3f4c74 100644 --- a/fs/jffs2/os-linux.h +++ b/fs/jffs2/os-linux.h @@ -31,13 +31,13 @@ struct kvec; #define JFFS2_F_I_GID(f) (i_gid_read(OFNI_EDONI_2SFFJ(f))) #define JFFS2_F_I_RDEV(f) (OFNI_EDONI_2SFFJ(f)->i_rdev) -#define ITIME(sec) ((struct timespec64){(int32_t)sec, 0}) -#define JFFS2_NOW() (ktime_get_real_seconds()) -#define I_SEC(tv) ((tv).tv_sec) -#define JFFS2_F_I_CTIME(f) (OFNI_EDONI_2SFFJ(f)->i_ctime.tv_sec) -#define JFFS2_F_I_MTIME(f) (OFNI_EDONI_2SFFJ(f)->i_mtime.tv_sec) -#define JFFS2_F_I_ATIME(f) (OFNI_EDONI_2SFFJ(f)->i_atime.tv_sec) - +#define JFFS2_CLAMP_TIME(t) ((uint32_t)clamp_t(time64_t, (t), 0, U32_MAX)) +#define ITIME(sec) ((struct timespec64){sec, 0}) +#define JFFS2_NOW() JFFS2_CLAMP_TIME(ktime_get_real_seconds()) +#define I_SEC(tv) JFFS2_CLAMP_TIME((tv).tv_sec) +#define JFFS2_F_I_CTIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_ctime) +#define JFFS2_F_I_MTIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_mtime) +#define JFFS2_F_I_ATIME(f) I_SEC(OFNI_EDONI_2SFFJ(f)->i_atime) #define sleep_on_spinunlock(wq, s) \ do { \ DECLARE_WAITQUEUE(__wait, current); \