diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-06-19 01:06:21 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-07-06 17:39:58 -0400 |
commit | 721435a7679e13f810133dbea769f87ad7bae3a1 (patch) | |
tree | 54dcf11089989e1536cb2bcc612ffccba44c20d7 /fs/ufs | |
parent | 177848a018cb2cb196feac2990814ac8d7bb3c8e (diff) |
ufs_inode_getblock(): pass index instead of 'fragment'
The value passed to ufs_inode_getblock() as the 3rd argument
had lower bits ignored; the upper bits were shifted down
and used and they actually make sense - those are _lower_ bits
of index in indirect block (i.e. they form the index within
a fragment within an indirect block).
Pass those as argument. Upper bits of index (i.e. the number
of fragment within indirect block) will join them shortly.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ufs')
-rw-r--r-- | fs/ufs/inode.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index eeccf45fcd57..6866b904f148 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c | |||
@@ -338,8 +338,7 @@ repeat2: | |||
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 | * @bh: pointer to block which hold "pointer" to new allocated block |
341 | * @fragment: number of `fragment' which hold pointer | 341 | * @index: number of pointer in the indirect block |
342 | * to new allocated block | ||
343 | * @new_fragment: number of new allocated fragment | 342 | * @new_fragment: number of new allocated fragment |
344 | * (block will hold this fragment and also uspi->s_fpb-1) | 343 | * (block will hold this fragment and also uspi->s_fpb-1) |
345 | * @err: see ufs_inode_getfrag() | 344 | * @err: see ufs_inode_getfrag() |
@@ -349,20 +348,14 @@ repeat2: | |||
349 | */ | 348 | */ |
350 | static u64 | 349 | static u64 |
351 | ufs_inode_getblock(struct inode *inode, struct buffer_head *bh, | 350 | ufs_inode_getblock(struct inode *inode, struct buffer_head *bh, |
352 | u64 fragment, sector_t new_fragment, int *err, | 351 | unsigned index, sector_t new_fragment, int *err, |
353 | long *phys, int *new, struct page *locked_page) | 352 | long *phys, int *new, struct page *locked_page) |
354 | { | 353 | { |
355 | struct super_block *sb = inode->i_sb; | 354 | struct super_block *sb = inode->i_sb; |
356 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; | 355 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; |
357 | u64 tmp = 0, goal, block; | 356 | u64 tmp = 0, goal; |
358 | void *p; | 357 | void *p; |
359 | 358 | ||
360 | block = ufs_fragstoblks (fragment); | ||
361 | |||
362 | UFSD("ENTER, ino %lu, fragment %llu, new_fragment %llu, metadata %d\n", | ||
363 | inode->i_ino, (unsigned long long)fragment, | ||
364 | (unsigned long long)new_fragment, !phys); | ||
365 | |||
366 | if (!bh) | 359 | if (!bh) |
367 | goto out; | 360 | goto out; |
368 | if (!buffer_uptodate(bh)) { | 361 | if (!buffer_uptodate(bh)) { |
@@ -372,17 +365,17 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh, | |||
372 | goto out; | 365 | goto out; |
373 | } | 366 | } |
374 | if (uspi->fs_magic == UFS2_MAGIC) | 367 | if (uspi->fs_magic == UFS2_MAGIC) |
375 | p = (__fs64 *)bh->b_data + block; | 368 | p = (__fs64 *)bh->b_data + index; |
376 | else | 369 | else |
377 | p = (__fs32 *)bh->b_data + block; | 370 | p = (__fs32 *)bh->b_data + index; |
378 | 371 | ||
379 | tmp = ufs_data_ptr_to_cpu(sb, p); | 372 | tmp = ufs_data_ptr_to_cpu(sb, p); |
380 | if (tmp) | 373 | if (tmp) |
381 | goto out; | 374 | goto out; |
382 | 375 | ||
383 | if (block && (uspi->fs_magic == UFS2_MAGIC ? | 376 | if (index && (uspi->fs_magic == UFS2_MAGIC ? |
384 | (tmp = fs64_to_cpu(sb, ((__fs64 *)bh->b_data)[block-1])) : | 377 | (tmp = fs64_to_cpu(sb, ((__fs64 *)bh->b_data)[index-1])) : |
385 | (tmp = fs32_to_cpu(sb, ((__fs32 *)bh->b_data)[block-1])))) | 378 | (tmp = fs32_to_cpu(sb, ((__fs32 *)bh->b_data)[index-1])))) |
386 | goal = tmp + uspi->s_fpb; | 379 | goal = tmp + uspi->s_fpb; |
387 | else | 380 | else |
388 | goal = bh->b_blocknr + uspi->s_fpb; | 381 | goal = bh->b_blocknr + uspi->s_fpb; |
@@ -424,6 +417,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff | |||
424 | unsigned long ptr,phys; | 417 | unsigned long ptr,phys; |
425 | u64 phys64 = 0; | 418 | u64 phys64 = 0; |
426 | unsigned frag = fragment & uspi->s_fpbmask; | 419 | unsigned frag = fragment & uspi->s_fpbmask; |
420 | unsigned mask = uspi->s_apbmask >> uspi->s_fpbshift; | ||
427 | 421 | ||
428 | if (!create) { | 422 | if (!create) { |
429 | phys64 = ufs_frag_map(inode, offsets, depth); | 423 | phys64 = ufs_frag_map(inode, offsets, depth); |
@@ -499,7 +493,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff | |||
499 | bh = NULL; | 493 | bh = NULL; |
500 | } | 494 | } |
501 | phys64 = ufs_inode_getblock(inode, bh, | 495 | phys64 = ufs_inode_getblock(inode, bh, |
502 | (ptr >> uspi->s_2apbshift) & uspi->s_apbmask, | 496 | offsets[1] & mask, |
503 | fragment, &err, NULL, NULL, NULL); | 497 | fragment, &err, NULL, NULL, NULL); |
504 | if (phys64) { | 498 | if (phys64) { |
505 | phys64 += (ptr >> uspi->s_2apbshift) & uspi->s_fpbmask, | 499 | phys64 += (ptr >> uspi->s_2apbshift) & uspi->s_fpbmask, |
@@ -509,7 +503,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff | |||
509 | } | 503 | } |
510 | get_double: | 504 | get_double: |
511 | phys64 = ufs_inode_getblock(inode, bh, | 505 | phys64 = ufs_inode_getblock(inode, bh, |
512 | (ptr >> uspi->s_apbshift) & uspi->s_apbmask, | 506 | offsets[depth - 2] & mask, |
513 | fragment, &err, NULL, NULL, NULL); | 507 | fragment, &err, NULL, NULL, NULL); |
514 | if (phys64) { | 508 | if (phys64) { |
515 | phys64 += (ptr >> uspi->s_apbshift) & uspi->s_fpbmask, | 509 | phys64 += (ptr >> uspi->s_apbshift) & uspi->s_fpbmask, |
@@ -518,8 +512,8 @@ get_double: | |||
518 | bh = NULL; | 512 | bh = NULL; |
519 | } | 513 | } |
520 | get_indirect: | 514 | get_indirect: |
521 | phys64 = ufs_inode_getblock(inode, bh, ptr & uspi->s_apbmask, fragment, | 515 | phys64 = ufs_inode_getblock(inode, bh, offsets[depth - 1] & mask, |
522 | &err, &phys, &new, bh_result->b_page); | 516 | fragment, &err, &phys, &new, bh_result->b_page); |
523 | if (phys64) { | 517 | if (phys64) { |
524 | phys64 += frag; | 518 | phys64 += frag; |
525 | phys = phys64; | 519 | phys = phys64; |