super.c (5298d4bfe80f6ae6ae2777bcd1357b0022d98573) super.c (e4544b63a7ee49e7fbebf35ece0a6acd3b9617ae)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/super.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#include <linux/module.h>

--- 45 unchanged lines hidden (view full) ---

54 [FAULT_EVICT_INODE] = "evict_inode fail",
55 [FAULT_TRUNCATE] = "truncate fail",
56 [FAULT_READ_IO] = "read IO error",
57 [FAULT_CHECKPOINT] = "checkpoint error",
58 [FAULT_DISCARD] = "discard error",
59 [FAULT_WRITE_IO] = "write IO error",
60 [FAULT_SLAB_ALLOC] = "slab alloc",
61 [FAULT_DQUOT_INIT] = "dquot initialize",
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/super.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#include <linux/module.h>

--- 45 unchanged lines hidden (view full) ---

54 [FAULT_EVICT_INODE] = "evict_inode fail",
55 [FAULT_TRUNCATE] = "truncate fail",
56 [FAULT_READ_IO] = "read IO error",
57 [FAULT_CHECKPOINT] = "checkpoint error",
58 [FAULT_DISCARD] = "discard error",
59 [FAULT_WRITE_IO] = "write IO error",
60 [FAULT_SLAB_ALLOC] = "slab alloc",
61 [FAULT_DQUOT_INIT] = "dquot initialize",
62 [FAULT_LOCK_OP] = "lock_op",
62};
63
64void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate,
65 unsigned int type)
66{
67 struct f2fs_fault_info *ffi = &F2FS_OPTION(sbi).fault_info;
68
69 if (rate) {

--- 181 unchanged lines hidden (view full) ---

251 vaf.fmt = printk_skip_level(fmt);
252 vaf.va = &args;
253 printk("%c%cF2FS-fs (%s): %pV\n",
254 KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf);
255
256 va_end(args);
257}
258
63};
64
65void f2fs_build_fault_attr(struct f2fs_sb_info *sbi, unsigned int rate,
66 unsigned int type)
67{
68 struct f2fs_fault_info *ffi = &F2FS_OPTION(sbi).fault_info;
69
70 if (rate) {

--- 181 unchanged lines hidden (view full) ---

252 vaf.fmt = printk_skip_level(fmt);
253 vaf.va = &args;
254 printk("%c%cF2FS-fs (%s): %pV\n",
255 KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf);
256
257 va_end(args);
258}
259
259#if IS_ENABLED(CONFIG_UNICODE)
260#ifdef CONFIG_UNICODE
260static const struct f2fs_sb_encodings {
261 __u16 magic;
262 char *name;
263 unsigned int version;
264} f2fs_sb_encoding_map[] = {
265 {F2FS_ENC_UTF8_12_1, "utf8", UNICODE_AGE(12, 1, 0)},
266};
267

--- 48 unchanged lines hidden (view full) ---

316 make_kgid(&init_user_ns, F2FS_DEF_RESGID))))
317 f2fs_info(sbi, "Ignore s_resuid=%u, s_resgid=%u w/o reserve_root",
318 from_kuid_munged(&init_user_ns,
319 F2FS_OPTION(sbi).s_resuid),
320 from_kgid_munged(&init_user_ns,
321 F2FS_OPTION(sbi).s_resgid));
322}
323
261static const struct f2fs_sb_encodings {
262 __u16 magic;
263 char *name;
264 unsigned int version;
265} f2fs_sb_encoding_map[] = {
266 {F2FS_ENC_UTF8_12_1, "utf8", UNICODE_AGE(12, 1, 0)},
267};
268

--- 48 unchanged lines hidden (view full) ---

317 make_kgid(&init_user_ns, F2FS_DEF_RESGID))))
318 f2fs_info(sbi, "Ignore s_resuid=%u, s_resgid=%u w/o reserve_root",
319 from_kuid_munged(&init_user_ns,
320 F2FS_OPTION(sbi).s_resuid),
321 from_kgid_munged(&init_user_ns,
322 F2FS_OPTION(sbi).s_resgid));
323}
324
325static inline int adjust_reserved_segment(struct f2fs_sb_info *sbi)
326{
327 unsigned int sec_blks = sbi->blocks_per_seg * sbi->segs_per_sec;
328 unsigned int avg_vblocks;
329 unsigned int wanted_reserved_segments;
330 block_t avail_user_block_count;
331
332 if (!F2FS_IO_ALIGNED(sbi))
333 return 0;
334
335 /* average valid block count in section in worst case */
336 avg_vblocks = sec_blks / F2FS_IO_SIZE(sbi);
337
338 /*
339 * we need enough free space when migrating one section in worst case
340 */
341 wanted_reserved_segments = (F2FS_IO_SIZE(sbi) / avg_vblocks) *
342 reserved_segments(sbi);
343 wanted_reserved_segments -= reserved_segments(sbi);
344
345 avail_user_block_count = sbi->user_block_count -
346 sbi->current_reserved_blocks -
347 F2FS_OPTION(sbi).root_reserved_blocks;
348
349 if (wanted_reserved_segments * sbi->blocks_per_seg >
350 avail_user_block_count) {
351 f2fs_err(sbi, "IO align feature can't grab additional reserved segment: %u, available segments: %u",
352 wanted_reserved_segments,
353 avail_user_block_count >> sbi->log_blocks_per_seg);
354 return -ENOSPC;
355 }
356
357 SM_I(sbi)->additional_reserved_segments = wanted_reserved_segments;
358
359 f2fs_info(sbi, "IO align feature needs additional reserved segment: %u",
360 wanted_reserved_segments);
361
362 return 0;
363}
364
324static inline void adjust_unusable_cap_perc(struct f2fs_sb_info *sbi)
325{
326 if (!F2FS_OPTION(sbi).unusable_cap_perc)
327 return;
328
329 if (F2FS_OPTION(sbi).unusable_cap_perc == 100)
330 F2FS_OPTION(sbi).unusable_cap = sbi->user_block_count;
331 else

--- 881 unchanged lines hidden (view full) ---

1213 f2fs_info(sbi, "Filesystem with quota feature cannot be mounted RDWR without CONFIG_QUOTA");
1214 return -EINVAL;
1215 }
1216 if (f2fs_sb_has_project_quota(sbi) && !f2fs_readonly(sbi->sb)) {
1217 f2fs_err(sbi, "Filesystem with project quota feature cannot be mounted RDWR without CONFIG_QUOTA");
1218 return -EINVAL;
1219 }
1220#endif
365static inline void adjust_unusable_cap_perc(struct f2fs_sb_info *sbi)
366{
367 if (!F2FS_OPTION(sbi).unusable_cap_perc)
368 return;
369
370 if (F2FS_OPTION(sbi).unusable_cap_perc == 100)
371 F2FS_OPTION(sbi).unusable_cap = sbi->user_block_count;
372 else

--- 881 unchanged lines hidden (view full) ---

1254 f2fs_info(sbi, "Filesystem with quota feature cannot be mounted RDWR without CONFIG_QUOTA");
1255 return -EINVAL;
1256 }
1257 if (f2fs_sb_has_project_quota(sbi) && !f2fs_readonly(sbi->sb)) {
1258 f2fs_err(sbi, "Filesystem with project quota feature cannot be mounted RDWR without CONFIG_QUOTA");
1259 return -EINVAL;
1260 }
1261#endif
1221#if !IS_ENABLED(CONFIG_UNICODE)
1262#ifndef CONFIG_UNICODE
1222 if (f2fs_sb_has_casefold(sbi)) {
1223 f2fs_err(sbi,
1224 "Filesystem with casefold feature cannot be mounted without CONFIG_UNICODE");
1225 return -EINVAL;
1226 }
1227#endif
1228 /*
1229 * The BLKZONED feature indicates that the drive was formatted with

--- 79 unchanged lines hidden (view full) ---

1309 if (!fi)
1310 return NULL;
1311
1312 init_once((void *) fi);
1313
1314 /* Initialize f2fs-specific inode info */
1315 atomic_set(&fi->dirty_pages, 0);
1316 atomic_set(&fi->i_compr_blocks, 0);
1263 if (f2fs_sb_has_casefold(sbi)) {
1264 f2fs_err(sbi,
1265 "Filesystem with casefold feature cannot be mounted without CONFIG_UNICODE");
1266 return -EINVAL;
1267 }
1268#endif
1269 /*
1270 * The BLKZONED feature indicates that the drive was formatted with

--- 79 unchanged lines hidden (view full) ---

1350 if (!fi)
1351 return NULL;
1352
1353 init_once((void *) fi);
1354
1355 /* Initialize f2fs-specific inode info */
1356 atomic_set(&fi->dirty_pages, 0);
1357 atomic_set(&fi->i_compr_blocks, 0);
1317 init_rwsem(&fi->i_sem);
1358 init_f2fs_rwsem(&fi->i_sem);
1318 spin_lock_init(&fi->i_size_lock);
1319 INIT_LIST_HEAD(&fi->dirty_list);
1320 INIT_LIST_HEAD(&fi->gdirty_list);
1321 INIT_LIST_HEAD(&fi->inmem_ilist);
1322 INIT_LIST_HEAD(&fi->inmem_pages);
1323 mutex_init(&fi->inmem_lock);
1359 spin_lock_init(&fi->i_size_lock);
1360 INIT_LIST_HEAD(&fi->dirty_list);
1361 INIT_LIST_HEAD(&fi->gdirty_list);
1362 INIT_LIST_HEAD(&fi->inmem_ilist);
1363 INIT_LIST_HEAD(&fi->inmem_pages);
1364 mutex_init(&fi->inmem_lock);
1324 init_rwsem(&fi->i_gc_rwsem[READ]);
1325 init_rwsem(&fi->i_gc_rwsem[WRITE]);
1326 init_rwsem(&fi->i_xattr_sem);
1365 init_f2fs_rwsem(&fi->i_gc_rwsem[READ]);
1366 init_f2fs_rwsem(&fi->i_gc_rwsem[WRITE]);
1367 init_f2fs_rwsem(&fi->i_xattr_sem);
1327
1328 /* Will be used by directory only */
1329 fi->i_dir_level = F2FS_SB(sb)->dir_level;
1330
1331 return &fi->vfs_inode;
1332}
1333
1334static int f2fs_drop_inode(struct inode *inode)

--- 238 unchanged lines hidden (view full) ---

1573 for (i = 0; i < MAXQUOTAS; i++)
1574 kfree(F2FS_OPTION(sbi).s_qf_names[i]);
1575#endif
1576 fscrypt_free_dummy_policy(&F2FS_OPTION(sbi).dummy_enc_policy);
1577 destroy_percpu_info(sbi);
1578 f2fs_destroy_iostat(sbi);
1579 for (i = 0; i < NR_PAGE_TYPE; i++)
1580 kvfree(sbi->write_io[i]);
1368
1369 /* Will be used by directory only */
1370 fi->i_dir_level = F2FS_SB(sb)->dir_level;
1371
1372 return &fi->vfs_inode;
1373}
1374
1375static int f2fs_drop_inode(struct inode *inode)

--- 238 unchanged lines hidden (view full) ---

1614 for (i = 0; i < MAXQUOTAS; i++)
1615 kfree(F2FS_OPTION(sbi).s_qf_names[i]);
1616#endif
1617 fscrypt_free_dummy_policy(&F2FS_OPTION(sbi).dummy_enc_policy);
1618 destroy_percpu_info(sbi);
1619 f2fs_destroy_iostat(sbi);
1620 for (i = 0; i < NR_PAGE_TYPE; i++)
1621 kvfree(sbi->write_io[i]);
1581#if IS_ENABLED(CONFIG_UNICODE)
1622#ifdef CONFIG_UNICODE
1582 utf8_unload(sb->s_encoding);
1583#endif
1584 kfree(sbi);
1585}
1586
1587int f2fs_sync_fs(struct super_block *sb, int sync)
1588{
1589 struct f2fs_sb_info *sbi = F2FS_SB(sb);

--- 452 unchanged lines hidden (view full) ---

2042 f2fs_err(sbi, "checkpoint=disable on readonly fs");
2043 return -EINVAL;
2044 }
2045 sbi->sb->s_flags |= SB_ACTIVE;
2046
2047 f2fs_update_time(sbi, DISABLE_TIME);
2048
2049 while (!f2fs_time_over(sbi, DISABLE_TIME)) {
1623 utf8_unload(sb->s_encoding);
1624#endif
1625 kfree(sbi);
1626}
1627
1628int f2fs_sync_fs(struct super_block *sb, int sync)
1629{
1630 struct f2fs_sb_info *sbi = F2FS_SB(sb);

--- 452 unchanged lines hidden (view full) ---

2083 f2fs_err(sbi, "checkpoint=disable on readonly fs");
2084 return -EINVAL;
2085 }
2086 sbi->sb->s_flags |= SB_ACTIVE;
2087
2088 f2fs_update_time(sbi, DISABLE_TIME);
2089
2090 while (!f2fs_time_over(sbi, DISABLE_TIME)) {
2050 down_write(&sbi->gc_lock);
2091 f2fs_down_write(&sbi->gc_lock);
2051 err = f2fs_gc(sbi, true, false, false, NULL_SEGNO);
2052 if (err == -ENODATA) {
2053 err = 0;
2054 break;
2055 }
2056 if (err && err != -EAGAIN)
2057 break;
2058 }

--- 5 unchanged lines hidden (view full) ---

2064 }
2065
2066 unusable = f2fs_get_unusable_blocks(sbi);
2067 if (f2fs_disable_cp_again(sbi, unusable)) {
2068 err = -EAGAIN;
2069 goto restore_flag;
2070 }
2071
2092 err = f2fs_gc(sbi, true, false, false, NULL_SEGNO);
2093 if (err == -ENODATA) {
2094 err = 0;
2095 break;
2096 }
2097 if (err && err != -EAGAIN)
2098 break;
2099 }

--- 5 unchanged lines hidden (view full) ---

2105 }
2106
2107 unusable = f2fs_get_unusable_blocks(sbi);
2108 if (f2fs_disable_cp_again(sbi, unusable)) {
2109 err = -EAGAIN;
2110 goto restore_flag;
2111 }
2112
2072 down_write(&sbi->gc_lock);
2113 f2fs_down_write(&sbi->gc_lock);
2073 cpc.reason = CP_PAUSE;
2074 set_sbi_flag(sbi, SBI_CP_DISABLED);
2075 err = f2fs_write_checkpoint(sbi, &cpc);
2076 if (err)
2077 goto out_unlock;
2078
2079 spin_lock(&sbi->stat_lock);
2080 sbi->unusable_block_count = unusable;
2081 spin_unlock(&sbi->stat_lock);
2082
2083out_unlock:
2114 cpc.reason = CP_PAUSE;
2115 set_sbi_flag(sbi, SBI_CP_DISABLED);
2116 err = f2fs_write_checkpoint(sbi, &cpc);
2117 if (err)
2118 goto out_unlock;
2119
2120 spin_lock(&sbi->stat_lock);
2121 sbi->unusable_block_count = unusable;
2122 spin_unlock(&sbi->stat_lock);
2123
2124out_unlock:
2084 up_write(&sbi->gc_lock);
2125 f2fs_up_write(&sbi->gc_lock);
2085restore_flag:
2086 sbi->sb->s_flags = s_flags; /* Restore SB_RDONLY status */
2087 return err;
2088}
2089
2090static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
2091{
2092 int retry = DEFAULT_RETRY_IO_COUNT;
2093
2094 /* we should flush all the data to keep data consistency */
2095 do {
2096 sync_inodes_sb(sbi->sb);
2097 cond_resched();
2098 congestion_wait(BLK_RW_ASYNC, DEFAULT_IO_TIMEOUT);
2099 } while (get_pages(sbi, F2FS_DIRTY_DATA) && retry--);
2100
2101 if (unlikely(retry < 0))
2102 f2fs_warn(sbi, "checkpoint=enable has some unwritten data.");
2103
2126restore_flag:
2127 sbi->sb->s_flags = s_flags; /* Restore SB_RDONLY status */
2128 return err;
2129}
2130
2131static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi)
2132{
2133 int retry = DEFAULT_RETRY_IO_COUNT;
2134
2135 /* we should flush all the data to keep data consistency */
2136 do {
2137 sync_inodes_sb(sbi->sb);
2138 cond_resched();
2139 congestion_wait(BLK_RW_ASYNC, DEFAULT_IO_TIMEOUT);
2140 } while (get_pages(sbi, F2FS_DIRTY_DATA) && retry--);
2141
2142 if (unlikely(retry < 0))
2143 f2fs_warn(sbi, "checkpoint=enable has some unwritten data.");
2144
2104 down_write(&sbi->gc_lock);
2145 f2fs_down_write(&sbi->gc_lock);
2105 f2fs_dirty_to_prefree(sbi);
2106
2107 clear_sbi_flag(sbi, SBI_CP_DISABLED);
2108 set_sbi_flag(sbi, SBI_IS_DIRTY);
2146 f2fs_dirty_to_prefree(sbi);
2147
2148 clear_sbi_flag(sbi, SBI_CP_DISABLED);
2149 set_sbi_flag(sbi, SBI_IS_DIRTY);
2109 up_write(&sbi->gc_lock);
2150 f2fs_up_write(&sbi->gc_lock);
2110
2111 f2fs_sync_fs(sbi->sb, 1);
2112}
2113
2114static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2115{
2116 struct f2fs_sb_info *sbi = F2FS_SB(sb);
2117 struct f2fs_mount_info org_mount_opt;

--- 543 unchanged lines hidden (view full) ---

2661 if (!sb_has_quota_active(sb, type))
2662 return 0;
2663
2664 inode_lock(dqopt->files[cnt]);
2665
2666 /*
2667 * do_quotactl
2668 * f2fs_quota_sync
2151
2152 f2fs_sync_fs(sbi->sb, 1);
2153}
2154
2155static int f2fs_remount(struct super_block *sb, int *flags, char *data)
2156{
2157 struct f2fs_sb_info *sbi = F2FS_SB(sb);
2158 struct f2fs_mount_info org_mount_opt;

--- 543 unchanged lines hidden (view full) ---

2702 if (!sb_has_quota_active(sb, type))
2703 return 0;
2704
2705 inode_lock(dqopt->files[cnt]);
2706
2707 /*
2708 * do_quotactl
2709 * f2fs_quota_sync
2669 * down_read(quota_sem)
2710 * f2fs_down_read(quota_sem)
2670 * dquot_writeback_dquots()
2671 * f2fs_dquot_commit
2672 * block_operation
2711 * dquot_writeback_dquots()
2712 * f2fs_dquot_commit
2713 * block_operation
2673 * down_read(quota_sem)
2714 * f2fs_down_read(quota_sem)
2674 */
2675 f2fs_lock_op(sbi);
2715 */
2716 f2fs_lock_op(sbi);
2676 down_read(&sbi->quota_sem);
2717 f2fs_down_read(&sbi->quota_sem);
2677
2678 ret = f2fs_quota_sync_file(sbi, cnt);
2679
2718
2719 ret = f2fs_quota_sync_file(sbi, cnt);
2720
2680 up_read(&sbi->quota_sem);
2721 f2fs_up_read(&sbi->quota_sem);
2681 f2fs_unlock_op(sbi);
2682
2683 inode_unlock(dqopt->files[cnt]);
2684
2685 if (ret)
2686 break;
2687 }
2688 return ret;

--- 108 unchanged lines hidden (view full) ---

2797 }
2798}
2799
2800static int f2fs_dquot_commit(struct dquot *dquot)
2801{
2802 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb);
2803 int ret;
2804
2722 f2fs_unlock_op(sbi);
2723
2724 inode_unlock(dqopt->files[cnt]);
2725
2726 if (ret)
2727 break;
2728 }
2729 return ret;

--- 108 unchanged lines hidden (view full) ---

2838 }
2839}
2840
2841static int f2fs_dquot_commit(struct dquot *dquot)
2842{
2843 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb);
2844 int ret;
2845
2805 down_read_nested(&sbi->quota_sem, SINGLE_DEPTH_NESTING);
2846 f2fs_down_read_nested(&sbi->quota_sem, SINGLE_DEPTH_NESTING);
2806 ret = dquot_commit(dquot);
2807 if (ret < 0)
2808 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
2847 ret = dquot_commit(dquot);
2848 if (ret < 0)
2849 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
2809 up_read(&sbi->quota_sem);
2850 f2fs_up_read(&sbi->quota_sem);
2810 return ret;
2811}
2812
2813static int f2fs_dquot_acquire(struct dquot *dquot)
2814{
2815 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb);
2816 int ret;
2817
2851 return ret;
2852}
2853
2854static int f2fs_dquot_acquire(struct dquot *dquot)
2855{
2856 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb);
2857 int ret;
2858
2818 down_read(&sbi->quota_sem);
2859 f2fs_down_read(&sbi->quota_sem);
2819 ret = dquot_acquire(dquot);
2820 if (ret < 0)
2821 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
2860 ret = dquot_acquire(dquot);
2861 if (ret < 0)
2862 set_sbi_flag(sbi, SBI_QUOTA_NEED_REPAIR);
2822 up_read(&sbi->quota_sem);
2863 f2fs_up_read(&sbi->quota_sem);
2823 return ret;
2824}
2825
2826static int f2fs_dquot_release(struct dquot *dquot)
2827{
2828 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb);
2829 int ret = dquot_release(dquot);
2830

--- 704 unchanged lines hidden (view full) ---

3535 sbi->cur_victim_sec = NULL_SECNO;
3536 sbi->next_victim_seg[BG_GC] = NULL_SEGNO;
3537 sbi->next_victim_seg[FG_GC] = NULL_SEGNO;
3538 sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH;
3539 sbi->migration_granularity = sbi->segs_per_sec;
3540 sbi->seq_file_ra_mul = MIN_RA_MUL;
3541 sbi->max_fragment_chunk = DEF_FRAGMENT_SIZE;
3542 sbi->max_fragment_hole = DEF_FRAGMENT_SIZE;
2864 return ret;
2865}
2866
2867static int f2fs_dquot_release(struct dquot *dquot)
2868{
2869 struct f2fs_sb_info *sbi = F2FS_SB(dquot->dq_sb);
2870 int ret = dquot_release(dquot);
2871

--- 704 unchanged lines hidden (view full) ---

3576 sbi->cur_victim_sec = NULL_SECNO;
3577 sbi->next_victim_seg[BG_GC] = NULL_SEGNO;
3578 sbi->next_victim_seg[FG_GC] = NULL_SEGNO;
3579 sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH;
3580 sbi->migration_granularity = sbi->segs_per_sec;
3581 sbi->seq_file_ra_mul = MIN_RA_MUL;
3582 sbi->max_fragment_chunk = DEF_FRAGMENT_SIZE;
3583 sbi->max_fragment_hole = DEF_FRAGMENT_SIZE;
3584 spin_lock_init(&sbi->gc_urgent_high_lock);
3543
3544 sbi->dir_level = DEF_DIR_LEVEL;
3545 sbi->interval_time[CP_TIME] = DEF_CP_INTERVAL;
3546 sbi->interval_time[REQ_TIME] = DEF_IDLE_INTERVAL;
3547 sbi->interval_time[DISCARD_TIME] = DEF_IDLE_INTERVAL;
3548 sbi->interval_time[GC_TIME] = DEF_IDLE_INTERVAL;
3549 sbi->interval_time[DISABLE_TIME] = DEF_DISABLE_INTERVAL;
3550 sbi->interval_time[UMOUNT_DISCARD_TIMEOUT] =
3551 DEF_UMOUNT_DISCARD_TIMEOUT;
3552 clear_sbi_flag(sbi, SBI_NEED_FSCK);
3553
3554 for (i = 0; i < NR_COUNT_TYPE; i++)
3555 atomic_set(&sbi->nr_pages[i], 0);
3556
3557 for (i = 0; i < META; i++)
3558 atomic_set(&sbi->wb_sync_req[i], 0);
3559
3560 INIT_LIST_HEAD(&sbi->s_list);
3561 mutex_init(&sbi->umount_mutex);
3585
3586 sbi->dir_level = DEF_DIR_LEVEL;
3587 sbi->interval_time[CP_TIME] = DEF_CP_INTERVAL;
3588 sbi->interval_time[REQ_TIME] = DEF_IDLE_INTERVAL;
3589 sbi->interval_time[DISCARD_TIME] = DEF_IDLE_INTERVAL;
3590 sbi->interval_time[GC_TIME] = DEF_IDLE_INTERVAL;
3591 sbi->interval_time[DISABLE_TIME] = DEF_DISABLE_INTERVAL;
3592 sbi->interval_time[UMOUNT_DISCARD_TIMEOUT] =
3593 DEF_UMOUNT_DISCARD_TIMEOUT;
3594 clear_sbi_flag(sbi, SBI_NEED_FSCK);
3595
3596 for (i = 0; i < NR_COUNT_TYPE; i++)
3597 atomic_set(&sbi->nr_pages[i], 0);
3598
3599 for (i = 0; i < META; i++)
3600 atomic_set(&sbi->wb_sync_req[i], 0);
3601
3602 INIT_LIST_HEAD(&sbi->s_list);
3603 mutex_init(&sbi->umount_mutex);
3562 init_rwsem(&sbi->io_order_lock);
3604 init_f2fs_rwsem(&sbi->io_order_lock);
3563 spin_lock_init(&sbi->cp_lock);
3564
3565 sbi->dirty_device = 0;
3566 spin_lock_init(&sbi->dev_lock);
3567
3605 spin_lock_init(&sbi->cp_lock);
3606
3607 sbi->dirty_device = 0;
3608 spin_lock_init(&sbi->dev_lock);
3609
3568 init_rwsem(&sbi->sb_lock);
3569 init_rwsem(&sbi->pin_sem);
3610 init_f2fs_rwsem(&sbi->sb_lock);
3611 init_f2fs_rwsem(&sbi->pin_sem);
3570}
3571
3572static int init_percpu_info(struct f2fs_sb_info *sbi)
3573{
3574 int err;
3575
3576 err = percpu_counter_init(&sbi->alloc_valid_block_count, 0, GFP_KERNEL);
3577 if (err)

--- 278 unchanged lines hidden (view full) ---

3856 }
3857 f2fs_info(sbi,
3858 "IO Block Size: %8d KB", F2FS_IO_SIZE_KB(sbi));
3859 return 0;
3860}
3861
3862static int f2fs_setup_casefold(struct f2fs_sb_info *sbi)
3863{
3612}
3613
3614static int init_percpu_info(struct f2fs_sb_info *sbi)
3615{
3616 int err;
3617
3618 err = percpu_counter_init(&sbi->alloc_valid_block_count, 0, GFP_KERNEL);
3619 if (err)

--- 278 unchanged lines hidden (view full) ---

3898 }
3899 f2fs_info(sbi,
3900 "IO Block Size: %8d KB", F2FS_IO_SIZE_KB(sbi));
3901 return 0;
3902}
3903
3904static int f2fs_setup_casefold(struct f2fs_sb_info *sbi)
3905{
3864#if IS_ENABLED(CONFIG_UNICODE)
3906#ifdef CONFIG_UNICODE
3865 if (f2fs_sb_has_casefold(sbi) && !sbi->sb->s_encoding) {
3866 const struct f2fs_sb_encodings *encoding_info;
3867 struct unicode_map *encoding;
3868 __u16 encoding_flags;
3869
3870 encoding_info = f2fs_sb_read_encoding(sbi->raw_super);
3871 if (!encoding_info) {
3872 f2fs_err(sbi,

--- 147 unchanged lines hidden (view full) ---

4020 sb->s_time_gran = 1;
4021 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
4022 (test_opt(sbi, POSIX_ACL) ? SB_POSIXACL : 0);
4023 memcpy(&sb->s_uuid, raw_super->uuid, sizeof(raw_super->uuid));
4024 sb->s_iflags |= SB_I_CGROUPWB;
4025
4026 /* init f2fs-specific super block info */
4027 sbi->valid_super_block = valid_super_block;
3907 if (f2fs_sb_has_casefold(sbi) && !sbi->sb->s_encoding) {
3908 const struct f2fs_sb_encodings *encoding_info;
3909 struct unicode_map *encoding;
3910 __u16 encoding_flags;
3911
3912 encoding_info = f2fs_sb_read_encoding(sbi->raw_super);
3913 if (!encoding_info) {
3914 f2fs_err(sbi,

--- 147 unchanged lines hidden (view full) ---

4062 sb->s_time_gran = 1;
4063 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
4064 (test_opt(sbi, POSIX_ACL) ? SB_POSIXACL : 0);
4065 memcpy(&sb->s_uuid, raw_super->uuid, sizeof(raw_super->uuid));
4066 sb->s_iflags |= SB_I_CGROUPWB;
4067
4068 /* init f2fs-specific super block info */
4069 sbi->valid_super_block = valid_super_block;
4028 init_rwsem(&sbi->gc_lock);
4070 init_f2fs_rwsem(&sbi->gc_lock);
4029 mutex_init(&sbi->writepages);
4071 mutex_init(&sbi->writepages);
4030 init_rwsem(&sbi->cp_global_sem);
4031 init_rwsem(&sbi->node_write);
4032 init_rwsem(&sbi->node_change);
4072 init_f2fs_rwsem(&sbi->cp_global_sem);
4073 init_f2fs_rwsem(&sbi->node_write);
4074 init_f2fs_rwsem(&sbi->node_change);
4033
4034 /* disallow all the data/node/meta page writes */
4035 set_sbi_flag(sbi, SBI_POR_DOING);
4036 spin_lock_init(&sbi->stat_lock);
4037
4038 for (i = 0; i < NR_PAGE_TYPE; i++) {
4039 int n = (i == META) ? 1 : NR_TEMP_TYPE;
4040 int j;

--- 4 unchanged lines hidden (view full) ---

4045 sizeof(struct f2fs_bio_info)),
4046 GFP_KERNEL);
4047 if (!sbi->write_io[i]) {
4048 err = -ENOMEM;
4049 goto free_bio_info;
4050 }
4051
4052 for (j = HOT; j < n; j++) {
4075
4076 /* disallow all the data/node/meta page writes */
4077 set_sbi_flag(sbi, SBI_POR_DOING);
4078 spin_lock_init(&sbi->stat_lock);
4079
4080 for (i = 0; i < NR_PAGE_TYPE; i++) {
4081 int n = (i == META) ? 1 : NR_TEMP_TYPE;
4082 int j;

--- 4 unchanged lines hidden (view full) ---

4087 sizeof(struct f2fs_bio_info)),
4088 GFP_KERNEL);
4089 if (!sbi->write_io[i]) {
4090 err = -ENOMEM;
4091 goto free_bio_info;
4092 }
4093
4094 for (j = HOT; j < n; j++) {
4053 init_rwsem(&sbi->write_io[i][j].io_rwsem);
4095 init_f2fs_rwsem(&sbi->write_io[i][j].io_rwsem);
4054 sbi->write_io[i][j].sbi = sbi;
4055 sbi->write_io[i][j].bio = NULL;
4056 spin_lock_init(&sbi->write_io[i][j].io_lock);
4057 INIT_LIST_HEAD(&sbi->write_io[i][j].io_list);
4058 INIT_LIST_HEAD(&sbi->write_io[i][j].bio_list);
4096 sbi->write_io[i][j].sbi = sbi;
4097 sbi->write_io[i][j].bio = NULL;
4098 spin_lock_init(&sbi->write_io[i][j].io_lock);
4099 INIT_LIST_HEAD(&sbi->write_io[i][j].io_list);
4100 INIT_LIST_HEAD(&sbi->write_io[i][j].bio_list);
4059 init_rwsem(&sbi->write_io[i][j].bio_list_lock);
4101 init_f2fs_rwsem(&sbi->write_io[i][j].bio_list_lock);
4060 }
4061 }
4062
4102 }
4103 }
4104
4063 init_rwsem(&sbi->cp_rwsem);
4064 init_rwsem(&sbi->quota_sem);
4105 init_f2fs_rwsem(&sbi->cp_rwsem);
4106 init_f2fs_rwsem(&sbi->quota_sem);
4065 init_waitqueue_head(&sbi->cp_wait);
4066 init_sb_info(sbi);
4067
4068 err = f2fs_init_iostat(sbi);
4069 if (err)
4070 goto free_bio_info;
4071
4072 err = init_percpu_info(sbi);

--- 101 unchanged lines hidden (view full) ---

4174 }
4175 err = f2fs_build_node_manager(sbi);
4176 if (err) {
4177 f2fs_err(sbi, "Failed to initialize F2FS node manager (%d)",
4178 err);
4179 goto free_nm;
4180 }
4181
4107 init_waitqueue_head(&sbi->cp_wait);
4108 init_sb_info(sbi);
4109
4110 err = f2fs_init_iostat(sbi);
4111 if (err)
4112 goto free_bio_info;
4113
4114 err = init_percpu_info(sbi);

--- 101 unchanged lines hidden (view full) ---

4216 }
4217 err = f2fs_build_node_manager(sbi);
4218 if (err) {
4219 f2fs_err(sbi, "Failed to initialize F2FS node manager (%d)",
4220 err);
4221 goto free_nm;
4222 }
4223
4224 err = adjust_reserved_segment(sbi);
4225 if (err)
4226 goto free_nm;
4227
4182 /* For write statistics */
4183 sbi->sectors_written_start = f2fs_get_sectors_written(sbi);
4184
4185 /* Read accumulated write IO statistics if exists */
4186 seg_i = CURSEG_I(sbi, CURSEG_HOT_NODE);
4187 if (__exist_node_summaries(sbi))
4188 sbi->kbytes_written =
4189 le64_to_cpu(seg_i->journal->info.kbytes_written);

--- 217 unchanged lines hidden (view full) ---

4407free_percpu:
4408 destroy_percpu_info(sbi);
4409free_iostat:
4410 f2fs_destroy_iostat(sbi);
4411free_bio_info:
4412 for (i = 0; i < NR_PAGE_TYPE; i++)
4413 kvfree(sbi->write_io[i]);
4414
4228 /* For write statistics */
4229 sbi->sectors_written_start = f2fs_get_sectors_written(sbi);
4230
4231 /* Read accumulated write IO statistics if exists */
4232 seg_i = CURSEG_I(sbi, CURSEG_HOT_NODE);
4233 if (__exist_node_summaries(sbi))
4234 sbi->kbytes_written =
4235 le64_to_cpu(seg_i->journal->info.kbytes_written);

--- 217 unchanged lines hidden (view full) ---

4453free_percpu:
4454 destroy_percpu_info(sbi);
4455free_iostat:
4456 f2fs_destroy_iostat(sbi);
4457free_bio_info:
4458 for (i = 0; i < NR_PAGE_TYPE; i++)
4459 kvfree(sbi->write_io[i]);
4460
4415#if IS_ENABLED(CONFIG_UNICODE)
4461#ifdef CONFIG_UNICODE
4416 utf8_unload(sb->s_encoding);
4417 sb->s_encoding = NULL;
4418#endif
4419free_options:
4420#ifdef CONFIG_QUOTA
4421 for (i = 0; i < MAXQUOTAS; i++)
4422 kfree(F2FS_OPTION(sbi).s_qf_names[i]);
4423#endif

--- 215 unchanged lines hidden ---
4462 utf8_unload(sb->s_encoding);
4463 sb->s_encoding = NULL;
4464#endif
4465free_options:
4466#ifdef CONFIG_QUOTA
4467 for (i = 0; i < MAXQUOTAS; i++)
4468 kfree(F2FS_OPTION(sbi).s_qf_names[i]);
4469#endif

--- 215 unchanged lines hidden ---