diff options
author | Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz> | 2011-05-08 14:43:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-09 12:04:23 -0400 |
commit | 7d23ce36e3f52f9b83ac8da49296b73339c8b5b8 (patch) | |
tree | 0c3973efa632e3c58d056c5d949a38b4c475193f | |
parent | 7dd29d8d865efdb00c0542a5d2c87af8c52ea6c7 (diff) |
HPFS: Remove remaining locks
Remove remaining locks
Because of a new global per-fs lock, no other locks are needed
Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/hpfs/alloc.c | 50 | ||||
-rw-r--r-- | fs/hpfs/anode.c | 2 | ||||
-rw-r--r-- | fs/hpfs/buffer.c | 16 | ||||
-rw-r--r-- | fs/hpfs/dnode.c | 57 | ||||
-rw-r--r-- | fs/hpfs/ea.c | 6 | ||||
-rw-r--r-- | fs/hpfs/hpfs_fn.h | 12 | ||||
-rw-r--r-- | fs/hpfs/inode.c | 5 | ||||
-rw-r--r-- | fs/hpfs/namei.c | 53 | ||||
-rw-r--r-- | fs/hpfs/super.c | 4 |
9 files changed, 50 insertions, 155 deletions
diff --git a/fs/hpfs/alloc.c b/fs/hpfs/alloc.c index 5503e2c28910..995472de92a0 100644 --- a/fs/hpfs/alloc.c +++ b/fs/hpfs/alloc.c | |||
@@ -8,8 +8,6 @@ | |||
8 | 8 | ||
9 | #include "hpfs_fn.h" | 9 | #include "hpfs_fn.h" |
10 | 10 | ||
11 | static int hpfs_alloc_if_possible_nolock(struct super_block *s, secno sec); | ||
12 | |||
13 | /* | 11 | /* |
14 | * Check if a sector is allocated in bitmap | 12 | * Check if a sector is allocated in bitmap |
15 | * This is really slow. Turned on only if chk==2 | 13 | * This is really slow. Turned on only if chk==2 |
@@ -75,7 +73,6 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
75 | hpfs_error(s, "Bad allocation size: %d", n); | 73 | hpfs_error(s, "Bad allocation size: %d", n); |
76 | return 0; | 74 | return 0; |
77 | } | 75 | } |
78 | lock_super(s); | ||
79 | if (bs != ~0x3fff) { | 76 | if (bs != ~0x3fff) { |
80 | if (!(bmp = hpfs_map_bitmap(s, near >> 14, &qbh, "aib"))) goto uls; | 77 | if (!(bmp = hpfs_map_bitmap(s, near >> 14, &qbh, "aib"))) goto uls; |
81 | } else { | 78 | } else { |
@@ -143,7 +140,6 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
143 | b: | 140 | b: |
144 | hpfs_brelse4(&qbh); | 141 | hpfs_brelse4(&qbh); |
145 | uls: | 142 | uls: |
146 | unlock_super(s); | ||
147 | return ret; | 143 | return ret; |
148 | } | 144 | } |
149 | 145 | ||
@@ -155,7 +151,7 @@ static secno alloc_in_bmp(struct super_block *s, secno near, unsigned n, unsigne | |||
155 | * sectors | 151 | * sectors |
156 | */ | 152 | */ |
157 | 153 | ||
158 | secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forward, int lock) | 154 | secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forward) |
159 | { | 155 | { |
160 | secno sec; | 156 | secno sec; |
161 | int i; | 157 | int i; |
@@ -167,7 +163,6 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa | |||
167 | forward = -forward; | 163 | forward = -forward; |
168 | f_p = 1; | 164 | f_p = 1; |
169 | } | 165 | } |
170 | if (lock) hpfs_lock_creation(s); | ||
171 | n_bmps = (sbi->sb_fs_size + 0x4000 - 1) >> 14; | 166 | n_bmps = (sbi->sb_fs_size + 0x4000 - 1) >> 14; |
172 | if (near && near < sbi->sb_fs_size) { | 167 | if (near && near < sbi->sb_fs_size) { |
173 | if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret; | 168 | if ((sec = alloc_in_bmp(s, near, n, f_p ? forward : forward/4))) goto ret; |
@@ -214,18 +209,17 @@ secno hpfs_alloc_sector(struct super_block *s, secno near, unsigned n, int forwa | |||
214 | ret: | 209 | ret: |
215 | if (sec && f_p) { | 210 | if (sec && f_p) { |
216 | for (i = 0; i < forward; i++) { | 211 | for (i = 0; i < forward; i++) { |
217 | if (!hpfs_alloc_if_possible_nolock(s, sec + i + 1)) { | 212 | if (!hpfs_alloc_if_possible(s, sec + i + 1)) { |
218 | hpfs_error(s, "Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, sec, i); | 213 | hpfs_error(s, "Prealloc doesn't work! Wanted %d, allocated at %08x, can't allocate %d", forward, sec, i); |
219 | sec = 0; | 214 | sec = 0; |
220 | break; | 215 | break; |
221 | } | 216 | } |
222 | } | 217 | } |
223 | } | 218 | } |
224 | if (lock) hpfs_unlock_creation(s); | ||
225 | return sec; | 219 | return sec; |
226 | } | 220 | } |
227 | 221 | ||
228 | static secno alloc_in_dirband(struct super_block *s, secno near, int lock) | 222 | static secno alloc_in_dirband(struct super_block *s, secno near) |
229 | { | 223 | { |
230 | unsigned nr = near; | 224 | unsigned nr = near; |
231 | secno sec; | 225 | secno sec; |
@@ -236,43 +230,29 @@ static secno alloc_in_dirband(struct super_block *s, secno near, int lock) | |||
236 | nr = sbi->sb_dirband_start + sbi->sb_dirband_size - 4; | 230 | nr = sbi->sb_dirband_start + sbi->sb_dirband_size - 4; |
237 | nr -= sbi->sb_dirband_start; | 231 | nr -= sbi->sb_dirband_start; |
238 | nr >>= 2; | 232 | nr >>= 2; |
239 | if (lock) hpfs_lock_creation(s); | ||
240 | sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0); | 233 | sec = alloc_in_bmp(s, (~0x3fff) | nr, 1, 0); |
241 | if (lock) hpfs_unlock_creation(s); | ||
242 | if (!sec) return 0; | 234 | if (!sec) return 0; |
243 | return ((sec & 0x3fff) << 2) + sbi->sb_dirband_start; | 235 | return ((sec & 0x3fff) << 2) + sbi->sb_dirband_start; |
244 | } | 236 | } |
245 | 237 | ||
246 | /* Alloc sector if it's free */ | 238 | /* Alloc sector if it's free */ |
247 | 239 | ||
248 | static int hpfs_alloc_if_possible_nolock(struct super_block *s, secno sec) | 240 | int hpfs_alloc_if_possible(struct super_block *s, secno sec) |
249 | { | 241 | { |
250 | struct quad_buffer_head qbh; | 242 | struct quad_buffer_head qbh; |
251 | unsigned *bmp; | 243 | unsigned *bmp; |
252 | lock_super(s); | ||
253 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; | 244 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "aip"))) goto end; |
254 | if (bmp[(sec & 0x3fff) >> 5] & (1 << (sec & 0x1f))) { | 245 | if (bmp[(sec & 0x3fff) >> 5] & (1 << (sec & 0x1f))) { |
255 | bmp[(sec & 0x3fff) >> 5] &= ~(1 << (sec & 0x1f)); | 246 | bmp[(sec & 0x3fff) >> 5] &= ~(1 << (sec & 0x1f)); |
256 | hpfs_mark_4buffers_dirty(&qbh); | 247 | hpfs_mark_4buffers_dirty(&qbh); |
257 | hpfs_brelse4(&qbh); | 248 | hpfs_brelse4(&qbh); |
258 | unlock_super(s); | ||
259 | return 1; | 249 | return 1; |
260 | } | 250 | } |
261 | hpfs_brelse4(&qbh); | 251 | hpfs_brelse4(&qbh); |
262 | end: | 252 | end: |
263 | unlock_super(s); | ||
264 | return 0; | 253 | return 0; |
265 | } | 254 | } |
266 | 255 | ||
267 | int hpfs_alloc_if_possible(struct super_block *s, secno sec) | ||
268 | { | ||
269 | int r; | ||
270 | hpfs_lock_creation(s); | ||
271 | r = hpfs_alloc_if_possible_nolock(s, sec); | ||
272 | hpfs_unlock_creation(s); | ||
273 | return r; | ||
274 | } | ||
275 | |||
276 | /* Free sectors in bitmaps */ | 256 | /* Free sectors in bitmaps */ |
277 | 257 | ||
278 | void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) | 258 | void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) |
@@ -286,26 +266,22 @@ void hpfs_free_sectors(struct super_block *s, secno sec, unsigned n) | |||
286 | hpfs_error(s, "Trying to free reserved sector %08x", sec); | 266 | hpfs_error(s, "Trying to free reserved sector %08x", sec); |
287 | return; | 267 | return; |
288 | } | 268 | } |
289 | lock_super(s); | ||
290 | sbi->sb_max_fwd_alloc += n > 0xffff ? 0xffff : n; | 269 | sbi->sb_max_fwd_alloc += n > 0xffff ? 0xffff : n; |
291 | if (sbi->sb_max_fwd_alloc > 0xffffff) sbi->sb_max_fwd_alloc = 0xffffff; | 270 | if (sbi->sb_max_fwd_alloc > 0xffffff) sbi->sb_max_fwd_alloc = 0xffffff; |
292 | new_map: | 271 | new_map: |
293 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "free"))) { | 272 | if (!(bmp = hpfs_map_bitmap(s, sec >> 14, &qbh, "free"))) { |
294 | unlock_super(s); | ||
295 | return; | 273 | return; |
296 | } | 274 | } |
297 | new_tst: | 275 | new_tst: |
298 | if ((bmp[(sec & 0x3fff) >> 5] >> (sec & 0x1f) & 1)) { | 276 | if ((bmp[(sec & 0x3fff) >> 5] >> (sec & 0x1f) & 1)) { |
299 | hpfs_error(s, "sector %08x not allocated", sec); | 277 | hpfs_error(s, "sector %08x not allocated", sec); |
300 | hpfs_brelse4(&qbh); | 278 | hpfs_brelse4(&qbh); |
301 | unlock_super(s); | ||
302 | return; | 279 | return; |
303 | } | 280 | } |
304 | bmp[(sec & 0x3fff) >> 5] |= 1 << (sec & 0x1f); | 281 | bmp[(sec & 0x3fff) >> 5] |= 1 << (sec & 0x1f); |
305 | if (!--n) { | 282 | if (!--n) { |
306 | hpfs_mark_4buffers_dirty(&qbh); | 283 | hpfs_mark_4buffers_dirty(&qbh); |
307 | hpfs_brelse4(&qbh); | 284 | hpfs_brelse4(&qbh); |
308 | unlock_super(s); | ||
309 | return; | 285 | return; |
310 | } | 286 | } |
311 | if (!(++sec & 0x3fff)) { | 287 | if (!(++sec & 0x3fff)) { |
@@ -381,29 +357,25 @@ void hpfs_free_dnode(struct super_block *s, dnode_secno dno) | |||
381 | struct quad_buffer_head qbh; | 357 | struct quad_buffer_head qbh; |
382 | unsigned *bmp; | 358 | unsigned *bmp; |
383 | unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; | 359 | unsigned ssec = (dno - hpfs_sb(s)->sb_dirband_start) / 4; |
384 | lock_super(s); | ||
385 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { | 360 | if (!(bmp = hpfs_map_dnode_bitmap(s, &qbh))) { |
386 | unlock_super(s); | ||
387 | return; | 361 | return; |
388 | } | 362 | } |
389 | bmp[ssec >> 5] |= 1 << (ssec & 0x1f); | 363 | bmp[ssec >> 5] |= 1 << (ssec & 0x1f); |
390 | hpfs_mark_4buffers_dirty(&qbh); | 364 | hpfs_mark_4buffers_dirty(&qbh); |
391 | hpfs_brelse4(&qbh); | 365 | hpfs_brelse4(&qbh); |
392 | unlock_super(s); | ||
393 | } | 366 | } |
394 | } | 367 | } |
395 | 368 | ||
396 | struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near, | 369 | struct dnode *hpfs_alloc_dnode(struct super_block *s, secno near, |
397 | dnode_secno *dno, struct quad_buffer_head *qbh, | 370 | dnode_secno *dno, struct quad_buffer_head *qbh) |
398 | int lock) | ||
399 | { | 371 | { |
400 | struct dnode *d; | 372 | struct dnode *d; |
401 | if (hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_dmap) > FREE_DNODES_ADD) { | 373 | if (hpfs_count_one_bitmap(s, hpfs_sb(s)->sb_dmap) > FREE_DNODES_ADD) { |
402 | if (!(*dno = alloc_in_dirband(s, near, lock))) | 374 | if (!(*dno = alloc_in_dirband(s, near))) |
403 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0, lock))) return NULL; | 375 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) return NULL; |
404 | } else { | 376 | } else { |
405 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0, lock))) | 377 | if (!(*dno = hpfs_alloc_sector(s, near, 4, 0))) |
406 | if (!(*dno = alloc_in_dirband(s, near, lock))) return NULL; | 378 | if (!(*dno = alloc_in_dirband(s, near))) return NULL; |
407 | } | 379 | } |
408 | if (!(d = hpfs_get_4sectors(s, *dno, qbh))) { | 380 | if (!(d = hpfs_get_4sectors(s, *dno, qbh))) { |
409 | hpfs_free_dnode(s, *dno); | 381 | hpfs_free_dnode(s, *dno); |
@@ -424,7 +396,7 @@ struct fnode *hpfs_alloc_fnode(struct super_block *s, secno near, fnode_secno *f | |||
424 | struct buffer_head **bh) | 396 | struct buffer_head **bh) |
425 | { | 397 | { |
426 | struct fnode *f; | 398 | struct fnode *f; |
427 | if (!(*fno = hpfs_alloc_sector(s, near, 1, FNODE_ALLOC_FWD, 1))) return NULL; | 399 | if (!(*fno = hpfs_alloc_sector(s, near, 1, FNODE_ALLOC_FWD))) return NULL; |
428 | if (!(f = hpfs_get_sector(s, *fno, bh))) { | 400 | if (!(f = hpfs_get_sector(s, *fno, bh))) { |
429 | hpfs_free_sectors(s, *fno, 1); | 401 | hpfs_free_sectors(s, *fno, 1); |
430 | return NULL; | 402 | return NULL; |
@@ -441,7 +413,7 @@ struct anode *hpfs_alloc_anode(struct super_block *s, secno near, anode_secno *a | |||
441 | struct buffer_head **bh) | 413 | struct buffer_head **bh) |
442 | { | 414 | { |
443 | struct anode *a; | 415 | struct anode *a; |
444 | if (!(*ano = hpfs_alloc_sector(s, near, 1, ANODE_ALLOC_FWD, 1))) return NULL; | 416 | if (!(*ano = hpfs_alloc_sector(s, near, 1, ANODE_ALLOC_FWD))) return NULL; |
445 | if (!(a = hpfs_get_sector(s, *ano, bh))) { | 417 | if (!(a = hpfs_get_sector(s, *ano, bh))) { |
446 | hpfs_free_sectors(s, *ano, 1); | 418 | hpfs_free_sectors(s, *ano, 1); |
447 | return NULL; | 419 | return NULL; |
diff --git a/fs/hpfs/anode.c b/fs/hpfs/anode.c index 6a2f04bf3df0..f2a038411e3c 100644 --- a/fs/hpfs/anode.c +++ b/fs/hpfs/anode.c | |||
@@ -115,7 +115,7 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi | |||
115 | } | 115 | } |
116 | se = !fnod ? node : (node + 16384) & ~16383; | 116 | se = !fnod ? node : (node + 16384) & ~16383; |
117 | } | 117 | } |
118 | if (!(se = hpfs_alloc_sector(s, se, 1, fsecno*ALLOC_M>ALLOC_FWD_MAX ? ALLOC_FWD_MAX : fsecno*ALLOC_M<ALLOC_FWD_MIN ? ALLOC_FWD_MIN : fsecno*ALLOC_M, 1))) { | 118 | if (!(se = hpfs_alloc_sector(s, se, 1, fsecno*ALLOC_M>ALLOC_FWD_MAX ? ALLOC_FWD_MAX : fsecno*ALLOC_M<ALLOC_FWD_MIN ? ALLOC_FWD_MIN : fsecno*ALLOC_M))) { |
119 | brelse(bh); | 119 | brelse(bh); |
120 | return -1; | 120 | return -1; |
121 | } | 121 | } |
diff --git a/fs/hpfs/buffer.c b/fs/hpfs/buffer.c index 7cef5d5c3608..9ecde27d1e29 100644 --- a/fs/hpfs/buffer.c +++ b/fs/hpfs/buffer.c | |||
@@ -9,22 +9,6 @@ | |||
9 | #include <linux/slab.h> | 9 | #include <linux/slab.h> |
10 | #include "hpfs_fn.h" | 10 | #include "hpfs_fn.h" |
11 | 11 | ||
12 | void hpfs_lock_creation(struct super_block *s) | ||
13 | { | ||
14 | #ifdef DEBUG_LOCKS | ||
15 | printk("lock creation\n"); | ||
16 | #endif | ||
17 | mutex_lock(&hpfs_sb(s)->hpfs_creation_de); | ||
18 | } | ||
19 | |||
20 | void hpfs_unlock_creation(struct super_block *s) | ||
21 | { | ||
22 | #ifdef DEBUG_LOCKS | ||
23 | printk("unlock creation\n"); | ||
24 | #endif | ||
25 | mutex_unlock(&hpfs_sb(s)->hpfs_creation_de); | ||
26 | } | ||
27 | |||
28 | /* Map a sector into a buffer and return pointers to it and to the buffer. */ | 12 | /* Map a sector into a buffer and return pointers to it and to the buffer. */ |
29 | 13 | ||
30 | void *hpfs_map_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp, | 14 | void *hpfs_map_sector(struct super_block *s, unsigned secno, struct buffer_head **bhp, |
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c index 9b2ffadfc8c4..07711c392f8b 100644 --- a/fs/hpfs/dnode.c +++ b/fs/hpfs/dnode.c | |||
@@ -145,9 +145,10 @@ static void set_last_pointer(struct super_block *s, struct dnode *d, dnode_secno | |||
145 | } | 145 | } |
146 | } | 146 | } |
147 | if (ptr) { | 147 | if (ptr) { |
148 | if ((d->first_free += 4) > 2048) { | 148 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) + 4); |
149 | hpfs_error(s,"set_last_pointer: too long dnode %08x", d->self); | 149 | if (le32_to_cpu(d->first_free) > 2048) { |
150 | d->first_free -= 4; | 150 | hpfs_error(s, "set_last_pointer: too long dnode %08x", d->self); |
151 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - 4); | ||
151 | return; | 152 | return; |
152 | } | 153 | } |
153 | de->length = 36; | 154 | de->length = 36; |
@@ -184,7 +185,7 @@ struct hpfs_dirent *hpfs_add_de(struct super_block *s, struct dnode *d, | |||
184 | de->not_8x3 = hpfs_is_name_long(name, namelen); | 185 | de->not_8x3 = hpfs_is_name_long(name, namelen); |
185 | de->namelen = namelen; | 186 | de->namelen = namelen; |
186 | memcpy(de->name, name, namelen); | 187 | memcpy(de->name, name, namelen); |
187 | d->first_free += d_size; | 188 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) + d_size); |
188 | return de; | 189 | return de; |
189 | } | 190 | } |
190 | 191 | ||
@@ -197,8 +198,8 @@ static void hpfs_delete_de(struct super_block *s, struct dnode *d, | |||
197 | hpfs_error(s, "attempt to delete last dirent in dnode %08x", d->self); | 198 | hpfs_error(s, "attempt to delete last dirent in dnode %08x", d->self); |
198 | return; | 199 | return; |
199 | } | 200 | } |
200 | d->first_free -= de->length; | 201 | d->first_free = cpu_to_le32(le32_to_cpu(d->first_free) - de->length); |
201 | memmove(de, de_next_de(de), d->first_free + (char *)d - (char *)de); | 202 | memmove(de, de_next_de(de), le32_to_cpu(d->first_free) + (char *)d - (char *)de); |
202 | } | 203 | } |
203 | 204 | ||
204 | static void fix_up_ptrs(struct super_block *s, struct dnode *d) | 205 | static void fix_up_ptrs(struct super_block *s, struct dnode *d) |
@@ -262,7 +263,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
262 | kfree(nname); | 263 | kfree(nname); |
263 | return 1; | 264 | return 1; |
264 | } | 265 | } |
265 | if (d->first_free + de_size(namelen, down_ptr) <= 2048) { | 266 | if (le32_to_cpu(d->first_free) + de_size(namelen, down_ptr) <= 2048) { |
266 | loff_t t; | 267 | loff_t t; |
267 | copy_de(de=hpfs_add_de(i->i_sb, d, name, namelen, down_ptr), new_de); | 268 | copy_de(de=hpfs_add_de(i->i_sb, d, name, namelen, down_ptr), new_de); |
268 | t = get_pos(d, de); | 269 | t = get_pos(d, de); |
@@ -286,11 +287,11 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
286 | kfree(nname); | 287 | kfree(nname); |
287 | return 1; | 288 | return 1; |
288 | } | 289 | } |
289 | memcpy(nd, d, d->first_free); | 290 | memcpy(nd, d, le32_to_cpu(d->first_free)); |
290 | copy_de(de = hpfs_add_de(i->i_sb, nd, name, namelen, down_ptr), new_de); | 291 | copy_de(de = hpfs_add_de(i->i_sb, nd, name, namelen, down_ptr), new_de); |
291 | for_all_poss(i, hpfs_pos_ins, get_pos(nd, de), 1); | 292 | for_all_poss(i, hpfs_pos_ins, get_pos(nd, de), 1); |
292 | h = ((char *)dnode_last_de(nd) - (char *)nd) / 2 + 10; | 293 | h = ((char *)dnode_last_de(nd) - (char *)nd) / 2 + 10; |
293 | if (!(ad = hpfs_alloc_dnode(i->i_sb, d->up, &adno, &qbh1, 0))) { | 294 | if (!(ad = hpfs_alloc_dnode(i->i_sb, d->up, &adno, &qbh1))) { |
294 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); | 295 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); |
295 | hpfs_brelse4(&qbh); | 296 | hpfs_brelse4(&qbh); |
296 | kfree(nd); | 297 | kfree(nd); |
@@ -313,9 +314,9 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
313 | down_ptr = adno; | 314 | down_ptr = adno; |
314 | set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0); | 315 | set_last_pointer(i->i_sb, ad, de->down ? de_down_pointer(de) : 0); |
315 | de = de_next_de(de); | 316 | de = de_next_de(de); |
316 | memmove((char *)nd + 20, de, nd->first_free + (char *)nd - (char *)de); | 317 | memmove((char *)nd + 20, de, le32_to_cpu(nd->first_free) + (char *)nd - (char *)de); |
317 | nd->first_free -= (char *)de - (char *)nd - 20; | 318 | nd->first_free = cpu_to_le32(le32_to_cpu(nd->first_free) - (char *)de - (char *)nd - 20); |
318 | memcpy(d, nd, nd->first_free); | 319 | memcpy(d, nd, le32_to_cpu(nd->first_free)); |
319 | for_all_poss(i, hpfs_pos_del, (loff_t)dno << 4, pos); | 320 | for_all_poss(i, hpfs_pos_del, (loff_t)dno << 4, pos); |
320 | fix_up_ptrs(i->i_sb, ad); | 321 | fix_up_ptrs(i->i_sb, ad); |
321 | if (!d->root_dnode) { | 322 | if (!d->root_dnode) { |
@@ -326,7 +327,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
326 | hpfs_brelse4(&qbh1); | 327 | hpfs_brelse4(&qbh1); |
327 | goto go_up; | 328 | goto go_up; |
328 | } | 329 | } |
329 | if (!(rd = hpfs_alloc_dnode(i->i_sb, d->up, &rdno, &qbh2, 0))) { | 330 | if (!(rd = hpfs_alloc_dnode(i->i_sb, d->up, &rdno, &qbh2))) { |
330 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); | 331 | hpfs_error(i->i_sb, "unable to alloc dnode - dnode tree will be corrupted"); |
331 | hpfs_brelse4(&qbh); | 332 | hpfs_brelse4(&qbh); |
332 | hpfs_brelse4(&qbh1); | 333 | hpfs_brelse4(&qbh1); |
@@ -373,7 +374,7 @@ static int hpfs_add_to_dnode(struct inode *i, dnode_secno dno, | |||
373 | 374 | ||
374 | int hpfs_add_dirent(struct inode *i, | 375 | int hpfs_add_dirent(struct inode *i, |
375 | const unsigned char *name, unsigned namelen, | 376 | const unsigned char *name, unsigned namelen, |
376 | struct hpfs_dirent *new_de, int cdepth) | 377 | struct hpfs_dirent *new_de) |
377 | { | 378 | { |
378 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); | 379 | struct hpfs_inode_info *hpfs_inode = hpfs_i(i); |
379 | struct dnode *d; | 380 | struct dnode *d; |
@@ -403,7 +404,6 @@ int hpfs_add_dirent(struct inode *i, | |||
403 | } | 404 | } |
404 | } | 405 | } |
405 | hpfs_brelse4(&qbh); | 406 | hpfs_brelse4(&qbh); |
406 | if (!cdepth) hpfs_lock_creation(i->i_sb); | ||
407 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_ADD)) { | 407 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_ADD)) { |
408 | c = 1; | 408 | c = 1; |
409 | goto ret; | 409 | goto ret; |
@@ -411,7 +411,6 @@ int hpfs_add_dirent(struct inode *i, | |||
411 | i->i_version++; | 411 | i->i_version++; |
412 | c = hpfs_add_to_dnode(i, dno, name, namelen, new_de, 0); | 412 | c = hpfs_add_to_dnode(i, dno, name, namelen, new_de, 0); |
413 | ret: | 413 | ret: |
414 | if (!cdepth) hpfs_unlock_creation(i->i_sb); | ||
415 | return c; | 414 | return c; |
416 | } | 415 | } |
417 | 416 | ||
@@ -474,7 +473,7 @@ static secno move_to_top(struct inode *i, dnode_secno from, dnode_secno to) | |||
474 | hpfs_brelse4(&qbh); | 473 | hpfs_brelse4(&qbh); |
475 | return 0; | 474 | return 0; |
476 | } | 475 | } |
477 | dnode->first_free -= 4; | 476 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4); |
478 | de->length -= 4; | 477 | de->length -= 4; |
479 | de->down = 0; | 478 | de->down = 0; |
480 | hpfs_mark_4buffers_dirty(&qbh); | 479 | hpfs_mark_4buffers_dirty(&qbh); |
@@ -517,8 +516,8 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
517 | try_it_again: | 516 | try_it_again: |
518 | if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "delete_empty_dnode")) return; | 517 | if (hpfs_stop_cycles(i->i_sb, dno, &c1, &c2, "delete_empty_dnode")) return; |
519 | if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return; | 518 | if (!(dnode = hpfs_map_dnode(i->i_sb, dno, &qbh))) return; |
520 | if (dnode->first_free > 56) goto end; | 519 | if (le32_to_cpu(dnode->first_free) > 56) goto end; |
521 | if (dnode->first_free == 52 || dnode->first_free == 56) { | 520 | if (le32_to_cpu(dnode->first_free) == 52 || le32_to_cpu(dnode->first_free) == 56) { |
522 | struct hpfs_dirent *de_end; | 521 | struct hpfs_dirent *de_end; |
523 | int root = dnode->root_dnode; | 522 | int root = dnode->root_dnode; |
524 | up = dnode->up; | 523 | up = dnode->up; |
@@ -571,9 +570,9 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
571 | if (!down) { | 570 | if (!down) { |
572 | de->down = 0; | 571 | de->down = 0; |
573 | de->length -= 4; | 572 | de->length -= 4; |
574 | dnode->first_free -= 4; | 573 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) - 4); |
575 | memmove(de_next_de(de), (char *)de_next_de(de) + 4, | 574 | memmove(de_next_de(de), (char *)de_next_de(de) + 4, |
576 | (char *)dnode + dnode->first_free - (char *)de_next_de(de)); | 575 | (char *)dnode + le32_to_cpu(dnode->first_free) - (char *)de_next_de(de)); |
577 | } else { | 576 | } else { |
578 | struct dnode *d1; | 577 | struct dnode *d1; |
579 | struct quad_buffer_head qbh1; | 578 | struct quad_buffer_head qbh1; |
@@ -585,7 +584,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
585 | } | 584 | } |
586 | } | 585 | } |
587 | } else { | 586 | } else { |
588 | hpfs_error(i->i_sb, "delete_empty_dnode: dnode %08x, first_free == %03x", dno, dnode->first_free); | 587 | hpfs_error(i->i_sb, "delete_empty_dnode: dnode %08x, first_free == %03x", dno, le32_to_cpu(dnode->first_free)); |
589 | goto end; | 588 | goto end; |
590 | } | 589 | } |
591 | 590 | ||
@@ -635,7 +634,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
635 | struct hpfs_dirent *del = dnode_last_de(d1); | 634 | struct hpfs_dirent *del = dnode_last_de(d1); |
636 | dlp = del->down ? de_down_pointer(del) : 0; | 635 | dlp = del->down ? de_down_pointer(del) : 0; |
637 | if (!dlp && down) { | 636 | if (!dlp && down) { |
638 | if (d1->first_free > 2044) { | 637 | if (le32_to_cpu(d1->first_free) > 2044) { |
639 | if (hpfs_sb(i->i_sb)->sb_chk >= 2) { | 638 | if (hpfs_sb(i->i_sb)->sb_chk >= 2) { |
640 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); | 639 | printk("HPFS: warning: unbalanced dnode tree, see hpfs.txt 4 more info\n"); |
641 | printk("HPFS: warning: terminating balancing operation\n"); | 640 | printk("HPFS: warning: terminating balancing operation\n"); |
@@ -649,12 +648,12 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
649 | } | 648 | } |
650 | del->length += 4; | 649 | del->length += 4; |
651 | del->down = 1; | 650 | del->down = 1; |
652 | d1->first_free += 4; | 651 | d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) + 4); |
653 | } | 652 | } |
654 | if (dlp && !down) { | 653 | if (dlp && !down) { |
655 | del->length -= 4; | 654 | del->length -= 4; |
656 | del->down = 0; | 655 | del->down = 0; |
657 | d1->first_free -= 4; | 656 | d1->first_free = cpu_to_le32(le32_to_cpu(d1->first_free) - 4); |
658 | } else if (down) | 657 | } else if (down) |
659 | *(dnode_secno *) ((void *) del + del->length - 4) = down; | 658 | *(dnode_secno *) ((void *) del + del->length - 4) = down; |
660 | } else goto endm; | 659 | } else goto endm; |
@@ -670,7 +669,7 @@ static void delete_empty_dnode(struct inode *i, dnode_secno dno) | |||
670 | if (!de_prev->down) { | 669 | if (!de_prev->down) { |
671 | de_prev->length += 4; | 670 | de_prev->length += 4; |
672 | de_prev->down = 1; | 671 | de_prev->down = 1; |
673 | dnode->first_free += 4; | 672 | dnode->first_free = cpu_to_le32(le32_to_cpu(dnode->first_free) + 4); |
674 | } | 673 | } |
675 | *(dnode_secno *) ((void *) de_prev + de_prev->length - 4) = ndown; | 674 | *(dnode_secno *) ((void *) de_prev + de_prev->length - 4) = ndown; |
676 | hpfs_mark_4buffers_dirty(&qbh); | 675 | hpfs_mark_4buffers_dirty(&qbh); |
@@ -701,7 +700,6 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, | |||
701 | { | 700 | { |
702 | struct dnode *dnode = qbh->data; | 701 | struct dnode *dnode = qbh->data; |
703 | dnode_secno down = 0; | 702 | dnode_secno down = 0; |
704 | int lock = 0; | ||
705 | loff_t t; | 703 | loff_t t; |
706 | if (de->first || de->last) { | 704 | if (de->first || de->last) { |
707 | hpfs_error(i->i_sb, "hpfs_remove_dirent: attempt to delete first or last dirent in dnode %08x", dno); | 705 | hpfs_error(i->i_sb, "hpfs_remove_dirent: attempt to delete first or last dirent in dnode %08x", dno); |
@@ -710,11 +708,8 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, | |||
710 | } | 708 | } |
711 | if (de->down) down = de_down_pointer(de); | 709 | if (de->down) down = de_down_pointer(de); |
712 | if (depth && (de->down || (de == dnode_first_de(dnode) && de_next_de(de)->last))) { | 710 | if (depth && (de->down || (de == dnode_first_de(dnode) && de_next_de(de)->last))) { |
713 | lock = 1; | ||
714 | hpfs_lock_creation(i->i_sb); | ||
715 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_DEL)) { | 711 | if (hpfs_check_free_dnodes(i->i_sb, FREE_DNODES_DEL)) { |
716 | hpfs_brelse4(qbh); | 712 | hpfs_brelse4(qbh); |
717 | hpfs_unlock_creation(i->i_sb); | ||
718 | return 2; | 713 | return 2; |
719 | } | 714 | } |
720 | } | 715 | } |
@@ -727,11 +722,9 @@ int hpfs_remove_dirent(struct inode *i, dnode_secno dno, struct hpfs_dirent *de, | |||
727 | dnode_secno a = move_to_top(i, down, dno); | 722 | dnode_secno a = move_to_top(i, down, dno); |
728 | for_all_poss(i, hpfs_pos_subst, 5, t); | 723 | for_all_poss(i, hpfs_pos_subst, 5, t); |
729 | if (a) delete_empty_dnode(i, a); | 724 | if (a) delete_empty_dnode(i, a); |
730 | if (lock) hpfs_unlock_creation(i->i_sb); | ||
731 | return !a; | 725 | return !a; |
732 | } | 726 | } |
733 | delete_empty_dnode(i, dno); | 727 | delete_empty_dnode(i, dno); |
734 | if (lock) hpfs_unlock_creation(i->i_sb); | ||
735 | return 0; | 728 | return 0; |
736 | } | 729 | } |
737 | 730 | ||
diff --git a/fs/hpfs/ea.c b/fs/hpfs/ea.c index 45e53d972b42..1ac05bb6de37 100644 --- a/fs/hpfs/ea.c +++ b/fs/hpfs/ea.c | |||
@@ -266,7 +266,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
266 | secno n; | 266 | secno n; |
267 | struct buffer_head *bh; | 267 | struct buffer_head *bh; |
268 | char *data; | 268 | char *data; |
269 | if (!(n = hpfs_alloc_sector(s, fno, 1, 0, 1))) return; | 269 | if (!(n = hpfs_alloc_sector(s, fno, 1, 0))) return; |
270 | if (!(data = hpfs_get_sector(s, n, &bh))) { | 270 | if (!(data = hpfs_get_sector(s, n, &bh))) { |
271 | hpfs_free_sectors(s, n, 1); | 271 | hpfs_free_sectors(s, n, 1); |
272 | return; | 272 | return; |
@@ -284,7 +284,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
284 | if (pos >= 30000) goto bail; | 284 | if (pos >= 30000) goto bail; |
285 | while (((pos + 511) >> 9) > len) { | 285 | while (((pos + 511) >> 9) > len) { |
286 | if (!len) { | 286 | if (!len) { |
287 | if (!(fnode->ea_secno = hpfs_alloc_sector(s, fno, 1, 0, 1))) | 287 | if (!(fnode->ea_secno = hpfs_alloc_sector(s, fno, 1, 0))) |
288 | goto bail; | 288 | goto bail; |
289 | fnode->ea_anode = 0; | 289 | fnode->ea_anode = 0; |
290 | len++; | 290 | len++; |
@@ -312,7 +312,7 @@ void hpfs_set_ea(struct inode *inode, struct fnode *fnode, const char *key, | |||
312 | fnode->ea_secno = a_s;*/ | 312 | fnode->ea_secno = a_s;*/ |
313 | secno new_sec; | 313 | secno new_sec; |
314 | int i; | 314 | int i; |
315 | if (!(new_sec = hpfs_alloc_sector(s, fno, 1, 1 - ((pos + 511) >> 9), 1))) | 315 | if (!(new_sec = hpfs_alloc_sector(s, fno, 1, 1 - ((pos + 511) >> 9)))) |
316 | goto bail; | 316 | goto bail; |
317 | for (i = 0; i < len; i++) { | 317 | for (i = 0; i < len; i++) { |
318 | struct buffer_head *bh1, *bh2; | 318 | struct buffer_head *bh1, *bh2; |
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h index 89a4714b44c7..860d09f199b2 100644 --- a/fs/hpfs/hpfs_fn.h +++ b/fs/hpfs/hpfs_fn.h | |||
@@ -56,8 +56,6 @@ struct hpfs_inode_info { | |||
56 | unsigned i_ea_uid : 1; /* file's uid is stored in ea */ | 56 | unsigned i_ea_uid : 1; /* file's uid is stored in ea */ |
57 | unsigned i_ea_gid : 1; /* file's gid is stored in ea */ | 57 | unsigned i_ea_gid : 1; /* file's gid is stored in ea */ |
58 | unsigned i_dirty : 1; | 58 | unsigned i_dirty : 1; |
59 | struct mutex i_mutex; | ||
60 | struct mutex i_parent_mutex; | ||
61 | loff_t **i_rddir_off; | 59 | loff_t **i_rddir_off; |
62 | struct inode vfs_inode; | 60 | struct inode vfs_inode; |
63 | }; | 61 | }; |
@@ -88,8 +86,6 @@ struct hpfs_sb_info { | |||
88 | unsigned *sb_bmp_dir; /* main bitmap directory */ | 86 | unsigned *sb_bmp_dir; /* main bitmap directory */ |
89 | unsigned sb_c_bitmap; /* current bitmap */ | 87 | unsigned sb_c_bitmap; /* current bitmap */ |
90 | unsigned sb_max_fwd_alloc; /* max forwad allocation */ | 88 | unsigned sb_max_fwd_alloc; /* max forwad allocation */ |
91 | struct mutex hpfs_creation_de; /* when creating dirents, nobody else | ||
92 | can alloc blocks */ | ||
93 | /*unsigned sb_mounting : 1;*/ | 89 | /*unsigned sb_mounting : 1;*/ |
94 | int sb_timeshift; | 90 | int sb_timeshift; |
95 | }; | 91 | }; |
@@ -201,12 +197,12 @@ static inline unsigned tstbits(unsigned *bmp, unsigned b, unsigned n) | |||
201 | /* alloc.c */ | 197 | /* alloc.c */ |
202 | 198 | ||
203 | int hpfs_chk_sectors(struct super_block *, secno, int, char *); | 199 | int hpfs_chk_sectors(struct super_block *, secno, int, char *); |
204 | secno hpfs_alloc_sector(struct super_block *, secno, unsigned, int, int); | 200 | secno hpfs_alloc_sector(struct super_block *, secno, unsigned, int); |
205 | int hpfs_alloc_if_possible(struct super_block *, secno); | 201 | int hpfs_alloc_if_possible(struct super_block *, secno); |
206 | void hpfs_free_sectors(struct super_block *, secno, unsigned); | 202 | void hpfs_free_sectors(struct super_block *, secno, unsigned); |
207 | int hpfs_check_free_dnodes(struct super_block *, int); | 203 | int hpfs_check_free_dnodes(struct super_block *, int); |
208 | void hpfs_free_dnode(struct super_block *, secno); | 204 | void hpfs_free_dnode(struct super_block *, secno); |
209 | struct dnode *hpfs_alloc_dnode(struct super_block *, secno, dnode_secno *, struct quad_buffer_head *, int); | 205 | struct dnode *hpfs_alloc_dnode(struct super_block *, secno, dnode_secno *, struct quad_buffer_head *); |
210 | struct fnode *hpfs_alloc_fnode(struct super_block *, secno, fnode_secno *, struct buffer_head **); | 206 | struct fnode *hpfs_alloc_fnode(struct super_block *, secno, fnode_secno *, struct buffer_head **); |
211 | struct anode *hpfs_alloc_anode(struct super_block *, secno, anode_secno *, struct buffer_head **); | 207 | struct anode *hpfs_alloc_anode(struct super_block *, secno, anode_secno *, struct buffer_head **); |
212 | 208 | ||
@@ -223,8 +219,6 @@ void hpfs_remove_fnode(struct super_block *, fnode_secno fno); | |||
223 | 219 | ||
224 | /* buffer.c */ | 220 | /* buffer.c */ |
225 | 221 | ||
226 | void hpfs_lock_creation(struct super_block *); | ||
227 | void hpfs_unlock_creation(struct super_block *); | ||
228 | void *hpfs_map_sector(struct super_block *, unsigned, struct buffer_head **, int); | 222 | void *hpfs_map_sector(struct super_block *, unsigned, struct buffer_head **, int); |
229 | void *hpfs_get_sector(struct super_block *, unsigned, struct buffer_head **); | 223 | void *hpfs_get_sector(struct super_block *, unsigned, struct buffer_head **); |
230 | void *hpfs_map_4sectors(struct super_block *, unsigned, struct quad_buffer_head *, int); | 224 | void *hpfs_map_4sectors(struct super_block *, unsigned, struct quad_buffer_head *, int); |
@@ -248,7 +242,7 @@ void hpfs_del_pos(struct inode *, loff_t *); | |||
248 | struct hpfs_dirent *hpfs_add_de(struct super_block *, struct dnode *, | 242 | struct hpfs_dirent *hpfs_add_de(struct super_block *, struct dnode *, |
249 | const unsigned char *, unsigned, secno); | 243 | const unsigned char *, unsigned, secno); |
250 | int hpfs_add_dirent(struct inode *, const unsigned char *, unsigned, | 244 | int hpfs_add_dirent(struct inode *, const unsigned char *, unsigned, |
251 | struct hpfs_dirent *, int); | 245 | struct hpfs_dirent *); |
252 | int hpfs_remove_dirent(struct inode *, dnode_secno, struct hpfs_dirent *, struct quad_buffer_head *, int); | 246 | int hpfs_remove_dirent(struct inode *, dnode_secno, struct hpfs_dirent *, struct quad_buffer_head *, int); |
253 | void hpfs_count_dnodes(struct super_block *, dnode_secno, int *, int *, int *); | 247 | void hpfs_count_dnodes(struct super_block *, dnode_secno, int *, int *, int *); |
254 | dnode_secno hpfs_de_as_down_as_possible(struct super_block *, dnode_secno dno); | 248 | dnode_secno hpfs_de_as_down_as_possible(struct super_block *, dnode_secno dno); |
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c index 87f1f787e767..29cf0508d271 100644 --- a/fs/hpfs/inode.c +++ b/fs/hpfs/inode.c | |||
@@ -187,9 +187,7 @@ void hpfs_write_inode(struct inode *i) | |||
187 | kfree(hpfs_inode->i_rddir_off); | 187 | kfree(hpfs_inode->i_rddir_off); |
188 | hpfs_inode->i_rddir_off = NULL; | 188 | hpfs_inode->i_rddir_off = NULL; |
189 | } | 189 | } |
190 | mutex_lock(&hpfs_inode->i_parent_mutex); | ||
191 | if (!i->i_nlink) { | 190 | if (!i->i_nlink) { |
192 | mutex_unlock(&hpfs_inode->i_parent_mutex); | ||
193 | return; | 191 | return; |
194 | } | 192 | } |
195 | parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir); | 193 | parent = iget_locked(i->i_sb, hpfs_inode->i_parent_dir); |
@@ -200,14 +198,11 @@ void hpfs_write_inode(struct inode *i) | |||
200 | hpfs_read_inode(parent); | 198 | hpfs_read_inode(parent); |
201 | unlock_new_inode(parent); | 199 | unlock_new_inode(parent); |
202 | } | 200 | } |
203 | mutex_lock(&hpfs_inode->i_mutex); | ||
204 | hpfs_write_inode_nolock(i); | 201 | hpfs_write_inode_nolock(i); |
205 | mutex_unlock(&hpfs_inode->i_mutex); | ||
206 | iput(parent); | 202 | iput(parent); |
207 | } else { | 203 | } else { |
208 | mark_inode_dirty(i); | 204 | mark_inode_dirty(i); |
209 | } | 205 | } |
210 | mutex_unlock(&hpfs_inode->i_parent_mutex); | ||
211 | } | 206 | } |
212 | 207 | ||
213 | void hpfs_write_inode_nolock(struct inode *i) | 208 | void hpfs_write_inode_nolock(struct inode *i) |
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c index d5f8c8a19023..8c9f91537195 100644 --- a/fs/hpfs/namei.c +++ b/fs/hpfs/namei.c | |||
@@ -29,7 +29,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
29 | fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); | 29 | fnode = hpfs_alloc_fnode(dir->i_sb, hpfs_i(dir)->i_dno, &fno, &bh); |
30 | if (!fnode) | 30 | if (!fnode) |
31 | goto bail; | 31 | goto bail; |
32 | dnode = hpfs_alloc_dnode(dir->i_sb, fno, &dno, &qbh0, 1); | 32 | dnode = hpfs_alloc_dnode(dir->i_sb, fno, &dno, &qbh0); |
33 | if (!dnode) | 33 | if (!dnode) |
34 | goto bail1; | 34 | goto bail1; |
35 | memset(&dee, 0, sizeof dee); | 35 | memset(&dee, 0, sizeof dee); |
@@ -60,8 +60,7 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
60 | if (dee.read_only) | 60 | if (dee.read_only) |
61 | result->i_mode &= ~0222; | 61 | result->i_mode &= ~0222; |
62 | 62 | ||
63 | mutex_lock(&hpfs_i(dir)->i_mutex); | 63 | r = hpfs_add_dirent(dir, name, len, &dee); |
64 | r = hpfs_add_dirent(dir, name, len, &dee, 0); | ||
65 | if (r == 1) | 64 | if (r == 1) |
66 | goto bail3; | 65 | goto bail3; |
67 | if (r == -1) { | 66 | if (r == -1) { |
@@ -101,11 +100,9 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
101 | hpfs_write_inode_nolock(result); | 100 | hpfs_write_inode_nolock(result); |
102 | } | 101 | } |
103 | d_instantiate(dentry, result); | 102 | d_instantiate(dentry, result); |
104 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
105 | hpfs_unlock(dir->i_sb); | 103 | hpfs_unlock(dir->i_sb); |
106 | return 0; | 104 | return 0; |
107 | bail3: | 105 | bail3: |
108 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
109 | iput(result); | 106 | iput(result); |
110 | bail2: | 107 | bail2: |
111 | hpfs_brelse4(&qbh0); | 108 | hpfs_brelse4(&qbh0); |
@@ -168,8 +165,7 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
168 | result->i_data.a_ops = &hpfs_aops; | 165 | result->i_data.a_ops = &hpfs_aops; |
169 | hpfs_i(result)->mmu_private = 0; | 166 | hpfs_i(result)->mmu_private = 0; |
170 | 167 | ||
171 | mutex_lock(&hpfs_i(dir)->i_mutex); | 168 | r = hpfs_add_dirent(dir, name, len, &dee); |
172 | r = hpfs_add_dirent(dir, name, len, &dee, 0); | ||
173 | if (r == 1) | 169 | if (r == 1) |
174 | goto bail2; | 170 | goto bail2; |
175 | if (r == -1) { | 171 | if (r == -1) { |
@@ -193,12 +189,10 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, int mode, struc | |||
193 | hpfs_write_inode_nolock(result); | 189 | hpfs_write_inode_nolock(result); |
194 | } | 190 | } |
195 | d_instantiate(dentry, result); | 191 | d_instantiate(dentry, result); |
196 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
197 | hpfs_unlock(dir->i_sb); | 192 | hpfs_unlock(dir->i_sb); |
198 | return 0; | 193 | return 0; |
199 | 194 | ||
200 | bail2: | 195 | bail2: |
201 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
202 | iput(result); | 196 | iput(result); |
203 | bail1: | 197 | bail1: |
204 | brelse(bh); | 198 | brelse(bh); |
@@ -254,8 +248,7 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t | |||
254 | result->i_blocks = 1; | 248 | result->i_blocks = 1; |
255 | init_special_inode(result, mode, rdev); | 249 | init_special_inode(result, mode, rdev); |
256 | 250 | ||
257 | mutex_lock(&hpfs_i(dir)->i_mutex); | 251 | r = hpfs_add_dirent(dir, name, len, &dee); |
258 | r = hpfs_add_dirent(dir, name, len, &dee, 0); | ||
259 | if (r == 1) | 252 | if (r == 1) |
260 | goto bail2; | 253 | goto bail2; |
261 | if (r == -1) { | 254 | if (r == -1) { |
@@ -271,12 +264,10 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t | |||
271 | 264 | ||
272 | hpfs_write_inode_nolock(result); | 265 | hpfs_write_inode_nolock(result); |
273 | d_instantiate(dentry, result); | 266 | d_instantiate(dentry, result); |
274 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
275 | brelse(bh); | 267 | brelse(bh); |
276 | hpfs_unlock(dir->i_sb); | 268 | hpfs_unlock(dir->i_sb); |
277 | return 0; | 269 | return 0; |
278 | bail2: | 270 | bail2: |
279 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
280 | iput(result); | 271 | iput(result); |
281 | bail1: | 272 | bail1: |
282 | brelse(bh); | 273 | brelse(bh); |
@@ -333,8 +324,7 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
333 | result->i_op = &page_symlink_inode_operations; | 324 | result->i_op = &page_symlink_inode_operations; |
334 | result->i_data.a_ops = &hpfs_symlink_aops; | 325 | result->i_data.a_ops = &hpfs_symlink_aops; |
335 | 326 | ||
336 | mutex_lock(&hpfs_i(dir)->i_mutex); | 327 | r = hpfs_add_dirent(dir, name, len, &dee); |
337 | r = hpfs_add_dirent(dir, name, len, &dee, 0); | ||
338 | if (r == 1) | 328 | if (r == 1) |
339 | goto bail2; | 329 | goto bail2; |
340 | if (r == -1) { | 330 | if (r == -1) { |
@@ -352,11 +342,9 @@ static int hpfs_symlink(struct inode *dir, struct dentry *dentry, const char *sy | |||
352 | 342 | ||
353 | hpfs_write_inode_nolock(result); | 343 | hpfs_write_inode_nolock(result); |
354 | d_instantiate(dentry, result); | 344 | d_instantiate(dentry, result); |
355 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
356 | hpfs_unlock(dir->i_sb); | 345 | hpfs_unlock(dir->i_sb); |
357 | return 0; | 346 | return 0; |
358 | bail2: | 347 | bail2: |
359 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
360 | iput(result); | 348 | iput(result); |
361 | bail1: | 349 | bail1: |
362 | brelse(bh); | 350 | brelse(bh); |
@@ -382,8 +370,6 @@ static int hpfs_unlink(struct inode *dir, struct dentry *dentry) | |||
382 | hpfs_lock(dir->i_sb); | 370 | hpfs_lock(dir->i_sb); |
383 | hpfs_adjust_length(name, &len); | 371 | hpfs_adjust_length(name, &len); |
384 | again: | 372 | again: |
385 | mutex_lock(&hpfs_i(inode)->i_parent_mutex); | ||
386 | mutex_lock(&hpfs_i(dir)->i_mutex); | ||
387 | err = -ENOENT; | 373 | err = -ENOENT; |
388 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); | 374 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); |
389 | if (!de) | 375 | if (!de) |
@@ -410,8 +396,6 @@ again: | |||
410 | if (rep++) | 396 | if (rep++) |
411 | break; | 397 | break; |
412 | 398 | ||
413 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
414 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); | ||
415 | dentry_unhash(dentry); | 399 | dentry_unhash(dentry); |
416 | if (!d_unhashed(dentry)) { | 400 | if (!d_unhashed(dentry)) { |
417 | dput(dentry); | 401 | dput(dentry); |
@@ -445,8 +429,6 @@ again: | |||
445 | out1: | 429 | out1: |
446 | hpfs_brelse4(&qbh); | 430 | hpfs_brelse4(&qbh); |
447 | out: | 431 | out: |
448 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
449 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); | ||
450 | hpfs_unlock(dir->i_sb); | 432 | hpfs_unlock(dir->i_sb); |
451 | return err; | 433 | return err; |
452 | } | 434 | } |
@@ -466,8 +448,6 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
466 | 448 | ||
467 | hpfs_adjust_length(name, &len); | 449 | hpfs_adjust_length(name, &len); |
468 | hpfs_lock(dir->i_sb); | 450 | hpfs_lock(dir->i_sb); |
469 | mutex_lock(&hpfs_i(inode)->i_parent_mutex); | ||
470 | mutex_lock(&hpfs_i(dir)->i_mutex); | ||
471 | err = -ENOENT; | 451 | err = -ENOENT; |
472 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); | 452 | de = map_dirent(dir, hpfs_i(dir)->i_dno, name, len, &dno, &qbh); |
473 | if (!de) | 453 | if (!de) |
@@ -505,8 +485,6 @@ static int hpfs_rmdir(struct inode *dir, struct dentry *dentry) | |||
505 | out1: | 485 | out1: |
506 | hpfs_brelse4(&qbh); | 486 | hpfs_brelse4(&qbh); |
507 | out: | 487 | out: |
508 | mutex_unlock(&hpfs_i(dir)->i_mutex); | ||
509 | mutex_unlock(&hpfs_i(inode)->i_parent_mutex); | ||
510 | hpfs_unlock(dir->i_sb); | 488 | hpfs_unlock(dir->i_sb); |
511 | return err; | 489 | return err; |
512 | } | 490 | } |
@@ -568,12 +546,6 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
568 | 546 | ||
569 | hpfs_lock(i->i_sb); | 547 | hpfs_lock(i->i_sb); |
570 | /* order doesn't matter, due to VFS exclusion */ | 548 | /* order doesn't matter, due to VFS exclusion */ |
571 | mutex_lock(&hpfs_i(i)->i_parent_mutex); | ||
572 | if (new_inode) | ||
573 | mutex_lock(&hpfs_i(new_inode)->i_parent_mutex); | ||
574 | mutex_lock(&hpfs_i(old_dir)->i_mutex); | ||
575 | if (new_dir != old_dir) | ||
576 | mutex_lock(&hpfs_i(new_dir)->i_mutex); | ||
577 | 549 | ||
578 | /* Erm? Moving over the empty non-busy directory is perfectly legal */ | 550 | /* Erm? Moving over the empty non-busy directory is perfectly legal */ |
579 | if (new_inode && S_ISDIR(new_inode->i_mode)) { | 551 | if (new_inode && S_ISDIR(new_inode->i_mode)) { |
@@ -610,9 +582,7 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
610 | 582 | ||
611 | if (new_dir == old_dir) hpfs_brelse4(&qbh); | 583 | if (new_dir == old_dir) hpfs_brelse4(&qbh); |
612 | 584 | ||
613 | hpfs_lock_creation(i->i_sb); | 585 | if ((r = hpfs_add_dirent(new_dir, new_name, new_len, &de))) { |
614 | if ((r = hpfs_add_dirent(new_dir, new_name, new_len, &de, 1))) { | ||
615 | hpfs_unlock_creation(i->i_sb); | ||
616 | if (r == -1) hpfs_error(new_dir->i_sb, "hpfs_rename: dirent already exists!"); | 586 | if (r == -1) hpfs_error(new_dir->i_sb, "hpfs_rename: dirent already exists!"); |
617 | err = r == 1 ? -ENOSPC : -EFSERROR; | 587 | err = r == 1 ? -ENOSPC : -EFSERROR; |
618 | if (new_dir != old_dir) hpfs_brelse4(&qbh); | 588 | if (new_dir != old_dir) hpfs_brelse4(&qbh); |
@@ -621,20 +591,17 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
621 | 591 | ||
622 | if (new_dir == old_dir) | 592 | if (new_dir == old_dir) |
623 | if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) { | 593 | if (!(dep = map_dirent(old_dir, hpfs_i(old_dir)->i_dno, old_name, old_len, &dno, &qbh))) { |
624 | hpfs_unlock_creation(i->i_sb); | ||
625 | hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2"); | 594 | hpfs_error(i->i_sb, "lookup succeeded but map dirent failed at #2"); |
626 | err = -ENOENT; | 595 | err = -ENOENT; |
627 | goto end1; | 596 | goto end1; |
628 | } | 597 | } |
629 | 598 | ||
630 | if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) { | 599 | if ((r = hpfs_remove_dirent(old_dir, dno, dep, &qbh, 0))) { |
631 | hpfs_unlock_creation(i->i_sb); | ||
632 | hpfs_error(i->i_sb, "hpfs_rename: could not remove dirent"); | 600 | hpfs_error(i->i_sb, "hpfs_rename: could not remove dirent"); |
633 | err = r == 2 ? -ENOSPC : -EFSERROR; | 601 | err = r == 2 ? -ENOSPC : -EFSERROR; |
634 | goto end1; | 602 | goto end1; |
635 | } | 603 | } |
636 | hpfs_unlock_creation(i->i_sb); | 604 | |
637 | |||
638 | end: | 605 | end: |
639 | hpfs_i(i)->i_parent_dir = new_dir->i_ino; | 606 | hpfs_i(i)->i_parent_dir = new_dir->i_ino; |
640 | if (S_ISDIR(i->i_mode)) { | 607 | if (S_ISDIR(i->i_mode)) { |
@@ -652,12 +619,6 @@ static int hpfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
652 | hpfs_i(i)->i_conv = hpfs_sb(i->i_sb)->sb_conv; | 619 | hpfs_i(i)->i_conv = hpfs_sb(i->i_sb)->sb_conv; |
653 | hpfs_decide_conv(i, new_name, new_len); | 620 | hpfs_decide_conv(i, new_name, new_len); |
654 | end1: | 621 | end1: |
655 | if (old_dir != new_dir) | ||
656 | mutex_unlock(&hpfs_i(new_dir)->i_mutex); | ||
657 | mutex_unlock(&hpfs_i(old_dir)->i_mutex); | ||
658 | mutex_unlock(&hpfs_i(i)->i_parent_mutex); | ||
659 | if (new_inode) | ||
660 | mutex_unlock(&hpfs_i(new_inode)->i_parent_mutex); | ||
661 | hpfs_unlock(i->i_sb); | 622 | hpfs_unlock(i->i_sb); |
662 | return err; | 623 | return err; |
663 | } | 624 | } |
diff --git a/fs/hpfs/super.c b/fs/hpfs/super.c index 41232c2d60dc..6493377cbef5 100644 --- a/fs/hpfs/super.c +++ b/fs/hpfs/super.c | |||
@@ -191,8 +191,6 @@ static void init_once(void *foo) | |||
191 | { | 191 | { |
192 | struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; | 192 | struct hpfs_inode_info *ei = (struct hpfs_inode_info *) foo; |
193 | 193 | ||
194 | mutex_init(&ei->i_mutex); | ||
195 | mutex_init(&ei->i_parent_mutex); | ||
196 | inode_init_once(&ei->vfs_inode); | 194 | inode_init_once(&ei->vfs_inode); |
197 | } | 195 | } |
198 | 196 | ||
@@ -496,8 +494,6 @@ static int hpfs_fill_super(struct super_block *s, void *options, int silent) | |||
496 | mutex_init(&sbi->hpfs_mutex); | 494 | mutex_init(&sbi->hpfs_mutex); |
497 | hpfs_lock(s); | 495 | hpfs_lock(s); |
498 | 496 | ||
499 | mutex_init(&sbi->hpfs_creation_de); | ||
500 | |||
501 | uid = current_uid(); | 497 | uid = current_uid(); |
502 | gid = current_gid(); | 498 | gid = current_gid(); |
503 | umask = current_umask(); | 499 | umask = current_umask(); |