diff options
author | Dave Chinner <dchinner@redhat.com> | 2014-06-06 01:08:18 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-06-06 01:08:18 -0400 |
commit | 30028030b14d083123c88e3ab45990a8c375abf1 (patch) | |
tree | c6787bd71e8b29f7acf675500a899e4154e0b951 /fs/xfs/xfs_dir2_readdir.c | |
parent | 2998ab1d450a526a9a3a6292f91239b4fc209db0 (diff) |
xfs: convert directory db conversion to xfs_da_geometry
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_readdir.c')
-rw-r--r-- | fs/xfs/xfs_dir2_readdir.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c index 57e92475cb86..c2a63878d27c 100644 --- a/fs/xfs/xfs_dir2_readdir.c +++ b/fs/xfs/xfs_dir2_readdir.c | |||
@@ -87,8 +87,10 @@ xfs_dir2_sf_getdents( | |||
87 | xfs_dir2_dataptr_t dot_offset; | 87 | xfs_dir2_dataptr_t dot_offset; |
88 | xfs_dir2_dataptr_t dotdot_offset; | 88 | xfs_dir2_dataptr_t dotdot_offset; |
89 | xfs_ino_t ino; | 89 | xfs_ino_t ino; |
90 | struct xfs_da_geometry *geo; | ||
90 | 91 | ||
91 | mp = dp->i_mount; | 92 | mp = dp->i_mount; |
93 | geo = mp->m_dir_geo; | ||
92 | 94 | ||
93 | ASSERT(dp->i_df.if_flags & XFS_IFINLINE); | 95 | ASSERT(dp->i_df.if_flags & XFS_IFINLINE); |
94 | /* | 96 | /* |
@@ -109,7 +111,7 @@ xfs_dir2_sf_getdents( | |||
109 | /* | 111 | /* |
110 | * If the block number in the offset is out of range, we're done. | 112 | * If the block number in the offset is out of range, we're done. |
111 | */ | 113 | */ |
112 | if (xfs_dir2_dataptr_to_db(mp, ctx->pos) > mp->m_dirdatablk) | 114 | if (xfs_dir2_dataptr_to_db(geo, ctx->pos) > mp->m_dirdatablk) |
113 | return 0; | 115 | return 0; |
114 | 116 | ||
115 | /* | 117 | /* |
@@ -118,9 +120,9 @@ xfs_dir2_sf_getdents( | |||
118 | * XXX(hch): the second argument is sometimes 0 and sometimes | 120 | * XXX(hch): the second argument is sometimes 0 and sometimes |
119 | * mp->m_dirdatablk. | 121 | * mp->m_dirdatablk. |
120 | */ | 122 | */ |
121 | dot_offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, | 123 | dot_offset = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk, |
122 | dp->d_ops->data_dot_offset); | 124 | dp->d_ops->data_dot_offset); |
123 | dotdot_offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, | 125 | dotdot_offset = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk, |
124 | dp->d_ops->data_dotdot_offset); | 126 | dp->d_ops->data_dotdot_offset); |
125 | 127 | ||
126 | /* | 128 | /* |
@@ -149,7 +151,7 @@ xfs_dir2_sf_getdents( | |||
149 | for (i = 0; i < sfp->count; i++) { | 151 | for (i = 0; i < sfp->count; i++) { |
150 | __uint8_t filetype; | 152 | __uint8_t filetype; |
151 | 153 | ||
152 | off = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, | 154 | off = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk, |
153 | xfs_dir2_sf_get_offset(sfep)); | 155 | xfs_dir2_sf_get_offset(sfep)); |
154 | 156 | ||
155 | if (ctx->pos > off) { | 157 | if (ctx->pos > off) { |
@@ -166,7 +168,7 @@ xfs_dir2_sf_getdents( | |||
166 | sfep = dp->d_ops->sf_nextentry(sfp, sfep); | 168 | sfep = dp->d_ops->sf_nextentry(sfp, sfep); |
167 | } | 169 | } |
168 | 170 | ||
169 | ctx->pos = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & | 171 | ctx->pos = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk + 1, 0) & |
170 | 0x7fffffff; | 172 | 0x7fffffff; |
171 | return 0; | 173 | return 0; |
172 | } | 174 | } |
@@ -190,12 +192,14 @@ xfs_dir2_block_getdents( | |||
190 | char *ptr; /* current data entry */ | 192 | char *ptr; /* current data entry */ |
191 | int wantoff; /* starting block offset */ | 193 | int wantoff; /* starting block offset */ |
192 | xfs_off_t cook; | 194 | xfs_off_t cook; |
195 | struct xfs_da_geometry *geo; | ||
193 | 196 | ||
194 | mp = dp->i_mount; | 197 | mp = dp->i_mount; |
198 | geo = mp->m_dir_geo; | ||
195 | /* | 199 | /* |
196 | * If the block number in the offset is out of range, we're done. | 200 | * If the block number in the offset is out of range, we're done. |
197 | */ | 201 | */ |
198 | if (xfs_dir2_dataptr_to_db(mp, ctx->pos) > mp->m_dirdatablk) | 202 | if (xfs_dir2_dataptr_to_db(geo, ctx->pos) > mp->m_dirdatablk) |
199 | return 0; | 203 | return 0; |
200 | 204 | ||
201 | error = xfs_dir3_block_read(NULL, dp, &bp); | 205 | error = xfs_dir3_block_read(NULL, dp, &bp); |
@@ -206,7 +210,7 @@ xfs_dir2_block_getdents( | |||
206 | * Extract the byte offset we start at from the seek pointer. | 210 | * Extract the byte offset we start at from the seek pointer. |
207 | * We'll skip entries before this. | 211 | * We'll skip entries before this. |
208 | */ | 212 | */ |
209 | wantoff = xfs_dir2_dataptr_to_off(mp, ctx->pos); | 213 | wantoff = xfs_dir2_dataptr_to_off(geo, ctx->pos); |
210 | hdr = bp->b_addr; | 214 | hdr = bp->b_addr; |
211 | xfs_dir3_data_check(dp, bp); | 215 | xfs_dir3_data_check(dp, bp); |
212 | /* | 216 | /* |
@@ -244,7 +248,7 @@ xfs_dir2_block_getdents( | |||
244 | if ((char *)dep - (char *)hdr < wantoff) | 248 | if ((char *)dep - (char *)hdr < wantoff) |
245 | continue; | 249 | continue; |
246 | 250 | ||
247 | cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, | 251 | cook = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk, |
248 | (char *)dep - (char *)hdr); | 252 | (char *)dep - (char *)hdr); |
249 | 253 | ||
250 | ctx->pos = cook & 0x7fffffff; | 254 | ctx->pos = cook & 0x7fffffff; |
@@ -264,7 +268,7 @@ xfs_dir2_block_getdents( | |||
264 | * Reached the end of the block. | 268 | * Reached the end of the block. |
265 | * Set the offset to a non-existent block 1 and return. | 269 | * Set the offset to a non-existent block 1 and return. |
266 | */ | 270 | */ |
267 | ctx->pos = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & | 271 | ctx->pos = xfs_dir2_db_off_to_dataptr(geo, mp->m_dirdatablk + 1, 0) & |
268 | 0x7fffffff; | 272 | 0x7fffffff; |
269 | xfs_trans_brelse(NULL, bp); | 273 | xfs_trans_brelse(NULL, bp); |
270 | return 0; | 274 | return 0; |
@@ -300,6 +304,7 @@ xfs_dir2_leaf_readbuf( | |||
300 | int length; | 304 | int length; |
301 | int i; | 305 | int i; |
302 | int j; | 306 | int j; |
307 | struct xfs_da_geometry *geo = mp->m_dir_geo; | ||
303 | 308 | ||
304 | /* | 309 | /* |
305 | * If we have a buffer, we need to release it and | 310 | * If we have a buffer, we need to release it and |
@@ -342,14 +347,14 @@ xfs_dir2_leaf_readbuf( | |||
342 | * run out of data blocks, get some more mappings. | 347 | * run out of data blocks, get some more mappings. |
343 | */ | 348 | */ |
344 | if (1 + mip->ra_want > mip->map_blocks && | 349 | if (1 + mip->ra_want > mip->map_blocks && |
345 | mip->map_off < xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET)) { | 350 | mip->map_off < xfs_dir2_byte_to_da(geo, XFS_DIR2_LEAF_OFFSET)) { |
346 | /* | 351 | /* |
347 | * Get more bmaps, fill in after the ones | 352 | * Get more bmaps, fill in after the ones |
348 | * we already have in the table. | 353 | * we already have in the table. |
349 | */ | 354 | */ |
350 | mip->nmap = mip->map_size - mip->map_valid; | 355 | mip->nmap = mip->map_size - mip->map_valid; |
351 | error = xfs_bmapi_read(dp, mip->map_off, | 356 | error = xfs_bmapi_read(dp, mip->map_off, |
352 | xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET) - | 357 | xfs_dir2_byte_to_da(geo, XFS_DIR2_LEAF_OFFSET) - |
353 | mip->map_off, | 358 | mip->map_off, |
354 | &map[mip->map_valid], &mip->nmap, 0); | 359 | &map[mip->map_valid], &mip->nmap, 0); |
355 | 360 | ||
@@ -370,7 +375,7 @@ xfs_dir2_leaf_readbuf( | |||
370 | i = mip->map_valid + mip->nmap - 1; | 375 | i = mip->map_valid + mip->nmap - 1; |
371 | mip->map_off = map[i].br_startoff + map[i].br_blockcount; | 376 | mip->map_off = map[i].br_startoff + map[i].br_blockcount; |
372 | } else | 377 | } else |
373 | mip->map_off = xfs_dir2_byte_to_da(mp, | 378 | mip->map_off = xfs_dir2_byte_to_da(geo, |
374 | XFS_DIR2_LEAF_OFFSET); | 379 | XFS_DIR2_LEAF_OFFSET); |
375 | 380 | ||
376 | /* | 381 | /* |
@@ -396,14 +401,14 @@ xfs_dir2_leaf_readbuf( | |||
396 | * No valid mappings, so no more data blocks. | 401 | * No valid mappings, so no more data blocks. |
397 | */ | 402 | */ |
398 | if (!mip->map_valid) { | 403 | if (!mip->map_valid) { |
399 | *curoff = xfs_dir2_da_to_byte(mp->m_dir_geo, mip->map_off); | 404 | *curoff = xfs_dir2_da_to_byte(geo, mip->map_off); |
400 | goto out; | 405 | goto out; |
401 | } | 406 | } |
402 | 407 | ||
403 | /* | 408 | /* |
404 | * Read the directory block starting at the first mapping. | 409 | * Read the directory block starting at the first mapping. |
405 | */ | 410 | */ |
406 | mip->curdb = xfs_dir2_da_to_db(mp->m_dir_geo, map->br_startoff); | 411 | mip->curdb = xfs_dir2_da_to_db(geo, map->br_startoff); |
407 | error = xfs_dir3_data_read(NULL, dp, map->br_startoff, | 412 | error = xfs_dir3_data_read(NULL, dp, map->br_startoff, |
408 | map->br_blockcount >= mp->m_dirblkfsbs ? | 413 | map->br_blockcount >= mp->m_dirblkfsbs ? |
409 | XFS_FSB_TO_DADDR(mp, map->br_startblock) : -1, &bp); | 414 | XFS_FSB_TO_DADDR(mp, map->br_startblock) : -1, &bp); |
@@ -504,6 +509,7 @@ xfs_dir2_leaf_getdents( | |||
504 | xfs_dir2_off_t newoff; /* new curoff after new blk */ | 509 | xfs_dir2_off_t newoff; /* new curoff after new blk */ |
505 | char *ptr = NULL; /* pointer to current data */ | 510 | char *ptr = NULL; /* pointer to current data */ |
506 | struct xfs_dir2_leaf_map_info *map_info; | 511 | struct xfs_dir2_leaf_map_info *map_info; |
512 | struct xfs_da_geometry *geo; | ||
507 | 513 | ||
508 | /* | 514 | /* |
509 | * If the offset is at or past the largest allowed value, | 515 | * If the offset is at or past the largest allowed value, |
@@ -513,6 +519,7 @@ xfs_dir2_leaf_getdents( | |||
513 | return 0; | 519 | return 0; |
514 | 520 | ||
515 | mp = dp->i_mount; | 521 | mp = dp->i_mount; |
522 | geo = mp->m_dir_geo; | ||
516 | 523 | ||
517 | /* | 524 | /* |
518 | * Set up to bmap a number of blocks based on the caller's | 525 | * Set up to bmap a number of blocks based on the caller's |
@@ -536,8 +543,8 @@ xfs_dir2_leaf_getdents( | |||
536 | * Force this conversion through db so we truncate the offset | 543 | * Force this conversion through db so we truncate the offset |
537 | * down to get the start of the data block. | 544 | * down to get the start of the data block. |
538 | */ | 545 | */ |
539 | map_info->map_off = xfs_dir2_db_to_da(mp->m_dir_geo, | 546 | map_info->map_off = xfs_dir2_db_to_da(geo, |
540 | xfs_dir2_byte_to_db(mp, curoff)); | 547 | xfs_dir2_byte_to_db(geo, curoff)); |
541 | 548 | ||
542 | /* | 549 | /* |
543 | * Loop over directory entries until we reach the end offset. | 550 | * Loop over directory entries until we reach the end offset. |
@@ -571,7 +578,7 @@ xfs_dir2_leaf_getdents( | |||
571 | * Make sure we're in the right block. | 578 | * Make sure we're in the right block. |
572 | */ | 579 | */ |
573 | else if (curoff > newoff) | 580 | else if (curoff > newoff) |
574 | ASSERT(xfs_dir2_byte_to_db(mp, curoff) == | 581 | ASSERT(xfs_dir2_byte_to_db(geo, curoff) == |
575 | map_info->curdb); | 582 | map_info->curdb); |
576 | hdr = bp->b_addr; | 583 | hdr = bp->b_addr; |
577 | xfs_dir3_data_check(dp, bp); | 584 | xfs_dir3_data_check(dp, bp); |
@@ -608,8 +615,8 @@ xfs_dir2_leaf_getdents( | |||
608 | * Now set our real offset. | 615 | * Now set our real offset. |
609 | */ | 616 | */ |
610 | curoff = | 617 | curoff = |
611 | xfs_dir2_db_off_to_byte(mp->m_dir_geo, | 618 | xfs_dir2_db_off_to_byte(geo, |
612 | xfs_dir2_byte_to_db(mp, curoff), | 619 | xfs_dir2_byte_to_db(geo, curoff), |
613 | (char *)ptr - (char *)hdr); | 620 | (char *)ptr - (char *)hdr); |
614 | if (ptr >= (char *)hdr + mp->m_dirblksize) { | 621 | if (ptr >= (char *)hdr + mp->m_dirblksize) { |
615 | continue; | 622 | continue; |