diff mbox series

[06/18] xfs: don't clear the "dinode core" in xfs_inode_alloc

Message ID 20210324142129.1011766-7-hch@lst.de (mailing list archive)
State Superseded
Headers show
Series [01/18] xfs: split xfs_imap_to_bp | expand

Commit Message

Christoph Hellwig March 24, 2021, 2:21 p.m. UTC
The xfs_icdinode structure just contains a random mix of inode field,
which are all read from the on-disk inode and mostly not looked at
before reading the inode or initializing a new inode cluster.  The
only exceptions are the forkoff and blocks field, which are used
in sanity checks for freshly allocated inodes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_icache.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Darrick J. Wong March 24, 2021, 6:27 p.m. UTC | #1
On Wed, Mar 24, 2021 at 03:21:17PM +0100, Christoph Hellwig wrote:
> The xfs_icdinode structure just contains a random mix of inode field,
> which are all read from the on-disk inode and mostly not looked at
> before reading the inode or initializing a new inode cluster.  The
> only exceptions are the forkoff and blocks field, which are used
> in sanity checks for freshly allocated inodes.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Hmm, does this fix the crash I complained about last time?

https://lore.kernel.org/linux-xfs/20200702183426.GD7606@magnolia/

I /think/ it does, but can't tell for sure from the comments. :/

--D

> ---
>  fs/xfs/xfs_icache.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> index 0e43d27e8e13bc..a8d982a10df828 100644
> --- a/fs/xfs/xfs_icache.c
> +++ b/fs/xfs/xfs_icache.c
> @@ -63,8 +63,9 @@ xfs_inode_alloc(
>  	memset(&ip->i_df, 0, sizeof(ip->i_df));
>  	ip->i_flags = 0;
>  	ip->i_delayed_blks = 0;
> -	memset(&ip->i_d, 0, sizeof(ip->i_d));
>  	ip->i_d.di_flags2 = mp->m_ino_geo.new_diflags2;
> +	ip->i_d.di_nblocks = 0;
> +	ip->i_d.di_forkoff = 0;
>  	ip->i_sick = 0;
>  	ip->i_checked = 0;
>  	INIT_WORK(&ip->i_ioend_work, xfs_end_io);
> -- 
> 2.30.1
>
Christoph Hellwig March 24, 2021, 6:28 p.m. UTC | #2
On Wed, Mar 24, 2021 at 11:27:25AM -0700, Darrick J. Wong wrote:
> On Wed, Mar 24, 2021 at 03:21:17PM +0100, Christoph Hellwig wrote:
> > The xfs_icdinode structure just contains a random mix of inode field,
> > which are all read from the on-disk inode and mostly not looked at
> > before reading the inode or initializing a new inode cluster.  The
> > only exceptions are the forkoff and blocks field, which are used
> > in sanity checks for freshly allocated inodes.
> > 
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Hmm, does this fix the crash I complained about last time?
> 
> https://lore.kernel.org/linux-xfs/20200702183426.GD7606@magnolia/
> 
> I /think/ it does, but can't tell for sure from the comments. :/

Your crash was due to the uninitialized diflags2, which is fixed very
early on in the series.
Darrick J. Wong March 24, 2021, 6:40 p.m. UTC | #3
On Wed, Mar 24, 2021 at 07:28:49PM +0100, Christoph Hellwig wrote:
> On Wed, Mar 24, 2021 at 11:27:25AM -0700, Darrick J. Wong wrote:
> > On Wed, Mar 24, 2021 at 03:21:17PM +0100, Christoph Hellwig wrote:
> > > The xfs_icdinode structure just contains a random mix of inode field,
> > > which are all read from the on-disk inode and mostly not looked at
> > > before reading the inode or initializing a new inode cluster.  The
> > > only exceptions are the forkoff and blocks field, which are used
> > > in sanity checks for freshly allocated inodes.
> > > 
> > > Signed-off-by: Christoph Hellwig <hch@lst.de>
> > 
> > Hmm, does this fix the crash I complained about last time?
> > 
> > https://lore.kernel.org/linux-xfs/20200702183426.GD7606@magnolia/
> > 
> > I /think/ it does, but can't tell for sure from the comments. :/
> 
> Your crash was due to the uninitialized diflags2, which is fixed very
> early on in the series.

Ah, ok.  I thought that might be the proper fix for that.  At the very
least, the repro instructions don't lead to a crash this time, so I'll
toss this series at fstests cloud and see if anything falls out.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D
diff mbox series

Patch

diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
index 0e43d27e8e13bc..a8d982a10df828 100644
--- a/fs/xfs/xfs_icache.c
+++ b/fs/xfs/xfs_icache.c
@@ -63,8 +63,9 @@  xfs_inode_alloc(
 	memset(&ip->i_df, 0, sizeof(ip->i_df));
 	ip->i_flags = 0;
 	ip->i_delayed_blks = 0;
-	memset(&ip->i_d, 0, sizeof(ip->i_d));
 	ip->i_d.di_flags2 = mp->m_ino_geo.new_diflags2;
+	ip->i_d.di_nblocks = 0;
+	ip->i_d.di_forkoff = 0;
 	ip->i_sick = 0;
 	ip->i_checked = 0;
 	INIT_WORK(&ip->i_ioend_work, xfs_end_io);