Commit b93b6e43 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Christoph Hellwig

xfs: make sure to free the real-time inodes in the mount error path

When mount fails after allocating the real-time inodes we currently leak
them.  Add a new helper to free the real-time inodes which can be used by
both the mount and unmount path.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarFelix Blyakher <felixb@sgi.com>
parent f9057e3d
...@@ -1138,7 +1138,7 @@ xfs_mountfs( ...@@ -1138,7 +1138,7 @@ xfs_mountfs(
error = xfs_mount_log_sb(mp, mp->m_update_flags); error = xfs_mount_log_sb(mp, mp->m_update_flags);
if (error) { if (error) {
cmn_err(CE_WARN, "XFS: failed to write sb changes"); cmn_err(CE_WARN, "XFS: failed to write sb changes");
goto out_rele_rip; goto out_rtunmount;
} }
} }
...@@ -1147,7 +1147,7 @@ xfs_mountfs( ...@@ -1147,7 +1147,7 @@ xfs_mountfs(
*/ */
error = XFS_QM_INIT(mp, &quotamount, &quotaflags); error = XFS_QM_INIT(mp, &quotamount, &quotaflags);
if (error) if (error)
goto out_rele_rip; goto out_rtunmount;
/* /*
* Finish recovering the file system. This part needed to be * Finish recovering the file system. This part needed to be
...@@ -1157,7 +1157,7 @@ xfs_mountfs( ...@@ -1157,7 +1157,7 @@ xfs_mountfs(
error = xfs_log_mount_finish(mp); error = xfs_log_mount_finish(mp);
if (error) { if (error) {
cmn_err(CE_WARN, "XFS: log mount finish failed"); cmn_err(CE_WARN, "XFS: log mount finish failed");
goto out_rele_rip; goto out_rtunmount;
} }
/* /*
...@@ -1165,7 +1165,7 @@ xfs_mountfs( ...@@ -1165,7 +1165,7 @@ xfs_mountfs(
*/ */
error = XFS_QM_MOUNT(mp, quotamount, quotaflags); error = XFS_QM_MOUNT(mp, quotamount, quotaflags);
if (error) if (error)
goto out_rele_rip; goto out_rtunmount;
/* /*
* Now we are mounted, reserve a small amount of unused space for * Now we are mounted, reserve a small amount of unused space for
...@@ -1189,6 +1189,8 @@ xfs_mountfs( ...@@ -1189,6 +1189,8 @@ xfs_mountfs(
return 0; return 0;
out_rtunmount:
xfs_rtunmount_inodes(mp);
out_rele_rip: out_rele_rip:
IRELE(rip); IRELE(rip);
out_log_dealloc: out_log_dealloc:
...@@ -1219,10 +1221,7 @@ xfs_unmountfs( ...@@ -1219,10 +1221,7 @@ xfs_unmountfs(
*/ */
XFS_QM_UNMOUNT(mp); XFS_QM_UNMOUNT(mp);
if (mp->m_rbmip) xfs_rtunmount_inodes(mp);
IRELE(mp->m_rbmip);
if (mp->m_rsumip)
IRELE(mp->m_rsumip);
IRELE(mp->m_rootip); IRELE(mp->m_rootip);
/* /*
......
...@@ -2288,6 +2288,16 @@ xfs_rtmount_inodes( ...@@ -2288,6 +2288,16 @@ xfs_rtmount_inodes(
return 0; return 0;
} }
void
xfs_rtunmount_inodes(
struct xfs_mount *mp)
{
if (mp->m_rbmip)
IRELE(mp->m_rbmip);
if (mp->m_rsumip)
IRELE(mp->m_rsumip);
}
/* /*
* Pick an extent for allocation at the start of a new realtime file. * Pick an extent for allocation at the start of a new realtime file.
* Use the sequence number stored in the atime field of the bitmap inode. * Use the sequence number stored in the atime field of the bitmap inode.
......
...@@ -108,6 +108,9 @@ xfs_rtfree_extent( ...@@ -108,6 +108,9 @@ xfs_rtfree_extent(
int /* error */ int /* error */
xfs_rtmount_init( xfs_rtmount_init(
struct xfs_mount *mp); /* file system mount structure */ struct xfs_mount *mp); /* file system mount structure */
void
xfs_rtunmount_inodes(
struct xfs_mount *mp);
/* /*
* Get the bitmap and summary inodes into the mount structure * Get the bitmap and summary inodes into the mount structure
...@@ -146,6 +149,7 @@ xfs_growfs_rt( ...@@ -146,6 +149,7 @@ xfs_growfs_rt(
# define xfs_growfs_rt(mp,in) (ENOSYS) # define xfs_growfs_rt(mp,in) (ENOSYS)
# define xfs_rtmount_init(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS)) # define xfs_rtmount_init(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
# define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS)) # define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
# define xfs_rtunmount_inodes(m)
#endif /* CONFIG_XFS_RT */ #endif /* CONFIG_XFS_RT */
#endif /* __KERNEL__ */ #endif /* __KERNEL__ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment