From patchwork Sun Aug 18 16:57:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099703 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6B2CF112C for ; Sun, 18 Aug 2019 16:59:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 562C128437 for ; Sun, 18 Aug 2019 16:59:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4898A2847E; Sun, 18 Aug 2019 16:59:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 218A728437 for ; Sun, 18 Aug 2019 16:59:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726882AbfHRQ7c (ORCPT ); Sun, 18 Aug 2019 12:59:32 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:32998 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbfHRQ7c (ORCPT ); Sun, 18 Aug 2019 12:59:32 -0400 Received: by mail-pf1-f196.google.com with SMTP id g2so5747950pfq.0; Sun, 18 Aug 2019 09:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=shWsRWzM35+5Yos+RU2UQmsto+H1BQo5byPAe0Akm68=; b=B3e7PTxrj2DaLWUCNuBoKtm+rwj4kJpzRtXfqb3S6l/65rA1d5fYVCs1Yb1CWqd+kD ZMmybglSMVjQQxS3iAUr6P+Zyx1uhPt4LSAIfhT76d3Sc7FuuTmfZqa3i0y3OqPKrUqX JaqwA6CAcS1tJTfKarwN1LwzB3hHNBUc5jhC8EhBi8WzHX1xRl3WW7Q2c30jCdXLmWiv FTdhcusPbhAcZP9xevzUawo7zWtNXs0rC0vkYntwCrEY+q1PfwI3DMWvkoXF4UEmPsaM Ak6/fh7YLisbbue03omVbf7CxA1bVejQseOGWut9dH9UoK8g7u5QHppD2fu8FLmjvEho E+mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=shWsRWzM35+5Yos+RU2UQmsto+H1BQo5byPAe0Akm68=; b=nwpnHs295A+uTXlMGmWVOPvcvInNtfkBM71hCwP0CTrm1BVAkTDd9Yw/+CVU/vebJ+ OQJ4j44QjeecgEdlTaOGyYGS1rZLnKBSkoFgZYFGe2G7f1XxEYViaBtM57uGOUYSuVe9 cU6Fb3eAbWCLI6yhzQo2r/4060/7N+LVdqy4Nup0lvFyeh02HP0r9noyZGIPkRHUcOmn D89ejGvdtfxOHovJtm8iNqZA7nC65KQ3LFBM4SANQALvOxyNTiytdOPRes0nSvu0y9yG 6WwUNaYS9qAcVYndPFKylUgQuscHL6bQRf76iRUrfIuHknVtOrrcZdeCqWF6oWtvbPBc ZTsA== X-Gm-Message-State: APjAAAXvQ9ImytvHrN3P+lzsdlZfmXP0I2RFAaibBpZgjZygHNOpPiqh CnrgZjWUhHCcH61HmbHjk0A38A39 X-Google-Smtp-Source: APXvYqy+kjZ2DvdO7w2xvC04IWsdu978wsibBtbY4J767+g61DztlihAtNZRrV5Qn3136FKPvXwXyQ== X-Received: by 2002:a62:2aca:: with SMTP id q193mr20674597pfq.209.1566147571763; Sun, 18 Aug 2019 09:59:31 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:31 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de Subject: [PATCH v8 01/20] vfs: Add file timestamp range support Date: Sun, 18 Aug 2019 09:57:58 -0700 Message-Id: <20190818165817.32634-2-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add fields to the superblock to track the min and max timestamps supported by filesystems. Initially, when a superblock is allocated, initialize it to the max and min values the fields can hold. Individual filesystems override these to match their actual limits. Pseudo filesystems are assumed to always support the min and max allowable values for the fields. Signed-off-by: Deepa Dinamani --- fs/super.c | 2 ++ include/linux/fs.h | 3 +++ include/linux/time64.h | 2 ++ 3 files changed, 7 insertions(+) diff --git a/fs/super.c b/fs/super.c index 36cb5aaf6f08..620c1911bb36 100644 --- a/fs/super.c +++ b/fs/super.c @@ -258,6 +258,8 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, s->s_maxbytes = MAX_NON_LFS; s->s_op = &default_op; s->s_time_gran = 1000000000; + s->s_time_min = TIME64_MIN; + s->s_time_max = TIME64_MAX; s->cleancache_poolid = CLEANCACHE_NO_POOL; s->s_shrink.seeks = DEFAULT_SEEKS; diff --git a/include/linux/fs.h b/include/linux/fs.h index d97d74f35eb3..93c440d22547 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1463,6 +1463,9 @@ struct super_block { /* Granularity of c/m/atime in ns (cannot be worse than a second) */ u32 s_time_gran; + /* Time limits for c/m/atime in seconds */ + time64_t s_time_min; + time64_t s_time_max; #ifdef CONFIG_FSNOTIFY __u32 s_fsnotify_mask; struct fsnotify_mark_connector __rcu *s_fsnotify_marks; diff --git a/include/linux/time64.h b/include/linux/time64.h index a620ee610b9f..19125489ae94 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -30,6 +30,8 @@ struct itimerspec64 { /* Located here for timespec[64]_valid_strict */ #define TIME64_MAX ((s64)~((u64)1 << 63)) +#define TIME64_MIN (-TIME64_MAX - 1) + #define KTIME_MAX ((s64)~((u64)1 << 63)) #define KTIME_SEC_MAX (KTIME_MAX / NSEC_PER_SEC) From patchwork Sun Aug 18 16:57:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 589E814F7 for ; Sun, 18 Aug 2019 16:59:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40E0228437 for ; Sun, 18 Aug 2019 16:59:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 328CA2847E; Sun, 18 Aug 2019 16:59:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C226D28437 for ; Sun, 18 Aug 2019 16:59:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726964AbfHRQ7g (ORCPT ); Sun, 18 Aug 2019 12:59:36 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43721 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbfHRQ7f (ORCPT ); Sun, 18 Aug 2019 12:59:35 -0400 Received: by mail-pf1-f194.google.com with SMTP id v12so5713554pfn.10; Sun, 18 Aug 2019 09:59:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=X4S1jP6JxbrAY5LAlhL0l2T5ZB0TobcoF1e+jYIC6JQ=; b=L8MGPefZg6eIgQo4yOxgeyqLU8H+1bvdtduSoRT5Ec2z+4+IkPoB9EHXeBRYFIz9fR XWv0lyov3QoGlAZ6lVt8haaPGWu56dtc1qPy3rhA8hwEfr4HlTwSMXPGp1/eG3UrBUd5 ls4STrMCAoaRoAOm3kdYO8zwZAjpelo6sx/uyGaSjkpMJaYMI6G13Vg7lQqgxbFB38jX 8+O0jwzSqLRCP8GVg968HRV7QCps92kz3HwdDvIdNtj/kXW+I71kRsFflDSFAaOpmEWY sedUHq0l2PYiWKKG0hw/uy+V+IivljpG5l1WsEuouKcxrAhyhyYETbZ2TiMIe3QiHrk6 cICA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=X4S1jP6JxbrAY5LAlhL0l2T5ZB0TobcoF1e+jYIC6JQ=; b=g5n9BnCUn577+peEhJJ4rLTMOywysyONrg2WSSyExgV5YkfkQGZWDzDw5l+aor0OKq 4f2RB9m9gP1AtXPmunXaY0KT0iZNVP8PjydrJdjNeUi4djtRsV/nbhKrCOg5dLHLLvnP IM8g4BhUaB8hG4hUl0lEj4Yis/jYHJIQJ0ajh9ChnRIIxCOtbg3JpzlO0HkypcMgEKs5 iDhXnAP69xUarLdF2B+Mu8BJEg25qnVT22MEHt4mBEIB2U0TBHzviTgZAagLo8kPLdrD OPFLkPSEZz8Wuw3xQXcsgiOinIZ1zzCUkRy0JAdWEaANx/6LAmF0LfZHR1IUta6F0ADL bndg== X-Gm-Message-State: APjAAAUwaX3ZKuiFJ+vD3So6uMVtofhd5dBlhyMFI/2kBvmk9mHXdrzN wPoRlWkiEzHz6PvdV60nMpuEenzE X-Google-Smtp-Source: APXvYqxENSxuYopBbdzr3b3DEoqjxPe1GP+G2AQGOYdXsR8ZldanKgFojrfRhtv58BmKEbttL2c/GQ== X-Received: by 2002:a63:3dcd:: with SMTP id k196mr16606794pga.45.1566147574845; Sun, 18 Aug 2019 09:59:34 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:34 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de Subject: [PATCH v8 02/20] vfs: Add timestamp_truncate() api Date: Sun, 18 Aug 2019 09:57:59 -0700 Message-Id: <20190818165817.32634-3-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP timespec_trunc() function is used to truncate a filesystem timestamp to the right granularity. But, the function does not clamp tv_sec part of the timestamps according to the filesystem timestamp limits. The replacement api: timestamp_truncate() also alters the signature of the function to accommodate filesystem timestamp clamping according to flesystem limits. Note that the tv_nsec part is set to 0 if tv_sec is not within the range supported for the filesystem. Signed-off-by: Deepa Dinamani --- fs/inode.c | 33 ++++++++++++++++++++++++++++++++- include/linux/fs.h | 2 ++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/fs/inode.c b/fs/inode.c index ef33fdf0105f..fef457a42882 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -2169,6 +2169,37 @@ struct timespec64 timespec64_trunc(struct timespec64 t, unsigned gran) } EXPORT_SYMBOL(timespec64_trunc); +/** + * timestamp_truncate - Truncate timespec to a granularity + * @t: Timespec + * @inode: inode being updated + * + * Truncate a timespec to the granularity supported by the fs + * containing the inode. Always rounds down. gran must + * not be 0 nor greater than a second (NSEC_PER_SEC, or 10^9 ns). + */ +struct timespec64 timestamp_truncate(struct timespec64 t, struct inode *inode) +{ + struct super_block *sb = inode->i_sb; + unsigned int gran = sb->s_time_gran; + + t.tv_sec = clamp(t.tv_sec, sb->s_time_min, sb->s_time_max); + if (unlikely(t.tv_sec == sb->s_time_max || t.tv_sec == sb->s_time_min)) + t.tv_nsec = 0; + + /* Avoid division in the common cases 1 ns and 1 s. */ + if (gran == 1) + ; /* nothing */ + else if (gran == NSEC_PER_SEC) + t.tv_nsec = 0; + else if (gran > 1 && gran < NSEC_PER_SEC) + t.tv_nsec -= t.tv_nsec % gran; + else + WARN(1, "invalid file time granularity: %u", gran); + return t; +} +EXPORT_SYMBOL(timestamp_truncate); + /** * current_time - Return FS time * @inode: inode. @@ -2190,7 +2221,7 @@ struct timespec64 current_time(struct inode *inode) return now; } - return timespec64_trunc(now, inode->i_sb->s_time_gran); + return timestamp_truncate(now, inode); } EXPORT_SYMBOL(current_time); diff --git a/include/linux/fs.h b/include/linux/fs.h index 93c440d22547..1170d8260aa2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -737,6 +737,8 @@ struct inode { void *i_private; /* fs or device private pointer */ } __randomize_layout; +struct timespec64 timestamp_truncate(struct timespec64 t, struct inode *inode); + static inline unsigned int i_blocksize(const struct inode *node) { return (1 << node->i_blkbits); From patchwork Sun Aug 18 16:58:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099749 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9F12912 for ; Sun, 18 Aug 2019 17:01:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1DF11FE8D for ; Sun, 18 Aug 2019 17:01:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95A07228C8; Sun, 18 Aug 2019 17:01:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEEC71FE8D for ; Sun, 18 Aug 2019 17:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726994AbfHRQ7j (ORCPT ); Sun, 18 Aug 2019 12:59:39 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42984 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726988AbfHRQ7i (ORCPT ); Sun, 18 Aug 2019 12:59:38 -0400 Received: by mail-pg1-f193.google.com with SMTP id p3so5500828pgb.9; Sun, 18 Aug 2019 09:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XBoGugkhUC7RzEVn8NEyVinAwt3h5A3UJUwpo03Y32I=; b=mlw3BTHmR65CECBGBfXGXHjTZ5nyHwdI6R8Rp5DQ3oO8pXG6+/TVmoY/X1eUUe7m4M NywGeGa506MTS3HvJq+RKK7t3qeBzAy0zkmEjQJUw3iRS7ZGFvkA54/44d4skmg4mKPp 9BM+1IdlEpQwrbDb0bEN9VuGlPsG04Lgn7VDjI80Je7xwzN/p4ERNoksd0iHF6EWwxJ9 yscfg30lVzUcx3ZCiC0DGkrfUzoJicdlyogkoyW98sWY9bVjzwIJaV4mduy5FAvxqsxn +J4B9McSFexn31/NZCFP74SXSJo58mjK/ALWOZExwDIlSqEGlWhsWa+t49PyLth6Z1T9 fn5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XBoGugkhUC7RzEVn8NEyVinAwt3h5A3UJUwpo03Y32I=; b=T9u9AT05zA7wYXCJZjFC93FiQVnaJbdLx4d9LYrLFfUpo4/0nAk5KQydWDGbtfoGGN j50kbYnaDa4hQSCf64gp6AMJRhJXivF6EEEKqfy5uzOOEk4eSRxy+MgaX2YHn5UzIbQG Hv36ZXy71Zcz44THR2+RGflCxNXR+nHjVNCfqlyMQuv73ZGyYKPH/db1ywtXJ1YbzBH1 IzO0hzRmxxE0XRiqmwfAPz42KreyKiyflxCNc7W98k3ssCA4ITUXKIN/cnwEsT2AUwzh vj+oMpbzdvFi5O72a6wO5mMlDFSkYHDL2NwdAfs6WF/KMqayP/1x3UEvPFaJ/4wtBoFx rbzw== X-Gm-Message-State: APjAAAWfCGK9XNYMTxSiZOYDQQQ++CXvDo71qchwwP6GlaxxG8/1+57d KyYKmq9E13djD/bJVYKwHCbighMIEaU= X-Google-Smtp-Source: APXvYqyMocWQPnOEOvETytOVzxJTuHH9RsqGxnRaQNh5G1nPmvEKz71Glx/Lb38BKq0xU4X4UktRWA== X-Received: by 2002:a63:e20a:: with SMTP id q10mr16098732pgh.24.1566147577789; Sun, 18 Aug 2019 09:59:37 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:37 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, adrian.hunter@intel.com, dedekind1@gmail.com, gregkh@linuxfoundation.org, hch@lst.de, jaegeuk@kernel.org, jlbec@evilplan.org, richard@nod.at, tj@kernel.org, yuchao0@huawei.com, linux-f2fs-devel@lists.sourceforge.net, linux-ntfs-dev@lists.sourceforge.net, linux-mtd@lists.infradead.org Subject: [PATCH v8 03/20] timestamp_truncate: Replace users of timespec64_trunc Date: Sun, 18 Aug 2019 09:58:00 -0700 Message-Id: <20190818165817.32634-4-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Update the inode timestamp updates to use timestamp_truncate() instead of timespec64_trunc(). The change was mostly generated by the following coccinelle script. virtual context virtual patch @r1 depends on patch forall@ struct inode *inode; identifier i_xtime =~ "^i_[acm]time$"; expression e; @@ inode->i_xtime = - timespec64_trunc( + timestamp_truncate( ..., - e); + inode); Signed-off-by: Deepa Dinamani Cc: adrian.hunter@intel.com Cc: dedekind1@gmail.com Cc: gregkh@linuxfoundation.org Cc: hch@lst.de Cc: jaegeuk@kernel.org Cc: jlbec@evilplan.org Cc: richard@nod.at Cc: tj@kernel.org Cc: yuchao0@huawei.com Cc: linux-f2fs-devel@lists.sourceforge.net Cc: linux-ntfs-dev@lists.sourceforge.net Cc: linux-mtd@lists.infradead.org --- fs/attr.c | 21 ++++++++++++--------- fs/configfs/inode.c | 12 ++++++------ fs/f2fs/file.c | 21 ++++++++++++--------- fs/kernfs/inode.c | 7 +++---- fs/ntfs/inode.c | 21 ++++++++++++--------- fs/ubifs/file.c | 21 ++++++++++++--------- 6 files changed, 57 insertions(+), 46 deletions(-) diff --git a/fs/attr.c b/fs/attr.c index 1fcfdcc5b367..97b60ad7f419 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -183,15 +183,18 @@ void setattr_copy(struct inode *inode, const struct iattr *attr) inode->i_uid = attr->ia_uid; if (ia_valid & ATTR_GID) inode->i_gid = attr->ia_gid; - if (ia_valid & ATTR_ATIME) - inode->i_atime = timespec64_trunc(attr->ia_atime, - inode->i_sb->s_time_gran); - if (ia_valid & ATTR_MTIME) - inode->i_mtime = timespec64_trunc(attr->ia_mtime, - inode->i_sb->s_time_gran); - if (ia_valid & ATTR_CTIME) - inode->i_ctime = timespec64_trunc(attr->ia_ctime, - inode->i_sb->s_time_gran); + if (ia_valid & ATTR_ATIME) { + inode->i_atime = timestamp_truncate(attr->ia_atime, + inode); + } + if (ia_valid & ATTR_MTIME) { + inode->i_mtime = timestamp_truncate(attr->ia_mtime, + inode); + } + if (ia_valid & ATTR_CTIME) { + inode->i_ctime = timestamp_truncate(attr->ia_ctime, + inode); + } if (ia_valid & ATTR_MODE) { umode_t mode = attr->ia_mode; diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c index ab0284321912..884dcf06cfbe 100644 --- a/fs/configfs/inode.c +++ b/fs/configfs/inode.c @@ -76,14 +76,14 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr) if (ia_valid & ATTR_GID) sd_iattr->ia_gid = iattr->ia_gid; if (ia_valid & ATTR_ATIME) - sd_iattr->ia_atime = timespec64_trunc(iattr->ia_atime, - inode->i_sb->s_time_gran); + sd_iattr->ia_atime = timestamp_truncate(iattr->ia_atime, + inode); if (ia_valid & ATTR_MTIME) - sd_iattr->ia_mtime = timespec64_trunc(iattr->ia_mtime, - inode->i_sb->s_time_gran); + sd_iattr->ia_mtime = timestamp_truncate(iattr->ia_mtime, + inode); if (ia_valid & ATTR_CTIME) - sd_iattr->ia_ctime = timespec64_trunc(iattr->ia_ctime, - inode->i_sb->s_time_gran); + sd_iattr->ia_ctime = timestamp_truncate(iattr->ia_ctime, + inode); if (ia_valid & ATTR_MODE) { umode_t mode = iattr->ia_mode; diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 89a9ee22296d..af8cdd345f3d 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -749,15 +749,18 @@ static void __setattr_copy(struct inode *inode, const struct iattr *attr) inode->i_uid = attr->ia_uid; if (ia_valid & ATTR_GID) inode->i_gid = attr->ia_gid; - if (ia_valid & ATTR_ATIME) - inode->i_atime = timespec64_trunc(attr->ia_atime, - inode->i_sb->s_time_gran); - if (ia_valid & ATTR_MTIME) - inode->i_mtime = timespec64_trunc(attr->ia_mtime, - inode->i_sb->s_time_gran); - if (ia_valid & ATTR_CTIME) - inode->i_ctime = timespec64_trunc(attr->ia_ctime, - inode->i_sb->s_time_gran); + if (ia_valid & ATTR_ATIME) { + inode->i_atime = timestamp_truncate(attr->ia_atime, + inode); + } + if (ia_valid & ATTR_MTIME) { + inode->i_mtime = timestamp_truncate(attr->ia_mtime, + inode); + } + if (ia_valid & ATTR_CTIME) { + inode->i_ctime = timestamp_truncate(attr->ia_ctime, + inode); + } if (ia_valid & ATTR_MODE) { umode_t mode = attr->ia_mode; diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c index f3f3984cce80..f3eaa8869f42 100644 --- a/fs/kernfs/inode.c +++ b/fs/kernfs/inode.c @@ -158,12 +158,11 @@ static inline void set_default_inode_attr(struct inode *inode, umode_t mode) static inline void set_inode_attr(struct inode *inode, struct kernfs_iattrs *attrs) { - struct super_block *sb = inode->i_sb; inode->i_uid = attrs->ia_uid; inode->i_gid = attrs->ia_gid; - inode->i_atime = timespec64_trunc(attrs->ia_atime, sb->s_time_gran); - inode->i_mtime = timespec64_trunc(attrs->ia_mtime, sb->s_time_gran); - inode->i_ctime = timespec64_trunc(attrs->ia_ctime, sb->s_time_gran); + inode->i_atime = timestamp_truncate(attrs->ia_atime, inode); + inode->i_mtime = timestamp_truncate(attrs->ia_mtime, inode); + inode->i_ctime = timestamp_truncate(attrs->ia_ctime, inode); } static void kernfs_refresh_inode(struct kernfs_node *kn, struct inode *inode) diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index 8baa34baf548..6c7388430ad3 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -2899,15 +2899,18 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr) ia_valid |= ATTR_MTIME | ATTR_CTIME; } } - if (ia_valid & ATTR_ATIME) - vi->i_atime = timespec64_trunc(attr->ia_atime, - vi->i_sb->s_time_gran); - if (ia_valid & ATTR_MTIME) - vi->i_mtime = timespec64_trunc(attr->ia_mtime, - vi->i_sb->s_time_gran); - if (ia_valid & ATTR_CTIME) - vi->i_ctime = timespec64_trunc(attr->ia_ctime, - vi->i_sb->s_time_gran); + if (ia_valid & ATTR_ATIME) { + vi->i_atime = timestamp_truncate(attr->ia_atime, + vi); + } + if (ia_valid & ATTR_MTIME) { + vi->i_mtime = timestamp_truncate(attr->ia_mtime, + vi); + } + if (ia_valid & ATTR_CTIME) { + vi->i_ctime = timestamp_truncate(attr->ia_ctime, + vi); + } mark_inode_dirty(vi); out: return err; diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c index 400970d740bb..cd52585c8f4f 100644 --- a/fs/ubifs/file.c +++ b/fs/ubifs/file.c @@ -1078,15 +1078,18 @@ static void do_attr_changes(struct inode *inode, const struct iattr *attr) inode->i_uid = attr->ia_uid; if (attr->ia_valid & ATTR_GID) inode->i_gid = attr->ia_gid; - if (attr->ia_valid & ATTR_ATIME) - inode->i_atime = timespec64_trunc(attr->ia_atime, - inode->i_sb->s_time_gran); - if (attr->ia_valid & ATTR_MTIME) - inode->i_mtime = timespec64_trunc(attr->ia_mtime, - inode->i_sb->s_time_gran); - if (attr->ia_valid & ATTR_CTIME) - inode->i_ctime = timespec64_trunc(attr->ia_ctime, - inode->i_sb->s_time_gran); + if (attr->ia_valid & ATTR_ATIME) { + inode->i_atime = timestamp_truncate(attr->ia_atime, + inode); + } + if (attr->ia_valid & ATTR_MTIME) { + inode->i_mtime = timestamp_truncate(attr->ia_mtime, + inode); + } + if (attr->ia_valid & ATTR_CTIME) { + inode->i_ctime = timestamp_truncate(attr->ia_ctime, + inode); + } if (attr->ia_valid & ATTR_MODE) { umode_t mode = attr->ia_mode; From patchwork Sun Aug 18 16:58:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099747 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5A6EB14F7 for ; Sun, 18 Aug 2019 17:01:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41E791FE8D for ; Sun, 18 Aug 2019 17:01:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 351C4228C8; Sun, 18 Aug 2019 17:01:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C49651FE8D for ; Sun, 18 Aug 2019 17:01:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727019AbfHRQ7k (ORCPT ); Sun, 18 Aug 2019 12:59:40 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38494 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727005AbfHRQ7k (ORCPT ); Sun, 18 Aug 2019 12:59:40 -0400 Received: by mail-pg1-f193.google.com with SMTP id e11so5505905pga.5; Sun, 18 Aug 2019 09:59:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6rUBVEJFml8xN/3NysGyzbXTdVn2u+LQ/JuruhLlfDg=; b=pitzbBHZsC1uM0DL/w98n1NkYkBv923i14v+6uF3OjXUnuFklYRxPvDOOnm7pXQdRd oO+y1taV/sMp/pDxW2kA7wRLIwmAk2aBWajXPvIftBYk4mJZplMsv16UaFaHsuJIZNrT /0szjiFztu/xE2imziHMT0jT8VYx5yr1hAzNJtH7evNH/VPg2ZPS6rZJG7is2cnHZy+Q 9ye5q9vFZXdm5wfbF9B2NN+USdQERWmpQSHh+BNeUpjthdov6iZTRSAKRJ4kPHXiIbcn LldQw5HHIAPwgGlcZruQ9ylZWCxDm/7mnYoc83+uu2dvfnE7DWs62B0OGJdZlquGVkIA vuig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6rUBVEJFml8xN/3NysGyzbXTdVn2u+LQ/JuruhLlfDg=; b=s9BUfoW3s19RwidWjqSLqFdFzfO/V3VcCHQnzMstfzBvnLchz+q9WUgIcTluMjjRSS t6jRkAVTtXppIPDEVASJlyI8R0o/2DFDby+ZlxdreibTumNnhu88yx+3dsq16qD5Q+F1 6OZ7NJ5GxmhRxRvY3vvAfc3W00RCuC2t32HRWhugV08yaS7htrTh8UOJDPixX54Lxb3v lpc48sKXiGkyCoUsskYN2Anu0MU6CqZPsiTFBxCtUASoT6ZveZ/TGDqwYtbO6gBBvG9E mVUDVxEVLr2w845G4mDiPP3+AsEpFfh+gKsUF0y9emuNRNXdcagwf51SFURpZa0wG6V/ vlVg== X-Gm-Message-State: APjAAAVq+/cHHxTaxAdEt5k4HSpecSBx3LJOUndpIriVV91xzJ8tk/wh vSOqRFIuIWtFzPPPOAWocJU= X-Google-Smtp-Source: APXvYqwSEVrmo7MbgR7WT42005XrBMQC2eEXpXo+oxpUZuKIOAKm0W6XYP6C9mEpzMFD+JZMb4n+FA== X-Received: by 2002:a63:4042:: with SMTP id n63mr5870840pga.75.1566147579569; Sun, 18 Aug 2019 09:59:39 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:39 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de Subject: [PATCH v8 04/20] mount: Add mount warning for impending timestamp expiry Date: Sun, 18 Aug 2019 09:58:01 -0700 Message-Id: <20190818165817.32634-5-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The warning reuses the uptime max of 30 years used by settimeofday(). Note that the warning is only emitted for writable filesystem mounts through the mount syscall. Automounts do not have the same warning. Print out the warning in human readable format using the struct tm. After discussion with Arnd Bergmann, we chose to print only the year number. The raw s_time_max is also displayed, and the user can easily decode it e.g. "date -u -d @$((0x7fffffff))". We did not want to consolidate struct rtc_tm and struct tm just to print the date using a format specifier as part of this series. Given that the rtc_tm is not compiled on all architectures, this is not a trivial patch. This can be added in the future. Signed-off-by: Deepa Dinamani --- fs/namespace.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index bfcb4e341257..7fcf289593c5 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2468,6 +2468,26 @@ static void set_mount_attributes(struct mount *mnt, unsigned int mnt_flags) unlock_mount_hash(); } +static void mnt_warn_timestamp_expiry(struct path *mountpoint, struct vfsmount *mnt) +{ + struct super_block *sb = mnt->mnt_sb; + + if (!__mnt_is_readonly(mnt) && + (ktime_get_real_seconds() + TIME_UPTIME_SEC_MAX > sb->s_time_max)) { + char *buf = (char *)__get_free_page(GFP_KERNEL); + char *mntpath = buf ? d_path(mountpoint, buf, PAGE_SIZE) : ERR_PTR(-ENOMEM); + struct tm tm; + + time64_to_tm(sb->s_time_max, 0, &tm); + + pr_warn("Mounted %s file system at %s supports timestamps until %04ld (0x%llx)\n", + sb->s_type->name, mntpath, + tm.tm_year+1900, (unsigned long long)sb->s_time_max); + + free_page((unsigned long)buf); + } +} + /* * Handle reconfiguration of the mountpoint only without alteration of the * superblock it refers to. This is triggered by specifying MS_REMOUNT|MS_BIND @@ -2493,6 +2513,9 @@ static int do_reconfigure_mnt(struct path *path, unsigned int mnt_flags) if (ret == 0) set_mount_attributes(mnt, mnt_flags); up_write(&sb->s_umount); + + mnt_warn_timestamp_expiry(path, &mnt->mnt); + return ret; } @@ -2533,6 +2556,9 @@ static int do_remount(struct path *path, int ms_flags, int sb_flags, } up_write(&sb->s_umount); } + + mnt_warn_timestamp_expiry(path, &mnt->mnt); + put_fs_context(fc); return err; } @@ -2741,8 +2767,13 @@ static int do_new_mount_fc(struct fs_context *fc, struct path *mountpoint, return PTR_ERR(mnt); error = do_add_mount(real_mount(mnt), mountpoint, mnt_flags); - if (error < 0) + if (error < 0) { mntput(mnt); + return error; + } + + mnt_warn_timestamp_expiry(mountpoint, mnt); + return error; } From patchwork Sun Aug 18 16:58:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099745 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E4BD14F7 for ; Sun, 18 Aug 2019 17:01:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3702D1FE8D for ; Sun, 18 Aug 2019 17:01:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A71B228C8; Sun, 18 Aug 2019 17:01:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B52C91FE8D for ; Sun, 18 Aug 2019 17:00:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727046AbfHRQ7n (ORCPT ); Sun, 18 Aug 2019 12:59:43 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:44701 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727005AbfHRQ7m (ORCPT ); Sun, 18 Aug 2019 12:59:42 -0400 Received: by mail-pf1-f196.google.com with SMTP id c81so5702980pfc.11; Sun, 18 Aug 2019 09:59:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=PROzJfbp0ODOr1Wl6KKNqPCVH4+5GxUkJXbhUONEYSY=; b=dGXA0inWQvE8aXZCNgKD/FWPA8bj/UjFevVpEkp+Wi7hxNjRDW5wAxvF6I0Vm/MLXk aLZNJduj2iNk1UelnG7X+FYtMwNorfo7pbBQFH2g+dfyS1/5nNJw+xaqYilJfEm6tJEL 7xC76qhYekklaBW6T07XvJVfiOxe3pZg9BXuW+fTEYTqn4TBONuhhsCfg1ByhQK60h/o 2To5iImTup7ojxCd0KoFIhPFzUUUqj2wzpAbjYC8jpWkfYBY3aTaii7JhH2QtLi25Wul novYUUpGq1c+NpiVHS+GRCL1eY6WNo9NM7Q8d38SnCf0KPIvUo16BPh5dpSzCP928GcX X9xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PROzJfbp0ODOr1Wl6KKNqPCVH4+5GxUkJXbhUONEYSY=; b=ajTdRGUJ3ok9VKWcQas7bJ7yrLjvOj5d10oDxDQddb+FNcgYlYKTMn+H3NHrEB+CyO hwcH2OsV6oF4i4rQz/8sc7SDHZ22dBrYAbBHN519ZivFSQ665NrMvxhuJORuAO1LrPMb NcNRvRj61ocXIAKB65zHTrfg6rpweoZresW5jYLxsdd3mGn7yDXZ+WLVERw9qCVtihFk JK9k1Czd7tOeGAlksMf5St+eyjUMM2dnZt8fQH84IaHkBVTXOil93KcJrwLTh0r+/J5H qOLdoZw6/ZD+pCpHgfTUIssD+/7egyXwwFEdhLQHwp4nCcSdZzyo1RzPlg3bDmG3yO3D Ne5g== X-Gm-Message-State: APjAAAXTI3FhnGuWYeq/P1riqVLgblHMy+57ovzo5uWHBJdLPRAiYM5X rDYZDLqzgGMxrnrRBwmaYs6zdD9f X-Google-Smtp-Source: APXvYqwvQPeHGvxt0OGk+f3slnmRpy1dCIPr5h4Er9+GDyrbygH6nVTj4ScO9Hd2dpIulMonyg43cg== X-Received: by 2002:a63:2685:: with SMTP id m127mr16304426pgm.6.1566147581549; Sun, 18 Aug 2019 09:59:41 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:41 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de Subject: [PATCH v8 05/20] utimes: Clamp the timestamps before update Date: Sun, 18 Aug 2019 09:58:02 -0700 Message-Id: <20190818165817.32634-6-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP POSIX is ambiguous on the behavior of timestamps for futimens, utimensat and utimes. Whether to return an error or silently clamp a timestamp beyond the range supported by the underlying filesystems is not clear. POSIX.1 section for futimens, utimensat and utimes says: (http://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html) The file's relevant timestamp shall be set to the greatest value supported by the file system that is not greater than the specified time. If the tv_nsec field of a timespec structure has the special value UTIME_NOW, the file's relevant timestamp shall be set to the greatest value supported by the file system that is not greater than the current time. [EINVAL] A new file timestamp would be a value whose tv_sec component is not a value supported by the file system. The patch chooses to clamp the timestamps according to the filesystem timestamp ranges and does not return an error. This is in line with the behavior of utime syscall also since the POSIX page(http://pubs.opengroup.org/onlinepubs/009695399/functions/utime.html) for utime does not mention returning an error or clamping like above. Same for utimes http://pubs.opengroup.org/onlinepubs/009695399/functions/utimes.html Signed-off-by: Deepa Dinamani --- fs/utimes.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/utimes.c b/fs/utimes.c index 350c9c16ace1..1ba3f7883870 100644 --- a/fs/utimes.c +++ b/fs/utimes.c @@ -36,16 +36,14 @@ static int utimes_common(const struct path *path, struct timespec64 *times) if (times[0].tv_nsec == UTIME_OMIT) newattrs.ia_valid &= ~ATTR_ATIME; else if (times[0].tv_nsec != UTIME_NOW) { - newattrs.ia_atime.tv_sec = times[0].tv_sec; - newattrs.ia_atime.tv_nsec = times[0].tv_nsec; + newattrs.ia_atime = timestamp_truncate(times[0], inode); newattrs.ia_valid |= ATTR_ATIME_SET; } if (times[1].tv_nsec == UTIME_OMIT) newattrs.ia_valid &= ~ATTR_MTIME; else if (times[1].tv_nsec != UTIME_NOW) { - newattrs.ia_mtime.tv_sec = times[1].tv_sec; - newattrs.ia_mtime.tv_nsec = times[1].tv_nsec; + newattrs.ia_mtime = timestamp_truncate(times[1], inode); newattrs.ia_valid |= ATTR_MTIME_SET; } /* From patchwork Sun Aug 18 16:58:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099707 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 726A814F7 for ; Sun, 18 Aug 2019 16:59:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B38428437 for ; Sun, 18 Aug 2019 16:59:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E9472847E; Sun, 18 Aug 2019 16:59:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7250F28437 for ; Sun, 18 Aug 2019 16:59:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727093AbfHRQ7q (ORCPT ); Sun, 18 Aug 2019 12:59:46 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:43093 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727005AbfHRQ7p (ORCPT ); Sun, 18 Aug 2019 12:59:45 -0400 Received: by mail-pg1-f194.google.com with SMTP id k3so5496116pgb.10; Sun, 18 Aug 2019 09:59:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hcDJouypjtfHakqyyqAP9XhBSp/6phxQjTvkkHXeS8Q=; b=ho/0ZAQ1HuBLAksSZugEnf6GEEUUwx2c7MSMuYwFEq19+6+nW6wgHJuJCYWYim53+c u7rSUABUkgvn2R22ED0deEqUbRE+FNspV4WzfNzRamxvI1UX6V/AjBvRoeUZyeJPkmaI HkQbe0hIHTJtii+Aib1Q5rGf7k7V+7yIp5pGqQbrX2B+d1apq92LrCGLJT1YlG1OBaf2 Ih4gR4TLnn9SHFarM/5nVQzc54Agvl6UAxCVm4Ubx92SRAMD9FzmUggN0T6G7/8orJSk QgFDS3I4GLJpdyY5bFXh8qvaRIMJ4YKEmO3fbsPu4vzz2U97Qz9+l1ommUAS6hCW0Wzd /+Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hcDJouypjtfHakqyyqAP9XhBSp/6phxQjTvkkHXeS8Q=; b=gYTNsny9aOwOO7xsm2hsPvsKIZowhN6A7De7HafDJpfNndW01gY47aKJHicGOcY3Lb Eaa6PXXACCIBj41c/i7yNP4inMoPRu/izjlG4oLcUV/iLFRsssjbXYiPiaIx77n50/qL 2lWn7bXhUm2EsjFLhQOjBU5EswfZHOwVrnMA0/anPtr0HlofQ/oETZLhqFBWusseLIgF QkXfvxET9/X6MXCjb4Kcs3ZelfjhV7xbmyPOXCF7en/FReYQUMwFJR90VNO3pR+3Ieag B/cFrt8a3mY0hdjR5rzWtlrZmFkPi3+FCY6P48JoNZOyEgu3fEATuKlTEdEgBDiJRofu l67Q== X-Gm-Message-State: APjAAAUtPDXteIcIfBjkCSFxP1bX1mV2v6Uuvt1j7/ahIVJxQElyFVua WMjP8ANQIlNAEVwnnsaZe444F9FuOUE= X-Google-Smtp-Source: APXvYqxbzXhppEsQPWOFxWOWxonZW01Tf6ODgmsFYoPy528tWmObH2OS0FTzK14N9zOjR2ueP6B+qw== X-Received: by 2002:a17:90a:5288:: with SMTP id w8mr17181277pjh.61.1566147584902; Sun, 18 Aug 2019 09:59:44 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:44 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, aivazian.tigran@gmail.com, al@alarsen.net, coda@cs.cmu.edu, darrick.wong@oracle.com, dushistov@mail.ru, dwmw2@infradead.org, hch@infradead.org, jack@suse.com, jaharkes@cs.cmu.edu, luisbg@kernel.org, nico@fluxnic.net, phillip@squashfs.org.uk, richard@nod.at, salah.triki@gmail.com, shaggy@kernel.org, linux-xfs@vger.kernel.org, codalist@coda.cs.cmu.edu, linux-ext4@vger.kernel.org, linux-mtd@lists.infradead.org, jfs-discussion@lists.sourceforge.net, reiserfs-devel@vger.kernel.org Subject: [PATCH v8 06/20] fs: Fill in max and min timestamps in superblock Date: Sun, 18 Aug 2019 09:58:03 -0700 Message-Id: <20190818165817.32634-7-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Even though some filesystems are read-only, fill in the timestamps to reflect the on-disk representation. Signed-off-by: Deepa Dinamani Reviewed-by: Darrick J. Wong Cc: aivazian.tigran@gmail.com Cc: al@alarsen.net Cc: coda@cs.cmu.edu Cc: darrick.wong@oracle.com Cc: dushistov@mail.ru Cc: dwmw2@infradead.org Cc: hch@infradead.org Cc: jack@suse.com Cc: jaharkes@cs.cmu.edu Cc: luisbg@kernel.org Cc: nico@fluxnic.net Cc: phillip@squashfs.org.uk Cc: richard@nod.at Cc: salah.triki@gmail.com Cc: shaggy@kernel.org Cc: linux-xfs@vger.kernel.org Cc: codalist@coda.cs.cmu.edu Cc: linux-ext4@vger.kernel.org Cc: linux-mtd@lists.infradead.org Cc: jfs-discussion@lists.sourceforge.net Cc: reiserfs-devel@vger.kernel.org Acked-by: Anders Larsen Acked-By: Tigran Aivazian --- fs/befs/linuxvfs.c | 2 ++ fs/bfs/inode.c | 2 ++ fs/coda/inode.c | 3 +++ fs/cramfs/inode.c | 2 ++ fs/efs/super.c | 2 ++ fs/ext2/super.c | 2 ++ fs/freevxfs/vxfs_super.c | 2 ++ fs/jffs2/fs.c | 3 +++ fs/jfs/super.c | 2 ++ fs/minix/inode.c | 2 ++ fs/qnx4/inode.c | 2 ++ fs/qnx6/inode.c | 2 ++ fs/reiserfs/super.c | 3 +++ fs/romfs/super.c | 2 ++ fs/squashfs/super.c | 2 ++ fs/ufs/super.c | 7 +++++++ fs/xfs/xfs_super.c | 2 ++ 17 files changed, 42 insertions(+) diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c index 462d096ff3e9..64cdf4d8e424 100644 --- a/fs/befs/linuxvfs.c +++ b/fs/befs/linuxvfs.c @@ -893,6 +893,8 @@ befs_fill_super(struct super_block *sb, void *data, int silent) sb_set_blocksize(sb, (ulong) befs_sb->block_size); sb->s_op = &befs_sops; sb->s_export_op = &befs_export_operations; + sb->s_time_min = 0; + sb->s_time_max = 0xffffffffffffll; root = befs_iget(sb, iaddr2blockno(sb, &(befs_sb->root_dir))); if (IS_ERR(root)) { ret = PTR_ERR(root); diff --git a/fs/bfs/inode.c b/fs/bfs/inode.c index 5e97bed073d7..f8ce1368218b 100644 --- a/fs/bfs/inode.c +++ b/fs/bfs/inode.c @@ -324,6 +324,8 @@ static int bfs_fill_super(struct super_block *s, void *data, int silent) return -ENOMEM; mutex_init(&info->bfs_lock); s->s_fs_info = info; + s->s_time_min = 0; + s->s_time_max = U32_MAX; sb_set_blocksize(s, BFS_BSIZE); diff --git a/fs/coda/inode.c b/fs/coda/inode.c index 59a9a29ade0a..e07b5f2ceccc 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c @@ -223,6 +223,9 @@ static int coda_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_magic = CODA_SUPER_MAGIC; sb->s_op = &coda_super_operations; sb->s_d_op = &coda_dentry_operations; + sb->s_time_gran = 1; + sb->s_time_min = S64_MIN; + sb->s_time_max = S64_MAX; error = super_setup_bdi(sb); if (error) diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index 2ee89a353d64..c304ae8357ef 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -599,6 +599,8 @@ static int cramfs_finalize_super(struct super_block *sb, /* Set it all up.. */ sb->s_flags |= SB_RDONLY; + sb->s_time_min = 0; + sb->s_time_max = 0; sb->s_op = &cramfs_ops; root = get_cramfs_inode(sb, cramfs_root, 0); if (IS_ERR(root)) diff --git a/fs/efs/super.c b/fs/efs/super.c index 867fc24dee20..4a6ebff2af76 100644 --- a/fs/efs/super.c +++ b/fs/efs/super.c @@ -257,6 +257,8 @@ static int efs_fill_super(struct super_block *s, void *d, int silent) if (!sb) return -ENOMEM; s->s_fs_info = sb; + s->s_time_min = 0; + s->s_time_max = U32_MAX; s->s_magic = EFS_SUPER_MAGIC; if (!sb_set_blocksize(s, EFS_BLOCKSIZE)) { diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 44eb6e7eb492..baa36c6fb71e 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -1002,6 +1002,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) sb->s_maxbytes = ext2_max_size(sb->s_blocksize_bits); sb->s_max_links = EXT2_LINK_MAX; + sb->s_time_min = S32_MIN; + sb->s_time_max = S32_MAX; if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) { sbi->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE; diff --git a/fs/freevxfs/vxfs_super.c b/fs/freevxfs/vxfs_super.c index a89f68c3cbed..578a5062706e 100644 --- a/fs/freevxfs/vxfs_super.c +++ b/fs/freevxfs/vxfs_super.c @@ -229,6 +229,8 @@ static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) sbp->s_op = &vxfs_super_ops; sbp->s_fs_info = infp; + sbp->s_time_min = 0; + sbp->s_time_max = U32_MAX; if (!vxfs_try_sb_magic(sbp, silent, 1, (__force __fs32)cpu_to_le32(VXFS_SUPER_MAGIC))) { diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c index 25736676a456..05fe6cf5f1ac 100644 --- a/fs/jffs2/fs.c +++ b/fs/jffs2/fs.c @@ -591,6 +591,9 @@ int jffs2_do_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_blocksize = PAGE_SIZE; sb->s_blocksize_bits = PAGE_SHIFT; sb->s_magic = JFFS2_SUPER_MAGIC; + sb->s_time_min = 0; + sb->s_time_max = U32_MAX; + if (!sb_rdonly(sb)) jffs2_start_garbage_collect_thread(c); return 0; diff --git a/fs/jfs/super.c b/fs/jfs/super.c index f4e10cb9f734..b2dc4d1f9dcc 100644 --- a/fs/jfs/super.c +++ b/fs/jfs/super.c @@ -503,6 +503,8 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent) sb->s_fs_info = sbi; sb->s_max_links = JFS_LINK_MAX; + sb->s_time_min = 0; + sb->s_time_max = U32_MAX; sbi->sb = sb; sbi->uid = INVALID_UID; sbi->gid = INVALID_GID; diff --git a/fs/minix/inode.c b/fs/minix/inode.c index f96073f25432..7cb5fd38eb14 100644 --- a/fs/minix/inode.c +++ b/fs/minix/inode.c @@ -277,6 +277,8 @@ static int minix_fill_super(struct super_block *s, void *data, int silent) /* set up enough so that it can read an inode */ s->s_op = &minix_sops; + s->s_time_min = 0; + s->s_time_max = U32_MAX; root_inode = minix_iget(s, MINIX_ROOT_INO); if (IS_ERR(root_inode)) { ret = PTR_ERR(root_inode); diff --git a/fs/qnx4/inode.c b/fs/qnx4/inode.c index 922d083bbc7c..e8da1cde87b9 100644 --- a/fs/qnx4/inode.c +++ b/fs/qnx4/inode.c @@ -201,6 +201,8 @@ static int qnx4_fill_super(struct super_block *s, void *data, int silent) s->s_op = &qnx4_sops; s->s_magic = QNX4_SUPER_MAGIC; s->s_flags |= SB_RDONLY; /* Yup, read-only yet */ + s->s_time_min = 0; + s->s_time_max = U32_MAX; /* Check the superblock signature. Since the qnx4 code is dangerous, we should leave as quickly as possible diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c index 0f8b0ff1ba43..345db56c98fd 100644 --- a/fs/qnx6/inode.c +++ b/fs/qnx6/inode.c @@ -429,6 +429,8 @@ static int qnx6_fill_super(struct super_block *s, void *data, int silent) s->s_op = &qnx6_sops; s->s_magic = QNX6_SUPER_MAGIC; s->s_flags |= SB_RDONLY; /* Yup, read-only yet */ + s->s_time_min = 0; + s->s_time_max = U32_MAX; /* ease the later tree level calculations */ sbi = QNX6_SB(s); diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c index ab028ea0e561..d69b4ac0ae2f 100644 --- a/fs/reiserfs/super.c +++ b/fs/reiserfs/super.c @@ -1976,6 +1976,9 @@ static int reiserfs_fill_super(struct super_block *s, void *data, int silent) goto error_unlocked; } + s->s_time_min = 0; + s->s_time_max = U32_MAX; + rs = SB_DISK_SUPER_BLOCK(s); /* * Let's do basic sanity check to verify that underlying device is not diff --git a/fs/romfs/super.c b/fs/romfs/super.c index 4636f867b9e8..338ac8521e65 100644 --- a/fs/romfs/super.c +++ b/fs/romfs/super.c @@ -477,6 +477,8 @@ static int romfs_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_maxbytes = 0xFFFFFFFF; sb->s_magic = ROMFS_MAGIC; sb->s_flags |= SB_RDONLY | SB_NOATIME; + sb->s_time_min = 0; + sb->s_time_max = 0; sb->s_op = &romfs_super_ops; #ifdef CONFIG_ROMFS_ON_MTD diff --git a/fs/squashfs/super.c b/fs/squashfs/super.c index 0311171af72d..e2d6566371ec 100644 --- a/fs/squashfs/super.c +++ b/fs/squashfs/super.c @@ -186,6 +186,8 @@ static int squashfs_fill_super(struct super_block *sb, struct fs_context *fc) (u64) le64_to_cpu(sblk->id_table_start)); sb->s_maxbytes = MAX_LFS_FILESIZE; + sb->s_time_min = 0; + sb->s_time_max = U32_MAX; sb->s_flags |= SB_RDONLY; sb->s_op = &squashfs_super_ops; diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 4ed0dca52ec8..1da0be667409 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c @@ -843,6 +843,10 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) sb->s_maxbytes = MAX_LFS_FILESIZE; + sb->s_time_gran = NSEC_PER_SEC; + sb->s_time_min = S32_MIN; + sb->s_time_max = S32_MAX; + switch (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) { case UFS_MOUNT_UFSTYPE_44BSD: UFSD("ufstype=44bsd\n"); @@ -861,6 +865,9 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) uspi->s_fshift = 9; uspi->s_sbsize = super_block_size = 1536; uspi->s_sbbase = 0; + sb->s_time_gran = 1; + sb->s_time_min = S64_MIN; + sb->s_time_max = S64_MAX; flags |= UFS_TYPE_UFS2 | UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD; break; diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index f9450235533c..d3b10900fc24 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1663,6 +1663,8 @@ xfs_fs_fill_super( sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits); sb->s_max_links = XFS_MAXLINK; sb->s_time_gran = 1; + sb->s_time_min = S32_MIN; + sb->s_time_max = S32_MAX; sb->s_iflags |= SB_I_CGROUPWB; set_posix_acl_flag(sb); From patchwork Sun Aug 18 16:58:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1640E14F7 for ; Sun, 18 Aug 2019 17:00:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F15391FE8D for ; Sun, 18 Aug 2019 17:00:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E541D228C8; Sun, 18 Aug 2019 17:00:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 922BC1FE8D for ; Sun, 18 Aug 2019 17:00:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727110AbfHRQ7t (ORCPT ); Sun, 18 Aug 2019 12:59:49 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:43599 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727107AbfHRQ7t (ORCPT ); Sun, 18 Aug 2019 12:59:49 -0400 Received: by mail-pl1-f195.google.com with SMTP id 4so4618476pld.10; Sun, 18 Aug 2019 09:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i+LRMSNrj6ysytmm99Rc/BfD1o0cWeoJWbC6wV2pjKo=; b=u0p1xnlWIscokdPFGB1xYyyYkHxHQ1EL+oy8mcZPSMZFggyqqZZ0F9/0+kW22duHD/ 8ju4CMdUcg5dqW8NFvrLjqsPO+3+tcTuwk/zJhzsiYRNobzXm67Xt4msC8U7Gs2RrvU/ JTyWeqsdkz6Bd3Mer0vl5GbuRd4FHNEKuREypUk8XTJDC5gE68zNpQzwDj2hnam9Ow30 WEohjyeaEX/tYbtjEMkgHqo8Mt2G5ijBEH8TXthmxHiahwTHkqtFUQmCuGyvxIXPhdRD DZo4MpwSedXBGn7w9nPknrg5pDuKae2X+zorJK7HyvQ2p4xWml8IVwIv/Y69Byr8lTb+ Ajdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=i+LRMSNrj6ysytmm99Rc/BfD1o0cWeoJWbC6wV2pjKo=; b=qkmSRFCXFNkjp8zPk0XkPP59LeSlXs/nUSY13epvHVSrOXehjYhvDMhJ0lo0PdXz+z 2o1iwuubiWJnjgns/KDuOwDWYPAFXOfk9z4rFVKYbPXLcgiXx+fmlS+9XJ7loiQiXUfH UOvrLC8Yjj6vavEsU1MvWFPWYqk9oXNt8Y925/ZAQXFRyHgHz40u6JcrEDpiBK4czqEr CwcXWqEB2oQRNi0bD6KlT1IDXyTpgYN5K+04xlK8zg4phSFyHrlXiGhDfcGFR5G573uR neCK64IU1daMG71stDa1lYSdHGl2eWS0tETvGQUk45rXRmkUOTEZVvjDXhEA/nLn5xlC XmdA== X-Gm-Message-State: APjAAAWPlvc/Ctb+3F4r2QQPDkmH9pdmkCDUJGwmp3TtNbHV4nefTUmC Ui2dA2nI2UVipV1co1f2R64= X-Google-Smtp-Source: APXvYqz112IoLRouv9ryA9wIoo9SK+U9diVimz4rMdCo6J+hyGg3GbdOEHSKOlp7hb6NH7QwtSqJVQ== X-Received: by 2002:a17:902:e406:: with SMTP id ci6mr18220361plb.207.1566147588404; Sun, 18 Aug 2019 09:59:48 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:48 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, ericvh@gmail.com, lucho@ionkov.net, asmadeus@codewreck.org, v9fs-developer@lists.sourceforge.net Subject: [PATCH v8 07/20] 9p: Fill min and max timestamps in sb Date: Sun, 18 Aug 2019 09:58:04 -0700 Message-Id: <20190818165817.32634-8-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP struct p9_wstat and struct p9_stat_dotl indicate that the wire transport uses u32 and u64 fields for timestamps. Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Note that the upper bound for V9FS_PROTO_2000L is retained as S64_MAX. This is because that is the upper bound supported by vfs. Signed-off-by: Deepa Dinamani Cc: ericvh@gmail.com Cc: lucho@ionkov.net Cc: asmadeus@codewreck.org Cc: v9fs-developer@lists.sourceforge.net --- fs/9p/vfs_super.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 08112fbcaece..ca243e658d71 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c @@ -69,8 +69,12 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses, if (v9fs_proto_dotl(v9ses)) { sb->s_op = &v9fs_super_ops_dotl; sb->s_xattr = v9fs_xattr_handlers; - } else + } else { sb->s_op = &v9fs_super_ops; + sb->s_time_max = U32_MAX; + } + + sb->s_time_min = 0; ret = super_setup_bdi(sb); if (ret) From patchwork Sun Aug 18 16:58:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099739 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2815B14F7 for ; Sun, 18 Aug 2019 17:00:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 115411FE8D for ; Sun, 18 Aug 2019 17:00:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05BDB228C8; Sun, 18 Aug 2019 17:00:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98EB51FE8D for ; Sun, 18 Aug 2019 17:00:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727124AbfHRQ7w (ORCPT ); Sun, 18 Aug 2019 12:59:52 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:39837 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727117AbfHRQ7v (ORCPT ); Sun, 18 Aug 2019 12:59:51 -0400 Received: by mail-pl1-f196.google.com with SMTP id z3so4644620pln.6; Sun, 18 Aug 2019 09:59:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZDn2Y98kbbO22z0K+xR+AWtcv4GaQ+wX4PQ2vNgnGx0=; b=HZZECivaaHUGQpuuX/FAHVzlTJJLx3E0iyKj9ADCKY61mBIlC5TV6Os3rc0pFt/dsX KW+haRJEzqY16CKn9IDlmyyilH20DyykTBymCfAofasTklaRwyZo/hnoqEGvxfnBeduZ PKWJORpP5BCid1bVmi0Drt+kDcXrgwe7DOPlpA6/zveCSo9KO9uL2XF3NHSwduc1bkDI FqSFh8NhKnA2zZP9yFNfSNpDogJrGh1Twfb1cX5tNaeKwzI2l4Cta4NWdIT2+DiHKTHG wz4IzZdvnZ0+nCOZMpFFJkhk/dOFeJy5j5nUoUuOTIDnNoh9/uvfcMDkyHj0+XCJYFbU oLow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZDn2Y98kbbO22z0K+xR+AWtcv4GaQ+wX4PQ2vNgnGx0=; b=VAEOC1RCvOHsNMXC3RJ9Mdh4C7NgxJlezRO+TbYLwcShyWjXnh+/pkwd5E+PuZJSE9 gV8PoFsE+tSSD8ZMiu+Vp3Vw9ozMfRozCfcEE39EbsVf8S+xFSF+kvzFSA/rZ8WgD9gj /Ou55M8sYPGC3vOtrT9K/9Nc4ynFEkeY0TgjLIFGPIcswbXTZBh+CcnLvsFmknqSXwcq vSoW5euLVid9ShOrO2+UxSps5tJgSQgW7zxaet/mtYFJSxf4RqUW80MPEK0eit4akxFs 49AWbaR0zcAdZIBtkjR887BQYrWvp3d9FoMQKDzzNZdBijSuDGrJ5U3dnvr1SRi3hWPl Ofkw== X-Gm-Message-State: APjAAAUYesR2noT8JbRYqsYTEznSHW3yOJKCbSn84Gdo4e/0WSLQyHwB acS978Ixb/mLVxjGdmOPYeM= X-Google-Smtp-Source: APXvYqwDEc/zbsCzxpbWInKA8ux4ee6fNVm2CdnwLU0UTK0TDNa6JvgW7VDUpgedC65jtR4bP/diQw== X-Received: by 2002:a17:902:d90a:: with SMTP id c10mr18269442plz.208.1566147590877; Sun, 18 Aug 2019 09:59:50 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:50 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de Subject: [PATCH v8 08/20] adfs: Fill in max and min timestamps in sb Date: Sun, 18 Aug 2019 09:58:05 -0700 Message-Id: <20190818165817.32634-9-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Note that the min timestamp is assumed to be 01 Jan 1970 00:00:00 (Unix epoch). This is consistent with the way we convert timestamps in adfs_adfs2unix_time(). Signed-off-by: Deepa Dinamani --- fs/adfs/adfs.h | 13 +++++++++++++ fs/adfs/inode.c | 8 ++------ fs/adfs/super.c | 2 ++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h index b7e844d2f321..dca8b23aa43f 100644 --- a/fs/adfs/adfs.h +++ b/fs/adfs/adfs.h @@ -3,6 +3,19 @@ #include #include +/* + * 01 Jan 1970 00:00:00 (Unix epoch) as seconds since + * 01 Jan 1900 00:00:00 (RISC OS epoch) + */ +#define RISC_OS_EPOCH_DELTA 2208988800LL + +/* + * Convert 40 bit centi seconds to seconds + * since 01 Jan 1900 00:00:00 (RISC OS epoch) + * The result is 2248-06-03 06:57:57 GMT + */ +#define ADFS_MAX_TIMESTAMP ((0xFFFFFFFFFFLL / 100) - RISC_OS_EPOCH_DELTA) + /* Internal data structures for ADFS */ #define ADFS_FREE_FRAG 0 diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c index 124de75413a5..41eca1c451dc 100644 --- a/fs/adfs/inode.c +++ b/fs/adfs/inode.c @@ -167,11 +167,7 @@ static void adfs_adfs2unix_time(struct timespec64 *tv, struct inode *inode) { unsigned int high, low; - /* 01 Jan 1970 00:00:00 (Unix epoch) as nanoseconds since - * 01 Jan 1900 00:00:00 (RISC OS epoch) - */ - static const s64 nsec_unix_epoch_diff_risc_os_epoch = - 2208988800000000000LL; + static const s64 nsec_unix_epoch_diff_risc_os_epoch = RISC_OS_EPOCH_DELTA * NSEC_PER_SEC; s64 nsec; if (!adfs_inode_is_stamped(inode)) @@ -216,7 +212,7 @@ adfs_unix2adfs_time(struct inode *inode, unsigned int secs) if (adfs_inode_is_stamped(inode)) { /* convert 32-bit seconds to 40-bit centi-seconds */ low = (secs & 255) * 100; - high = (secs / 256) * 100 + (low >> 8) + 0x336e996a; + high = (secs / 256) * 100 + (low >> 8) + (RISC_OS_EPOCH_DELTA*100/256); ADFS_I(inode)->loadaddr = (high >> 24) | (ADFS_I(inode)->loadaddr & ~0xff); diff --git a/fs/adfs/super.c b/fs/adfs/super.c index 65b04ebb51c3..f074fe7d7158 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c @@ -463,6 +463,8 @@ static int adfs_fill_super(struct super_block *sb, void *data, int silent) asb->s_map_size = dr->nzones | (dr->nzones_high << 8); asb->s_map2blk = dr->log2bpmb - dr->log2secsize; asb->s_log2sharesize = dr->log2sharesize; + sb->s_time_min = 0; + sb->s_time_max = ADFS_MAX_TIMESTAMP; asb->s_map = adfs_read_map(sb, dr); if (IS_ERR(asb->s_map)) { From patchwork Sun Aug 18 16:58:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099709 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 136CA14F7 for ; Sun, 18 Aug 2019 17:00:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1B6328437 for ; Sun, 18 Aug 2019 16:59:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5D702847E; Sun, 18 Aug 2019 16:59:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7101328437 for ; Sun, 18 Aug 2019 16:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727158AbfHRQ76 (ORCPT ); Sun, 18 Aug 2019 12:59:58 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38588 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727137AbfHRQ7x (ORCPT ); Sun, 18 Aug 2019 12:59:53 -0400 Received: by mail-pl1-f196.google.com with SMTP id m12so4628304plt.5; Sun, 18 Aug 2019 09:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Bixo0d9JjVSmJP3zunYh4uJR5sDX3PUyVSVA35Jm0FY=; b=WTuXL53CLURj5aLi3QpopNfU2HCbOZcvXfAXvNbLHaeiXRjkDE+OyGMppcB/hn4j5c WtdxFfM9N7Y5Srktdgxtrld2dilkdzOYzha5NVVFpiuW2FWR8k8X+GLKR6WZjwA3fyWj mpiwz4OQB0ho+A7z5D10nh7qcp9JIZLRwpo8EhA9vxZ0+DbCBMjCmnzIOYEjL/ZZyPsJ r2suupkpUgcLm20f30+NXLF6zgRInErF4rzxOMX/iPJjYjfrr57u8l4dn0lFWJIFiYg9 QNU/xGdVV60c4OxpV4hAhVSWjRlv6AhnwYih73krgEGGmFrpFhlYJpsx+eA4Vjivm3l0 id3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Bixo0d9JjVSmJP3zunYh4uJR5sDX3PUyVSVA35Jm0FY=; b=DQU/SDgInBal71QcIsuGbN2Fz14x/V1A8gM/XGwOoJGXi1VeQmg+fkUIi6c9bWmVRI goN8Cyt4R5Z2AWP2OShjcCyz4EfH/E1UhrNtMHkE2H9uNw/ezwmkyJWBNxUpitqjD+0X dutdZVmo43L/3zWOmPpvZ7zZskmONLQWIyZmVCUeSJ99hbYbp3jfg1CWnCACvGtm85E2 bNOVtU/A7TqK7HqfGLriyTrsjnpWpCD6jDIMZv4nEFyMoNy2aOheUGNkMUYuFr+IVy4o 0TFm9CxiiPkrE+GkuizJIXPNNODWq+fAfTwgU2KmnKfYGlNEJhuJhnfqoAherlcLUhLR fN1w== X-Gm-Message-State: APjAAAUIFcKZ+60pRC0vYNxlIZwKxXY9T9RTwl+MO+zmV/xkfgb526GA N0/x4SzSQ1SLO1wDVE6NkEY= X-Google-Smtp-Source: APXvYqyKSFklkROLyfCHvHH06V4+O4L2K9sP6JRoVvpdbxityMSw53WzHF3Th+mpCDHKI3WCN44LBw== X-Received: by 2002:a17:902:788b:: with SMTP id q11mr18746076pll.308.1566147592742; Sun, 18 Aug 2019 09:59:52 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:52 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Subject: [PATCH v8 09/20] ext4: Initialize timestamps limits Date: Sun, 18 Aug 2019 09:58:06 -0700 Message-Id: <20190818165817.32634-10-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP ext4 has different overflow limits for max filesystem timestamps based on the extra bytes available. The timestamp limits are calculated according to the encoding table in a4dad1ae24f85i(ext4: Fix handling of extended tv_sec): * extra msb of adjust for signed * epoch 32-bit 32-bit tv_sec to * bits time decoded 64-bit tv_sec 64-bit tv_sec valid time range * 0 0 1 -0x80000000..-0x00000001 0x000000000 1901-12-13..1969-12-31 * 0 0 0 0x000000000..0x07fffffff 0x000000000 1970-01-01..2038-01-19 * 0 1 1 0x080000000..0x0ffffffff 0x100000000 2038-01-19..2106-02-07 * 0 1 0 0x100000000..0x17fffffff 0x100000000 2106-02-07..2174-02-25 * 1 0 1 0x180000000..0x1ffffffff 0x200000000 2174-02-25..2242-03-16 * 1 0 0 0x200000000..0x27fffffff 0x200000000 2242-03-16..2310-04-04 * 1 1 1 0x280000000..0x2ffffffff 0x300000000 2310-04-04..2378-04-22 * 1 1 0 0x300000000..0x37fffffff 0x300000000 2378-04-22..2446-05-10 Note that the time limits are not correct for deletion times. Added a warn when an inode cannot be extended to incorporate an extended timestamp. Signed-off-by: Deepa Dinamani Reviewed-by: Andreas Dilger Cc: tytso@mit.edu Cc: adilger.kernel@dilger.ca Cc: linux-ext4@vger.kernel.org --- fs/ext4/ext4.h | 10 +++++++++- fs/ext4/super.c | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 9c7f4036021b..ae5d0c86aba2 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -832,11 +832,15 @@ static inline void ext4_decode_extra_time(struct timespec64 *time, #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode) \ do { \ - (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \ if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) {\ + (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \ (raw_inode)->xtime ## _extra = \ ext4_encode_extra_time(&(inode)->xtime); \ } \ + else {\ + (raw_inode)->xtime = cpu_to_le32(clamp_t(int32_t, (inode)->xtime.tv_sec, S32_MIN, S32_MAX)); \ + ext4_warning_inode(inode, "inode does not support timestamps beyond 2038"); \ + } \ } while (0) #define EXT4_EINODE_SET_XTIME(xtime, einode, raw_inode) \ @@ -1643,6 +1647,10 @@ static inline bool ext4_verity_in_progress(struct inode *inode) #define EXT4_GOOD_OLD_INODE_SIZE 128 +#define EXT4_EXTRA_TIMESTAMP_MAX (((s64)1 << 34) - 1 + S32_MIN) +#define EXT4_NON_EXTRA_TIMESTAMP_MAX S32_MAX +#define EXT4_TIMESTAMP_MIN S32_MIN + /* * Feature set definitions */ diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 27cd622676e7..3db5f17228b7 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -4039,8 +4039,21 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) sbi->s_inode_size); goto failed_mount; } - if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) - sb->s_time_gran = 1 << (EXT4_EPOCH_BITS - 2); + /* + * i_atime_extra is the last extra field available for [acm]times in + * struct ext4_inode. Checking for that field should suffice to ensure + * we have extra space for all three. + */ + if (sbi->s_inode_size >= offsetof(struct ext4_inode, i_atime_extra) + + sizeof(((struct ext4_inode *)0)->i_atime_extra)) { + sb->s_time_gran = 1; + sb->s_time_max = EXT4_EXTRA_TIMESTAMP_MAX; + } else { + sb->s_time_gran = NSEC_PER_SEC; + sb->s_time_max = EXT4_NON_EXTRA_TIMESTAMP_MAX; + } + + sb->s_time_min = EXT4_TIMESTAMP_MIN; } sbi->s_desc_size = le16_to_cpu(es->s_desc_size); From patchwork Sun Aug 18 16:58:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099733 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DE64E14F7 for ; Sun, 18 Aug 2019 17:00:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C54621FE8D for ; Sun, 18 Aug 2019 17:00:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B960C228C8; Sun, 18 Aug 2019 17:00:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C4D81FE8D for ; Sun, 18 Aug 2019 17:00:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727339AbfHRRAo (ORCPT ); Sun, 18 Aug 2019 13:00:44 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34149 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727035AbfHRQ7z (ORCPT ); Sun, 18 Aug 2019 12:59:55 -0400 Received: by mail-pf1-f196.google.com with SMTP id b24so5747431pfp.1; Sun, 18 Aug 2019 09:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HGJ0SLLZ/8OiPn6gk75MHhbU4//pD3TrNh/zboW2EHI=; b=msrzD0Y9xNpt458A4zyO9I98iFYcvBfMe8wPmB4FuYb3QQzBzYSqAhtBY/qrcW87AA SQOgbWAt8qWQgvjbDY4qNud6q5rh553E4XHK6sf1AcRzUfvlYZz5i/CT7VilNmYgzdLI HrmeF8L99G+ZkbT4IZg8w5PYn83VtO9LOL7aDKodtY5eqe3nPow7+cVDOtlI3raF7pxJ gGO1eBjOG1FKJM/AGZWTPRXUVV1fFwvh/Ak2irv3b7+p1wwiKDUmImv3hGowvt0/eFDj F38j2DvADFJ8dC/gYf/tJjtzgYgAEFhZ26p7QrQ9jvKjUr4T7STs/hPEbFdZFxbOpXy3 ufTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HGJ0SLLZ/8OiPn6gk75MHhbU4//pD3TrNh/zboW2EHI=; b=ZTa14xzgdNHTTFnURDEmvVRu+E/1CvCpKyVaLpGysxKxH+mibTzlcMoriO2Hd8g920 WY+iFZlsEZJLunVOwYuH12dfARtvkY683UWj76zMLuApSuvZ7EdsWXqwIBHGMQtV1bKa CsVOW32motx1CFb/WZauCFLW/bV90oBWTEWpIfKgHAGTjhYfxWe0v51B5fG1ZgTivUju xjjbf4Hna/hZAOb8XFVSAqXD5INOJf3yjswKgykUaqVr1r2n6pa7mKfXxvKRrhsKtYBc yJ1eVOIpJLivZzVYZfgFLmQUKKtUHx/cdiHECQwPVRjnuqdmZMmcw7JvNy1Wi3E6vM+7 Drrw== X-Gm-Message-State: APjAAAWzVlmQMBEXz+fa8bZlcQ3pSOE22ANspA7r+NSjPEXTzMih/CNT KpLq2aLIpI6HLuy4N7CS6us= X-Google-Smtp-Source: APXvYqzxqwkDUvkPJOOZEtUbgNwAcxhbG0Q3MVR+Ce1pxVGHbDA3DuIuRfR52BAYtZsFDlhHQI1Azg== X-Received: by 2002:a17:90a:e38e:: with SMTP id b14mr16763092pjz.125.1566147594799; Sun, 18 Aug 2019 09:59:54 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:54 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, linux-nfs@vger.kernel.org Subject: [PATCH v8 10/20] fs: nfs: Initialize filesystem timestamp ranges Date: Sun, 18 Aug 2019 09:58:07 -0700 Message-Id: <20190818165817.32634-11-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. The time formats for various verious is detailed in the RFCs as below: https://tools.ietf.org/html/rfc7862(time metadata) https://tools.ietf.org/html/rfc7530: nfstime4 struct nfstime4 { int64_t seconds; uint32_t nseconds; }; https://tools.ietf.org/html/rfc1094 struct timeval { unsigned int seconds; unsigned int useconds; }; https://tools.ietf.org/html/rfc1813 struct nfstime3 { uint32 seconds; uint32 nseconds; }; Use the limits as per the RFC. Signed-off-by: Deepa Dinamani Cc: trond.myklebust@hammerspace.com Cc: anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org --- fs/nfs/super.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 703f595dce90..19a76cfa8b1f 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -2382,6 +2382,15 @@ void nfs_fill_super(struct super_block *sb, struct nfs_mount_info *mount_info) sb->s_flags |= SB_POSIXACL; sb->s_time_gran = 1; sb->s_export_op = &nfs_export_ops; + } else + sb->s_time_gran = 1000; + + if (server->nfs_client->rpc_ops->version != 4) { + sb->s_time_min = 0; + sb->s_time_max = U32_MAX; + } else { + sb->s_time_min = S64_MIN; + sb->s_time_max = S64_MAX; } nfs_initialise_sb(sb); @@ -2402,7 +2411,6 @@ static void nfs_clone_super(struct super_block *sb, sb->s_maxbytes = old_sb->s_maxbytes; sb->s_xattr = old_sb->s_xattr; sb->s_op = old_sb->s_op; - sb->s_time_gran = 1; sb->s_export_op = old_sb->s_export_op; if (server->nfs_client->rpc_ops->version != 2) { @@ -2410,6 +2418,16 @@ static void nfs_clone_super(struct super_block *sb, * so ourselves when necessary. */ sb->s_flags |= SB_POSIXACL; + sb->s_time_gran = 1; + } else + sb->s_time_gran = 1000; + + if (server->nfs_client->rpc_ops->version != 4) { + sb->s_time_min = 0; + sb->s_time_max = U32_MAX; + } else { + sb->s_time_min = S64_MIN; + sb->s_time_max = S64_MAX; } nfs_initialise_sb(sb); From patchwork Sun Aug 18 16:58:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7491818EC for ; Sun, 18 Aug 2019 17:00:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E7CC1FE8D for ; Sun, 18 Aug 2019 17:00:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5317C228C8; Sun, 18 Aug 2019 17:00:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8CED1FE8D for ; Sun, 18 Aug 2019 17:00:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726925AbfHRRAo (ORCPT ); Sun, 18 Aug 2019 13:00:44 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35158 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727119AbfHRQ75 (ORCPT ); Sun, 18 Aug 2019 12:59:57 -0400 Received: by mail-pf1-f196.google.com with SMTP id d85so5742118pfd.2; Sun, 18 Aug 2019 09:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=OANlzDBkabtl5UN7ibJ4MLwySknYtbivCf67bcL51AQ=; b=LY1WM6E8Kys2q7bNl2j7oB8/ISkGzEPiE0m9INgM32Ocw3Rsj+EYWZEUlZyH/X+yDW uJmiZ2eQrFLYP1ngeyVFhdvwrjcpeJwA60pSqsAnTjGCnCWbgZxMQCNR6QSfIrhijmWV DqF3vgYoawl+9EUYEgHazkgWm+ygOuKzuxtDpiN+VX5dFw0xDydRa1sZHnp0+znIpmoX hJV+v6Wu5nIFkcgDm0oPB+WItqilJxlctvpkK2lxSMCBbNz9ww5Sxxqu/tIpwZprJIet ttAu5Jw9SdUpCXQrU4Cco6c9sQq2kB/+xgyMMqXzHAnehdvOKgPS+TmiMjcnhGieYuGl kshw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OANlzDBkabtl5UN7ibJ4MLwySknYtbivCf67bcL51AQ=; b=c7UDJ48Xxzmzvox2ecSXEqoX32wGPsn8/Swzpjx8MzUAvfB2vVNS0mDgqlyRxiT/jV sXnOv75arNIInJngrh6b+XuTnkd8n6BGEtPbhqcQ4YiHYVR3aE9xLHiW22VBkR6d2tNr s+S5/4S7PSl5/dEGEp4jMml/zj6EZr4eWCiFPVkLikMco0h6VuQZ97aaF+7IK2qvC7QU nryA+XvEugJi5rZ+4Q8rh2rQ1uLALkhg+j5Yj2iTcAxONx+/JMZhrHEm4YZmBhJFNhWx TL5lEqrDnEBTFtWGnzMN2TKnG3HV84VIz/T5YLq+K3JTUbLwsn88l8yROkLPkEj34p8A VQzg== X-Gm-Message-State: APjAAAUvauVy0zccC3e26sLK9Gb2sxez14C1QZ6AxWYsldbDUPO+RMJT hawSs9Wdnqe5yByZO5RGjyA= X-Google-Smtp-Source: APXvYqwz00Tt6K8qor9ax5HaEuLrqJg2JMRGS32/pgAAjnqroMTDadhto/XOMVcETYlxqjtrhrsgqw== X-Received: by 2002:aa7:8a99:: with SMTP id a25mr20446137pfc.127.1566147596711; Sun, 18 Aug 2019 09:59:56 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:56 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, sfrench@samba.org, linux-cifs@vger.kernel.org Subject: [PATCH v8 11/20] fs: cifs: Initialize filesystem timestamp ranges Date: Sun, 18 Aug 2019 09:58:08 -0700 Message-Id: <20190818165817.32634-12-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Also fixed cnvrtDosUnixTm calculations to avoid int overflow while computing maximum date. References: http://cifs.com/ https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/d416ff7c-c536-406e-a951-4f04b2fd1d2b Signed-off-by: Deepa Dinamani Cc: sfrench@samba.org Cc: linux-cifs@vger.kernel.org --- fs/cifs/cifsfs.c | 22 ++++++++++++++++++++++ fs/cifs/netmisc.c | 14 +++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 3289b566463f..7a75726442ad 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -56,6 +56,15 @@ #include "dfs_cache.h" #endif +/* + * DOS dates from 1980/1/1 through 2107/12/31 + * Protocol specifications indicate the range should be to 119, which + * limits maximum year to 2099. But this range has not been checked. + */ +#define SMB_DATE_MAX (127<<9 | 12<<5 | 31) +#define SMB_DATE_MIN (0<<9 | 1<<5 | 1) +#define SMB_TIME_MAX (23<<11 | 59<<5 | 29) + int cifsFYI = 0; bool traceSMB; bool enable_oplocks = true; @@ -142,6 +151,7 @@ cifs_read_super(struct super_block *sb) struct inode *inode; struct cifs_sb_info *cifs_sb; struct cifs_tcon *tcon; + struct timespec64 ts; int rc = 0; cifs_sb = CIFS_SB(sb); @@ -161,6 +171,18 @@ cifs_read_super(struct super_block *sb) /* BB FIXME fix time_gran to be larger for LANMAN sessions */ sb->s_time_gran = 100; + if (tcon->unix_ext) { + ts = cifs_NTtimeToUnix(0); + sb->s_time_min = ts.tv_sec; + ts = cifs_NTtimeToUnix(cpu_to_le64(S64_MAX)); + sb->s_time_max = ts.tv_sec; + } else { + ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MIN), 0, 0); + sb->s_time_min = ts.tv_sec; + ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MAX), cpu_to_le16(SMB_TIME_MAX), 0); + sb->s_time_max = ts.tv_sec; + } + sb->s_magic = CIFS_MAGIC_NUMBER; sb->s_op = &cifs_super_ops; sb->s_xattr = cifs_xattr_handlers; diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index ed92958e842d..49c17ee18254 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c @@ -949,8 +949,8 @@ static const int total_days_of_prev_months[] = { struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset) { struct timespec64 ts; - time64_t sec; - int min, days, month, year; + time64_t sec, days; + int min, day, month, year; u16 date = le16_to_cpu(le_date); u16 time = le16_to_cpu(le_time); SMB_TIME *st = (SMB_TIME *)&time; @@ -966,15 +966,15 @@ struct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset) sec += 60 * 60 * st->Hours; if (st->Hours > 24) cifs_dbg(VFS, "illegal hours %d\n", st->Hours); - days = sd->Day; + day = sd->Day; month = sd->Month; - if (days < 1 || days > 31 || month < 1 || month > 12) { - cifs_dbg(VFS, "illegal date, month %d day: %d\n", month, days); - days = clamp(days, 1, 31); + if (day < 1 || day > 31 || month < 1 || month > 12) { + cifs_dbg(VFS, "illegal date, month %d day: %d\n", month, day); + day = clamp(day, 1, 31); month = clamp(month, 1, 12); } month -= 1; - days += total_days_of_prev_months[month]; + days = day + total_days_of_prev_months[month]; days += 3652; /* account for difference in days between 1980 and 1970 */ year = sd->Year; days += year * 365; From patchwork Sun Aug 18 16:58:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099727 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F35B4912 for ; Sun, 18 Aug 2019 17:00:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8F9327CF3 for ; Sun, 18 Aug 2019 17:00:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAA1F212D9; Sun, 18 Aug 2019 17:00:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72771212D9 for ; Sun, 18 Aug 2019 17:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727176AbfHRRAA (ORCPT ); Sun, 18 Aug 2019 13:00:00 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:46171 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727067AbfHRQ76 (ORCPT ); Sun, 18 Aug 2019 12:59:58 -0400 Received: by mail-pf1-f193.google.com with SMTP id q139so5701037pfc.13; Sun, 18 Aug 2019 09:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A08CQyPF693tmDGwyR4szt4dpA6CyB4J0ZetXSJxCsI=; b=D3UzYMN0ubh5OjWIPnDT31k0PC+Ich0Iti3pY8agIwmBEfh4giotU36w7CPi4aJUDi A8TNhlzmGX8N3gYYHeBmUl5gYG1Aps4+iKvb4f35zC5C7YcEEC0OByyfZWa1rn/O49Lt 68+eVWloTEJkFhTCp2xX+kNHj9dt3X6uBFi3jpq9OyZizQHEbx5k2zmja0JwdM+28t0l TTWijpf7HfhmcQwyCcJFnxlwAI2YEXMtQPIkITSGzA8Im21zk2spABQgrB8RRZWFQ5AU eehoFZArqJHemcbdJURNxrYnz49EKHnREgfoC+d2IpP+KePg604bCIye/3bBbLZYyXF8 t7Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=A08CQyPF693tmDGwyR4szt4dpA6CyB4J0ZetXSJxCsI=; b=Ynx1pVjBnrU7GxTbal9W/qxIhZKTgV0CpJjFSe2z9ZwTX1Yp4f6hKN7mNfPIUD3aPM ow0PnU9t+UQotLQcE/VlZIExAWnjge2M1LYN+i1NOrPl5evmIOr8cg0qF8hXBfNsnX+L wZ9d5ML51sqyUEjNcaielekw7I02fXZy7WYDm/IuzPIxQtRK8e4Dj8wmRpbJ2f1Voas6 MXr9j9Qccze7lr4F0+Ix1M9ydfeMrApKu9ZVdGgui8fRgDdBA+gI0RrEBMH+wJ8H6dz6 KrrHBTGN/V2uu6j5wzfbihVckquHjxkMZIJ5wSIM7Aq02cS3CtYLnIJXcrLmnA+K3VyN bppg== X-Gm-Message-State: APjAAAUv16emr1UkKFDghmcIC6JQPs8yaYjlftwix38URLJ5RTMkoIko oquhYMSPAKoGq/Gxf/ZOMmg= X-Google-Smtp-Source: APXvYqx/sle7DSPuLV3QaIXCNVWde/w+5lmvjpliq7rm7/ePMmQOHOoZqsVToWT6ZCOTNTb876Y+/Q== X-Received: by 2002:a63:b10f:: with SMTP id r15mr16218681pgf.230.1566147597851; Sun, 18 Aug 2019 09:59:57 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:57 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, hirofumi@mail.parknet.co.jp Subject: [PATCH v8 12/20] fs: fat: Initialize filesystem timestamp ranges Date: Sun, 18 Aug 2019 09:58:09 -0700 Message-Id: <20190818165817.32634-13-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Some FAT variants indicate that the years after 2099 are not supported. Since commit 7decd1cb0305 ("fat: Fix and cleanup timestamp conversion") we support the full range of years that can be represented, up to 2107. Signed-off-by: Deepa Dinamani Cc: hirofumi@mail.parknet.co.jp --- fs/fat/inode.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 0bc2abc5d453..f27f84e2103f 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -31,6 +31,11 @@ #define KB_IN_SECTORS 2 +/* DOS dates from 1980/1/1 through 2107/12/31 */ +#define FAT_DATE_MIN (0<<9 | 1<<5 | 1) +#define FAT_DATE_MAX (127<<9 | 12<<5 | 31) +#define FAT_TIME_MAX (23<<11 | 59<<5 | 29) + /* * A deserialized copy of the on-disk structure laid out in struct * fat_boot_sector. @@ -1617,6 +1622,7 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, int debug; long error; char buf[50]; + struct timespec64 ts; /* * GFP_KERNEL is ok here, because while we do hold the @@ -1710,6 +1716,12 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, int isvfat, sbi->free_clus_valid = 0; sbi->prev_free = FAT_START_ENT; sb->s_maxbytes = 0xffffffff; + fat_time_fat2unix(sbi, &ts, 0, cpu_to_le16(FAT_DATE_MIN), 0); + sb->s_time_min = ts.tv_sec; + + fat_time_fat2unix(sbi, &ts, cpu_to_le16(FAT_TIME_MAX), + cpu_to_le16(FAT_DATE_MAX), 0); + sb->s_time_max = ts.tv_sec; if (!sbi->fat_length && bpb.fat32_length) { struct fat_boot_fsinfo *fsinfo; From patchwork Sun Aug 18 16:58:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 783FA1805 for ; Sun, 18 Aug 2019 17:00:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58C88228C8 for ; Sun, 18 Aug 2019 17:00:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C92227CF3; Sun, 18 Aug 2019 17:00:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDE5B26E78 for ; Sun, 18 Aug 2019 17:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727320AbfHRRAj (ORCPT ); Sun, 18 Aug 2019 13:00:39 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43004 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727172AbfHRQ77 (ORCPT ); Sun, 18 Aug 2019 12:59:59 -0400 Received: by mail-pg1-f193.google.com with SMTP id p3so5501093pgb.9; Sun, 18 Aug 2019 09:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3J/tBreUSwmCA21c4aXcQcRD2d0OTlcA32UpOssIiE8=; b=gZwJ5HE2pHL1eTvcl02IMavV2M+r9J5ekcI4osMw8oKeg/9n0tSfpp3ucUd14xTF0k Gnzd4zmGvhyTDlODzTE0d8CNyAVr+htyfETwQ0L09gLGLkEpzfZq2sRwNb0a5//dZFqP OgTCs6xoNBT94V7xRjnYWdX6ZeHl04Ke2EbbQ0yYK4V1Z1Jb9KGTIKwS95V3ZNDolL2Q sNunkDpySOe+TfMD1S36VPZa3gtFES9UBOM+4Oo58mM0mVJdbThPAUfZdA5aeRSaL94n mA/xy5PTWuytM80F9CiYIusm3YnU5tR4XHR3X02aGOEHhIdQP97CIpsVnpbFzbpLke7m jjXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3J/tBreUSwmCA21c4aXcQcRD2d0OTlcA32UpOssIiE8=; b=pD4RqzvcB2h7s58tzirTSPGpu22qMXjIsWrnTu90IWdpKzRK88ApFmksby50JWeDvS L2EsSP8QkrtUQY1S6cDZ9SGpiE9AqusYyTydUTGIYRFdXaTqf1FPQOfLt9redK/ly5zl 1/K/HPbsgfj6EK93bp2LM0FT1wJV8HmHRJ93Osf1mMHKV52UwtghV/FnT00j+02FAoH1 y4yxRzLZ9spKxfhV/IaX/vNHkHLWwXOZeoWf5WENkYyjbQPuS2TY5Fcakm2/Rc+d771m X57XY4skr2n26/ow3aFgxAzKYwyAyvWH5bhE0q/9M6U/TGpp2hQLS5AgjJeZhi90KABt k0jg== X-Gm-Message-State: APjAAAWS4uz0k751i/MHiM7+wqBplqeueqRw3YzVfhH3c8Jd+P3kGSdo 1FuwZPqxXGJM4OdO/hHsOiU= X-Google-Smtp-Source: APXvYqzaNkM2HJbDHBWrBAPb+F5hpzNQpnHsP945rT4hwd4QMhQLtKT0BtFu+J+65VjwnowJkYIXlA== X-Received: by 2002:a63:62c6:: with SMTP id w189mr16322750pgb.312.1566147598968; Sun, 18 Aug 2019 09:59:58 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:58 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, dsterba@suse.com Subject: [PATCH v8 13/20] fs: affs: Initialize filesystem timestamp ranges Date: Sun, 18 Aug 2019 09:58:10 -0700 Message-Id: <20190818165817.32634-14-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Also fix timestamp calculation to avoid overflow while converting from days to seconds. Signed-off-by: Deepa Dinamani Acked-by: David Sterba Cc: dsterba@suse.com --- fs/affs/amigaffs.c | 2 +- fs/affs/amigaffs.h | 3 +++ fs/affs/inode.c | 4 ++-- fs/affs/super.c | 4 ++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c index 14a6c1b90c9f..f708c45d5f66 100644 --- a/fs/affs/amigaffs.c +++ b/fs/affs/amigaffs.c @@ -375,7 +375,7 @@ affs_secs_to_datestamp(time64_t secs, struct affs_date *ds) u32 minute; s32 rem; - secs -= sys_tz.tz_minuteswest * 60 + ((8 * 365 + 2) * 24 * 60 * 60); + secs -= sys_tz.tz_minuteswest * 60 + AFFS_EPOCH_DELTA; if (secs < 0) secs = 0; days = div_s64_rem(secs, 86400, &rem); diff --git a/fs/affs/amigaffs.h b/fs/affs/amigaffs.h index f9bef9056659..81fb396d4dfa 100644 --- a/fs/affs/amigaffs.h +++ b/fs/affs/amigaffs.h @@ -32,6 +32,9 @@ #define AFFS_ROOT_BMAPS 25 +/* Seconds since Amiga epoch of 1978/01/01 to UNIX */ +#define AFFS_EPOCH_DELTA ((8 * 365 + 2) * 86400LL) + struct affs_date { __be32 days; __be32 mins; diff --git a/fs/affs/inode.c b/fs/affs/inode.c index 73598bff8506..a346cf7659f1 100644 --- a/fs/affs/inode.c +++ b/fs/affs/inode.c @@ -150,10 +150,10 @@ struct inode *affs_iget(struct super_block *sb, unsigned long ino) } inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec - = (be32_to_cpu(tail->change.days) * (24 * 60 * 60) + + = (be32_to_cpu(tail->change.days) * 86400LL + be32_to_cpu(tail->change.mins) * 60 + be32_to_cpu(tail->change.ticks) / 50 + - ((8 * 365 + 2) * 24 * 60 * 60)) + + AFFS_EPOCH_DELTA) + sys_tz.tz_minuteswest * 60; inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_atime.tv_nsec = 0; affs_brelse(bh); diff --git a/fs/affs/super.c b/fs/affs/super.c index e7d036efbaa1..cc463ae47c12 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c @@ -355,6 +355,10 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) sb->s_op = &affs_sops; sb->s_flags |= SB_NODIRATIME; + sb->s_time_gran = NSEC_PER_SEC; + sb->s_time_min = sys_tz.tz_minuteswest * 60 + AFFS_EPOCH_DELTA; + sb->s_time_max = 86400LL * U32_MAX + 86400 + sb->s_time_min; + sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL); if (!sbi) return -ENOMEM; From patchwork Sun Aug 18 16:58:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099711 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3E26912 for ; Sun, 18 Aug 2019 17:00:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB0332847A for ; Sun, 18 Aug 2019 17:00:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CBF6428437; Sun, 18 Aug 2019 17:00:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EBCF28437 for ; Sun, 18 Aug 2019 17:00:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727194AbfHRRAB (ORCPT ); Sun, 18 Aug 2019 13:00:01 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46179 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727182AbfHRRAB (ORCPT ); Sun, 18 Aug 2019 13:00:01 -0400 Received: by mail-pf1-f195.google.com with SMTP id q139so5701093pfc.13; Sun, 18 Aug 2019 10:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Yus3UESewstQeP6xBqn0c8tU9AnJsLA523aHx91as5s=; b=bzG6Ys9MB8EB/SIiNm1O90+0fRmj7AmkXhOlkEZgA2BAesZ0uHBfgMNz1jtKbxVp5g 36SUBW4JMGzSQyQjYdgSOqYzYlxv+uWeVoEAIG5gmgaPI6uutfmBTGB1pA/qbbuDTfXV qKNJ+Fb9016L1xeg3QvFgCIFy4yem+zUSAIbQVVTODOmPQsawouPuRi8aEP5aRVcLDrE b3zfL9hDv0DWcJ7p87GiuOFWR86S3tfcu90wsAbuspJa3ux6zdJ6hD75QxDfS//tp3vZ RALHTIESSx3hRb/bvcBpZRUNAeq4zz6RqzNLmat+LatBMu+wpsW6a9XtC+pwY3E1N1tK FAew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Yus3UESewstQeP6xBqn0c8tU9AnJsLA523aHx91as5s=; b=OJopcZIUkGZQDjNcKceVvTlDNh49d5Kako87RQLXoqLyDIAcKGGhFJLb0r7bjXEzwU cqBjOLhdYZ0RCoEn5wv+gp350dzvIvsk1jVDfJJsVkK4+vNWdVcEWcOQbNd+5UvWDqBd 4pJ774xG/Og7RCFXLC99kiCExMGcm8taCTBSMk10LQKnsbD1h7XMugaiHFYgwkduQ79x 28ZVIbOyHO5BgayhmZT7Ztk9DdFmSxjI5sSr1t7BDo4OEp6x1vmtq/UMtFh+zuTjCV1F 0iT17fdwcPfvPg7Dm731J+9Iau0w/KE8uo8u3ls0ELCMBNkeoI1Qm5dNhOfkvOfHKCSc 1HuQ== X-Gm-Message-State: APjAAAWqdw+BhSKxVEPu7TJu/xK+XCN1TN5dyGLBv8D1W5babWV45ySp Ua/Li7lqxgIV8+00s0QE6Rc= X-Google-Smtp-Source: APXvYqy2w/ZWdNv7hvowG949tJNK2klBSLXYvs+QyMD1FHMvXxFsOirfLmDtgTaoEtpWAfTbN8Aj6g== X-Received: by 2002:a65:6415:: with SMTP id a21mr15511088pgv.98.1566147600079; Sun, 18 Aug 2019 10:00:00 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.09.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 09:59:59 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, hch@infradead.org Subject: [PATCH v8 14/20] fs: sysv: Initialize filesystem timestamp ranges Date: Sun, 18 Aug 2019 09:58:11 -0700 Message-Id: <20190818165817.32634-15-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Signed-off-by: Deepa Dinamani Cc: hch@infradead.org --- fs/sysv/super.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/sysv/super.c b/fs/sysv/super.c index d788b1daa7eb..cc8e2ed155c8 100644 --- a/fs/sysv/super.c +++ b/fs/sysv/super.c @@ -368,7 +368,8 @@ static int sysv_fill_super(struct super_block *sb, void *data, int silent) sbi->s_block_base = 0; mutex_init(&sbi->s_lock); sb->s_fs_info = sbi; - + sb->s_time_min = 0; + sb->s_time_max = U32_MAX; sb_set_blocksize(sb, BLOCK_SIZE); for (i = 0; i < ARRAY_SIZE(flavours) && !size; i++) { @@ -487,6 +488,8 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent) sbi->s_type = FSTYPE_V7; mutex_init(&sbi->s_lock); sb->s_fs_info = sbi; + sb->s_time_min = 0; + sb->s_time_max = U32_MAX; sb_set_blocksize(sb, 512); From patchwork Sun Aug 18 16:58:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099725 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8D6E1805 for ; Sun, 18 Aug 2019 17:00:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2B972847A for ; Sun, 18 Aug 2019 17:00:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3A7A28437; Sun, 18 Aug 2019 17:00:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6067628437 for ; Sun, 18 Aug 2019 17:00:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727301AbfHRRAa (ORCPT ); Sun, 18 Aug 2019 13:00:30 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35166 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727199AbfHRRAC (ORCPT ); Sun, 18 Aug 2019 13:00:02 -0400 Received: by mail-pf1-f196.google.com with SMTP id d85so5742203pfd.2; Sun, 18 Aug 2019 10:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=InlPSV/Fud4UWUCgto+/j1ZvODODh0X74nMaQ0nLf/c=; b=NIGqsIaek0HjL2GgtSXKY5GZVgFt+5jqDUInO3L77J5eaER7ZN8d99MATAtLY2JzPN EVU5bVid6REbeVbkJDFb80b1sy38bFj6EO7gXXIHl3taHTXPhgrQh0W9fPEu+B1mtBNz zMJ0EwoJx11zqoZSxzoxq+Pi0C49es/Fh02nL1WeL0NolPViJyNKX4/juh8KVqYaKM6F TBuyOd/mTqBSWauWhT/9Q3Crf2dCiiidIYe7govFkyI1EQd/XjxiI1owhL/FNRPI7etw w2pGv19Ci1X61OH6jsfSUGfjyXZIMbsjiwJUiasimYgezzTN8XxSGHtvEB7mCMBaa479 kR5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=InlPSV/Fud4UWUCgto+/j1ZvODODh0X74nMaQ0nLf/c=; b=q/Gb3SZ9y5V+qBTdkd8EOFp0SQTRpJ4hpTfoXZRMu1JwuCu+VhvfVvFrTbp3YiCawb Zy64SxDuiL8ogeQawJYG+yPchCp2MDuZ1yOqugv40jus2Aaf1Q00s5X5mzpFluUw4mav wxRoqOiqWfLwV0yrGo3dGnBgVBpUsKEM6o665jksK6rR/8xQ942a8lYUroYe0suGyYo2 opJuT+x9vW7w4Fqk0ifka42UT9qlYDfYwIHIAmz1occFXEqLoGLfhzbItUXY7h4L++uo +pQudIeRmF4TH7rGt5L+kA1eKsKLUGUWb5iY/8In14yfN++G8t8xyHvUyN0BrDBIAlVe txew== X-Gm-Message-State: APjAAAWCOHpTuuzQQMbQSBUmJA9C/h3ALyxaORI94GMG3IaZGgvwTgan DLwj4y90296TqUtHrSeWELQ= X-Google-Smtp-Source: APXvYqxm+JpZUrPKi90PzUoRj4CYKmRp6DCp9IDbKaerdS94K13XnVQclSTUErvrl1h7LBtc+yL4LQ== X-Received: by 2002:a63:b60b:: with SMTP id j11mr5062604pgf.283.1566147601603; Sun, 18 Aug 2019 10:00:01 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.10.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 10:00:01 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, zyan@redhat.com, sage@redhat.com, idryomov@gmail.com, ceph-devel@vger.kernel.org Subject: [PATCH v8 15/20] fs: ceph: Initialize filesystem timestamp ranges Date: Sun, 18 Aug 2019 09:58:12 -0700 Message-Id: <20190818165817.32634-16-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. According to the disscussion in https://patchwork.kernel.org/patch/8308691/ we agreed to use unsigned 32 bit timestamps on ceph. Update the limits accordingly. Signed-off-by: Deepa Dinamani Cc: zyan@redhat.com Cc: sage@redhat.com Cc: idryomov@gmail.com Cc: ceph-devel@vger.kernel.org --- fs/ceph/super.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 4406ec7018bb..2aa052b7bda7 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -907,6 +907,8 @@ static int ceph_set_super(struct super_block *s, struct fs_context *fc) s->s_export_op = &ceph_export_ops; s->s_time_gran = 1; + s->s_time_min = 0; + s->s_time_max = U32_MAX; ret = set_anon_super_fc(s, fc); if (ret != 0) From patchwork Sun Aug 18 16:58:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 087A3912 for ; Sun, 18 Aug 2019 17:00:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5BE428437 for ; Sun, 18 Aug 2019 17:00:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D914F2847E; Sun, 18 Aug 2019 17:00:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EC8E28437 for ; Sun, 18 Aug 2019 17:00:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727279AbfHRRAZ (ORCPT ); Sun, 18 Aug 2019 13:00:25 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:44720 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727208AbfHRRAD (ORCPT ); Sun, 18 Aug 2019 13:00:03 -0400 Received: by mail-pf1-f194.google.com with SMTP id c81so5703291pfc.11; Sun, 18 Aug 2019 10:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4vdpiujyv0Q54P4wr1NHiItOOVlay6nEIW3I5YYez1M=; b=qUD/uEQQpa5IDC7eb5nxpxQr/sWFHbFJfQN7K/crcrZ2iHsJ2DJgPtrQ5pL8lKjaOf GPYR11BRkK20l0XSflbKunmNOk0fMJ7hCwJC6eYGYAkss/I9A/UcV3qlTgLq3/imhpmS 4G7Z3YROQt83sLgDymrw4DFNq66x9Xtp/fOBr1KyXz3k1xISoJfPY4oZ5fERJ7E5/V2D qnAml5iKJ7fgcKDv5ssM671Ay2p1kCPe/tD1qxfO5W0KY0PbG3iYrwMe5OrlWfGQy5cX cWVpHihyiDeAHupNdZksDWLzOzBNVj2M6kFBPl22MqGlI2K2pX0zrxeXijX5QNvQTcXx TiHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4vdpiujyv0Q54P4wr1NHiItOOVlay6nEIW3I5YYez1M=; b=oHckccaQ5NS2PHwKc6DWmN2l1R64v2ZrUCNJ1m35JxntwaVJSyjEbx1dJTYajQumcQ Lt1s35Cau1BNb0Etm8oLdCR/HqC9aauLXm0GrmG+W9/3djbAvJn4DY0WPUtsE4Zj7rkQ X8jixuQhHj7tr+3pFjf1PsgvkREg17PADkmnM8+giu1PAek2ucTW2gtH9b2m9hWGyOuC 4IG/gbrcpgz3i83gGB3I0c56iMd/Gu5GzgjXF0NBN5hO4mB2CFNQx3li8DcNRn3xK9mt 92BO0l7Kzpk6BPUmWg37xOo/RUpVnPUCcjMHu6kUbt5nFppbIMgNNKYdBvq50V6OCcFd 7IKg== X-Gm-Message-State: APjAAAX6XTRC/1Xnqq2Dxoal0gpzF2fcwMJjNrTl34Goz552ytQfgI4z wOav5Q5ZMynELIAgUIAiAhlHgx5B X-Google-Smtp-Source: APXvYqyr9mBtlQK7ACvNr+uLKfh0Jp10T6k1lmnDKUFzMFgoW8J/zrcMq8sDrz3A6P+Mu4s+wlJGRQ== X-Received: by 2002:a63:8dc9:: with SMTP id z192mr16109414pgd.151.1566147602804; Sun, 18 Aug 2019 10:00:02 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.10.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 10:00:02 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, hubcap@omnibond.com, martin@omnibond.com, devel@lists.orangefs.org Subject: [PATCH v8 16/20] fs: orangefs: Initialize filesystem timestamp ranges Date: Sun, 18 Aug 2019 09:58:13 -0700 Message-Id: <20190818165817.32634-17-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Assume the limits as unsigned according to the below commit 98e8eef557a9 ("changed PVFS_time from int64_t to uint64_t") in https://github.com/waltligon/orangefs Author: Neill Miller Date: Thu Sep 2 15:00:38 2004 +0000 Signed-off-by: Deepa Dinamani Cc: hubcap@omnibond.com Cc: martin@omnibond.com Cc: devel@lists.orangefs.org --- fs/orangefs/super.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c index 2811586fafc2..1ec08fe459cf 100644 --- a/fs/orangefs/super.c +++ b/fs/orangefs/super.c @@ -425,6 +425,8 @@ static int orangefs_fill_sb(struct super_block *sb, sb->s_blocksize = PAGE_SIZE; sb->s_blocksize_bits = PAGE_SHIFT; sb->s_maxbytes = MAX_LFS_FILESIZE; + sb->s_time_min = 0; + sb->s_time_max = S64_MAX; ret = super_setup_bdi(sb); if (ret) From patchwork Sun Aug 18 16:58:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FC7D14F7 for ; Sun, 18 Aug 2019 17:00:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 090B128437 for ; Sun, 18 Aug 2019 17:00:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F183F2847E; Sun, 18 Aug 2019 17:00:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97A9028437 for ; Sun, 18 Aug 2019 17:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727228AbfHRRAG (ORCPT ); Sun, 18 Aug 2019 13:00:06 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38345 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727215AbfHRRAE (ORCPT ); Sun, 18 Aug 2019 13:00:04 -0400 Received: by mail-pf1-f194.google.com with SMTP id o70so5724800pfg.5; Sun, 18 Aug 2019 10:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vRAjF3ngnOVHXNvH9bSrKw90+Pov0J0fPixsHFf+DcE=; b=jZjJ6zS+ULCgVMeHvDCf3yU13Ae3QSfVl/zvJ/2eHjA8kLF9bQNf7JvTz/+hZ32HUy wwAXN8raBp0z94UCaXzJTCqVwa3fCMwb9ayUJ2msB37464FHIzljIU48spnNf9REpiVY 9uVoNAPH0OBHPw7KlQA1Up26mukmknakJneUIhI/3F/xCwVpjqhZSOyP2V2Coe0/X1wY HIyZnLfASnAhl3O61I6vx6bafabaXCWwrdSjfOU1uGfeJDPU44yvkzAO/Vq8M8jP1Z/8 cUKEzS2Rz8d5zgIYVZ+TaP0C3VZUmaNX0uXIGns1H4iBy4GR6gVHMYWxatXWcug9Ukq9 JDng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vRAjF3ngnOVHXNvH9bSrKw90+Pov0J0fPixsHFf+DcE=; b=Y/2oCxFj3a1locjHK3qEYm1SagigZ/ZD9j7O2o5YMrqx/PYNNZK2wOBgjFh8ueT4zE wj9hMzUaW0cAbS5WobYLxX1U1cj6F7W5/6zW+Jo8kpVgyqeFOkYHfpug2JRv5PFlVxrz 3mxxkIYwgQRCfTc7zyqqhoh90lXHcBZTrAhM3YMoaQH/VrEAcyCTmYw++qTuf1anRaxq xnOAB2L4VxcHsLQLXcadRWLaoZ0aCovV1++T2BPVmRReA6wbFi1dlZcZIPPW5j1xzwGg IrlzBe/BFjG3Z2u85IXMEzNop7PDx523YFeuDiM8FsyRtnI2SP7VXneMoPjm43vOvD3q jz/w== X-Gm-Message-State: APjAAAVILT4m2EKC82kYbk477v/WX/6Ge89ILBwX+2UdLX75xhYNOswB K63PlOYlsSJYki85iZKitPYM7W6F X-Google-Smtp-Source: APXvYqzBbzIf1WjL+vgTd3SN1/9RA4tXcLk9JxU7E8lP/B3k/UqoQUrEA68hdqfsMXcmRqL++75ixA== X-Received: by 2002:a17:90a:630a:: with SMTP id e10mr6112550pjj.25.1566147604015; Sun, 18 Aug 2019 10:00:04 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.10.00.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 10:00:03 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, mikulas@artax.karlin.mff.cuni.cz Subject: [PATCH v8 17/20] fs: hpfs: Initialize filesystem timestamp ranges Date: Sun, 18 Aug 2019 09:58:14 -0700 Message-Id: <20190818165817.32634-18-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Also change the local_to_gmt() to use time64_t instead of time32_t. Signed-off-by: Deepa Dinamani Cc: mikulas@artax.karlin.mff.cuni.cz --- fs/hpfs/hpfs_fn.h | 6 ++---- fs/hpfs/super.c | 2 ++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h index ab2e7cc2ff33..1cca83218fb5 100644 --- a/fs/hpfs/hpfs_fn.h +++ b/fs/hpfs/hpfs_fn.h @@ -334,7 +334,7 @@ long hpfs_ioctl(struct file *file, unsigned cmd, unsigned long arg); * local time (HPFS) to GMT (Unix) */ -static inline time64_t local_to_gmt(struct super_block *s, time32_t t) +static inline time64_t local_to_gmt(struct super_block *s, time64_t t) { extern struct timezone sys_tz; return t + sys_tz.tz_minuteswest * 60 + hpfs_sb(s)->sb_timeshift; @@ -343,9 +343,7 @@ static inline time64_t local_to_gmt(struct super_block *s, time32_t t) static inline time32_t gmt_to_local(struct super_block *s, time64_t t) { extern struct timezone sys_tz; - t = t - sys_tz.tz_minuteswest * 60 - hpfs_sb(s)->sb_timeshift; - - return clamp_t(time64_t, t, 0, U32_MAX); + return t - sys_tz.tz_minuteswest * 60 - hpfs_sb(s)->sb_timeshift; } static inline time32_t local_get_seconds(struct super_block *s) diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index 9db6d84f0d62..0a677a9aaf34 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c @@ -614,6 +614,8 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) s->s_magic = HPFS_SUPER_MAGIC; s->s_op = &hpfs_sops; s->s_d_op = &hpfs_dentry_operations; + s->s_time_min = local_to_gmt(s, 0); + s->s_time_max = local_to_gmt(s, U32_MAX); sbi->sb_root = le32_to_cpu(superblock->root); sbi->sb_fs_size = le32_to_cpu(superblock->n_sectors); From patchwork Sun Aug 18 16:58:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099713 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AF9A7912 for ; Sun, 18 Aug 2019 17:00:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ED622847A for ; Sun, 18 Aug 2019 17:00:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83227285BE; Sun, 18 Aug 2019 17:00:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 329C92847A for ; Sun, 18 Aug 2019 17:00:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727235AbfHRRAI (ORCPT ); Sun, 18 Aug 2019 13:00:08 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:38518 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727219AbfHRRAG (ORCPT ); Sun, 18 Aug 2019 13:00:06 -0400 Received: by mail-pg1-f193.google.com with SMTP id e11so5506288pga.5; Sun, 18 Aug 2019 10:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nEEbHHdJo3J9AWmv4sfl/bvoNMJ35SzSby1tOYDy5S8=; b=b54tQzYSsRmCAlJyh6Kavpohs0OdJvZ9UDjvuR2AoSoybX1ntN0bftuCQ/XShiI+vF o77j5EvbgujPkihKMGvkrkwT49Xd7cRCwb53xGz2gQMmNONshxyytbDFBjE56rQRzC5k EsUHvclx2o5wul7wGEkU1dCg7ebKj0yqp1B0E0u2u133bdTPkmdaXSJLsA9YJx4XL1Xz 2nnKiNJcuqRJgjBMnKTxkvkUjAmHh09TWq1f9QH+p+Hw/wbDn/liGZsYi/xmieu1DJzV m8I2cfmvFL796976kmGmhFlGqMJQ2yCkgdhsP2GLv6nqxzBKoBlOyBmkpUbFYVlaXWY4 urAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nEEbHHdJo3J9AWmv4sfl/bvoNMJ35SzSby1tOYDy5S8=; b=JtRyk6EP4KUwejxJG+VgNhIsXKPU2FFNvBGQESv5M9ec5NTsaLpwCFALgUUFK4/5eH q2Bjr4HpeEWD6vMwGM1XXo4z0lxCap+WRlV/4DgnaFLuEkuSMXV6DXWIb2HSN6NNsK0O 51z02cnuOiWAl9luOXOoTlPudOXzKSVeUt7bzq4gBbgDggmVhQGVxroyTKQ8lXmJ+jrj EDTRQu3E4Y4ZFDmpktuoW/ONGa7vPh0AAhn+RejCM/MsqD2UJCtRdyppXhwwMXiomit1 hx32sA87nYlNSMUMvvUHIp0tZA5lt3KrSVWWbe00O5IF/AECKRfTWn9bgaSPRHZqJkJC ZI8w== X-Gm-Message-State: APjAAAWlqVbebH12G8ecjGnWh8fam/UcQQYJET0aLh9G7ideRXa6R1Ou OwTJCGRAnx01bJmkL81JXvI= X-Google-Smtp-Source: APXvYqwRhXzRs1zzMZIezaq6/uw6Cob7hLAY+JhGzjIvW8SRcCJqm9Plm4qMhRGHBZ/z/Bj/huu8Ng== X-Received: by 2002:a63:2bd2:: with SMTP id r201mr16161226pgr.193.1566147605323; Sun, 18 Aug 2019 10:00:05 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.10.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 10:00:04 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, me@bobcopeland.com, linux-karma-devel@lists.sourceforge.net Subject: [PATCH v8 18/20] fs: omfs: Initialize filesystem timestamp ranges Date: Sun, 18 Aug 2019 09:58:15 -0700 Message-Id: <20190818165817.32634-19-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Signed-off-by: Deepa Dinamani Acked-by: Bob Copeland Cc: me@bobcopeland.com Cc: linux-karma-devel@lists.sourceforge.net --- fs/omfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c index 08226a835ec3..b76ec6b88ded 100644 --- a/fs/omfs/inode.c +++ b/fs/omfs/inode.c @@ -478,6 +478,10 @@ static int omfs_fill_super(struct super_block *sb, void *data, int silent) sb->s_maxbytes = 0xffffffff; + sb->s_time_gran = NSEC_PER_MSEC; + sb->s_time_min = 0; + sb->s_time_max = U64_MAX / MSEC_PER_SEC; + sb_set_blocksize(sb, 0x200); bh = sb_bread(sb, 0); From patchwork Sun Aug 18 16:58:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099719 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7EDBA14F7 for ; Sun, 18 Aug 2019 17:00:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6696628437 for ; Sun, 18 Aug 2019 17:00:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AD842847E; Sun, 18 Aug 2019 17:00:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E242728437 for ; Sun, 18 Aug 2019 17:00:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727260AbfHRRAU (ORCPT ); Sun, 18 Aug 2019 13:00:20 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44675 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727233AbfHRRAH (ORCPT ); Sun, 18 Aug 2019 13:00:07 -0400 Received: by mail-pg1-f193.google.com with SMTP id i18so5502269pgl.11; Sun, 18 Aug 2019 10:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yc219Aj1bi5akUr6C+VEItZb9oqP5EGh5K613uvjY0o=; b=V/xaDGSosY9BoU9lSHk+AsdK3u2fYRctnCOSz2Pvi5thzhcLVSGDQCgaumSHtvlB9J g8lPmPiewegowAXZQx7lWMikzkKoJlitvFQsbUKfbR9UO+U9abRsv9cwCcg49VsHsSkC ocYQTnJ8zE8jqcOpdYLVq7Eul22FxOgG7F5FPODBd2zm5ePEl90F2D80hqXXHyymU9hT mC5L1vLsmWcw0XTHeOc8W63n3djf7QfvJLo1MreWlfGAaWVC7CR2cZP4Rxl70iZVb3Lb PjCnH3rg/Te3qTKp/pDNuMQXZibWOB9T64a/1E+pFprlLYnlRI5f+fT2XisJsizQ1BW4 eT3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yc219Aj1bi5akUr6C+VEItZb9oqP5EGh5K613uvjY0o=; b=LEWayiIMtsMn0Qd/+KNFYJiPsvoMgdU6iuFXz3xwmVVsX9trhdJWO8pJHd70n33qjg oPVPQX8niHw1nx0CbBwSU4x1yvuNXgkoHWfN0wfo6SaGqzNGR3Q8qaGaf6/ZlOBFWkjW xFhfBi1ucqVSWLVMlDgKszL3CMvlR00yGFPyJ4kH79NgOWNNZanGqUpEnrg9dQM8lvGS kQ2ztYfhZZOcnwjZqAxCej45IgWnH2nr8rjWPPreQRisbo7anhpH5x1ES3x/FOGJjNC5 TzIF+UWDxiFFxPMtHbLBEbspvmQZybfLLbiaOAV6b548eGa9RDCb/Z8u5hcIoQ03IVKX FrKw== X-Gm-Message-State: APjAAAV/n7kfCxOwE6cdhETAkXDYs0DoEI4fYl/HLpxcI0UJTaH+wIp/ fZaFsPEhA69O9Nj/HYkfAoE= X-Google-Smtp-Source: APXvYqwc49bVGlBZJ+ea5wgKMEj4ypc8J+NoD8zYw9CFpcbCLb36a3nT1zj20DYBqHsy/iOEVBDA1w== X-Received: by 2002:a17:90a:22f0:: with SMTP id s103mr17550576pjc.56.1566147606746; Sun, 18 Aug 2019 10:00:06 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.10.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 10:00:06 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de, anton@enomsg.org, ccross@android.com, keescook@chromium.org, tony.luck@intel.com Subject: [PATCH v8 19/20] pstore: fs superblock limits Date: Sun, 18 Aug 2019 09:58:16 -0700 Message-Id: <20190818165817.32634-20-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Leaving granularity at 1ns because it is dependent on the specific attached backing pstore module. ramoops has microsecond resolution. Fix the readback of ramoops fractional timestamp microseconds, which has incorrectly been reporting the value as nanoseconds since 3f8f80f0 ("pstore/ram: Read and write to the 'compressed' flag of pstore"). Signed-off-by: Deepa Dinamani Acked-by: Kees Cook Cc: anton@enomsg.org Cc: ccross@android.com Cc: keescook@chromium.org Cc: tony.luck@intel.com --- fs/pstore/ram.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 2bb3468fc93a..8caff834f002 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -144,6 +144,7 @@ static int ramoops_read_kmsg_hdr(char *buffer, struct timespec64 *time, if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%lld.%lu-%c\n%n", (time64_t *)&time->tv_sec, &time->tv_nsec, &data_type, &header_length) == 3) { + time->tv_nsec *= 1000; if (data_type == 'C') *compressed = true; else @@ -151,6 +152,7 @@ static int ramoops_read_kmsg_hdr(char *buffer, struct timespec64 *time, } else if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%lld.%lu\n%n", (time64_t *)&time->tv_sec, &time->tv_nsec, &header_length) == 2) { + time->tv_nsec *= 1000; *compressed = false; } else { time->tv_sec = 0; From patchwork Sun Aug 18 16:58:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 11099715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2948F912 for ; Sun, 18 Aug 2019 17:00:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 111C128437 for ; Sun, 18 Aug 2019 17:00:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 052BC285C9; Sun, 18 Aug 2019 17:00:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C87A28437 for ; Sun, 18 Aug 2019 17:00:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727245AbfHRRAK (ORCPT ); Sun, 18 Aug 2019 13:00:10 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42371 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727070AbfHRRAI (ORCPT ); Sun, 18 Aug 2019 13:00:08 -0400 Received: by mail-pf1-f193.google.com with SMTP id i30so5713516pfk.9; Sun, 18 Aug 2019 10:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=B53kfNAL5bPehU6SpckbeuA1BwDTxczPn/Y5JPnbD6I=; b=hkv+ERgF20ssKIwymu3URWuHg3UvErhauZ06k/0G2LrqPxFB090vLrMGy/+WZBO2ho XSt+Q68y7GmJkE7msre2w2OU38bqK87Adp9b3L+OFdr/MALR1I6O7SHMof+oACZUAvaN 6KLPI5KKnDKlR1hJ/DOl7FVx8rk+mSUZ9j/wqitb/xx6Z6iXq3fAkgqdz+sFI+tZV8Jy 4G+KvomuB1vGD8b7FNR4afRSFrCSusWeLb+v6N9a+kbdEfFSF0ufKluXKnIjAx1C6qkD B/m3Cl5aZYTnrovlybeFZE5I4QynuGte/X6KW6yDlrYdlAuD5TDLayR1P7Iv+yoTE9p3 8XpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=B53kfNAL5bPehU6SpckbeuA1BwDTxczPn/Y5JPnbD6I=; b=amVAWmxMgrUqbqbo2TmI6nrdd8sYOh+Hopwn09tK9EhG0Bx39PqbLoKV43GbfQOcwQ GvfqMM7CDALZJJfK3zGN1eg+q7BULJOBlJmIYU6mvXWhrfau9aETiHOj1ENC8jCYRNjI iwaT7sW/pBXeP4g/ua4LY3uqqHlGAzOvHCQCA6Ycjk3s30ShFsbSsjNigQI60tVNO8T2 lNuRjPQB1HW2RE/oXhx9CBTZfVjtFiVgS0wso19/p+6+PBYEGrOSZsGdRelvQ6sLnTC7 yS3rxI72CvOZhVGIV7/+reHUdiPYK4piQ0PIo1i26wSaHc2fdugtx3FQHVAijehCGRzi tNSA== X-Gm-Message-State: APjAAAVXpMD3dNfMPc4l0Huiwql8YZ2M6npZUxc+5SUp36KTsgn2igVJ cInI87yrawgvKUFZp+m/0fM= X-Google-Smtp-Source: APXvYqwCKGjBW16GSAq1uDKuynJzJTBXWLl/QOCsZVV2XmdwJpydRmod7Xpj2D3WUvxWBkEwnteQZA== X-Received: by 2002:aa7:8498:: with SMTP id u24mr20671125pfn.61.1566147607698; Sun, 18 Aug 2019 10:00:07 -0700 (PDT) Received: from deepa-ubuntu.lan (c-98-234-52-230.hsd1.ca.comcast.net. [98.234.52.230]) by smtp.gmail.com with ESMTPSA id b136sm15732831pfb.73.2019.08.18.10.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2019 10:00:07 -0700 (PDT) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org, arnd@arndb.de Subject: [PATCH v8 20/20] isofs: Initialize filesystem timestamp ranges Date: Sun, 18 Aug 2019 09:58:17 -0700 Message-Id: <20190818165817.32634-21-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190818165817.32634-1-deepa.kernel@gmail.com> References: <20190818165817.32634-1-deepa.kernel@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fill in the appropriate limits to avoid inconsistencies in the vfs cached inode times when timestamps are outside the permitted range. Reference: http://www.ecma-international.org/publications/standards/Ecma-119.htm Signed-off-by: Deepa Dinamani --- fs/isofs/inode.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/isofs/inode.c b/fs/isofs/inode.c index 9e30d8703735..62c0462dc89f 100644 --- a/fs/isofs/inode.c +++ b/fs/isofs/inode.c @@ -30,6 +30,9 @@ #include "isofs.h" #include "zisofs.h" +/* max tz offset is 13 hours */ +#define MAX_TZ_OFFSET (52*15*60) + #define BEQUIET static int isofs_hashi(const struct dentry *parent, struct qstr *qstr); @@ -801,6 +804,10 @@ static int isofs_fill_super(struct super_block *s, void *data, int silent) */ s->s_maxbytes = 0x80000000000LL; + /* ECMA-119 timestamp from 1900/1/1 with tz offset */ + s->s_time_min = mktime64(1900, 1, 1, 0, 0, 0) - MAX_TZ_OFFSET; + s->s_time_max = mktime64(U8_MAX+1900, 12, 31, 23, 59, 59) + MAX_TZ_OFFSET; + /* Set this for reference. Its not currently used except on write which we don't have .. */