From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753930AbbCIJeK (ORCPT ); Mon, 9 Mar 2015 05:34:10 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:38513 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753779AbbCIJeI (ORCPT ); Mon, 9 Mar 2015 05:34:08 -0400 X-AuditID: cbfee61a-f79c06d000004e71-46-54fd690d7d69 From: Chao Yu To: Jaegeuk Kim , Changman Lee Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] f2fs: fix to calculate max length of contiguous free slots correctly Date: Mon, 09 Mar 2015 17:33:16 +0800 Message-id: <000701d05a4c$2fa0b520$8ee21f60$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdBaSxOrW+S0fpzQRG+756kCxBzRzw== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsVy+t9jQV2+zL8hBjNfsVhc29fIZPFk/Sxm i0uL3C0u75rD5sDisWlVJ5vH7gWfmTz6tqxi9Pi8SS6AJYrLJiU1J7MstUjfLoEr49DKoywF V3grNp++wdTAeIeri5GTQ0LAROLZjXYWCFtM4sK99WxdjFwcQgLTGSU+f+xlhXB+MEqsfPKA EaSKTUBFYnnHfyYQW0TAS2LS/hNg3cwCHhKNHd9ZQWxhgXCJ5vVXgeo5OFgEVCX+bRIFCfMK WEq8uNPHDGELSvyYfA+qVUti/c7jTBC2vMTmNW+ZIQ5SkNhx9jXYGBEBPYk77zIgSsQlNh65 xTKBUWAWkkmzkEyahWTSLCQtCxhZVjGKphYkFxQnpeca6hUn5haX5qXrJefnbmIEB/QzqR2M KxssDjEKcDAq8fDuOPEnRIg1say4MvcQowQHs5IIr37Y3xAh3pTEyqrUovz4otKc1OJDjNIc LErivEr2bSFCAumJJanZqakFqUUwWSYOTqkGRnN2cR6md7eW/Xfm7tI1fpYk0ThXZJedy78N d3uFkm+ElM+veyCdGn+p429uuIB7J59FawdvWfXdneFLpoUESN5iu7G0Yk6X1JuzH29L7FH8 X+mX9o9ta5nfAaHipie3fc78uhbRcZQ5acfd3YEXjgbIB172atKMz5bgKk4Jm5w7tb/smKGH EktxRqKhFnNRcSIAU6VQwWQCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When lookuping for creating, we will try to record the level of current dentry hash table if current dentry has enough contiguous slots for storing name of new file which will be created later, this can save our lookup time when add a link into parent dir. But currently in find_target_dentry, our current length of contiguous free slots is not calculated correctly. This make us leaving some holes in dentry block occasionally, it wastes our space of dentry block. Let's refactor the lookup flow for max slots as following to fix this issue: a) increase max_len if current slot is free; b) update max_slots with max_len if max_len is larger than max_slots; c) reset max_len to zero if current slot is not free. Signed-off-by: Chao Yu --- fs/f2fs/dir.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 1f1a1bc..6189e57 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -127,22 +127,19 @@ struct f2fs_dir_entry *find_target_dentry(struct qstr *name, int *max_slots, *max_slots = 0; while (bit_pos < d->max) { if (!test_bit_le(bit_pos, d->bitmap)) { - if (bit_pos == 0) - max_len = 1; - else if (!test_bit_le(bit_pos - 1, d->bitmap)) - max_len++; bit_pos++; + max_len++; continue; } + de = &d->dentry[bit_pos]; if (early_match_name(name->len, namehash, de) && !memcmp(d->filename[bit_pos], name->name, name->len)) goto found; - if (max_slots && max_len > *max_slots) { + if (max_slots && max_len > *max_slots) *max_slots = max_len; - max_len = 0; - } + max_len = 0; /* remain bug on condition */ if (unlikely(!de->name_len)) -- 2.3.1