From patchwork Thu Mar 3 07:50:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 8488641 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CDD83C0553 for ; Thu, 3 Mar 2016 07:50:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 019C12012B for ; Thu, 3 Mar 2016 07:50:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0654C20122 for ; Thu, 3 Mar 2016 07:50:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754502AbcCCHuU (ORCPT ); Thu, 3 Mar 2016 02:50:20 -0500 Received: from mail-pa0-f65.google.com ([209.85.220.65]:34820 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753194AbcCCHuT (ORCPT ); Thu, 3 Mar 2016 02:50:19 -0500 Received: by mail-pa0-f65.google.com with SMTP id fl4so855674pad.2 for ; Wed, 02 Mar 2016 23:50:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=ZjRrBj3pCgcjJmdA05Dbt9+HmOSCmeLZQJggNP5tUTc=; b=FI0lbXJzf2VtWWuKI+aAIfttA43aCxGYHnQ+8S78Ns3RYTcW4WAF8At6zVuSadkX+r RWFI+OSEp2VGn+ZnRiEYLVhmA18tmFN+E5I6dFUhh2I+TARh5vsgzrMhdRe9Ga1Y2oDC uqXwJLxnIkdNtWiHL6mMqtckm5IOJ1Uhft6cbCGqMOreXDGA/mZGP7ELV7aEGcM5SREC OhqeBtfwfh0ftUSJmTYJszp4+4t0yqkmklAbtAlUpghTt1yj/jHySm7JRKn1R8TS377Q fVgyv36jRz76aBhLVgtJRpDVJg+rF5u2ZD2jwt7rKmRoEvNDAAI4E5+Fqw3x1Xno7cxp o7kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZjRrBj3pCgcjJmdA05Dbt9+HmOSCmeLZQJggNP5tUTc=; b=hoIaTzjeSlgKnU67WcOQzydYkeyNTzcqxSuLwzRYaLizlgncPCC0pz5GvCW7N0PcGb o5zxfk9Jx90G51KQhGNQEKCXl2rEJA3ozq76ROZ1hlGnyrUIOtdM8jEShtLI4zU5mdwv QM/ag71Dlqg+VU8/AUO8sdm7uEi8JBmxlCpXcpE47l3dsvK5yf2g5z6DAMFQMyqoCgKa YRH8uhJMPWpGaViFXiZmFSSwv3hV8SZsTEOh5yvxzODVSARWnRBdJdXM2kTH0f5/lPgo hfJILkU16M9GRKt5coV+WS4LZVC+Bw5tSYMVw/MnJxQpkr3smyV00hhgrZQs27HREFM9 JRHQ== X-Gm-Message-State: AD7BkJIz72T18pTLYRKVz8eFDI/F+WuoLUP75g79/Rx+xhUpbTojKr3e2TY4MTWDXylKfw== X-Received: by 10.66.150.170 with SMTP id uj10mr1688456pab.91.1456991419277; Wed, 02 Mar 2016 23:50:19 -0800 (PST) Received: from localhost.localdomain ([106.51.27.3]) by smtp.gmail.com with ESMTPSA id ml5sm58214186pab.2.2016.03.02.23.50.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Mar 2016 23:50:18 -0800 (PST) From: Deepa Dinamani To: linux-fsdevel@vger.kernel.org, y2038@lists.linaro.org Cc: viro@zeniv.linux.org.uk, tglx@linutronix.de, arnd@arndb.de, david@fromorbit.com Subject: [PATCH v2] vfs: Add support to check max and min inode times Date: Wed, 2 Mar 2016 23:50:01 -0800 Message-Id: <1456991401-27643-1-git-send-email-deepa.kernel@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is a preparation patch to add range checking for inode timestamps. Extend struct super_block to include information about the max and min inode times each filesystem can hold. These are dependent on the on-disk format of filesystems. These range checks will be used to clamp timestamps to filesystem allowed ranges. Individual filesystems do not have the same on disk format as the in memory inodes. Range checking and clamping times assigned to inodes will help keep in memory and on-disk timestamps to be in sync. Every time a new superblock is created, make sure that the superblock max and min timestamp fields are assigned invalid values. Another series will initialize these fields to appropriate values for every filesystem. The values are currently ignored. The exact policy and behavior will be decided in a separate patch. max and min times are initialized to MIN_VFS_TIME and MAX_VFS_TIME respectively so that even if one of the fields is uninitialized, it can be detected by using the condition max_time < min_time. The original idea for the feature comes from the discussion: https://lkml.org/lkml/2014/5/30/669 Signed-off-by: Deepa Dinamani --- The intention is to include this as part of 4.6 so that the follow on patches can go into 4.7. The series and the plan have been discussed with Arnd Bergmann. Changes from v1: * Delete INVALID macros, use VFS_TIME macros directly. * Add comment in alloc_super() to explain range checking. * Reword the commit text to reflect the above. fs/super.c | 7 +++++++ include/linux/fs.h | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/fs/super.c b/fs/super.c index 1182af8..37ec188 100644 --- a/fs/super.c +++ b/fs/super.c @@ -239,6 +239,13 @@ 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; + /* + * Assign a default empty range [MAX_VFS_TIME, MIN_VFS_TIME]. + * This will help VFS detect filesystems that do not populate + * these fields in the superblock. + */ + s->s_time_min = MAX_VFS_TIME; + s->s_time_max = MIN_VFS_TIME; 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 1af4727..cee8f99 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -927,6 +927,9 @@ static inline struct file *get_file(struct file *f) #define MAX_LFS_FILESIZE ((loff_t)0x7fffffffffffffffLL) #endif +#define MIN_VFS_TIME S64_MIN +#define MAX_VFS_TIME S64_MAX + #define FL_POSIX 1 #define FL_FLOCK 2 #define FL_DELEG 4 /* NFSv4 delegation */ @@ -1343,7 +1346,14 @@ struct super_block { /* Granularity of c/m/atime in ns. Cannot be worse than a second */ - u32 s_time_gran; + u32 s_time_gran; + + /* + * Max and min values for timestamps + * according to the range supported by filesystems. + */ + time64_t s_time_min; + time64_t s_time_max; /* * The next field is for VFS *only*. No filesystems have any business