super.c (9a9aecaad92d4fba0e2682ca6897d3a5aeabf123) super.c (4d3aed70902f299ff2ed7048ef44f0d4d573d786)
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>

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

131 Opt_offprjjquota,
132 Opt_jqfmt_vfsold,
133 Opt_jqfmt_vfsv0,
134 Opt_jqfmt_vfsv1,
135 Opt_whint,
136 Opt_alloc,
137 Opt_fsync,
138 Opt_test_dummy_encryption,
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>

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

131 Opt_offprjjquota,
132 Opt_jqfmt_vfsold,
133 Opt_jqfmt_vfsv0,
134 Opt_jqfmt_vfsv1,
135 Opt_whint,
136 Opt_alloc,
137 Opt_fsync,
138 Opt_test_dummy_encryption,
139 Opt_checkpoint,
139 Opt_checkpoint_disable,
140 Opt_checkpoint_disable_cap,
141 Opt_checkpoint_disable_cap_perc,
142 Opt_checkpoint_enable,
140 Opt_err,
141};
142
143static match_table_t f2fs_tokens = {
144 {Opt_gc_background, "background_gc=%s"},
145 {Opt_disable_roll_forward, "disable_roll_forward"},
146 {Opt_norecovery, "norecovery"},
147 {Opt_discard, "discard"},

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

190 {Opt_offprjjquota, "prjjquota="},
191 {Opt_jqfmt_vfsold, "jqfmt=vfsold"},
192 {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
193 {Opt_jqfmt_vfsv1, "jqfmt=vfsv1"},
194 {Opt_whint, "whint_mode=%s"},
195 {Opt_alloc, "alloc_mode=%s"},
196 {Opt_fsync, "fsync_mode=%s"},
197 {Opt_test_dummy_encryption, "test_dummy_encryption"},
143 Opt_err,
144};
145
146static match_table_t f2fs_tokens = {
147 {Opt_gc_background, "background_gc=%s"},
148 {Opt_disable_roll_forward, "disable_roll_forward"},
149 {Opt_norecovery, "norecovery"},
150 {Opt_discard, "discard"},

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

193 {Opt_offprjjquota, "prjjquota="},
194 {Opt_jqfmt_vfsold, "jqfmt=vfsold"},
195 {Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
196 {Opt_jqfmt_vfsv1, "jqfmt=vfsv1"},
197 {Opt_whint, "whint_mode=%s"},
198 {Opt_alloc, "alloc_mode=%s"},
199 {Opt_fsync, "fsync_mode=%s"},
200 {Opt_test_dummy_encryption, "test_dummy_encryption"},
198 {Opt_checkpoint, "checkpoint=%s"},
201 {Opt_checkpoint_disable, "checkpoint=disable"},
202 {Opt_checkpoint_disable_cap, "checkpoint=disable:%u"},
203 {Opt_checkpoint_disable_cap_perc, "checkpoint=disable:%u%%"},
204 {Opt_checkpoint_enable, "checkpoint=enable"},
199 {Opt_err, NULL},
200};
201
202void f2fs_msg(struct super_block *sb, const char *level, const char *fmt, ...)
203{
204 struct va_format vaf;
205 va_list args;
206

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

767 F2FS_OPTION(sbi).test_dummy_encryption = true;
768 f2fs_msg(sb, KERN_INFO,
769 "Test dummy encryption mode enabled");
770#else
771 f2fs_msg(sb, KERN_INFO,
772 "Test dummy encryption mount option ignored");
773#endif
774 break;
205 {Opt_err, NULL},
206};
207
208void f2fs_msg(struct super_block *sb, const char *level, const char *fmt, ...)
209{
210 struct va_format vaf;
211 va_list args;
212

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

773 F2FS_OPTION(sbi).test_dummy_encryption = true;
774 f2fs_msg(sb, KERN_INFO,
775 "Test dummy encryption mode enabled");
776#else
777 f2fs_msg(sb, KERN_INFO,
778 "Test dummy encryption mount option ignored");
779#endif
780 break;
775 case Opt_checkpoint:
776 name = match_strdup(&args[0]);
777 if (!name)
778 return -ENOMEM;
779
780 if (strlen(name) == 6 &&
781 !strncmp(name, "enable", 6)) {
782 clear_opt(sbi, DISABLE_CHECKPOINT);
783 } else if (strlen(name) == 7 &&
784 !strncmp(name, "disable", 7)) {
785 set_opt(sbi, DISABLE_CHECKPOINT);
786 } else {
787 kvfree(name);
781 case Opt_checkpoint_disable_cap_perc:
782 if (args->from && match_int(args, &arg))
788 return -EINVAL;
783 return -EINVAL;
789 }
790 kvfree(name);
784 if (arg < 0 || arg > 100)
785 return -EINVAL;
786 if (arg == 100)
787 F2FS_OPTION(sbi).unusable_cap =
788 sbi->user_block_count;
789 else
790 F2FS_OPTION(sbi).unusable_cap =
791 (sbi->user_block_count / 100) * arg;
792 set_opt(sbi, DISABLE_CHECKPOINT);
791 break;
793 break;
794 case Opt_checkpoint_disable_cap:
795 if (args->from && match_int(args, &arg))
796 return -EINVAL;
797 F2FS_OPTION(sbi).unusable_cap = arg;
798 set_opt(sbi, DISABLE_CHECKPOINT);
799 break;
800 case Opt_checkpoint_disable:
801 set_opt(sbi, DISABLE_CHECKPOINT);
802 break;
803 case Opt_checkpoint_enable:
804 clear_opt(sbi, DISABLE_CHECKPOINT);
805 break;
792 default:
793 f2fs_msg(sb, KERN_ERR,
794 "Unrecognized mount option \"%s\" or missing value",
795 p);
796 return -EINVAL;
797 }
798 }
799#ifdef CONFIG_QUOTA

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

1407#endif
1408
1409 if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_DEFAULT)
1410 seq_printf(seq, ",alloc_mode=%s", "default");
1411 else if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_REUSE)
1412 seq_printf(seq, ",alloc_mode=%s", "reuse");
1413
1414 if (test_opt(sbi, DISABLE_CHECKPOINT))
806 default:
807 f2fs_msg(sb, KERN_ERR,
808 "Unrecognized mount option \"%s\" or missing value",
809 p);
810 return -EINVAL;
811 }
812 }
813#ifdef CONFIG_QUOTA

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

1421#endif
1422
1423 if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_DEFAULT)
1424 seq_printf(seq, ",alloc_mode=%s", "default");
1425 else if (F2FS_OPTION(sbi).alloc_mode == ALLOC_MODE_REUSE)
1426 seq_printf(seq, ",alloc_mode=%s", "reuse");
1427
1428 if (test_opt(sbi, DISABLE_CHECKPOINT))
1415 seq_puts(seq, ",checkpoint=disable");
1416
1429 seq_printf(seq, ",checkpoint=disable:%u",
1430 F2FS_OPTION(sbi).unusable_cap);
1417 if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_POSIX)
1418 seq_printf(seq, ",fsync_mode=%s", "posix");
1419 else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT)
1420 seq_printf(seq, ",fsync_mode=%s", "strict");
1421 else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_NOBARRIER)
1422 seq_printf(seq, ",fsync_mode=%s", "nobarrier");
1423 return 0;
1424}

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

1437
1438 set_opt(sbi, BG_GC);
1439 set_opt(sbi, INLINE_XATTR);
1440 set_opt(sbi, INLINE_DATA);
1441 set_opt(sbi, INLINE_DENTRY);
1442 set_opt(sbi, EXTENT_CACHE);
1443 set_opt(sbi, NOHEAP);
1444 clear_opt(sbi, DISABLE_CHECKPOINT);
1431 if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_POSIX)
1432 seq_printf(seq, ",fsync_mode=%s", "posix");
1433 else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT)
1434 seq_printf(seq, ",fsync_mode=%s", "strict");
1435 else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_NOBARRIER)
1436 seq_printf(seq, ",fsync_mode=%s", "nobarrier");
1437 return 0;
1438}

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

1451
1452 set_opt(sbi, BG_GC);
1453 set_opt(sbi, INLINE_XATTR);
1454 set_opt(sbi, INLINE_DATA);
1455 set_opt(sbi, INLINE_DENTRY);
1456 set_opt(sbi, EXTENT_CACHE);
1457 set_opt(sbi, NOHEAP);
1458 clear_opt(sbi, DISABLE_CHECKPOINT);
1459 F2FS_OPTION(sbi).unusable_cap = 0;
1445 sbi->sb->s_flags |= SB_LAZYTIME;
1446 set_opt(sbi, FLUSH_MERGE);
1447 set_opt(sbi, DISCARD);
1448 if (f2fs_sb_has_blkzoned(sbi))
1449 set_opt_mode(sbi, F2FS_MOUNT_LFS);
1450 else
1451 set_opt_mode(sbi, F2FS_MOUNT_ADAPTIVE);
1452

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

1465#endif
1466
1467static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
1468{
1469 unsigned int s_flags = sbi->sb->s_flags;
1470 struct cp_control cpc;
1471 int err = 0;
1472 int ret;
1460 sbi->sb->s_flags |= SB_LAZYTIME;
1461 set_opt(sbi, FLUSH_MERGE);
1462 set_opt(sbi, DISCARD);
1463 if (f2fs_sb_has_blkzoned(sbi))
1464 set_opt_mode(sbi, F2FS_MOUNT_LFS);
1465 else
1466 set_opt_mode(sbi, F2FS_MOUNT_ADAPTIVE);
1467

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

1480#endif
1481
1482static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi)
1483{
1484 unsigned int s_flags = sbi->sb->s_flags;
1485 struct cp_control cpc;
1486 int err = 0;
1487 int ret;
1488 block_t unusable;
1473
1474 if (s_flags & SB_RDONLY) {
1475 f2fs_msg(sbi->sb, KERN_ERR,
1476 "checkpoint=disable on readonly fs");
1477 return -EINVAL;
1478 }
1479 sbi->sb->s_flags |= SB_ACTIVE;
1480

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

1492 }
1493
1494 ret = sync_filesystem(sbi->sb);
1495 if (ret || err) {
1496 err = ret ? ret: err;
1497 goto restore_flag;
1498 }
1499
1489
1490 if (s_flags & SB_RDONLY) {
1491 f2fs_msg(sbi->sb, KERN_ERR,
1492 "checkpoint=disable on readonly fs");
1493 return -EINVAL;
1494 }
1495 sbi->sb->s_flags |= SB_ACTIVE;
1496

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

1508 }
1509
1510 ret = sync_filesystem(sbi->sb);
1511 if (ret || err) {
1512 err = ret ? ret: err;
1513 goto restore_flag;
1514 }
1515
1500 if (f2fs_disable_cp_again(sbi)) {
1516 unusable = f2fs_get_unusable_blocks(sbi);
1517 if (f2fs_disable_cp_again(sbi, unusable)) {
1501 err = -EAGAIN;
1502 goto restore_flag;
1503 }
1504
1505 mutex_lock(&sbi->gc_mutex);
1506 cpc.reason = CP_PAUSE;
1507 set_sbi_flag(sbi, SBI_CP_DISABLED);
1508 err = f2fs_write_checkpoint(sbi, &cpc);
1509 if (err)
1510 goto out_unlock;
1511
1512 spin_lock(&sbi->stat_lock);
1518 err = -EAGAIN;
1519 goto restore_flag;
1520 }
1521
1522 mutex_lock(&sbi->gc_mutex);
1523 cpc.reason = CP_PAUSE;
1524 set_sbi_flag(sbi, SBI_CP_DISABLED);
1525 err = f2fs_write_checkpoint(sbi, &cpc);
1526 if (err)
1527 goto out_unlock;
1528
1529 spin_lock(&sbi->stat_lock);
1513 sbi->unusable_block_count = 0;
1530 sbi->unusable_block_count = unusable;
1514 spin_unlock(&sbi->stat_lock);
1515
1516out_unlock:
1517 mutex_unlock(&sbi->gc_mutex);
1518restore_flag:
1519 sbi->sb->s_flags = s_flags; /* Restore MS_RDONLY status */
1520 return err;
1521}

--- 2167 unchanged lines hidden ---
1531 spin_unlock(&sbi->stat_lock);
1532
1533out_unlock:
1534 mutex_unlock(&sbi->gc_mutex);
1535restore_flag:
1536 sbi->sb->s_flags = s_flags; /* Restore MS_RDONLY status */
1537 return err;
1538}

--- 2167 unchanged lines hidden ---