f2fs: fix a bug when using namehash to locate dentry bucket
authorShuoran Liu <liushuoran@huawei.com>
Thu, 25 Aug 2016 12:42:09 +0000 (20:42 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Tue, 30 Aug 2016 01:31:16 +0000 (18:31 -0700)
In the following scenario,

1) we don't have the key and doing a lookup for encrypted file,
2) and the encrypted filename is big name

we should use fname->hash as name hash value instead of what is
calculated by fname->disk_name. Because in such case,
fname->disk_name is empty.

Signed-off-by: Shuoran Liu <liushuoran@huawei.com>
Acked-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/dir.c

index 9054aeac80152ba952eb2f362d3bb106280b115e..b3e6f7feadc9fb378815b4a52eb68e946bd28e28 100644 (file)
@@ -172,7 +172,10 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir,
        int max_slots;
        f2fs_hash_t namehash;
 
-       namehash = f2fs_dentry_hash(&name);
+       if(fname->hash)
+               namehash = cpu_to_le32(fname->hash);
+       else
+               namehash = f2fs_dentry_hash(&name);
 
        nbucket = dir_buckets(level, F2FS_I(dir)->i_dir_level);
        nblock = bucket_blocks(level);
This page took 0.029606 seconds and 5 git commands to generate.