diff options
Diffstat (limited to 'fs/hpfs/map.c')
-rw-r--r-- | fs/hpfs/map.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/fs/hpfs/map.c b/fs/hpfs/map.c index 4acb19d78359..3aa66ae1031e 100644 --- a/fs/hpfs/map.c +++ b/fs/hpfs/map.c | |||
@@ -17,7 +17,9 @@ __le32 *hpfs_map_bitmap(struct super_block *s, unsigned bmp_block, | |||
17 | struct quad_buffer_head *qbh, char *id) | 17 | struct quad_buffer_head *qbh, char *id) |
18 | { | 18 | { |
19 | secno sec; | 19 | secno sec; |
20 | if (hpfs_sb(s)->sb_chk) if (bmp_block * 16384 > hpfs_sb(s)->sb_fs_size) { | 20 | __le32 *ret; |
21 | unsigned n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14; | ||
22 | if (hpfs_sb(s)->sb_chk) if (bmp_block >= n_bands) { | ||
21 | hpfs_error(s, "hpfs_map_bitmap called with bad parameter: %08x at %s", bmp_block, id); | 23 | hpfs_error(s, "hpfs_map_bitmap called with bad parameter: %08x at %s", bmp_block, id); |
22 | return NULL; | 24 | return NULL; |
23 | } | 25 | } |
@@ -26,7 +28,23 @@ __le32 *hpfs_map_bitmap(struct super_block *s, unsigned bmp_block, | |||
26 | hpfs_error(s, "invalid bitmap block pointer %08x -> %08x at %s", bmp_block, sec, id); | 28 | hpfs_error(s, "invalid bitmap block pointer %08x -> %08x at %s", bmp_block, sec, id); |
27 | return NULL; | 29 | return NULL; |
28 | } | 30 | } |
29 | return hpfs_map_4sectors(s, sec, qbh, 4); | 31 | ret = hpfs_map_4sectors(s, sec, qbh, 4); |
32 | if (ret) hpfs_prefetch_bitmap(s, bmp_block + 1); | ||
33 | return ret; | ||
34 | } | ||
35 | |||
36 | void hpfs_prefetch_bitmap(struct super_block *s, unsigned bmp_block) | ||
37 | { | ||
38 | unsigned to_prefetch, next_prefetch; | ||
39 | unsigned n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14; | ||
40 | if (unlikely(bmp_block >= n_bands)) | ||
41 | return; | ||
42 | to_prefetch = le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[bmp_block]); | ||
43 | if (unlikely(bmp_block + 1 >= n_bands)) | ||
44 | next_prefetch = 0; | ||
45 | else | ||
46 | next_prefetch = le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[bmp_block + 1]); | ||
47 | hpfs_prefetch_sectors(s, to_prefetch, 4 + 4 * (to_prefetch + 4 == next_prefetch)); | ||
30 | } | 48 | } |
31 | 49 | ||
32 | /* | 50 | /* |