From: Deepa Dinamani <deepa.kernel@gmail.com>
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 [thread overview]
Message-ID: <1456991401-27643-1-git-send-email-deepa.kernel@gmail.com> (raw)
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 <deepa.kernel@gmail.com>
---
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
--
1.9.1
next reply other threads:[~2016-03-03 7:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-03 7:50 Deepa Dinamani [this message]
2016-03-03 14:10 ` [PATCH v2] vfs: Add support to check max and min inode times Arnd Bergmann
2016-03-03 15:38 ` Deepa Dinamani
2016-03-03 16:03 ` Arnd Bergmann
2016-03-03 17:33 ` Deepa Dinamani
2016-03-17 21:48 ` Alex Elder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1456991401-27643-1-git-send-email-deepa.kernel@gmail.com \
--to=deepa.kernel@gmail.com \
--cc=arnd@arndb.de \
--cc=david@fromorbit.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
--cc=y2038@lists.linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.