diff options
Diffstat (limited to 'fs/xfs/xfs_fsops.c')
-rw-r--r-- | fs/xfs/xfs_fsops.c | 60 |
1 files changed, 42 insertions, 18 deletions
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 9153d2c77caf..1c6fdeb702ff 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -194,6 +194,10 @@ xfs_growfs_data_private( | |||
194 | bp = xfs_buf_get(mp->m_ddev_targp, | 194 | bp = xfs_buf_get(mp->m_ddev_targp, |
195 | XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)), | 195 | XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)), |
196 | XFS_FSS_TO_BB(mp, 1), XBF_LOCK | XBF_MAPPED); | 196 | XFS_FSS_TO_BB(mp, 1), XBF_LOCK | XBF_MAPPED); |
197 | if (!bp) { | ||
198 | error = ENOMEM; | ||
199 | goto error0; | ||
200 | } | ||
197 | agf = XFS_BUF_TO_AGF(bp); | 201 | agf = XFS_BUF_TO_AGF(bp); |
198 | memset(agf, 0, mp->m_sb.sb_sectsize); | 202 | memset(agf, 0, mp->m_sb.sb_sectsize); |
199 | agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC); | 203 | agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC); |
@@ -216,16 +220,21 @@ xfs_growfs_data_private( | |||
216 | tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp); | 220 | tmpsize = agsize - XFS_PREALLOC_BLOCKS(mp); |
217 | agf->agf_freeblks = cpu_to_be32(tmpsize); | 221 | agf->agf_freeblks = cpu_to_be32(tmpsize); |
218 | agf->agf_longest = cpu_to_be32(tmpsize); | 222 | agf->agf_longest = cpu_to_be32(tmpsize); |
219 | error = xfs_bwrite(mp, bp); | 223 | error = xfs_bwrite(bp); |
220 | if (error) { | 224 | xfs_buf_relse(bp); |
225 | if (error) | ||
221 | goto error0; | 226 | goto error0; |
222 | } | 227 | |
223 | /* | 228 | /* |
224 | * AG inode header block | 229 | * AG inode header block |
225 | */ | 230 | */ |
226 | bp = xfs_buf_get(mp->m_ddev_targp, | 231 | bp = xfs_buf_get(mp->m_ddev_targp, |
227 | XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)), | 232 | XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)), |
228 | XFS_FSS_TO_BB(mp, 1), XBF_LOCK | XBF_MAPPED); | 233 | XFS_FSS_TO_BB(mp, 1), XBF_LOCK | XBF_MAPPED); |
234 | if (!bp) { | ||
235 | error = ENOMEM; | ||
236 | goto error0; | ||
237 | } | ||
229 | agi = XFS_BUF_TO_AGI(bp); | 238 | agi = XFS_BUF_TO_AGI(bp); |
230 | memset(agi, 0, mp->m_sb.sb_sectsize); | 239 | memset(agi, 0, mp->m_sb.sb_sectsize); |
231 | agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC); | 240 | agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC); |
@@ -240,10 +249,11 @@ xfs_growfs_data_private( | |||
240 | agi->agi_dirino = cpu_to_be32(NULLAGINO); | 249 | agi->agi_dirino = cpu_to_be32(NULLAGINO); |
241 | for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) | 250 | for (bucket = 0; bucket < XFS_AGI_UNLINKED_BUCKETS; bucket++) |
242 | agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO); | 251 | agi->agi_unlinked[bucket] = cpu_to_be32(NULLAGINO); |
243 | error = xfs_bwrite(mp, bp); | 252 | error = xfs_bwrite(bp); |
244 | if (error) { | 253 | xfs_buf_relse(bp); |
254 | if (error) | ||
245 | goto error0; | 255 | goto error0; |
246 | } | 256 | |
247 | /* | 257 | /* |
248 | * BNO btree root block | 258 | * BNO btree root block |
249 | */ | 259 | */ |
@@ -251,6 +261,10 @@ xfs_growfs_data_private( | |||
251 | XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)), | 261 | XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)), |
252 | BTOBB(mp->m_sb.sb_blocksize), | 262 | BTOBB(mp->m_sb.sb_blocksize), |
253 | XBF_LOCK | XBF_MAPPED); | 263 | XBF_LOCK | XBF_MAPPED); |
264 | if (!bp) { | ||
265 | error = ENOMEM; | ||
266 | goto error0; | ||
267 | } | ||
254 | block = XFS_BUF_TO_BLOCK(bp); | 268 | block = XFS_BUF_TO_BLOCK(bp); |
255 | memset(block, 0, mp->m_sb.sb_blocksize); | 269 | memset(block, 0, mp->m_sb.sb_blocksize); |
256 | block->bb_magic = cpu_to_be32(XFS_ABTB_MAGIC); | 270 | block->bb_magic = cpu_to_be32(XFS_ABTB_MAGIC); |
@@ -262,10 +276,11 @@ xfs_growfs_data_private( | |||
262 | arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); | 276 | arec->ar_startblock = cpu_to_be32(XFS_PREALLOC_BLOCKS(mp)); |
263 | arec->ar_blockcount = cpu_to_be32( | 277 | arec->ar_blockcount = cpu_to_be32( |
264 | agsize - be32_to_cpu(arec->ar_startblock)); | 278 | agsize - be32_to_cpu(arec->ar_startblock)); |
265 | error = xfs_bwrite(mp, bp); | 279 | error = xfs_bwrite(bp); |
266 | if (error) { | 280 | xfs_buf_relse(bp); |
281 | if (error) | ||
267 | goto error0; | 282 | goto error0; |
268 | } | 283 | |
269 | /* | 284 | /* |
270 | * CNT btree root block | 285 | * CNT btree root block |
271 | */ | 286 | */ |
@@ -273,6 +288,10 @@ xfs_growfs_data_private( | |||
273 | XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)), | 288 | XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)), |
274 | BTOBB(mp->m_sb.sb_blocksize), | 289 | BTOBB(mp->m_sb.sb_blocksize), |
275 | XBF_LOCK | XBF_MAPPED); | 290 | XBF_LOCK | XBF_MAPPED); |
291 | if (!bp) { | ||
292 | error = ENOMEM; | ||
293 | goto error0; | ||
294 | } | ||
276 | block = XFS_BUF_TO_BLOCK(bp); | 295 | block = XFS_BUF_TO_BLOCK(bp); |
277 | memset(block, 0, mp->m_sb.sb_blocksize); | 296 | memset(block, 0, mp->m_sb.sb_blocksize); |
278 | block->bb_magic = cpu_to_be32(XFS_ABTC_MAGIC); | 297 | block->bb_magic = cpu_to_be32(XFS_ABTC_MAGIC); |
@@ -285,10 +304,11 @@ xfs_growfs_data_private( | |||
285 | arec->ar_blockcount = cpu_to_be32( | 304 | arec->ar_blockcount = cpu_to_be32( |
286 | agsize - be32_to_cpu(arec->ar_startblock)); | 305 | agsize - be32_to_cpu(arec->ar_startblock)); |
287 | nfree += be32_to_cpu(arec->ar_blockcount); | 306 | nfree += be32_to_cpu(arec->ar_blockcount); |
288 | error = xfs_bwrite(mp, bp); | 307 | error = xfs_bwrite(bp); |
289 | if (error) { | 308 | xfs_buf_relse(bp); |
309 | if (error) | ||
290 | goto error0; | 310 | goto error0; |
291 | } | 311 | |
292 | /* | 312 | /* |
293 | * INO btree root block | 313 | * INO btree root block |
294 | */ | 314 | */ |
@@ -296,6 +316,10 @@ xfs_growfs_data_private( | |||
296 | XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)), | 316 | XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)), |
297 | BTOBB(mp->m_sb.sb_blocksize), | 317 | BTOBB(mp->m_sb.sb_blocksize), |
298 | XBF_LOCK | XBF_MAPPED); | 318 | XBF_LOCK | XBF_MAPPED); |
319 | if (!bp) { | ||
320 | error = ENOMEM; | ||
321 | goto error0; | ||
322 | } | ||
299 | block = XFS_BUF_TO_BLOCK(bp); | 323 | block = XFS_BUF_TO_BLOCK(bp); |
300 | memset(block, 0, mp->m_sb.sb_blocksize); | 324 | memset(block, 0, mp->m_sb.sb_blocksize); |
301 | block->bb_magic = cpu_to_be32(XFS_IBT_MAGIC); | 325 | block->bb_magic = cpu_to_be32(XFS_IBT_MAGIC); |
@@ -303,10 +327,10 @@ xfs_growfs_data_private( | |||
303 | block->bb_numrecs = 0; | 327 | block->bb_numrecs = 0; |
304 | block->bb_u.s.bb_leftsib = cpu_to_be32(NULLAGBLOCK); | 328 | block->bb_u.s.bb_leftsib = cpu_to_be32(NULLAGBLOCK); |
305 | block->bb_u.s.bb_rightsib = cpu_to_be32(NULLAGBLOCK); | 329 | block->bb_u.s.bb_rightsib = cpu_to_be32(NULLAGBLOCK); |
306 | error = xfs_bwrite(mp, bp); | 330 | error = xfs_bwrite(bp); |
307 | if (error) { | 331 | xfs_buf_relse(bp); |
332 | if (error) | ||
308 | goto error0; | 333 | goto error0; |
309 | } | ||
310 | } | 334 | } |
311 | xfs_trans_agblocks_delta(tp, nfree); | 335 | xfs_trans_agblocks_delta(tp, nfree); |
312 | /* | 336 | /* |
@@ -396,9 +420,9 @@ xfs_growfs_data_private( | |||
396 | * just issue a warning and continue. The real work is | 420 | * just issue a warning and continue. The real work is |
397 | * already done and committed. | 421 | * already done and committed. |
398 | */ | 422 | */ |
399 | if (!(error = xfs_bwrite(mp, bp))) { | 423 | error = xfs_bwrite(bp); |
400 | continue; | 424 | xfs_buf_relse(bp); |
401 | } else { | 425 | if (error) { |
402 | xfs_warn(mp, | 426 | xfs_warn(mp, |
403 | "write error %d updating secondary superblock for ag %d", | 427 | "write error %d updating secondary superblock for ag %d", |
404 | error, agno); | 428 | error, agno); |