From patchwork Tue Jun 19 15:59:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 931691 X-Patchwork-Delegate: dwmw2@infradead.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pbUSptBp"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 419CMt5QPXz9s37 for ; Wed, 20 Jun 2018 01:59:54 +1000 (AEST) 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=2UhlSr9Z/+SrEmYx2u5MAeNFQwvog727/sLlAiopy8Q=; b=pbU SptBpmfM/EapP8wIK9UH+Q1m7gM7iPqQsc5Lva/DvnIvdAowwdlBBNLgl6SwZSUp1v8ZMEuW7ryiK NOCgit3pOZOY0CJ59oZ17Vbcll9m3fXU/LH4ce5c1NoJHVKzmcg1SNcHDd8ojkY/LdOIWiCNUpuRF bgBhi/LKwC6zqhEjZ3vahnXQHn/Pp6YME2wg8yZiJSK+fN+4elH20gfKAKwSzmoykksEFObAV5qTr /JXgIqQDx5EknDd4JPHb8z43qopHon52dIY9CRZMw4T2r6ZuvD70e5N4tY6dlIdizwRihP7LuGXtF 4KV8Cidr44mOUMNW+K2aX4hcZhrc+oA==; 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 1fVJ2p-00015i-KT; Tue, 19 Jun 2018 15:59:47 +0000 Received: from mout.kundenserver.de ([212.227.17.13]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVJ2l-00013Y-Ap for linux-mtd@lists.infradead.org; Tue, 19 Jun 2018 15:59:45 +0000 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0Mbb9R-1fnntS12Ll-00IyXi; Tue, 19 Jun 2018 17:59:27 +0200 From: Arnd Bergmann To: David Woodhouse Subject: [PATCH 1/2] jffs2: use 64-bit intermediate timestamps Date: Tue, 19 Jun 2018 17:59:03 +0200 Message-Id: <20180619155925.4107498-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:eeKxuE4Qe5q1IB2NdpY1z+HTlGBDbAjRgdgsDvvYmIEMpgX9QDZ wXu2XXZrO2V4GzipYC7/avsKP1vgIYgtugK/7TPrCcwmOvyVT5qTtmF1V2n3hHHWNJ5+IgP BA6kgCBNBBZNnstEvRtBY94yJRO2CrrCXdmh7Ophr/Ii1AF2JyJ76BLZwJMS982/hCiPs8C w6WAT/EiJNquyVaSPnF7A== X-UI-Out-Filterresults: notjunk:1; V01:K0:WnXYo3caGrA=:pRS4FbaEyswuGg+QMEXrfO 01PkDgyO+Au3G9hOtySEnHQPPAOSi+W5ZbQ6ix5pAyy5Rv8QKGzz5V1fP+3Z/jDkZO1b1f3c3 J8fTzaL8RmgDaD5gbE4YZ9TqEyDxSySXKK7EhGhve3mk+u+SrqQNJ+QzxuSv6d4KM5+MntCuH bbFU3lqpE6CLajXg0CKaQIA5Gz2KGTkXxFwBUffYvM04SYurD2o+bX2/ff3mctsuM494fW7as Dg4OJAWutcy9G5y1ccU0WArtt2gk4LBuuRo0AWp4VZB3sRqUgwwWFAu07x2fp2RCMJqgQLQws 7S3kPccz2p8W/9zc/3KjKSVmAXM4bg1FJlJcl+o4d62Bq1k079VhRKDGo9AACmoISEviHV93v DVOIey7a5FhlFbfc0S9XOrBgPScBaJJy0u/AHaumevYyoV3C0Vgk8KtJLnVR1htE/64ps0gvT Wweqmk/VkQhXTz4cUjWQqbRhzB4ls1A6rRoTI7+2qvfRhMXhzQR0FT70SbtTUwPGC2hYdeROo U5aHJJGVLTnbTWwMBpStzXGdr+Py1x6otYO9cZ9XH6wId0FC9sQQF6BDbw2iEJgOkOP9zbbDs vnKNQHeqty0nWwWsu5mZCjAmX/OcZIbNEddgO3UlGQyLcZgXwpO8W1xbjxAe4aiYs6t9h7jt0 fd7XoNX9ZtvKeYiBJez8sdAaFV/C4agNs0ENzJZJ+YDS9nIOYGS6EdkaYoC//3/VTY2M= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180619_085943_688322_2E98B9E6 X-CRM114-Status: GOOD ( 15.11 ) 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.13 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: Andreas Dilger , Arnd Bergmann , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, Deepa Dinamani , Al Viro MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.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 --- 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(-) 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 Tue Jun 19 15:59:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 931692 X-Patchwork-Delegate: dwmw2@infradead.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="clG8+Fve"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 419CNN2ZTRz9s3R for ; Wed, 20 Jun 2018 02:00:20 +1000 (AEST) 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=clG8+FveCdzw4CCKhvmc761MKG HdqzXO3OSfwS8IuhPf/fSY/vJpH3jcpCAr94fV9feinspth0mrZL25pGWB5QtFiODJ90G8mA3Xbeq o7yZXzakVMZOrw7+lY49WaUXK37BiKouHSnJcWKp5P/1xldx3e4/LRDu6M6zRirusVA7VQj/b6T25 adTq0gzbsGKqkQsWerp2xAQhb08xxpxDTVCaQaCoU3pihGxOtiiNvVJuXDB7VtAXhGjQgnJyYpnyY s84pP8Ogd0Hj4AbbwL1HaCSrGeuLK1h5tx2XrcBaRJwGp42bFtoMvNToaUMJdeLF8u9bcX82KEfz+ Gxzg7Zxg==; 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 1fVJ3B-0001Sm-TW; Tue, 19 Jun 2018 16:00:09 +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 1fVJ2m-00013a-Qp for linux-mtd@lists.infradead.org; Tue, 19 Jun 2018 15:59:47 +0000 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MPrBi-1faH7m1TJC-0052b7; Tue, 19 Jun 2018 17:59:32 +0200 From: Arnd Bergmann To: David Woodhouse Subject: [PATCH 2/2] jffs2: use unsigned 32-bit timstamps consistently Date: Tue, 19 Jun 2018 17:59:04 +0200 Message-Id: <20180619155925.4107498-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180619155925.4107498-1-arnd@arndb.de> References: <20180619155925.4107498-1-arnd@arndb.de> X-Provags-ID: V03:K1:In2LSs2gpZ6AWdNNz8wswR1amcrtt1fvcMaLH4XrQYVXOTjCte5 W0zgt3tCHO2KTSW6qtCP6bZXGM9gX1a2EKA8ViknC2A3TZSf+90vpg3slG9PLATLCN8ZNSN VRA54wjzBWp+fAY7OExnsjqXlVymv55BhjQ3nTHxhWj4fyH50jOTIjZGOC8RFtIqfeisk60 BAlQQKHVATAM4wECPv0bg== X-UI-Out-Filterresults: notjunk:1; V01:K0:qB1l/bvs9X0=:nFq66kTEoAr7Pv3OGwTMGc AtJzjyBkBLLG6qTI/vPrhC+0odb82wOdT65HJ2gsJ+PqoD8WJF7WRXyRsPmDDK+l3UYXYFyB9 X6sJgPvfLdvzLgbjudavfxeBb1MFniBAWqz53ePxTX7Fd1tJI186+wZTmychcIlAo9mwzEwUJ PqNwOiW+FfFPjwmeAXnD2OepGfXXHKK4I9J3k1c/T+fxoUGbqJ8qbMdbsON3UFiDUusyZD6Qg o9Ua1ot96uKncvI0994XVU9bsbuhNRVHh4J/N6AFRER/w5E6dANWp4FqgGUmt5QEZKikMfBTr /aQS/bIBcnS/UN0v7E7dmYsvd7Ozal4E7Xhmb7sRSJHHrsJTyM9uJeFmBM2URvm1UEfhxgsWY naLUf0vPRwtPcEypwjBOhAqmMC5D+bUeVS42DVxAPlnXDxdLyjN1PTMrG7QOcp1wWFOf10szf k2/9kB3BIkn/s/zGJ/m4F6tBTGg78ssTaLeLa79g8lm410J67wOjDmzIwiBWsi+xaDwZAEHg0 6tvBBRg8w+vLgCPmkPB8ElxV/Qg/Cc25SQ4TmQODQyuWOdrMp4G27mYyUiu3FEkC1SLaA40gj XoxAIfKJ5cZFsB8GMqZHsi3CifqvEqLQziP8etMZwbxz7O7XkDeIoboj7NcUu1/UJ1RFk8YnV 2Db1UDFkzCpumh3+pSEV6ablVQC+ChNil26U77DWt7aaRo0A+HiwJL2kuI4qxCbgcq6Q= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180619_085945_182810_684CAC4C X-CRM114-Status: GOOD ( 10.90 ) 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: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Arnd Bergmann MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.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(-) 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); \