From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934533AbcHYOOh (ORCPT ); Thu, 25 Aug 2016 10:14:37 -0400 Received: from mail.kernel.org ([198.145.29.136]:47506 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934273AbcHYOOd (ORCPT ); Thu, 25 Aug 2016 10:14:33 -0400 Subject: Re: [f2fs-dev] [PATCH] f2fs: fix a bug when using namehash to locate dentry bucket To: Shuoran Liu , jaegeuk@kernel.org References: <1472128929-86774-1-git-send-email-liushuoran@huawei.com> Cc: linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org From: Chao Yu Message-ID: Date: Thu, 25 Aug 2016 22:13:31 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1472128929-86774-1-git-send-email-liushuoran@huawei.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/8/25 20:42, Shuoran Liu wrote: > 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. Your signiture is missing here. Anyway that's a good catch! Acked-by: Chao Yu > --- > fs/f2fs/dir.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c > index 9054aea..b3e6f7f 100644 > --- a/fs/f2fs/dir.c > +++ b/fs/f2fs/dir.c > @@ -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); >