diff options
Diffstat (limited to 'fs/xfs/xfs_fsops.c')
-rw-r--r-- | fs/xfs/xfs_fsops.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index a13919a6a364..37a6f62c57b6 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -167,27 +167,14 @@ xfs_growfs_data_private( | |||
167 | } | 167 | } |
168 | new = nb - mp->m_sb.sb_dblocks; | 168 | new = nb - mp->m_sb.sb_dblocks; |
169 | oagcount = mp->m_sb.sb_agcount; | 169 | oagcount = mp->m_sb.sb_agcount; |
170 | if (nagcount > oagcount) { | ||
171 | void *new_perag, *old_perag; | ||
172 | |||
173 | xfs_filestream_flush(mp); | ||
174 | |||
175 | new_perag = kmem_zalloc(sizeof(xfs_perag_t) * nagcount, | ||
176 | KM_MAYFAIL); | ||
177 | if (!new_perag) | ||
178 | return XFS_ERROR(ENOMEM); | ||
179 | |||
180 | down_write(&mp->m_peraglock); | ||
181 | memcpy(new_perag, mp->m_perag, sizeof(xfs_perag_t) * oagcount); | ||
182 | old_perag = mp->m_perag; | ||
183 | mp->m_perag = new_perag; | ||
184 | |||
185 | mp->m_flags |= XFS_MOUNT_32BITINODES; | ||
186 | nagimax = xfs_initialize_perag(mp, nagcount); | ||
187 | up_write(&mp->m_peraglock); | ||
188 | 170 | ||
189 | kmem_free(old_perag); | 171 | /* allocate the new per-ag structures */ |
172 | if (nagcount > oagcount) { | ||
173 | error = xfs_initialize_perag(mp, nagcount, &nagimax); | ||
174 | if (error) | ||
175 | return error; | ||
190 | } | 176 | } |
177 | |||
191 | tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS); | 178 | tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS); |
192 | tp->t_flags |= XFS_TRANS_RESERVE; | 179 | tp->t_flags |= XFS_TRANS_RESERVE; |
193 | if ((error = xfs_trans_reserve(tp, XFS_GROWFS_SPACE_RES(mp), | 180 | if ((error = xfs_trans_reserve(tp, XFS_GROWFS_SPACE_RES(mp), |
@@ -196,6 +183,11 @@ xfs_growfs_data_private( | |||
196 | return error; | 183 | return error; |
197 | } | 184 | } |
198 | 185 | ||
186 | /* | ||
187 | * Write new AG headers to disk. Non-transactional, but written | ||
188 | * synchronously so they are completed prior to the growfs transaction | ||
189 | * being logged. | ||
190 | */ | ||
199 | nfree = 0; | 191 | nfree = 0; |
200 | for (agno = nagcount - 1; agno >= oagcount; agno--, new -= agsize) { | 192 | for (agno = nagcount - 1; agno >= oagcount; agno--, new -= agsize) { |
201 | /* | 193 | /* |
@@ -359,6 +351,12 @@ xfs_growfs_data_private( | |||
359 | goto error0; | 351 | goto error0; |
360 | } | 352 | } |
361 | } | 353 | } |
354 | |||
355 | /* | ||
356 | * Update changed superblock fields transactionally. These are not | ||
357 | * seen by the rest of the world until the transaction commit applies | ||
358 | * them atomically to the superblock. | ||
359 | */ | ||
362 | if (nagcount > oagcount) | 360 | if (nagcount > oagcount) |
363 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_AGCOUNT, nagcount - oagcount); | 361 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_AGCOUNT, nagcount - oagcount); |
364 | if (nb > mp->m_sb.sb_dblocks) | 362 | if (nb > mp->m_sb.sb_dblocks) |
@@ -369,9 +367,9 @@ xfs_growfs_data_private( | |||
369 | if (dpct) | 367 | if (dpct) |
370 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_IMAXPCT, dpct); | 368 | xfs_trans_mod_sb(tp, XFS_TRANS_SB_IMAXPCT, dpct); |
371 | error = xfs_trans_commit(tp, 0); | 369 | error = xfs_trans_commit(tp, 0); |
372 | if (error) { | 370 | if (error) |
373 | return error; | 371 | return error; |
374 | } | 372 | |
375 | /* New allocation groups fully initialized, so update mount struct */ | 373 | /* New allocation groups fully initialized, so update mount struct */ |
376 | if (nagimax) | 374 | if (nagimax) |
377 | mp->m_maxagi = nagimax; | 375 | mp->m_maxagi = nagimax; |
@@ -381,6 +379,8 @@ xfs_growfs_data_private( | |||
381 | mp->m_maxicount = icount << mp->m_sb.sb_inopblog; | 379 | mp->m_maxicount = icount << mp->m_sb.sb_inopblog; |
382 | } else | 380 | } else |
383 | mp->m_maxicount = 0; | 381 | mp->m_maxicount = 0; |
382 | |||
383 | /* update secondary superblocks. */ | ||
384 | for (agno = 1; agno < nagcount; agno++) { | 384 | for (agno = 1; agno < nagcount; agno++) { |
385 | error = xfs_read_buf(mp, mp->m_ddev_targp, | 385 | error = xfs_read_buf(mp, mp->m_ddev_targp, |
386 | XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)), | 386 | XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)), |