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

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

1298}
1299
1300static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)
1301{
1302 unsigned long orphan_num = sbi->im[ORPHAN_INO].ino_num;
1303 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
1304 unsigned long flags;
1305
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * fs/f2fs/checkpoint.c
4 *
5 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
6 * http://www.samsung.com/
7 */
8#include <linux/fs.h>

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

1298}
1299
1300static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)
1301{
1302 unsigned long orphan_num = sbi->im[ORPHAN_INO].ino_num;
1303 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
1304 unsigned long flags;
1305
1306 if (cpc->reason & CP_UMOUNT) {
1307 if (le32_to_cpu(ckpt->cp_pack_total_block_count) >
1308 sbi->blocks_per_seg - NM_I(sbi)->nat_bits_blocks) {
1309 clear_ckpt_flags(sbi, CP_NAT_BITS_FLAG);
1310 f2fs_notice(sbi, "Disable nat_bits due to no space");
1311 } else if (!is_set_ckpt_flags(sbi, CP_NAT_BITS_FLAG) &&
1312 f2fs_nat_bitmap_enabled(sbi)) {
1313 f2fs_enable_nat_bits(sbi);
1314 set_ckpt_flags(sbi, CP_NAT_BITS_FLAG);
1315 f2fs_notice(sbi, "Rebuild and enable nat_bits");
1316 }
1317 }
1318
1306 spin_lock_irqsave(&sbi->cp_lock, flags);
1307
1319 spin_lock_irqsave(&sbi->cp_lock, flags);
1320
1308 if ((cpc->reason & CP_UMOUNT) &&
1309 le32_to_cpu(ckpt->cp_pack_total_block_count) >
1310 sbi->blocks_per_seg - NM_I(sbi)->nat_bits_blocks)
1311 disable_nat_bits(sbi, false);
1312
1313 if (cpc->reason & CP_TRIMMED)
1314 __set_ckpt_flags(ckpt, CP_TRIMMED_FLAG);
1315 else
1316 __clear_ckpt_flags(ckpt, CP_TRIMMED_FLAG);
1317
1318 if (cpc->reason & CP_UMOUNT)
1319 __set_ckpt_flags(ckpt, CP_UMOUNT_FLAG);
1320 else

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

1489 crc32 = f2fs_checkpoint_chksum(sbi, ckpt);
1490 *((__le32 *)((unsigned char *)ckpt +
1491 le32_to_cpu(ckpt->checksum_offset)))
1492 = cpu_to_le32(crc32);
1493
1494 start_blk = __start_cp_next_addr(sbi);
1495
1496 /* write nat bits */
1321 if (cpc->reason & CP_TRIMMED)
1322 __set_ckpt_flags(ckpt, CP_TRIMMED_FLAG);
1323 else
1324 __clear_ckpt_flags(ckpt, CP_TRIMMED_FLAG);
1325
1326 if (cpc->reason & CP_UMOUNT)
1327 __set_ckpt_flags(ckpt, CP_UMOUNT_FLAG);
1328 else

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

1497 crc32 = f2fs_checkpoint_chksum(sbi, ckpt);
1498 *((__le32 *)((unsigned char *)ckpt +
1499 le32_to_cpu(ckpt->checksum_offset)))
1500 = cpu_to_le32(crc32);
1501
1502 start_blk = __start_cp_next_addr(sbi);
1503
1504 /* write nat bits */
1497 if (enabled_nat_bits(sbi, cpc)) {
1505 if ((cpc->reason & CP_UMOUNT) &&
1506 is_set_ckpt_flags(sbi, CP_NAT_BITS_FLAG)) {
1498 __u64 cp_ver = cur_cp_version(ckpt);
1499 block_t blk;
1500
1501 cp_ver |= ((__u64)crc32 << 32);
1502 *(__le64 *)nm_i->nat_bits = cpu_to_le64(cp_ver);
1503
1504 blk = start_blk + sbi->blocks_per_seg - nm_i->nat_bits_blocks;
1505 for (i = 0; i < nm_i->nat_bits_blocks; i++)

--- 400 unchanged lines hidden ---
1507 __u64 cp_ver = cur_cp_version(ckpt);
1508 block_t blk;
1509
1510 cp_ver |= ((__u64)crc32 << 32);
1511 *(__le64 *)nm_i->nat_bits = cpu_to_le64(cp_ver);
1512
1513 blk = start_blk + sbi->blocks_per_seg - nm_i->nat_bits_blocks;
1514 for (i = 0; i < nm_i->nat_bits_blocks; i++)

--- 400 unchanged lines hidden ---