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

udf: Unify types in anchor block detection

When detecting last recorded block and from it derived anchor block
position, we were mixing unsigned long, u32, and sector_t types. Since
udf supports only 32-bit block numbers this is harmless but sometimes
makes things awkward. Convert everything to udf_pblk_t and also handle
the situation when block device size would not fit into udf_pblk_t.

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

Jan Kara bd904f3c 1ea1cd11

+8 -5
+5 -2
fs/udf/lowlevel.c
··· 45 45 return 0; 46 46 } 47 47 48 - unsigned long udf_get_last_block(struct super_block *sb) 48 + udf_pblk_t udf_get_last_block(struct super_block *sb) 49 49 { 50 50 struct cdrom_device_info *cdi = disk_to_cdi(sb->s_bdev->bd_disk); 51 51 unsigned long lblock = 0; ··· 54 54 * The cdrom layer call failed or returned obviously bogus value? 55 55 * Try using the device size... 56 56 */ 57 - if (!cdi || cdrom_get_last_written(cdi, &lblock) || lblock == 0) 57 + if (!cdi || cdrom_get_last_written(cdi, &lblock) || lblock == 0) { 58 + if (sb_bdev_nr_blocks(sb) > ~(udf_pblk_t)0) 59 + return 0; 58 60 lblock = sb_bdev_nr_blocks(sb); 61 + } 59 62 60 63 if (lblock) 61 64 return lblock - 1;
+2 -2
fs/udf/super.c
··· 1861 1861 * Returns < 0 on error, 0 on success. -EAGAIN is special - try next set 1862 1862 * of anchors. 1863 1863 */ 1864 - static int udf_scan_anchors(struct super_block *sb, sector_t *lastblock, 1864 + static int udf_scan_anchors(struct super_block *sb, udf_pblk_t *lastblock, 1865 1865 struct kernel_lb_addr *fileset) 1866 1866 { 1867 - sector_t last[6]; 1867 + udf_pblk_t last[6]; 1868 1868 int i; 1869 1869 struct udf_sb_info *sbi = UDF_SB(sb); 1870 1870 int last_count = 0;
+1 -1
fs/udf/udfdecl.h
··· 196 196 197 197 /* lowlevel.c */ 198 198 extern unsigned int udf_get_last_session(struct super_block *); 199 - extern unsigned long udf_get_last_block(struct super_block *); 199 + udf_pblk_t udf_get_last_block(struct super_block *); 200 200 201 201 /* partition.c */ 202 202 extern uint32_t udf_get_pblock(struct super_block *, uint32_t, uint16_t,