Commit Graph

419 Commits

Author SHA1 Message Date
Hyojun Kim
5b2dc59ece sload.f2fs: fix bugs in f2fs_write_block()
Found and fixed following three bugs in f2fs_write_block() function.
 - Write (4096 - offset) bytes for the first block even for small count.
 - For overwriting, found blkaddr is not used for writing.
 - dn.idirty status can be lost by set_new_dnode().
 - missing inode_checksum

Signed-off-by: Hyojun Kim <hyojun@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-10-30 20:41:49 -07:00
Chao Yu
8d46072f07 f2fs-tools: support flexible inline xattr size
This patch makes mkfs to support flexible inline xattr feature, also
this enables fsck to recognize new disk-layout of inode which be of
flexible inline xattr size.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-10-30 02:16:35 -07:00
Yunlei He
1797a5f092 fsck: introduce generic function f2fs_fsync_device
We use f2fs_finalize_device to fsync previous data in
checkpoint area before write last CP pack, in order to avoid
cp corruption in sudden-power-off case. But this function will
close the device, so this patch introduce a function to call
fsync() only.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-10-26 12:25:27 +02:00
Liu Xue
b449febe90 mkfs.f2fs: fix wrong end blkaddr
The end blkaddr should use main blkaddr and add main area segments.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-10-26 12:25:27 +02:00
Jaegeuk Kim
c6d5ec2faa f2fs-tools: release 1.9.0
This release includes:
 - sparse support
 - inode checksum support
 - nat_bits option
 - encryption management
 - noheap allocation by default
 - add CP_TRIMMED_FLAG

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-09-21 16:15:40 -07:00
Yunlong Song
d879e7ebde f2fs-tools: move_curseg_info only if check_curseg_offset fails
Current design will lose recovery process when check_curseg_offset is OK.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-09-11 18:22:48 -07:00
Yunlong Song
f4078d7e5b f2fs-tools: fix is_set_ckpt_flags for correct bool value
If flag bit to check is in 0xFFFFFF00, then the return value will be false,
this is not correct, so fix it.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-09-11 18:22:32 -07:00
Yunlong Song
0e18bc4d15 f2fs-tools: add cscope files to .gitignore
Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-09-11 17:22:50 -07:00
Jaegeuk Kim
9448c14055 mkfs.f2fs: fix wrong curseg check
We should avoid i==j, otherwise we always assign 0~5 segments.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-09-05 10:56:40 -07:00
Yunlei He
8d9885de45 fsck.f2fs: write back last cp block in the end
Write back last cp block in the end in case of sudden power off
during fsck process

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-08-29 10:04:00 -07:00
Jaegeuk Kim
410ee3b2ea mkfs.f2fs: fix missing cpu_to_le64 for checkpoint version
The error on mips was reported by Stijn as follow.

Commit 8399a29df9 in f2fs-tools
("mkfs.f2fs: give random checkpoint version") causes a bug when mounting
a filesystem created with it on a MIPS64 device running a 4.4(.83)
kernel. The following kernel warning appears several times per second,
for 30 seconds:

[   23.837262] ------------[ cut here ]------------
[   23.842039] WARNING: CPU: 0 PID: 935 at fs/f2fs/segment.c:718
update_sit_entry+0x1c0/0x2b0()
[   23.850507] Modules linked in: pppoe ppp_async l2tp_ppp iptable_nat
[   24.174064] Call Trace:
[   24.176527] [<ffffffff81126e14>] show_stack+0x68/0xb4
[   24.181595] [<ffffffff81321fc4>] dump_stack+0x8c/0xc4
[   24.186660] [<ffffffff8113d004>] warn_slowpath_common+0xa0/0xd0
[   24.192597] [<ffffffff812e0148>] update_sit_entry+0x1c0/0x2b0
[   24.198353] [<ffffffff812e0a70>] refresh_sit_entry+0x70/0xf8
[   24.204022] [<ffffffff812e251c>] allocate_data_block+0x1f0/0x310
[   24.210038] [<ffffffff812e28d8>] do_write_page+0x29c/0x2bc
[   24.215532] [<ffffffff812e2a88>] write_data_page+0xa0/0xd8
[   24.221028] [<ffffffff812d844c>] do_write_data_page+0xe4/0x384
[   24.226870] [<ffffffff812d88f4>] f2fs_write_data_page+0x208/0x464
[   24.232972] [<ffffffff812d5184>] __f2fs_writepage+0x1c/0x74
[   24.238553] [<ffffffff812d54dc>]
f2fs_write_cache_pages.constprop.7+0x250/0x394
[   24.245869] [<ffffffff812d57f4>] f2fs_write_data_pages+0x130/0x1b0
[   24.252066] [<ffffffff811a9f80>] __filemap_fdatawrite_range+0xa0/0xd4
[   24.258515] [<ffffffff812d2338>] sync_dirty_dir_inodes+0x94/0xd8
[   24.264530] [<ffffffff812d2484>] write_checkpoint+0x108/0xb9c
[   24.270283] [<ffffffff812cc398>] f2fs_sync_fs+0x68/0xb0
[   24.275526] [<ffffffff812c641c>] f2fs_sync_file+0x2e8/0x518
[   24.281107] [<ffffffff81213ff4>] do_fsync+0x38/0x70
[   24.285992] [<ffffffff812142e8>] SyS_fsync+0x14/0x20
[   24.290972] [<ffffffff81103950>] syscall_common+0x34/0x58
[   24.296372]
[   24.298096] ---[ end trace fd3ac44449b218ab ]---

Fix: 8399a29df9 ("mkfs.f2fs: give random checkpoint version")
Reported-And-Tested-by: Stijn Tintel <stijn@linux-ipv6.be>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-08-29 10:03:48 -07:00
Chao Yu
7457726261 f2fs-tools: support inode checksum
This patch introduce a new option 'inode_checksum' for enabling inode
checksum functionality in mkfs/fsck/sload.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-07-26 14:38:43 -07:00
Piotr Sokołowski
38c7581ee3 f2fs-tools: fix printing block adresses
This patch allows properly printing all addresses in an inode.
It is useful in commands like dump.f2fs.

Signed-off-by: Piotr Sokołowski <piosoko1@student.pg.edu.pl>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-07-26 14:28:24 -07:00
Chao Yu
a3d9db1f88 f2fs-tools: support project quota
This patch introduce a new option 'project_quota' for enabling project
quota functionality during mkfs.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-07-26 11:42:56 -07:00
Chao Yu
dad33a1ee7 f2fs-tools: enhance on-disk inode structure scalability
This patch adds an option 'extra_attr' in mkfs for enabling v2 f2fs
inode format in kernel codes.

Also this patch makes fsck to support recognize v2 inode format,
below is v2 format description:

Original one:

struct f2fs_inode {
	...
	struct f2fs_extent i_ext;
	__le32 i_addr[DEF_ADDRS_PER_INODE];
	__le32 i_nid[DEF_NIDS_PER_INODE];
}

Extended one:

struct f2fs_inode {
        ...
        struct f2fs_extent i_ext;
	union {
		struct {
			__le16 i_extra_isize;
			__le16 i_padding;
			__le32 i_extra_end[0];
		};
		__le32 i_addr[DEF_ADDRS_PER_INODE];
	};
        __le32 i_nid[DEF_NIDS_PER_INODE];
}

Once F2FS_EXTRA_ATTR is set, we will steal four bytes in the head of
i_addr field for storing i_extra_isize and i_padding. with i_extra_isize,
we can calculate actual size of reserved space in i_addr, available
attribute fields included in total extra attribute fields for current
inode can be described as below:

  +--------------------+
  | .i_mode            |
  | ...                |
  | .i_ext             |
  +--------------------+
  | .i_extra_isize     |-----+
  | .i_padding         |     |
  | .i_prjid           |     |
  | .i_atime_extra     |     |
  | .i_ctime_extra     |     |
  | .i_mtime_extra     |<----+
  | .i_inode_cs        |<----- store blkaddr/inline from here
  | .i_xattr_cs        |
  | ...                |
  +--------------------+
  |                    |
  |    block address   |
  |                    |
  +--------------------+
  | .i_nid             |
  +--------------------+
  |   node_footer      |
  | (nid, ino, offset) |
  +--------------------+

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-07-26 11:42:49 -07:00
Jaegeuk Kim
8721519c8d f2fs-tools: add atomic_write feature flag
This patch adds atomic_write feature flag.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-07-21 13:49:28 -07:00
Chao Yu
8b4406a5bd f2fs-tools: spread struct f2fs_dentry_ptr for inline path
Use f2fs_dentry_ptr structure to indicate inline dentry structure as
much as possible, so we can wrap inline dentry with size-fixed fields
to the one with size-changeable fields. With this change, we can
handle size-changeable inline dentry more easily.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-07-17 14:35:33 -07:00
Yang Jin
4abc53c38f add sparse support for f2fs
Description:
modify I/O operations to support writing in sparse format
build host executable for making sparse image

Signed-off-by: Yang Jin <yajin@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-06-16 14:06:21 -07:00
Jaegeuk Kim
ea008a24f7 mkfs.f2fs: drop initial spaces for feature string
This patch removes initial spaces to detect correct feature string.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-06-05 18:12:55 -07:00
Jaegeuk Kim
8e29c2be47 f2fs-tools: avoid build warnings
This patch resolves warnings while building it in android.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-06-05 13:58:50 -07:00
Jaegeuk Kim
5c99767625 mkfs.f2fs: avoid wrong discard of dnode
This can drop root inode, which can be caused by previous stale data.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-05-25 19:17:44 -07:00
Tiezhu Yang
d9180db7d4 f2fs-tools: fix the wrong message when errno is EBUSY
If f2fs is unmounted with the -l option, the process can still use the
file system. In this case, the command mkfs.f2fs, fsck.f2fs, dump.f2fs,
defrag.f2fs, resize.f2fs and sload.f2fs failed due to the device is in
use by the system. At the moment f2fs is already not mounted, so it is
wrong to print error message "Error: Not available on mounted device!",
this patch fixes it.

[root@localhost home]# mkfs.f2fs -f /dev/sdb1
[root@localhost home]# mkdir -p /mnt/f2fs_mnt_point
[root@localhost home]# mount -t f2fs /dev/sdb1 /mnt/f2fs_mnt_point/
[root@localhost home]# cd /mnt/f2fs_mnt_point/
[root@localhost f2fs_mnt_point]# umount /dev/sdb1
umount: /mnt/f2fs_mnt_point: target is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@localhost f2fs_mnt_point]# umount -l /dev/sdb1
[root@localhost f2fs_mnt_point]# umount /dev/sdb1
umount: /dev/sdb1: not mounted
[root@localhost f2fs_mnt_point]# mkfs.f2fs -f /dev/sdb1

	F2FS-tools: mkfs.f2fs Ver: 1.8.0 (2017-04-28)

Info: Disable heap-based policy
Info: Debug level = 0
Info: Label =
Info: Trim is enabled
	Error: In use by the system!
	Error: Not available on mounted device!
[root@localhost f2fs_mnt_point]# fsck.f2fs /dev/sdb1
	Error: In use by the system!
	Error: Not available on mounted device!
[root@localhost f2fs_mnt_point]# dump.f2fs /dev/sdb1
	Error: In use by the system!
	Error: Not available on mounted device!
[root@localhost f2fs_mnt_point]# defrag.f2fs /dev/sdb1
	Error: In use by the system!
	Error: Not available on mounted device!
[root@localhost f2fs_mnt_point]# resize.f2fs /dev/sdb1
	Error: In use by the system!
	Error: Not available on mounted device!
[root@localhost f2fs_mnt_point]# sload.f2fs /dev/sdb1
	Error: In use by the system!
	Error: Not available on mounted device!

Signed-off-by: Tiezhu Yang <kernelpatch@126.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-05-10 10:22:51 -07:00
Chao Yu
f642b24822 f2fs-tools: support to set and recognize CP_TRIMMED_FLAG
During mkfs, once we have issued discard for all device, we can set
CP_TRIMMED_FLAG in cp pack, this can make kernel module to record
undiscard blocks correctly, it will help to avoid unneeded discard.

Also this patch makes f2fs-tools be with the ability of recognizing
that new flag.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-28 12:04:21 -07:00
Jin Qian
892e1542e7 fsck.f2fs: sanity check segno and blk_off when building curseg array
segno and blk_off were read from input image without sanity check. This
could lead to buffer overflow when accessing internal arrays like SIT
sentries and seg_entry cur_valid_map.

Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-27 15:49:54 -07:00
Jin Qian
b79c3ba4ea fsck.f2fs: sanity check cp_payload before reading checkpoint
cp_payload is not sanity checked from input image. A invalid size
can cause buffer overflow when reading checkpoint blks into memory.

Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-27 12:51:09 -07:00
Jin Qian
d87fc37b02 fsck.f2fs: sanity check blk_off for summary block entries
crafted malicious f2fs partition can fill an out of bound blk_off,
which cause overflow when accessing summary block entries.

Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-27 12:42:58 -07:00
Jaegeuk Kim
33ddf01c79 mkfs.f2fs: fix wrong segment assignment
We must guarantee that current segments should be different between different
logs.
This should resolve xfstests/generic/015 panic.

Fixes: 8f9327c0c0 ("mkfs.f2fs: use noheap by default")
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-25 17:53:21 -07:00
Jin Qian
6ab50775fa f2fs-tools: sanity check segment count
make sure segment count in super block doesn't exceed F2FS_MAX_SEGMENT.

Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-25 16:37:37 -07:00
Jin Qian
8a51985120 fsck.f2fs: fix cur_valid_map buffer overflow
blk_off is read from image. Attacker can construct an image with big
blk_off that trigger overflow on se->cur_valid_map.

Signed-off-by: Jin Qian <jinqian@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-21 11:42:59 -07:00
Yong, Jonathan
0f9e1e23da Fix mkfs out of tree builds
Libraries are built in builddir, not srcdir, fix Makefile.am
accordingly.

Signed-off-by: Yong, Jonathan <jonathan.yong@intel.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-21 11:42:59 -07:00
Jaegeuk Kim
8f9327c0c0 mkfs.f2fs: use noheap by default
Let's set noheap by default.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-04-21 11:42:56 -07:00
Kinglong Mee
f57dee09fb libf2fs: avoid overwrite the c.start_sector by non-root device
For multiple devices, the c.start_sector will be overwrite by the non-root devices.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-19 23:14:23 -04:00
Kinglong Mee
0f3045d3e8 sload.f2fs: support sload files into directory includes inline dentry
It seems the new created directory always includes inline dentries,
let sload.f2fs supporting it.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-19 18:46:10 -04:00
Kinglong Mee
9a4df3c466 sload.f2fs: let dir_buckets/dir_block_index supports dir_level
The dir_level in the filesystem maybe larger than zero,
supports it.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-19 18:45:47 -04:00
Kinglong Mee
7b03ccbb9b fsck.f2fs: check encrypted filename depends FADVISE_ENC_NAME_BIT
An encrypted directory under an unencrypted directory, the filename isn't encrypted.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-19 18:45:37 -04:00
Kinglong Mee
5e6526940e fsck.f2fs: fix bad notice of missing device
The following messages is better than before.

Before,
# fsck.f2fs -d 1
    Error: Need argument for -d

Now,
# fsck.f2fs -d 1
Info: Debug level = 1
        Error: Device not specified

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-19 18:45:21 -04:00
Kinglong Mee
8e710d1d71 sload.f2fs: fix missing SSA updates
If sload many larger files to disk, the SSA that doesn't cached will be missed.

Mar 17 12:04:39 localhost kernel: ------------[ cut here ]------------
Mar 17 12:04:39 localhost kernel: kernel BUG at fs/f2fs/gc.c:899!
Mar 17 12:04:39 localhost kernel: invalid opcode: 0000 [#1] SMP
Mar 17 12:04:39 localhost kernel: Modules linked in: f2fs tun bridge stp llc fuse ip_set nfnetlink vmw_vsock_vmci_transport vsock snd_seq_midi snd_seq_midi_event snd_ens1371 gameport snd_ac97_codec coretemp ac97_bus crct10dif_pclmul crc32_pclmul ppdev snd_seq snd_pcm ghash_clmulni_intel intel_rapl_perf vmw_balloon snd_rawmidi joydev snd_timer snd_seq_device snd soundcore parport_pc parport nfit acpi_cpufreq tpm_tis tpm_tis_core shpchp vmw_vmci tpm i2c_piix4 nfsd auth_rpcgss nfs_acl lockd grace sunrpc xfs libcrc32c vmwgfx drm_kms_helper ttm drm e1000 crc32c_intel mptspi scsi_transport_spi serio_raw mptscsih mptbase ata_generic pata_acpi fjes
Mar 17 12:04:39 localhost kernel: CPU: 0 PID: 6427 Comm: f2fs_gc-8:33 Tainted: G        W       4.10.0-f2fs+ #25
Mar 17 12:04:39 localhost kernel: Hardware name: VMware, Inc. VMware Virtual Platform/440BX Desktop Reference Platform, BIOS 6.00 07/02/2015
Mar 17 12:04:39 localhost kernel: task: ffff94ba7d998000 task.stack: ffffb6e4c2e50000
Mar 17 12:04:39 localhost kernel: RIP: 0010:do_garbage_collect+0xa39/0xb60 [f2fs]
Mar 17 12:04:39 localhost kernel: RSP: 0018:ffffb6e4c2e53cc0 EFLAGS: 00010213
Mar 17 12:04:39 localhost kernel: RAX: ffff94baa0427000 RBX: 0000000000000001 RCX: 0000000000000002
Mar 17 12:04:39 localhost kernel: RDX: 0000000000000000 RSI: fffff5e2c28109c0 RDI: fffff5e2c28109c0
Mar 17 12:04:39 localhost kernel: RBP: ffffb6e4c2e53dc0 R08: ffff94ba7dfc72f0 R09: fffff5e2c28109dc
Mar 17 12:04:39 localhost kernel: R10: 0000000000000040 R11: ffff94ba7dfc7238 R12: 0000000000000418
Mar 17 12:04:39 localhost kernel: R13: fffff5e2c28109c0 R14: 0000000000000417 R15: ffff94ba3c021000
Mar 17 12:04:39 localhost kernel: FS:  0000000000000000(0000) GS:ffff94babb600000(0000) knlGS:0000000000000000
Mar 17 12:04:39 localhost kernel: CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
Mar 17 12:04:39 localhost kernel: CR2: 00007fc42a0d7000 CR3: 00000000a7e94000 CR4: 00000000001406f0
Mar 17 12:04:39 localhost kernel: Call Trace:
Mar 17 12:04:39 localhost kernel: ? find_next_bit+0xb/0x10
Mar 17 12:04:39 localhost kernel: f2fs_gc+0x111/0x480 [f2fs]
Mar 17 12:04:39 localhost kernel: ? prepare_to_wait_event+0x79/0x160
Mar 17 12:04:39 localhost kernel: gc_thread_func+0x2d0/0x3f0 [f2fs]
Mar 17 12:04:39 localhost kernel: ? __schedule+0x273/0x860
Mar 17 12:04:39 localhost kernel: ? remove_wait_queue+0x70/0x70
Mar 17 12:04:39 localhost kernel: kthread+0x101/0x140
Mar 17 12:04:39 localhost kernel: ? f2fs_gc+0x480/0x480 [f2fs]
Mar 17 12:04:39 localhost kernel: ? kthread_park+0x90/0x90
Mar 17 12:04:39 localhost kernel: ret_from_fork+0x2c/0x40
Mar 17 12:04:39 localhost kernel: Code: 48 8d 84 24 90 00 00 00 48 89 c7 48 89 44 24 28 e8 7d cc ba e6 e9 17 fa ff ff 48 c7 c6 48 3f 84 c0 48 89 c7 e8 59 8d 9d e6 0f 0b <0f> 0b 48 c7 c6 48 3f 84 c0 4c 89 ff e8 46 8d 9d e6 0f 0b 8b b4
Mar 17 12:04:39 localhost kernel: RIP: do_garbage_collect+0xa39/0xb60 [f2fs] RSP: ffffb6e4c2e53cc0
Mar 17 12:04:39 localhost kernel: ---[ end trace 926d61b064ed1f2d ]---

Fixes: 767a93ea8b ("defrag.f2fs: fix missing SSA updates")
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-17 20:47:08 +08:00
Kinglong Mee
6fb673abc0 fsck.f2fs: a separate option for showing directory tree
Showing directory tree reuses dbg_lv that if setting "-t",
fsck.f2fs does not show any others.
Users may want much information include the debug info and directory tree.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-16 08:16:39 +08:00
Kinglong Mee
7f00dd441c f2fscrypt: add a tool for encryption management in the f2fs filesystem
It's migrated from e4crypt.
Adds an example to the f2fscrypt manpages.

v3, add /tools/f2fscrypt to .gitignore
v2, migrate those micro defines for encrypt to f2fs internal,
    drop unless of libsha etc.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-16 08:15:37 +08:00
Kinglong Mee
802b6499bd fsck.f2fs: sanity check of crc_offset from raw checkpoint
The crc_offset towards or beyond the end of block is wrong,
sanity check it.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-16 08:15:12 +08:00
Yunlei He
78ad88d1d2 resize.f2fs: fix a resize fail for sector size mismatch
This patch fix a resize faill for sector size mismatch.
The initial fs comes from an image file, with sector size
512KB, and the block device sector size is equal to block
size.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-16 08:13:58 +08:00
Kinglong Mee
52a3a273d1 mkfs.f2fs: check overwrite before make filesystem
Mkfs.f2fs doesn't check the overwrite of exist filesystem.
Avoid formatting an exist filesystem by mistake, a notice is important.
The code is modified from xfsprogs.

v3, add the missing update of SYNOPSIS
v2, add the manpages description of -f.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-06 17:15:26 -08:00
Kinglong Mee
2f52fcf698 mkfs.f2fs: clearfiy the help message and manpages
Add some missing options in manpages, also order those options.

v3, add the missing update of SYNOPSIS

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-03-06 17:14:42 -08:00
Jaegeuk Kim
191573e71b mkfs.f2fs: support nat_bits feature
This patch adds nat_bits in the last one ore two 4KB-sized blocks of first
checkpoint segment. So, now a set of checkpoint *segment* consists of:

< checkpoint segment >
----------------------
| cp page #1         | 4KB
----------------------
| compacted data sum | 4KB
----------------------
| node sum  #1       | 4KB
----------------------
| node sum  #2       | 4KB
----------------------
| node sum  #3       | 4KB
----------------------
| cp page #2         | 4KB
----------------------
...
----------------------
| crc|cpver          | 8 bytes
----------------------
| full NAT bits      | # of NAT segments / 2 * 512 / 8 bytes
----------------------
| empty NAT bits     | # of NAT segments / 2 * 512 / 8 bytes
----------------------

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-23 10:11:41 -08:00
Jaegeuk Kim
f081d54ba8 fsck.f2fs: fix wrong usage out
This fixes wrong messages for error out.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-23 10:11:41 -08:00
Jaegeuk Kim
a0bd5b9822 f2fs-tools: catch up up-to-date checkpoint flag
It needs to use up-to-date ckpt flag.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-23 10:11:41 -08:00
Kinglong Mee
9edcda5ec7 mkfs.f2fs: make sure clean all reset dnodes
memset(raw_node, 0, F2FS_BLKSIZE) sets the next_blkaddr to zero,
so that, only one reset dnode is cleaned always.

Fixes: ad042d9194 "mkfs.f2fs: reset dnode with zeros",
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-23 10:11:35 -08:00
Kinglong Mee
a2b7afa16d mkfs.f2fs: check the c.overprovision with zero before using it
The using of c.overprovision when it equal zero as,

        c.reserved_segments =
                        (2 * (100 / c.overprovision + 1) + 6)
                        * c.segs_per_sec;

may cause problem, although it doesn't happen.

Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-06 14:49:50 -08:00
Sheng Yong
2b4b86066b resize.f2fs: correct checkpoint_ver of new checkpoint
resize.f2fs rebuilds a new checkpoint at the new position. Its
checkpoint_ver should be increased.

Signed-off-by: Shuoran Liu <liushuoran@huawei.com>
Signed-off-by: Weichao Guo <guoweichao@huawei.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-06 14:49:39 -08:00
Jaegeuk Kim
1e7aedf99b f2fs-tools: release 1.8.0
This release includes:
 - enhance fsck.f2fs mostly.
 - retrieve lost files from dump.f2fs.
 - support zoned device and multiple devices.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2017-02-03 16:10:17 -08:00