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

Message ID 20190809131831.26370-1-josef@toxicpanda.com
State New
Headers show
Series
  • btrfs-progs: don't check nbytes on unlinked files
Related show

Commit Message

Josef Bacik Aug. 9, 2019, 1:18 p.m. UTC
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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 check/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nikolay Borisov Aug. 9, 2019, 3:27 p.m. UTC | #1
On 9.08.19 г. 16:18 ч., Josef Bacik wrote:
> 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.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

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 ?

> ---
>  check/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/check/main.c b/check/main.c
> index ca2ace10..45726e6e 100644
> --- a/check/main.c
> +++ b/check/main.c
> @@ -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 ||
>
Josef Bacik Aug. 9, 2019, 3:30 p.m. UTC | #2
On Fri, Aug 09, 2019 at 06:27:14PM +0300, Nikolay Borisov wrote:
> 
> 
> On 9.08.19 г. 16:18 ч., Josef Bacik wrote:
> > 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.
> > 
> > Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> 
> 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
Qu Wenruo Aug. 10, 2019, 1:06 a.m. UTC | #3
On 2019/8/9 下午9:18, Josef Bacik wrote:
> 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
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>  check/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/check/main.c b/check/main.c
> index ca2ace10..45726e6e 100644
> --- a/check/main.c
> +++ b/check/main.c
> @@ -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 ||
>
David Sterba Aug. 26, 2019, 6:34 p.m. UTC | #4
On Sat, Aug 10, 2019 at 09:06:22AM +0800, Qu Wenruo wrote:
> 
> 
> On 2019/8/9 下午9:18, Josef Bacik wrote:
> > 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.
David Sterba Aug. 26, 2019, 6:36 p.m. UTC | #5
On Fri, Aug 09, 2019 at 09:18:31AM -0400, Josef Bacik wrote:
> 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.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Added to devel, thanks.
> ---
>  check/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/check/main.c b/check/main.c
> index ca2ace10..45726e6e 100644
> --- a/check/main.c
> +++ b/check/main.c
> @@ -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.

Patch
diff mbox series

diff --git a/check/main.c b/check/main.c
index ca2ace10..45726e6e 100644
--- a/check/main.c
+++ b/check/main.c
@@ -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 ||