Skip to content

Commit 7b0b093

Browse files
committed
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>
1 parent ef6919c commit 7b0b093

1 file changed

Lines changed: 15 additions & 21 deletions

File tree

‎fs/udf/inode.c‎

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ static int udf_update_inode(struct inode *, int);
5353
static void udf_fill_inode(struct inode *, struct buffer_head *);
5454
static int udf_sync_inode(struct inode *inode);
5555
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 *);
5857
static int8_t udf_insert_aext(struct inode *, struct extent_position,
5958
struct kernel_lb_addr, uint32_t);
6059
static void udf_split_extents(struct inode *, int *, int, int,
@@ -310,7 +309,6 @@ static int udf_get_block(struct inode *inode, sector_t block,
310309
struct buffer_head *bh_result, int create)
311310
{
312311
int err, new;
313-
struct buffer_head *bh;
314312
sector_t phys = 0;
315313
struct udf_inode_info *iinfo;
316314

@@ -323,7 +321,6 @@ static int udf_get_block(struct inode *inode, sector_t block,
323321

324322
err = -EIO;
325323
new = 0;
326-
bh = NULL;
327324
iinfo = UDF_I(inode);
328325

329326
down_write(&iinfo->i_data_sem);
@@ -332,13 +329,10 @@ static int udf_get_block(struct inode *inode, sector_t block,
332329
iinfo->i_next_alloc_goal++;
333330
}
334331

335-
err = 0;
336332

337-
bh = inode_getblk(inode, block, &err, &phys, &new);
338-
BUG_ON(bh);
339-
if (err)
333+
phys = inode_getblk(inode, block, &err, &new);
334+
if (!phys)
340335
goto abort;
341-
BUG_ON(!phys);
342336

343337
if (new)
344338
set_buffer_new(bh_result);
@@ -547,11 +541,10 @@ static int udf_extend_file(struct inode *inode, loff_t newsize)
547541
return err;
548542
}
549543

550-
static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
551-
int *err, sector_t *phys, int *new)
544+
static sector_t inode_getblk(struct inode *inode, sector_t block,
545+
int *err, int *new)
552546
{
553547
static sector_t last_block;
554-
struct buffer_head *result = NULL;
555548
struct kernel_long_ad laarr[EXTENT_MERGE_SIZE];
556549
struct extent_position prev_epos, cur_epos, next_epos;
557550
int count = 0, startnum = 0, endnum = 0;
@@ -566,6 +559,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
566559
int goal = 0, pgoal = iinfo->i_location.logicalBlockNum;
567560
int lastblock = 0;
568561

562+
*err = 0;
563+
*new = 0;
569564
prev_epos.offset = udf_file_entry_alloc_offset(inode);
570565
prev_epos.block = iinfo->i_location;
571566
prev_epos.bh = NULL;
@@ -635,8 +630,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
635630
brelse(cur_epos.bh);
636631
brelse(next_epos.bh);
637632
newblock = udf_get_lb_pblock(inode->i_sb, &eloc, offset);
638-
*phys = newblock;
639-
return NULL;
633+
return newblock;
640634
}
641635

642636
last_block = block;
@@ -664,7 +658,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
664658
brelse(cur_epos.bh);
665659
brelse(next_epos.bh);
666660
*err = ret;
667-
return NULL;
661+
return 0;
668662
}
669663
c = 0;
670664
offset = 0;
@@ -729,7 +723,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
729723
if (!newblocknum) {
730724
brelse(prev_epos.bh);
731725
*err = -ENOSPC;
732-
return NULL;
726+
return 0;
733727
}
734728
iinfo->i_lenExtents += inode->i_sb->s_blocksize;
735729
}
@@ -761,10 +755,10 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
761755

762756
newblock = udf_get_pblock(inode->i_sb, newblocknum,
763757
iinfo->i_location.partitionReferenceNum, 0);
764-
if (!newblock)
765-
return NULL;
766-
*phys = newblock;
767-
*err = 0;
758+
if (!newblock) {
759+
*err = -EIO;
760+
return 0;
761+
}
768762
*new = 1;
769763
iinfo->i_next_alloc_block = block;
770764
iinfo->i_next_alloc_goal = newblocknum;
@@ -775,7 +769,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
775769
else
776770
mark_inode_dirty(inode);
777771

778-
return result;
772+
return newblock;
779773
}
780774

781775
static void udf_split_extents(struct inode *inode, int *c, int offset,

0 commit comments

Comments
 (0)