diff options
Diffstat (limited to 'fs/hfsplus/super.c')
| -rw-r--r-- | fs/hfsplus/super.c | 75 |
1 files changed, 24 insertions, 51 deletions
diff --git a/fs/hfsplus/super.c b/fs/hfsplus/super.c index 8093351bd7c3..7843f792a4b7 100644 --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c | |||
| @@ -22,29 +22,12 @@ static void hfsplus_destroy_inode(struct inode *inode); | |||
| 22 | 22 | ||
| 23 | #include "hfsplus_fs.h" | 23 | #include "hfsplus_fs.h" |
| 24 | 24 | ||
| 25 | void hfsplus_inode_check(struct super_block *sb) | ||
| 26 | { | ||
| 27 | #if 0 | ||
| 28 | u32 cnt = atomic_read(&HFSPLUS_SB(sb).inode_cnt); | ||
| 29 | u32 last_cnt = HFSPLUS_SB(sb).last_inode_cnt; | ||
| 30 | |||
| 31 | if (cnt <= (last_cnt / 2) || | ||
| 32 | cnt >= (last_cnt * 2)) { | ||
| 33 | HFSPLUS_SB(sb).last_inode_cnt = cnt; | ||
| 34 | printk("inode_check: %u,%u,%u\n", cnt, last_cnt, | ||
| 35 | HFSPLUS_SB(sb).cat_tree ? HFSPLUS_SB(sb).cat_tree->node_hash_cnt : 0); | ||
| 36 | } | ||
| 37 | #endif | ||
| 38 | } | ||
| 39 | |||
| 40 | static void hfsplus_read_inode(struct inode *inode) | 25 | static void hfsplus_read_inode(struct inode *inode) |
| 41 | { | 26 | { |
| 42 | struct hfs_find_data fd; | 27 | struct hfs_find_data fd; |
| 43 | struct hfsplus_vh *vhdr; | 28 | struct hfsplus_vh *vhdr; |
| 44 | int err; | 29 | int err; |
| 45 | 30 | ||
| 46 | atomic_inc(&HFSPLUS_SB(inode->i_sb).inode_cnt); | ||
| 47 | hfsplus_inode_check(inode->i_sb); | ||
| 48 | INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); | 31 | INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list); |
| 49 | init_MUTEX(&HFSPLUS_I(inode).extents_lock); | 32 | init_MUTEX(&HFSPLUS_I(inode).extents_lock); |
| 50 | HFSPLUS_I(inode).flags = 0; | 33 | HFSPLUS_I(inode).flags = 0; |
| @@ -155,12 +138,10 @@ static int hfsplus_write_inode(struct inode *inode, int unused) | |||
| 155 | static void hfsplus_clear_inode(struct inode *inode) | 138 | static void hfsplus_clear_inode(struct inode *inode) |
| 156 | { | 139 | { |
| 157 | dprint(DBG_INODE, "hfsplus_clear_inode: %lu\n", inode->i_ino); | 140 | dprint(DBG_INODE, "hfsplus_clear_inode: %lu\n", inode->i_ino); |
| 158 | atomic_dec(&HFSPLUS_SB(inode->i_sb).inode_cnt); | ||
| 159 | if (HFSPLUS_IS_RSRC(inode)) { | 141 | if (HFSPLUS_IS_RSRC(inode)) { |
| 160 | HFSPLUS_I(HFSPLUS_I(inode).rsrc_inode).rsrc_inode = NULL; | 142 | HFSPLUS_I(HFSPLUS_I(inode).rsrc_inode).rsrc_inode = NULL; |
| 161 | iput(HFSPLUS_I(inode).rsrc_inode); | 143 | iput(HFSPLUS_I(inode).rsrc_inode); |
| 162 | } | 144 | } |
| 163 | hfsplus_inode_check(inode->i_sb); | ||
| 164 | } | 145 | } |
| 165 | 146 | ||
| 166 | static void hfsplus_write_super(struct super_block *sb) | 147 | static void hfsplus_write_super(struct super_block *sb) |
| @@ -188,7 +169,7 @@ static void hfsplus_write_super(struct super_block *sb) | |||
| 188 | block = HFSPLUS_SB(sb).blockoffset; | 169 | block = HFSPLUS_SB(sb).blockoffset; |
| 189 | block += (HFSPLUS_SB(sb).sect_count - 2) >> (sb->s_blocksize_bits - 9); | 170 | block += (HFSPLUS_SB(sb).sect_count - 2) >> (sb->s_blocksize_bits - 9); |
| 190 | offset = ((HFSPLUS_SB(sb).sect_count - 2) << 9) & (sb->s_blocksize - 1); | 171 | offset = ((HFSPLUS_SB(sb).sect_count - 2) << 9) & (sb->s_blocksize - 1); |
| 191 | printk("backup: %u,%u,%u,%u\n", HFSPLUS_SB(sb).blockoffset, | 172 | printk(KERN_DEBUG "hfs: backup: %u,%u,%u,%u\n", HFSPLUS_SB(sb).blockoffset, |
| 192 | HFSPLUS_SB(sb).sect_count, block, offset); | 173 | HFSPLUS_SB(sb).sect_count, block, offset); |
| 193 | bh = sb_bread(sb, block); | 174 | bh = sb_bread(sb, block); |
| 194 | if (bh) { | 175 | if (bh) { |
| @@ -198,7 +179,7 @@ static void hfsplus_write_super(struct super_block *sb) | |||
| 198 | mark_buffer_dirty(bh); | 179 | mark_buffer_dirty(bh); |
| 199 | brelse(bh); | 180 | brelse(bh); |
| 200 | } else | 181 | } else |
| 201 | printk("backup not found!\n"); | 182 | printk(KERN_WARNING "hfs: backup not found!\n"); |
| 202 | } | 183 | } |
| 203 | } | 184 | } |
| 204 | HFSPLUS_SB(sb).flags &= ~HFSPLUS_SB_WRITEBACKUP; | 185 | HFSPLUS_SB(sb).flags &= ~HFSPLUS_SB_WRITEBACKUP; |
| @@ -259,18 +240,18 @@ static int hfsplus_remount(struct super_block *sb, int *flags, char *data) | |||
| 259 | return -EINVAL; | 240 | return -EINVAL; |
| 260 | 241 | ||
| 261 | if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { | 242 | if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { |
| 262 | printk("HFS+-fs warning: Filesystem was not cleanly unmounted, " | 243 | printk(KERN_WARNING "hfs: filesystem was not cleanly unmounted, " |
| 263 | "running fsck.hfsplus is recommended. leaving read-only.\n"); | 244 | "running fsck.hfsplus is recommended. leaving read-only.\n"); |
| 264 | sb->s_flags |= MS_RDONLY; | 245 | sb->s_flags |= MS_RDONLY; |
| 265 | *flags |= MS_RDONLY; | 246 | *flags |= MS_RDONLY; |
| 266 | } else if (sbi.flags & HFSPLUS_SB_FORCE) { | 247 | } else if (sbi.flags & HFSPLUS_SB_FORCE) { |
| 267 | /* nothing */ | 248 | /* nothing */ |
| 268 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) { | 249 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) { |
| 269 | printk("HFS+-fs: Filesystem is marked locked, leaving read-only.\n"); | 250 | printk(KERN_WARNING "hfs: filesystem is marked locked, leaving read-only.\n"); |
| 270 | sb->s_flags |= MS_RDONLY; | 251 | sb->s_flags |= MS_RDONLY; |
| 271 | *flags |= MS_RDONLY; | 252 | *flags |= MS_RDONLY; |
| 272 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) { | 253 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) { |
| 273 | printk("HFS+-fs: Filesystem is marked journaled, leaving read-only.\n"); | 254 | printk(KERN_WARNING "hfs: filesystem is marked journaled, leaving read-only.\n"); |
| 274 | sb->s_flags |= MS_RDONLY; | 255 | sb->s_flags |= MS_RDONLY; |
| 275 | *flags |= MS_RDONLY; | 256 | *flags |= MS_RDONLY; |
| 276 | } | 257 | } |
| @@ -311,8 +292,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
| 311 | INIT_HLIST_HEAD(&sbi->rsrc_inodes); | 292 | INIT_HLIST_HEAD(&sbi->rsrc_inodes); |
| 312 | hfsplus_fill_defaults(sbi); | 293 | hfsplus_fill_defaults(sbi); |
| 313 | if (!hfsplus_parse_options(data, sbi)) { | 294 | if (!hfsplus_parse_options(data, sbi)) { |
| 314 | if (!silent) | 295 | printk(KERN_ERR "hfs: unable to parse mount options\n"); |
| 315 | printk("HFS+-fs: unable to parse mount options\n"); | ||
| 316 | err = -EINVAL; | 296 | err = -EINVAL; |
| 317 | goto cleanup; | 297 | goto cleanup; |
| 318 | } | 298 | } |
| @@ -320,8 +300,8 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
| 320 | /* temporarily use utf8 to correctly find the hidden dir below */ | 300 | /* temporarily use utf8 to correctly find the hidden dir below */ |
| 321 | nls = sbi->nls; | 301 | nls = sbi->nls; |
| 322 | sbi->nls = load_nls("utf8"); | 302 | sbi->nls = load_nls("utf8"); |
| 323 | if (!nls) { | 303 | if (!sbi->nls) { |
| 324 | printk("HFS+: unable to load nls for utf8\n"); | 304 | printk(KERN_ERR "hfs: unable to load nls for utf8\n"); |
| 325 | err = -EINVAL; | 305 | err = -EINVAL; |
| 326 | goto cleanup; | 306 | goto cleanup; |
| 327 | } | 307 | } |
| @@ -329,17 +309,17 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
| 329 | /* Grab the volume header */ | 309 | /* Grab the volume header */ |
| 330 | if (hfsplus_read_wrapper(sb)) { | 310 | if (hfsplus_read_wrapper(sb)) { |
| 331 | if (!silent) | 311 | if (!silent) |
| 332 | printk("HFS+-fs: unable to find HFS+ superblock\n"); | 312 | printk(KERN_WARNING "hfs: unable to find HFS+ superblock\n"); |
| 333 | err = -EINVAL; | 313 | err = -EINVAL; |
| 334 | goto cleanup; | 314 | goto cleanup; |
| 335 | } | 315 | } |
| 336 | vhdr = HFSPLUS_SB(sb).s_vhdr; | 316 | vhdr = HFSPLUS_SB(sb).s_vhdr; |
| 337 | 317 | ||
| 338 | /* Copy parts of the volume header into the superblock */ | 318 | /* Copy parts of the volume header into the superblock */ |
| 339 | sb->s_magic = be16_to_cpu(vhdr->signature); | 319 | sb->s_magic = HFSPLUS_VOLHEAD_SIG; |
| 340 | if (be16_to_cpu(vhdr->version) != HFSPLUS_CURRENT_VERSION) { | 320 | if (be16_to_cpu(vhdr->version) < HFSPLUS_MIN_VERSION || |
| 341 | if (!silent) | 321 | be16_to_cpu(vhdr->version) > HFSPLUS_CURRENT_VERSION) { |
| 342 | printk("HFS+-fs: wrong filesystem version\n"); | 322 | printk(KERN_ERR "hfs: wrong filesystem version\n"); |
| 343 | goto cleanup; | 323 | goto cleanup; |
| 344 | } | 324 | } |
| 345 | HFSPLUS_SB(sb).total_blocks = be32_to_cpu(vhdr->total_blocks); | 325 | HFSPLUS_SB(sb).total_blocks = be32_to_cpu(vhdr->total_blocks); |
| @@ -360,20 +340,17 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
| 360 | sb->s_maxbytes = MAX_LFS_FILESIZE; | 340 | sb->s_maxbytes = MAX_LFS_FILESIZE; |
| 361 | 341 | ||
| 362 | if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { | 342 | if (!(vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_UNMNT))) { |
| 363 | if (!silent) | 343 | printk(KERN_WARNING "hfs: Filesystem was not cleanly unmounted, " |
| 364 | printk("HFS+-fs warning: Filesystem was not cleanly unmounted, " | 344 | "running fsck.hfsplus is recommended. mounting read-only.\n"); |
| 365 | "running fsck.hfsplus is recommended. mounting read-only.\n"); | ||
| 366 | sb->s_flags |= MS_RDONLY; | 345 | sb->s_flags |= MS_RDONLY; |
| 367 | } else if (sbi->flags & HFSPLUS_SB_FORCE) { | 346 | } else if (sbi->flags & HFSPLUS_SB_FORCE) { |
| 368 | /* nothing */ | 347 | /* nothing */ |
| 369 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) { | 348 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_SOFTLOCK)) { |
| 370 | if (!silent) | 349 | printk(KERN_WARNING "hfs: Filesystem is marked locked, mounting read-only.\n"); |
| 371 | printk("HFS+-fs: Filesystem is marked locked, mounting read-only.\n"); | ||
| 372 | sb->s_flags |= MS_RDONLY; | 350 | sb->s_flags |= MS_RDONLY; |
| 373 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) { | 351 | } else if (vhdr->attributes & cpu_to_be32(HFSPLUS_VOL_JOURNALED)) { |
| 374 | if (!silent) | 352 | printk(KERN_WARNING "hfs: write access to a jounaled filesystem is not supported, " |
| 375 | printk("HFS+-fs: write access to a jounaled filesystem is not supported, " | 353 | "use the force option at your own risk, mounting read-only.\n"); |
| 376 | "use the force option at your own risk, mounting read-only.\n"); | ||
| 377 | sb->s_flags |= MS_RDONLY; | 354 | sb->s_flags |= MS_RDONLY; |
| 378 | } | 355 | } |
| 379 | sbi->flags &= ~HFSPLUS_SB_FORCE; | 356 | sbi->flags &= ~HFSPLUS_SB_FORCE; |
| @@ -381,21 +358,18 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
| 381 | /* Load metadata objects (B*Trees) */ | 358 | /* Load metadata objects (B*Trees) */ |
| 382 | HFSPLUS_SB(sb).ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID); | 359 | HFSPLUS_SB(sb).ext_tree = hfs_btree_open(sb, HFSPLUS_EXT_CNID); |
| 383 | if (!HFSPLUS_SB(sb).ext_tree) { | 360 | if (!HFSPLUS_SB(sb).ext_tree) { |
| 384 | if (!silent) | 361 | printk(KERN_ERR "hfs: failed to load extents file\n"); |
| 385 | printk("HFS+-fs: failed to load extents file\n"); | ||
| 386 | goto cleanup; | 362 | goto cleanup; |
| 387 | } | 363 | } |
| 388 | HFSPLUS_SB(sb).cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID); | 364 | HFSPLUS_SB(sb).cat_tree = hfs_btree_open(sb, HFSPLUS_CAT_CNID); |
| 389 | if (!HFSPLUS_SB(sb).cat_tree) { | 365 | if (!HFSPLUS_SB(sb).cat_tree) { |
| 390 | if (!silent) | 366 | printk(KERN_ERR "hfs: failed to load catalog file\n"); |
| 391 | printk("HFS+-fs: failed to load catalog file\n"); | ||
| 392 | goto cleanup; | 367 | goto cleanup; |
| 393 | } | 368 | } |
| 394 | 369 | ||
| 395 | HFSPLUS_SB(sb).alloc_file = iget(sb, HFSPLUS_ALLOC_CNID); | 370 | HFSPLUS_SB(sb).alloc_file = iget(sb, HFSPLUS_ALLOC_CNID); |
| 396 | if (!HFSPLUS_SB(sb).alloc_file) { | 371 | if (!HFSPLUS_SB(sb).alloc_file) { |
| 397 | if (!silent) | 372 | printk(KERN_ERR "hfs: failed to load allocation file\n"); |
| 398 | printk("HFS+-fs: failed to load allocation file\n"); | ||
| 399 | goto cleanup; | 373 | goto cleanup; |
| 400 | } | 374 | } |
| 401 | 375 | ||
| @@ -403,8 +377,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
| 403 | root = iget(sb, HFSPLUS_ROOT_CNID); | 377 | root = iget(sb, HFSPLUS_ROOT_CNID); |
| 404 | sb->s_root = d_alloc_root(root); | 378 | sb->s_root = d_alloc_root(root); |
| 405 | if (!sb->s_root) { | 379 | if (!sb->s_root) { |
| 406 | if (!silent) | 380 | printk(KERN_ERR "hfs: failed to load root directory\n"); |
| 407 | printk("HFS+-fs: failed to load root directory\n"); | ||
| 408 | iput(root); | 381 | iput(root); |
| 409 | goto cleanup; | 382 | goto cleanup; |
| 410 | } | 383 | } |
| @@ -438,7 +411,7 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) | |||
| 438 | sync_dirty_buffer(HFSPLUS_SB(sb).s_vhbh); | 411 | sync_dirty_buffer(HFSPLUS_SB(sb).s_vhbh); |
| 439 | 412 | ||
| 440 | if (!HFSPLUS_SB(sb).hidden_dir) { | 413 | if (!HFSPLUS_SB(sb).hidden_dir) { |
| 441 | printk("HFS+: create hidden dir...\n"); | 414 | printk(KERN_DEBUG "hfs: create hidden dir...\n"); |
| 442 | HFSPLUS_SB(sb).hidden_dir = hfsplus_new_inode(sb, S_IFDIR); | 415 | HFSPLUS_SB(sb).hidden_dir = hfsplus_new_inode(sb, S_IFDIR); |
| 443 | hfsplus_create_cat(HFSPLUS_SB(sb).hidden_dir->i_ino, sb->s_root->d_inode, | 416 | hfsplus_create_cat(HFSPLUS_SB(sb).hidden_dir->i_ino, sb->s_root->d_inode, |
| 444 | &str, HFSPLUS_SB(sb).hidden_dir); | 417 | &str, HFSPLUS_SB(sb).hidden_dir); |
| @@ -518,7 +491,7 @@ static void __exit exit_hfsplus_fs(void) | |||
| 518 | { | 491 | { |
| 519 | unregister_filesystem(&hfsplus_fs_type); | 492 | unregister_filesystem(&hfsplus_fs_type); |
| 520 | if (kmem_cache_destroy(hfsplus_inode_cachep)) | 493 | if (kmem_cache_destroy(hfsplus_inode_cachep)) |
| 521 | printk(KERN_INFO "hfsplus_inode_cache: not all structures were freed\n"); | 494 | printk(KERN_ERR "hfsplus_inode_cache: not all structures were freed\n"); |
| 522 | } | 495 | } |
| 523 | 496 | ||
| 524 | module_init(init_hfsplus_fs) | 497 | module_init(init_hfsplus_fs) |
