aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ufs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-06-19 01:23:08 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-07-06 17:39:59 -0400
commit619cfac09134b4de7a4f232cf3636cf43728577d (patch)
tree61454e66f2ab53e02d08cf2d52dda487aa7de1d4 /fs/ufs
parent721435a7679e13f810133dbea769f87ad7bae3a1 (diff)
ufs_inode_getblock(): pass indirect block number and full index
... instead of messing with buffer_head. We can bloody well do sb_bread() in there. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ufs')
-rw-r--r--fs/ufs/inode.c62
1 files changed, 16 insertions, 46 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 6866b904f148..25d47df934e2 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -337,8 +337,8 @@ repeat2:
337/** 337/**
338 * ufs_inode_getblock() - allocate new block 338 * ufs_inode_getblock() - allocate new block
339 * @inode: pointer to inode 339 * @inode: pointer to inode
340 * @bh: pointer to block which hold "pointer" to new allocated block 340 * @ind_block: block number of the indirect block
341 * @index: number of pointer in the indirect block 341 * @index: number of pointer within the indirect block
342 * @new_fragment: number of new allocated fragment 342 * @new_fragment: number of new allocated fragment
343 * (block will hold this fragment and also uspi->s_fpb-1) 343 * (block will hold this fragment and also uspi->s_fpb-1)
344 * @err: see ufs_inode_getfrag() 344 * @err: see ufs_inode_getfrag()
@@ -347,23 +347,25 @@ repeat2:
347 * @locked_page: see ufs_inode_getfrag() 347 * @locked_page: see ufs_inode_getfrag()
348 */ 348 */
349static u64 349static u64
350ufs_inode_getblock(struct inode *inode, struct buffer_head *bh, 350ufs_inode_getblock(struct inode *inode, u64 ind_block,
351 unsigned index, sector_t new_fragment, int *err, 351 unsigned index, sector_t new_fragment, int *err,
352 long *phys, int *new, struct page *locked_page) 352 long *phys, int *new, struct page *locked_page)
353{ 353{
354 struct super_block *sb = inode->i_sb; 354 struct super_block *sb = inode->i_sb;
355 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; 355 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
356 int shift = uspi->s_apbshift - uspi->s_fpbshift;
356 u64 tmp = 0, goal; 357 u64 tmp = 0, goal;
358 struct buffer_head *bh;
357 void *p; 359 void *p;
358 360
359 if (!bh) 361 if (!ind_block)
360 goto out; 362 return 0;
361 if (!buffer_uptodate(bh)) { 363
362 ll_rw_block (READ, 1, &bh); 364 bh = sb_bread(sb, ind_block + (index >> shift));
363 wait_on_buffer (bh); 365 if (unlikely(!bh))
364 if (!buffer_uptodate(bh)) 366 return 0;
365 goto out; 367
366 } 368 index &= uspi->s_apbmask >> uspi->s_fpbshift;
367 if (uspi->fs_magic == UFS2_MAGIC) 369 if (uspi->fs_magic == UFS2_MAGIC)
368 p = (__fs64 *)bh->b_data + index; 370 p = (__fs64 *)bh->b_data + index;
369 else 371 else
@@ -459,12 +461,6 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
459 UFS_IND_FRAGMENT + (ptr >> uspi->s_apbshift), 461 UFS_IND_FRAGMENT + (ptr >> uspi->s_apbshift),
460 fragment, uspi->s_fpb, &err, NULL, NULL, 462 fragment, uspi->s_fpb, &err, NULL, NULL,
461 bh_result->b_page); 463 bh_result->b_page);
462 if (phys64) {
463 phys64 += (ptr >> uspi->s_apbshift) & uspi->s_fpbmask;
464 bh = sb_getblk(sb, phys64);
465 } else {
466 bh = NULL;
467 }
468 goto get_indirect; 464 goto get_indirect;
469 } 465 }
470 ptr -= 1 << (uspi->s_apbshift + uspi->s_fpbshift); 466 ptr -= 1 << (uspi->s_apbshift + uspi->s_fpbshift);
@@ -473,12 +469,6 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
473 UFS_DIND_FRAGMENT + (ptr >> uspi->s_2apbshift), 469 UFS_DIND_FRAGMENT + (ptr >> uspi->s_2apbshift),
474 fragment, uspi->s_fpb, &err, NULL, NULL, 470 fragment, uspi->s_fpb, &err, NULL, NULL,
475 bh_result->b_page); 471 bh_result->b_page);
476 if (phys64) {
477 phys64 += (ptr >> uspi->s_2apbshift) & uspi->s_fpbmask;
478 bh = sb_getblk(sb, phys64);
479 } else {
480 bh = NULL;
481 }
482 goto get_double; 472 goto get_double;
483 } 473 }
484 ptr -= 1 << (uspi->s_2apbshift + uspi->s_fpbshift); 474 ptr -= 1 << (uspi->s_2apbshift + uspi->s_fpbshift);
@@ -486,33 +476,13 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
486 UFS_TIND_FRAGMENT + (ptr >> uspi->s_3apbshift), 476 UFS_TIND_FRAGMENT + (ptr >> uspi->s_3apbshift),
487 fragment, uspi->s_fpb, &err, NULL, NULL, 477 fragment, uspi->s_fpb, &err, NULL, NULL,
488 bh_result->b_page); 478 bh_result->b_page);
489 if (phys64) { 479 phys64 = ufs_inode_getblock(inode, phys64, offsets[1],
490 phys64 += (ptr >> uspi->s_3apbshift) & uspi->s_fpbmask;
491 bh = sb_getblk(sb, phys64);
492 } else {
493 bh = NULL;
494 }
495 phys64 = ufs_inode_getblock(inode, bh,
496 offsets[1] & mask,
497 fragment, &err, NULL, NULL, NULL); 480 fragment, &err, NULL, NULL, NULL);
498 if (phys64) {
499 phys64 += (ptr >> uspi->s_2apbshift) & uspi->s_fpbmask,
500 bh = sb_getblk(sb, phys64);
501 } else {
502 bh = NULL;
503 }
504get_double: 481get_double:
505 phys64 = ufs_inode_getblock(inode, bh, 482 phys64 = ufs_inode_getblock(inode, phys64, offsets[depth - 2],
506 offsets[depth - 2] & mask,
507 fragment, &err, NULL, NULL, NULL); 483 fragment, &err, NULL, NULL, NULL);
508 if (phys64) {
509 phys64 += (ptr >> uspi->s_apbshift) & uspi->s_fpbmask,
510 bh = sb_getblk(sb, phys64);
511 } else {
512 bh = NULL;
513 }
514get_indirect: 484get_indirect:
515 phys64 = ufs_inode_getblock(inode, bh, offsets[depth - 1] & mask, 485 phys64 = ufs_inode_getblock(inode, phys64, offsets[depth - 1],
516 fragment, &err, &phys, &new, bh_result->b_page); 486 fragment, &err, &phys, &new, bh_result->b_page);
517 if (phys64) { 487 if (phys64) {
518 phys64 += frag; 488 phys64 += frag;