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

fs/affs: make root lookup from blkdev logical size

This patch resolves https://bugzilla.kernel.org/show_bug.cgi?id=16531.

When logical blkdev size > 512 then sector numbers become larger than the
device can support.

Make affs start lookup based on the device's logical sector size instead
of 512.

Reported-by: Mark <markk@clara.co.uk>
Suggested-by: Mark <markk@clara.co.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Pranay Kr. Srivastava and committed by
Linus Torvalds
e852d82a 9a5bc726

+5 -3
+5 -3
fs/affs/super.c
··· 18 18 #include <linux/sched.h> 19 19 #include <linux/slab.h> 20 20 #include <linux/writeback.h> 21 + #include <linux/blkdev.h> 21 22 #include "affs.h" 22 23 23 24 static int affs_statfs(struct dentry *dentry, struct kstatfs *buf); ··· 353 352 * blocks, we will have to change it. 354 353 */ 355 354 356 - size = sb->s_bdev->bd_inode->i_size >> 9; 355 + size = i_size_read(sb->s_bdev->bd_inode) >> 9; 357 356 pr_debug("initial blocksize=%d, #blocks=%d\n", 512, size); 358 357 359 358 affs_set_blocksize(sb, PAGE_SIZE); 360 359 /* Try to find root block. Its location depends on the block size. */ 361 360 362 - i = 512; 363 - j = 4096; 361 + i = bdev_logical_block_size(sb->s_bdev); 362 + j = PAGE_SIZE; 364 363 if (blocksize > 0) { 365 364 i = j = blocksize; 366 365 size = size / (blocksize / 512); 367 366 } 367 + 368 368 for (blocksize = i; blocksize <= j; blocksize <<= 1, size >>= 1) { 369 369 sbi->s_root_block = root_block; 370 370 if (root_block < 0)