aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/f2fs/dir.c21
-rw-r--r--fs/f2fs/f2fs.h1
-rw-r--r--fs/f2fs/inline.c27
3 files changed, 12 insertions, 37 deletions
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index cc6474a85d6c..164c6c911bf8 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -427,27 +427,23 @@ void update_parent_metadata(struct inode *dir, struct inode *inode,
427 clear_inode_flag(F2FS_I(inode), FI_INC_LINK); 427 clear_inode_flag(F2FS_I(inode), FI_INC_LINK);
428} 428}
429 429
430static int room_for_filename(struct f2fs_dentry_block *dentry_blk, int slots) 430int room_for_filename(const void *bitmap, int slots, int max_slots)
431{ 431{
432 int bit_start = 0; 432 int bit_start = 0;
433 int zero_start, zero_end; 433 int zero_start, zero_end;
434next: 434next:
435 zero_start = find_next_zero_bit_le(&dentry_blk->dentry_bitmap, 435 zero_start = find_next_zero_bit_le(bitmap, max_slots, bit_start);
436 NR_DENTRY_IN_BLOCK, 436 if (zero_start >= max_slots)
437 bit_start); 437 return max_slots;
438 if (zero_start >= NR_DENTRY_IN_BLOCK)
439 return NR_DENTRY_IN_BLOCK;
440 438
441 zero_end = find_next_bit_le(&dentry_blk->dentry_bitmap, 439 zero_end = find_next_bit_le(bitmap, max_slots, zero_start);
442 NR_DENTRY_IN_BLOCK,
443 zero_start);
444 if (zero_end - zero_start >= slots) 440 if (zero_end - zero_start >= slots)
445 return zero_start; 441 return zero_start;
446 442
447 bit_start = zero_end + 1; 443 bit_start = zero_end + 1;
448 444
449 if (zero_end + 1 >= NR_DENTRY_IN_BLOCK) 445 if (zero_end + 1 >= max_slots)
450 return NR_DENTRY_IN_BLOCK; 446 return max_slots;
451 goto next; 447 goto next;
452} 448}
453 449
@@ -509,7 +505,8 @@ start:
509 return PTR_ERR(dentry_page); 505 return PTR_ERR(dentry_page);
510 506
511 dentry_blk = kmap(dentry_page); 507 dentry_blk = kmap(dentry_page);
512 bit_pos = room_for_filename(dentry_blk, slots); 508 bit_pos = room_for_filename(&dentry_blk->dentry_bitmap,
509 slots, NR_DENTRY_IN_BLOCK);
513 if (bit_pos < NR_DENTRY_IN_BLOCK) 510 if (bit_pos < NR_DENTRY_IN_BLOCK)
514 goto add_dentry; 511 goto add_dentry;
515 512
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index c537699d0182..aa055e3fbd67 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1248,6 +1248,7 @@ void set_de_type(struct f2fs_dir_entry *, struct inode *);
1248struct page *init_inode_metadata(struct inode *, struct inode *, 1248struct page *init_inode_metadata(struct inode *, struct inode *,
1249 const struct qstr *); 1249 const struct qstr *);
1250void update_parent_metadata(struct inode *, struct inode *, unsigned int); 1250void update_parent_metadata(struct inode *, struct inode *, unsigned int);
1251int room_for_filename(const void *, int, int);
1251void f2fs_drop_nlink(struct inode *, struct inode *, struct page *); 1252void f2fs_drop_nlink(struct inode *, struct inode *, struct page *);
1252struct f2fs_dir_entry *f2fs_find_entry(struct inode *, struct qstr *, 1253struct f2fs_dir_entry *f2fs_find_entry(struct inode *, struct qstr *,
1253 struct page **); 1254 struct page **);
diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c
index 1fafc8561542..29090b34c768 100644
--- a/fs/f2fs/inline.c
+++ b/fs/f2fs/inline.c
@@ -363,30 +363,6 @@ int make_empty_inline_dir(struct inode *inode, struct inode *parent,
363 return 0; 363 return 0;
364} 364}
365 365
366int room_in_inline_dir(struct f2fs_inline_dentry *dentry_blk, int slots)
367{
368 int bit_start = 0;
369 int zero_start, zero_end;
370next:
371 zero_start = find_next_zero_bit_le(&dentry_blk->dentry_bitmap,
372 NR_INLINE_DENTRY,
373 bit_start);
374 if (zero_start >= NR_INLINE_DENTRY)
375 return NR_INLINE_DENTRY;
376
377 zero_end = find_next_bit_le(&dentry_blk->dentry_bitmap,
378 NR_INLINE_DENTRY,
379 zero_start);
380 if (zero_end - zero_start >= slots)
381 return zero_start;
382
383 bit_start = zero_end + 1;
384
385 if (zero_end + 1 >= NR_INLINE_DENTRY)
386 return NR_INLINE_DENTRY;
387 goto next;
388}
389
390int f2fs_convert_inline_dir(struct inode *dir, struct page *ipage, 366int f2fs_convert_inline_dir(struct inode *dir, struct page *ipage,
391 struct f2fs_inline_dentry *inline_dentry) 367 struct f2fs_inline_dentry *inline_dentry)
392{ 368{
@@ -460,7 +436,8 @@ int f2fs_add_inline_entry(struct inode *dir, const struct qstr *name,
460 return PTR_ERR(ipage); 436 return PTR_ERR(ipage);
461 437
462 dentry_blk = inline_data_addr(ipage); 438 dentry_blk = inline_data_addr(ipage);
463 bit_pos = room_in_inline_dir(dentry_blk, slots); 439 bit_pos = room_for_filename(&dentry_blk->dentry_bitmap,
440 slots, NR_INLINE_DENTRY);
464 if (bit_pos >= NR_INLINE_DENTRY) { 441 if (bit_pos >= NR_INLINE_DENTRY) {
465 err = f2fs_convert_inline_dir(dir, ipage, dentry_blk); 442 err = f2fs_convert_inline_dir(dir, ipage, dentry_blk);
466 if (!err) 443 if (!err)