tree-checker read time error, unable to mount

2021-04-12 Thread Henrik Nordström
We have an btrfs filesystem which have crashed and fails to mount. The filesystem is on an extrenal SSD and it is quite possible it got disconnected badly or had an unclean shutdown due to suspend issues. [ 447.321770] BTRFS critical (device sdc3): corrupt leaf: root=256 block=2036170752 slot=1 i

Re: [PATCH v2 2/2] btrfs: tree-checker: check if chunk item end oveflows

2021-01-04 Thread Anand Jain
tree checker then the image will be rejected to be mounted. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=208929 Signed-off-by: Su Yue ---   fs/btrfs/tree-checker.c | 7 +++   1 file changed, 7 insertions(+) diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c index

Re: [PATCH v2 2/2] btrfs: tree-checker: check if chunk item end oveflows

2021-01-04 Thread David Sterba
On Sun, Jan 03, 2021 at 05:28:04PM +0800, Su Yue wrote: > while mounting the poc image user-provided, kernel panics due to the > invalid chunk item whose end is less than start. > > [ 66.387422] loop: module loaded > [ 66.

Re: [PATCH v2 2/2] btrfs: tree-checker: check if chunk item end oveflows

2021-01-04 Thread Su Yue
ogical start 37748736 and length 18446744073701163008. The calculated end 29360127 is overflowed obviously. -EEXIST was caught by insert_state() because of the duplicate end and extent_io_tree_panic() was called. Add overflow check of chunk item end in tree checker then the image will be reject

Re: [PATCH v2 2/2] btrfs: tree-checker: check if chunk item end oveflows

2021-01-04 Thread Anand Jain
obviously. -EEXIST was caught by insert_state() because of the duplicate end and extent_io_tree_panic() was called. Add overflow check of chunk item end in tree checker then the image will be rejected to be mounted. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=208929 Signed-off-by: Su Yue

[PATCH v2 2/2] btrfs: tree-checker: check if chunk item end oveflows

2021-01-03 Thread Su Yue
te() because of the duplicate end and extent_io_tree_panic() was called. Add overflow check of chunk item end in tree checker then the image will be rejected to be mounted. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=208929 Signed-off-by: Su Yue --- fs/btrfs/tree-checker.c | 7

Re: tree-checker: corrupt leaf: invalid mode: has 00 expect valid S_IF* bit(s)

2019-10-18 Thread Qu Wenruo
valid S_IF* bit(s) Tree-checker detects an invalid inode mode bit. From previous report, it should be caused by older kernel around 2014. > [26876.491171] BTRFS error (device dm-0): block=739531833344 read time > tree block corruption detected > > It is triggered whenever stat() i

tree-checker: corrupt leaf: invalid mode: has 00 expect valid S_IF* bit(s)

2019-10-18 Thread ‍小太
: Input/output error ls: cannot access './/2018-05-31.201834+1000AEST.html': Input/output error ls: cannot access './/2018-05-31.222947+1000AEST.html': Input/output error https://btrfs.wiki.kernel.org/index.php/Tree-checker#How_to_handle_such_error tells me to post on this mailing li

Re: [PATCH 0/3] btrfs: tree-checker: False alerts fixes for log trees

2019-10-07 Thread David Sterba
On Fri, Oct 04, 2019 at 05:31:30PM +0800, Qu Wenruo wrote: > There is a false alerts of tree-checker when running fstests/btrfs/063 > in a loop. > > The bug is caused by commit 59b0d030fb30 ("btrfs: tree-checker: Try to detect > missing INODE_ITEM"). > For the full err

Re: [PATCH 1/3] btrfs: tree-checker: Fix false alerts on log trees

2019-10-07 Thread David Sterba
On Fri, Oct 04, 2019 at 03:15:51PM +0100, Filipe Manana wrote: > On Fri, Oct 4, 2019 at 11:27 AM Qu Wenruo wrote: > > Reported-by: David Sterba > > Fixes: 59b0d030fb30 ("btrfs: tree-checker: Try to detect missing > > INODE_ITEM") > > So this is bogus, si

Re: [PATCH 1/3] btrfs: tree-checker: Fix false alerts on log trees

2019-10-04 Thread Nikolay Borisov
On 4.10.19 г. 17:13 ч., Filipe Manana wrote: > On Fri, Oct 4, 2019 at 2:54 PM Nikolay Borisov wrote: >> >> >> >> On 4.10.19 г. 12:31 ч., Qu Wenruo wrote: >>> [BUG] >>> When running btrfs/063 in a loop, we got the following random write time >

Re: [PATCH 1/3] btrfs: tree-checker: Fix false alerts on log trees

2019-10-04 Thread Filipe Manana
On Fri, Oct 4, 2019 at 11:27 AM Qu Wenruo wrote: > > [BUG] > When running btrfs/063 in a loop, we got the following random write time > tree checker error: > > BTRFS critical (device dm-4): corrupt leaf: root=18446744073709551610 > block=33095680 slot=2 ino=307 file_offse

Re: [PATCH 1/3] btrfs: tree-checker: Fix false alerts on log trees

2019-10-04 Thread Filipe Manana
On Fri, Oct 4, 2019 at 2:54 PM Nikolay Borisov wrote: > > > > On 4.10.19 г. 12:31 ч., Qu Wenruo wrote: > > [BUG] > > When running btrfs/063 in a loop, we got the following random write time > > tree checker error: > > > > BTRFS critical (device dm-4

Re: [PATCH 1/3] btrfs: tree-checker: Fix false alerts on log trees

2019-10-04 Thread Nikolay Borisov
On 4.10.19 г. 12:31 ч., Qu Wenruo wrote: > [BUG] > When running btrfs/063 in a loop, we got the following random write time > tree checker error: > > BTRFS critical (device dm-4): corrupt leaf: root=18446744073709551610 > block=33095680 slot=2 ino=307 file_offset=0, in

[PATCH 1/3] btrfs: tree-checker: Fix false alerts on log trees

2019-10-04 Thread Qu Wenruo
[BUG] When running btrfs/063 in a loop, we got the following random write time tree checker error: BTRFS critical (device dm-4): corrupt leaf: root=18446744073709551610 block=33095680 slot=2 ino=307 file_offset=0, invalid previous key objectid, have 305 expect 307 BTRFS info (device dm-4

[PATCH 3/3] btrfs: Enhance the error outputting for write time tree checker

2019-10-04 Thread Qu Wenruo
Unlike read time tree checker error, write time error can't be inspected by "btrfs ins dump-tree", so we need extra info to determine what's going wrong. The patch will add the following output for write time tree checker error: - The content of the offending tree block To

[PATCH 2/3] btrfs: tree-checker: Refactor prev_key check for ino into a function

2019-10-04 Thread Qu Wenruo
Refactor the check for prev_key->objectid of the following key types into one function, check_prev_ino(): - EXTENT_DATA - INODE_REF - DIR_INDEX - DIR_ITEM - XATTR_ITEM Despite the refactor, also add the check of prev_key for INODE_REF. Signed-off-by: Qu Wenruo --- fs/btrfs/tree-checker.c | 113

[PATCH 0/3] btrfs: tree-checker: False alerts fixes for log trees

2019-10-04 Thread Qu Wenruo
There is a false alerts of tree-checker when running fstests/btrfs/063 in a loop. The bug is caused by commit 59b0d030fb30 ("btrfs: tree-checker: Try to detect missing INODE_ITEM"). For the full error analyse, please check the first patch. The first patch will give it a quick fix, so t

Re: Tree checker

2019-09-24 Thread Charles Wright
Ok, I'll check it out. I think I'v tracked down all the files with bad "atime" and cleared all the BTRFS errors by cp -r , deleting the originals and moving the copies in . thanks a bunch . Charles Wright On Tue, Sep 24, 2019 at 12:08 AM Chris Murphy wrote: > > On Mon, Sep 23, 2019 at 6:35 PM

Re: Tree checker

2019-09-23 Thread Chris Murphy
On Mon, Sep 23, 2019 at 6:35 PM Charles Wright wrote: > > if I boot the 5.0.0-30 kernel and enter the "dwhelper" directory and > do "dmesg" their is this > > [ 199.522886] ata2.00: exception Emask 0x10 SAct 0x8000 SErr 0x2d0100 > action 0x6 frozen > [ 199.522891] ata2.00: irq_stat 0x0800, in

Re: Tree checker

2019-09-23 Thread Qu Wenruo
xpected range is [0, 80501], but you have a super large generation number. Doesn't that 18446744073709551492 looks strange? It's 0xff84, by somehow we overflow the generation number. And tree-checker is doing its job, although not every user likes what tree-checker is doing

Tree checker

2019-09-23 Thread Charles Wright
ernel Version: 5.0.0-30-generic OS Type: 64-bit Processors: 8 × Intel® Core™ i7-4910MQ CPU @ 2.90GHz Memory: 15.6 GiB of RAM the web page https://btrfs.wiki.kernel.org/index.php/Tree-checker asked to report an error like this hear , so her I am :) any more info or tests you want me to run or pro

Re: [PATCH 2/2] btrfs: tree-checker: Add check for INODE_REF

2019-09-23 Thread David Sterba
On Mon, Aug 26, 2019 at 03:40:39PM +0800, Qu Wenruo wrote: > For INODE_REF we will check: > - Objectid (ino) against previous key > To detect missing INODE_ITEM. > > - No overflow/padding in the data payload > Much like DIR_ITEM, but with less members to check. > > Signed-off-by: Qu Wenruo >

Re: [PATCH 2/2] btrfs: tree-checker: Add check for INODE_REF

2019-09-23 Thread David Sterba
On Mon, Aug 26, 2019 at 07:50:03PM +0800, Qu Wenruo wrote: > > > On 2019/8/26 下午7:45, Nikolay Borisov wrote: > > > > > > On 26.08.19 г. 10:40 ч., Qu Wenruo wrote: > >> For INODE_REF we will check: > >> - Objectid (ino) against previous key > >> To detect missing INODE_ITEM. > >> > >> - No overf

[PATCH AUTOSEL 5.3 201/203] btrfs: tree-checker: Add ROOT_ITEM check

2019-09-22 Thread Sasha Levin
From: Qu Wenruo [ Upstream commit 259ee7754b6793af8bdd77f9ca818bc41cfe9541 ] This patch will introduce ROOT_ITEM check, which includes: - Key->objectid and key->offset check Currently only some easy check, e.g. 0 as rootid is invalid. - Item size check Root item size is fixed. - Generation

[PATCH AUTOSEL 5.2 183/185] btrfs: tree-checker: Add ROOT_ITEM check

2019-09-22 Thread Sasha Levin
From: Qu Wenruo [ Upstream commit 259ee7754b6793af8bdd77f9ca818bc41cfe9541 ] This patch will introduce ROOT_ITEM check, which includes: - Key->objectid and key->offset check Currently only some easy check, e.g. 0 as rootid is invalid. - Item size check Root item size is fixed. - Generation

Re: [PATCH v3 2/2] btrfs: tree-checker: Fix wrong check on max devid

2019-09-10 Thread Anand Jain
On 10/9/19 5:12 PM, WenRuo Qu wrote: On 2019/9/10 下午5:07, Anand Jain wrote: diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c index ccd5706199d7..15d1aa7cef1f 100644 --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c @@ -686,9 +686,7 @@ static void dev_item_err(const

Re: [PATCH v3 2/2] btrfs: tree-checker: Fix wrong check on max devid

2019-09-10 Thread WenRuo Qu
On 2019/9/10 下午5:07, Anand Jain wrote: > > > > >> diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c >> index ccd5706199d7..15d1aa7cef1f 100644 >> --- a/fs/btrfs/tree-checker.c >> +++ b/fs/btrfs/tree-checker.c >> @@ -686,9 +686,7 @@ static void dev_item_err(const struct >> extent_

Re: [PATCH v3 2/2] btrfs: tree-checker: Fix wrong check on max devid

2019-09-10 Thread Anand Jain
diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c index ccd5706199d7..15d1aa7cef1f 100644 --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c @@ -686,9 +686,7 @@ static void dev_item_err(const struct extent_buffer *eb, int slot, static int check_dev_item(struct extent

[PATCH] btrfs: tree-checker: Check item size before reading file extent type

2019-09-02 Thread Qu Wenruo
In check_extent_data_item(), we read file extent type without verifying if the item size is valid. Add such check to ensure the file extent type we read is correct. The check is not as accurate as we need to cover both inline and regular extents, so it only checks if the item size is larger or eq

Re: [PATCH v3 2/2] btrfs: tree-checker: Fix wrong check on max devid

2019-08-27 Thread WenRuo Qu
t;> dev2=$dev_tmp >> done > > Instead of putting the script here, can't it be turned into a fstest to > ensure we don't regress in the future? Sure, already crafting. Thanks, Qu > >> >> [CAUSE] >> Tree-checker uses BTRFS_MAX_DEVS() and

Re: [PATCH v3 2/2] btrfs: tree-checker: Fix wrong check on max devid

2019-08-27 Thread Nikolay Borisov
rfs dev add -f $dev2 $mnt || _fail > btrfs dev del $dev1 $mnt || _fail > dev_tmp=$dev1 > dev1=$dev2 > dev2=$dev_tmp > done Instead of putting the script here, can't it be turned into a fstest to ensure we don't regress in the future? > &

[PATCH v3 2/2] btrfs: tree-checker: Fix wrong check on max devid

2019-08-27 Thread Qu Wenruo
t $dev1 $mnt _fail() { echo "!!! FAILED !!!" exit 1 } for ((i = 0; i < 4096; i++)); do btrfs dev add -f $dev2 $mnt || _fail btrfs dev del $dev1 $mnt || _fail dev_tmp=$dev1 dev1=$dev2 dev2=$dev_tmp done [CAUSE] Tree

Re: [PATCH v2] btrfs: tree-checker: Fix wrong check on max devid

2019-08-27 Thread WenRuo Qu
On 2019/8/28 上午7:26, Anand Jain wrote: > On 27/8/19 10:05 PM, Qu Wenruo wrote: >> Btrfs doesn't reuse devid, thus if we add and delete device in a loop, >> we can increase devid to higher value, triggering tree checker to give a >> false alert. >> >> Furthe

Re: [PATCH v2] btrfs: tree-checker: Fix wrong check on max devid

2019-08-27 Thread Anand Jain
On 27/8/19 10:05 PM, Qu Wenruo wrote: Btrfs doesn't reuse devid, thus if we add and delete device in a loop, we can increase devid to higher value, triggering tree checker to give a false alert. Furthermore, we have dev extent verification already (after tree-checker, at mount time). So ev

[PATCH v2] btrfs: tree-checker: Fix wrong check on max devid

2019-08-27 Thread Qu Wenruo
Btrfs doesn't reuse devid, thus if we add and delete device in a loop, we can increase devid to higher value, triggering tree checker to give a false alert. Furthermore, we have dev extent verification already (after tree-checker, at mount time). So even if user had bitflip on some dev item

Re: [PATCH] btrfs: tree-checker: Fix wrong check on max devid

2019-08-27 Thread Jeff Mahoney
On 8/27/19 9:56 AM, Qu Wenruo wrote: > > > On 2019/8/27 下午9:37, Jeff Mahoney wrote: >> On 8/27/19 9:22 AM, Qu Wenruo wrote: >>> Btrfs doesn't reuse devid, thus if we add and delete device in a loop, >>> we can increase devid to higher value, triggering

Re: [PATCH] btrfs: tree-checker: Fix wrong check on max devid

2019-08-27 Thread Qu Wenruo
On 2019/8/27 下午9:37, Jeff Mahoney wrote: > On 8/27/19 9:22 AM, Qu Wenruo wrote: >> Btrfs doesn't reuse devid, thus if we add and delete device in a loop, >> we can increase devid to higher value, triggering tree checker to give a >> false alert. >> >> But we

Re: [PATCH] btrfs: tree-checker: Fix wrong check on max devid

2019-08-27 Thread Jeff Mahoney
On 8/27/19 9:22 AM, Qu Wenruo wrote: > Btrfs doesn't reuse devid, thus if we add and delete device in a loop, > we can increase devid to higher value, triggering tree checker to give a > false alert. > > But we still don't want to give up the devid check, so here we

[PATCH] btrfs: tree-checker: Fix wrong check on max devid

2019-08-27 Thread Qu Wenruo
Btrfs doesn't reuse devid, thus if we add and delete device in a loop, we can increase devid to higher value, triggering tree checker to give a false alert. But we still don't want to give up the devid check, so here we compromise by setting a larger devid upper limit, 1<<32.

[PATCH] btrfs: tree-checker: Reject unknown tree owner 0

2019-08-26 Thread Qu Wenruo
[BUG] With crafted image, btrfs will panic at btree operations: kernel BUG at fs/btrfs/ctree.c:3894! invalid opcode: [#1] SMP PTI CPU: 0 PID: 1138 Comm: btrfs-transacti Not tainted 5.0.0-rc8+ #9 RIP: 0010:__push_leaf_left+0x6b6/0x6e0 Code: 00 00 48 98 48 8d 04 80 48 8d 74 80 65 e8 42

Re: [PATCH 2/2] btrfs: tree-checker: Add check for INODE_REF

2019-08-26 Thread Qu Wenruo
On 2019/8/26 下午7:45, Nikolay Borisov wrote: > > > On 26.08.19 г. 10:40 ч., Qu Wenruo wrote: >> For INODE_REF we will check: >> - Objectid (ino) against previous key >> To detect missing INODE_ITEM. >> >> - No overflow/padding in the data payload >> Much like DIR_ITEM, but with less members t

Re: [PATCH 1/2] btrfs: tree-checker: Try to detect missing INODE_ITEM

2019-08-26 Thread Nikolay Borisov
On 26.08.19 г. 10:40 ч., Qu Wenruo wrote: > For the following items, key->objectid is inode number: > - DIR_ITEM > - DIR_INDEX > - XATTR_ITEM > - EXTENT_DATA > - INODE_REF > > So in btrfs btree, such items must have its previous item shares the > same objectid, e.g.: > (257 INODE_ITEM 0) > (2

Re: [PATCH 2/2] btrfs: tree-checker: Add check for INODE_REF

2019-08-26 Thread Nikolay Borisov
On 26.08.19 г. 10:40 ч., Qu Wenruo wrote: > For INODE_REF we will check: > - Objectid (ino) against previous key > To detect missing INODE_ITEM. > > - No overflow/padding in the data payload > Much like DIR_ITEM, but with less members to check. > > Signed-off-by: Qu Wenruo > --- > fs/btr

[PATCH 0/2] btrfs: tree-checker: Add checks to detect missing INODE_ITEM

2019-08-26 Thread Qu Wenruo
an cover the INODE_ITEM missing case in tree-checker without much cost, but achieve the check which is normally done by btrfs-check. (I'm already a little concerned about the fact that kernel tree-checker is getting stronger and stronger while btrfs-progs can't fix all problems) Of co

[PATCH 1/2] btrfs: tree-checker: Try to detect missing INODE_ITEM

2019-08-26 Thread Qu Wenruo
For the following items, key->objectid is inode number: - DIR_ITEM - DIR_INDEX - XATTR_ITEM - EXTENT_DATA - INODE_REF So in btrfs btree, such items must have its previous item shares the same objectid, e.g.: (257 INODE_ITEM 0) (257 DIR_INDEX xxx) (257 DIR_ITEM xxx) (258 INODE_ITEM 0) (258 INO

[PATCH 2/2] btrfs: tree-checker: Add check for INODE_REF

2019-08-26 Thread Qu Wenruo
For INODE_REF we will check: - Objectid (ino) against previous key To detect missing INODE_ITEM. - No overflow/padding in the data payload Much like DIR_ITEM, but with less members to check. Signed-off-by: Qu Wenruo --- fs/btrfs/tree-checker.c | 53 +

Re: [PATCH v1.2 0/3] btrfs: tree-checker: Add extent items check

2019-08-22 Thread David Sterba
On Fri, Aug 09, 2019 at 09:24:21AM +0800, Qu Wenruo wrote: > Finally, we are going to add tree-checker support for extent items, > which includes: > - EXTENT_ITEM/METADATA_ITEM > Which futher contains inline backrefs of: > * TREE_BLOCK_REF > * SHARED_BLOCK_REF >

Re: [PATCH v1.2 2/3] btrfs: tree-checker: Add simple keyed refs check

2019-08-22 Thread David Sterba
On Fri, Aug 09, 2019 at 09:24:23AM +0800, Qu Wenruo wrote: > For TREE_BLOCK_REF, SHARED_DATA_REF and SHARED_BLOCK_REF we need to > check: > | TREE_BLOCK_REF | SHARED_BLOCK_REF | SHARED_BLOCK_REF > --++-+-- > key->objectid |

Re: [PATCH v1.2 1/3] btrfs: tree-checker: Add EXTENT_ITEM and METADATA_ITEM check

2019-08-22 Thread David Sterba
On Fri, Aug 09, 2019 at 09:24:22AM +0800, Qu Wenruo wrote: > +static int check_extent_item(struct extent_buffer *leaf, > + struct btrfs_key *key, int slot) > +{ > + struct btrfs_fs_info *fs_info = leaf->fs_info; > + struct btrfs_extent_item *ei; > + bool is_tree

Re: [PATCH v1.1 1/3] btrfs: tree-checker: Add EXTENT_ITEM and METADATA_ITEM check

2019-08-09 Thread David Sterba
On Thu, Aug 08, 2019 at 11:55:37PM +, WenRuo Qu wrote: > > > On 2019/8/8 下午10:54, David Sterba wrote: > > On Wed, Aug 07, 2019 at 10:08:41PM +0800, Qu Wenruo wrote: > >> + > >> +static int check_extent_item(struct extent_buffer *leaf, > >> + struct btrfs_key *key, int sl

[PATCH v1.2 0/3] btrfs: tree-checker: Add extent items check

2019-08-08 Thread Qu Wenruo
Finally, we are going to add tree-checker support for extent items, which includes: - EXTENT_ITEM/METADATA_ITEM Which futher contains inline backrefs of: * TREE_BLOCK_REF * SHARED_BLOCK_REF * EXETNT_DATA_REF * SHARED_DATA_REF - TREE_BLOCK_REF - SHARED_BLOCK_REF - EXTENT_DATA_REF

[PATCH v1.2 2/3] btrfs: tree-checker: Add simple keyed refs check

2019-08-08 Thread Qu Wenruo
For TREE_BLOCK_REF, SHARED_DATA_REF and SHARED_BLOCK_REF we need to check: | TREE_BLOCK_REF | SHARED_BLOCK_REF | SHARED_BLOCK_REF --++-+-- key->objectid |Alignment | Alignment|Alignment key->offset |An

[PATCH v1.2 3/3] btrfs: tree-checker: Add EXTENT_DATA_REF check

2019-08-08 Thread Qu Wenruo
EXTENT_DATA_REF is a little like DIR_ITEM which contains hash in its key->offset. This patch will check the following contents: - Key->objectid Basic alignment check. - Hash Hash of each extent_data_ref item must match key->offset. - Offset Basic alignment check. Signed-off-by: Qu Wenruo

[PATCH v1.2 1/3] btrfs: tree-checker: Add EXTENT_ITEM and METADATA_ITEM check

2019-08-08 Thread Qu Wenruo
This patch introduces the ability to check extent items. This check involves: - key->objectid check Basic alignment check. - key->type check Against btrfs_extent_item::type and SKINNY_METADATA feature. - key->offset alignment check for EXTENT_ITEM - key->offset check for METADATA_ITEM - it

Re: [PATCH v1.1 1/3] btrfs: tree-checker: Add EXTENT_ITEM and METADATA_ITEM check

2019-08-08 Thread WenRuo Qu
On 2019/8/8 下午10:54, David Sterba wrote: > On Wed, Aug 07, 2019 at 10:08:41PM +0800, Qu Wenruo wrote: >> + >> +static int check_extent_item(struct extent_buffer *leaf, >> + struct btrfs_key *key, int slot) >> +{ >> +struct btrfs_fs_info *fs_info = leaf->fs_info; >> +

Re: [PATCH v1.1 3/3] btrfs: tree-checker: Add EXTENT_DATA_REF check

2019-08-08 Thread David Sterba
On Wed, Aug 07, 2019 at 10:08:43PM +0800, Qu Wenruo wrote: > EXTENT_DATA_REF is a little like DIR_ITEM which contains hash in its > key->offset. > > This patch will check the following contents: > - Key->objectid > Basic alignment check. > > - Hash > Hash of each extent_data_ref item must mat

Re: [PATCH v1.1 1/3] btrfs: tree-checker: Add EXTENT_ITEM and METADATA_ITEM check

2019-08-08 Thread David Sterba
On Wed, Aug 07, 2019 at 10:08:41PM +0800, Qu Wenruo wrote: > + > +static int check_extent_item(struct extent_buffer *leaf, > + struct btrfs_key *key, int slot) > +{ > + struct btrfs_fs_info *fs_info = leaf->fs_info; > + struct btrfs_extent_item *ei; > + bool is_

[PATCH v1.1 2/3] btrfs: tree-checker: Add simple keyed refs check

2019-08-07 Thread Qu Wenruo
For TREE_BLOCK_REF, SHARED_DATA_REF and SHARED_BLOCK_REF we need to check: | TREE_BLOCK_REF | SHARED_BLOCK_REF | SHARED_BLOCK_REF --++-+-- key->objectid |Alignment | Alignment|Alignment key->offset |An

[PATCH v1.1 3/3] btrfs: tree-checker: Add EXTENT_DATA_REF check

2019-08-07 Thread Qu Wenruo
EXTENT_DATA_REF is a little like DIR_ITEM which contains hash in its key->offset. This patch will check the following contents: - Key->objectid Basic alignment check. - Hash Hash of each extent_data_ref item must match key->offset. - Offset Basic alignment check. Signed-off-by: Qu Wenruo

[PATCH v1.1 1/3] btrfs: tree-checker: Add EXTENT_ITEM and METADATA_ITEM check

2019-08-07 Thread Qu Wenruo
This patch introduces the ability to check extent items. This check involves: - key->objectid check Basic alignment check. - key->type check Against btrfs_extent_item::type and SKINNY_METADATA feature. - key->offset alignment check for EXTENT_ITEM - key->offset check for METADATA_ITEM - it

[PATCH v1.1 0/3] btrfs: tree-checker: Add extent items check

2019-08-07 Thread Qu Wenruo
Finally, we are going to add tree-checker support for extent items, which includes: - EXTENT_ITEM/METADATA_ITEM Which futher contains inline backrefs of: * TREE_BLOCK_REF * SHARED_BLOCK_REF * EXETNT_DATA_REF * SHARED_DATA_REF - TREE_BLOCK_REF - SHARED_BLOCK_REF - EXTENT_DATA_REF

Re: [PATCH 3/3] btrfs: tree-checker: Add ROOT_ITEM check

2019-07-31 Thread David Sterba
f (btrfs_root_generation_v2(&ri) > > >> + btrfs_super_generation(fs_info->super_copy) + 1) { > >> + generic_err(leaf, slot, > >> + "invalid root v2 generaetion, have %llu expect (0, %llu]", > > > > So (0, %llu] here

Re: [PATCH 1/3] btrfs: tree-checker: Add EXTENT_ITEM and METADATA_ITEM check

2019-07-29 Thread Qu Wenruo
On 2019/7/29 下午9:42, Nikolay Borisov wrote: [...] >> + >> +/* key->offset is tree level for METADATA_ITEM_KEY */ >> +if (key->type == BTRFS_METADATA_ITEM_KEY) { >> +if (key->offset >= BTRFS_MAX_LEVEL) { > > make it a compound statement: > > if key->type && key->offset. The ex

Re: [PATCH 1/3] btrfs: tree-checker: Add EXTENT_ITEM and METADATA_ITEM check

2019-07-29 Thread Nikolay Borisov
On 29.07.19 г. 10:43 ч., Qu Wenruo wrote: > This patch introduces the ability to check extent items. > > This check involves: > - key->objectid check > Basic alignment check. > > - key->type check > Against btrfs_extent_item::type and SKINNY_METADATA feature. > > - key->offset alignment c

[PATCH 3/3] btrfs: tree-checker: Add EXTENT_DATA_REF check

2019-07-29 Thread Qu Wenruo
EXTENT_DATA_REF is a little like DIR_ITEM which contains hash in its key->offset. This patch will check the following contents: - Key->objectid Basic alignment check. - Hash Hash of each extent_data_ref item must match key->offset. - Offset Basic alignment check. Signed-off-by: Qu Wenruo

[PATCH 2/3] btrfs: tree-checker: Add simple keyed refs check

2019-07-29 Thread Qu Wenruo
For TREE_BLOCK_REF, SHARED_DATA_REF and SHARED_BLOCK_REF we need to check: | TREE_BLOCK_REF | SHARED_BLOCK_REF | SHARED_BLOCK_REF --++-+-- key->objectid |Alignment | Alignment|Alignment key->offset |An

[PATCH 1/3] btrfs: tree-checker: Add EXTENT_ITEM and METADATA_ITEM check

2019-07-29 Thread Qu Wenruo
This patch introduces the ability to check extent items. This check involves: - key->objectid check Basic alignment check. - key->type check Against btrfs_extent_item::type and SKINNY_METADATA feature. - key->offset alignment check for EXTENT_ITEM - key->offset check for METADATA_ITEM - it

[PATCH 0/3] btrfs: tree-checker: Add extent items check

2019-07-29 Thread Qu Wenruo
Finally, we are going to add tree-checker support for extent items, which includes: - EXTENT_ITEM/METADATA_ITEM Which futher contains inline backrefs of: * TREE_BLOCK_REF * SHARED_BLOCK_REF * EXETNT_DATA_REF * SHARED_DATA_REF - TREE_BLOCK_REF - SHARED_BLOCK_REF - EXTENT_DATA_REF

Re: [PATCH 3/3] btrfs: tree-checker: Add ROOT_ITEM check

2019-07-26 Thread Qu Wenruo
generic_err(leaf, slot, >> +"invalid root v2 generaetion, have %llu expect (0, %llu]", > > So (0, %llu] here means that it must be greater than zero, right? I'm > not sure that everyone uses the same notatio

Re: [PATCH 3/3] btrfs: tree-checker: Add ROOT_ITEM check

2019-07-26 Thread David Sterba
On Tue, Jul 16, 2019 at 05:00:34PM +0800, Qu Wenruo wrote: > This patch will introduce ROOT_ITEM check, which includes: > - Key->objectid and key->offset check > Currently only some easy check, e.g. 0 as rootid is invalid. > > - Item size check > Root item size is fixed. > > - Generation chec

[PATCH AUTOSEL 5.2 26/85] btrfs: tree-checker: Check if the file extent end overflows

2019-07-26 Thread Sasha Levin
e extent, not directly related to the size. In theory it is OK to have a large value, and put extra limitation on RAM bytes may cause unexpected false alerts. So in tree-checker, we only check if the file offset and num bytes overflow. Signed-off-by: Qu Wenruo Signed-off-by: David Sterba Signe

[PATCH 3/3] btrfs: tree-checker: Add ROOT_ITEM check

2019-07-16 Thread Qu Wenruo
This patch will introduce ROOT_ITEM check, which includes: - Key->objectid and key->offset check Currently only some easy check, e.g. 0 as rootid is invalid. - Item size check Root item size is fixed. - Generation checks Generation, v2_generaetion and last_snapshot should not pass super g

Re: [PATCH] btrfs: tree-checker: Check if the file extent end overflow

2019-05-30 Thread David Sterba
On Thu, May 30, 2019 at 08:03:48PM +0800, Qu Wenruo wrote: > >> @@ -112,6 +112,7 @@ static int check_extent_data_item(struct extent_buffer > >> *leaf, > >>struct btrfs_file_extent_item *fi; > >>u32 sectorsize = fs_info->sectorsize; > >>u32 item_size = btrfs_item_size_nr(leaf, slot); >

Re: [PATCH] btrfs: tree-checker: Check if the file extent end overflow

2019-05-30 Thread Qu Wenruo
as file_offset + num_bytes should never go beyond u64 >> max. >> >> For ram_bytes part, it's about the decompressed size of the extent, not >> directly related to the size. >> In theory is OK to have super large value, and put extra >> limitation on ram bytes may c

Re: [PATCH] btrfs: tree-checker: Check if the file extent end overflow

2019-05-30 Thread David Sterba
part, it's about the decompressed size of the extent, not > directly related to the size. > In theory is OK to have super large value, and put extra > limitation on ram bytes may cause unexpected false alert. > > So in tree-checker, we only check if the file offset and num bytes

Re: [PATCH] btrfs: tree-checker: Check if the file extent end overflow

2019-05-16 Thread Qu Wenruo
as file_offset + num_bytes should never go beyond u64 >> max. >> >> For ram_bytes part, it's about the decompressed size of the extent, not >> directly related to the size. >> In theory is OK to have super large value, and put extra >> limitation on ram bytes may c

Re: [PATCH] btrfs: tree-checker: Check if the file extent end overflow

2019-05-16 Thread David Sterba
part, it's about the decompressed size of the extent, not > directly related to the size. > In theory is OK to have super large value, and put extra > limitation on ram bytes may cause unexpected false alert. > > So in tree-checker, we only check if the file offset and num bytes

Re: [PATCH 2/2] Btrfs: teach tree-checker to detect file extent items with overlapping ranges

2019-05-08 Thread Qu Wenruo
it traims file extent > items). Therefore teach the tree checker to detect such cases. This is > motivated by a recently fixed bug (race between ranged full fsync and > writeback or adjacent ranges). > > Signed-off-by: Filipe Manana Reviewed-by: Qu Wenruo It's better than

Re: [PATCH 2/2] Btrfs: teach tree-checker to detect file extent items with overlapping ranges

2019-05-07 Thread Josef Bacik
_extents() when it traims file extent > items). Therefore teach the tree checker to detect such cases. This is > motivated by a recently fixed bug (race between ranged full fsync and > writeback or adjacent ranges). > > Signed-off-by: Filipe Manana Reviewed-by: Josef Bacik Thanks, Josef

[PATCH 2/2] Btrfs: teach tree-checker to detect file extent items with overlapping ranges

2019-05-06 Thread fdmanana
From: Filipe Manana Having file extent items with ranges that overlap each other is a serious issue that leads to all sorts of corruptions and crashes (like a BUG_ON() during the course of __btrfs_drop_extents() when it traims file extent items). Therefore teach the tree checker to detect such

[PATCH] btrfs: tree-checker: Check if the file extent end overflow

2019-05-02 Thread Qu Wenruo
lue, and put extra limitation on ram bytes may cause unexpected false alert. So in tree-checker, we only check if the file offset and num bytes overflow. Signed-off-by: Qu Wenruo --- fs/btrfs/tree-checker.c | 9 + 1 file changed, 9 insertions(+) diff --git a/fs/btrfs/tree-checker.c b/

Re: [PATCH] btrfs: tree-checker: Allow error injection for tree-checker

2019-04-25 Thread David Sterba
On Thu, Apr 25, 2019 at 10:22:30PM +0800, Qu Wenruo wrote: > > > On 2019/4/25 下午10:13, David Sterba wrote: > > On Thu, Apr 25, 2019 at 08:30:38AM +0800, Qu Wenruo wrote: > >> > >> > >> On 2019/4/25 上午1:45, David Sterba wrote: > >>> On Wed, Apr 24, 2019 at 03:22:53PM +0800, Qu Wenruo wrote: >

Re: [PATCH] btrfs: tree-checker: Allow error injection for tree-checker

2019-04-25 Thread Qu Wenruo
On 2019/4/25 下午10:13, David Sterba wrote: > On Thu, Apr 25, 2019 at 08:30:38AM +0800, Qu Wenruo wrote: >> >> >> On 2019/4/25 上午1:45, David Sterba wrote: >>> On Wed, Apr 24, 2019 at 03:22:53PM +0800, Qu Wenruo wrote: Allowing error injection for btrfs_check_leaf_full() and btrfs_check_no

Re: [PATCH] btrfs: tree-checker: Allow error injection for tree-checker

2019-04-25 Thread David Sterba
On Thu, Apr 25, 2019 at 08:30:38AM +0800, Qu Wenruo wrote: > > > On 2019/4/25 上午1:45, David Sterba wrote: > > On Wed, Apr 24, 2019 at 03:22:53PM +0800, Qu Wenruo wrote: > >> Allowing error injection for btrfs_check_leaf_full() and > >> btrfs_check_node() is useful to test the failure path of btrf

Re: [PATCH] btrfs: tree-checker: Allow error injection for tree-checker

2019-04-24 Thread Qu Wenruo
On 2019/4/25 上午1:45, David Sterba wrote: > On Wed, Apr 24, 2019 at 03:22:53PM +0800, Qu Wenruo wrote: >> Allowing error injection for btrfs_check_leaf_full() and >> btrfs_check_node() is useful to test the failure path of btrfs write >> time tree check. >> >> Signed-off-by: Qu Wenruo > > Does n

Re: [PATCH] btrfs: tree-checker: Allow error injection for tree-checker

2019-04-24 Thread David Sterba
On Wed, Apr 24, 2019 at 03:22:53PM +0800, Qu Wenruo wrote: > Allowing error injection for btrfs_check_leaf_full() and > btrfs_check_node() is useful to test the failure path of btrfs write > time tree check. > > Signed-off-by: Qu Wenruo Added to misc-next, thanks.

Re: [PATCH] btrfs: tree-checker: Allow error injection for tree-checker

2019-04-24 Thread David Sterba
On Wed, Apr 24, 2019 at 03:22:53PM +0800, Qu Wenruo wrote: > Allowing error injection for btrfs_check_leaf_full() and > btrfs_check_node() is useful to test the failure path of btrfs write > time tree check. > > Signed-off-by: Qu Wenruo Does not compile: CC [M] fs/btrfs/tests/extent-map-test

[PATCH] btrfs: tree-checker: Allow error injection for tree-checker

2019-04-24 Thread Qu Wenruo
Allowing error injection for btrfs_check_leaf_full() and btrfs_check_node() is useful to test the failure path of btrfs write time tree check. Signed-off-by: Qu Wenruo --- fs/btrfs/tree-checker.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-check

Re: [PATCH 0/2] Fixup and optimization for write time tree checker

2019-04-08 Thread David Sterba
On Sat, Apr 06, 2019 at 09:57:35AM +0800, Qu Wenruo wrote: > >>> > >>> This patchset also introduces a new optimization, where original empty > >>> leaf owner check can be pretty expensive and cause false alerts for > >>> write time tree checker. &

Re: [PATCH] btrfs: tree-checker: Don't check device size as we can have valid 0 total_bytes

2019-04-08 Thread David Sterba
|- btrfs_device_set_total_bytes(device, 0) > > | |- btrfs_update_device() > > | |- btrfs_commit_transaction() #1 > > |- btrfs_rm_dev_item() > > > > This will trigger write time tree checker warning. > > And further more, this can create valid btrfs with devic

Re: [PATCH] btrfs: tree-checker: Don't check device size as we can have valid 0 total_bytes

2019-04-07 Thread Qu Wenruo
mmit_transaction() #1 > |- btrfs_rm_dev_item() > > This will trigger write time tree checker warning. > And further more, this can create valid btrfs with device->total_bytes > == 0 and triggering read time tree-checker if power loss happens after > above transaction #1 but befo

[PATCH] btrfs: tree-checker: Don't check device size as we can have valid 0 total_bytes

2019-04-07 Thread Qu Wenruo
checker warning. And further more, this can create valid btrfs with device->total_bytes == 0 and triggering read time tree-checker if power loss happens after above transaction #1 but before next transaction. So this dev item check is too restrict. Please fold this patch into commit 87d87c6dc

Re: [PATCH 0/2] Fixup and optimization for write time tree checker

2019-04-05 Thread Qu Wenruo
+0200 >>> >>> btrfs: Switch btrfs_trim_free_extents to find_first_clear_extent_bit >>> >>> These two patches changes the behavior of write time tree-checker, where >>> the initial patches didn't check the content of the leaf, leaving memory >&

Re: [PATCh v2 5/9] btrfs: tree-checker: Verify dev item

2019-04-05 Thread Qu Wenruo
remove this patch from misc-next queue. Under the following call trace, we could create device with total_bytes == 0; btrfs_rm_device() |- btrfs_shrink_device() | |- btrfs_device_set_total_bytes(device, 0) | |- btrfs_update_device() | |- btrfs_commit_transaction() #1 |- btrfs_rm_dev_item() Thi

Re: [PATCH 0/2] Fixup and optimization for write time tree checker

2019-04-05 Thread Qu Wenruo
xtent_bit >> >> These two patches changes the behavior of write time tree-checker, where >> the initial patches didn't check the content of the leaf, leaving memory >> bit flipping possible to sneak in. >> >> This patchset also introduces a new optimization, w

Re: [PATCH 0/2] Fixup and optimization for write time tree checker

2019-04-05 Thread David Sterba
56a7b > (david/misc-next-with-write-checks, david/misc-next) > Author: Nikolay Borisov > Date: Wed Mar 27 14:24:18 2019 +0200 > > btrfs: Switch btrfs_trim_free_extents to find_first_clear_extent_bit > > These two patches changes the behavior of write time tree-checker

Re: [PATCH 1/2] btrfs: tree-checker: Remove comprehensive root owner check

2019-04-04 Thread David Sterba
; However it's pretty expensive tree search to locate the owner root, > > especially when it get reused by mandatory read and write time > > tree-checker. > > > > This patch will remove that check, and completely rely on owner based > > empty leaf check, which is

Re: [PATCH 1/2] btrfs: tree-checker: Remove comprehensive root owner check

2019-04-03 Thread Qu Wenruo
y expensive tree search to locate the owner root, >> especially when it get reused by mandatory read and write time >> tree-checker. >> >> This patch will remove that check, and completely rely on owner based >> empty leaf check, which is much faster and still works fine

Re: [PATCH 1/2] btrfs: tree-checker: Remove comprehensive root owner check

2019-04-03 Thread Nikolay Borisov
t get reused by mandatory read and write time > tree-checker. > > This patch will remove that check, and completely rely on owner based > empty leaf check, which is much faster and still works fine for most > case. > > And since we skip the old root owner ch

  1   2   3   4   >