aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-02-04 03:33:58 -0500
committerChristoph Hellwig <hch@brick.lst.de>2009-02-04 03:33:58 -0500
commitb93b6e434c046459cf3111c76dce46ba4abcb2b6 (patch)
tree04277a4f1bae95d38ea775623db3aaac72d56f26 /fs/xfs
parentf9057e3da79d18fdbd9d6adbb183f032c614feeb (diff)
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: Christoph Hellwig <hch@lst.de> Reviewed-by: Felix Blyakher <felixb@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_mount.c15
-rw-r--r--fs/xfs/xfs_rtalloc.c10
-rw-r--r--fs/xfs/xfs_rtalloc.h4
3 files changed, 21 insertions, 8 deletions
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 86ac80c897c3..664961e45e02 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -1138,7 +1138,7 @@ xfs_mountfs(
1138 error = xfs_mount_log_sb(mp, mp->m_update_flags); 1138 error = xfs_mount_log_sb(mp, mp->m_update_flags);
1139 if (error) { 1139 if (error) {
1140 cmn_err(CE_WARN, "XFS: failed to write sb changes"); 1140 cmn_err(CE_WARN, "XFS: failed to write sb changes");
1141 goto out_rele_rip; 1141 goto out_rtunmount;
1142 } 1142 }
1143 } 1143 }
1144 1144
@@ -1147,7 +1147,7 @@ xfs_mountfs(
1147 */ 1147 */
1148 error = XFS_QM_INIT(mp, &quotamount, &quotaflags); 1148 error = XFS_QM_INIT(mp, &quotamount, &quotaflags);
1149 if (error) 1149 if (error)
1150 goto out_rele_rip; 1150 goto out_rtunmount;
1151 1151
1152 /* 1152 /*
1153 * Finish recovering the file system. This part needed to be 1153 * Finish recovering the file system. This part needed to be
@@ -1157,7 +1157,7 @@ xfs_mountfs(
1157 error = xfs_log_mount_finish(mp); 1157 error = xfs_log_mount_finish(mp);
1158 if (error) { 1158 if (error) {
1159 cmn_err(CE_WARN, "XFS: log mount finish failed"); 1159 cmn_err(CE_WARN, "XFS: log mount finish failed");
1160 goto out_rele_rip; 1160 goto out_rtunmount;
1161 } 1161 }
1162 1162
1163 /* 1163 /*
@@ -1165,7 +1165,7 @@ xfs_mountfs(
1165 */ 1165 */
1166 error = XFS_QM_MOUNT(mp, quotamount, quotaflags); 1166 error = XFS_QM_MOUNT(mp, quotamount, quotaflags);
1167 if (error) 1167 if (error)
1168 goto out_rele_rip; 1168 goto out_rtunmount;
1169 1169
1170 /* 1170 /*
1171 * Now we are mounted, reserve a small amount of unused space for 1171 * Now we are mounted, reserve a small amount of unused space for
@@ -1189,6 +1189,8 @@ xfs_mountfs(
1189 1189
1190 return 0; 1190 return 0;
1191 1191
1192 out_rtunmount:
1193 xfs_rtunmount_inodes(mp);
1192 out_rele_rip: 1194 out_rele_rip:
1193 IRELE(rip); 1195 IRELE(rip);
1194 out_log_dealloc: 1196 out_log_dealloc:
@@ -1219,10 +1221,7 @@ xfs_unmountfs(
1219 */ 1221 */
1220 XFS_QM_UNMOUNT(mp); 1222 XFS_QM_UNMOUNT(mp);
1221 1223
1222 if (mp->m_rbmip) 1224 xfs_rtunmount_inodes(mp);
1223 IRELE(mp->m_rbmip);
1224 if (mp->m_rsumip)
1225 IRELE(mp->m_rsumip);
1226 IRELE(mp->m_rootip); 1225 IRELE(mp->m_rootip);
1227 1226
1228 /* 1227 /*
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index c5bb86f3ec05..385f6dceba5d 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -2288,6 +2288,16 @@ xfs_rtmount_inodes(
2288 return 0; 2288 return 0;
2289} 2289}
2290 2290
2291void
2292xfs_rtunmount_inodes(
2293 struct xfs_mount *mp)
2294{
2295 if (mp->m_rbmip)
2296 IRELE(mp->m_rbmip);
2297 if (mp->m_rsumip)
2298 IRELE(mp->m_rsumip);
2299}
2300
2291/* 2301/*
2292 * Pick an extent for allocation at the start of a new realtime file. 2302 * Pick an extent for allocation at the start of a new realtime file.
2293 * Use the sequence number stored in the atime field of the bitmap inode. 2303 * Use the sequence number stored in the atime field of the bitmap inode.
diff --git a/fs/xfs/xfs_rtalloc.h b/fs/xfs/xfs_rtalloc.h
index 8d8dcd215716..3bac681218a4 100644
--- a/fs/xfs/xfs_rtalloc.h
+++ b/fs/xfs/xfs_rtalloc.h
@@ -108,6 +108,9 @@ xfs_rtfree_extent(
108int /* error */ 108int /* error */
109xfs_rtmount_init( 109xfs_rtmount_init(
110 struct xfs_mount *mp); /* file system mount structure */ 110 struct xfs_mount *mp); /* file system mount structure */
111void
112xfs_rtunmount_inodes(
113 struct xfs_mount *mp);
111 114
112/* 115/*
113 * Get the bitmap and summary inodes into the mount structure 116 * Get the bitmap and summary inodes into the mount structure
@@ -146,6 +149,7 @@ xfs_growfs_rt(
146# define xfs_growfs_rt(mp,in) (ENOSYS) 149# define xfs_growfs_rt(mp,in) (ENOSYS)
147# define xfs_rtmount_init(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS)) 150# define xfs_rtmount_init(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
148# define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS)) 151# define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
152# define xfs_rtunmount_inodes(m)
149#endif /* CONFIG_XFS_RT */ 153#endif /* CONFIG_XFS_RT */
150 154
151#endif /* __KERNEL__ */ 155#endif /* __KERNEL__ */