Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

udf: Cleanup calling convention of inode_getblk()

inode_getblk() always returned NULL and passed results in its parameters.
Make the function return something useful - found block number.

Signed-off-by: Jan Kara <jack@suse.cz>

Jan Kara 7b0b0933 ef6919c2

+15 -21
+15 -21
fs/udf/inode.c
··· 53 53 static void udf_fill_inode(struct inode *, struct buffer_head *); 54 54 static int udf_sync_inode(struct inode *inode); 55 55 static int udf_alloc_i_data(struct inode *inode, size_t size); 56 - static struct buffer_head *inode_getblk(struct inode *, sector_t, int *, 57 - sector_t *, int *); 56 + static sector_t inode_getblk(struct inode *, sector_t, int *, int *); 58 57 static int8_t udf_insert_aext(struct inode *, struct extent_position, 59 58 struct kernel_lb_addr, uint32_t); 60 59 static void udf_split_extents(struct inode *, int *, int, int, ··· 309 310 struct buffer_head *bh_result, int create) 310 311 { 311 312 int err, new; 312 - struct buffer_head *bh; 313 313 sector_t phys = 0; 314 314 struct udf_inode_info *iinfo; 315 315 ··· 321 323 322 324 err = -EIO; 323 325 new = 0; 324 - bh = NULL; 325 326 iinfo = UDF_I(inode); 326 327 327 328 down_write(&iinfo->i_data_sem); ··· 329 332 iinfo->i_next_alloc_goal++; 330 333 } 331 334 332 - err = 0; 333 335 334 - bh = inode_getblk(inode, block, &err, &phys, &new); 335 - BUG_ON(bh); 336 - if (err) 336 + phys = inode_getblk(inode, block, &err, &new); 337 + if (!phys) 337 338 goto abort; 338 - BUG_ON(!phys); 339 339 340 340 if (new) 341 341 set_buffer_new(bh_result); ··· 541 547 return err; 542 548 } 543 549 544 - static struct buffer_head *inode_getblk(struct inode *inode, sector_t block, 545 - int *err, sector_t *phys, int *new) 550 + static sector_t inode_getblk(struct inode *inode, sector_t block, 551 + int *err, int *new) 546 552 { 547 553 static sector_t last_block; 548 - struct buffer_head *result = NULL; 549 554 struct kernel_long_ad laarr[EXTENT_MERGE_SIZE]; 550 555 struct extent_position prev_epos, cur_epos, next_epos; 551 556 int count = 0, startnum = 0, endnum = 0; ··· 559 566 int goal = 0, pgoal = iinfo->i_location.logicalBlockNum; 560 567 int lastblock = 0; 561 568 569 + *err = 0; 570 + *new = 0; 562 571 prev_epos.offset = udf_file_entry_alloc_offset(inode); 563 572 prev_epos.block = iinfo->i_location; 564 573 prev_epos.bh = NULL; ··· 630 635 brelse(cur_epos.bh); 631 636 brelse(next_epos.bh); 632 637 newblock = udf_get_lb_pblock(inode->i_sb, &eloc, offset); 633 - *phys = newblock; 634 - return NULL; 638 + return newblock; 635 639 } 636 640 637 641 last_block = block; ··· 658 664 brelse(cur_epos.bh); 659 665 brelse(next_epos.bh); 660 666 *err = ret; 661 - return NULL; 667 + return 0; 662 668 } 663 669 c = 0; 664 670 offset = 0; ··· 723 729 if (!newblocknum) { 724 730 brelse(prev_epos.bh); 725 731 *err = -ENOSPC; 726 - return NULL; 732 + return 0; 727 733 } 728 734 iinfo->i_lenExtents += inode->i_sb->s_blocksize; 729 735 } ··· 755 761 756 762 newblock = udf_get_pblock(inode->i_sb, newblocknum, 757 763 iinfo->i_location.partitionReferenceNum, 0); 758 - if (!newblock) 759 - return NULL; 760 - *phys = newblock; 761 - *err = 0; 764 + if (!newblock) { 765 + *err = -EIO; 766 + return 0; 767 + } 762 768 *new = 1; 763 769 iinfo->i_next_alloc_block = block; 764 770 iinfo->i_next_alloc_goal = newblocknum; ··· 769 775 else 770 776 mark_inode_dirty(inode); 771 777 772 - return result; 778 + return newblock; 773 779 } 774 780 775 781 static void udf_split_extents(struct inode *inode, int *c, int offset,