aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ufs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-06-19 14:20:21 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-07-06 17:40:04 -0400
commit0385f1f9e3e5cb17047474037002500383237f47 (patch)
treef1eca598ec5d869fc05a3e8d243ab47a0a6f4182 /fs/ufs
parent5fbfb238f7a0a5c4633438eb5bdfb4810995c76a (diff)
ufs_getfrag_block(): tidy up a bit
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ufs')
-rw-r--r--fs/ufs/inode.c48
1 files changed, 15 insertions, 33 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index ed70147e1cb4..7f551b3e3ba4 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -398,40 +398,30 @@ out:
398 398
399static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head *bh_result, int create) 399static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buffer_head *bh_result, int create)
400{ 400{
401 struct super_block * sb = inode->i_sb; 401 struct super_block *sb = inode->i_sb;
402 struct ufs_sb_info * sbi = UFS_SB(sb); 402 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
403 struct ufs_sb_private_info * uspi = sbi->s_uspi; 403 int err = 0, new = 0;
404 struct buffer_head * bh;
405 int ret, err, new;
406 unsigned offsets[4]; 404 unsigned offsets[4];
407 int depth = ufs_block_to_path(inode, fragment >> uspi->s_fpbshift, offsets); 405 int depth = ufs_block_to_path(inode, fragment >> uspi->s_fpbshift, offsets);
408 unsigned long phys;
409 u64 phys64 = 0; 406 u64 phys64 = 0;
407 unsigned long phys;
410 unsigned frag = fragment & uspi->s_fpbmask; 408 unsigned frag = fragment & uspi->s_fpbmask;
411 409
412 if (!create) { 410 if (!create) {
413 phys64 = ufs_frag_map(inode, offsets, depth); 411 phys64 = ufs_frag_map(inode, offsets, depth);
414 if (phys64) { 412 goto out;
415 phys64 += frag;
416 map_bh(bh_result, sb, phys64);
417 }
418 return 0;
419 } 413 }
420 414
421 /* This code entered only while writing ....? */ 415 /* This code entered only while writing ....? */
422 416
423 err = -EIO;
424 new = 0;
425 ret = 0;
426 bh = NULL;
427
428 mutex_lock(&UFS_I(inode)->truncate_mutex); 417 mutex_lock(&UFS_I(inode)->truncate_mutex);
429 418
430 UFSD("ENTER, ino %lu, fragment %llu\n", inode->i_ino, (unsigned long long)fragment); 419 UFSD("ENTER, ino %lu, fragment %llu\n", inode->i_ino, (unsigned long long)fragment);
431 if (!depth) 420 if (unlikely(!depth)) {
432 goto abort_too_big; 421 ufs_warning(sb, "ufs_get_block", "block > big");
433 422 err = -EIO;
434 err = 0; 423 goto out;
424 }
435 425
436 if (UFS_I(inode)->i_lastfrag < UFS_NDIR_FRAGMENT) { 426 if (UFS_I(inode)->i_lastfrag < UFS_NDIR_FRAGMENT) {
437 unsigned lastfrag = UFS_I(inode)->i_lastfrag; 427 unsigned lastfrag = UFS_I(inode)->i_lastfrag;
@@ -439,7 +429,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
439 if (tailfrags && fragment >= lastfrag) { 429 if (tailfrags && fragment >= lastfrag) {
440 if (!ufs_extend_tail(inode, fragment, 430 if (!ufs_extend_tail(inode, fragment,
441 &err, bh_result->b_page)) 431 &err, bh_result->b_page))
442 goto abort; 432 goto out;
443 } 433 }
444 } 434 }
445 435
@@ -456,23 +446,15 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
456 phys64 = ufs_inode_getblock(inode, phys64, offsets[depth - 1], 446 phys64 = ufs_inode_getblock(inode, phys64, offsets[depth - 1],
457 fragment, &err, &phys, &new, bh_result->b_page); 447 fragment, &err, &phys, &new, bh_result->b_page);
458 } 448 }
449out:
459 if (phys64) { 450 if (phys64) {
460 phys64 += frag; 451 phys64 += frag;
461 phys = phys64; 452 map_bh(bh_result, sb, phys64);
453 if (new)
454 set_buffer_new(bh_result);
462 } 455 }
463 if (err)
464 goto abort;
465 if (new)
466 set_buffer_new(bh_result);
467 map_bh(bh_result, sb, phys);
468abort:
469 mutex_unlock(&UFS_I(inode)->truncate_mutex); 456 mutex_unlock(&UFS_I(inode)->truncate_mutex);
470
471 return err; 457 return err;
472
473abort_too_big:
474 ufs_warning(sb, "ufs_get_block", "block > big");
475 goto abort;
476} 458}
477 459
478static int ufs_writepage(struct page *page, struct writeback_control *wbc) 460static int ufs_writepage(struct page *page, struct writeback_control *wbc)