Commit 6e135bae authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'f2fs-for-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs

Pull f2fs updates from Jaegeuk Kim:
 "In this series, we've implemented transparent compression
  experimentally. It supports LZO and LZ4, but will add more later as we
  investigate in the field more.

  At this point, the feature doesn't expose compressed space to user
  directly in order to guarantee potential data updates later to the
  space. Instead, the main goal is to reduce data writes to flash disk
  as much as possible, resulting in extending disk life time as well as
  relaxing IO congestion.

  Alternatively, we're also considering to add ioctl() to reclaim
  compressed space and show it to user after putting the immutable bit.

  Enhancements:
   - add compression support
   - avoid unnecessary locks in quota ops
   - harden power-cut scenario for zoned block devices
   - use private bio_set to avoid IO congestion
   - replace GC mutex with rwsem to serialize callers

  Bug fixes:
   - fix dentry consistency and memory corruption in rename()'s error case
   - fix wrong swap extent reports
   - fix casefolding bugs
   - change lock coverage to avoid deadlock
   - avoid GFP_KERNEL under f2fs_lock_op

  And, we've cleaned up sysfs entries to prepare no debugfs"

* tag 'f2fs-for-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (31 commits)
  f2fs: fix race conditions in ->d_compare() and ->d_hash()
  f2fs: fix dcache lookup of !casefolded directories
  f2fs: Add f2fs stats to sysfs
  f2fs: delete duplicate information on sysfs nodes
  f2fs: change to use rwsem for gc_mutex
  f2fs: update f2fs document regarding to fsync_mode
  f2fs: add a way to turn off ipu bio cache
  f2fs: code cleanup for f2fs_statfs_project()
  f2fs: fix miscounted block limit in f2fs_statfs_project()
  f2fs: show the CP_PAUSE reason in checkpoint traces
  f2fs: fix deadlock allocating bio_post_read_ctx from mempool
  f2fs: remove unneeded check for error allocating bio_post_read_ctx
  f2fs: convert inline_dir early before starting rename
  f2fs: fix memleak of kobject
  f2fs: fix to add swap extent correctly
  f2fs: run fsck when getting bad inode during GC
  f2fs: support data compression
  f2fs: free sysfs kobject
  f2fs: declare nested quota_sem and remove unnecessary sems
  f2fs: don't put new_page twice in f2fs_rename
  ...
parents 0196be12 80f2388a
This diff is collapsed.
This diff is collapsed.
...@@ -22,7 +22,7 @@ config F2FS_FS ...@@ -22,7 +22,7 @@ config F2FS_FS
config F2FS_STAT_FS config F2FS_STAT_FS
bool "F2FS Status Information" bool "F2FS Status Information"
depends on F2FS_FS && DEBUG_FS depends on F2FS_FS
default y default y
help help
/sys/kernel/debug/f2fs/ contains information about all the partitions /sys/kernel/debug/f2fs/ contains information about all the partitions
...@@ -93,3 +93,28 @@ config F2FS_FAULT_INJECTION ...@@ -93,3 +93,28 @@ config F2FS_FAULT_INJECTION
Test F2FS to inject faults such as ENOMEM, ENOSPC, and so on. Test F2FS to inject faults such as ENOMEM, ENOSPC, and so on.
If unsure, say N. If unsure, say N.
config F2FS_FS_COMPRESSION
bool "F2FS compression feature"
depends on F2FS_FS
help
Enable filesystem-level compression on f2fs regular files,
multiple back-end compression algorithms are supported.
config F2FS_FS_LZO
bool "LZO compression support"
depends on F2FS_FS_COMPRESSION
select LZO_COMPRESS
select LZO_DECOMPRESS
default y
help
Support LZO compress algorithm, if unsure, say Y.
config F2FS_FS_LZ4
bool "LZ4 compression support"
depends on F2FS_FS_COMPRESSION
select LZ4_COMPRESS
select LZ4_DECOMPRESS
default y
help
Support LZ4 compress algorithm, if unsure, say Y.
...@@ -9,3 +9,4 @@ f2fs-$(CONFIG_F2FS_FS_XATTR) += xattr.o ...@@ -9,3 +9,4 @@ f2fs-$(CONFIG_F2FS_FS_XATTR) += xattr.o
f2fs-$(CONFIG_F2FS_FS_POSIX_ACL) += acl.o f2fs-$(CONFIG_F2FS_FS_POSIX_ACL) += acl.o
f2fs-$(CONFIG_F2FS_IO_TRACE) += trace.o f2fs-$(CONFIG_F2FS_IO_TRACE) += trace.o
f2fs-$(CONFIG_FS_VERITY) += verity.o f2fs-$(CONFIG_FS_VERITY) += verity.o
f2fs-$(CONFIG_F2FS_FS_COMPRESSION) += compress.o
...@@ -1509,10 +1509,10 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -1509,10 +1509,10 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
f2fs_wait_on_all_pages_writeback(sbi); f2fs_wait_on_all_pages_writeback(sbi);
/* /*
* invalidate intermediate page cache borrowed from meta inode * invalidate intermediate page cache borrowed from meta inode which are
* which are used for migration of encrypted inode's blocks. * used for migration of encrypted or verity inode's blocks.
*/ */
if (f2fs_sb_has_encrypt(sbi)) if (f2fs_sb_has_encrypt(sbi) || f2fs_sb_has_verity(sbi))
invalidate_mapping_pages(META_MAPPING(sbi), invalidate_mapping_pages(META_MAPPING(sbi),
MAIN_BLKADDR(sbi), MAX_BLKADDR(sbi) - 1); MAIN_BLKADDR(sbi), MAX_BLKADDR(sbi) - 1);
......
This diff is collapsed.
This diff is collapsed.
...@@ -21,9 +21,45 @@ ...@@ -21,9 +21,45 @@
#include "gc.h" #include "gc.h"
static LIST_HEAD(f2fs_stat_list); static LIST_HEAD(f2fs_stat_list);
static struct dentry *f2fs_debugfs_root;
static DEFINE_MUTEX(f2fs_stat_mutex); static DEFINE_MUTEX(f2fs_stat_mutex);
#ifdef CONFIG_DEBUG_FS
static struct dentry *f2fs_debugfs_root;
#endif
/*
* This function calculates BDF of every segments
*/
void f2fs_update_sit_info(struct f2fs_sb_info *sbi)
{
struct f2fs_stat_info *si = F2FS_STAT(sbi);
unsigned long long blks_per_sec, hblks_per_sec, total_vblocks;
unsigned long long bimodal, dist;
unsigned int segno, vblocks;
int ndirty = 0;
bimodal = 0;
total_vblocks = 0;
blks_per_sec = BLKS_PER_SEC(sbi);
hblks_per_sec = blks_per_sec / 2;
for (segno = 0; segno < MAIN_SEGS(sbi); segno += sbi->segs_per_sec) {
vblocks = get_valid_blocks(sbi, segno, true);
dist = abs(vblocks - hblks_per_sec);
bimodal += dist * dist;
if (vblocks > 0 && vblocks < blks_per_sec) {
total_vblocks += vblocks;
ndirty++;
}
}
dist = div_u64(MAIN_SECS(sbi) * hblks_per_sec * hblks_per_sec, 100);
si->bimodal = div64_u64(bimodal, dist);
if (si->dirty_count)
si->avg_vblocks = div_u64(total_vblocks, ndirty);
else
si->avg_vblocks = 0;
}
#ifdef CONFIG_DEBUG_FS
static void update_general_status(struct f2fs_sb_info *sbi) static void update_general_status(struct f2fs_sb_info *sbi)
{ {
struct f2fs_stat_info *si = F2FS_STAT(sbi); struct f2fs_stat_info *si = F2FS_STAT(sbi);
...@@ -56,7 +92,7 @@ static void update_general_status(struct f2fs_sb_info *sbi) ...@@ -56,7 +92,7 @@ static void update_general_status(struct f2fs_sb_info *sbi)
si->nquota_files = sbi->nquota_files; si->nquota_files = sbi->nquota_files;
si->ndirty_all = sbi->ndirty_inode[DIRTY_META]; si->ndirty_all = sbi->ndirty_inode[DIRTY_META];
si->inmem_pages = get_pages(sbi, F2FS_INMEM_PAGES); si->inmem_pages = get_pages(sbi, F2FS_INMEM_PAGES);
si->aw_cnt = atomic_read(&sbi->aw_cnt); si->aw_cnt = sbi->atomic_files;
si->vw_cnt = atomic_read(&sbi->vw_cnt); si->vw_cnt = atomic_read(&sbi->vw_cnt);
si->max_aw_cnt = atomic_read(&sbi->max_aw_cnt); si->max_aw_cnt = atomic_read(&sbi->max_aw_cnt);
si->max_vw_cnt = atomic_read(&sbi->max_vw_cnt); si->max_vw_cnt = atomic_read(&sbi->max_vw_cnt);
...@@ -94,6 +130,8 @@ static void update_general_status(struct f2fs_sb_info *sbi) ...@@ -94,6 +130,8 @@ static void update_general_status(struct f2fs_sb_info *sbi)
si->inline_xattr = atomic_read(&sbi->inline_xattr); si->inline_xattr = atomic_read(&sbi->inline_xattr);
si->inline_inode = atomic_read(&sbi->inline_inode); si->inline_inode = atomic_read(&sbi->inline_inode);
si->inline_dir = atomic_read(&sbi->inline_dir); si->inline_dir = atomic_read(&sbi->inline_dir);
si->compr_inode = atomic_read(&sbi->compr_inode);
si->compr_blocks = atomic_read(&sbi->compr_blocks);
si->append = sbi->im[APPEND_INO].ino_num; si->append = sbi->im[APPEND_INO].ino_num;
si->update = sbi->im[UPDATE_INO].ino_num; si->update = sbi->im[UPDATE_INO].ino_num;
si->orphans = sbi->im[ORPHAN_INO].ino_num; si->orphans = sbi->im[ORPHAN_INO].ino_num;
...@@ -114,7 +152,6 @@ static void update_general_status(struct f2fs_sb_info *sbi) ...@@ -114,7 +152,6 @@ static void update_general_status(struct f2fs_sb_info *sbi)
si->free_nids = NM_I(sbi)->nid_cnt[FREE_NID]; si->free_nids = NM_I(sbi)->nid_cnt[FREE_NID];
si->avail_nids = NM_I(sbi)->available_nids; si->avail_nids = NM_I(sbi)->available_nids;
si->alloc_nids = NM_I(sbi)->nid_cnt[PREALLOC_NID]; si->alloc_nids = NM_I(sbi)->nid_cnt[PREALLOC_NID];
si->bg_gc = sbi->bg_gc;
si->io_skip_bggc = sbi->io_skip_bggc; si->io_skip_bggc = sbi->io_skip_bggc;
si->other_skip_bggc = sbi->other_skip_bggc; si->other_skip_bggc = sbi->other_skip_bggc;
si->skipped_atomic_files[BG_GC] = sbi->skipped_atomic_files[BG_GC]; si->skipped_atomic_files[BG_GC] = sbi->skipped_atomic_files[BG_GC];
...@@ -145,39 +182,6 @@ static void update_general_status(struct f2fs_sb_info *sbi) ...@@ -145,39 +182,6 @@ static void update_general_status(struct f2fs_sb_info *sbi)
si->inplace_count = atomic_read(&sbi->inplace_count); si->inplace_count = atomic_read(&sbi->inplace_count);
} }
/*
* This function calculates BDF of every segments
*/
static void update_sit_info(struct f2fs_sb_info *sbi)
{
struct f2fs_stat_info *si = F2FS_STAT(sbi);
unsigned long long blks_per_sec, hblks_per_sec, total_vblocks;
unsigned long long bimodal, dist;
unsigned int segno, vblocks;
int ndirty = 0;
bimodal = 0;
total_vblocks = 0;
blks_per_sec = BLKS_PER_SEC(sbi);
hblks_per_sec = blks_per_sec / 2;
for (segno = 0; segno < MAIN_SEGS(sbi); segno += sbi->segs_per_sec) {
vblocks = get_valid_blocks(sbi, segno, true);
dist = abs(vblocks - hblks_per_sec);
bimodal += dist * dist;
if (vblocks > 0 && vblocks < blks_per_sec) {
total_vblocks += vblocks;
ndirty++;
}
}
dist = div_u64(MAIN_SECS(sbi) * hblks_per_sec * hblks_per_sec, 100);
si->bimodal = div64_u64(bimodal, dist);
if (si->dirty_count)
si->avg_vblocks = div_u64(total_vblocks, ndirty);
else
si->avg_vblocks = 0;
}
/* /*
* This function calculates memory footprint. * This function calculates memory footprint.
*/ */
...@@ -315,6 +319,8 @@ static int stat_show(struct seq_file *s, void *v) ...@@ -315,6 +319,8 @@ static int stat_show(struct seq_file *s, void *v)
si->inline_inode); si->inline_inode);
seq_printf(s, " - Inline_dentry Inode: %u\n", seq_printf(s, " - Inline_dentry Inode: %u\n",
si->inline_dir); si->inline_dir);
seq_printf(s, " - Compressed Inode: %u, Blocks: %u\n",
si->compr_inode, si->compr_blocks);
seq_printf(s, " - Orphan/Append/Update Inode: %u, %u, %u\n", seq_printf(s, " - Orphan/Append/Update Inode: %u, %u, %u\n",
si->orphans, si->append, si->update); si->orphans, si->append, si->update);
seq_printf(s, "\nMain area: %d segs, %d secs %d zones\n", seq_printf(s, "\nMain area: %d segs, %d secs %d zones\n",
...@@ -441,7 +447,7 @@ static int stat_show(struct seq_file *s, void *v) ...@@ -441,7 +447,7 @@ static int stat_show(struct seq_file *s, void *v)
si->block_count[LFS], si->segment_count[LFS]); si->block_count[LFS], si->segment_count[LFS]);
/* segment usage info */ /* segment usage info */
update_sit_info(si->sbi); f2fs_update_sit_info(si->sbi);
seq_printf(s, "\nBDF: %u, avg. vblocks: %u\n", seq_printf(s, "\nBDF: %u, avg. vblocks: %u\n",
si->bimodal, si->avg_vblocks); si->bimodal, si->avg_vblocks);
...@@ -461,6 +467,7 @@ static int stat_show(struct seq_file *s, void *v) ...@@ -461,6 +467,7 @@ static int stat_show(struct seq_file *s, void *v)
} }
DEFINE_SHOW_ATTRIBUTE(stat); DEFINE_SHOW_ATTRIBUTE(stat);
#endif
int f2fs_build_stats(struct f2fs_sb_info *sbi) int f2fs_build_stats(struct f2fs_sb_info *sbi)
{ {
...@@ -491,11 +498,12 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi) ...@@ -491,11 +498,12 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
atomic_set(&sbi->inline_xattr, 0); atomic_set(&sbi->inline_xattr, 0);
atomic_set(&sbi->inline_inode, 0); atomic_set(&sbi->inline_inode, 0);
atomic_set(&sbi->inline_dir, 0); atomic_set(&sbi->inline_dir, 0);
atomic_set(&sbi->compr_inode, 0);
atomic_set(&sbi->compr_blocks, 0);
atomic_set(&sbi->inplace_count, 0); atomic_set(&sbi->inplace_count, 0);
for (i = META_CP; i < META_MAX; i++) for (i = META_CP; i < META_MAX; i++)
atomic_set(&sbi->meta_count[i], 0); atomic_set(&sbi->meta_count[i], 0);
atomic_set(&sbi->aw_cnt, 0);
atomic_set(&sbi->vw_cnt, 0); atomic_set(&sbi->vw_cnt, 0);
atomic_set(&sbi->max_aw_cnt, 0); atomic_set(&sbi->max_aw_cnt, 0);
atomic_set(&sbi->max_vw_cnt, 0); atomic_set(&sbi->max_vw_cnt, 0);
...@@ -520,14 +528,18 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi) ...@@ -520,14 +528,18 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
void __init f2fs_create_root_stats(void) void __init f2fs_create_root_stats(void)
{ {
#ifdef CONFIG_DEBUG_FS
f2fs_debugfs_root = debugfs_create_dir("f2fs", NULL); f2fs_debugfs_root = debugfs_create_dir("f2fs", NULL);
debugfs_create_file("status", S_IRUGO, f2fs_debugfs_root, NULL, debugfs_create_file("status", S_IRUGO, f2fs_debugfs_root, NULL,
&stat_fops); &stat_fops);
#endif
} }
void f2fs_destroy_root_stats(void) void f2fs_destroy_root_stats(void)
{ {
#ifdef CONFIG_DEBUG_FS
debugfs_remove_recursive(f2fs_debugfs_root); debugfs_remove_recursive(f2fs_debugfs_root);
f2fs_debugfs_root = NULL; f2fs_debugfs_root = NULL;
#endif
} }
...@@ -578,6 +578,20 @@ int f2fs_room_for_filename(const void *bitmap, int slots, int max_slots) ...@@ -578,6 +578,20 @@ int f2fs_room_for_filename(const void *bitmap, int slots, int max_slots)
goto next; goto next;
} }
bool f2fs_has_enough_room(struct inode *dir, struct page *ipage,
struct fscrypt_name *fname)
{
struct f2fs_dentry_ptr d;
unsigned int bit_pos;
int slots = GET_DENTRY_SLOTS(fname_len(fname));
make_dentry_ptr_inline(dir, &d, inline_data_addr(dir, ipage));
bit_pos = f2fs_room_for_filename(d.bitmap, slots, d.max);
return bit_pos < d.max;
}
void f2fs_update_dentry(nid_t ino, umode_t mode, struct f2fs_dentry_ptr *d, void f2fs_update_dentry(nid_t ino, umode_t mode, struct f2fs_dentry_ptr *d,
const struct qstr *name, f2fs_hash_t name_hash, const struct qstr *name, f2fs_hash_t name_hash,
unsigned int bit_pos) unsigned int bit_pos)
...@@ -1069,24 +1083,27 @@ static int f2fs_d_compare(const struct dentry *dentry, unsigned int len, ...@@ -1069,24 +1083,27 @@ static int f2fs_d_compare(const struct dentry *dentry, unsigned int len,
const char *str, const struct qstr *name) const char *str, const struct qstr *name)
{ {
struct qstr qstr = {.name = str, .len = len }; struct qstr qstr = {.name = str, .len = len };
const struct dentry *parent = READ_ONCE(dentry->d_parent);
const struct inode *inode = READ_ONCE(parent->d_inode);
if (!IS_CASEFOLDED(dentry->d_parent->d_inode)) { if (!inode || !IS_CASEFOLDED(inode)) {
if (len != name->len) if (len != name->len)
return -1; return -1;
return memcmp(str, name, len); return memcmp(str, name->name, len);
} }
return f2fs_ci_compare(dentry->d_parent->d_inode, name, &qstr, false); return f2fs_ci_compare(inode, name, &qstr, false);
} }
static int f2fs_d_hash(const struct dentry *dentry, struct qstr *str) static int f2fs_d_hash(const struct dentry *dentry, struct qstr *str)
{ {
struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb); struct f2fs_sb_info *sbi = F2FS_SB(dentry->d_sb);
const struct unicode_map *um = sbi->s_encoding; const struct unicode_map *um = sbi->s_encoding;
const struct inode *inode = READ_ONCE(dentry->d_inode);
unsigned char *norm; unsigned char *norm;
int len, ret = 0; int len, ret = 0;
if (!IS_CASEFOLDED(dentry->d_inode)) if (!inode || !IS_CASEFOLDED(inode))
return 0; return 0;
norm = f2fs_kmalloc(sbi, PATH_MAX, GFP_ATOMIC); norm = f2fs_kmalloc(sbi, PATH_MAX, GFP_ATOMIC);
......
This diff is collapsed.
This diff is collapsed.
...@@ -78,18 +78,18 @@ static int gc_thread_func(void *data) ...@@ -78,18 +78,18 @@ static int gc_thread_func(void *data)
*/ */
if (sbi->gc_mode == GC_URGENT) { if (sbi->gc_mode == GC_URGENT) {
wait_ms = gc_th->urgent_sleep_time; wait_ms = gc_th->urgent_sleep_time;
mutex_lock(&sbi->gc_mutex); down_write(&sbi->gc_lock);
goto do_gc; goto do_gc;
} }
if (!mutex_trylock(&sbi->gc_mutex)) { if (!down_write_trylock(&sbi->gc_lock)) {
stat_other_skip_bggc_count(sbi); stat_other_skip_bggc_count(sbi);
goto next; goto next;
} }
if (!is_idle(sbi, GC_TIME)) { if (!is_idle(sbi, GC_TIME)) {
increase_sleep_time(gc_th, &wait_ms); increase_sleep_time(gc_th, &wait_ms);
mutex_unlock(&sbi->gc_mutex); up_write(&sbi->gc_lock);
stat_io_skip_bggc_count(sbi); stat_io_skip_bggc_count(sbi);
goto next; goto next;
} }
...@@ -99,7 +99,7 @@ static int gc_thread_func(void *data) ...@@ -99,7 +99,7 @@ static int gc_thread_func(void *data)
else else
increase_sleep_time(gc_th, &wait_ms); increase_sleep_time(gc_th, &wait_ms);
do_gc: do_gc:
stat_inc_bggc_count(sbi); stat_inc_bggc_count(sbi->stat_info);
/* if return value is not zero, no victim was selected */ /* if return value is not zero, no victim was selected */
if (f2fs_gc(sbi, test_opt(sbi, FORCE_FG_GC), true, NULL_SEGNO)) if (f2fs_gc(sbi, test_opt(sbi, FORCE_FG_GC), true, NULL_SEGNO))
...@@ -1049,8 +1049,10 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, ...@@ -1049,8 +1049,10 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
if (phase == 3) { if (phase == 3) {
inode = f2fs_iget(sb, dni.ino); inode = f2fs_iget(sb, dni.ino);
if (IS_ERR(inode) || is_bad_inode(inode)) if (IS_ERR(inode) || is_bad_inode(inode)) {
set_sbi_flag(sbi, SBI_NEED_FSCK);
continue; continue;
}
if (!down_write_trylock( if (!down_write_trylock(
&F2FS_I(inode)->i_gc_rwsem[WRITE])) { &F2FS_I(inode)->i_gc_rwsem[WRITE])) {
...@@ -1368,7 +1370,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, ...@@ -1368,7 +1370,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
reserved_segments(sbi), reserved_segments(sbi),
prefree_segments(sbi)); prefree_segments(sbi));
mutex_unlock(&sbi->gc_mutex); up_write(&sbi->gc_lock);
put_gc_inode(&gc_list); put_gc_inode(&gc_list);
...@@ -1407,9 +1409,9 @@ static int free_segment_range(struct f2fs_sb_info *sbi, unsigned int start, ...@@ -1407,9 +1409,9 @@ static int free_segment_range(struct f2fs_sb_info *sbi, unsigned int start,
.iroot = RADIX_TREE_INIT(gc_list.iroot, GFP_NOFS), .iroot = RADIX_TREE_INIT(gc_list.iroot, GFP_NOFS),
}; };
mutex_lock(&sbi->gc_mutex); down_write(&sbi->gc_lock);
do_garbage_collect(sbi, segno, &gc_list, FG_GC); do_garbage_collect(sbi, segno, &gc_list, FG_GC);
mutex_unlock(&sbi->gc_mutex); up_write(&sbi->gc_lock);
put_gc_inode(&gc_list); put_gc_inode(&gc_list);
if (get_valid_blocks(sbi, segno, true)) if (get_valid_blocks(sbi, segno, true))
......
...@@ -368,7 +368,7 @@ static int f2fs_move_inline_dirents(struct inode *dir, struct page *ipage, ...@@ -368,7 +368,7 @@ static int f2fs_move_inline_dirents(struct inode *dir, struct page *ipage,
struct f2fs_dentry_ptr src, dst; struct f2fs_dentry_ptr src, dst;
int err; int err;
page = f2fs_grab_cache_page(dir->i_mapping, 0, false); page = f2fs_grab_cache_page(dir->i_mapping, 0, true);
if (!page) { if (!page) {
f2fs_put_page(ipage, 1); f2fs_put_page(ipage, 1);
return -ENOMEM; return -ENOMEM;
...@@ -530,7 +530,7 @@ static int f2fs_move_rehashed_dirents(struct inode *dir, struct page *ipage, ...@@ -530,7 +530,7 @@ static int f2fs_move_rehashed_dirents(struct inode *dir, struct page *ipage,
return err; return err;
} }
static int f2fs_convert_inline_dir(struct inode *dir, struct page *ipage, static int do_convert_inline_dir(struct inode *dir, struct page *ipage,
void *inline_dentry) void *inline_dentry)
{ {
if (!F2FS_I(dir)->i_dir_level) if (!F2FS_I(dir)->i_dir_level)
...@@ -539,6 +539,44 @@ static int f2fs_convert_inline_dir(struct inode *dir, struct page *ipage, ...@@ -539,6 +539,44 @@ static int f2fs_convert_inline_dir(struct inode *dir, struct page *ipage,
return f2fs_move_rehashed_dirents(dir, ipage, inline_dentry); return f2fs_move_rehashed_dirents(dir, ipage, inline_dentry);
} }
int f2fs_try_convert_inline_dir(struct inode *dir, struct dentry *dentry)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
struct page *ipage;
struct fscrypt_name fname;
void *inline_dentry = NULL;
int err = 0;
if (!f2fs_has_inline_dentry(dir))
return 0;
f2fs_lock_op(sbi);
err = fscrypt_setup_filename(dir, &dentry->d_name, 0, &fname);
if (err)
goto out;
ipage = f2fs_get_node_page(sbi, dir->i_ino);
if (IS_ERR(ipage)) {
err = PTR_ERR(ipage);
goto out;
}
if (f2fs_has_enough_room(dir, ipage, &fname)) {
f2fs_put_page(ipage, 1);
goto out;
}
inline_dentry = inline_data_addr(dir, ipage);
err = do_convert_inline_dir(dir, ipage, inline_dentry);
if (!err)
f2fs_put_page(ipage, 1);
out:
f2fs_unlock_op(sbi);
return err;
}
int f2fs_add_inline_entry(struct inode *dir, const struct qstr *new_name, int f2fs_add_inline_entry(struct inode *dir, const struct qstr *new_name,
const struct qstr *orig_name, const struct qstr *orig_name,
struct inode *inode, nid_t ino, umode_t mode) struct inode *inode, nid_t ino, umode_t mode)
...@@ -562,7 +600,7 @@ int f2fs_add_inline_entry(struct inode *dir, const struct qstr *new_name, ...@@ -562,7 +600,7 @@ int f2fs_add_inline_entry(struct inode *dir, const struct qstr *new_name,
bit_pos = f2fs_room_for_filename(d.bitmap, slots, d.max); bit_pos = f2fs_room_for_filename(d.bitmap, slots, d.max);
if (bit_pos >= d.max) { if (bit_pos >= d.max) {
err = f2fs_convert_inline_dir(dir, ipage, inline_dentry); err = do_convert_inline_dir(dir, ipage, inline_dentry);
if (err) if (err)
return err; return err;
err = -EAGAIN; err = -EAGAIN;
......
...@@ -200,6 +200,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page) ...@@ -200,6 +200,7 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
{ {
struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
struct f2fs_inode_info *fi = F2FS_I(inode); struct f2fs_inode_info *fi = F2FS_I(inode);
struct f2fs_inode *ri = F2FS_INODE(node_page);
unsigned long long iblocks; unsigned long long iblocks;
iblocks = le64_to_cpu(F2FS_INODE(node_page)->i_blocks); iblocks = le64_to_cpu(F2FS_INODE(node_page)->i_blocks);
...@@ -286,6 +287,19 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page) ...@@ -286,6 +287,19 @@ static bool sanity_check_inode(struct inode *inode, struct page *node_page)
return false; return false;
} }
if (f2fs_has_extra_attr(inode) && f2fs_sb_has_compression(sbi) &&
fi->i_flags & F2FS_COMPR_FL &&
F2FS_FITS_IN_INODE(ri, fi->i_extra_isize,
i_log_cluster_size)) {
if (ri->i_compress_algorithm >= COMPRESS_MAX)
return false;
if (le64_to_cpu(ri->i_compr_blocks) > inode->i_blocks)
return false;
if (ri->i_log_cluster_size < MIN_COMPRESS_LOG_SIZE ||
ri->i_log_cluster_size > MAX_COMPRESS_LOG_SIZE)
return false;
}
return true; return true;
} }
...@@ -407,6 +421,18 @@ static int do_read_inode(struct inode *inode) ...@@ -407,6 +421,18 @@ static int do_read_inode(struct inode *inode)
fi->i_crtime.tv_nsec = le32_to_cpu(ri->i_crtime_nsec); fi->i_crtime.tv_nsec = le32_to_cpu(ri->i_crtime_nsec);
} }
if (f2fs_has_extra_attr(inode) && f2fs_sb_has_compression(sbi) &&
(fi->i_flags & F2FS_COMPR_FL)) {
if (F2FS_FITS_IN_INODE(ri, fi->i_extra_isize,
i_log_cluster_size)) {
fi->i_compr_blocks = le64_to_cpu(ri->i_compr_blocks);
fi->i_compress_algorithm = ri->i_compress_algorithm;
fi->i_log_cluster_size = ri->i_log_cluster_size;
fi->i_cluster_size = 1 << fi->i_log_cluster_size;
set_inode_flag(inode, FI_COMPRESSED_FILE);
}
}
F2FS_I(inode)->i_disk_time[0] = inode->i_atime; F2FS_I(inode)->i_disk_time[0] = inode->i_atime;
F2FS_I(inode)->i_disk_time[1] = inode->i_ctime; F2FS_I(inode)->i_disk_time[1] = inode->i_ctime;
F2FS_I(inode)->i_disk_time[2] = inode->i_mtime; F2FS_I(inode)->i_disk_time[2] = inode->i_mtime;
...@@ -416,6 +442,8 @@ static int do_read_inode(struct inode *inode) ...@@ -416,6 +442,8 @@ static int do_read_inode(struct inode *inode)
stat_inc_inline_xattr(inode); stat_inc_inline_xattr(inode);
stat_inc_inline_inode(inode); stat_inc_inline_inode(inode);
stat_inc_inline_dir(inode); stat_inc_inline_dir(inode);
stat_inc_compr_inode(inode);
stat_add_compr_blocks(inode, F2FS_I(inode)->i_compr_blocks);
return 0; return 0;
} }
...@@ -569,6 +597,17 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page) ...@@ -569,6 +597,17 @@ void f2fs_update_inode(struct inode *inode, struct page *node_page)
ri->i_crtime_nsec = ri->i_crtime_nsec =
cpu_to_le32(F2FS_I(inode)->i_crtime.tv_nsec); cpu_to_le32(F2FS_I(inode)->i_crtime.tv_nsec);
} }
if (f2fs_sb_has_compression(F2FS_I_SB(inode)) &&
F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize,
i_log_cluster_size)) {
ri->i_compr_blocks =
cpu_to_le64(F2FS_I(inode)->i_compr_blocks);
ri->i_compress_algorithm =
F2FS_I(inode)->i_compress_algorithm;
ri->i_log_cluster_size =
F2FS_I(inode)->i_log_cluster_size;
}
} }
__set_inode_rdev(inode, ri); __set_inode_rdev(inode, ri);
...@@ -711,6 +750,8 @@ void f2fs_evict_inode(struct inode *inode) ...@@ -711,6 +750,8 @@ void f2fs_evict_inode(struct inode *inode)
stat_dec_inline_xattr(inode); stat_dec_inline_xattr(inode);
stat_dec_inline_dir(inode); stat_dec_inline_dir(inode);
stat_dec_inline_inode(inode); stat_dec_inline_inode(inode);
stat_dec_compr_inode(inode);
stat_sub_compr_blocks(inode, F2FS_I(inode)->i_compr_blocks);
if (likely(!f2fs_cp_error(sbi) && if (likely(!f2fs_cp_error(sbi) &&
!is_sbi_flag_set(sbi, SBI_CP_DISABLED))) !is_sbi_flag_set(sbi, SBI_CP_DISABLED)))
......
...@@ -119,6 +119,13 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) ...@@ -119,6 +119,13 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
if (F2FS_I(inode)->i_flags & F2FS_PROJINHERIT_FL) if (F2FS_I(inode)->i_flags & F2FS_PROJINHERIT_FL)
set_inode_flag(inode, FI_PROJ_INHERIT); set_inode_flag(inode, FI_PROJ_INHERIT);
if (f2fs_sb_has_compression(sbi)) {
/* Inherit the compression flag in directory */
if ((F2FS_I(dir)->i_flags & F2FS_COMPR_FL) &&
f2fs_may_compress(inode))
set_compress_context(inode);
}
f2fs_set_inode_flags(inode); f2fs_set_inode_flags(inode);
trace_f2fs_new_inode(inode, 0); trace_f2fs_new_inode(inode, 0);
...@@ -149,6 +156,9 @@ static inline int is_extension_exist(const unsigned char *s, const char *sub) ...@@ -149,6 +156,9 @@ static inline int is_extension_exist(const unsigned char *s, const char *sub)
size_t sublen = strlen(sub); size_t sublen = strlen(sub);
int i; int i;
if (sublen == 1 && *sub == '*')
return 1;
/* /*
* filename format of multimedia file should be defined as: * filename format of multimedia file should be defined as:
* "filename + '.' + extension + (optional: '.' + temp extension)". * "filename + '.' + extension + (optional: '.' + temp extension)".
...@@ -262,6 +272,45 @@ int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name, ...@@ -262,6 +272,45 @@ int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
return 0; return 0;
} }
static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode,
const unsigned char *name)
{
__u8 (*extlist)[F2FS_EXTENSION_LEN] = sbi->raw_super->extension_list;
unsigned char (*ext)[F2FS_EXTENSION_LEN];
unsigned int ext_cnt = F2FS_OPTION(sbi).compress_ext_cnt;
int i, cold_count, hot_count;
if (!f2fs_sb_has_compression(sbi) ||
is_inode_flag_set(inode, FI_COMPRESSED_FILE) ||
F2FS_I(inode)->i_flags & F2FS_NOCOMP_FL ||
!f2fs_may_compress(inode))
return;
down_read(&sbi->sb_lock);
cold_count = le32_to_cpu(sbi->raw_super->extension_count);
hot_count = sbi->raw_super->hot_ext_count;
for (i = cold_count; i < cold_count + hot_count; i++) {
if (is_extension_exist(name, extlist[i])) {
up_read(&sbi->sb_lock);
return;
}
}
up_read(&sbi->sb_lock);
ext = F2FS_OPTION(sbi).extensions;
for (i = 0; i < ext_cnt; i++) {
if (!is_extension_exist(name, ext[i]))
continue;
set_compress_context(inode);
return;
}
}
static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
bool excl) bool excl)
{ {
...@@ -286,6 +335,8 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, ...@@ -286,6 +335,8 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
if (!test_opt(sbi, DISABLE_EXT_IDENTIFY)) if (!test_opt(sbi, DISABLE_EXT_IDENTIFY))
set_file_temperature(sbi, inode, dentry->d_name.name); set_file_temperature(sbi, inode, dentry->d_name.name);
set_compress_inode(sbi, inode, dentry->d_name.name);
inode->i_op = &f2fs_file_inode_operations; inode->i_op = &f2fs_file_inode_operations;
inode->i_fop = &f2fs_file_operations; inode->i_fop = &f2fs_file_operations;
inode->i_mapping->a_ops = &f2fs_dblock_aops; inode->i_mapping->a_ops = &f2fs_dblock_aops;
...@@ -797,6 +848,7 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry, ...@@ -797,6 +848,7 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
if (whiteout) { if (whiteout) {
f2fs_i_links_write(inode, false); f2fs_i_links_write(inode, false);
inode->i_state |= I_LINKABLE;
*whiteout = inode; *whiteout = inode;
} else { } else {
d_tmpfile(dentry, inode); d_tmpfile(dentry, inode);
...@@ -849,12 +901,11 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -849,12 +901,11 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
struct inode *old_inode = d_inode(old_dentry); struct inode *old_inode = d_inode(old_dentry);
struct inode *new_inode = d_inode(new_dentry); struct inode *new_inode = d_inode(new_dentry);
struct inode *whiteout = NULL; struct inode *whiteout = NULL;
struct page *old_dir_page; struct page *old_dir_page = NULL;
struct page *old_page, *new_page = NULL; struct page *old_page, *new_page = NULL;
struct f2fs_dir_entry *old_dir_entry = NULL; struct f2fs_dir_entry *old_dir_entry = NULL;
struct f2fs_dir_entry *old_entry; struct f2fs_dir_entry *old_entry;
struct f2fs_dir_entry *new_entry; struct f2fs_dir_entry *new_entry;
bool is_old_inline = f2fs_has_inline_dentry(old_dir);
int err; int err;
if (unlikely(f2fs_cp_error(sbi))) if (unlikely(f2fs_cp_error(sbi)))
...@@ -867,6 +918,26 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -867,6 +918,26 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
F2FS_I(old_dentry->d_inode)->i_projid))) F2FS_I(old_dentry->d_inode)->i_projid)))
return -EXDEV; return -EXDEV;
/*
* If new_inode is null, the below renaming flow will
* add a link in old_dir which can conver inline_dir.
* After then, if we failed to get the entry due to other
* reasons like ENOMEM, we had to remove the new entry.
* Instead of adding such the error handling routine, let's
* simply convert first here.
*/
if (old_dir == new_dir && !new_inode) {
err = f2fs_try_convert_inline_dir(old_dir, new_dentry);
if (err)
return err;
}
if (flags & RENAME_WHITEOUT) {
err = f2fs_create_whiteout(old_dir, &whiteout);
if (err)
return err;
}
err = dquot_initialize(old_dir); err = dquot_initialize(old_dir);
if (err) if (err)
goto out; goto out;
...@@ -898,17 +969,11 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -898,17 +969,11 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
} }
} }
if (flags & RENAME_WHITEOUT) {
err = f2fs_create_whiteout(old_dir, &whiteout);
if (err)
goto out_dir;
}
if (new_inode) { if (new_inode) {
err = -ENOTEMPTY; err = -ENOTEMPTY;
if (old_dir_entry && !f2fs_empty_dir(new_inode)) if (old_dir_entry && !f2fs_empty_dir(new_inode))
goto out_whiteout; goto out_dir;
err = -ENOENT; err = -ENOENT;
new_entry = f2fs_find_entry(new_dir, &new_dentry->d_name, new_entry = f2fs_find_entry(new_dir, &new_dentry->d_name,
...@@ -916,7 +981,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -916,7 +981,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (!new_entry) { if (!new_entry) {
if (IS_ERR(new_page)) if (IS_ERR(new_page))
err = PTR_ERR(new_page); err = PTR_ERR(new_page);
goto out_whiteout; goto out_dir;
} }
f2fs_balance_fs(sbi, true); f2fs_balance_fs(sbi, true);
...@@ -928,6 +993,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -928,6 +993,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
goto put_out_dir; goto put_out_dir;
f2fs_set_link(new_dir, new_entry, new_page, old_inode); f2fs_set_link(new_dir, new_entry, new_page, old_inode);
new_page = NULL;
new_inode->i_ctime = current_time(new_inode); new_inode->i_ctime = current_time(new_inode);
down_write(&F2FS_I(new_inode)->i_sem); down_write(&F2FS_I(new_inode)->i_sem);
...@@ -948,33 +1014,11 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -948,33 +1014,11 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
err = f2fs_add_link(new_dentry, old_inode); err = f2fs_add_link(new_dentry, old_inode);
if (err) { if (err) {
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
goto out_whiteout; goto out_dir;
} }
if (old_dir_entry) if (old_dir_entry)
f2fs_i_links_write(new_dir, true); f2fs_i_links_write(new_dir, true);
/*
* old entry and new entry can locate in the same inline
* dentry in inode, when attaching new entry in inline dentry,
* it could force inline dentry conversion, after that,
* old_entry and old_page will point to wrong address, in
* order to avoid this, let's do the check and update here.
*/
if (is_old_inline && !f2fs_has_inline_dentry(old_dir)) {
f2fs_put_page(old_page, 0);
old_page = NULL;
old_entry = f2fs_find_entry(old_dir,
&old_dentry->d_name, &old_page);
if (!old_entry) {
err = -ENOENT;
if (IS_ERR(old_page))
err = PTR_ERR(old_page);
f2fs_unlock_op(sbi);
goto out_whiteout;
}
}
} }
down_write(&F2FS_I(old_inode)->i_sem); down_write(&F2FS_I(old_inode)->i_sem);
...@@ -989,9 +1033,9 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -989,9 +1033,9 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
f2fs_mark_inode_dirty_sync(old_inode, false); f2fs_mark_inode_dirty_sync(old_inode, false);
f2fs_delete_entry(old_entry, old_page, old_dir, NULL); f2fs_delete_entry(old_entry, old_page, old_dir, NULL);
old_page = NULL;
if (whiteout) { if (whiteout) {
whiteout->i_state |= I_LINKABLE;
set_inode_flag(whiteout, FI_INC_LINK); set_inode_flag(whiteout, FI_INC_LINK);
err = f2fs_add_link(old_dentry, whiteout); err = f2fs_add_link(old_dentry, whiteout);
if (err) if (err)
...@@ -1025,17 +1069,15 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1025,17 +1069,15 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
put_out_dir: put_out_dir:
f2fs_unlock_op(sbi); f2fs_unlock_op(sbi);
if (new_page)
f2fs_put_page(new_page, 0); f2fs_put_page(new_page, 0);
out_whiteout:
if (whiteout)
iput(whiteout);
out_dir: out_dir:
if (old_dir_entry) if (old_dir_entry)
f2fs_put_page(old_dir_page, 0); f2fs_put_page(old_dir_page, 0);
out_old: out_old:
f2fs_put_page(old_page, 0); f2fs_put_page(old_page, 0);
out: out:
if (whiteout)
iput(whiteout);
return err; return err;
} }
......
...@@ -723,6 +723,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) ...@@ -723,6 +723,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
int ret = 0; int ret = 0;
unsigned long s_flags = sbi->sb->s_flags; unsigned long s_flags = sbi->sb->s_flags;
bool need_writecp = false; bool need_writecp = false;
bool fix_curseg_write_pointer = false;
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
int quota_enabled; int quota_enabled;
#endif #endif
...@@ -774,6 +775,8 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) ...@@ -774,6 +775,8 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
sbi->sb->s_flags = s_flags; sbi->sb->s_flags = s_flags;
} }
skip: skip:
fix_curseg_write_pointer = !check_only || list_empty(&inode_list);
destroy_fsync_dnodes(&inode_list, err); destroy_fsync_dnodes(&inode_list, err);
destroy_fsync_dnodes(&tmp_inode_list, err); destroy_fsync_dnodes(&tmp_inode_list, err);
...@@ -784,9 +787,22 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) ...@@ -784,9 +787,22 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
if (err) { if (err) {
truncate_inode_pages_final(NODE_MAPPING(sbi)); truncate_inode_pages_final(NODE_MAPPING(sbi));
truncate_inode_pages_final(META_MAPPING(sbi)); truncate_inode_pages_final(META_MAPPING(sbi));
} else {
clear_sbi_flag(sbi, SBI_POR_DOING);
} }
/*
* If fsync data succeeds or there is no fsync data to recover,
* and the f2fs is not read only, check and fix zoned block devices'
* write pointer consistency.
*/
if (!err && fix_curseg_write_pointer && !f2fs_readonly(sbi->sb) &&
f2fs_sb_has_blkzoned(sbi)) {
err = f2fs_fix_curseg_write_pointer(sbi);
ret = err;
}
if (!err)
clear_sbi_flag(sbi, SBI_POR_DOING);
mutex_unlock(&sbi->cp_mutex); mutex_unlock(&sbi->cp_mutex);
/* let's drop all the directory inodes for clean checkpoint */ /* let's drop all the directory inodes for clean checkpoint */
......
This diff is collapsed.
...@@ -200,18 +200,6 @@ struct segment_allocation { ...@@ -200,18 +200,6 @@ struct segment_allocation {
void (*allocate_segment)(struct f2fs_sb_info *, int, bool); void (*allocate_segment)(struct f2fs_sb_info *, int, bool);
}; };
/*
* this value is set in page as a private data which indicate that
* the page is atomically written, and it is in inmem_pages list.
*/
#define ATOMIC_WRITTEN_PAGE ((unsigned long)-1)
#define DUMMY_WRITTEN_PAGE ((unsigned long)-2)
#define IS_ATOMIC_WRITTEN_PAGE(page) \
(page_private(page) == (unsigned long)ATOMIC_WRITTEN_PAGE)
#define IS_DUMMY_WRITTEN_PAGE(page) \
(page_private(page) == (unsigned long)DUMMY_WRITTEN_PAGE)
#define MAX_SKIP_GC_COUNT 16 #define MAX_SKIP_GC_COUNT 16
struct inmem_pages { struct inmem_pages {
...@@ -619,8 +607,10 @@ static inline int utilization(struct f2fs_sb_info *sbi) ...@@ -619,8 +607,10 @@ static inline int utilization(struct f2fs_sb_info *sbi)
* threashold, * threashold,
* F2FS_IPU_FSYNC - activated in fsync path only for high performance flash * F2FS_IPU_FSYNC - activated in fsync path only for high performance flash
* storages. IPU will be triggered only if the # of dirty * storages. IPU will be triggered only if the # of dirty
* pages over min_fsync_blocks. * pages over min_fsync_blocks. (=default option)
* F2FS_IPUT_DISABLE - disable IPU. (=default option) * F2FS_IPU_ASYNC - do IPU given by asynchronous write requests.
* F2FS_IPU_NOCACHE - disable IPU bio cache.
* F2FS_IPUT_DISABLE - disable IPU. (=default option in LFS mode)
*/ */
#define DEF_MIN_IPU_UTIL 70 #define DEF_MIN_IPU_UTIL 70
#define DEF_MIN_FSYNC_BLOCKS 8 #define DEF_MIN_FSYNC_BLOCKS 8
...@@ -635,6 +625,7 @@ enum { ...@@ -635,6 +625,7 @@ enum {
F2FS_IPU_SSR_UTIL, F2FS_IPU_SSR_UTIL,
F2FS_IPU_FSYNC, F2FS_IPU_FSYNC,
F2FS_IPU_ASYNC, F2FS_IPU_ASYNC,
F2FS_IPU_NOCACHE,
}; };
static inline unsigned int curseg_segno(struct f2fs_sb_info *sbi, static inline unsigned int curseg_segno(struct f2fs_sb_info *sbi,
......
This diff is collapsed.
This diff is collapsed.
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#define NULL_ADDR ((block_t)0) /* used as block_t addresses */ #define NULL_ADDR ((block_t)0) /* used as block_t addresses */
#define NEW_ADDR ((block_t)-1) /* used as block_t addresses */ #define NEW_ADDR ((block_t)-1) /* used as block_t addresses */
#define COMPRESS_ADDR ((block_t)-2) /* used as compressed data flag */
#define F2FS_BYTES_TO_BLK(bytes) ((bytes) >> F2FS_BLKSIZE_BITS) #define F2FS_BYTES_TO_BLK(bytes) ((bytes) >> F2FS_BLKSIZE_BITS)
#define F2FS_BLK_TO_BYTES(blk) ((blk) << F2FS_BLKSIZE_BITS) #define F2FS_BLK_TO_BYTES(blk) ((blk) << F2FS_BLKSIZE_BITS)
...@@ -271,6 +272,10 @@ struct f2fs_inode { ...@@ -271,6 +272,10 @@ struct f2fs_inode {
__le32 i_inode_checksum;/* inode meta checksum */ __le32 i_inode_checksum;/* inode meta checksum */
__le64 i_crtime; /* creation time */ __le64 i_crtime; /* creation time */
__le32 i_crtime_nsec; /* creation time in nano scale */ __le32 i_crtime_nsec; /* creation time in nano scale */
__le64 i_compr_blocks; /* # of compressed blocks */
__u8 i_compress_algorithm; /* compress algorithm */
__u8 i_log_cluster_size; /* log of cluster size */
__le16 i_padding; /* padding */
__le32 i_extra_end[0]; /* for attribute size calculation */ __le32 i_extra_end[0]; /* for attribute size calculation */
} __packed; } __packed;
__le32 i_addr[DEF_ADDRS_PER_INODE]; /* Pointers to data blocks */ __le32 i_addr[DEF_ADDRS_PER_INODE]; /* Pointers to data blocks */
......
...@@ -49,6 +49,7 @@ TRACE_DEFINE_ENUM(CP_SYNC); ...@@ -49,6 +49,7 @@ TRACE_DEFINE_ENUM(CP_SYNC);
TRACE_DEFINE_ENUM(CP_RECOVERY); TRACE_DEFINE_ENUM(CP_RECOVERY);
TRACE_DEFINE_ENUM(CP_DISCARD); TRACE_DEFINE_ENUM(CP_DISCARD);
TRACE_DEFINE_ENUM(CP_TRIMMED); TRACE_DEFINE_ENUM(CP_TRIMMED);
TRACE_DEFINE_ENUM(CP_PAUSE);
#define show_block_type(type) \ #define show_block_type(type) \
__print_symbolic(type, \ __print_symbolic(type, \
...@@ -124,13 +125,14 @@ TRACE_DEFINE_ENUM(CP_TRIMMED); ...@@ -124,13 +125,14 @@ TRACE_DEFINE_ENUM(CP_TRIMMED);
{ CP_SYNC, "Sync" }, \ { CP_SYNC, "Sync" }, \
{ CP_RECOVERY, "Recovery" }, \ { CP_RECOVERY, "Recovery" }, \
{ CP_DISCARD, "Discard" }, \ { CP_DISCARD, "Discard" }, \
{ CP_UMOUNT, "Umount" }, \ { CP_PAUSE, "Pause" }, \
{ CP_TRIMMED, "Trimmed" }) { CP_TRIMMED, "Trimmed" })
#define show_fsync_cpreason(type) \ #define show_fsync_cpreason(type) \
__print_symbolic(type, \ __print_symbolic(type, \
{ CP_NO_NEEDED, "no needed" }, \ { CP_NO_NEEDED, "no needed" }, \
{ CP_NON_REGULAR, "non regular" }, \ { CP_NON_REGULAR, "non regular" }, \
{ CP_COMPRESSED, "compreesed" }, \
{ CP_HARDLINK, "hardlink" }, \ { CP_HARDLINK, "hardlink" }, \
{ CP_SB_NEED_CP, "sb needs cp" }, \ { CP_SB_NEED_CP, "sb needs cp" }, \
{ CP_WRONG_PINO, "wrong pino" }, \ { CP_WRONG_PINO, "wrong pino" }, \
...@@ -148,6 +150,11 @@ TRACE_DEFINE_ENUM(CP_TRIMMED); ...@@ -148,6 +150,11 @@ TRACE_DEFINE_ENUM(CP_TRIMMED);
{ F2FS_GOING_DOWN_METAFLUSH, "meta flush" }, \ { F2FS_GOING_DOWN_METAFLUSH, "meta flush" }, \
{ F2FS_GOING_DOWN_NEED_FSCK, "need fsck" }) { F2FS_GOING_DOWN_NEED_FSCK, "need fsck" })
#define show_compress_algorithm(type) \
__print_symbolic(type, \
{ COMPRESS_LZO, "LZO" }, \
{ COMPRESS_LZ4, "LZ4" })
struct f2fs_sb_info; struct f2fs_sb_info;
struct f2fs_io_info; struct f2fs_io_info;
struct extent_info; struct extent_info;
...@@ -1710,6 +1717,100 @@ TRACE_EVENT(f2fs_shutdown, ...@@ -1710,6 +1717,100 @@ TRACE_EVENT(f2fs_shutdown,
__entry->ret) __entry->ret)
); );
DECLARE_EVENT_CLASS(f2fs_zip_start,
TP_PROTO(struct inode *inode, pgoff_t cluster_idx,
unsigned int cluster_size, unsigned char algtype),
TP_ARGS(inode, cluster_idx, cluster_size, algtype),
TP_STRUCT__entry(
__field(dev_t, dev)
__field(ino_t, ino)
__field(pgoff_t, idx)
__field(unsigned int, size)
__field(unsigned int, algtype)
),
TP_fast_assign(
__entry->dev = inode->i_sb->s_dev;
__entry->ino = inode->i_ino;
__entry->idx = cluster_idx;
__entry->size = cluster_size;
__entry->algtype = algtype;
),
TP_printk("dev = (%d,%d), ino = %lu, cluster_idx:%lu, "
"cluster_size = %u, algorithm = %s",
show_dev_ino(__entry),
__entry->idx,
__entry->size,
show_compress_algorithm(__entry->algtype))
);
DECLARE_EVENT_CLASS(f2fs_zip_end,
TP_PROTO(struct inode *inode, pgoff_t cluster_idx,
unsigned int compressed_size, int ret),
TP_ARGS(inode, cluster_idx, compressed_size, ret),
TP_STRUCT__entry(
__field(dev_t, dev)
__field(ino_t, ino)
__field(pgoff_t, idx)
__field(unsigned int, size)
__field(unsigned int, ret)
),
TP_fast_assign(
__entry->dev = inode->i_sb->s_dev;
__entry->ino = inode->i_ino;
__entry->idx = cluster_idx;
__entry->size = compressed_size;
__entry->ret = ret;
),
TP_printk("dev = (%d,%d), ino = %lu, cluster_idx:%lu, "
"compressed_size = %u, ret = %d",
show_dev_ino(__entry),
__entry->idx,
__entry->size,
__entry->ret)
);
DEFINE_EVENT(f2fs_zip_start, f2fs_compress_pages_start,
TP_PROTO(struct inode *inode, pgoff_t cluster_idx,
unsigned int cluster_size, unsigned char algtype),
TP_ARGS(inode, cluster_idx, cluster_size, algtype)
);
DEFINE_EVENT(f2fs_zip_start, f2fs_decompress_pages_start,
TP_PROTO(struct inode *inode, pgoff_t cluster_idx,
unsigned int cluster_size, unsigned char algtype),
TP_ARGS(inode, cluster_idx, cluster_size, algtype)
);
DEFINE_EVENT(f2fs_zip_end, f2fs_compress_pages_end,
TP_PROTO(struct inode *inode, pgoff_t cluster_idx,
unsigned int compressed_size, int ret),
TP_ARGS(inode, cluster_idx, compressed_size, ret)
);
DEFINE_EVENT(f2fs_zip_end, f2fs_decompress_pages_end,
TP_PROTO(struct inode *inode, pgoff_t cluster_idx,
unsigned int compressed_size, int ret),
TP_ARGS(inode, cluster_idx, compressed_size, ret)
);
#endif /* _TRACE_F2FS_H */ #endif /* _TRACE_F2FS_H */
/* This part must be outside protection */ /* This part must be outside protection */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment