summaryrefslogtreecommitdiff
path: root/fs/udf
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2023-01-18 15:33:41 +0100
committerJan Kara <jack@suse.cz>2023-01-26 16:46:33 +0100
commit32f123a3f34283f9c6446de87861696f0502b02e (patch)
tree6bb98dd35ae5854fef2abe52cf25e577d6b09b01 /fs/udf
parent541e047b14c8f07de05262fce948ee7667117986 (diff)
downloadlinux-32f123a3f34283f9c6446de87861696f0502b02e.tar.gz
udf: Fold udf_getblk() into udf_bread()
udf_getblk() has a single call site. Fold it there. Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/udf')
-rw-r--r--fs/udf/inode.c47
1 files changed, 20 insertions, 27 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index d3877a356715..adef328c4278 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -401,31 +401,6 @@ static int udf_get_block(struct inode *inode, sector_t block,
return 0;
}
-static struct buffer_head *udf_getblk(struct inode *inode, udf_pblk_t block,
- int create, int *err)
-{
- struct buffer_head *bh;
- struct udf_map_rq map = {
- .lblk = block,
- .iflags = UDF_MAP_NOPREALLOC | (create ? UDF_MAP_CREATE : 0),
- };
-
- *err = udf_map_block(inode, &map);
- if (!*err && map.oflags & UDF_BLK_MAPPED) {
- bh = sb_getblk(inode->i_sb, map.pblk);
- if (map.oflags & UDF_BLK_NEW) {
- lock_buffer(bh);
- memset(bh->b_data, 0x00, inode->i_sb->s_blocksize);
- set_buffer_uptodate(bh);
- unlock_buffer(bh);
- mark_buffer_dirty_inode(bh, inode);
- }
- return bh;
- }
-
- return NULL;
-}
-
/* Extend the file with new blocks totaling 'new_block_bytes',
* return the number of extents added
*/
@@ -1140,11 +1115,29 @@ struct buffer_head *udf_bread(struct inode *inode, udf_pblk_t block,
int create, int *err)
{
struct buffer_head *bh = NULL;
+ struct udf_map_rq map = {
+ .lblk = block,
+ .iflags = UDF_MAP_NOPREALLOC | (create ? UDF_MAP_CREATE : 0),
+ };
- bh = udf_getblk(inode, block, create, err);
- if (!bh)
+ *err = udf_map_block(inode, &map);
+ if (*err || !(map.oflags & UDF_BLK_MAPPED))
return NULL;
+ bh = sb_getblk(inode->i_sb, map.pblk);
+ if (!bh) {
+ *err = -ENOMEM;
+ return NULL;
+ }
+ if (map.oflags & UDF_BLK_NEW) {
+ lock_buffer(bh);
+ memset(bh->b_data, 0x00, inode->i_sb->s_blocksize);
+ set_buffer_uptodate(bh);
+ unlock_buffer(bh);
+ mark_buffer_dirty_inode(bh, inode);
+ return bh;
+ }
+
if (bh_read(bh, 0) >= 0)
return bh;