From patchwork Sat Feb 18 23:30:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepa Dinamani X-Patchwork-Id: 729476 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vQmQb2zKjz9s8X for ; Sun, 19 Feb 2017 10:32:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="RsL53MOR"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751543AbdBRXca (ORCPT ); Sat, 18 Feb 2017 18:32:30 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:35896 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750812AbdBRXbJ (ORCPT ); Sat, 18 Feb 2017 18:31:09 -0500 Received: by mail-pg0-f65.google.com with SMTP id a123so5406677pgc.3; Sat, 18 Feb 2017 15:30:43 -0800 (PST) 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=Uadb4ae023RDnlq4QIHyo5C00oGTfUwX1/sG+Fjxbug=; b=RsL53MORr7E83U5whLBdrK3ZXwhMepQS4hKc7pCRqzmxQkPvMb+YOG+T3Gko2Qbezs LpX/lCMPM6jWKKRkCGNZ5s+sUsaXkT8uTzVlVoqHz9IVjAkLX4ntii3LqmUdUupL7PBl ZwTLHbNiwBi3/nJlqm90rBzjM5GUZv6ii/6yECJFm50dm4qCIcucgagVQv4e0G/qIW6r 54eQcmiYa3z7oegVlzf46PLf0QYGsarDotvfIjQ61irpFqrq/V02CsC/Nf3/2tI42ppi eywV2ujeu65ERC0Wc7a7tOZ3HIRkDMK/EhqVnO3LSMSVXV7vYPytr9WA9O8GnCBGkVgr 0bDw== 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=Uadb4ae023RDnlq4QIHyo5C00oGTfUwX1/sG+Fjxbug=; b=JF1DX20BfsSSaiuklvzNfW3m7Aj696npD4f0BrPeAbhjyWFnBh89gMR/r9lluOOsEg LjpZekFaOU8NAJfMbRxz4lcKDlkEHgNGUPywW301NHHSmjU8SB9+ip9C8PcQld+IJP5+ x5XFbyLn9TqFKP1zDztEsnipBLtHmtURStRypepLw26R+3DKNuoJLenBPNYiy9GT/94z 6E65w/rzMTZsXTZI8cyiEPOSjcOLFrifm1VPukjDs+VzvCS3iTe/MXzSEaVr9FrM0Udx kXRYbPIZIoo4kzXg2cfme2uNRbwBj6lU/O4Z1EXlH5vb467ioLG41rlp4nmyA8u3Truf GlyA== X-Gm-Message-State: AMke39kKouqInGEbLR15FToec6Xa7Kivkktwf8LlfDLIhQAQhzVaLJv0//t+tg5ihpPnLg== X-Received: by 10.84.224.11 with SMTP id r11mr21494121plj.130.1487460642437; Sat, 18 Feb 2017 15:30:42 -0800 (PST) Received: from deepa-ubuntu.hsd1.ca.comcast.net ([2601:647:5000:6620:e8a1:d9de:f814:c176]) by smtp.gmail.com with ESMTPSA id s24sm27278030pgo.25.2017.02.18.15.30.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 18 Feb 2017 15:30:41 -0800 (PST) From: Deepa Dinamani To: viro@zeniv.linux.org.uk, tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de, y2038@lists.linaro.org Subject: [PATCH v3 1/5] vfs: Add file timestamp range support Date: Sat, 18 Feb 2017 15:30:04 -0800 Message-Id: <1487460608-15697-2-git-send-email-deepa.kernel@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487460608-15697-1-git-send-email-deepa.kernel@gmail.com> References: <1487460608-15697-1-git-send-email-deepa.kernel@gmail.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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. Note that the time ranges are saved in type time64_t rather than time_t. This is required because if we save ranges in time_t then we would not be able to save timestamp ranges for files that support timestamps beyond y2038. Signed-off-by: Deepa Dinamani --- fs/libfs.c | 4 ++++ fs/super.c | 2 ++ include/linux/fs.h | 3 +++ include/linux/time64.h | 2 ++ 4 files changed, 11 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index 28d6f35..90ee803 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -257,6 +257,8 @@ struct dentry *mount_pseudo_xattr(struct file_system_type *fs_type, char *name, s->s_op = ops ? ops : &simple_super_operations; s->s_xattr = xattr; s->s_time_gran = 1; + s->s_time_min = TIME64_MIN; + s->s_time_max = TIME64_MAX; root = new_inode(s); if (!root) goto Enomem; @@ -518,6 +520,8 @@ int simple_fill_super(struct super_block *s, unsigned long magic, s->s_magic = magic; s->s_op = &simple_super_operations; s->s_time_gran = 1; + s->s_time_min = TIME64_MIN; + s->s_time_max = TIME64_MAX; inode = new_inode(s); if (!inode) diff --git a/fs/super.c b/fs/super.c index b8b6a08..f9c2241 100644 --- a/fs/super.c +++ b/fs/super.c @@ -247,6 +247,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 de8ed0b..ef55dfb 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1337,6 +1337,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; /* * The next field is for VFS *only*. No filesystems have any business diff --git a/include/linux/time64.h b/include/linux/time64.h index 980c71b..25433b18 100644 --- a/include/linux/time64.h +++ b/include/linux/time64.h @@ -38,6 +38,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)