Skip to content

Commit

Permalink
f2fs: fix to calculate max length of contiguous free slots correctly
Browse files Browse the repository at this point in the history
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 <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
  • Loading branch information
Chao Yu authored and Jaegeuk Kim committed Apr 10, 2015
1 parent 57ed1e9 commit bda1907
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions fs/f2fs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit bda1907

Please sign in to comment.