diff options
Diffstat (limited to 'fs/hpfs')
-rw-r--r-- | fs/hpfs/buffer.c | 33 | ||||
-rw-r--r-- | fs/hpfs/dentry.c | 7 | ||||
-rw-r--r-- | fs/hpfs/dir.c | 56 | ||||
-rw-r--r-- | fs/hpfs/file.c | 40 | ||||
-rw-r--r-- | fs/hpfs/hpfs_fn.h | 7 | ||||
-rw-r--r-- | fs/hpfs/map.c | 22 | ||||
-rw-r--r-- | fs/hpfs/super.c | 17 |
7 files changed, 137 insertions, 45 deletions
diff --git a/fs/hpfs/buffer.c b/fs/hpfs/buffer.c index f49d1498aa2e..4d0a1afa058c 100644 --- a/fs/hpfs/buffer.c +++ b/fs/hpfs/buffer.c | |||
@@ -7,8 +7,37 @@ | |||
7 | */ | 7 | */ |
8 | #include <linux/sched.h> | 8 | #include <linux/sched.h> |
9 | #include <linux/slab.h> | 9 | #include <linux/slab.h> |
10 | #include <linux/blkdev.h> | ||
10 | #include "hpfs_fn.h" | 11 | #include "hpfs_fn.h" |
11 | 12 | ||
13 | void hpfs_prefetch_sectors(struct super_block *s, unsigned secno, int n) | ||
14 | { | ||
15 | struct buffer_head *bh; | ||
16 | struct blk_plug plug; | ||
17 | |||
18 | if (n <= 0 || unlikely(secno >= hpfs_sb(s)->sb_fs_size)) | ||
19 | return; | ||
20 | |||
21 | bh = sb_find_get_block(s, secno); | ||
22 | if (bh) { | ||
23 | if (buffer_uptodate(bh)) { | ||
24 | brelse(bh); | ||
25 | return; | ||
26 | } | ||
27 | brelse(bh); | ||
28 | }; | ||
29 | |||
30 | blk_start_plug(&plug); | ||
31 | while (n > 0) { | ||
32 | if (unlikely(secno >= hpfs_sb(s)->sb_fs_size)) | ||
33 | break; | ||
34 | sb_breadahead(s, secno); | ||
35 | secno++; | ||
36 | n--; | ||
37 | } | ||
38 | blk_finish_plug(&plug); | ||
39 | } | ||
40 | |||
12 | /* Map a sector into a buffer and return pointers to it and to the buffer. */ | 41 | /* Map a sector into a buffer and return pointers to it and to the buffer. */ |
13 | 42 | ||
14 | void *hpfs_map_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp, | 43 | void *hpfs_map_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp, |
@@ -18,6 +47,8 @@ void *hpfs_map_sector(struct super_block *s, unsigned secno, struct buffer_head | |||
18 | 47 | ||
19 | hpfs_lock_assert(s); | 48 | hpfs_lock_assert(s); |
20 | 49 | ||
50 | hpfs_prefetch_sectors(s, secno, ahead); | ||
51 | |||
21 | cond_resched(); | 52 | cond_resched(); |
22 | 53 | ||
23 | *bhp = bh = sb_bread(s, secno); | 54 | *bhp = bh = sb_bread(s, secno); |
@@ -67,6 +98,8 @@ void *hpfs_map_4sectors(struct super_block *s, unsigned secno, struct quad_buffe | |||
67 | return NULL; | 98 | return NULL; |
68 | } | 99 | } |
69 | 100 | ||
101 | hpfs_prefetch_sectors(s, secno, 4 + ahead); | ||
102 | |||
70 | qbh->data = data = kmalloc(2048, GFP_NOFS); | 103 | qbh->data = data = kmalloc(2048, GFP_NOFS); |
71 | if (!data) { | 104 | if (!data) { |
72 | printk("HPFS: hpfs_map_4sectors: out of memory\n"); | 105 | printk("HPFS: hpfs_map_4sectors: out of memory\n"); |
diff --git a/fs/hpfs/dentry.c b/fs/hpfs/dentry.c index 05d4816e4e77..fa27980f2229 100644 --- a/fs/hpfs/dentry.c +++ b/fs/hpfs/dentry.c | |||
@@ -12,8 +12,7 @@ | |||
12 | * Note: the dentry argument is the parent dentry. | 12 | * Note: the dentry argument is the parent dentry. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | static int hpfs_hash_dentry(const struct dentry *dentry, const struct inode *inode, | 15 | static int hpfs_hash_dentry(const struct dentry *dentry, struct qstr *qstr) |
16 | struct qstr *qstr) | ||
17 | { | 16 | { |
18 | unsigned long hash; | 17 | unsigned long hash; |
19 | int i; | 18 | int i; |
@@ -35,9 +34,7 @@ static int hpfs_hash_dentry(const struct dentry *dentry, const struct inode *ino | |||
35 | return 0; | 34 | return 0; |
36 | } | 35 | } |
37 | 36 | ||
38 | static int hpfs_compare_dentry(const struct dentry *parent, | 37 | static int hpfs_compare_dentry(const struct dentry *parent, const struct dentry *dentry, |
39 | const struct inode *pinode, | ||
40 | const struct dentry *dentry, const struct inode *inode, | ||
41 | unsigned int len, const char *str, const struct qstr *name) | 38 | unsigned int len, const char *str, const struct qstr *name) |
42 | { | 39 | { |
43 | unsigned al = len; | 40 | unsigned al = len; |
diff --git a/fs/hpfs/dir.c b/fs/hpfs/dir.c index 834ac13c04b7..292b1acb9b81 100644 --- a/fs/hpfs/dir.c +++ b/fs/hpfs/dir.c | |||
@@ -57,14 +57,14 @@ fail: | |||
57 | return -ESPIPE; | 57 | return -ESPIPE; |
58 | } | 58 | } |
59 | 59 | ||
60 | static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | 60 | static int hpfs_readdir(struct file *file, struct dir_context *ctx) |
61 | { | 61 | { |
62 | struct inode *inode = file_inode(filp); | 62 | struct inode *inode = file_inode(file); |
63 | struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); | 63 | struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); |
64 | struct quad_buffer_head qbh; | 64 | struct quad_buffer_head qbh; |
65 | struct hpfs_dirent *de; | 65 | struct hpfs_dirent *de; |
66 | int lc; | 66 | int lc; |
67 | long old_pos; | 67 | loff_t next_pos; |
68 | unsigned char *tempname; | 68 | unsigned char *tempname; |
69 | int c1, c2 = 0; | 69 | int c1, c2 = 0; |
70 | int ret = 0; | 70 | int ret = 0; |
@@ -105,11 +105,11 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
105 | } | 105 | } |
106 | } | 106 | } |
107 | lc = hpfs_sb(inode->i_sb)->sb_lowercase; | 107 | lc = hpfs_sb(inode->i_sb)->sb_lowercase; |
108 | if (filp->f_pos == 12) { /* diff -r requires this (note, that diff -r */ | 108 | if (ctx->pos == 12) { /* diff -r requires this (note, that diff -r */ |
109 | filp->f_pos = 13; /* also fails on msdos filesystem in 2.0) */ | 109 | ctx->pos = 13; /* also fails on msdos filesystem in 2.0) */ |
110 | goto out; | 110 | goto out; |
111 | } | 111 | } |
112 | if (filp->f_pos == 13) { | 112 | if (ctx->pos == 13) { |
113 | ret = -ENOENT; | 113 | ret = -ENOENT; |
114 | goto out; | 114 | goto out; |
115 | } | 115 | } |
@@ -120,33 +120,34 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
120 | accepted by filldir, but what can I do? | 120 | accepted by filldir, but what can I do? |
121 | maybe killall -9 ls helps */ | 121 | maybe killall -9 ls helps */ |
122 | if (hpfs_sb(inode->i_sb)->sb_chk) | 122 | if (hpfs_sb(inode->i_sb)->sb_chk) |
123 | if (hpfs_stop_cycles(inode->i_sb, filp->f_pos, &c1, &c2, "hpfs_readdir")) { | 123 | if (hpfs_stop_cycles(inode->i_sb, ctx->pos, &c1, &c2, "hpfs_readdir")) { |
124 | ret = -EFSERROR; | 124 | ret = -EFSERROR; |
125 | goto out; | 125 | goto out; |
126 | } | 126 | } |
127 | if (filp->f_pos == 12) | 127 | if (ctx->pos == 12) |
128 | goto out; | 128 | goto out; |
129 | if (filp->f_pos == 3 || filp->f_pos == 4 || filp->f_pos == 5) { | 129 | if (ctx->pos == 3 || ctx->pos == 4 || ctx->pos == 5) { |
130 | printk("HPFS: warning: pos==%d\n",(int)filp->f_pos); | 130 | printk("HPFS: warning: pos==%d\n",(int)ctx->pos); |
131 | goto out; | 131 | goto out; |
132 | } | 132 | } |
133 | if (filp->f_pos == 0) { | 133 | if (ctx->pos == 0) { |
134 | if (filldir(dirent, ".", 1, filp->f_pos, inode->i_ino, DT_DIR) < 0) | 134 | if (!dir_emit_dot(file, ctx)) |
135 | goto out; | 135 | goto out; |
136 | filp->f_pos = 11; | 136 | ctx->pos = 11; |
137 | } | 137 | } |
138 | if (filp->f_pos == 11) { | 138 | if (ctx->pos == 11) { |
139 | if (filldir(dirent, "..", 2, filp->f_pos, hpfs_inode->i_parent_dir, DT_DIR) < 0) | 139 | if (!dir_emit(ctx, "..", 2, hpfs_inode->i_parent_dir, DT_DIR)) |
140 | goto out; | 140 | goto out; |
141 | filp->f_pos = 1; | 141 | ctx->pos = 1; |
142 | } | 142 | } |
143 | if (filp->f_pos == 1) { | 143 | if (ctx->pos == 1) { |
144 | filp->f_pos = ((loff_t) hpfs_de_as_down_as_possible(inode->i_sb, hpfs_inode->i_dno) << 4) + 1; | 144 | ctx->pos = ((loff_t) hpfs_de_as_down_as_possible(inode->i_sb, hpfs_inode->i_dno) << 4) + 1; |
145 | hpfs_add_pos(inode, &filp->f_pos); | 145 | hpfs_add_pos(inode, &file->f_pos); |
146 | filp->f_version = inode->i_version; | 146 | file->f_version = inode->i_version; |
147 | } | 147 | } |
148 | old_pos = filp->f_pos; | 148 | next_pos = ctx->pos; |
149 | if (!(de = map_pos_dirent(inode, &filp->f_pos, &qbh))) { | 149 | if (!(de = map_pos_dirent(inode, &next_pos, &qbh))) { |
150 | ctx->pos = next_pos; | ||
150 | ret = -EIOERROR; | 151 | ret = -EIOERROR; |
151 | goto out; | 152 | goto out; |
152 | } | 153 | } |
@@ -154,20 +155,21 @@ static int hpfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
154 | if (hpfs_sb(inode->i_sb)->sb_chk) { | 155 | if (hpfs_sb(inode->i_sb)->sb_chk) { |
155 | if (de->first && !de->last && (de->namelen != 2 | 156 | if (de->first && !de->last && (de->namelen != 2 |
156 | || de ->name[0] != 1 || de->name[1] != 1)) | 157 | || de ->name[0] != 1 || de->name[1] != 1)) |
157 | hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08lx", old_pos); | 158 | hpfs_error(inode->i_sb, "hpfs_readdir: bad ^A^A entry; pos = %08lx", (unsigned long)ctx->pos); |
158 | if (de->last && (de->namelen != 1 || de ->name[0] != 255)) | 159 | if (de->last && (de->namelen != 1 || de ->name[0] != 255)) |
159 | hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08lx", old_pos); | 160 | hpfs_error(inode->i_sb, "hpfs_readdir: bad \\377 entry; pos = %08lx", (unsigned long)ctx->pos); |
160 | } | 161 | } |
161 | hpfs_brelse4(&qbh); | 162 | hpfs_brelse4(&qbh); |
163 | ctx->pos = next_pos; | ||
162 | goto again; | 164 | goto again; |
163 | } | 165 | } |
164 | tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3); | 166 | tempname = hpfs_translate_name(inode->i_sb, de->name, de->namelen, lc, de->not_8x3); |
165 | if (filldir(dirent, tempname, de->namelen, old_pos, le32_to_cpu(de->fnode), DT_UNKNOWN) < 0) { | 167 | if (!dir_emit(ctx, tempname, de->namelen, le32_to_cpu(de->fnode), DT_UNKNOWN)) { |
166 | filp->f_pos = old_pos; | ||
167 | if (tempname != de->name) kfree(tempname); | 168 | if (tempname != de->name) kfree(tempname); |
168 | hpfs_brelse4(&qbh); | 169 | hpfs_brelse4(&qbh); |
169 | goto out; | 170 | goto out; |
170 | } | 171 | } |
172 | ctx->pos = next_pos; | ||
171 | if (tempname != de->name) kfree(tempname); | 173 | if (tempname != de->name) kfree(tempname); |
172 | hpfs_brelse4(&qbh); | 174 | hpfs_brelse4(&qbh); |
173 | } | 175 | } |
@@ -322,7 +324,7 @@ const struct file_operations hpfs_dir_ops = | |||
322 | { | 324 | { |
323 | .llseek = hpfs_dir_lseek, | 325 | .llseek = hpfs_dir_lseek, |
324 | .read = generic_read_dir, | 326 | .read = generic_read_dir, |
325 | .readdir = hpfs_readdir, | 327 | .iterate = hpfs_readdir, |
326 | .release = hpfs_dir_release, | 328 | .release = hpfs_dir_release, |
327 | .fsync = hpfs_file_fsync, | 329 | .fsync = hpfs_file_fsync, |
328 | }; | 330 | }; |
diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c index e4ba5fe4c3b5..4e9dabcf1f4c 100644 --- a/fs/hpfs/file.c +++ b/fs/hpfs/file.c | |||
@@ -7,6 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | 8 | ||
9 | #include "hpfs_fn.h" | 9 | #include "hpfs_fn.h" |
10 | #include <linux/mpage.h> | ||
10 | 11 | ||
11 | #define BLOCKS(size) (((size) + 511) >> 9) | 12 | #define BLOCKS(size) (((size) + 511) >> 9) |
12 | 13 | ||
@@ -34,7 +35,7 @@ int hpfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync) | |||
34 | * so we must ignore such errors. | 35 | * so we must ignore such errors. |
35 | */ | 36 | */ |
36 | 37 | ||
37 | static secno hpfs_bmap(struct inode *inode, unsigned file_secno) | 38 | static secno hpfs_bmap(struct inode *inode, unsigned file_secno, unsigned *n_secs) |
38 | { | 39 | { |
39 | struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); | 40 | struct hpfs_inode_info *hpfs_inode = hpfs_i(inode); |
40 | unsigned n, disk_secno; | 41 | unsigned n, disk_secno; |
@@ -42,11 +43,20 @@ static secno hpfs_bmap(struct inode *inode, unsigned file_secno) | |||
42 | struct buffer_head *bh; | 43 | struct buffer_head *bh; |
43 | if (BLOCKS(hpfs_i(inode)->mmu_private) <= file_secno) return 0; | 44 | if (BLOCKS(hpfs_i(inode)->mmu_private) <= file_secno) return 0; |
44 | n = file_secno - hpfs_inode->i_file_sec; | 45 | n = file_secno - hpfs_inode->i_file_sec; |
45 | if (n < hpfs_inode->i_n_secs) return hpfs_inode->i_disk_sec + n; | 46 | if (n < hpfs_inode->i_n_secs) { |
47 | *n_secs = hpfs_inode->i_n_secs - n; | ||
48 | return hpfs_inode->i_disk_sec + n; | ||
49 | } | ||
46 | if (!(fnode = hpfs_map_fnode(inode->i_sb, inode->i_ino, &bh))) return 0; | 50 | if (!(fnode = hpfs_map_fnode(inode->i_sb, inode->i_ino, &bh))) return 0; |
47 | disk_secno = hpfs_bplus_lookup(inode->i_sb, inode, &fnode->btree, file_secno, bh); | 51 | disk_secno = hpfs_bplus_lookup(inode->i_sb, inode, &fnode->btree, file_secno, bh); |
48 | if (disk_secno == -1) return 0; | 52 | if (disk_secno == -1) return 0; |
49 | if (hpfs_chk_sectors(inode->i_sb, disk_secno, 1, "bmap")) return 0; | 53 | if (hpfs_chk_sectors(inode->i_sb, disk_secno, 1, "bmap")) return 0; |
54 | n = file_secno - hpfs_inode->i_file_sec; | ||
55 | if (n < hpfs_inode->i_n_secs) { | ||
56 | *n_secs = hpfs_inode->i_n_secs - n; | ||
57 | return hpfs_inode->i_disk_sec + n; | ||
58 | } | ||
59 | *n_secs = 1; | ||
50 | return disk_secno; | 60 | return disk_secno; |
51 | } | 61 | } |
52 | 62 | ||
@@ -67,10 +77,14 @@ static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_he | |||
67 | { | 77 | { |
68 | int r; | 78 | int r; |
69 | secno s; | 79 | secno s; |
80 | unsigned n_secs; | ||
70 | hpfs_lock(inode->i_sb); | 81 | hpfs_lock(inode->i_sb); |
71 | s = hpfs_bmap(inode, iblock); | 82 | s = hpfs_bmap(inode, iblock, &n_secs); |
72 | if (s) { | 83 | if (s) { |
84 | if (bh_result->b_size >> 9 < n_secs) | ||
85 | n_secs = bh_result->b_size >> 9; | ||
73 | map_bh(bh_result, inode->i_sb, s); | 86 | map_bh(bh_result, inode->i_sb, s); |
87 | bh_result->b_size = n_secs << 9; | ||
74 | goto ret_0; | 88 | goto ret_0; |
75 | } | 89 | } |
76 | if (!create) goto ret_0; | 90 | if (!create) goto ret_0; |
@@ -95,14 +109,26 @@ static int hpfs_get_block(struct inode *inode, sector_t iblock, struct buffer_he | |||
95 | return r; | 109 | return r; |
96 | } | 110 | } |
97 | 111 | ||
112 | static int hpfs_readpage(struct file *file, struct page *page) | ||
113 | { | ||
114 | return mpage_readpage(page, hpfs_get_block); | ||
115 | } | ||
116 | |||
98 | static int hpfs_writepage(struct page *page, struct writeback_control *wbc) | 117 | static int hpfs_writepage(struct page *page, struct writeback_control *wbc) |
99 | { | 118 | { |
100 | return block_write_full_page(page,hpfs_get_block, wbc); | 119 | return block_write_full_page(page, hpfs_get_block, wbc); |
101 | } | 120 | } |
102 | 121 | ||
103 | static int hpfs_readpage(struct file *file, struct page *page) | 122 | static int hpfs_readpages(struct file *file, struct address_space *mapping, |
123 | struct list_head *pages, unsigned nr_pages) | ||
124 | { | ||
125 | return mpage_readpages(mapping, pages, nr_pages, hpfs_get_block); | ||
126 | } | ||
127 | |||
128 | static int hpfs_writepages(struct address_space *mapping, | ||
129 | struct writeback_control *wbc) | ||
104 | { | 130 | { |
105 | return block_read_full_page(page,hpfs_get_block); | 131 | return mpage_writepages(mapping, wbc, hpfs_get_block); |
106 | } | 132 | } |
107 | 133 | ||
108 | static void hpfs_write_failed(struct address_space *mapping, loff_t to) | 134 | static void hpfs_write_failed(struct address_space *mapping, loff_t to) |
@@ -161,6 +187,8 @@ static sector_t _hpfs_bmap(struct address_space *mapping, sector_t block) | |||
161 | const struct address_space_operations hpfs_aops = { | 187 | const struct address_space_operations hpfs_aops = { |
162 | .readpage = hpfs_readpage, | 188 | .readpage = hpfs_readpage, |
163 | .writepage = hpfs_writepage, | 189 | .writepage = hpfs_writepage, |
190 | .readpages = hpfs_readpages, | ||
191 | .writepages = hpfs_writepages, | ||
164 | .write_begin = hpfs_write_begin, | 192 | .write_begin = hpfs_write_begin, |
165 | .write_end = hpfs_write_end, | 193 | .write_end = hpfs_write_end, |
166 | .bmap = _hpfs_bmap | 194 | .bmap = _hpfs_bmap |
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h index b7ae286646b5..1b398636e990 100644 --- a/fs/hpfs/hpfs_fn.h +++ b/fs/hpfs/hpfs_fn.h | |||
@@ -27,8 +27,9 @@ | |||
27 | #define ALLOC_FWD_MAX 128 | 27 | #define ALLOC_FWD_MAX 128 |
28 | #define ALLOC_M 1 | 28 | #define ALLOC_M 1 |
29 | #define FNODE_RD_AHEAD 16 | 29 | #define FNODE_RD_AHEAD 16 |
30 | #define ANODE_RD_AHEAD 16 | 30 | #define ANODE_RD_AHEAD 0 |
31 | #define DNODE_RD_AHEAD 4 | 31 | #define DNODE_RD_AHEAD 72 |
32 | #define COUNT_RD_AHEAD 62 | ||
32 | 33 | ||
33 | #define FREE_DNODES_ADD 58 | 34 | #define FREE_DNODES_ADD 58 |
34 | #define FREE_DNODES_DEL 29 | 35 | #define FREE_DNODES_DEL 29 |
@@ -207,6 +208,7 @@ void hpfs_remove_fnode(struct super_block *, fnode_secno fno); | |||
207 | 208 | ||
208 | /* buffer.c */ | 209 | /* buffer.c */ |
209 | 210 | ||
211 | void hpfs_prefetch_sectors(struct super_block *, unsigned, int); | ||
210 | void *hpfs_map_sector(struct super_block *, unsigned, struct buffer_head **, int); | 212 | void *hpfs_map_sector(struct super_block *, unsigned, struct buffer_head **, int); |
211 | void *hpfs_get_sector(struct super_block *, unsigned, struct buffer_head **); | 213 | void *hpfs_get_sector(struct super_block *, unsigned, struct buffer_head **); |
212 | void *hpfs_map_4sectors(struct super_block *, unsigned, struct quad_buffer_head *, int); | 214 | void *hpfs_map_4sectors(struct super_block *, unsigned, struct quad_buffer_head *, int); |
@@ -271,6 +273,7 @@ void hpfs_evict_inode(struct inode *); | |||
271 | 273 | ||
272 | __le32 *hpfs_map_dnode_bitmap(struct super_block *, struct quad_buffer_head *); | 274 | __le32 *hpfs_map_dnode_bitmap(struct super_block *, struct quad_buffer_head *); |
273 | __le32 *hpfs_map_bitmap(struct super_block *, unsigned, struct quad_buffer_head *, char *); | 275 | __le32 *hpfs_map_bitmap(struct super_block *, unsigned, struct quad_buffer_head *, char *); |
276 | void hpfs_prefetch_bitmap(struct super_block *, unsigned); | ||
274 | unsigned char *hpfs_load_code_page(struct super_block *, secno); | 277 | unsigned char *hpfs_load_code_page(struct super_block *, secno); |
275 | __le32 *hpfs_load_bitmap_directory(struct super_block *, secno bmp); | 278 | __le32 *hpfs_load_bitmap_directory(struct super_block *, secno bmp); |
276 | struct fnode *hpfs_map_fnode(struct super_block *s, ino_t, struct buffer_head **); | 279 | struct fnode *hpfs_map_fnode(struct super_block *s, ino_t, struct buffer_head **); |
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 | /* |
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index a0617e706957..4334cda8dba1 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c | |||
@@ -121,7 +121,7 @@ unsigned hpfs_count_one_bitmap(struct super_block *s, secno secno) | |||
121 | unsigned long *bits; | 121 | unsigned long *bits; |
122 | unsigned count; | 122 | unsigned count; |
123 | 123 | ||
124 | bits = hpfs_map_4sectors(s, secno, &qbh, 4); | 124 | bits = hpfs_map_4sectors(s, secno, &qbh, 0); |
125 | if (!bits) | 125 | if (!bits) |
126 | return 0; | 126 | return 0; |
127 | count = bitmap_weight(bits, 2048 * BITS_PER_BYTE); | 127 | count = bitmap_weight(bits, 2048 * BITS_PER_BYTE); |
@@ -134,8 +134,13 @@ static unsigned count_bitmaps(struct super_block *s) | |||
134 | unsigned n, count, n_bands; | 134 | unsigned n, count, n_bands; |
135 | n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14; | 135 | n_bands = (hpfs_sb(s)->sb_fs_size + 0x3fff) >> 14; |
136 | count = 0; | 136 | count = 0; |
137 | for (n = 0; n < n_bands; n++) | 137 | for (n = 0; n < COUNT_RD_AHEAD; n++) { |
138 | hpfs_prefetch_bitmap(s, n); | ||
139 | } | ||
140 | for (n = 0; n < n_bands; n++) { | ||
141 | hpfs_prefetch_bitmap(s, n + COUNT_RD_AHEAD); | ||
138 | count += hpfs_count_one_bitmap(s, le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[n])); | 142 | count += hpfs_count_one_bitmap(s, le32_to_cpu(hpfs_sb(s)->sb_bmp_dir[n])); |
143 | } | ||
139 | return count; | 144 | return count; |
140 | } | 145 | } |
141 | 146 | ||
@@ -558,7 +563,13 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
558 | sbi->sb_cp_table = NULL; | 563 | sbi->sb_cp_table = NULL; |
559 | sbi->sb_c_bitmap = -1; | 564 | sbi->sb_c_bitmap = -1; |
560 | sbi->sb_max_fwd_alloc = 0xffffff; | 565 | sbi->sb_max_fwd_alloc = 0xffffff; |
561 | 566 | ||
567 | if (sbi->sb_fs_size >= 0x80000000) { | ||
568 | hpfs_error(s, "invalid size in superblock: %08x", | ||
569 | (unsigned)sbi->sb_fs_size); | ||
570 | goto bail4; | ||
571 | } | ||
572 | |||
562 | /* Load bitmap directory */ | 573 | /* Load bitmap directory */ |
563 | if (!(sbi->sb_bmp_dir = hpfs_load_bitmap_directory(s, le32_to_cpu(superblock->bitmaps)))) | 574 | if (!(sbi->sb_bmp_dir = hpfs_load_bitmap_directory(s, le32_to_cpu(superblock->bitmaps)))) |
564 | goto bail4; | 575 | goto bail4; |