forked from Minki/linux
udf: use sb_bdev_nr_blocks
Use the sb_bdev_nr_blocks helper instead of open coding it. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20211018101130.1838532-31-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
2ffae493dc
commit
e4ae4735f7
@ -47,8 +47,7 @@ unsigned int udf_get_last_session(struct super_block *sb)
|
||||
|
||||
unsigned long udf_get_last_block(struct super_block *sb)
|
||||
{
|
||||
struct block_device *bdev = sb->s_bdev;
|
||||
struct cdrom_device_info *cdi = disk_to_cdi(bdev->bd_disk);
|
||||
struct cdrom_device_info *cdi = disk_to_cdi(sb->s_bdev->bd_disk);
|
||||
unsigned long lblock = 0;
|
||||
|
||||
/*
|
||||
@ -56,7 +55,7 @@ unsigned long udf_get_last_block(struct super_block *sb)
|
||||
* Try using the device size...
|
||||
*/
|
||||
if (!cdi || cdrom_get_last_written(cdi, &lblock) || lblock == 0)
|
||||
lblock = i_size_read(bdev->bd_inode) >> sb->s_blocksize_bits;
|
||||
lblock = sb_bdev_nr_blocks(sb);
|
||||
|
||||
if (lblock)
|
||||
return lblock - 1;
|
||||
|
@ -1175,8 +1175,7 @@ static int udf_load_vat(struct super_block *sb, int p_index, int type1_index)
|
||||
struct udf_inode_info *vati;
|
||||
uint32_t pos;
|
||||
struct virtualAllocationTable20 *vat20;
|
||||
sector_t blocks = i_size_read(sb->s_bdev->bd_inode) >>
|
||||
sb->s_blocksize_bits;
|
||||
sector_t blocks = sb_bdev_nr_blocks(sb);
|
||||
|
||||
udf_find_vat_block(sb, p_index, type1_index, sbi->s_last_block);
|
||||
if (!sbi->s_vat_inode &&
|
||||
@ -1838,8 +1837,7 @@ static int udf_check_anchor_block(struct super_block *sb, sector_t block,
|
||||
int ret;
|
||||
|
||||
if (UDF_QUERY_FLAG(sb, UDF_FLAG_VARCONV) &&
|
||||
udf_fixed_to_variable(block) >=
|
||||
i_size_read(sb->s_bdev->bd_inode) >> sb->s_blocksize_bits)
|
||||
udf_fixed_to_variable(block) >= sb_bdev_nr_blocks(sb))
|
||||
return -EAGAIN;
|
||||
|
||||
bh = udf_read_tagged(sb, block, block, &ident);
|
||||
@ -1901,8 +1899,7 @@ static int udf_scan_anchors(struct super_block *sb, sector_t *lastblock,
|
||||
last[last_count++] = *lastblock - 152;
|
||||
|
||||
for (i = 0; i < last_count; i++) {
|
||||
if (last[i] >= i_size_read(sb->s_bdev->bd_inode) >>
|
||||
sb->s_blocksize_bits)
|
||||
if (last[i] >= sb_bdev_nr_blocks(sb))
|
||||
continue;
|
||||
ret = udf_check_anchor_block(sb, last[i], fileset);
|
||||
if (ret != -EAGAIN) {
|
||||
|
Loading…
Reference in New Issue
Block a user