f2fs: give random value to i_generation
authorJaegeuk Kim <jaegeuk@kernel.org>
Mon, 25 Feb 2019 17:46:45 +0000 (09:46 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 13 Mar 2019 01:59:18 +0000 (18:59 -0700)
This follows to give random number to i_generation along with commit
232530680290b ("ext4: improve smp scalability for inode generation")

This can be used for DUN for UFS HW encryption.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h
fs/f2fs/namei.c
fs/f2fs/super.c

index 19cbf17550c76ae2c500c35f66a7b8ce5087bbe5..3007759dd2dd09f60e2682f06b3b4305615eaa1c 100644 (file)
@@ -1242,8 +1242,6 @@ struct f2fs_sb_info {
 
        unsigned int nquota_files;              /* # of quota sysfile */
 
-       u32 s_next_generation;                  /* for NFS support */
-
        /* # of pages, see count_type */
        atomic_t nr_pages[NR_COUNT_TYPE];
        /* # of allocated blocks */
index 62d9829f3a6a7ea23746e04891a819dddb221c8a..f218d9424d8b6772963e1bb184bb167f317c2259 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/pagemap.h>
 #include <linux/sched.h>
 #include <linux/ctype.h>
+#include <linux/random.h>
 #include <linux/dcache.h>
 #include <linux/namei.h>
 #include <linux/quotaops.h>
@@ -50,7 +51,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
        inode->i_blocks = 0;
        inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
        F2FS_I(inode)->i_crtime = inode->i_mtime;
-       inode->i_generation = sbi->s_next_generation++;
+       inode->i_generation = prandom_u32();
 
        if (S_ISDIR(inode->i_mode))
                F2FS_I(inode)->i_current_depth = 1;
index 45121190a2ba485f01b6d1151bb466b762e4149a..42eb5c86330ac7d340d55bc49dd9b080e2bc785d 100644 (file)
@@ -3129,7 +3129,6 @@ try_onemore:
        sb->s_maxbytes = sbi->max_file_blocks <<
                                le32_to_cpu(raw_super->log_blocksize);
        sb->s_max_links = F2FS_LINK_MAX;
-       get_random_bytes(&sbi->s_next_generation, sizeof(u32));
 
 #ifdef CONFIG_QUOTA
        sb->dq_op = &f2fs_quota_operations;