Skip to contentSkip to conversation

btrfs-progs: don't check nbytes on unlinked files

PATCH In review Josef Bacik 4 participants 6 messages Aug 9, 2019 – Aug 26, 2019 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs-progs: don't check nbytes on unlinked files

We don't update the inode when evicting it, so the nbytes will be wrong in between transaction commits. This isn't a problem, stop complaining about it to make generic/269 stop randomly failing.

---
 check/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
check/main.c +1 -1
index ca2ace10..45726e6e 100644
@@ -807,7 +807,7 @@ static void maybe_free_inode_rec(struct cache_tree *inode_cache,
 	} else if (S_ISREG(rec->imode) || S_ISLNK(rec->imode)) {
 		if (rec->found_dir_item)
 			rec->errors |= I_ERR_ODD_DIR_ITEM;
-		if (rec->found_size != rec->nbytes)
+		if (rec->nlink > 0 && rec->found_size != rec->nbytes)
 			rec->errors |= I_ERR_FILE_NBYTES_WRONG;
 		if (rec->nlink > 0 && !no_holes &&
 		    (rec->extent_end < rec->isize ||
Signature · 1 line
2.21.0
#1 lore raw
Quoted 5 lines · Josef Bacik

We don't update the inode when evicting it, so the nbytes will be wrong in between transaction commits. This isn't a problem, stop complaining about it to make generic/269 stop randomly failing.

We shouldn't be able to see unlinked files in the tree. At the very least they should be orphans, no ? So why do we need this check ?

Quoted 18 lines
---
 check/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
check/main.c +1 -1
index ca2ace10..45726e6e 100644
@@ -807,7 +807,7 @@ static void maybe_free_inode_rec(struct cache_tree *inode_cache,
 	} else if (S_ISREG(rec->imode) || S_ISLNK(rec->imode)) {
 		if (rec->found_dir_item)
 			rec->errors |= I_ERR_ODD_DIR_ITEM;
-		if (rec->found_size != rec->nbytes)
+		if (rec->nlink > 0 && rec->found_size != rec->nbytes)
 			rec->errors |= I_ERR_FILE_NBYTES_WRONG;
 		if (rec->nlink > 0 && !no_holes &&
 		    (rec->extent_end < rec->isize ||
#2 lore raw
Quoted 12 lines · Nikolay Borisov
Quoted 5 lines · Josef Bacik

We don't update the inode when evicting it, so the nbytes will be wrong in between transaction commits. This isn't a problem, stop complaining about it to make generic/269 stop randomly failing.

We shouldn't be able to see unlinked files in the tree. At the very least they should be orphans, no ? So why do we need this check ?

Because we don't update the inode when evicting it. btrfsck doesn't skip inodes that have orphan items, it just does it's normal checks, which is why we need this. Thanks,

Josef

#3 lore raw
In reply to Josef Bacik
Quoted 3 lines · Josef Bacik

We don't update the inode when evicting it, so the nbytes will be wrong in between transaction commits. This isn't a problem, stop complaining about it to make generic/269 stop randomly failing.

Would you like to add the same check for lowmem mode?

Or mind me to do that?

Thanks,
Qu

Quoted 20 lines
---
 check/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
check/main.c +1 -1
index ca2ace10..45726e6e 100644
@@ -807,7 +807,7 @@ static void maybe_free_inode_rec(struct cache_tree *inode_cache,
 	} else if (S_ISREG(rec->imode) || S_ISLNK(rec->imode)) {
 		if (rec->found_dir_item)
 			rec->errors |= I_ERR_ODD_DIR_ITEM;
-		if (rec->found_size != rec->nbytes)
+		if (rec->nlink > 0 && rec->found_size != rec->nbytes)
 			rec->errors |= I_ERR_FILE_NBYTES_WRONG;
 		if (rec->nlink > 0 && !no_holes &&
 		    (rec->extent_end < rec->isize ||
#4 lore raw
Quoted 10 lines · Qu Wenruo
Quoted 3 lines · Josef Bacik

We don't update the inode when evicting it, so the nbytes will be wrong in between transaction commits. This isn't a problem, stop complaining about it to make generic/269 stop randomly failing.

Would you like to add the same check for lowmem mode?

Or mind me to do that?

Yes please. Thanks.

#5 lore raw
In reply to Josef Bacik
Quoted 5 lines · Josef Bacik

We don't update the inode when evicting it, so the nbytes will be wrong in between transaction commits. This isn't a problem, stop complaining about it to make generic/269 stop randomly failing.

Added to devel, thanks.

Quoted 9 lines
---
 check/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
check/main.c +0 -0
index ca2ace10..45726e6e 100644

check/main.c static void maybe_free_inode_rec(struct cache_tree *inode_cache, · line 810

Quoted 5 lines
check/main.c +1 -1
@@ -807,7 +807,7 @@ static void maybe_free_inode_rec(struct cache_tree *inode_cache,
 	} else if (S_ISREG(rec->imode) || S_ISLNK(rec->imode)) {
 		if (rec->found_dir_item)
 			rec->errors |= I_ERR_ODD_DIR_ITEM;
-		if (rec->found_size != rec->nbytes)
+		if (rec->nlink > 0 && rec->found_size != rec->nbytes)

I've added a comment above the line.