btrfs-progs: check/lowmem: Skip nbytes check for orphan inodes

For orphan inodes, kernel won't update its nbytes and size since it's a
waste of time.

So lowmem check can report false alert on some orphan inodes.

Fix it by checking if the inode is an orphan before
complaining/repairing its nbytes.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Qu Wenruo 2019-09-02 12:57:49 +08:00 committed by David Sterba
parent 9b1a1dacbc
commit c31bd8db54

View File

@ -2519,6 +2519,7 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path)
return err;
}
is_orphan = has_orphan_item(root, inode_id);
ii = btrfs_item_ptr(node, slot, struct btrfs_inode_item);
isize = btrfs_inode_size(node, ii);
nbytes = btrfs_inode_nbytes(node, ii);
@ -2672,19 +2673,22 @@ out:
"root %llu INODE[%llu] nlink(%llu) not equal to inode_refs(%llu)",
root->objectid, inode_id, nlink, refs);
}
} else if (!nlink) {
is_orphan = has_orphan_item(root, inode_id);
if (!is_orphan && repair)
} else if (!nlink && !is_orphan) {
if (repair)
ret = repair_inode_orphan_item_lowmem(root,
path, inode_id);
if (!is_orphan && (!repair || ret)) {
if (!repair || ret) {
err |= ORPHAN_ITEM;
error("root %llu INODE[%llu] is orphan item",
root->objectid, inode_id);
}
}
if (nbytes != extent_size) {
/*
* For orhpan inode, updating nbytes/size is just a waste of
* time, so skip such repair and don't report them as error.
*/
if (nbytes != extent_size && !is_orphan) {
if (repair) {
ret = repair_inode_nbytes_lowmem(root, path,
inode_id, extent_size);