Re: [PATCH 1/2] btrfs-progs: cmds-check.c: supports inode nbytes fix in lowmem

2017-01-19 Thread Su Yue
+0800, Su Yue wrote: Added 'repair_inode_item' which dispatches functions such as 'repair_inode__nbytes_lowmem' to correct errors and 'struct inode_item_fix_info' to store correct values and errors. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c

[PATCH 03/20] btrfs-progs: cmds-check.c: inode orphan item repair

2017-02-28 Thread Su Yue
Add a function named 'repair_inode_orphan_item_lowmem'. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 50 +- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/cmds-check.c b/cmds-check.c index f13ce317..fb

[PATCH 07/20] btrfs-progs: cmds-check.c: introduce print_inode_ref

2017-02-28 Thread Su Yue
Introduce 'print_inode_ref' to print error msg while checking inode ref. Add args 'name_ret' and 'namelen_ret' to 'check_inode_ref' because they are essential while doing nlinks repair. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.

[PATCH 04/20] btrfs-progs: cmds-check.c: change find_inode_ref's arg

2017-02-28 Thread Su Yue
For further lowmem repairs, change the index type u64 to u64 *. So we could get the index of ref. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 24 +++- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/cmds-check.c b/cmds-check.c

[PATCH 13/20] btrfs-progs: cmds-check.c: repair_inode_item_missing

2017-02-28 Thread Su Yue
Introduce 'repair_inode_item_missing' to fix INODE_ITEM_MISSING This patch is for further repair. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 43 +++ 1 file changed, 43 insertions(+) diff --git a/cmds-check.c b/cmds-check.c

[PATCH 12/20] btrfs-progs: cmds-check.c: introduce __create_inode_item

2017-02-28 Thread Su Yue
Introduce '__create_inode' to create and insert inode item. Modify origin 'create_inode_item' call it. Create 'create_inode_item_lowmem' call it. The patch is for further lowmem repair. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.

[PATCH 11/20] btrfs-progs: inode.c: alter btrfs_add_link

2017-02-28 Thread Su Yue
Add an arg 'ignore_existed' to btrfs_add_link. If ignore_existed=1, continue to add while relative dir index/item or inode ref is already existed. This patch is for further repair. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 6 +++--- convert/main.c | 2 +- c

[PATCH v3 3/3] btrfs-progs: fsck-tests/016: lowmem mode check for images

2017-01-11 Thread Su Yue
Since lowmem mode can repair inode nbytes error now, modify this test case to allow lowmem mode repair. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- v3: add this patch. --- tests/fsck-tests/016-wrong-inode-nbytes/test.sh | 33 + 1 file changed, 33 inse

[PATCH v3 1/3] btrfs-progs: cmds-check.c: supports inode nbytes fix in lowmem

2017-01-11 Thread Su Yue
Added 'repair_inode_item' which dispatches functions such as 'repair_inode__nbytes_lowmem' to correct errors and 'struct inode_item_fix_info' to store correct values and errors. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- v2: reassign err to info.err after repaired in process_one_l

[PATCH v3 2/3] btrfs-progs: cmds-check.c: supports inode isize fix in lowmem

2017-01-11 Thread Su Yue
Add a function 'repair_inode_isize' to support inode isize repair. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- v2: none v3: none --- cmds-check.c | 49 - 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/cmds-check.c

[PATH v2 2/2] btrfs-progs: cmds-check.c: supports inode isize fix in lowmem

2017-01-11 Thread Su Yue
Add a function 'repair_inode_isize' to support inode isize repair. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 49 - 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/cmds-check.c b/cmds-check.c index d

[PATH v2 1/2] btrfs-progs: cmds-check.c: supports inode nbytes fix in lowmem

2017-01-11 Thread Su Yue
Added 'repair_inode_item' which dispatches functions such as 'repair_inode__nbytes_lowmem' to correct errors and 'struct inode_item_fix_info' to store correct values and errors. v2: reassign err to info.err in process_one_leaf. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> ---

[PATCH 1/2] fstests: btrfs/104: Redirect mkfs output to avoid false alert

2016-12-29 Thread Su Yue
btrfs/104 doesn't redirect mkfs output correctly, which leads to false alert. Fix it. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- tests/btrfs/104 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/btrfs/104 b/tests/btrfs/104 index e6a6d3b..c8be4dd

[PATCH 2/2] fstests: btrfs/006: Fix false alert due to output change

2016-12-29 Thread Su Yue
Btrfs-progs v4.9 changed "device status" output by adding one more space, which differs from golden output. Fix it by introducing new filter to convert multi space into one. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- common/filter | 6 ++ tests/bt

[PATCH v2] fstests: btrfs/006: Fix false alert due to output change

2017-01-02 Thread Su Yue
Btrfs-progs v4.9 changed "device status" output by adding one more space, which differs from golden output. Fix it by using filter '_filter_spaces' to convert multi space into one. --- v2: Changed the '_filter_spaces' to match both Tab and Space and tested all related tests. --- common/filter

[PATCH 2/2] btrfs-progs: cmds-check.c: supports inode isize fix in lowmem

2017-01-08 Thread Su Yue
Add a function 'repair_inode_isize' to support inode isize repair. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 49 - 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/cmds-check.c b/cmds-check.c index 5

[PATCH 1/2] btrfs-progs: cmds-check.c: supports inode nbytes fix in lowmem

2017-01-08 Thread Su Yue
Added 'repair_inode_item' which dispatches functions such as 'repair_inode__nbytes_lowmem' to correct errors and 'struct inode_item_fix_info' to store correct values and errors. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c

Re: [PATCH 00/20] Enable lowmem repair for fs/subvolume tree

2017-03-30 Thread Su Yue
On 03/31/2017 12:44 AM, David Sterba wrote: On Wed, Mar 01, 2017 at 11:13:43AM +0800, Su Yue wrote: It can be feched from my github: https://github.com/Damenly/btrfs-progs.git lowmem_repair This patchset can repair errors found in fs tree in lowmem mode. This patchset request includes: 1

[PATCH 1/5] btrfs-progs: check: inode nbytes fix in lowmem

2017-04-10 Thread Su Yue
After checking one inode item, we should get the actual nbytes of the inode item. Introduce function 'repair_inode_nbytes_lowmem' to set nbytes in struct btrfs_inode_item to the actual nbytes. After call of the function, the wrong nbytes should have been corrected. Signed-off-by: Su Yue <su

[PATCH 2/5] btrfs-progs: check: dir isize fix in lowmem

2017-04-10 Thread Su Yue
After traversal of whole directory, we should get the actual isize. Introduce function 'repair_dir_isize_lowmem' to set isize in the directory inode item to actual size. After call of the function, the wrong dir isize should have been corrected. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.

[PATCH 4/5] btrfs-progs: fsck-check: Allow fsck check test to repair in lowmem mode for certain test cases

2017-04-10 Thread Su Yue
From: Qu Wenruo Since lowmem mode can repair certain corruptions (mostly in fs tree), insert a beacon into each fsck test cases to allow some of them be tested for lowmem mode. With this patch, fsck option override will check the beacon file ".lowmem_repairbale" in the

[PATCH 3/5] btrfs-progs: check: enable lowmem repair

2017-04-10 Thread Su Yue
Enable btrfsck option '--repair' with option '--mode=lowmem'. Now lowmem mode only repairs wrong nbytes, dir isize. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index 6a

[PATCH 0/5] btrfs-progs: check: simple errors repair in lowmem

2017-04-10 Thread Su Yue
cases Su Yue (4): btrfs-progs: check: inode nbytes fix in lowmem btrfs-progs: check: dir isize fix in lowmem btrfs-progs: check: enable lowmem repair btrfs-progs: fsck-check: test cases for nbytes and dir isize cmds-check.c | 149

[PATCH 5/5] btrfs-progs: fsck-check: test cases for nbytes and dir isize

2017-04-10 Thread Su Yue
Create test case '026-wrong-dir-inode-isize'. Create becon files '.lowmem_repairable' under tests/fsck-test/016 and 026. Now 'make test-fsck' will test lowmem repairable test cases if TEST_ENABLE_OVERRIDE=true. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- .../fsck-tests/016-wrong

[PATCH 18/20] btrfs-progs: cmds-check.c: repair nlinks lowmem

2017-02-28 Thread Su Yue
Introduce 'repair_inode_nlinks_lowmem'. If ref is 0, move the inode to "lost + found". Set inode item's nlink to ref_count. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 233 +-- 1 file changed, 179 i

[PATCH 15/20] btrfs-progs: cmds-check.c: introduce repair_ternary_lowmem

2017-02-28 Thread Su Yue
Introduce 'repair_ternary_lowmem' to repair error while checking dir_item/index, inode_ref by the rule: 1. If two of three is missing or mismatched, delete the existed one. 2. If one of three is missing or mismatched, add the missing one. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> ---

[PATCH 01/20] btrfs-progs: cmds-check.c: supports inode nbytes fix in lowmem

2017-02-28 Thread Su Yue
Add a function 'repair_inode_nbytes_lowmem' to correct inode item nbytes error in lowmem mode. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 82 +++- 1 file changed, 76 insertions(+), 6 deletions(-) diff --git

[PATCH 02/20] btrfs-progs: cmds-check.c: supports dir isize fix in lowmem

2017-02-28 Thread Su Yue
Add a function 'repair_dir_isize_lowmem' to support dir isize repair in lowmem mode. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 69 +--- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/cmds-che

[PATCH 17/20] btrfs-progs: cmds-check.c: repair inode ref

2017-02-28 Thread Su Yue
Call repair_ternary_lowmem while checking inode ref. Introduce 'repair_dir_item' calls above function to repair dir_item. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 29 +++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git

[PATCH 06/20] btrfs-progs: cmds-check.c: change find_dir_index/item

2017-02-28 Thread Su Yue
For further lowmem_repair, introduce 'find_dir_index' to get the index by other inode item information. Remove 'check_dir_item' error msg print. Adjust 'find_dir_item' args and remove err msg print. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c

[PATCH 16/20] btrfs-progs: cmds-check.c: Introduce repair_dir_item

2017-02-28 Thread Su Yue
Introduce 'repair_dir_item' to repair dir item/index missing/mismatch and relative inode item missing while checking. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 78 1 file changed, 78 insertions(+) diff

[PATCH 20/20] btrfs-progs: fsck-check: Allow fsck check test to repair in lowmem mode for certain test cases

2017-02-28 Thread Su Yue
From: Qu Wenruo Since lowmem mode can repair certain corruptions (mostly in fs tree), insert a beacon into each fsck test cases to allow some of them be tested for lowmem mode. With this patch, fsck option override will check the beacon file ".lowmem_repairbale" in the

[PATCH 08/20] btrfs-progs: cmds-check.c: print_dir_item_err

2017-02-28 Thread Su Yue
Introduce 'print_dir_item_err' to print error msg while checking dir_item/dir_index. 'check_dir_item' now checks relative dir item and calls 'print_dir_itm_err" to print error msg. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-ch

[PATCH 00/20] Enable lowmem repair for fs/subvolume tree

2017-02-28 Thread Su Yue
mode. Qu Wenruo (1): btrfs-progs: fsck-check: Allow fsck check test to repair in lowmem mode for certain test cases Su Yue (19): btrfs-progs: cmds-check.c: supports inode nbytes fix in lowmem btrfs-progs: cmds-check.c: supports dir isize fix in lowmem btrfs-progs: cmds-check.c: inode

[PATCH 09/20] btrfs-progs: cmds-check.c: introduce count_dir_isize

2017-02-28 Thread Su Yue
Introduce 'count_dir_isize' to get dir isize. This function is called only under lowmme repair mode. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 95 ++-- 1 file changed, 92 insertions(+), 3 deletions(-) diff

[PATCH 19/20] btrfs-progs: cmds-check.c: add punch_extent_hole

2017-02-28 Thread Su Yue
Introduce 'punch_extent_hole' to punch holes while repair file extent. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 51 +-- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/cmds-check.c b/cmds-check.c

[PATCH 14/20] btrfs-progs: cmds-check.c: repair_fs_first_inode

2017-02-28 Thread Su Yue
Introduce 'repair_fs_first_inode' to repair first inode errors. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 69 1 file changed, 69 insertions(+) diff --git a/cmds-check.c b/cmds-check.c index 6dafbd7d..85

[PATCH 05/20] btrfs-progs: cmds-check.c: modify check_fs_first_inode

2017-02-28 Thread Su Yue
Modify check_fs_first_inode to check firt_inode inode item and inode ref. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 57 ++--- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/cmds-check.c b/cmds-c

[PATCH 1/3] btrfs-progs: check: verify name in dir_item for original mode

2017-07-14 Thread Su Yue
t; matches with 54846528, while hash of "deprecated.sxt" should be 2008317993. Reported-by: Filippe LeMarchand <gasinv...@gmail.com> Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 8 1 file changed, 8 insertions(+) diff --git a/cmds-check.c b/cmds-

[PATCH 3/3] btrfs-progs: fsck-test: case for corrupted dir item name

2017-07-14 Thread Su Yue
In this test case, all name in dir_item, dir_index, inode_ref are corrupted to another one. btrfs check should report errors about the corrupted dir_item but btrfs can't repair the case now. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- .../fsck-tests/026-bad-dir-ite

[PATCH 2/3] btrfs-progs: check: verify dir item name and hash in lowmem mode

2017-07-14 Thread Su Yue
Although lowmem mode can detect name and hash mismatch in dir_item, it's done by checking inode_ref to expose such problem. This patch will enhance dir_item check, by also comparing name and hash when checking dir_items. Reported-by: Filippe LeMarchand <gasinv...@gmail.com> Signed-off-by:

[PATCH] btrfs-progs: check: check tree blocks using walking tree down and up

2017-07-27 Thread Su Yue
to be same as fs tree which calls walk_down_tree_v2() and walk_up_tree_v2() is easy for further repair. And now check_***_items() is with btrfs_path. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 325 +-- 1 file c

[no subject]

2017-07-27 Thread Su Yue
subscribe linux-btrfs -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html

Re: [PATCH v2] btrfs: fix validation of XATTR_ITEM dir items

2017-07-03 Thread Su Yue
Thanks a lot. I'm sorry for that I hadn't noticed those emails during the vacation. On 06/30/2017 02:20 AM, David Sterba wrote: The XATTR_ITEM is a type of a directory item so we use the common validator helper. Unlike other dir items, it can have data. The way the name len validation is

Re: [PATCH 0/5] btrfs-progs: check: simple errors repair in lowmem

2017-05-17 Thread Su Yue
Hi This patchset was sent a month ago. Since it's a start of lowmem repair patches, I hope to get some opinions about it. Thanks Su Yue On 04/11/2017 11:26 AM, Su Yue wrote: The series include following contents: 1) Repair wrong nbytes of file inode item. After traversal

[PATCH] btrfs: tree-log.c: Wrong printk information about namelen

2017-05-23 Thread Su Yue
In verify_dir_item, it wants to printk name_len of dir_item but printk data_len acutally. Fix it by calling btrfs_dir_name_len instead of btrfs_dir_data_len. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/dir-item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH 2/3] btrfs: check namelen with boundary in verify dir_item

2017-05-24 Thread Su Yue
namelen with item boundary by calling 'btrfs_check_namelen'. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/ctree.h| 2 +- fs/btrfs/dir-item.c | 13 - fs/btrfs/inode.c| 2 +- fs/btrfs/tree-log.c | 4 ++-- fs/btrfs/xattr.c| 2 +- 5 files chang

[PATCH 1/3] btrfs: Introduce btrfs_check_namelen to avoid reading beyond boundary

2017-05-24 Thread Su Yue
compares arg @namelen with boundary then returns 'proper' namelen. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/ctree.h| 2 ++ fs/btrfs/dir-item.c | 22 ++ 2 files changed, 24 insertions(+) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h

[PATCH 3/3] btrfs: check namelen before read/memcmp_extent_buffer

2017-05-24 Thread Su Yue
ise, call 'check_btrfs_namelen' to get 'proper' namelen. If the returned value is not equal to original namelen, returns with error. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/dir-item.c | 5 ++-- fs/btrfs/export.c | 7 + fs/btrfs/inode-item.c | 11 +++-

[PATCH v2 1/5] btrfs-progs: check: inode nbytes fix in lowmem

2017-05-25 Thread Su Yue
After checking one inode item, we should get the actual nbytes of the inode item. Introduce function 'repair_inode_nbytes_lowmem' to set nbytes in struct btrfs_inode_item to the actual nbytes. After call of the function, the wrong nbytes should have been corrected. Signed-off-by: Su Yue <su

[PATCH v2 0/5] btrfs-progs: check: simple errors repair in lowmem

2017-05-25 Thread Su Yue
to repair in lowmem mode for certain test cases Su Yue (4): btrfs-progs: check: inode nbytes fix in lowmem btrfs-progs: check: dir isize fix in lowmem btrfs-progs: check: enable lowmem repair btrfs-progs: fsck-check: test cases for nbytes and dir isize cmds-check.c

[PATCH v2 4/5] btrfs-progs: fsck-check: Allow fsck check test to repair in lowmem mode for certain test cases

2017-05-25 Thread Su Yue
From: Qu Wenruo Since lowmem mode can repair certain corruptions (mostly in fs tree), insert a beacon into each fsck test cases to allow some of them be tested for lowmem mode. With this patch, fsck option override will check the beacon file ".lowmem_repairbale" in the

[PATCH v2 5/5] btrfs-progs: fsck-check: test cases for nbytes and dir isize

2017-05-25 Thread Su Yue
Create test case '026-wrong-dir-inode-isize'. Create becon files '.lowmem_repairable' under tests/fsck-test/016 and 026. Now 'make test-fsck' will test lowmem repairable test cases if TEST_ENABLE_OVERRIDE=true. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- .../fsck-tests/016-wrong

[PATCH v2 3/5] btrfs-progs: check: enable lowmem repair

2017-05-25 Thread Su Yue
Enable btrfsck option '--repair' with option '--mode=lowmem'. Now lowmem mode only repairs wrong nbytes, dir isize. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index cf

[PATCH v2 2/5] btrfs-progs: check: dir isize fix in lowmem

2017-05-25 Thread Su Yue
After traversal of whole directory, we should get the actual isize. Introduce function 'repair_dir_isize_lowmem' to set isize in the directory inode item to actual size. After call of the function, the wrong dir isize should have been corrected. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.

Re: [PATCH 3/3] btrfs: check namelen before read/memcmp_extent_buffer

2017-05-30 Thread Su Yue
On 05/29/2017 11:43 PM, David Sterba wrote: This patch adds the name length verification to many places and in some of them it looks unnecessary, as the directory item passes sanity checks already. The verification should always happen when we read the input, ie from disk, after search_slot

Re: [PATCH v2 1/9] btrfs: Introduce btrfs_is_namelen_valid to avoid reading beyond boundary

2017-06-01 Thread Su Yue
On 06/01/2017 05:44 PM, Nikolay Borisov wrote: On 1.06.2017 11:57, Su Yue wrote: Introduce function btrfs_is_namelen_valid. The function compares arg @namelen with item boundary then returns value represents namelen is valid or not. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.

[PATCH v2 4/9] btrfs: Verify dir_item in 'replay_xattr_deletes'

2017-06-01 Thread Su Yue
Call 'verify_dir_item' to check namelen in 'replay_xattr_deletes' in avoid of read out of boundary. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/tree-log.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index 7d9885

[PATCH v2 6/9] btrfs: Check name before read in 'iterate_dir_item'

2017-06-01 Thread Su Yue
Since 'iterate_dir_item' checks namelen in its way, use 'btrfs_is_namelen_valid' not 'verify_dir_item'. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/send.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index fc496a6f842a..caf96a

[PATCH v2 9/9] btrfs: Verify dir_item 'in iterate_object_props'

2017-06-01 Thread Su Yue
Call 'Verify dir_item' before memcmp_extent_buffer. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/props.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c index d6cb155ef7a1..4b23ae5d0e5c 100644 --- a/fs/btrfs/props.c +++ b/fs

[PATCH v2 7/9] btrfs: Check namelen before read in 'btrfs_get_name'

2017-06-01 Thread Su Yue
Call 'btrfs_is_namelen_valid' in 'btrfs_get_name'. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/export.c | 5 + 1 file changed, 5 insertions(+) diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c index 87144c9f9593..213e971e8dcf 100644 --- a/fs/btrfs/export.c +++ b/fs

[PATCH v2 5/9] btrfs: Check namelen in 'btrfs_check_ref_name_override'

2017-06-01 Thread Su Yue
Call 'btrfs_is_namelen_valid' before reading name. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/tree-log.c | 5 + 1 file changed, 5 insertions(+) diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c index ae51144571e2..fdab0f021197 100644 --- a/fs/btrfs/tree-log.c ++

[PATCH v2 2/9] btrfs: Check namelen with boundary in verify dir_item

2017-06-01 Thread Su Yue
and check namelen with item boundary by calling 'btrfs_is_namelen_valid'. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/ctree.h| 2 +- fs/btrfs/dir-item.c | 10 +- fs/btrfs/inode.c| 2 +- fs/btrfs/tree-log.c | 4 ++-- fs/btrfs/xattr.c| 2 +- 5 fi

[PATCH v2 1/9] btrfs: Introduce btrfs_is_namelen_valid to avoid reading beyond boundary

2017-06-01 Thread Su Yue
Introduce function btrfs_is_namelen_valid. The function compares arg @namelen with item boundary then returns value represents namelen is valid or not. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/ctree.h| 2 ++ fs/btrfs/dir-item.

[PATCH v2 0/9] btrfs: check namelen before read name

2017-06-01 Thread Su Yue
' to 'btrfs_is_namelen_valid'. 2.Split patches according call graph. Su Yue (9): btrfs: Introduce btrfs_is_namelen_valid to avoid reading beyond boundary btrfs: Check namelen with boundary in verify dir_item btrfs: Check name len on add_inode_ref call path btrfs: Verify dir_item

[PATCH v2 3/9] btrfs: Check name len on add_inode_ref call path

2017-06-01 Thread Su Yue
-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/dir-item.c | 4 ++-- fs/btrfs/tree-log.c | 27 ++- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index f9d1ca76ca04..38dc5176cc5b 100644 --- a/fs/btrfs/dir-

[PATCH v2 8/9] btrfs: Check namelen before in 'btrfs_del_root_ref'

2017-06-01 Thread Su Yue
Call btrfs_is_namelen_valid before memcmp. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/root-tree.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c index 7d6bc308bf43..7a5450600723 100644 --- a/fs/btrfs/root-tree.c ++

[PATCH v3 3/9] btrfs: Check name_len on add_inode_ref call path

2017-06-06 Thread Su Yue
-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/dir-item.c | 4 ++-- fs/btrfs/tree-log.c | 27 ++- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c index 806b9fe0178a..dc42066cbaeb 100644 --- a/fs/btrfs/dir-

[PATCH v3 6/9] btrfs: Check name_len before read in iterate_dir_item

2017-06-06 Thread Su Yue
Since 'iterate_dir_item' checks name_len in its way, so use 'btrfs_is_name_len_valid' not 'verify_dir_item' to make more strict name_len check. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/send.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/fs/btrfs/send.c b/fs

[PATCH v3 0/9] btrfs: check name_len before read name

2017-06-06 Thread Su Yue
' in function and changelog. Su Yue (9): btrfs: Introduce btrfs_is_name_len_valid to avoid reading beyond boundary btrfs: Check name_len with boundary in verify dir_item btrfs: Check name_len on add_inode_ref call path btrfs: Verify dir_item in replay_xattr_deletes btrfs: Check name_len

Re: [PATCH v3 0/9] btrfs: check name_len before read name

2017-06-16 Thread Su Yue
On 06/15/2017 11:57 PM, David Sterba wrote: On Tue, Jun 06, 2017 at 05:56:59PM +0800, Su Yue wrote: When reading out name from inode_ref, dir_item, it's possible that corrupted name_len leads to read beyond boundary. Since there are already patches for btrfs-progs, this patchset is for btrfs

[PATCH] btrfs-progs: check: Fix heap use after free.

2017-05-02 Thread Su Yue
iterating over backrefs. So let it continue to next step after free can fix it. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmds-check.c b/cmds-check.c index 5cc84690..c910e520 100644 --- a/cmds-check.c +++

[PATCH] btrfs-progs: check: Fix heap use after free.

2017-05-02 Thread Su Yue
after free can fix it. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmds-check.c b/cmds-check.c index 897b1587..e52fbb84 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -2666,6 +2666,7 @

[PATCH v3 2/9] btrfs: Check name_len with boundary in verify dir_item

2017-06-06 Thread Su Yue
ter @slot and check name_len with item boundary by calling 'btrfs_is_name_len_valid'. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/ctree.h| 2 +- fs/btrfs/dir-item.c | 10 +- fs/btrfs/inode.c| 2 +- fs/btrfs/tree-log.c | 4 ++-- fs/btrfs/xattr.c| 2 +- 5 fi

[PATCH v3 9/9] btrfs: Verify dir_item in iterate_object_props

2017-06-06 Thread Su Yue
Call 'Verify dir_item' before 'memcmp_extent_buffer' reading name from dir_item. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/props.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/fs/btrfs/props.c b/fs/btrfs/props.c index d6cb155ef7a1..4b23ae5d0e5c 100644 --

[PATCH v3 1/9] btrfs: Introduce btrfs_is_name_len_valid to avoid reading beyond boundary

2017-06-06 Thread Su Yue
Introduce function btrfs_is_name_len_valid. The function compares arg @name_len with item boundary then returns value represents name_len is valid or not. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/ctree.h| 2 ++ fs/btrfs/dir-item.

[PATCH v3 8/9] btrfs: Check name_len before in btrfs_del_root_ref

2017-06-06 Thread Su Yue
'btrfs_del_root_ref' does search_slot and reads name from root_ref. Call 'btrfs_is_name_len_valid' before memcmp. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/root-tree.c | 7 +++ 1 file changed, 7 insertions(+) diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c

[PATCH v3 4/9] btrfs: Verify dir_item in replay_xattr_deletes

2017-06-06 Thread Su Yue
'replay_xattr_deletes' calls 'btrfs_search_slot' to get buffer and reads name. Call 'verify_dir_item' to check name_len in 'replay_xattr_deletes' in avoid of read out of boundary. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/tree-log.c | 7 +++ 1 file changed, 7 inse

[PATCH v3 5/9] btrfs: Check name_len in btrfs_check_ref_name_override

2017-06-06 Thread Su Yue
In 'btrfs_log_inode', 'btrfs_search_forward' gets the buffer and then 'btrfs_check_ref_name_override' will read name from inode_ref/inode_extref for the first time. Call 'btrfs_is_name_len_valid' before reading name. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/tree-log

[PATCH v3 7/9] btrfs: Check name_len before read in btrfs_get_name

2017-06-06 Thread Su Yue
In 'btrfs_get_name', it does 'btrfs_search_slot' and reads name from inode_ref/root_ref. Call btrfs_is_name_len_valid in btrfs_get_name. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- fs/btrfs/export.c | 5 + 1 file changed, 5 insertions(+) diff --git a/fs/btrfs/export.c b/fs

[PATCH] btrfs-progs: check: check invalid extent_inline_ref type in lowmem

2017-09-19 Thread Su Yue
(_start+0x2a)[0x55fabc267e7a] [1]5188 abort (core dumped) btrfs check --mode=lowmem /tmp/data_small Fix it by checking type before obtaining inline_ref size. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 9 + 1 file changed, 9 insertions(+) diff --git

Re: [PATCH] btrfs-progs: check: check invalid extent_inline_ref type in lowmem

2017-09-19 Thread Su Yue
On 09/19/2017 04:48 PM, Qu Wenruo wrote: On 2017年09月19日 16:32, Su Yue wrote: Lowmem check does not skip invalid type in extent_inline_ref then calls btrfs_extent_inline_ref_size(type) which causes crash. Example: $ ./btrfs-corrupt-block -e -l 20971520 /tmp/data_small corrupting extent

Re: [PATCH 1/5] btrfs-progs: check: return value of check_extent_refs()

2017-10-05 Thread Su Yue
On 10/06/2017 01:46 AM, David Sterba wrote: On Wed, Sep 27, 2017 at 02:34:36PM +0800, Su Yue wrote: In original check mode(without option "--repair"), check_extent_refs() always returns 0. Add a variable @error to record status while checking extents. At the end of check_extent_r

Re: [PATCH 1/5] btrfs-progs: check: return value of check_extent_refs()

2017-10-05 Thread Su Yue
On 10/06/2017 01:46 AM, David Sterba wrote: On Wed, Sep 27, 2017 at 02:34:36PM +0800, Su Yue wrote: In original check mode(without option "--repair"), check_extent_refs() always returns 0. Add a variable @error to record status while checking extents. At the end of check_extent_r

[PATCH v2] btrfs-progs: print: Check on num_stripes in print_chunk

2017-09-06 Thread Su Yue
From: Zhang Yu In fuzz-tests/004-simple-dump-tree: Since there is one wrong item(DATA_RELOC_TREE CHUNK_ITEM 0) in root tree. It fails as follow: ctree.h:317: btrfs_chunk_item_size: BUG_ON `num_stripes == 0` triggered, value 1

question: behavior of original check

2017-09-25 Thread Su Yue
Hi During writing patches about check, I found something confusing about btrfs-progs original check. Setup: Version: Btrfs progs v4.13.1 $ make TEST=006\* test-fsck [TEST] fsck-tests.sh [TEST/fsck] 006-bad-root-items $ cat tests/fsck-tests-results.txt | tail -n 25 ###

Re: [PATCH] btrfs-progs: check: check invalid extent_inline_ref type in lowmem

2017-09-25 Thread Su Yue
On 09/24/2017 10:17 PM, Nikolay Borisov wrote: On 19.09.2017 13:00, Qu Wenruo wrote: On 2017年09月19日 17:48, Su Yue wrote: On 09/19/2017 04:48 PM, Qu Wenruo wrote: On 2017年09月19日 16:32, Su Yue wrote: Lowmem check does not skip invalid type in extent_inline_ref then calls

[PATCH] btrfs-progs: tests: arg override in command line

2017-09-28 Thread Su Yue
by making _skip_spec() always be defined in common.local. Reported-by: David Sterba <dste...@suse.cz> Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- tests/common | 8 ++-- tests/common.local | 11 +-- 2 files changed, 7 insertions(+), 12 deletions(-) diff

[PATCH 4/5] btrfs-progs: check: check extent_inline_ref in lowmem

2017-09-27 Thread Su Yue
Solve it by introducing check_extent_inline_ref() to check type. If the checker returns a nonzero value, we should not check the corrupted extent item anymore. Suggested-by: Qu Wenruo <quwenruo.bt...@gmx.com> Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-

[PATCH 1/5] btrfs-progs: check: return value of check_extent_refs()

2017-09-27 Thread Su Yue
pace waste bytes: 109471 file data blocks allocated: 0 referenced 0 Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmds-check.c b/cmds-check.c index 8aa136df..93b47194 100644 --- a/cmds-check.c ++

[PATCH 0/5] btrfs-progs: check: original and lowmem mode fix

2017-09-27 Thread Su Yue
not be modified if repair_root_items() succeeded in original repair. The late two patches are about invalid type in extent_inline_ref. Only original mode applied 001-003 patches can handle the case in the last patch. So I gather those 5 patches together. Su Yue (5): btrfs-progs: check: return

[PATCH 3/5] btrfs-progs: check: error or return value of repair_root_items()

2017-09-27 Thread Su Yue
Return value of repair_root_items(): <0 on error =0 does nothing >0 if repair is enable, N roots is repaired; else N roots is corrupted. In the repair mode, there should be no error if return value is bigger than 0. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check

[PATCH 5/5] btrfs-progs: fsck-tests: 027/bad_extent_inline_ref_type

2017-09-27 Thread Su Yue
This case is for avoiding crash in lowmem check mode. Field type of extent_inline_ref in an extent is corrupted. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- .../bad-extent-inline-ref-type.raw.xz | Bin 0 -> 17144 bytes 1 file changed, 0 insertions(+), 0

[PATCH 2/5] btrfs-progs: check: call repair_root_items() before any repair

2017-09-27 Thread Su Yue
r_root_items() if do init_extent_tree. Then test-fsck/013 works well. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 43 +++ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index 93b47194..3e2f9faa 10064

[PATCH v2 2/5] btrfs-progs: check: call repair_root_items() before any repair

2017-09-27 Thread Su Yue
d not call repair_root_items() if do init_extent_tree. Then test-fsck/013 works well. --- Changelog: v2: Correct commit number reported. (Suggested by Qu Wenruo) Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 43 +++ 1

[PATCH v3 2/5] btrfs-progs: check: call repair_root_items() before any repair

2017-09-27 Thread Su Yue
is nonzero. Now put repair_root_items() before do_check_chunks_and_extents() and not call repair_root_items() if do init_extent_tree. Then test-fsck/013 works well. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- Changelog: v2: Correct commit number reported. (Suggested by Qu Wenruo) v

Re: btrfs check lowmem vs original

2017-11-12 Thread Su Yue
Hi On 11/11/2017 07:16 AM, Chris Murphy wrote: Resurrecting this old thread because I'm still seeing these errors. On Thu, Mar 16, 2017 at 6:54 PM, Qu Wenruo wrote: At 03/17/2017 07:22 AM, Chris Murphy wrote: With kernel 4.10.3, and btrfs-progs 4.10, I'm still

[PATCH 0/3] btrfs-progs: check: fix up bugs of lowmem mode

2017-11-26 Thread Su Yue
. 2) Repair in lowmem mode always reports error about block group accounting. The third patch excludes extents of all treeblocks and extent items to avoid wrong extent overwrite. Then repair in lowmem mode should work again. Su Yue (3): btrfs-progs: check: release path in repair_extent_data_item

[PATCH 1/3] btrfs-progs: check: release path in repair_extent_data_item()

2017-11-26 Thread Su Yue
In repair_extent_data_item(), path is not be released if some errors occurs which causes extent buffer leak. So release path in end of the function. Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds-c

[PATCH 2/3] btrfs-progs: check: record returned errors after walk_down_tree_v2()

2017-11-26 Thread Su Yue
nonzero value even the filesystem is fine after repair. So let @err contains bits after walk_down_tree_v2(). Signed-off-by: Su Yue <suy.f...@cn.fujitsu.com> --- cmds-check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmds-check.c b/cmds-check.c index 3a72f8

  1   2   3   4   5   >