aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_fsops.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2012-11-14 01:54:40 -0500
committerBen Myers <bpm@sgi.com>2012-11-15 22:35:12 -0500
commit1813dd64057490e7a0678a885c4fe6d02f78bdc1 (patch)
treecaf95e2be7881b771da65561b2f1664d73588401 /fs/xfs/xfs_fsops.c
parentb0f539de9fcc543a3ffa40bc22bf51aca6ea6183 (diff)
xfs: convert buffer verifiers to an ops structure.
To separate the verifiers from iodone functions and associate read and write verifiers at the same time, introduce a buffer verifier operations structure to the xfs_buf. This avoids the need for assigning the write verifier, clearing the iodone function and re-running ioend processing in the read verifier, and gets rid of the nasty "b_pre_io" name for the write verifier function pointer. If we ever need to, it will also be easier to add further content specific callbacks to a buffer with an ops structure in place. We also avoid needing to export verifier functions, instead we can simply export the ops structures for those that are needed outside the function they are defined in. This patch also fixes a directory block readahead verifier issue it exposed. This patch also adds ops callbacks to the inode/alloc btree blocks initialised by growfs. These will need more work before they will work with CRCs. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Phil White <pwhite@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_fsops.c')
-rw-r--r--fs/xfs/xfs_fsops.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 5d6d6b9d369d..94eaeedc5498 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -119,7 +119,8 @@ xfs_growfs_get_hdr_buf(
119 struct xfs_mount *mp, 119 struct xfs_mount *mp,
120 xfs_daddr_t blkno, 120 xfs_daddr_t blkno,
121 size_t numblks, 121 size_t numblks,
122 int flags) 122 int flags,
123 const struct xfs_buf_ops *ops)
123{ 124{
124 struct xfs_buf *bp; 125 struct xfs_buf *bp;
125 126
@@ -130,6 +131,7 @@ xfs_growfs_get_hdr_buf(
130 xfs_buf_zero(bp, 0, BBTOB(bp->b_length)); 131 xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
131 bp->b_bn = blkno; 132 bp->b_bn = blkno;
132 bp->b_maps[0].bm_bn = blkno; 133 bp->b_maps[0].bm_bn = blkno;
134 bp->b_ops = ops;
133 135
134 return bp; 136 return bp;
135} 137}
@@ -217,12 +219,12 @@ xfs_growfs_data_private(
217 */ 219 */
218 bp = xfs_growfs_get_hdr_buf(mp, 220 bp = xfs_growfs_get_hdr_buf(mp,
219 XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)), 221 XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
220 XFS_FSS_TO_BB(mp, 1), 0); 222 XFS_FSS_TO_BB(mp, 1), 0,
223 &xfs_agf_buf_ops);
221 if (!bp) { 224 if (!bp) {
222 error = ENOMEM; 225 error = ENOMEM;
223 goto error0; 226 goto error0;
224 } 227 }
225 bp->b_pre_io = xfs_agf_write_verify;
226 228
227 agf = XFS_BUF_TO_AGF(bp); 229 agf = XFS_BUF_TO_AGF(bp);
228 agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC); 230 agf->agf_magicnum = cpu_to_be32(XFS_AGF_MAGIC);
@@ -255,12 +257,12 @@ xfs_growfs_data_private(
255 */ 257 */
256 bp = xfs_growfs_get_hdr_buf(mp, 258 bp = xfs_growfs_get_hdr_buf(mp,
257 XFS_AG_DADDR(mp, agno, XFS_AGFL_DADDR(mp)), 259 XFS_AG_DADDR(mp, agno, XFS_AGFL_DADDR(mp)),
258 XFS_FSS_TO_BB(mp, 1), 0); 260 XFS_FSS_TO_BB(mp, 1), 0,
261 &xfs_agfl_buf_ops);
259 if (!bp) { 262 if (!bp) {
260 error = ENOMEM; 263 error = ENOMEM;
261 goto error0; 264 goto error0;
262 } 265 }
263 bp->b_pre_io = xfs_agfl_write_verify;
264 266
265 agfl = XFS_BUF_TO_AGFL(bp); 267 agfl = XFS_BUF_TO_AGFL(bp);
266 for (bucket = 0; bucket < XFS_AGFL_SIZE(mp); bucket++) 268 for (bucket = 0; bucket < XFS_AGFL_SIZE(mp); bucket++)
@@ -276,12 +278,12 @@ xfs_growfs_data_private(
276 */ 278 */
277 bp = xfs_growfs_get_hdr_buf(mp, 279 bp = xfs_growfs_get_hdr_buf(mp,
278 XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)), 280 XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
279 XFS_FSS_TO_BB(mp, 1), 0); 281 XFS_FSS_TO_BB(mp, 1), 0,
282 &xfs_agi_buf_ops);
280 if (!bp) { 283 if (!bp) {
281 error = ENOMEM; 284 error = ENOMEM;
282 goto error0; 285 goto error0;
283 } 286 }
284 bp->b_pre_io = xfs_agi_write_verify;
285 287
286 agi = XFS_BUF_TO_AGI(bp); 288 agi = XFS_BUF_TO_AGI(bp);
287 agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC); 289 agi->agi_magicnum = cpu_to_be32(XFS_AGI_MAGIC);
@@ -306,7 +308,8 @@ xfs_growfs_data_private(
306 */ 308 */
307 bp = xfs_growfs_get_hdr_buf(mp, 309 bp = xfs_growfs_get_hdr_buf(mp,
308 XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)), 310 XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)),
309 BTOBB(mp->m_sb.sb_blocksize), 0); 311 BTOBB(mp->m_sb.sb_blocksize), 0,
312 &xfs_allocbt_buf_ops);
310 313
311 if (!bp) { 314 if (!bp) {
312 error = ENOMEM; 315 error = ENOMEM;
@@ -329,7 +332,8 @@ xfs_growfs_data_private(
329 */ 332 */
330 bp = xfs_growfs_get_hdr_buf(mp, 333 bp = xfs_growfs_get_hdr_buf(mp,
331 XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)), 334 XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)),
332 BTOBB(mp->m_sb.sb_blocksize), 0); 335 BTOBB(mp->m_sb.sb_blocksize), 0,
336 &xfs_allocbt_buf_ops);
333 if (!bp) { 337 if (!bp) {
334 error = ENOMEM; 338 error = ENOMEM;
335 goto error0; 339 goto error0;
@@ -352,7 +356,8 @@ xfs_growfs_data_private(
352 */ 356 */
353 bp = xfs_growfs_get_hdr_buf(mp, 357 bp = xfs_growfs_get_hdr_buf(mp,
354 XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)), 358 XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)),
355 BTOBB(mp->m_sb.sb_blocksize), 0); 359 BTOBB(mp->m_sb.sb_blocksize), 0,
360 &xfs_inobt_buf_ops);
356 if (!bp) { 361 if (!bp) {
357 error = ENOMEM; 362 error = ENOMEM;
358 goto error0; 363 goto error0;
@@ -448,14 +453,14 @@ xfs_growfs_data_private(
448 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, 453 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp,
449 XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)), 454 XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)),
450 XFS_FSS_TO_BB(mp, 1), 0, &bp, 455 XFS_FSS_TO_BB(mp, 1), 0, &bp,
451 xfs_sb_read_verify); 456 &xfs_sb_buf_ops);
452 } else { 457 } else {
453 bp = xfs_trans_get_buf(NULL, mp->m_ddev_targp, 458 bp = xfs_trans_get_buf(NULL, mp->m_ddev_targp,
454 XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)), 459 XFS_AGB_TO_DADDR(mp, agno, XFS_SB_BLOCK(mp)),
455 XFS_FSS_TO_BB(mp, 1), 0); 460 XFS_FSS_TO_BB(mp, 1), 0);
456 if (bp) { 461 if (bp) {
462 bp->b_ops = &xfs_sb_buf_ops;
457 xfs_buf_zero(bp, 0, BBTOB(bp->b_length)); 463 xfs_buf_zero(bp, 0, BBTOB(bp->b_length));
458 bp->b_pre_io = xfs_sb_write_verify;
459 } else 464 } else
460 error = ENOMEM; 465 error = ENOMEM;
461 } 466 }