Skip to content

Commit

Permalink
Merge tag 'f2fs-for-4.21' of git://git.kernel.org/pub/scm/linux/kerne…
Browse files Browse the repository at this point in the history
…l/git/jaegeuk/f2fs

Pull f2fs updates from Jaegeuk Kim:
 "In this round, we've focused on bug fixes since Pixel devices have
  been shipping with f2fs. Some of them were related to hardware
  encryption support which are actually not an issue in mainline, but
  would be better to merge them in order to avoid potential bugs.

  Enhancements:
   - do GC sub-sections when the section is large
   - add a flag in ioctl(SHUTDOWN) to trigger fsck for QA
   - use kvmalloc() in order to give another chance to avoid ENOMEM

  Bug fixes:
   - fix accessing memory boundaries in a malformed iamge
   - GC gives stale unencrypted block
   - GC counts in large sections
   - detect idle time more precisely
   - block allocation of DIO writes
   - race conditions between write_begin and write_checkpoint
   - allow GCs for node segments via ioctl()

  There are various clean-ups and minor bug fixes as well"

* tag 'f2fs-for-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (43 commits)
  f2fs: sanity check of xattr entry size
  f2fs: fix use-after-free issue when accessing sbi->stat_info
  f2fs: check PageWriteback flag for ordered case
  f2fs: fix validation of the block count in sanity_check_raw_super
  f2fs: fix missing unlock(sbi->gc_mutex)
  f2fs: fix to dirty inode synchronously
  f2fs: clean up structure extent_node
  f2fs: fix block address for __check_sit_bitmap
  f2fs: fix sbi->extent_list corruption issue
  f2fs: clean up checkpoint flow
  f2fs: flush stale issued discard candidates
  f2fs: correct wrong spelling, issing_*
  f2fs: use kvmalloc, if kmalloc is failed
  f2fs: remove redundant comment of unused wio_mutex
  f2fs: fix to reorder set_page_dirty and wait_on_page_writeback
  f2fs: clear PG_writeback if IPU failed
  f2fs: add an ioctl() to explicitly trigger fsck later
  f2fs: avoid frequent costly fsck triggers
  f2fs: fix m_may_create to make OPU DIO write correctly
  f2fs: fix to update new block address correctly for OPU
  ...
  • Loading branch information
torvalds committed Dec 31, 2018
2 parents 1953031 + 64beba0 commit 9ab97ae
Show file tree
Hide file tree
Showing 21 changed files with 542 additions and 366 deletions.
9 changes: 9 additions & 0 deletions Documentation/ABI/testing/sysfs-fs-f2fs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ Contact: "Jaegeuk Kim" <[email protected]>
Description:
Controls the number of trials to find a victim segment.

What: /sys/fs/f2fs/<disk>/migration_granularity
Date: October 2018
Contact: "Chao Yu" <[email protected]>
Description:
Controls migration granularity of garbage collection on large
section, it can let GC move partial segment{s} of one section
in one GC cycle, so that dispersing heavy overhead GC to
multiple lightweight one.

What: /sys/fs/f2fs/<disk>/dir_level
Date: March 2014
Contact: "Jaegeuk Kim" <[email protected]>
Expand Down
20 changes: 11 additions & 9 deletions fs/f2fs/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ static void *f2fs_acl_to_disk(struct f2fs_sb_info *sbi,
return (void *)f2fs_acl;

fail:
kfree(f2fs_acl);
kvfree(f2fs_acl);
return ERR_PTR(-EINVAL);
}

Expand Down Expand Up @@ -190,7 +190,7 @@ static struct posix_acl *__f2fs_get_acl(struct inode *inode, int type,
acl = NULL;
else
acl = ERR_PTR(retval);
kfree(value);
kvfree(value);

return acl;
}
Expand Down Expand Up @@ -240,7 +240,7 @@ static int __f2fs_set_acl(struct inode *inode, int type,

error = f2fs_setxattr(inode, name_index, "", value, size, ipage, 0);

kfree(value);
kvfree(value);
if (!error)
set_cached_acl(inode, type, acl);

Expand Down Expand Up @@ -352,12 +352,14 @@ static int f2fs_acl_create(struct inode *dir, umode_t *mode,
return PTR_ERR(p);

clone = f2fs_acl_clone(p, GFP_NOFS);
if (!clone)
goto no_mem;
if (!clone) {
ret = -ENOMEM;
goto release_acl;
}

ret = f2fs_acl_create_masq(clone, mode);
if (ret < 0)
goto no_mem_clone;
goto release_clone;

if (ret == 0)
posix_acl_release(clone);
Expand All @@ -371,11 +373,11 @@ static int f2fs_acl_create(struct inode *dir, umode_t *mode,

return 0;

no_mem_clone:
release_clone:
posix_acl_release(clone);
no_mem:
release_acl:
posix_acl_release(p);
return -ENOMEM;
return ret;
}

int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,
Expand Down
33 changes: 12 additions & 21 deletions fs/f2fs/checkpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
cond_resched();
goto repeat;
}
f2fs_wait_on_page_writeback(page, META, true);
f2fs_wait_on_page_writeback(page, META, true, true);
if (!PageUptodate(page))
SetPageUptodate(page);
return page;
Expand Down Expand Up @@ -370,9 +370,8 @@ long f2fs_sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
goto continue_unlock;
}

f2fs_wait_on_page_writeback(page, META, true);
f2fs_wait_on_page_writeback(page, META, true, true);

BUG_ON(PageWriteback(page));
if (!clear_page_dirty_for_io(page))
goto continue_unlock;

Expand Down Expand Up @@ -911,7 +910,7 @@ int f2fs_get_valid_checkpoint(struct f2fs_sb_info *sbi)
f2fs_put_page(cp1, 1);
f2fs_put_page(cp2, 1);
fail_no_cp:
kfree(sbi->ckpt);
kvfree(sbi->ckpt);
return -EINVAL;
}

Expand Down Expand Up @@ -1290,11 +1289,11 @@ static void commit_checkpoint(struct f2fs_sb_info *sbi,
struct page *page = f2fs_grab_meta_page(sbi, blk_addr);
int err;

f2fs_wait_on_page_writeback(page, META, true, true);

memcpy(page_address(page), src, PAGE_SIZE);
set_page_dirty(page);

f2fs_wait_on_page_writeback(page, META, true);
f2fs_bug_on(sbi, PageWriteback(page));
set_page_dirty(page);
if (unlikely(!clear_page_dirty_for_io(page)))
f2fs_bug_on(sbi, 1);

Expand Down Expand Up @@ -1328,11 +1327,9 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
int err;

/* Flush all the NAT/SIT pages */
while (get_pages(sbi, F2FS_DIRTY_META)) {
f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
if (unlikely(f2fs_cp_error(sbi)))
break;
}
f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
f2fs_bug_on(sbi, get_pages(sbi, F2FS_DIRTY_META) &&
!f2fs_cp_error(sbi));

/*
* modify checkpoint
Expand Down Expand Up @@ -1405,14 +1402,6 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
for (i = 0; i < nm_i->nat_bits_blocks; i++)
f2fs_update_meta_page(sbi, nm_i->nat_bits +
(i << F2FS_BLKSIZE_BITS), blk + i);

/* Flush all the NAT BITS pages */
while (get_pages(sbi, F2FS_DIRTY_META)) {
f2fs_sync_meta_pages(sbi, META, LONG_MAX,
FS_CP_META_IO);
if (unlikely(f2fs_cp_error(sbi)))
break;
}
}

/* write out checkpoint buffer at block 0 */
Expand Down Expand Up @@ -1448,6 +1437,8 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)

/* Here, we have one bio having CP pack except cp pack 2 page */
f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
f2fs_bug_on(sbi, get_pages(sbi, F2FS_DIRTY_META) &&
!f2fs_cp_error(sbi));

/* wait for previous submitted meta pages writeback */
f2fs_wait_on_all_pages_writeback(sbi);
Expand All @@ -1465,7 +1456,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
* invalidate intermediate page cache borrowed from meta inode
* which are used for migration of encrypted inode's blocks.
*/
if (f2fs_sb_has_encrypt(sbi->sb))
if (f2fs_sb_has_encrypt(sbi))
invalidate_mapping_pages(META_MAPPING(sbi),
MAIN_BLKADDR(sbi), MAX_BLKADDR(sbi) - 1);

Expand Down
Loading

0 comments on commit 9ab97ae

Please sign in to comment.