mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	xfs: check unused nlink fields in the ondisk inode
v2/v3 inodes use di_nlink and not di_onlink; and v1 inodes use di_onlink and not di_nlink. Whichever field is not in use, make sure its contents are zero, and teach xfs_scrub to fix that if it is. This clears a bunch of missing scrub failure errors in xfs/385 for core.onlink. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
		
							parent
							
								
									ab97f4b1c0
								
							
						
					
					
						commit
						40cb8613d6
					
				
					 2 changed files with 20 additions and 0 deletions
				
			
		| 
						 | 
					@ -491,6 +491,14 @@ xfs_dinode_verify(
 | 
				
			||||||
			return __this_address;
 | 
								return __this_address;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (dip->di_version > 1) {
 | 
				
			||||||
 | 
							if (dip->di_onlink)
 | 
				
			||||||
 | 
								return __this_address;
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							if (dip->di_nlink)
 | 
				
			||||||
 | 
								return __this_address;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* don't allow invalid i_size */
 | 
						/* don't allow invalid i_size */
 | 
				
			||||||
	di_size = be64_to_cpu(dip->di_size);
 | 
						di_size = be64_to_cpu(dip->di_size);
 | 
				
			||||||
	if (di_size & (1ULL << 63))
 | 
						if (di_size & (1ULL << 63))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -516,6 +516,17 @@ xrep_dinode_mode(
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Fix unused link count fields having nonzero values. */
 | 
				
			||||||
 | 
					STATIC void
 | 
				
			||||||
 | 
					xrep_dinode_nlinks(
 | 
				
			||||||
 | 
						struct xfs_dinode	*dip)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						if (dip->di_version > 1)
 | 
				
			||||||
 | 
							dip->di_onlink = 0;
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							dip->di_nlink = 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Fix any conflicting flags that the verifiers complain about. */
 | 
					/* Fix any conflicting flags that the verifiers complain about. */
 | 
				
			||||||
STATIC void
 | 
					STATIC void
 | 
				
			||||||
xrep_dinode_flags(
 | 
					xrep_dinode_flags(
 | 
				
			||||||
| 
						 | 
					@ -1377,6 +1388,7 @@ xrep_dinode_core(
 | 
				
			||||||
	iget_error = xrep_dinode_mode(ri, dip);
 | 
						iget_error = xrep_dinode_mode(ri, dip);
 | 
				
			||||||
	if (iget_error)
 | 
						if (iget_error)
 | 
				
			||||||
		goto write;
 | 
							goto write;
 | 
				
			||||||
 | 
						xrep_dinode_nlinks(dip);
 | 
				
			||||||
	xrep_dinode_flags(sc, dip, ri->rt_extents > 0);
 | 
						xrep_dinode_flags(sc, dip, ri->rt_extents > 0);
 | 
				
			||||||
	xrep_dinode_size(ri, dip);
 | 
						xrep_dinode_size(ri, dip);
 | 
				
			||||||
	xrep_dinode_extsize_hints(sc, dip);
 | 
						xrep_dinode_extsize_hints(sc, dip);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue