Commit Graph

983 Commits

Author SHA1 Message Date
Jaegeuk Kim
59591e45c0 fsck.f2fs: fix wrong block addres of nids
This patch avoids assert when nid has wrong block address.
Let's fix this.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-10-07 15:26:48 -07:00
joerg jungermann
fe067853b0 mkfs.f2fs: possible endianes bug in mkfs.f2fs roll-forward speed
I might found a bug in mkfs.f2fs. while experimenting with f2fs on my big
endian MIPS32 device (platform lantiq, 14.07-rc3, uclibc).

I ran into an issue that mkfs.f2fs, was not able to format block devices if I
did not specify the sector count manually.

I hunted it down to lib/libf2fs.c.
After I found that the detected sector count equals to the wanted sector count
shifted left (32+9) times.

I found two issues:
Firstly it uses ioctl BLKGETSIZE, which writes to an uint32_t the size of the
device.
As c->total_sectors is of type uint64_t, the value is written in to the first
4 bytes.
That explained the left shift of 32 bits.

Secondly BLKGETSIZE determines the size of the device in bytes (AFAIK, learned
by observation).
In the first branch of the if-block patched below, the c->total_sectors is
calculated by
  c->total_sectors = stat_buf.st_size / c->sector_size;
The else branch omits the devision. sector_sice is mostly 512, that explained
the left shift by 9 bytes.

 * fixes sector count calculation
 * uses BLKGETSIZE64 if avail

Signed-off-by: joerg jungermann <jj@borkum.net>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-09-25 22:14:45 -07:00
Jaegeuk Kim
f3a1ea9c7a f2fs-tools: fix for build big-endian processors
This patch fixes build failure on big-endian systems.

Reported-and-Tested-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-09-23 10:21:56 -07:00
Jaegeuk Kim
baac4b4e6f f2fs-tools: release 1.4.0
This version includes:
 - fsck.f2fs fixing corrupted images/partitions
 - dump.f2fs retrieving speicific file
 - bug fixes on f2fsstat and fibmap.f2fs
 - refactor code blocks for android build

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-09-18 18:10:37 -07:00
Jaegeuk Kim
7f47499d43 f2fstat: enhance readability of output
This patch enhances output readability of f2fstat.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-09-18 18:10:34 -07:00
Jaegeuk Kim
c7ac585c9f tracepoint.sh: update latest tracepoints
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-09-08 11:13:00 -07:00
Jaegeuk Kim
cfeb015e88 f2fs: rearrange options to remove redundant check
This patch summarizes the usage of options.

-a : auto_fix, fix corruption, only if f2fs reported some potential errors
-f : force,    fix corruption entire partition
None : prompt, if fsck.f2fs detets any corruption

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-09-03 19:45:42 -07:00
Jaegeuk Kim
7eb6c5a03b fsck.f2fs: add auto_fix feature
This patch adds an auto_fix feature which fixes inconsistency of f2fs images.

E.g.,

With this option, -a, fsck.f2fs tries to fix inconsistency only if its valid
checkpoint has CP_FSCK_FLAG, written by previous bug_on cases.

So, normally it does fix nothing, so that there is no performance regression.
But, if a sort of corruption was reported by the f2fs module, this tries to
fix potential corrupted partition.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-09-02 18:23:11 -07:00
Jaegeuk Kim
a6a7ac8e9d fsck.f2fs: avoid build warnings
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-09-02 11:07:33 -07:00
Jaegeuk Kim
7d96d138a3 fsck.f2fs: remove list.h
Just use list_head only.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 17:15:09 -07:00
Jaegeuk Kim
a6b2870ddb fsck.f2fs: check next block is free or not
If block allocation is made to the next block offset, we should drop that
block.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 16:37:46 -07:00
Jaegeuk Kim
b700e313b4 fsck.f2fs: fix checkpoint
- fix nat entries
- fix sit entries
- fix checkpoint

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
1dc1edfbcb fsck.f2fs: handle correctly segment summary entries
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
1bc74e1eed fsck.f2fs: remove corrupted xattr block
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
a89223b220 fsck.f2fs: corrupted orphan inode will be removed
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
32edfeaac7 fsck.f2fs: remove dentry if its inode block is corrupted
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
48ffea7ba8 fsck.f2fs: add fixing messeages
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
634dfb1552 fsck.f2fs: fix inode block inconsistency
This patch is to fix inode block inconsistency such as iblocks and ilinks.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
48863d422e fsck.f2fs: give a chance to recover sit entries
This patch skips initial verfication on SIT entries, which checks the number of
valid blocks from its bitmap.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
1ce70c67e3 fsck.f2fs: cleanup mount.c
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
5cd7001f5d fsck.f2fs: handle error cases
Do sanity check first and then update metadata.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
2701c94ab0 fsck.f2fs: remove return value of get_node_info
We don't need to get the return value.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
7aafb1b5f4 fsck.f2fs: handle IS_VALID_BLK_ADDR
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
f6d1d582e9 fsck.f2fs: clean up codes
Fix wrong coding style.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:29 -07:00
Jaegeuk Kim
6f4106c12b fsck.f2fs: retry to fix corrupted image
This patch adds a facility to retry conducting fsck.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 13:43:27 -07:00
Jaegeuk Kim
f46078949b f2fs_dentry_hash: avoid casting unsigned char to singed char
This can hurt when calculating hash value, resulting in false alarm.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-29 10:52:19 -07:00
Jaegeuk Kim
347e94f4b2 fsck.f2fs: show inode numbers
fsck.f2fs -d 1 [dev]
 : shows inode informations
fsck.f2fs -d -1 [dev]
 : shows directory tree with inode number

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-26 17:30:18 -07:00
Jaegeuk Kim
6cd2c51c20 dump.f2fs: support dump_file from image
This patch adds supporting dump_file, which can extract a file from image.

You can simply select [yes|no] when doing dump.f2fs -i [inode number] [img].

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-08-26 17:30:15 -07:00
Jaegeuk Kim
f381590f80 mkfs.f2fs: remove build warning
Should be unsigned int for le32_to_cpu.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-07-29 16:24:52 -07:00
Jaegeuk Kim
4b80852d76 tracepoint.sh: add missing tracepoints
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-07-29 16:24:11 -07:00
Sankalp Bose
92a65a44e5 mkfs.f2fs: fix name conflict for BLKDISCARD
The compile time option BLKDISCARD conflicts with ioctl code
for discard. This causes discard to fail with "Info: This
device doesn't support TRIM". Rename compile time option
to WITH_BLKDISCARD.

Signed-off-by: Sankalp Bose <sankalp@tuxera.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-07-25 08:11:16 -07:00
Changman Lee
092e3d9da3 mkfs.f2fs: large volume support
This patch supports large volume over about 3TB.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-07-10 16:22:04 -07:00
Mark Salyzyn
58edb106a8 f2fs-tools: 64-bit compile issue
Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Change-Id: I9398b877571d3dabbcb29c87a67d59672ea7fbaa
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-07-03 09:27:47 -07:00
JP Abgrall
e91da2f664 libf2fs: move the finalize_device() into the io lib.
This is required so that libf2fs.c can be used against any kind
of device (E.g. an in-memory sparse file) just by linking against
something that provides the libf2fs_io.c functions.

libf2fs is currently libf2fs.c + libf2fs_io.c

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-06-14 14:22:02 +09:00
Jaegeuk Kim
09f8f56066 mkfs: set BLKDISCARD by default
And let's show some debug info as well.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-06-13 17:48:42 +09:00
Jaegeuk Kim
0575dd1c56 libf2fs, fsck, mkfs: call f2fs_finalize_device before exit
The fsck tool should call f2fs_finalize_device before exit to close the device
file.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-06-13 17:06:02 +09:00
JP Abgrall
3ba4ce8950 mkfs: support passing in the number of sectors to use
Adds the optional sectors count:
  mkfs.f2fs [options] device [sectors]

Change-Id: I3ac83121576574bda074140ffa60195a2bc9947b

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-06-12 17:01:41 +09:00
JP Abgrall
97fd9037ec License tweak: LGPL v2.1 vs LGPL v2
The important part is

    b) Use a suitable shared library mechanism for linking with the
    Library.  A suitable mechanism is one that (1) uses at run time a
    copy of the library already present on the user's computer system,
    rather than copying library functions into the executable, and (2)
    will operate properly with a modified version of the library, if
    the user installs one, as long as the modified version is
    interface-compatible with the version that the work was made with.

Change-Id: Ic1a02ec5cfcb2bedda3d53f3061037e1e7437221
Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-06-12 16:52:59 +09:00
Changman Lee
4ea4f1db27 fsck.f2fs: large volume support
This patch support large volume over about 3TB.

Signed-off-by: Changman Lee <cm224.lee@samsung.com>
[Jaegeuk Kim: add missing cp_payload in f2fs_super_block]
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-06-04 13:32:07 +09:00
Jaegeuk Kim
03ca33c407 fibmap: need linux/fs.h for FIBMAP
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2014-05-26 10:42:08 +09:00
JP Abgrall
a68ee58a5d Cleanup various build warnings (signed vs unsigned, unused vars,...)
* removed unused includes.
* removed unused parameters.
* Fixed a bunch of warnings around:
    int i;
    if (i < some_uint) ...
  and
    u32 x;
    ...
    if (x < 0) return error;
* Protect BLKDISCARD usage if it is not available.

Change-Id: Iede035b1beb2df01c961589a69aff47a5258ecd2
Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-05-15 08:40:55 +09:00
Jaegeuk Kim
a4499dbe93 f2fs: fix to remove the test code that should not be merged
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-05-09 10:32:14 +09:00
Jaegeuk Kim
e35b8afb34 f2fs-tools: announce dual licenses with GPL and LGPL v2
This patch announces LGPL v2 for the following files.
- include/f2fs_fs.h
- lib/libf2fs.c
- lib/libf2fs_io.c
- mkfs/f2fs_format.c
- mkfs/f2fs_format_main.c
- mkfs/f2fs_format_utils.c
- mkfs/f2fs_format_utils.h

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-04-25 14:07:17 +09:00
JP Abgrall
a35529fce0 format: add support for dev_fill() and extra dev_*() debugging.
Support an fs_io dev_fill().
This helps with devices that actually already return 0 on uninitialized
data. It also helps with in memory devices using sparse libs: don't
allocate a block of 0s.

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-04-07 12:14:32 +09:00
JP Abgrall
15ea79b3ae further split up lib2fs so that it does not do any IO directly.
This will allow turning mkfs into a libarary more easily.

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-04-07 12:14:10 +09:00
JP Abgrall
af3c6803bd split up mkfs format into main and just the format code.
This will allow using the format code as a library.

Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-04-07 12:13:51 +09:00
Dongho Sim
2f229b89a7 mkfs: fix wrong extension count
fix an bug related to extension list.
there was the potential bug in set_cold_files function, namei.c.

Signed-off-by: Dongho Sim <dh.sim@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-04-01 18:56:13 +09:00
Natanael Copa
379ff8916e fibmap.f2fs: compile fix for musl libc
Include sys/types.h for major/minor macros.

This fixes the following compile error with musl libc:
fibmap.o: In function `print_stat':
/home/ncopa/src/f2fs-tools/tools/fibmap.c:34: undefined reference to `minor'
/home/ncopa/src/f2fs-tools/tools/fibmap.c:34: undefined reference to `major'
fibmap.o: In function `stat_bdev':
/home/ncopa/src/f2fs-tools/tools/fibmap.c:54: undefined reference to `minor'
/home/ncopa/src/f2fs-tools/tools/fibmap.c:54: undefined reference to `major'
collect2: error: ld returned 1 exit status

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-03-04 18:26:30 +09:00
Jaegeuk Kim
99250ec1aa mkfs: support large directory
This patch synchronizes mkfs with the latest f2fs configuration in which
supports large directory by assigning dir_level.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-02-27 20:32:09 +09:00
Jaegeuk Kim
192d979c61 fsck: remove build warnings
This patch casts some variable types to remove build warnings.

Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
2014-02-25 08:31:49 +09:00