Commit b93b6e434c046459cf3111c76dce46ba4abcb2b6

Authored by Christoph Hellwig
Committed by Christoph Hellwig
1 parent f9057e3da7

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>

Showing 3 changed files with 21 additions and 8 deletions Side-by-side Diff

... ... @@ -1138,7 +1138,7 @@
1138 1138 error = xfs_mount_log_sb(mp, mp->m_update_flags);
1139 1139 if (error) {
1140 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 @@
1147 1147 */
1148 1148 error = XFS_QM_INIT(mp, &quotamount, &quotaflags);
1149 1149 if (error)
1150   - goto out_rele_rip;
  1150 + goto out_rtunmount;
1151 1151  
1152 1152 /*
1153 1153 * Finish recovering the file system. This part needed to be
... ... @@ -1157,7 +1157,7 @@
1157 1157 error = xfs_log_mount_finish(mp);
1158 1158 if (error) {
1159 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 @@
1165 1165 */
1166 1166 error = XFS_QM_MOUNT(mp, quotamount, quotaflags);
1167 1167 if (error)
1168   - goto out_rele_rip;
  1168 + goto out_rtunmount;
1169 1169  
1170 1170 /*
1171 1171 * Now we are mounted, reserve a small amount of unused space for
... ... @@ -1189,6 +1189,8 @@
1189 1189  
1190 1190 return 0;
1191 1191  
  1192 + out_rtunmount:
  1193 + xfs_rtunmount_inodes(mp);
1192 1194 out_rele_rip:
1193 1195 IRELE(rip);
1194 1196 out_log_dealloc:
... ... @@ -1219,10 +1221,7 @@
1219 1221 */
1220 1222 XFS_QM_UNMOUNT(mp);
1221 1223  
1222   - if (mp->m_rbmip)
1223   - IRELE(mp->m_rbmip);
1224   - if (mp->m_rsumip)
1225   - IRELE(mp->m_rsumip);
  1224 + xfs_rtunmount_inodes(mp);
1226 1225 IRELE(mp->m_rootip);
1227 1226  
1228 1227 /*
fs/xfs/xfs_rtalloc.c
... ... @@ -2288,6 +2288,16 @@
2288 2288 return 0;
2289 2289 }
2290 2290  
  2291 +void
  2292 +xfs_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 2302 * Pick an extent for allocation at the start of a new realtime file.
2293 2303 * Use the sequence number stored in the atime field of the bitmap inode.
fs/xfs/xfs_rtalloc.h
... ... @@ -108,6 +108,9 @@
108 108 int /* error */
109 109 xfs_rtmount_init(
110 110 struct xfs_mount *mp); /* file system mount structure */
  111 +void
  112 +xfs_rtunmount_inodes(
  113 + struct xfs_mount *mp);
111 114  
112 115 /*
113 116 * Get the bitmap and summary inodes into the mount structure
... ... @@ -146,6 +149,7 @@
146 149 # define xfs_growfs_rt(mp,in) (ENOSYS)
147 150 # define xfs_rtmount_init(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
148 151 # define xfs_rtmount_inodes(m) (((mp)->m_sb.sb_rblocks == 0)? 0 : (ENOSYS))
  152 +# define xfs_rtunmount_inodes(m)
149 153 #endif /* CONFIG_XFS_RT */
150 154  
151 155 #endif /* __KERNEL__ */