[f2fs-dev] [PATCH] fsck.f2fs: fix double free invalid checkpoint

2015-12-27 Thread Sheng Yong
The invalid checkpoin is freed in validate_checkpoint(). Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/mount.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fsck/mount.c b/fsck/mount.c index fe68f37..7533926 100644 --- a/fsck/mount.c +++

[f2fs-dev] [RFC PATCH V2 2/2] mkfs.f2fs: avoid dumplicate extensions

2015-11-27 Thread Sheng Yong
Before copying an user specified extension to extension_list, check if it is already in the list. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- mkfs/f2fs_format.c | 26 +- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/mkfs/f2fs_format.c

Re: [f2fs-dev] [RFC PATCH] mkfs.f2fs: avoid dumplicate extension

2015-11-27 Thread Sheng Yong
On 11/28/2015 10:31 AM, Chao Yu wrote: > Hi Sheng Yong, > > On 11/28/15 8:39 AM, Sheng Yong wrote: >> >> On 11/27/2015 9:09 PM, Chao Yu wrote: >>> Hi Sheng Yong, >>> >>> On 11/28/15 12:55 AM, Sheng Yong wrote: >>>> Befo

Re: [f2fs-dev] [RFC PATCH V3 2/2] mkfs.f2fs: avoid dumplicate extensions

2015-11-27 Thread Sheng Yong
On 11/28/2015 12:00 PM, Chao Yu wrote: > On 11/28/15 11:07 AM, Sheng Yong wrote: >> Before copying an user specified extension to extension_list, check if it >> is already in the list. >> >> Signed-off-by: Sheng Yong <shengyo...@huawei.com> &

[f2fs-dev] [PATCH V3 1/2] mkfs.f2fs: avoid dumplicate extensions

2015-11-29 Thread Sheng Yong
Before copying an user specified extension to extension_list, check if it is already in the list. User specified extensions are delimitted by token either ',' or ' '. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- mkfs/f2fs_format.c | 20 +--- 1 file changed, 17 inse

Re: [f2fs-dev] [PATCH V3 2/2] mkfs.f2fs: skip extension name that is too long

2015-11-29 Thread Sheng Yong
Hi, Chao Yu, Jaegeuk I'm not sure if it is ok to send this patch out by me. If I did it the wrong way, please ignore this patch. thanks, Sheng On 11/30/2015 6:41 PM, Sheng Yong wrote: > From: Chao Yu <chao2...@samsung.com> > > The length of extension name has a l

[f2fs-dev] [RFC PATCH] mkfs.f2fs: avoid dumplicate extension

2015-11-27 Thread Sheng Yong
Before copying user specified extension to extension_list, check if it is already in the list. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- mkfs/f2fs_format.c | 23 ++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/mkfs/f2fs_format.c

[f2fs-dev] [RFC PATCH] f2fs: find parent dentry correctly

2016-06-04 Thread Sheng Yong
If dotdot directory is corrupted, its slot may be ocupied by another file. In this case, dentry[1] is not the parent directory. Rename and cross-rename will update the inode in dentry[1] incorrectly. This patch finds dotdot dentry by name. Signed-off-by: Sheng Yong <shengyo...@huawei.

[f2fs-dev] [PATCH] fsck.f2fs: swap checkpoint crc to CPU endian

2016-01-13 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/mount.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fsck/mount.c b/fsck/mount.c index c758774..b5fbaaa 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -390,7 +390,7 @@ void *validate_checkpoint(

[f2fs-dev] [PATCH] f2fs: fix endianness of on-disk summary_footer

2016-01-27 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- include/linux/f2fs_fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h index 25c6324..2863274 100644 --- a/include/linux/f2fs_fs.h +++ b/include/linux/f2fs_fs.h @@

[f2fs-dev] [RFC PATCH 0/4] do more check in sanity_check_nid and clean up

2016-01-29 Thread Sheng Yong
PATCH 1/4 cleans up get_{sb|cp} and set_{sb|cp} to integrate them into get_val and set_val to avoid dumplicated definition of macro. PATCH 3/4 and 4/4 check nat_entry->ino. If it is wrong, we drop corresponding nodes. thanks, Sheng Sheng Yong (4): f2fs-tools: simplify get_{sb|cp} and set_

[f2fs-dev] [RFC PATCH 1/4] f2fs-tools: simplify get_{sb|cp} and set_{sb|cp}

2016-01-29 Thread Sheng Yong
* Remove dumplicated definitions of get_{sb|cp} and set_{sb|cp}, and introduce micros get_val and set_val instead. * Add a new parameter to get_val and set_val so that they are not depended on implied definition of `sb' and `cp'. Signed-off-by: Sheng Yong <shengyo...@huawei.com> ---

[f2fs-dev] [RFC PATCH 3/4] fsck.f2fs: check ino of an used nat entry

2016-01-29 Thread Sheng Yong
If a nid is valid, the ino in its nat entry should record its parent nid. However if the ino is zero, we should drop the node. Signed-off-by: Sheng Yong <shengyo...@huawei.com> Signed-off-by: Xue Liu <liuxueliu@huawei.com> --- fsck/fsck.c | 5 + 1 file changed, 5 inserti

[f2fs-dev] [RFC PATCH 4/4] fsck.f2fs: check ino of an inode

2016-01-29 Thread Sheng Yong
If the node is an inode, its ino in the nat entry should be equal to the ino in its node footer. Otherwise, we drop the file. Signed-off-by: Sheng Yong <shengyo...@huawei.com> Signed-off-by: Xue Liu <liuxueliu@huawei.com> --- fsck/fsck.c | 5 + 1 file changed, 5 insertions(+)

[f2fs-dev] [RFC PATCH 2/4] f2fs-tools: fix endianness of on-disk check_sum in summary_footer

2016-01-29 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- include/f2fs_fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 2ab9f49..1b02d16 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -677,7 +677,7 @@ struct f2fs_s

Re: [f2fs-dev] [RFC PATCH 1/4] f2fs-tools: simplify get_{sb|cp} and set_{sb|cp}

2016-01-29 Thread Sheng Yong
s a trivial cleanup. I think it's ok to keep it as it is now :) thanks, Sheng > Thanks, > > On Sat, Jan 30, 2016 at 09:16:36AM +, Sheng Yong wrote: >> * Remove dumplicated definitions of get_{sb|cp} and set_{sb|cp}, and >> introduce >> micros get_val and set_

[f2fs-dev] [RFC PATCH v2] f2fs-tools: simplify get_{sb|cp} and set_{sb|cp}

2016-01-30 Thread Sheng Yong
-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/fsck.c| 20 ++--- fsck/main.c| 8 +- fsck/mount.c | 146 - include/f2fs_fs.h | 88 mkfs/f2fs_format.c | 234 ++

[f2fs-dev] [RFC PATCH] fsck.f2fs: fix corrupted nat entry [0]

2016-02-23 Thread Sheng Yong
The first nat entry must be null. If it is corrupted, we set its bit in nat_area_bitmap, without increasing valid_nat_entry_cnt, fsck_verify will nullify it at last. Reported-by: Cheng Yinchao <chengyinc...@huawei.com> Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/

[f2fs-dev] [RFC PATCH] fsck.f2fs: remove corrupted nid entry from indirect/double-indirect node

2016-02-19 Thread Sheng Yong
d bugs [Fail] = So let's clean it. Reported-by: Chen Yinchao <chengyinc...@huawei.com> Signed-off-by: Liu Xue <liuxueliu@huawei.com> Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/fsck.c | 46 --

[f2fs-dev] [RFC PATCH 1/4] f2fs: correct return value type of f2fs_fill_super

2016-05-11 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 28c8992..0e54e84 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1417,7 +1417,7 @@ stat

[f2fs-dev] [RFC PATCH 2/4] f2fs: introduce f2fs_fault_info for fault injection

2016-05-11 Thread Sheng Yong
This patch introduces a new struct f2fs_fault_info and a global f2fs_fault to save fault injection status. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/f2fs.h | 12 fs/f2fs/super.c | 1 + 2 files changed, 13 insertions(+) diff --git a/fs/f2fs/f2fs.h b/f

[f2fs-dev] [RFC PATCH 4/4] f2fs: move fault injection to sysfs

2016-05-11 Thread Sheng Yong
Replace mount option "f2fs_injection" by injection attributes in sysfs. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/f2fs.h | 24 ++-- fs/f2fs/super.c | 15 --- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/fs/

[f2fs-dev] [RFC PATCH v2 4/4] f2fs: move fault injection to sysfs

2016-05-11 Thread Sheng Yong
Replace mount option "f2fs_injection" by injection attributes in sysfs. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/f2fs.h | 24 ++-- fs/f2fs/super.c | 18 -- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/

Re: [f2fs-dev] [PATCH v2 2/2] f2fs: add fault injection to sysfs

2016-05-12 Thread Sheng Yong
Hi, Kim On 5/13/2016 10:47 AM, Jaegeuk Kim wrote: > Hi Sheng, > > On Fri, May 13, 2016 at 10:22:40AM +0800, Sheng Yong wrote: >> This patch introduces a new struct f2fs_fault_info and a global f2fs_fault >> to save fault injection status. All fault injection interfaces are

[f2fs-dev] [PATCH v3 1/2] f2fs: correct return value type of f2fs_fill_super

2016-05-15 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 28c8992..0e54e84 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1417,7 +1417,7 @@ stat

[f2fs-dev] [PATCH v3 2/2] f2fs: add fault injection to sysfs

2016-05-15 Thread Sheng Yong
This patch introduces a new struct f2fs_fault_info and a global f2fs_fault to save fault injection status. Fault injection entries are created in /sys/fs/f2fs/fault_injection/ during initializing f2fs module. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- v3: * Integrate all fault

[f2fs-dev] [PATCH v2 2/2] f2fs: add fault injection to sysfs

2016-05-12 Thread Sheng Yong
This patch introduces a new struct f2fs_fault_info and a global f2fs_fault to save fault injection status. All fault injection interfaces are created in /sys/fs/f2fs/fault_injection during initializing f2fs module. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/f2fs.h

[f2fs-dev] [PATCH v2 1/2] f2fs: correct return value type of f2fs_fill_super

2016-05-12 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 28c8992..0e54e84 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1417,7 +1417,7 @@ stat

[f2fs-dev] [PATCH trivial 1/7] dump.f2fs: show inode->i_dir_level

2016-07-15 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/mount.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fsck/mount.c b/fsck/mount.c index e0223e0..3e3d176 100644 --- a/fsck/mount.c +++ b/fsck/mount.c @@ -70,6 +70,7 @@ void print_inode_info(struct f2fs_inode *inode, in

[f2fs-dev] [PATCH trivial 3/7] fsck.f2fs: correct variable type and name

2016-07-15 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/fsck.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fsck/fsck.c b/fsck/fsck.c index 8a6373b..f349bd8 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -736,7 +736,7 @@ void fsck_chk_inode_blk(struct f2fs_s

[f2fs-dev] [PATCH trivial 2/7] f2fs.fsck: fix endianess

2016-07-15 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/fsck.c | 2 +- fsck/mount.c | 8 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fsck/fsck.c b/fsck/fsck.c index c24eb58..8a6373b 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -383,7 +383,7 @@ stat

[f2fs-dev] [PATCH trivial 4/7] fsck.f2fs: fix typo

2016-07-15 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/fsck.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fsck/fsck.c b/fsck/fsck.c index f349bd8..33e8cf7 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -369,7 +369,7 @@ static int sanity_check_nid(struct f2fs_s

[f2fs-dev] [PATCH trivial 6/7] f2fs-tools: update the format of output message

2016-07-15 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/mount.c| 4 ++-- fsck/resize.c | 4 ++-- mkfs/f2fs_format.c | 28 ++-- mkfs/f2fs_format_main.c | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/fsck/mou

[f2fs-dev] [PATCH trivial 7/7] fsck.f2fs: clean up duplicated code

2016-07-15 Thread Sheng Yong
From: Xue Liu From: Xue Liu Call current_nat_addr() to calculate nat block address. Signed-off-by: Xue Liu --- fsck/mount.c | 56 1 file changed, 8

[f2fs-dev] [PATCH trivial 5/7] fsck.f2fs: free nat entry cache

2016-07-15 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/fsck.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fsck/fsck.c b/fsck/fsck.c index 33e8cf7..d2248c6 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -1953,6 +1953,9 @@ void fsck_free(struct f2fs_sb_info *sbi) if

Re: [f2fs-dev] [PATCH] mkfs.f2fs: fix bad assignment of total_sectors for f2fs_configuration

2017-01-23 Thread Sheng Yong
Hi, Kinglong On 1/24/2017 10:42 AM, Kinglong Mee wrote: > wanted_total_sectors is introduced instead total_sectors, > so that, the initialize is a fault, drop it. > > Signed-off-by: Kinglong Mee > --- > mkfs/f2fs_format_main.c | 3 --- > 1 file changed, 3 deletions(-) >

[f2fs-dev] [PATCH 1/2] f2fs-tools: correct endianness

2017-01-18 Thread Sheng Yong
It is reported that fsck.f2fs behaves abnormally when running on MIPS32 rel 2 big endian cpu, since incorrect endianness. So let's correct all endianess issues of f2fs-tools. Reported-by: <k...@vodka.home.kg> Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/dir.c

[f2fs-dev] [PATCH 2/2] fsck.f2fs: support -p without argument

2017-01-18 Thread Sheng Yong
This patch allows fsck run -p without argument. So we could use -p as -p, -p0, and -p1. '-p' and '-p0' have the same meaning as '-a'. '-p1' checks more meta data than '-a'. Reported-by: KARBOWSKI Piotr <piotr.karbow...@gmail.com> Signed-off-by: Sheng Yong <shengyo...@huawei.com> ---

Re: [f2fs-dev] [PATCH 2/2] fsck.f2fs: support -p without argument

2017-01-20 Thread Sheng Yong
Hi Jaegeuk, On 1/20/2017 5:47 PM, Jaegeuk Kim wrote: > On 01/20, Sheng Yong wrote: [..] >>> >>> if (!strcmp("fsck.f2fs", prog)) { >>> - const char *option_string = "ad:fp:t"; >>> + const char *option_string = &

Re: [f2fs-dev] [PATCH 2/2] fsck.f2fs: support -p without argument

2017-01-20 Thread Sheng Yong
Hi Jaegeuk, On 1/20/2017 7:19 AM, Jaegeuk Kim wrote: > Hi Sheng Yong, > > I tested this, but failed on -p with arguments. Sorry, this may because double colon in optsting can only be used at some Unix-like distributions :( > > Could you take a look at this change? I te

[f2fs-dev] [PATCH] f2fs: remove unnecessary initialization

2016-08-23 Thread Sheng Yong
`flags' is used to save value from userspace, there is no need to initialize it, and FS_FL_USER_VISIBLE is the mask for getflags. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/file.c b/f

[f2fs-dev] [trivial PATCH] f2fs: remove dead variable

2016-09-29 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/gc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index c9b8a67..93985c6 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -275,7 +275,7 @@ static int get_victim_by_default(

[f2fs-dev] [PATCH 1/2] dump/fsck: convert encrypted file name

2016-10-23 Thread Sheng Yong
If fscrypt is enabled, we need to convert the encrypted file name before printing it. So let's export convert_encrypted_name for other functions, and make it returns the length of converted string. This patch also changes the parameter of file_is_encrypt to f2fs_inode. Signed-off-by: Sheng Yong

Re: [f2fs-dev] [PATCH 1/2] dump/fsck: convert encrypted file name

2016-10-23 Thread Sheng Yong
Hi, Jaegeuk, On 10/24/2016 10:16 AM, Sheng Yong wrote: > If fscrypt is enabled, we need to convert the encrypted file name before > printing it. So let's export convert_encrypted_name for other functions, > and make it returns the length of converted string. > This patch

[f2fs-dev] [RFT PATCH 1/2] fsck.f2fs: remove duplicated header files

2016-11-25 Thread Sheng Yong
Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/f2fs.h | 2 -- fsck/xattr.h | 1 - 2 files changed, 3 deletions(-) diff --git a/fsck/f2fs.h b/fsck/f2fs.h index fbb878a..1a0723c 100644 --- a/fsck/f2fs.h +++ b/fsck/f2fs.h @@ -19,8 +19,6 @@ #include #include #include -#i

Re: [f2fs-dev] [RFT PATCH 2/2] fsck.f2fs: correct endianness

2016-11-25 Thread Sheng Yong
> [FSCK] valid_inode_count matched with CP [Ok..] [0x1] > [FSCK] free segment_count matched with CP [Ok..] [0x24] > [FSCK] next block offset is free [Ok..] > [FSCK] fixing SIT types > [FSCK] other corrupted bugs [Ok..] >

[f2fs-dev] [RFT PATCH 2/2] fsck.f2fs: correct endianness

2016-11-25 Thread Sheng Yong
Reported-by: <k...@vodka.home.kg> Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- Hi, k Could you please try this? I think I've correct all endianness issue. And can I have your reported-by and test-by? thanks, Sheng --- fsck/dir.c| 6 +++--- fsck/dump.

Re: [f2fs-dev] fsck is broken on mips32 platform

2016-11-24 Thread Sheng Yong
Hi, On 11/25/2016 6:30 AM, k...@vodka.home.kg wrote: > Hi ! > > I'm using f2fs on router Dlink dir-825 with openwrt/LEDE firmware. > Its mips32 rel 2 big endian cpu. > > mkfs.f2fs - works > mount - works > fsck.f2fs - corrupts filesystem > > # i'm trying to fsck valid empty mountable f2fs

[f2fs-dev] [PATCH 2/2] f2fs: check range before defragment

2017-03-07 Thread Sheng Yong
This patch checks the parameter range passed by ioctl to void that range exceeds the max_file_blocks limit. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/file.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index e0b2378..eb675f1

Re: [f2fs-dev] [RFC PATCH v2 2/2] f2fs: do not set LOST_PINO for renamed dir

2017-07-01 Thread Sheng Yong
Hi, Jaegeuk On 2017/7/1 23:10, Jaegeuk Kim wrote: Hi, On 06/26, Sheng Yong wrote: After renaming a directory, fsck could detect unmatched pino. The scenario can be reproduced as the following: $ mkdir /bar/subbar /foo $ rename /bar/subbar /foo Then fsck will report: [ASSERT

[f2fs-dev] [RFC PATCH] f2fs: do not set LOST_PINO for created/renamed dir

2017-06-22 Thread Sheng Yong
be reproduced as the following: $ mkdir /bar/subbar /foo $ rename /bar/subbar /foo Then fsck will report: [ASSERT] (__chk_dots_dentries:1182) --> Bad inode number[0x3] for '..', parent parent ino is [0x4] Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/di

[f2fs-dev] [RFC PATCH v2 1/2] f2fs: do not set LOST_PINO for newly created dir

2017-06-25 Thread Sheng Yong
Since directories will be written back with checkpoint and fsync a directory will always write CP, there is no need to set LOST_PINO after creating a directory. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff

[f2fs-dev] [RFC PATCH v2 2/2] f2fs: do not set LOST_PINO for renamed dir

2017-06-25 Thread Sheng Yong
ino is [0x4] Rename sets LOST_PINO for old_inode. However, the flag cannot be cleared, since dir is written back with CP. So, let's get rid of LOST_PINO for a renamed dir and fix the pino directly at the end of rename. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/namei.c | 5

[f2fs-dev] [RFC PATCH 1/3] f2fs: introduce sysfs readdir_ra to readahead inode block in readdir

2017-11-22 Thread Sheng Yong
0m01.94s user 0m50.80s system enable readdir_ra: 0m18.55s real 0m00.44s user 0m15.39s system Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++ fs/f2fs/dir.c | 4 fs/f2fs/f2fs.h

[f2fs-dev] [PATCH 2/3] f2fs: still write data if preallocate only partial blocks

2017-11-22 Thread Sheng Yong
If there is not enough space left, f2fs_preallocate_blocks may only preallocte partial blocks. As a result, the write operation fails but i_blocks is not 0. To avoid this, f2fs should write data in non-preallocation way and write as many data as the size of i_blocks. Signed-off-by: Sheng Yong

[f2fs-dev] [PATCH 3/3] f2fs: remove unused parameter

2017-11-22 Thread Sheng Yong
Commit d260081ccf37 ("f2fs: change recovery policy of xattr node block") removes the use of blkaddr, which is no longer used. So remove the parameter. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/f2fs.h | 3 +-- fs/f2fs/node.c | 2 +- fs/f2fs/recovery

Re: [f2fs-dev] [PATCH] fsck.f2fs: check nid range before use to avoid segmentation fault

2017-12-15 Thread Sheng Yong
On 2017/12/15 14:26, Yunlong Song wrote: Signed-off-by: Yunlong Song --- fsck/fsck.c | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fsck/fsck.c b/fsck/fsck.c index 11b8b0b..2212aa3 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -14,6

Re: [f2fs-dev] [PATCH] fsck.f2fs: check and fix i_namelen to avoid double free

2017-12-15 Thread Sheng Yong
On 2017/12/15 14:25, Yunlong Song wrote: Signed-off-by: Yunlong Song --- fsck/fsck.c | 19 --- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/fsck/fsck.c b/fsck/fsck.c index 2212aa3..8ff4e4b 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c

[f2fs-dev] [RFC PATCH v2 9/9] fsck.f2fs: format output message of FIX_MSG

2017-11-01 Thread Sheng Yong
This patch removes an extra '\n' at the end of the string in FIX_MSG. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/fsck.c | 4 ++-- fsck/mount.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fsck/fsck.c b/fsck/fsck.c index 77490d8..1905319

[f2fs-dev] [RFC PATCH v2 6/9] fsck.f2fs: introduce new option --dry-run

2017-11-01 Thread Sheng Yong
With --dry-run enabled, fsck.f2fs will do all checks and "fixes" except that all fixes will not be written to storage at last. Signed-off-by: Sheng Yong <shengyo...@huawei.com> Reviewed-by: Chao Yu <yuch...@huawei.com> --- fsck/main.c | 14 +- include

[f2fs-dev] [RFC PATCH v2 1/9] fsck.f2fs: do not set fix_on directly

2017-11-01 Thread Sheng Yong
Do not set fix_on if it is allowed by user. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/main.c | 2 +- fsck/mount.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/fsck/main.c b/fsck/main.c index c9411eb..93037e1 100644 --- a/fsck/main.c +++ b/fsck/

[f2fs-dev] [RFC PATCH v2 3/9] dump/fsck: introduce print_xattr_entry

2017-11-01 Thread Sheng Yong
This patch exports read_all_xattrs to allow dump/fsck to get all xattrs, and introduces print_xattr_entry which tries to parse an xattr entry accroding to its xattr index. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/dump.c | 18 - fsck/fsck.h | 7 +++- fsck/m

[f2fs-dev] [RFC PATCH v2 4/9] dump.f2fs: introduce dump_xattr

2017-11-01 Thread Sheng Yong
This patch introduces dump_xattr to create xattrs for dumped files. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/dump.c | 63 ++--- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/fsck/dump.c b/fsck/dump.c

[f2fs-dev] [RFC PATCH v2 7/9] fsck.f2fs: introduce sanity_check_inode

2017-11-01 Thread Sheng Yong
f2fs_iget checks if i_mode is valid. If it is not, the file cannot be accessed as well as deleted. To make sure such files can be removed, fsck adds the same check, and removes incorrect inode blocks. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/fsck.c | 21 ++

[f2fs-dev] [RFC PATCH v2 5/9] dump.f2fs: do not dump encrypted files

2017-11-01 Thread Sheng Yong
If a file is encrypted, its content is cipher text on the storage. So there is no need to dump an encrypted file. Signed-off-by: Sheng Yong <shengyo...@huawei.com> Reviewed-by: Chao Yu <yuch...@huawei.com> --- fsck/dump.c | 12 1 file changed, 8 insertions(+), 4 deleti

[f2fs-dev] [RFC PATCH v2 0/9] f2fs-tools: fix fix_on usage and introduce dump/print xattr

2017-11-01 Thread Sheng Yong
v1-v2: [PATCH 3] print values of USER/SECRUITY xattr as hex instead of plain text. [PATCH 4] replace xattr value if it already exists by setting parameter `flags' as 0 of fsetxattr. [PATCH 1/7] move message printing modification into a different patch. thanks, Sheng Sheng Yong (9

[f2fs-dev] [RFC PATCH v2 8/9] f2fs-tools: remove unused list.h

2017-11-01 Thread Sheng Yong
Commit 7d96d138a378 ("fsck.f2fs: remove list.h") has already the usage of list.h. So let's remove list.h itself. Signed-off-by: Sheng Yong <shengyo...@huawei.com> Reviewed-by: Chao Yu <yuch...@huawei.com> --- include/list.h | 88

[f2fs-dev] [RFC PATCH v2 2/9] fsck.f2fs: do not fix corrupted nat entries in build_nat_area_bitmap

2017-11-01 Thread Sheng Yong
Fixing corrupted data depends on c.fix_on. If it's not set, we should not force fixing corrupted data. So if nat entries are found invalid when building nat_area_bitmap, we should just set c.bug_on, and fix it later. Signed-off-by: Sheng Yong <shengyo...@huawei.com> Reviewed-by: Chao Yu

[f2fs-dev] [PATCH v5] dump/fsck: introduce print_xattr_entry

2017-11-02 Thread Sheng Yong
This patch exports read_all_xattrs to allow dump/fsck to get all xattrs, and introduces print_xattr_entry which tries to parse an xattr entry accroding to its xattr index. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- v3->v5: Please ignore the previous [PATCH v3/v4] because o

[f2fs-dev] [PATCH v3] dump/fsck: introduce print_xattr_entry

2017-11-02 Thread Sheng Yong
This patch exports read_all_xattrs to allow dump/fsck to get all xattrs, and introduces print_xattr_entry which tries to parse an xattr entry accroding to its xattr index. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- v2->v3: check if is supported. If it is not, print ACL val

[f2fs-dev] [PATCH v4] dump/fsck: introduce print_xattr_entry

2017-11-02 Thread Sheng Yong
This patch exports read_all_xattrs to allow dump/fsck to get all xattrs, and introduces print_xattr_entry which tries to parse an xattr entry accroding to its xattr index. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- v3->v4: Please ignore the previous [PATCH v3] because o

[f2fs-dev] [RFC PATCH 3/8] dump/fsck: introduce print_xattr_entry

2017-10-30 Thread Sheng Yong
This patch exports read_all_xattrs to allow dump/fsck to get all xattrs, and introduces print_xattr_entry which tries to parse an xattr entry accroding to its xattr index. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/dump.c | 18 - fsck/fsck.h | 7 +++- fsck/m

[f2fs-dev] [RFC PATCH 2/8] fsck.f2fs: do not fix corrupted nat entries in build_nat_area_bitmap

2017-10-30 Thread Sheng Yong
Fixing corrupted data depends on c.fix_on. If it's not set, we should not force fixing corrupted data. So if nat entries are found invalid when building nat_area_bitmap, we should just set c.bug_on, and fix it later. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/mount.

[f2fs-dev] [RFC PATCH 5/8] dump.f2fs: do not dump encrypted files

2017-10-30 Thread Sheng Yong
If a file is encrypted, its content is cipher text on the storage. So there is no need to dump an encrypted file. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/dump.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fsck/dump.c b/fsck/dump.c

[f2fs-dev] [RFC PATCH 4/8] dump.f2fs: introduce dump_xattr

2017-10-30 Thread Sheng Yong
This patch introduces dump_xattr to create xattrs for dumped files. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/dump.c | 63 ++--- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/fsck/dump.c b/fsck/dump.c

[f2fs-dev] [RFC PATCH 1/8] fsck.f2fs: do not set fix_on directly

2017-10-30 Thread Sheng Yong
Do not set fix_on if it is allowed by user. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/main.c | 2 +- fsck/mount.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsck/main.c b/fsck/main.c index c9411eb..93037e1 100644 --- a/fsck/main.c +++ b/fsck/

[f2fs-dev] [RFC PATCH 7/8] fsck.f2fs: introduce sanity_check_inode

2017-10-30 Thread Sheng Yong
f2fs_iget checks if i_mode is valid. If it is not, the file cannot be accessed as well as deleted. To make sure such files can be removed, fsck adds the same check, and removes incorrect inode blocks. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/fsck.c

[f2fs-dev] [RFC PATCH 8/8] f2fs-tools: remove unused list.h

2017-10-30 Thread Sheng Yong
Commit 7d96d138a378 ("fsck.f2fs: remove list.h") has already the usage of list.h. So let's remove list.h itself. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- include/list.h | 88 -- 1 file changed, 88 deletions

[f2fs-dev] [RFC PATCH 6/8] fsck.f2fs: introduce new option --dry-run

2017-10-30 Thread Sheng Yong
With --dry-run enabled, fsck.f2fs will do all checks and "fixes" except that all fixes will not be written to storage at last. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/main.c | 14 +- include/f2fs_fs.h | 1 + lib/libf2fs.c | 1 + lib/li

Re: [f2fs-dev] [RFC PATCH 2/8] fsck.f2fs: do not fix corrupted nat entries in build_nat_area_bitmap

2017-10-31 Thread Sheng Yong
Hi, Chao On 2017/10/31 15:20, Chao Yu wrote: On 2017/10/31 9:38, Sheng Yong wrote: Fixing corrupted data depends on c.fix_on. If it's not set, we should not force fixing corrupted data. So if nat entries are found invalid when building nat_area_bitmap, we should just set c.bug_on, and fix

Re: [f2fs-dev] [RFC PATCH 3/8] dump/fsck: introduce print_xattr_entry

2017-10-31 Thread Sheng Yong
On 2017/10/31 15:51, Chao Yu wrote: On 2017/10/31 9:38, Sheng Yong wrote: [...] + +void print_xattr_entry(struct f2fs_xattr_entry *ent) +{ + char *value = (char *)(ent->e_name + le16_to_cpu(ent->e_name_len)); + struct fscrypt_context *ctx; + int i; + + MSG(0, &q

Re: [f2fs-dev] [RFC PATCH 5/8] dump.f2fs: do not dump encrypted files

2017-10-31 Thread Sheng Yong
On 2017/10/31 15:57, Chao Yu wrote: On 2017/10/31 9:38, Sheng Yong wrote: If a file is encrypted, its content is cipher text on the storage. So there is no need to dump an encrypted file. IMO, if user have encryption key, it still has chance to read that file, right? So how about keeping

Re: [f2fs-dev] [RFC PATCH 4/8] dump.f2fs: introduce dump_xattr

2017-10-31 Thread Sheng Yong
On 2017/10/31 15:51, Chao Yu wrote: On 2017/10/31 9:38, Sheng Yong wrote: This patch introduces dump_xattr to create xattrs for dumped files. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/dump.c | 63 ++---

Re: [f2fs-dev] [RFC PATCH 6/8] fsck.f2fs: introduce new option --dry-run

2017-10-31 Thread Sheng Yong
On 2017/10/31 15:57, Chao Yu wrote: On 2017/10/31 9:38, Sheng Yong wrote: With --dry-run enabled, fsck.f2fs will do all checks and "fixes" except that all fixes will not be written to storage at last. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/m

Re: [f2fs-dev] [RFC PATCH 7/8] fsck.f2fs: introduce sanity_check_inode

2017-10-31 Thread Sheng Yong
On 2017/10/31 16:04, Chao Yu wrote: On 2017/10/31 9:38, Sheng Yong wrote: f2fs_iget checks if i_mode is valid. If it is not, the file cannot be accessed as well as deleted. To make sure such files can be removed, fsck adds the same check, and removes incorrect inode blocks. Signed-off

Re: [f2fs-dev] [RFC PATCH 1/8] fsck.f2fs: do not set fix_on directly

2017-10-31 Thread Sheng Yong
On 2017/10/31 15:06, Chao Yu wrote: On 2017/10/31 9:38, Sheng Yong wrote: Do not set fix_on if it is allowed by user. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fsck/main.c | 2 +- fsck/mount.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fsck/

[f2fs-dev] [PATCH] f2fs: clear discard_wake earlier

2018-05-08 Thread Sheng Yong
If SBI_NEED_FSCK is set, discard_wake will never be cleared. As a result, the condition of wait_event_interruptible_timeout() is always true, which gets discard thread run too frequently. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/segment.c | 7 --- 1 file chan

[f2fs-dev] [PATCH 1/2] sload.f2fs: update sit entries of cursegs

2018-06-12 Thread Sheng Yong
move_curseg_info->reset_curseg changes cursegs, however, new segment entries are not set as dirty. As a result, flush_sit_entries will not update entries in SIT, especially when an empty segment is selected as the new curseg, its seg_entry->type is lost. Signed-off-by: Sheng Yong ---

[f2fs-dev] [RFC PATCH 2/2] fsck.f2fs: introduce fsck_chk_curseg_info

2018-06-12 Thread Sheng Yong
If curseg is an empty segment, it will not be checked. This patch introduces fsck_chk_curseg_info() to check SIT/SSA type of cursegs to avoid curseg corruption. Signed-off-by: Sheng Yong --- fsck/fsck.c | 34 ++ fsck/fsck.h | 1 + fsck/main.c | 2 ++ 3 files

[f2fs-dev] [PATCH] f2fs-tools: do not count free_segs in flush_sit_entries

2018-06-13 Thread Sheng Yong
flush_sit_entries() is always called before write_checkpoint(). Since free_segs is counted in write_checkpoint, there is no need to do that in flush_sit_entries. Besides, the value of free_segs may be not correct if we skip uptodate seg_entries. Signed-off-by: Sheng Yong --- fsck/mount.c | 7

[f2fs-dev] [PATCH] resize.f2fs: skip cursegs when finding next free block

2018-06-04 Thread Sheng Yong
resize.f2fs (f2fs_defragment) tries to migrate blocks to new positions. However, if a curseg is selected, and f2fs_defragment is broken by any error, curseg->next_blkoff is left not updated. To avoid this, we skip cursegs when finding next free block. Signed-off-by: Sheng Yong --- fsck/f2f

Re: [f2fs-dev] [PATCH] resize.f2fs: skip cursegs when finding next free block

2018-06-04 Thread Sheng Yong
Hi, Jaegeuk On 2018/6/5 4:55, Jaegeuk Kim wrote: On 06/04, Sheng Yong wrote: resize.f2fs (f2fs_defragment) tries to migrate blocks to new positions. However, if a curseg is selected, and f2fs_defragment is broken by any error, curseg->next_blkoff is left not updated. To avoid this, we s

[f2fs-dev] [PATCH] fsck.f2fs: clear qf_ino if quota node is removed

2018-06-21 Thread Sheng Yong
If a quota node is corrupted, it may be removed. Then its qf_ino should also be removed. Signed-off-by: Sheng Yong --- fsck/fsck.c | 19 +-- fsck/fsck.h | 1 + fsck/mount.c | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/fsck/fsck.c b/fsck/fsck.c

[f2fs-dev] [PATCH 1/2] fsck.f2fs: check extent of inline data/dentry inode

2018-07-03 Thread Sheng Yong
Check extent for inline data/dentry inode. If an inode contains inline data/dentry, it should have no extent. Link: https://bugzilla.kernel.org/show_bug.cgi?id=200175 Reported-by: Wen Xu Signed-off-by: Sheng Yong --- fsck/fsck.c | 16 +++- fsck/fsck.h | 1 + 2 files changed, 12

[f2fs-dev] [PATCH 2/2] fsck.f2fs: check extra_attr feature

2018-07-03 Thread Sheng Yong
Check extra_attr feature for inode. If it is corrupted, remove the inode. Link: https://bugzilla.kernel.org/show_bug.cgi?id=200219 Reported-by: Wen Xu Signed-off-by: Sheng Yong --- fsck/fsck.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/fsck/fsck.c b/fsck/fsck.c index 15264b2

[f2fs-dev] [PATCH] f2fs: avoid hungtask when gc encrypted block if io_bits is set

2018-01-10 Thread Sheng Yong
k+0x3a7/0x6f0 [ 246.756533] worker_thread+0x82/0x750 [ 246.756537] kthread+0x16f/0x1c0 [ 246.756541] ? trace_event_raw_event_workqueue_work+0x110/0x110 [ 246.756544] ? kthread_create_worker_on_cpu+0xb0/0xb0 [ 246.756548] ret_from_fork+0x1f/0x30 Signed-off-by: Sheng Yong <shengyo...@huawei.com>

[f2fs-dev] [PATCH v2] f2fs: avoid hungtask when GC encrypted block if io_bits is set

2018-01-16 Thread Sheng Yong
0 Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- v2->v1: do not change the index in meta inode make move_data_block aware EAGAIN error --- fs/f2fs/gc.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 33e79697e41c..aa720c

[f2fs-dev] [PATCH] f2fs: fix potential corruption in area before F2FS_SUPER_OFFSET

2018-01-29 Thread Sheng Yong
sb_getblk does not guarantee the buffer head is uptodate. If bh is not uptodate, the data (may be used as boot code) in area before F2FS_SUPER_OFFSET may get corrupted when super block is committed. Signed-off-by: Sheng Yong <shengyo...@huawei.com> --- fs/f2fs/super.c | 4 ++-- 1 file chan

Re: [f2fs-dev] [PATCH] f2fs: fix potential corruption in area before F2FS_SUPER_OFFSET

2018-01-29 Thread Sheng Yong
Hi, Chao On 2018/1/29 16:27, Chao Yu wrote: On 2018/1/29 16:04, Sheng Yong wrote: sb_getblk does not guarantee the buffer head is uptodate. If bh is not uptodate, the data (may be used as boot code) in area before Why boot code can be stored into the position f2fs superblock locates

Re: [f2fs-dev] [PATCH] f2fs: fix potential corruption in area before F2FS_SUPER_OFFSET

2018-01-29 Thread Sheng Yong
On 2018/1/29 16:58, Chao Yu wrote: Hi Sheng Yong, On 2018/1/29 16:39, Sheng Yong wrote: Hi, Chao On 2018/1/29 16:27, Chao Yu wrote: On 2018/1/29 16:04, Sheng Yong wrote: sb_getblk does not guarantee the buffer head is uptodate. If bh is not uptodate, the data (may be used as boot code

  1   2   3   >