Commit d6edff78 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull f2fs updates from Jaegeuk Kim:
 "In this round, we've added 1) superblock checksum feature, 2)
  implemented new mount option which we can disable/enable checkpoint to
  provide atomic updates of entire filesystem, 3) refactored quota
  operations to enhance its consistency along with checkpoint, 4) fixed
  subtle IO hang conditions and roll-forward recovery flow to resurrect
  any fsync'ed inode metadata.

  Enhancements:
   - add checksum to keep superblock contents more safe
   - add checkpoint=disable/enable to support A/B update of entire filesystem
   - use plug for readahead IO in readdir
   - add more IO counts to avoid block layer hacks

  Bug fixes:
   - prevent data corruption issue for hardware encryption
   - fix IO hang issues when GC is heavily triggered
   - add missing up_read in __write_node_page
   - recover inode metadata during roll-forward recovery flow
   - fix null pointer dereference issue in wrongly configured discard map

  There are some more sanity checks and minor bug fixes as well"

* tag 'f2fs-for-4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (62 commits)
  f2fs: fix to keep project quota consistent
  f2fs: guarantee journalled quota data by checkpoint
  f2fs: cleanup dirty pages if recover failed
  f2fs: fix data corruption issue with hardware encryption
  f2fs: fix to recover inode->i_flags of inode block during POR
  f2fs: spread f2fs_set_inode_flags()
  f2fs: fix to spread clear_cold_data()
  Revert "f2fs: fix to clear PG_checked flag in set_page_dirty()"
  f2fs: account read IOs and use IO counts for is_idle
  f2fs: fix to account IO correctly for cgroup writeback
  f2fs: fix to account IO correctly
  f2fs: remove request_list check in is_idle()
  f2fs: allow to mount, if quota is failed
  f2fs: update REQ_TIME in f2fs_cross_rename()
  f2fs: do not update REQ_TIME in case of error conditions
  f2fs: remove unneeded disable_nat_bits()
  f2fs: remove unused sbi->trigger_ssr_threshold
  f2fs: shrink sbi->sb_lock coverage in set_file_temperature()
  f2fs: use rb_*_cached friends
  f2fs: fix to recover cold bit of inode block during POR
  ...
parents fe0142df 78130819
...@@ -121,7 +121,22 @@ What: /sys/fs/f2fs/<disk>/idle_interval ...@@ -121,7 +121,22 @@ What: /sys/fs/f2fs/<disk>/idle_interval
Date: January 2016 Date: January 2016
Contact: "Jaegeuk Kim" <jaegeuk@kernel.org> Contact: "Jaegeuk Kim" <jaegeuk@kernel.org>
Description: Description:
Controls the idle timing. Controls the idle timing for all paths other than
discard and gc path.
What: /sys/fs/f2fs/<disk>/discard_idle_interval
Date: September 2018
Contact: "Chao Yu" <yuchao0@huawei.com>
Contact: "Sahitya Tummala" <stummala@codeaurora.org>
Description:
Controls the idle timing for discard path.
What: /sys/fs/f2fs/<disk>/gc_idle_interval
Date: September 2018
Contact: "Chao Yu" <yuchao0@huawei.com>
Contact: "Sahitya Tummala" <stummala@codeaurora.org>
Description:
Controls the idle timing for gc path.
What: /sys/fs/f2fs/<disk>/iostat_enable What: /sys/fs/f2fs/<disk>/iostat_enable
Date: August 2017 Date: August 2017
......
...@@ -172,9 +172,10 @@ fault_type=%d Support configuring fault injection type, should be ...@@ -172,9 +172,10 @@ fault_type=%d Support configuring fault injection type, should be
FAULT_DIR_DEPTH 0x000000100 FAULT_DIR_DEPTH 0x000000100
FAULT_EVICT_INODE 0x000000200 FAULT_EVICT_INODE 0x000000200
FAULT_TRUNCATE 0x000000400 FAULT_TRUNCATE 0x000000400
FAULT_IO 0x000000800 FAULT_READ_IO 0x000000800
FAULT_CHECKPOINT 0x000001000 FAULT_CHECKPOINT 0x000001000
FAULT_DISCARD 0x000002000 FAULT_DISCARD 0x000002000
FAULT_WRITE_IO 0x000004000
mode=%s Control block allocation mode which supports "adaptive" mode=%s Control block allocation mode which supports "adaptive"
and "lfs". In "lfs" mode, there should be no random and "lfs". In "lfs" mode, there should be no random
writes towards main area. writes towards main area.
...@@ -211,6 +212,11 @@ fsync_mode=%s Control the policy of fsync. Currently supports "posix", ...@@ -211,6 +212,11 @@ fsync_mode=%s Control the policy of fsync. Currently supports "posix",
non-atomic files likewise "nobarrier" mount option. non-atomic files likewise "nobarrier" mount option.
test_dummy_encryption Enable dummy encryption, which provides a fake fscrypt test_dummy_encryption Enable dummy encryption, which provides a fake fscrypt
context. The fake fscrypt context is used by xfstests. context. The fake fscrypt context is used by xfstests.
checkpoint=%s Set to "disable" to turn off checkpointing. Set to "enable"
to reenable checkpointing. Is enabled by default. While
disabled, any unmounting or unexpected shutdowns will cause
the filesystem contents to appear as they did when the
filesystem was mounted with that option.
================================================================================ ================================================================================
DEBUGFS ENTRIES DEBUGFS ENTRIES
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/acl.c * fs/f2fs/acl.c
* *
...@@ -7,10 +8,6 @@ ...@@ -7,10 +8,6 @@
* Portions of this code from linux/fs/ext2/acl.c * Portions of this code from linux/fs/ext2/acl.c
* *
* Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de> * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/f2fs_fs.h> #include <linux/f2fs_fs.h>
#include "f2fs.h" #include "f2fs.h"
...@@ -53,6 +50,9 @@ static struct posix_acl *f2fs_acl_from_disk(const char *value, size_t size) ...@@ -53,6 +50,9 @@ static struct posix_acl *f2fs_acl_from_disk(const char *value, size_t size)
struct f2fs_acl_entry *entry = (struct f2fs_acl_entry *)(hdr + 1); struct f2fs_acl_entry *entry = (struct f2fs_acl_entry *)(hdr + 1);
const char *end = value + size; const char *end = value + size;
if (size < sizeof(struct f2fs_acl_header))
return ERR_PTR(-EINVAL);
if (hdr->a_version != cpu_to_le32(F2FS_ACL_VERSION)) if (hdr->a_version != cpu_to_le32(F2FS_ACL_VERSION))
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
...@@ -394,12 +394,16 @@ int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage, ...@@ -394,12 +394,16 @@ int f2fs_init_acl(struct inode *inode, struct inode *dir, struct page *ipage,
error = __f2fs_set_acl(inode, ACL_TYPE_DEFAULT, default_acl, error = __f2fs_set_acl(inode, ACL_TYPE_DEFAULT, default_acl,
ipage); ipage);
posix_acl_release(default_acl); posix_acl_release(default_acl);
} else {
inode->i_default_acl = NULL;
} }
if (acl) { if (acl) {
if (!error) if (!error)
error = __f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl, error = __f2fs_set_acl(inode, ACL_TYPE_ACCESS, acl,
ipage); ipage);
posix_acl_release(acl); posix_acl_release(acl);
} else {
inode->i_acl = NULL;
} }
return error; return error;
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/acl.h * fs/f2fs/acl.h
* *
...@@ -7,10 +8,6 @@ ...@@ -7,10 +8,6 @@
* Portions of this code from linux/fs/ext2/acl.h * Portions of this code from linux/fs/ext2/acl.h
* *
* Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de> * Copyright (C) 2001-2003 Andreas Gruenbacher, <agruen@suse.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#ifndef __F2FS_ACL_H__ #ifndef __F2FS_ACL_H__
#define __F2FS_ACL_H__ #define __F2FS_ACL_H__
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/checkpoint.c * fs/f2fs/checkpoint.c
* *
* Copyright (c) 2012 Samsung Electronics Co., Ltd. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
* http://www.samsung.com/ * http://www.samsung.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/bio.h> #include <linux/bio.h>
...@@ -122,11 +119,8 @@ struct page *f2fs_get_meta_page_nofail(struct f2fs_sb_info *sbi, pgoff_t index) ...@@ -122,11 +119,8 @@ struct page *f2fs_get_meta_page_nofail(struct f2fs_sb_info *sbi, pgoff_t index)
if (PTR_ERR(page) == -EIO && if (PTR_ERR(page) == -EIO &&
++count <= DEFAULT_RETRY_IO_COUNT) ++count <= DEFAULT_RETRY_IO_COUNT)
goto retry; goto retry;
f2fs_stop_checkpoint(sbi, false); f2fs_stop_checkpoint(sbi, false);
f2fs_bug_on(sbi, 1);
} }
return page; return page;
} }
...@@ -282,8 +276,7 @@ static int __f2fs_write_meta_page(struct page *page, ...@@ -282,8 +276,7 @@ static int __f2fs_write_meta_page(struct page *page,
dec_page_count(sbi, F2FS_DIRTY_META); dec_page_count(sbi, F2FS_DIRTY_META);
if (wbc->for_reclaim) if (wbc->for_reclaim)
f2fs_submit_merged_write_cond(sbi, page->mapping->host, f2fs_submit_merged_write_cond(sbi, NULL, page, 0, META);
0, page->index, META);
unlock_page(page); unlock_page(page);
...@@ -696,6 +689,8 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi) ...@@ -696,6 +689,8 @@ int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
/* clear Orphan Flag */ /* clear Orphan Flag */
clear_ckpt_flags(sbi, CP_ORPHAN_PRESENT_FLAG); clear_ckpt_flags(sbi, CP_ORPHAN_PRESENT_FLAG);
out: out:
set_sbi_flag(sbi, SBI_IS_RECOVERED);
#ifdef CONFIG_QUOTA #ifdef CONFIG_QUOTA
/* Turn quotas off */ /* Turn quotas off */
if (quota_enabled) if (quota_enabled)
...@@ -1084,6 +1079,21 @@ static void __prepare_cp_block(struct f2fs_sb_info *sbi) ...@@ -1084,6 +1079,21 @@ static void __prepare_cp_block(struct f2fs_sb_info *sbi)
ckpt->next_free_nid = cpu_to_le32(last_nid); ckpt->next_free_nid = cpu_to_le32(last_nid);
} }
static bool __need_flush_quota(struct f2fs_sb_info *sbi)
{
if (!is_journalled_quota(sbi))
return false;
if (is_sbi_flag_set(sbi, SBI_QUOTA_SKIP_FLUSH))
return false;
if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_REPAIR))
return false;
if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_FLUSH))
return true;
if (get_pages(sbi, F2FS_DIRTY_QDATA))
return true;
return false;
}
/* /*
* Freeze all the FS-operations for checkpoint. * Freeze all the FS-operations for checkpoint.
*/ */
...@@ -1095,12 +1105,36 @@ static int block_operations(struct f2fs_sb_info *sbi) ...@@ -1095,12 +1105,36 @@ static int block_operations(struct f2fs_sb_info *sbi)
.for_reclaim = 0, .for_reclaim = 0,
}; };
struct blk_plug plug; struct blk_plug plug;
int err = 0; int err = 0, cnt = 0;
blk_start_plug(&plug); blk_start_plug(&plug);
retry_flush_dents: retry_flush_quotas:
if (__need_flush_quota(sbi)) {
int locked;
if (++cnt > DEFAULT_RETRY_QUOTA_FLUSH_COUNT) {
set_sbi_flag(sbi, SBI_QUOTA_SKIP_FLUSH);
f2fs_lock_all(sbi);
goto retry_flush_dents;
}
clear_sbi_flag(sbi, SBI_QUOTA_NEED_FLUSH);
/* only failed during mount/umount/freeze/quotactl */
locked = down_read_trylock(&sbi->sb->s_umount);
f2fs_quota_sync(sbi->sb, -1);
if (locked)
up_read(&sbi->sb->s_umount);
}
f2fs_lock_all(sbi); f2fs_lock_all(sbi);
if (__need_flush_quota(sbi)) {
f2fs_unlock_all(sbi);
cond_resched();
goto retry_flush_quotas;
}
retry_flush_dents:
/* write all the dirty dentry pages */ /* write all the dirty dentry pages */
if (get_pages(sbi, F2FS_DIRTY_DENTS)) { if (get_pages(sbi, F2FS_DIRTY_DENTS)) {
f2fs_unlock_all(sbi); f2fs_unlock_all(sbi);
...@@ -1108,7 +1142,7 @@ static int block_operations(struct f2fs_sb_info *sbi) ...@@ -1108,7 +1142,7 @@ static int block_operations(struct f2fs_sb_info *sbi)
if (err) if (err)
goto out; goto out;
cond_resched(); cond_resched();
goto retry_flush_dents; goto retry_flush_quotas;
} }
/* /*
...@@ -1117,6 +1151,12 @@ static int block_operations(struct f2fs_sb_info *sbi) ...@@ -1117,6 +1151,12 @@ static int block_operations(struct f2fs_sb_info *sbi)
*/ */
down_write(&sbi->node_change); down_write(&sbi->node_change);
if (__need_flush_quota(sbi)) {
up_write(&sbi->node_change);
f2fs_unlock_all(sbi);
goto retry_flush_quotas;
}
if (get_pages(sbi, F2FS_DIRTY_IMETA)) { if (get_pages(sbi, F2FS_DIRTY_IMETA)) {
up_write(&sbi->node_change); up_write(&sbi->node_change);
f2fs_unlock_all(sbi); f2fs_unlock_all(sbi);
...@@ -1124,7 +1164,7 @@ static int block_operations(struct f2fs_sb_info *sbi) ...@@ -1124,7 +1164,7 @@ static int block_operations(struct f2fs_sb_info *sbi)
if (err) if (err)
goto out; goto out;
cond_resched(); cond_resched();
goto retry_flush_dents; goto retry_flush_quotas;
} }
retry_flush_nodes: retry_flush_nodes:
...@@ -1215,6 +1255,19 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -1215,6 +1255,19 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)
if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
__set_ckpt_flags(ckpt, CP_FSCK_FLAG); __set_ckpt_flags(ckpt, CP_FSCK_FLAG);
if (is_sbi_flag_set(sbi, SBI_CP_DISABLED))
__set_ckpt_flags(ckpt, CP_DISABLED_FLAG);
else
__clear_ckpt_flags(ckpt, CP_DISABLED_FLAG);
if (is_sbi_flag_set(sbi, SBI_QUOTA_SKIP_FLUSH))
__set_ckpt_flags(ckpt, CP_QUOTA_NEED_FSCK_FLAG);
else
__clear_ckpt_flags(ckpt, CP_QUOTA_NEED_FSCK_FLAG);
if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_REPAIR))
__set_ckpt_flags(ckpt, CP_QUOTA_NEED_FSCK_FLAG);
/* set this flag to activate crc|cp_ver for recovery */ /* set this flag to activate crc|cp_ver for recovery */
__set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG); __set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG);
__clear_ckpt_flags(ckpt, CP_NOCRC_RECOVERY_FLAG); __clear_ckpt_flags(ckpt, CP_NOCRC_RECOVERY_FLAG);
...@@ -1422,6 +1475,8 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -1422,6 +1475,8 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
clear_sbi_flag(sbi, SBI_IS_DIRTY); clear_sbi_flag(sbi, SBI_IS_DIRTY);
clear_sbi_flag(sbi, SBI_NEED_CP); clear_sbi_flag(sbi, SBI_NEED_CP);
clear_sbi_flag(sbi, SBI_QUOTA_SKIP_FLUSH);
sbi->unusable_block_count = 0;
__set_cp_next_pack(sbi); __set_cp_next_pack(sbi);
/* /*
...@@ -1446,6 +1501,12 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -1446,6 +1501,12 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
unsigned long long ckpt_ver; unsigned long long ckpt_ver;
int err = 0; int err = 0;
if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) {
if (cpc->reason != CP_PAUSE)
return 0;
f2fs_msg(sbi->sb, KERN_WARNING,
"Start checkpoint disabled!");
}
mutex_lock(&sbi->cp_mutex); mutex_lock(&sbi->cp_mutex);
if (!is_sbi_flag_set(sbi, SBI_IS_DIRTY) && if (!is_sbi_flag_set(sbi, SBI_IS_DIRTY) &&
...@@ -1497,7 +1558,10 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -1497,7 +1558,10 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
ckpt->checkpoint_ver = cpu_to_le64(++ckpt_ver); ckpt->checkpoint_ver = cpu_to_le64(++ckpt_ver);
/* write cached NAT/SIT entries to NAT/SIT area */ /* write cached NAT/SIT entries to NAT/SIT area */
f2fs_flush_nat_entries(sbi, cpc); err = f2fs_flush_nat_entries(sbi, cpc);
if (err)
goto stop;
f2fs_flush_sit_entries(sbi, cpc); f2fs_flush_sit_entries(sbi, cpc);
/* unlock all the fs_lock[] in do_checkpoint() */ /* unlock all the fs_lock[] in do_checkpoint() */
...@@ -1506,7 +1570,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -1506,7 +1570,7 @@ int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
f2fs_release_discard_addrs(sbi); f2fs_release_discard_addrs(sbi);
else else
f2fs_clear_prefree_segments(sbi, cpc); f2fs_clear_prefree_segments(sbi, cpc);
stop:
unblock_operations(sbi); unblock_operations(sbi);
stat_inc_cp_count(sbi->stat_info); stat_inc_cp_count(sbi->stat_info);
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0
/* /*
* f2fs debugging statistics * f2fs debugging statistics
* *
...@@ -5,10 +6,6 @@ ...@@ -5,10 +6,6 @@
* http://www.samsung.com/ * http://www.samsung.com/
* Copyright (c) 2012 Linux Foundation * Copyright (c) 2012 Linux Foundation
* Copyright (c) 2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org> * Copyright (c) 2012 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/fs.h> #include <linux/fs.h>
...@@ -58,6 +55,9 @@ static void update_general_status(struct f2fs_sb_info *sbi) ...@@ -58,6 +55,9 @@ static void update_general_status(struct f2fs_sb_info *sbi)
si->max_vw_cnt = atomic_read(&sbi->max_vw_cnt); si->max_vw_cnt = atomic_read(&sbi->max_vw_cnt);
si->nr_wb_cp_data = get_pages(sbi, F2FS_WB_CP_DATA); si->nr_wb_cp_data = get_pages(sbi, F2FS_WB_CP_DATA);
si->nr_wb_data = get_pages(sbi, F2FS_WB_DATA); si->nr_wb_data = get_pages(sbi, F2FS_WB_DATA);
si->nr_rd_data = get_pages(sbi, F2FS_RD_DATA);
si->nr_rd_node = get_pages(sbi, F2FS_RD_NODE);
si->nr_rd_meta = get_pages(sbi, F2FS_RD_META);
if (SM_I(sbi) && SM_I(sbi)->fcc_info) { if (SM_I(sbi) && SM_I(sbi)->fcc_info) {
si->nr_flushed = si->nr_flushed =
atomic_read(&SM_I(sbi)->fcc_info->issued_flush); atomic_read(&SM_I(sbi)->fcc_info->issued_flush);
...@@ -104,6 +104,8 @@ static void update_general_status(struct f2fs_sb_info *sbi) ...@@ -104,6 +104,8 @@ static void update_general_status(struct f2fs_sb_info *sbi)
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->bg_gc = sbi->bg_gc;
si->io_skip_bggc = sbi->io_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];
si->skipped_atomic_files[FG_GC] = sbi->skipped_atomic_files[FG_GC]; si->skipped_atomic_files[FG_GC] = sbi->skipped_atomic_files[FG_GC];
si->util_free = (int)(free_user_blocks(sbi) >> sbi->log_blocks_per_seg) si->util_free = (int)(free_user_blocks(sbi) >> sbi->log_blocks_per_seg)
...@@ -121,6 +123,9 @@ static void update_general_status(struct f2fs_sb_info *sbi) ...@@ -121,6 +123,9 @@ static void update_general_status(struct f2fs_sb_info *sbi)
si->curzone[i] = GET_ZONE_FROM_SEC(sbi, si->cursec[i]); si->curzone[i] = GET_ZONE_FROM_SEC(sbi, si->cursec[i]);
} }
for (i = META_CP; i < META_MAX; i++)
si->meta_count[i] = atomic_read(&sbi->meta_count[i]);
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
si->segment_count[i] = sbi->segment_count[i]; si->segment_count[i] = sbi->segment_count[i];
si->block_count[i] = sbi->block_count[i]; si->block_count[i] = sbi->block_count[i];
...@@ -190,8 +195,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi) ...@@ -190,8 +195,7 @@ static void update_mem_info(struct f2fs_sb_info *sbi)
si->base_mem += MAIN_SEGS(sbi) * sizeof(struct seg_entry); si->base_mem += MAIN_SEGS(sbi) * sizeof(struct seg_entry);
si->base_mem += f2fs_bitmap_size(MAIN_SEGS(sbi)); si->base_mem += f2fs_bitmap_size(MAIN_SEGS(sbi));
si->base_mem += 2 * SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi); si->base_mem += 2 * SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi);
if (f2fs_discard_en(sbi)) si->base_mem += SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi);
si->base_mem += SIT_VBLOCK_MAP_SIZE * MAIN_SEGS(sbi);
si->base_mem += SIT_VBLOCK_MAP_SIZE; si->base_mem += SIT_VBLOCK_MAP_SIZE;
if (sbi->segs_per_sec > 1) if (sbi->segs_per_sec > 1)
si->base_mem += MAIN_SECS(sbi) * sizeof(struct sec_entry); si->base_mem += MAIN_SECS(sbi) * sizeof(struct sec_entry);
...@@ -271,7 +275,8 @@ static int stat_show(struct seq_file *s, void *v) ...@@ -271,7 +275,8 @@ static int stat_show(struct seq_file *s, void *v)
seq_printf(s, "\n=====[ partition info(%pg). #%d, %s, CP: %s]=====\n", seq_printf(s, "\n=====[ partition info(%pg). #%d, %s, CP: %s]=====\n",
si->sbi->sb->s_bdev, i++, si->sbi->sb->s_bdev, i++,
f2fs_readonly(si->sbi->sb) ? "RO": "RW", f2fs_readonly(si->sbi->sb) ? "RO": "RW",
f2fs_cp_error(si->sbi) ? "Error": "Good"); is_set_ckpt_flags(si->sbi, CP_DISABLED_FLAG) ?
"Disabled": (f2fs_cp_error(si->sbi) ? "Error": "Good"));
seq_printf(s, "[SB: 1] [CP: 2] [SIT: %d] [NAT: %d] ", seq_printf(s, "[SB: 1] [CP: 2] [SIT: %d] [NAT: %d] ",
si->sit_area_segs, si->nat_area_segs); si->sit_area_segs, si->nat_area_segs);
seq_printf(s, "[SSA: %d] [MAIN: %d", seq_printf(s, "[SSA: %d] [MAIN: %d",
...@@ -333,6 +338,13 @@ static int stat_show(struct seq_file *s, void *v) ...@@ -333,6 +338,13 @@ static int stat_show(struct seq_file *s, void *v)
si->prefree_count, si->free_segs, si->free_secs); si->prefree_count, si->free_segs, si->free_secs);
seq_printf(s, "CP calls: %d (BG: %d)\n", seq_printf(s, "CP calls: %d (BG: %d)\n",
si->cp_count, si->bg_cp_count); si->cp_count, si->bg_cp_count);
seq_printf(s, " - cp blocks : %u\n", si->meta_count[META_CP]);
seq_printf(s, " - sit blocks : %u\n",
si->meta_count[META_SIT]);
seq_printf(s, " - nat blocks : %u\n",
si->meta_count[META_NAT]);
seq_printf(s, " - ssa blocks : %u\n",
si->meta_count[META_SSA]);
seq_printf(s, "GC calls: %d (BG: %d)\n", seq_printf(s, "GC calls: %d (BG: %d)\n",
si->call_count, si->bg_gc); si->call_count, si->bg_gc);
seq_printf(s, " - data segments : %d (%d)\n", seq_printf(s, " - data segments : %d (%d)\n",
...@@ -349,6 +361,8 @@ static int stat_show(struct seq_file *s, void *v) ...@@ -349,6 +361,8 @@ static int stat_show(struct seq_file *s, void *v)
si->skipped_atomic_files[BG_GC] + si->skipped_atomic_files[BG_GC] +
si->skipped_atomic_files[FG_GC], si->skipped_atomic_files[FG_GC],
si->skipped_atomic_files[BG_GC]); si->skipped_atomic_files[BG_GC]);
seq_printf(s, "BG skip : IO: %u, Other: %u\n",
si->io_skip_bggc, si->other_skip_bggc);
seq_puts(s, "\nExtent Cache:\n"); seq_puts(s, "\nExtent Cache:\n");
seq_printf(s, " - Hit Count: L1-1:%llu L1-2:%llu L2:%llu\n", seq_printf(s, " - Hit Count: L1-1:%llu L1-2:%llu L2:%llu\n",
si->hit_largest, si->hit_cached, si->hit_largest, si->hit_cached,
...@@ -360,7 +374,9 @@ static int stat_show(struct seq_file *s, void *v) ...@@ -360,7 +374,9 @@ static int stat_show(struct seq_file *s, void *v)
seq_printf(s, " - Inner Struct Count: tree: %d(%d), node: %d\n", seq_printf(s, " - Inner Struct Count: tree: %d(%d), node: %d\n",
si->ext_tree, si->zombie_tree, si->ext_node); si->ext_tree, si->zombie_tree, si->ext_node);
seq_puts(s, "\nBalancing F2FS Async:\n"); seq_puts(s, "\nBalancing F2FS Async:\n");
seq_printf(s, " - IO (CP: %4d, Data: %4d, Flush: (%4d %4d %4d), " seq_printf(s, " - IO_R (Data: %4d, Node: %4d, Meta: %4d\n",
si->nr_rd_data, si->nr_rd_node, si->nr_rd_meta);
seq_printf(s, " - IO_W (CP: %4d, Data: %4d, Flush: (%4d %4d %4d), "
"Discard: (%4d %4d)) cmd: %4d undiscard:%4u\n", "Discard: (%4d %4d)) cmd: %4d undiscard:%4u\n",
si->nr_wb_cp_data, si->nr_wb_data, si->nr_wb_cp_data, si->nr_wb_data,
si->nr_flushing, si->nr_flushed, si->nr_flushing, si->nr_flushed,
...@@ -445,6 +461,7 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi) ...@@ -445,6 +461,7 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
{ {
struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
struct f2fs_stat_info *si; struct f2fs_stat_info *si;
int i;
si = f2fs_kzalloc(sbi, sizeof(struct f2fs_stat_info), GFP_KERNEL); si = f2fs_kzalloc(sbi, sizeof(struct f2fs_stat_info), GFP_KERNEL);
if (!si) if (!si)
...@@ -470,6 +487,8 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi) ...@@ -470,6 +487,8 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi)
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->inplace_count, 0); atomic_set(&sbi->inplace_count, 0);
for (i = META_CP; i < META_MAX; i++)
atomic_set(&sbi->meta_count[i], 0);
atomic_set(&sbi->aw_cnt, 0); atomic_set(&sbi->aw_cnt, 0);
atomic_set(&sbi->vw_cnt, 0); atomic_set(&sbi->vw_cnt, 0);
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/dir.c * fs/f2fs/dir.c
* *
* Copyright (c) 2012 Samsung Electronics Co., Ltd. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
* http://www.samsung.com/ * http://www.samsung.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/f2fs_fs.h> #include <linux/f2fs_fs.h>
...@@ -658,9 +655,9 @@ int f2fs_do_tmpfile(struct inode *inode, struct inode *dir) ...@@ -658,9 +655,9 @@ int f2fs_do_tmpfile(struct inode *inode, struct inode *dir)
f2fs_put_page(page, 1); f2fs_put_page(page, 1);
clear_inode_flag(inode, FI_NEW_INODE); clear_inode_flag(inode, FI_NEW_INODE);
f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
fail: fail:
up_write(&F2FS_I(inode)->i_sem); up_write(&F2FS_I(inode)->i_sem);
f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
return err; return err;
} }
...@@ -733,6 +730,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page, ...@@ -733,6 +730,7 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
clear_page_dirty_for_io(page); clear_page_dirty_for_io(page);
ClearPagePrivate(page); ClearPagePrivate(page);
ClearPageUptodate(page); ClearPageUptodate(page);
clear_cold_data(page);
inode_dec_dirty_pages(dir); inode_dec_dirty_pages(dir);
f2fs_remove_dirty_inode(dir); f2fs_remove_dirty_inode(dir);
} }
...@@ -784,9 +782,15 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d, ...@@ -784,9 +782,15 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
struct f2fs_dir_entry *de = NULL; struct f2fs_dir_entry *de = NULL;
struct fscrypt_str de_name = FSTR_INIT(NULL, 0); struct fscrypt_str de_name = FSTR_INIT(NULL, 0);
struct f2fs_sb_info *sbi = F2FS_I_SB(d->inode); struct f2fs_sb_info *sbi = F2FS_I_SB(d->inode);
struct blk_plug plug;
bool readdir_ra = sbi->readdir_ra == 1;
int err = 0;
bit_pos = ((unsigned long)ctx->pos % d->max); bit_pos = ((unsigned long)ctx->pos % d->max);
if (readdir_ra)
blk_start_plug(&plug);
while (bit_pos < d->max) { while (bit_pos < d->max) {
bit_pos = find_next_bit_le(d->bitmap, d->max, bit_pos); bit_pos = find_next_bit_le(d->bitmap, d->max, bit_pos);
if (bit_pos >= d->max) if (bit_pos >= d->max)
...@@ -806,29 +810,33 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d, ...@@ -806,29 +810,33 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
if (f2fs_encrypted_inode(d->inode)) { if (f2fs_encrypted_inode(d->inode)) {
int save_len = fstr->len; int save_len = fstr->len;
int err;
err = fscrypt_fname_disk_to_usr(d->inode, err = fscrypt_fname_disk_to_usr(d->inode,
(u32)de->hash_code, 0, (u32)de->hash_code, 0,
&de_name, fstr); &de_name, fstr);
if (err) if (err)
return err; goto out;
de_name = *fstr; de_name = *fstr;
fstr->len = save_len; fstr->len = save_len;
} }
if (!dir_emit(ctx, de_name.name, de_name.len, if (!dir_emit(ctx, de_name.name, de_name.len,
le32_to_cpu(de->ino), d_type)) le32_to_cpu(de->ino), d_type)) {
return 1; err = 1;
goto out;
}
if (sbi->readdir_ra == 1) if (readdir_ra)
f2fs_ra_node_page(sbi, le32_to_cpu(de->ino)); f2fs_ra_node_page(sbi, le32_to_cpu(de->ino));
bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
ctx->pos = start_pos + bit_pos; ctx->pos = start_pos + bit_pos;
} }
return 0; out:
if (readdir_ra)
blk_finish_plug(&plug);
return err;
} }
static int f2fs_readdir(struct file *file, struct dir_context *ctx) static int f2fs_readdir(struct file *file, struct dir_context *ctx)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/gc.h * fs/f2fs/gc.h
* *
* Copyright (c) 2012 Samsung Electronics Co., Ltd. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
* http://www.samsung.com/ * http://www.samsung.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#define GC_THREAD_MIN_WB_PAGES 1 /* #define GC_THREAD_MIN_WB_PAGES 1 /*
* a threshold to determine * a threshold to determine
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/hash.c * fs/f2fs/hash.c
* *
...@@ -7,10 +8,6 @@ ...@@ -7,10 +8,6 @@
* Portions of this code from linux/fs/ext3/hash.c * Portions of this code from linux/fs/ext3/hash.c
* *
* Copyright (C) 2002 by Theodore Ts'o * Copyright (C) 2002 by Theodore Ts'o
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/types.h> #include <linux/types.h>
#include <linux/fs.h> #include <linux/fs.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/inline.c * fs/f2fs/inline.c
* Copyright (c) 2013, Intel Corporation * Copyright (c) 2013, Intel Corporation
* Authors: Huajun Li <huajun.li@intel.com> * Authors: Huajun Li <huajun.li@intel.com>
* Haicheng Li <haicheng.li@intel.com> * Haicheng Li <haicheng.li@intel.com>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/fs.h> #include <linux/fs.h>
...@@ -300,7 +298,7 @@ bool f2fs_recover_inline_data(struct inode *inode, struct page *npage) ...@@ -300,7 +298,7 @@ bool f2fs_recover_inline_data(struct inode *inode, struct page *npage)
clear_inode_flag(inode, FI_INLINE_DATA); clear_inode_flag(inode, FI_INLINE_DATA);
f2fs_put_page(ipage, 1); f2fs_put_page(ipage, 1);
} else if (ri && (ri->i_inline & F2FS_INLINE_DATA)) { } else if (ri && (ri->i_inline & F2FS_INLINE_DATA)) {
if (f2fs_truncate_blocks(inode, 0, false)) if (f2fs_truncate_blocks(inode, 0, false, false))
return false; return false;
goto process_inline; goto process_inline;
} }
...@@ -472,7 +470,7 @@ static int f2fs_add_inline_entries(struct inode *dir, void *inline_dentry) ...@@ -472,7 +470,7 @@ static int f2fs_add_inline_entries(struct inode *dir, void *inline_dentry)
return 0; return 0;
punch_dentry_pages: punch_dentry_pages:
truncate_inode_pages(&dir->i_data, 0); truncate_inode_pages(&dir->i_data, 0);
f2fs_truncate_blocks(dir, 0, false); f2fs_truncate_blocks(dir, 0, false, false);
f2fs_remove_dirty_inode(dir); f2fs_remove_dirty_inode(dir);
return err; return err;
} }
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/inode.c * fs/f2fs/inode.c
* *
* Copyright (c) 2012 Samsung Electronics Co., Ltd. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
* http://www.samsung.com/ * http://www.samsung.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/f2fs_fs.h> #include <linux/f2fs_fs.h>
...@@ -368,6 +365,12 @@ static int do_read_inode(struct inode *inode) ...@@ -368,6 +365,12 @@ static int do_read_inode(struct inode *inode)
if (f2fs_has_inline_data(inode) && !f2fs_exist_data(inode)) if (f2fs_has_inline_data(inode) && !f2fs_exist_data(inode))
__recover_inline_status(inode, node_page); __recover_inline_status(inode, node_page);
/* try to recover cold bit for non-dir inode */
if (!S_ISDIR(inode->i_mode) && !is_cold_node(node_page)) {
set_cold_node(node_page, false);
set_page_dirty(node_page);
}
/* get rdev by using inline_info */ /* get rdev by using inline_info */
__get_inode_rdev(inode, ri); __get_inode_rdev(inode, ri);
...@@ -610,6 +613,9 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc) ...@@ -610,6 +613,9 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
if (!is_inode_flag_set(inode, FI_DIRTY_INODE)) if (!is_inode_flag_set(inode, FI_DIRTY_INODE))
return 0; return 0;
if (f2fs_is_checkpoint_ready(sbi))
return -ENOSPC;
/* /*
* We need to balance fs here to prevent from producing dirty node pages * We need to balance fs here to prevent from producing dirty node pages
* during the urgent cleaning time when runing out of free sections. * during the urgent cleaning time when runing out of free sections.
...@@ -648,7 +654,11 @@ void f2fs_evict_inode(struct inode *inode) ...@@ -648,7 +654,11 @@ void f2fs_evict_inode(struct inode *inode)
if (inode->i_nlink || is_bad_inode(inode)) if (inode->i_nlink || is_bad_inode(inode))
goto no_delete; goto no_delete;
dquot_initialize(inode); err = dquot_initialize(inode);
if (err) {
err = 0;
set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
}
f2fs_remove_ino_entry(sbi, inode->i_ino, APPEND_INO); f2fs_remove_ino_entry(sbi, inode->i_ino, APPEND_INO);
f2fs_remove_ino_entry(sbi, inode->i_ino, UPDATE_INO); f2fs_remove_ino_entry(sbi, inode->i_ino, UPDATE_INO);
...@@ -680,9 +690,10 @@ void f2fs_evict_inode(struct inode *inode) ...@@ -680,9 +690,10 @@ void f2fs_evict_inode(struct inode *inode)
goto retry; goto retry;
} }
if (err) if (err) {
f2fs_update_inode_page(inode); f2fs_update_inode_page(inode);
dquot_free_inode(inode); set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
}
sb_end_intwrite(inode->i_sb); sb_end_intwrite(inode->i_sb);
no_delete: no_delete:
dquot_drop(inode); dquot_drop(inode);
...@@ -691,7 +702,8 @@ void f2fs_evict_inode(struct inode *inode) ...@@ -691,7 +702,8 @@ void f2fs_evict_inode(struct inode *inode)
stat_dec_inline_dir(inode); stat_dec_inline_dir(inode);
stat_dec_inline_inode(inode); stat_dec_inline_inode(inode);
if (likely(!is_set_ckpt_flags(sbi, CP_ERROR_FLAG))) if (likely(!is_set_ckpt_flags(sbi, CP_ERROR_FLAG) &&
!is_sbi_flag_set(sbi, SBI_CP_DISABLED)))
f2fs_bug_on(sbi, is_inode_flag_set(inode, FI_DIRTY_INODE)); f2fs_bug_on(sbi, is_inode_flag_set(inode, FI_DIRTY_INODE));
else else
f2fs_inode_synced(inode); f2fs_inode_synced(inode);
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/namei.c * fs/f2fs/namei.c
* *
* Copyright (c) 2012 Samsung Electronics Co., Ltd. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
* http://www.samsung.com/ * http://www.samsung.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/f2fs_fs.h> #include <linux/f2fs_fs.h>
...@@ -19,6 +16,7 @@ ...@@ -19,6 +16,7 @@
#include "f2fs.h" #include "f2fs.h"
#include "node.h" #include "node.h"
#include "segment.h"
#include "xattr.h" #include "xattr.h"
#include "acl.h" #include "acl.h"
#include <trace/events/f2fs.h> #include <trace/events/f2fs.h>
...@@ -74,10 +72,6 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) ...@@ -74,10 +72,6 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
if (err) if (err)
goto fail_drop; goto fail_drop;
err = dquot_alloc_inode(inode);
if (err)
goto fail_drop;
set_inode_flag(inode, FI_NEW_INODE); set_inode_flag(inode, FI_NEW_INODE);
/* If the directory encrypted, then we should encrypt the inode. */ /* If the directory encrypted, then we should encrypt the inode. */
...@@ -124,6 +118,8 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode) ...@@ -124,6 +118,8 @@ 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);
f2fs_set_inode_flags(inode);
trace_f2fs_new_inode(inode, 0); trace_f2fs_new_inode(inode, 0);
return inode; return inode;
...@@ -184,16 +180,19 @@ static inline void set_file_temperature(struct f2fs_sb_info *sbi, struct inode * ...@@ -184,16 +180,19 @@ static inline void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *
hot_count = sbi->raw_super->hot_ext_count; hot_count = sbi->raw_super->hot_ext_count;
for (i = 0; i < cold_count + hot_count; i++) { for (i = 0; i < cold_count + hot_count; i++) {
if (!is_extension_exist(name, extlist[i])) if (is_extension_exist(name, extlist[i]))
continue; break;
if (i < cold_count)
file_set_cold(inode);
else
file_set_hot(inode);
break;
} }
up_read(&sbi->sb_lock); up_read(&sbi->sb_lock);
if (i == cold_count + hot_count)
return;
if (i < cold_count)
file_set_cold(inode);
else
file_set_hot(inode);
} }
int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name, int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
...@@ -272,6 +271,9 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode, ...@@ -272,6 +271,9 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
if (unlikely(f2fs_cp_error(sbi))) if (unlikely(f2fs_cp_error(sbi)))
return -EIO; return -EIO;
err = f2fs_is_checkpoint_ready(sbi);
if (err)
return err;
err = dquot_initialize(dir); err = dquot_initialize(dir);
if (err) if (err)
...@@ -318,6 +320,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -318,6 +320,9 @@ static int f2fs_link(struct dentry *old_dentry, struct inode *dir,
if (unlikely(f2fs_cp_error(sbi))) if (unlikely(f2fs_cp_error(sbi)))
return -EIO; return -EIO;
err = f2fs_is_checkpoint_ready(sbi);
if (err)
return err;
err = fscrypt_prepare_link(old_dentry, dir, dentry); err = fscrypt_prepare_link(old_dentry, dir, dentry);
if (err) if (err)
...@@ -564,6 +569,9 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry, ...@@ -564,6 +569,9 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
if (unlikely(f2fs_cp_error(sbi))) if (unlikely(f2fs_cp_error(sbi)))
return -EIO; return -EIO;
err = f2fs_is_checkpoint_ready(sbi);
if (err)
return err;
err = fscrypt_prepare_symlink(dir, symname, len, dir->i_sb->s_blocksize, err = fscrypt_prepare_symlink(dir, symname, len, dir->i_sb->s_blocksize,
&disk_link); &disk_link);
...@@ -693,6 +701,9 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry, ...@@ -693,6 +701,9 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
if (unlikely(f2fs_cp_error(sbi))) if (unlikely(f2fs_cp_error(sbi)))
return -EIO; return -EIO;
err = f2fs_is_checkpoint_ready(sbi);
if (err)
return err;
err = dquot_initialize(dir); err = dquot_initialize(dir);
if (err) if (err)
...@@ -823,10 +834,13 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -823,10 +834,13 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
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); bool is_old_inline = f2fs_has_inline_dentry(old_dir);
int err = -ENOENT; int err;
if (unlikely(f2fs_cp_error(sbi))) if (unlikely(f2fs_cp_error(sbi)))
return -EIO; return -EIO;
err = f2fs_is_checkpoint_ready(sbi);
if (err)
return err;
if (is_inode_flag_set(new_dir, FI_PROJ_INHERIT) && if (is_inode_flag_set(new_dir, FI_PROJ_INHERIT) &&
(!projid_eq(F2FS_I(new_dir)->i_projid, (!projid_eq(F2FS_I(new_dir)->i_projid,
...@@ -847,6 +861,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -847,6 +861,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
goto out; goto out;
} }
err = -ENOENT;
old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page); old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page);
if (!old_entry) { if (!old_entry) {
if (IS_ERR(old_page)) if (IS_ERR(old_page))
...@@ -983,6 +998,8 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -983,6 +998,8 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir))
f2fs_sync_fs(sbi->sb, 1); f2fs_sync_fs(sbi->sb, 1);
f2fs_update_time(sbi, REQ_TIME);
return 0; return 0;
put_out_dir: put_out_dir:
...@@ -1012,10 +1029,13 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1012,10 +1029,13 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
struct f2fs_dir_entry *old_dir_entry = NULL, *new_dir_entry = NULL; struct f2fs_dir_entry *old_dir_entry = NULL, *new_dir_entry = NULL;
struct f2fs_dir_entry *old_entry, *new_entry; struct f2fs_dir_entry *old_entry, *new_entry;
int old_nlink = 0, new_nlink = 0; int old_nlink = 0, new_nlink = 0;
int err = -ENOENT; int err;
if (unlikely(f2fs_cp_error(sbi))) if (unlikely(f2fs_cp_error(sbi)))
return -EIO; return -EIO;
err = f2fs_is_checkpoint_ready(sbi);
if (err)
return err;
if ((is_inode_flag_set(new_dir, FI_PROJ_INHERIT) && if ((is_inode_flag_set(new_dir, FI_PROJ_INHERIT) &&
!projid_eq(F2FS_I(new_dir)->i_projid, !projid_eq(F2FS_I(new_dir)->i_projid,
...@@ -1033,6 +1053,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1033,6 +1053,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
if (err) if (err)
goto out; goto out;
err = -ENOENT;
old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page); old_entry = f2fs_find_entry(old_dir, &old_dentry->d_name, &old_page);
if (!old_entry) { if (!old_entry) {
if (IS_ERR(old_page)) if (IS_ERR(old_page))
...@@ -1136,6 +1157,8 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -1136,6 +1157,8 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir)) if (IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir))
f2fs_sync_fs(sbi->sb, 1); f2fs_sync_fs(sbi->sb, 1);
f2fs_update_time(sbi, REQ_TIME);
return 0; return 0;
out_new_dir: out_new_dir:
if (new_dir_entry) { if (new_dir_entry) {
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/node.c * fs/f2fs/node.c
* *
* Copyright (c) 2012 Samsung Electronics Co., Ltd. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
* http://www.samsung.com/ * http://www.samsung.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/f2fs_fs.h> #include <linux/f2fs_fs.h>
...@@ -129,6 +126,8 @@ static struct page *get_next_nat_page(struct f2fs_sb_info *sbi, nid_t nid) ...@@ -129,6 +126,8 @@ static struct page *get_next_nat_page(struct f2fs_sb_info *sbi, nid_t nid)
/* get current nat block page with lock */ /* get current nat block page with lock */
src_page = get_current_nat_page(sbi, nid); src_page = get_current_nat_page(sbi, nid);
if (IS_ERR(src_page))
return src_page;
dst_page = f2fs_grab_meta_page(sbi, dst_off); dst_page = f2fs_grab_meta_page(sbi, dst_off);
f2fs_bug_on(sbi, PageDirty(src_page)); f2fs_bug_on(sbi, PageDirty(src_page));
...@@ -1542,8 +1541,10 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, ...@@ -1542,8 +1541,10 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
} }
if (__is_valid_data_blkaddr(ni.blk_addr) && if (__is_valid_data_blkaddr(ni.blk_addr) &&
!f2fs_is_valid_blkaddr(sbi, ni.blk_addr, DATA_GENERIC)) !f2fs_is_valid_blkaddr(sbi, ni.blk_addr, DATA_GENERIC)) {
up_read(&sbi->node_write);
goto redirty_out; goto redirty_out;
}
if (atomic && !test_opt(sbi, NOBARRIER)) if (atomic && !test_opt(sbi, NOBARRIER))
fio.op_flags |= REQ_PREFLUSH | REQ_FUA; fio.op_flags |= REQ_PREFLUSH | REQ_FUA;
...@@ -1564,8 +1565,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, ...@@ -1564,8 +1565,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
up_read(&sbi->node_write); up_read(&sbi->node_write);
if (wbc->for_reclaim) { if (wbc->for_reclaim) {
f2fs_submit_merged_write_cond(sbi, page->mapping->host, 0, f2fs_submit_merged_write_cond(sbi, NULL, page, 0, NODE);
page->index, NODE);
submitted = NULL; submitted = NULL;
} }
...@@ -1587,8 +1587,10 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted, ...@@ -1587,8 +1587,10 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
return AOP_WRITEPAGE_ACTIVATE; return AOP_WRITEPAGE_ACTIVATE;
} }
void f2fs_move_node_page(struct page *node_page, int gc_type) int f2fs_move_node_page(struct page *node_page, int gc_type)
{ {
int err = 0;
if (gc_type == FG_GC) { if (gc_type == FG_GC) {
struct writeback_control wbc = { struct writeback_control wbc = {
.sync_mode = WB_SYNC_ALL, .sync_mode = WB_SYNC_ALL,
...@@ -1600,12 +1602,16 @@ void f2fs_move_node_page(struct page *node_page, int gc_type) ...@@ -1600,12 +1602,16 @@ void f2fs_move_node_page(struct page *node_page, int gc_type)
f2fs_wait_on_page_writeback(node_page, NODE, true); f2fs_wait_on_page_writeback(node_page, NODE, true);
f2fs_bug_on(F2FS_P_SB(node_page), PageWriteback(node_page)); f2fs_bug_on(F2FS_P_SB(node_page), PageWriteback(node_page));
if (!clear_page_dirty_for_io(node_page)) if (!clear_page_dirty_for_io(node_page)) {
err = -EAGAIN;
goto out_page; goto out_page;
}
if (__write_node_page(node_page, false, NULL, if (__write_node_page(node_page, false, NULL,
&wbc, false, FS_GC_NODE_IO, NULL)) &wbc, false, FS_GC_NODE_IO, NULL)) {
err = -EAGAIN;
unlock_page(node_page); unlock_page(node_page);
}
goto release_page; goto release_page;
} else { } else {
/* set page dirty and write it */ /* set page dirty and write it */
...@@ -1616,6 +1622,7 @@ void f2fs_move_node_page(struct page *node_page, int gc_type) ...@@ -1616,6 +1622,7 @@ void f2fs_move_node_page(struct page *node_page, int gc_type)
unlock_page(node_page); unlock_page(node_page);
release_page: release_page:
f2fs_put_page(node_page, 0); f2fs_put_page(node_page, 0);
return err;
} }
static int f2fs_write_node_page(struct page *page, static int f2fs_write_node_page(struct page *page,
...@@ -1630,13 +1637,13 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, ...@@ -1630,13 +1637,13 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
unsigned int *seq_id) unsigned int *seq_id)
{ {
pgoff_t index; pgoff_t index;
pgoff_t last_idx = ULONG_MAX;
struct pagevec pvec; struct pagevec pvec;
int ret = 0; int ret = 0;
struct page *last_page = NULL; struct page *last_page = NULL;
bool marked = false; bool marked = false;
nid_t ino = inode->i_ino; nid_t ino = inode->i_ino;
int nr_pages; int nr_pages;
int nwritten = 0;
if (atomic) { if (atomic) {
last_page = last_fsync_dnode(sbi, ino); last_page = last_fsync_dnode(sbi, ino);
...@@ -1714,7 +1721,7 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, ...@@ -1714,7 +1721,7 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
f2fs_put_page(last_page, 0); f2fs_put_page(last_page, 0);
break; break;
} else if (submitted) { } else if (submitted) {
last_idx = page->index; nwritten++;
} }
if (page == last_page) { if (page == last_page) {
...@@ -1740,8 +1747,8 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode, ...@@ -1740,8 +1747,8 @@ int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
goto retry; goto retry;
} }
out: out:
if (last_idx != ULONG_MAX) if (nwritten)
f2fs_submit_merged_write_cond(sbi, NULL, ino, last_idx, NODE); f2fs_submit_merged_write_cond(sbi, NULL, NULL, ino, NODE);
return ret ? -EIO: 0; return ret ? -EIO: 0;
} }
...@@ -2268,15 +2275,19 @@ static int __f2fs_build_free_nids(struct f2fs_sb_info *sbi, ...@@ -2268,15 +2275,19 @@ static int __f2fs_build_free_nids(struct f2fs_sb_info *sbi,
nm_i->nat_block_bitmap)) { nm_i->nat_block_bitmap)) {
struct page *page = get_current_nat_page(sbi, nid); struct page *page = get_current_nat_page(sbi, nid);
ret = scan_nat_page(sbi, page, nid); if (IS_ERR(page)) {
f2fs_put_page(page, 1); ret = PTR_ERR(page);
} else {
ret = scan_nat_page(sbi, page, nid);
f2fs_put_page(page, 1);
}
if (ret) { if (ret) {
up_read(&nm_i->nat_tree_lock); up_read(&nm_i->nat_tree_lock);
f2fs_bug_on(sbi, !mount); f2fs_bug_on(sbi, !mount);
f2fs_msg(sbi->sb, KERN_ERR, f2fs_msg(sbi->sb, KERN_ERR,
"NAT is corrupt, run fsck to fix it"); "NAT is corrupt, run fsck to fix it");
return -EINVAL; return ret;
} }
} }
...@@ -2353,8 +2364,9 @@ bool f2fs_alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid) ...@@ -2353,8 +2364,9 @@ bool f2fs_alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
spin_unlock(&nm_i->nid_list_lock); spin_unlock(&nm_i->nid_list_lock);
/* Let's scan nat pages and its caches to get free nids */ /* Let's scan nat pages and its caches to get free nids */
f2fs_build_free_nids(sbi, true, false); if (!f2fs_build_free_nids(sbi, true, false))
goto retry; goto retry;
return false;
} }
/* /*
...@@ -2537,7 +2549,7 @@ int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page) ...@@ -2537,7 +2549,7 @@ int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
if (!PageUptodate(ipage)) if (!PageUptodate(ipage))
SetPageUptodate(ipage); SetPageUptodate(ipage);
fill_node_footer(ipage, ino, ino, 0, true); fill_node_footer(ipage, ino, ino, 0, true);
set_cold_node(page, false); set_cold_node(ipage, false);
src = F2FS_INODE(page); src = F2FS_INODE(page);
dst = F2FS_INODE(ipage); dst = F2FS_INODE(ipage);
...@@ -2560,6 +2572,13 @@ int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page) ...@@ -2560,6 +2572,13 @@ int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize), F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize),
i_projid)) i_projid))
dst->i_projid = src->i_projid; dst->i_projid = src->i_projid;
if (f2fs_sb_has_inode_crtime(sbi->sb) &&
F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize),
i_crtime_nsec)) {
dst->i_crtime = src->i_crtime;
dst->i_crtime_nsec = src->i_crtime_nsec;
}
} }
new_ni = old_ni; new_ni = old_ni;
...@@ -2703,7 +2722,7 @@ static void __update_nat_bits(struct f2fs_sb_info *sbi, nid_t start_nid, ...@@ -2703,7 +2722,7 @@ static void __update_nat_bits(struct f2fs_sb_info *sbi, nid_t start_nid,
__clear_bit_le(nat_index, nm_i->full_nat_bits); __clear_bit_le(nat_index, nm_i->full_nat_bits);
} }
static void __flush_nat_entry_set(struct f2fs_sb_info *sbi, static int __flush_nat_entry_set(struct f2fs_sb_info *sbi,
struct nat_entry_set *set, struct cp_control *cpc) struct nat_entry_set *set, struct cp_control *cpc)
{ {
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
...@@ -2727,6 +2746,9 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi, ...@@ -2727,6 +2746,9 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
down_write(&curseg->journal_rwsem); down_write(&curseg->journal_rwsem);
} else { } else {
page = get_next_nat_page(sbi, start_nid); page = get_next_nat_page(sbi, start_nid);
if (IS_ERR(page))
return PTR_ERR(page);
nat_blk = page_address(page); nat_blk = page_address(page);
f2fs_bug_on(sbi, !nat_blk); f2fs_bug_on(sbi, !nat_blk);
} }
...@@ -2772,12 +2794,13 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi, ...@@ -2772,12 +2794,13 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
radix_tree_delete(&NM_I(sbi)->nat_set_root, set->set); radix_tree_delete(&NM_I(sbi)->nat_set_root, set->set);
kmem_cache_free(nat_entry_set_slab, set); kmem_cache_free(nat_entry_set_slab, set);
} }
return 0;
} }
/* /*
* This function is called during the checkpointing process. * This function is called during the checkpointing process.
*/ */
void f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc) int f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
{ {
struct f2fs_nm_info *nm_i = NM_I(sbi); struct f2fs_nm_info *nm_i = NM_I(sbi);
struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
...@@ -2787,6 +2810,7 @@ void f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -2787,6 +2810,7 @@ void f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
unsigned int found; unsigned int found;
nid_t set_idx = 0; nid_t set_idx = 0;
LIST_HEAD(sets); LIST_HEAD(sets);
int err = 0;
/* during unmount, let's flush nat_bits before checking dirty_nat_cnt */ /* during unmount, let's flush nat_bits before checking dirty_nat_cnt */
if (enabled_nat_bits(sbi, cpc)) { if (enabled_nat_bits(sbi, cpc)) {
...@@ -2796,7 +2820,7 @@ void f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -2796,7 +2820,7 @@ void f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
} }
if (!nm_i->dirty_nat_cnt) if (!nm_i->dirty_nat_cnt)
return; return 0;
down_write(&nm_i->nat_tree_lock); down_write(&nm_i->nat_tree_lock);
...@@ -2819,11 +2843,16 @@ void f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc) ...@@ -2819,11 +2843,16 @@ void f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
} }
/* flush dirty nats in nat entry set */ /* flush dirty nats in nat entry set */
list_for_each_entry_safe(set, tmp, &sets, set_list) list_for_each_entry_safe(set, tmp, &sets, set_list) {
__flush_nat_entry_set(sbi, set, cpc); err = __flush_nat_entry_set(sbi, set, cpc);
if (err)
break;
}
up_write(&nm_i->nat_tree_lock); up_write(&nm_i->nat_tree_lock);
/* Allow dirty nats by node block allocation in write_begin */ /* Allow dirty nats by node block allocation in write_begin */
return err;
} }
static int __get_nat_bitmaps(struct f2fs_sb_info *sbi) static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
...@@ -2850,10 +2879,8 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi) ...@@ -2850,10 +2879,8 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
struct page *page; struct page *page;
page = f2fs_get_meta_page(sbi, nat_bits_addr++); page = f2fs_get_meta_page(sbi, nat_bits_addr++);
if (IS_ERR(page)) { if (IS_ERR(page))
disable_nat_bits(sbi, true);
return PTR_ERR(page); return PTR_ERR(page);
}
memcpy(nm_i->nat_bits + (i << F2FS_BLKSIZE_BITS), memcpy(nm_i->nat_bits + (i << F2FS_BLKSIZE_BITS),
page_address(page), F2FS_BLKSIZE); page_address(page), F2FS_BLKSIZE);
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/node.h * fs/f2fs/node.h
* *
* Copyright (c) 2012 Samsung Electronics Co., Ltd. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
* http://www.samsung.com/ * http://www.samsung.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
/* start node id of a node block dedicated to the given node id */ /* start node id of a node block dedicated to the given node id */
#define START_NID(nid) (((nid) / NAT_ENTRY_PER_BLOCK) * NAT_ENTRY_PER_BLOCK) #define START_NID(nid) (((nid) / NAT_ENTRY_PER_BLOCK) * NAT_ENTRY_PER_BLOCK)
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/recovery.c * fs/f2fs/recovery.c
* *
* Copyright (c) 2012 Samsung Electronics Co., Ltd. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
* http://www.samsung.com/ * http://www.samsung.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/f2fs_fs.h> #include <linux/f2fs_fs.h>
...@@ -99,8 +96,12 @@ static struct fsync_inode_entry *add_fsync_inode(struct f2fs_sb_info *sbi, ...@@ -99,8 +96,12 @@ static struct fsync_inode_entry *add_fsync_inode(struct f2fs_sb_info *sbi,
return ERR_PTR(err); return ERR_PTR(err);
} }
static void del_fsync_inode(struct fsync_inode_entry *entry) static void del_fsync_inode(struct fsync_inode_entry *entry, int drop)
{ {
if (drop) {
/* inode should not be recovered, drop it */
f2fs_inode_synced(entry->inode);
}
iput(entry->inode); iput(entry->inode);
list_del(&entry->list); list_del(&entry->list);
kmem_cache_free(fsync_entry_slab, entry); kmem_cache_free(fsync_entry_slab, entry);
...@@ -194,6 +195,33 @@ static int recover_dentry(struct inode *inode, struct page *ipage, ...@@ -194,6 +195,33 @@ static int recover_dentry(struct inode *inode, struct page *ipage,
return err; return err;
} }
static int recover_quota_data(struct inode *inode, struct page *page)
{
struct f2fs_inode *raw = F2FS_INODE(page);
struct iattr attr;
uid_t i_uid = le32_to_cpu(raw->i_uid);
gid_t i_gid = le32_to_cpu(raw->i_gid);
int err;
memset(&attr, 0, sizeof(attr));
attr.ia_uid = make_kuid(inode->i_sb->s_user_ns, i_uid);
attr.ia_gid = make_kgid(inode->i_sb->s_user_ns, i_gid);
if (!uid_eq(attr.ia_uid, inode->i_uid))
attr.ia_valid |= ATTR_UID;
if (!gid_eq(attr.ia_gid, inode->i_gid))
attr.ia_valid |= ATTR_GID;
if (!attr.ia_valid)
return 0;
err = dquot_transfer(inode, &attr);
if (err)
set_sbi_flag(F2FS_I_SB(inode), SBI_QUOTA_NEED_REPAIR);
return err;
}
static void recover_inline_flags(struct inode *inode, struct f2fs_inode *ri) static void recover_inline_flags(struct inode *inode, struct f2fs_inode *ri)
{ {
if (ri->i_inline & F2FS_PIN_FILE) if (ri->i_inline & F2FS_PIN_FILE)
...@@ -206,12 +234,41 @@ static void recover_inline_flags(struct inode *inode, struct f2fs_inode *ri) ...@@ -206,12 +234,41 @@ static void recover_inline_flags(struct inode *inode, struct f2fs_inode *ri)
clear_inode_flag(inode, FI_DATA_EXIST); clear_inode_flag(inode, FI_DATA_EXIST);
} }
static void recover_inode(struct inode *inode, struct page *page) static int recover_inode(struct inode *inode, struct page *page)
{ {
struct f2fs_inode *raw = F2FS_INODE(page); struct f2fs_inode *raw = F2FS_INODE(page);
char *name; char *name;
int err;
inode->i_mode = le16_to_cpu(raw->i_mode); inode->i_mode = le16_to_cpu(raw->i_mode);
err = recover_quota_data(inode, page);
if (err)
return err;
i_uid_write(inode, le32_to_cpu(raw->i_uid));
i_gid_write(inode, le32_to_cpu(raw->i_gid));
if (raw->i_inline & F2FS_EXTRA_ATTR) {
if (f2fs_sb_has_project_quota(F2FS_I_SB(inode)->sb) &&
F2FS_FITS_IN_INODE(raw, le16_to_cpu(raw->i_extra_isize),
i_projid)) {
projid_t i_projid;
kprojid_t kprojid;
i_projid = (projid_t)le32_to_cpu(raw->i_projid);
kprojid = make_kprojid(&init_user_ns, i_projid);
if (!projid_eq(kprojid, F2FS_I(inode)->i_projid)) {
err = f2fs_transfer_project_quota(inode,
kprojid);
if (err)
return err;
F2FS_I(inode)->i_projid = kprojid;
}
}
}
f2fs_i_size_write(inode, le64_to_cpu(raw->i_size)); f2fs_i_size_write(inode, le64_to_cpu(raw->i_size));
inode->i_atime.tv_sec = le64_to_cpu(raw->i_atime); inode->i_atime.tv_sec = le64_to_cpu(raw->i_atime);
inode->i_ctime.tv_sec = le64_to_cpu(raw->i_ctime); inode->i_ctime.tv_sec = le64_to_cpu(raw->i_ctime);
...@@ -221,9 +278,15 @@ static void recover_inode(struct inode *inode, struct page *page) ...@@ -221,9 +278,15 @@ static void recover_inode(struct inode *inode, struct page *page)
inode->i_mtime.tv_nsec = le32_to_cpu(raw->i_mtime_nsec); inode->i_mtime.tv_nsec = le32_to_cpu(raw->i_mtime_nsec);
F2FS_I(inode)->i_advise = raw->i_advise; F2FS_I(inode)->i_advise = raw->i_advise;
F2FS_I(inode)->i_flags = le32_to_cpu(raw->i_flags);
f2fs_set_inode_flags(inode);
F2FS_I(inode)->i_gc_failures[GC_FAILURE_PIN] =
le16_to_cpu(raw->i_gc_failures);
recover_inline_flags(inode, raw); recover_inline_flags(inode, raw);
f2fs_mark_inode_dirty_sync(inode, true);
if (file_enc_name(inode)) if (file_enc_name(inode))
name = "<encrypted>"; name = "<encrypted>";
else else
...@@ -232,6 +295,7 @@ static void recover_inode(struct inode *inode, struct page *page) ...@@ -232,6 +295,7 @@ static void recover_inode(struct inode *inode, struct page *page)
f2fs_msg(inode->i_sb, KERN_NOTICE, f2fs_msg(inode->i_sb, KERN_NOTICE,
"recover_inode: ino = %x, name = %s, inline = %x", "recover_inode: ino = %x, name = %s, inline = %x",
ino_of_node(page), name, raw->i_inline); ino_of_node(page), name, raw->i_inline);
return 0;
} }
static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head, static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head,
...@@ -320,12 +384,12 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head, ...@@ -320,12 +384,12 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head,
return err; return err;
} }
static void destroy_fsync_dnodes(struct list_head *head) static void destroy_fsync_dnodes(struct list_head *head, int drop)
{ {
struct fsync_inode_entry *entry, *tmp; struct fsync_inode_entry *entry, *tmp;
list_for_each_entry_safe(entry, tmp, head, list) list_for_each_entry_safe(entry, tmp, head, list)
del_fsync_inode(entry); del_fsync_inode(entry, drop);
} }
static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi, static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
...@@ -358,6 +422,8 @@ static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi, ...@@ -358,6 +422,8 @@ static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
} }
sum_page = f2fs_get_sum_page(sbi, segno); sum_page = f2fs_get_sum_page(sbi, segno);
if (IS_ERR(sum_page))
return PTR_ERR(sum_page);
sum_node = (struct f2fs_summary_block *)page_address(sum_page); sum_node = (struct f2fs_summary_block *)page_address(sum_page);
sum = sum_node->entries[blkoff]; sum = sum_node->entries[blkoff];
f2fs_put_page(sum_page, 1); f2fs_put_page(sum_page, 1);
...@@ -560,7 +626,7 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode, ...@@ -560,7 +626,7 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
} }
static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list, static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list,
struct list_head *dir_list) struct list_head *tmp_inode_list, struct list_head *dir_list)
{ {
struct curseg_info *curseg; struct curseg_info *curseg;
struct page *page = NULL; struct page *page = NULL;
...@@ -598,8 +664,11 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list, ...@@ -598,8 +664,11 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list,
* In this case, we can lose the latest inode(x). * In this case, we can lose the latest inode(x).
* So, call recover_inode for the inode update. * So, call recover_inode for the inode update.
*/ */
if (IS_INODE(page)) if (IS_INODE(page)) {
recover_inode(entry->inode, page); err = recover_inode(entry->inode, page);
if (err)
break;
}
if (entry->last_dentry == blkaddr) { if (entry->last_dentry == blkaddr) {
err = recover_dentry(entry->inode, page, dir_list); err = recover_dentry(entry->inode, page, dir_list);
if (err) { if (err) {
...@@ -614,7 +683,7 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list, ...@@ -614,7 +683,7 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list,
} }
if (entry->blkaddr == blkaddr) if (entry->blkaddr == blkaddr)
del_fsync_inode(entry); list_move_tail(&entry->list, tmp_inode_list);
next: next:
/* check next segment */ /* check next segment */
blkaddr = next_blkaddr_of_node(page); blkaddr = next_blkaddr_of_node(page);
...@@ -627,7 +696,7 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list, ...@@ -627,7 +696,7 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list,
int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
{ {
struct list_head inode_list; struct list_head inode_list, tmp_inode_list;
struct list_head dir_list; struct list_head dir_list;
int err; int err;
int ret = 0; int ret = 0;
...@@ -658,6 +727,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) ...@@ -658,6 +727,7 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
} }
INIT_LIST_HEAD(&inode_list); INIT_LIST_HEAD(&inode_list);
INIT_LIST_HEAD(&tmp_inode_list);
INIT_LIST_HEAD(&dir_list); INIT_LIST_HEAD(&dir_list);
/* prevent checkpoint */ /* prevent checkpoint */
...@@ -676,11 +746,16 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) ...@@ -676,11 +746,16 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
need_writecp = true; need_writecp = true;
/* step #2: recover data */ /* step #2: recover data */
err = recover_data(sbi, &inode_list, &dir_list); err = recover_data(sbi, &inode_list, &tmp_inode_list, &dir_list);
if (!err) if (!err)
f2fs_bug_on(sbi, !list_empty(&inode_list)); f2fs_bug_on(sbi, !list_empty(&inode_list));
else {
/* restore s_flags to let iput() trash data */
sbi->sb->s_flags = s_flags;
}
skip: skip:
destroy_fsync_dnodes(&inode_list); destroy_fsync_dnodes(&inode_list, err);
destroy_fsync_dnodes(&tmp_inode_list, err);
/* truncate meta pages to be used by the recovery */ /* truncate meta pages to be used by the recovery */
truncate_inode_pages_range(META_MAPPING(sbi), truncate_inode_pages_range(META_MAPPING(sbi),
...@@ -689,19 +764,23 @@ int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only) ...@@ -689,19 +764,23 @@ 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);
} }
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 */
destroy_fsync_dnodes(&dir_list); destroy_fsync_dnodes(&dir_list, err);
if (!err && need_writecp) { if (need_writecp) {
struct cp_control cpc = { set_sbi_flag(sbi, SBI_IS_RECOVERED);
.reason = CP_RECOVERY,
}; if (!err) {
err = f2fs_write_checkpoint(sbi, &cpc); struct cp_control cpc = {
.reason = CP_RECOVERY,
};
err = f2fs_write_checkpoint(sbi, &cpc);
}
} }
kmem_cache_destroy(fsync_entry_slab); kmem_cache_destroy(fsync_entry_slab);
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/segment.h * fs/f2fs/segment.h
* *
* Copyright (c) 2012 Samsung Electronics Co., Ltd. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
* http://www.samsung.com/ * http://www.samsung.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/backing-dev.h> #include <linux/backing-dev.h>
...@@ -342,6 +339,12 @@ static inline unsigned int get_valid_blocks(struct f2fs_sb_info *sbi, ...@@ -342,6 +339,12 @@ static inline unsigned int get_valid_blocks(struct f2fs_sb_info *sbi,
return get_seg_entry(sbi, segno)->valid_blocks; return get_seg_entry(sbi, segno)->valid_blocks;
} }
static inline unsigned int get_ckpt_valid_blocks(struct f2fs_sb_info *sbi,
unsigned int segno)
{
return get_seg_entry(sbi, segno)->ckpt_valid_blocks;
}
static inline void seg_info_from_raw_sit(struct seg_entry *se, static inline void seg_info_from_raw_sit(struct seg_entry *se,
struct f2fs_sit_entry *rs) struct f2fs_sit_entry *rs)
{ {
...@@ -579,6 +582,15 @@ static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi, ...@@ -579,6 +582,15 @@ static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi,
reserved_sections(sbi) + needed); reserved_sections(sbi) + needed);
} }
static inline int f2fs_is_checkpoint_ready(struct f2fs_sb_info *sbi)
{
if (likely(!is_sbi_flag_set(sbi, SBI_CP_DISABLED)))
return 0;
if (likely(!has_not_enough_free_secs(sbi, 0, 0)))
return 0;
return -ENOSPC;
}
static inline bool excess_prefree_segs(struct f2fs_sb_info *sbi) static inline bool excess_prefree_segs(struct f2fs_sb_info *sbi)
{ {
return prefree_segments(sbi) > SM_I(sbi)->rec_prefree_segments; return prefree_segments(sbi) > SM_I(sbi)->rec_prefree_segments;
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* f2fs shrinker support * f2fs shrinker support
* the basic infra was copied from fs/ubifs/shrinker.c * the basic infra was copied from fs/ubifs/shrinker.c
* *
* Copyright (c) 2015 Motorola Mobility * Copyright (c) 2015 Motorola Mobility
* Copyright (c) 2015 Jaegeuk Kim <jaegeuk@kernel.org> * Copyright (c) 2015 Jaegeuk Kim <jaegeuk@kernel.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/f2fs_fs.h> #include <linux/f2fs_fs.h>
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0
/* /*
* f2fs sysfs interface * f2fs sysfs interface
* *
* Copyright (c) 2012 Samsung Electronics Co., Ltd. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
* http://www.samsung.com/ * http://www.samsung.com/
* Copyright (c) 2017 Chao Yu <chao@kernel.org> * Copyright (c) 2017 Chao Yu <chao@kernel.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/proc_fs.h> #include <linux/proc_fs.h>
...@@ -120,6 +117,9 @@ static ssize_t features_show(struct f2fs_attr *a, ...@@ -120,6 +117,9 @@ static ssize_t features_show(struct f2fs_attr *a,
if (f2fs_sb_has_lost_found(sb)) if (f2fs_sb_has_lost_found(sb))
len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
len ? ", " : "", "lost_found"); len ? ", " : "", "lost_found");
if (f2fs_sb_has_sb_chksum(sb))
len += snprintf(buf + len, PAGE_SIZE - len, "%s%s",
len ? ", " : "", "sb_checksum");
len += snprintf(buf + len, PAGE_SIZE - len, "\n"); len += snprintf(buf + len, PAGE_SIZE - len, "\n");
return len; return len;
} }
...@@ -337,6 +337,7 @@ enum feat_id { ...@@ -337,6 +337,7 @@ enum feat_id {
FEAT_QUOTA_INO, FEAT_QUOTA_INO,
FEAT_INODE_CRTIME, FEAT_INODE_CRTIME,
FEAT_LOST_FOUND, FEAT_LOST_FOUND,
FEAT_SB_CHECKSUM,
}; };
static ssize_t f2fs_feature_show(struct f2fs_attr *a, static ssize_t f2fs_feature_show(struct f2fs_attr *a,
...@@ -353,6 +354,7 @@ static ssize_t f2fs_feature_show(struct f2fs_attr *a, ...@@ -353,6 +354,7 @@ static ssize_t f2fs_feature_show(struct f2fs_attr *a,
case FEAT_QUOTA_INO: case FEAT_QUOTA_INO:
case FEAT_INODE_CRTIME: case FEAT_INODE_CRTIME:
case FEAT_LOST_FOUND: case FEAT_LOST_FOUND:
case FEAT_SB_CHECKSUM:
return snprintf(buf, PAGE_SIZE, "supported\n"); return snprintf(buf, PAGE_SIZE, "supported\n");
} }
return 0; return 0;
...@@ -407,6 +409,9 @@ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search); ...@@ -407,6 +409,9 @@ F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search);
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level); F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level);
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, cp_interval, interval_time[CP_TIME]); F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, cp_interval, interval_time[CP_TIME]);
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, idle_interval, interval_time[REQ_TIME]); F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, idle_interval, interval_time[REQ_TIME]);
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, discard_idle_interval,
interval_time[DISCARD_TIME]);
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_idle_interval, interval_time[GC_TIME]);
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, iostat_enable, iostat_enable); F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, iostat_enable, iostat_enable);
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, readdir_ra, readdir_ra); F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, readdir_ra, readdir_ra);
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_pin_file_thresh, gc_pin_file_threshold); F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_pin_file_thresh, gc_pin_file_threshold);
...@@ -434,6 +439,7 @@ F2FS_FEATURE_RO_ATTR(flexible_inline_xattr, FEAT_FLEXIBLE_INLINE_XATTR); ...@@ -434,6 +439,7 @@ F2FS_FEATURE_RO_ATTR(flexible_inline_xattr, FEAT_FLEXIBLE_INLINE_XATTR);
F2FS_FEATURE_RO_ATTR(quota_ino, FEAT_QUOTA_INO); F2FS_FEATURE_RO_ATTR(quota_ino, FEAT_QUOTA_INO);
F2FS_FEATURE_RO_ATTR(inode_crtime, FEAT_INODE_CRTIME); F2FS_FEATURE_RO_ATTR(inode_crtime, FEAT_INODE_CRTIME);
F2FS_FEATURE_RO_ATTR(lost_found, FEAT_LOST_FOUND); F2FS_FEATURE_RO_ATTR(lost_found, FEAT_LOST_FOUND);
F2FS_FEATURE_RO_ATTR(sb_checksum, FEAT_SB_CHECKSUM);
#define ATTR_LIST(name) (&f2fs_attr_##name.attr) #define ATTR_LIST(name) (&f2fs_attr_##name.attr)
static struct attribute *f2fs_attrs[] = { static struct attribute *f2fs_attrs[] = {
...@@ -460,6 +466,8 @@ static struct attribute *f2fs_attrs[] = { ...@@ -460,6 +466,8 @@ static struct attribute *f2fs_attrs[] = {
ATTR_LIST(dirty_nats_ratio), ATTR_LIST(dirty_nats_ratio),
ATTR_LIST(cp_interval), ATTR_LIST(cp_interval),
ATTR_LIST(idle_interval), ATTR_LIST(idle_interval),
ATTR_LIST(discard_idle_interval),
ATTR_LIST(gc_idle_interval),
ATTR_LIST(iostat_enable), ATTR_LIST(iostat_enable),
ATTR_LIST(readdir_ra), ATTR_LIST(readdir_ra),
ATTR_LIST(gc_pin_file_thresh), ATTR_LIST(gc_pin_file_thresh),
...@@ -491,6 +499,7 @@ static struct attribute *f2fs_feat_attrs[] = { ...@@ -491,6 +499,7 @@ static struct attribute *f2fs_feat_attrs[] = {
ATTR_LIST(quota_ino), ATTR_LIST(quota_ino),
ATTR_LIST(inode_crtime), ATTR_LIST(inode_crtime),
ATTR_LIST(lost_found), ATTR_LIST(lost_found),
ATTR_LIST(sb_checksum),
NULL, NULL,
}; };
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* f2fs IO tracer * f2fs IO tracer
* *
* Copyright (c) 2014 Motorola Mobility * Copyright (c) 2014 Motorola Mobility
* Copyright (c) 2014 Jaegeuk Kim <jaegeuk@kernel.org> * Copyright (c) 2014 Jaegeuk Kim <jaegeuk@kernel.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/f2fs_fs.h> #include <linux/f2fs_fs.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* f2fs IO tracer * f2fs IO tracer
* *
* Copyright (c) 2014 Motorola Mobility * Copyright (c) 2014 Motorola Mobility
* Copyright (c) 2014 Jaegeuk Kim <jaegeuk@kernel.org> * Copyright (c) 2014 Jaegeuk Kim <jaegeuk@kernel.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#ifndef __F2FS_TRACE_H__ #ifndef __F2FS_TRACE_H__
#define __F2FS_TRACE_H__ #define __F2FS_TRACE_H__
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/xattr.c * fs/f2fs/xattr.c
* *
...@@ -13,10 +14,6 @@ ...@@ -13,10 +14,6 @@
* suggestion of Luka Renko <luka.renko@hermes.si>. * suggestion of Luka Renko <luka.renko@hermes.si>.
* xattr consolidation Copyright (c) 2004 James Morris <jmorris@redhat.com>, * xattr consolidation Copyright (c) 2004 James Morris <jmorris@redhat.com>,
* Red Hat Inc. * Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#include <linux/rwsem.h> #include <linux/rwsem.h>
#include <linux/f2fs_fs.h> #include <linux/f2fs_fs.h>
......
// SPDX-License-Identifier: GPL-2.0
/* /*
* fs/f2fs/xattr.h * fs/f2fs/xattr.h
* *
...@@ -9,10 +10,6 @@ ...@@ -9,10 +10,6 @@
* On-disk format of extended attributes for the ext2 filesystem. * On-disk format of extended attributes for the ext2 filesystem.
* *
* (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org> * (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#ifndef __F2FS_XATTR_H__ #ifndef __F2FS_XATTR_H__
#define __F2FS_XATTR_H__ #define __F2FS_XATTR_H__
......
// SPDX-License-Identifier: GPL-2.0
/** /**
* include/linux/f2fs_fs.h * include/linux/f2fs_fs.h
* *
* Copyright (c) 2012 Samsung Electronics Co., Ltd. * Copyright (c) 2012 Samsung Electronics Co., Ltd.
* http://www.samsung.com/ * http://www.samsung.com/
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/ */
#ifndef _LINUX_F2FS_FS_H #ifndef _LINUX_F2FS_FS_H
#define _LINUX_F2FS_FS_H #define _LINUX_F2FS_FS_H
...@@ -112,12 +109,15 @@ struct f2fs_super_block { ...@@ -112,12 +109,15 @@ struct f2fs_super_block {
struct f2fs_device devs[MAX_DEVICES]; /* device list */ struct f2fs_device devs[MAX_DEVICES]; /* device list */
__le32 qf_ino[F2FS_MAX_QUOTAS]; /* quota inode numbers */ __le32 qf_ino[F2FS_MAX_QUOTAS]; /* quota inode numbers */
__u8 hot_ext_count; /* # of hot file extension */ __u8 hot_ext_count; /* # of hot file extension */
__u8 reserved[314]; /* valid reserved region */ __u8 reserved[310]; /* valid reserved region */
__le32 crc; /* checksum of superblock */
} __packed; } __packed;
/* /*
* For checkpoint * For checkpoint
*/ */
#define CP_DISABLED_FLAG 0x00001000
#define CP_QUOTA_NEED_FSCK_FLAG 0x00000800
#define CP_LARGE_NAT_BITMAP_FLAG 0x00000400 #define CP_LARGE_NAT_BITMAP_FLAG 0x00000400
#define CP_NOCRC_RECOVERY_FLAG 0x00000200 #define CP_NOCRC_RECOVERY_FLAG 0x00000200
#define CP_TRIMMED_FLAG 0x00000100 #define CP_TRIMMED_FLAG 0x00000100
......
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