summaryrefslogtreecommitdiff
path: root/fs/xfs/libxfs/xfs_inode_buf.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-05-14 14:01:17 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2020-05-19 09:40:57 -0700
commit9229d18e801bdbdf79d963d8c944980fc77b5d6b (patch)
tree4ec0f911f9de00eecd2801f0731e777a91471fe9 /fs/xfs/libxfs/xfs_inode_buf.c
parentcb7d58594412fff106cde550dd9e0a7999cc2a0c (diff)
xfs: split xfs_iformat_fork
xfs_iformat_fork is a weird catchall. Split it into one helper for the data fork and one for the attr fork, and then call both helper as well as the COW fork initialization from xfs_inode_from_disk. Order the COW fork initialization after the attr fork initialization given that it can't fail to simplify the error handling. Note that the newly split helpers are moved down the file in xfs_inode_fork.c to avoid the need for forward declarations. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_inode_buf.c')
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index dc00ce6fc4a2..abdecc80579e 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -187,6 +187,10 @@ xfs_inode_from_disk(
{
struct xfs_icdinode *to = &ip->i_d;
struct inode *inode = VFS_I(ip);
+ int error;
+
+ ASSERT(ip->i_cowfp == NULL);
+ ASSERT(ip->i_afp == NULL);
/*
* Convert v1 inodes immediately to v2 inode format as this is the
@@ -242,7 +246,21 @@ xfs_inode_from_disk(
to->di_cowextsize = be32_to_cpu(from->di_cowextsize);
}
- return xfs_iformat_fork(ip, from);
+ error = xfs_iformat_data_fork(ip, from);
+ if (error)
+ return error;
+ if (XFS_DFORK_Q(from)) {
+ error = xfs_iformat_attr_fork(ip, from);
+ if (error)
+ goto out_destroy_data_fork;
+ }
+ if (xfs_is_reflink_inode(ip))
+ xfs_ifork_init_cow(ip);
+ return 0;
+
+out_destroy_data_fork:
+ xfs_idestroy_fork(ip, XFS_DATA_FORK);
+ return error;
}
void