Skip to content

Commit

Permalink
udf: atomically read inode size
Browse files Browse the repository at this point in the history
See i_size_read() comments in include/linux/fs.h

Signed-off-by: Fabian Frederick <[email protected]>
Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
Fabian Frederick authored and jankara committed Jan 10, 2017
1 parent 54bb60d commit 23bcda1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fs/udf/lowlevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ unsigned long udf_get_last_block(struct super_block *sb)
*/
if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock) ||
lblock == 0)
lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits;
lblock = i_size_read(bdev->bd_inode) >> sb->s_blocksize_bits;

if (lblock)
return lblock - 1;
Expand Down
7 changes: 4 additions & 3 deletions fs/udf/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,8 @@ 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 = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits;
sector_t blocks = i_size_read(sb->s_bdev->bd_inode) >>
sb->s_blocksize_bits;

udf_find_vat_block(sb, p_index, type1_index, sbi->s_last_block);
if (!sbi->s_vat_inode &&
Expand Down Expand Up @@ -1803,7 +1804,7 @@ static int udf_check_anchor_block(struct super_block *sb, sector_t block,

if (UDF_QUERY_FLAG(sb, UDF_FLAG_VARCONV) &&
udf_fixed_to_variable(block) >=
sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits)
i_size_read(sb->s_bdev->bd_inode) >> sb->s_blocksize_bits)
return -EAGAIN;

bh = udf_read_tagged(sb, block, block, &ident);
Expand Down Expand Up @@ -1865,7 +1866,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] >= sb->s_bdev->bd_inode->i_size >>
if (last[i] >= i_size_read(sb->s_bdev->bd_inode) >>
sb->s_blocksize_bits)
continue;
ret = udf_check_anchor_block(sb, last[i], fileset);
Expand Down

0 comments on commit 23bcda1

Please sign in to comment.