Skip to content

Commit

Permalink
fs: Fill in max and min timestamps in superblock
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Acked-By: Tigran Aivazian <[email protected]>
Acked-by: Jeff Layton <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
  • Loading branch information
deepa-hub committed Aug 30, 2019
1 parent 42e729b commit 22b1396
Show file tree
Hide file tree
Showing 17 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/befs/linuxvfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions fs/bfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions fs/coda/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ static int coda_fill_super(struct super_block *sb, void *data, int silent)
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)
Expand Down
2 changes: 2 additions & 0 deletions fs/cramfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,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))
Expand Down
2 changes: 2 additions & 0 deletions fs/efs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
2 changes: 2 additions & 0 deletions fs/ext2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions fs/freevxfs/vxfs_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down
3 changes: 3 additions & 0 deletions fs/jffs2/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@ int jffs2_do_fill_super(struct super_block *sb, void *data, int silent)
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;
Expand Down
2 changes: 2 additions & 0 deletions fs/jfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions fs/minix/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions fs/qnx4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions fs/qnx6/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions fs/reiserfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions fs/romfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,8 @@ static int romfs_fill_super(struct super_block *sb, void *data, int silent)
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
Expand Down
2 changes: 2 additions & 0 deletions fs/squashfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ static int squashfs_fill_super(struct super_block *sb, void *data, int silent)
(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;

Expand Down
7 changes: 7 additions & 0 deletions fs/ufs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions fs/xfs/xfs_super.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 22b1396

Please sign in to comment.