diff options
Diffstat (limited to 'fs/ntfs/super.c')
-rw-r--r-- | fs/ntfs/super.c | 52 |
1 files changed, 8 insertions, 44 deletions
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c index 512806171bfa..a30ecacc01f2 100644 --- a/fs/ntfs/super.c +++ b/fs/ntfs/super.c | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <linux/buffer_head.h> | 30 | #include <linux/buffer_head.h> |
31 | #include <linux/vfs.h> | 31 | #include <linux/vfs.h> |
32 | #include <linux/moduleparam.h> | 32 | #include <linux/moduleparam.h> |
33 | #include <linux/smp_lock.h> | ||
34 | #include <linux/bitmap.h> | 33 | #include <linux/bitmap.h> |
35 | 34 | ||
36 | #include "sysctl.h" | 35 | #include "sysctl.h" |
@@ -445,7 +444,6 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) | |||
445 | 444 | ||
446 | ntfs_debug("Entering with remount options string: %s", opt); | 445 | ntfs_debug("Entering with remount options string: %s", opt); |
447 | 446 | ||
448 | lock_kernel(); | ||
449 | #ifndef NTFS_RW | 447 | #ifndef NTFS_RW |
450 | /* For read-only compiled driver, enforce read-only flag. */ | 448 | /* For read-only compiled driver, enforce read-only flag. */ |
451 | *flags |= MS_RDONLY; | 449 | *flags |= MS_RDONLY; |
@@ -469,18 +467,15 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) | |||
469 | if (NVolErrors(vol)) { | 467 | if (NVolErrors(vol)) { |
470 | ntfs_error(sb, "Volume has errors and is read-only%s", | 468 | ntfs_error(sb, "Volume has errors and is read-only%s", |
471 | es); | 469 | es); |
472 | unlock_kernel(); | ||
473 | return -EROFS; | 470 | return -EROFS; |
474 | } | 471 | } |
475 | if (vol->vol_flags & VOLUME_IS_DIRTY) { | 472 | if (vol->vol_flags & VOLUME_IS_DIRTY) { |
476 | ntfs_error(sb, "Volume is dirty and read-only%s", es); | 473 | ntfs_error(sb, "Volume is dirty and read-only%s", es); |
477 | unlock_kernel(); | ||
478 | return -EROFS; | 474 | return -EROFS; |
479 | } | 475 | } |
480 | if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) { | 476 | if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) { |
481 | ntfs_error(sb, "Volume has been modified by chkdsk " | 477 | ntfs_error(sb, "Volume has been modified by chkdsk " |
482 | "and is read-only%s", es); | 478 | "and is read-only%s", es); |
483 | unlock_kernel(); | ||
484 | return -EROFS; | 479 | return -EROFS; |
485 | } | 480 | } |
486 | if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { | 481 | if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { |
@@ -488,13 +483,11 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) | |||
488 | "(0x%x) and is read-only%s", | 483 | "(0x%x) and is read-only%s", |
489 | (unsigned)le16_to_cpu(vol->vol_flags), | 484 | (unsigned)le16_to_cpu(vol->vol_flags), |
490 | es); | 485 | es); |
491 | unlock_kernel(); | ||
492 | return -EROFS; | 486 | return -EROFS; |
493 | } | 487 | } |
494 | if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) { | 488 | if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) { |
495 | ntfs_error(sb, "Failed to set dirty bit in volume " | 489 | ntfs_error(sb, "Failed to set dirty bit in volume " |
496 | "information flags%s", es); | 490 | "information flags%s", es); |
497 | unlock_kernel(); | ||
498 | return -EROFS; | 491 | return -EROFS; |
499 | } | 492 | } |
500 | #if 0 | 493 | #if 0 |
@@ -514,21 +507,18 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) | |||
514 | ntfs_error(sb, "Failed to empty journal $LogFile%s", | 507 | ntfs_error(sb, "Failed to empty journal $LogFile%s", |
515 | es); | 508 | es); |
516 | NVolSetErrors(vol); | 509 | NVolSetErrors(vol); |
517 | unlock_kernel(); | ||
518 | return -EROFS; | 510 | return -EROFS; |
519 | } | 511 | } |
520 | if (!ntfs_mark_quotas_out_of_date(vol)) { | 512 | if (!ntfs_mark_quotas_out_of_date(vol)) { |
521 | ntfs_error(sb, "Failed to mark quotas out of date%s", | 513 | ntfs_error(sb, "Failed to mark quotas out of date%s", |
522 | es); | 514 | es); |
523 | NVolSetErrors(vol); | 515 | NVolSetErrors(vol); |
524 | unlock_kernel(); | ||
525 | return -EROFS; | 516 | return -EROFS; |
526 | } | 517 | } |
527 | if (!ntfs_stamp_usnjrnl(vol)) { | 518 | if (!ntfs_stamp_usnjrnl(vol)) { |
528 | ntfs_error(sb, "Failed to stamp transation log " | 519 | ntfs_error(sb, "Failed to stamp transation log " |
529 | "($UsnJrnl)%s", es); | 520 | "($UsnJrnl)%s", es); |
530 | NVolSetErrors(vol); | 521 | NVolSetErrors(vol); |
531 | unlock_kernel(); | ||
532 | return -EROFS; | 522 | return -EROFS; |
533 | } | 523 | } |
534 | } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) { | 524 | } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) { |
@@ -544,11 +534,9 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt) | |||
544 | 534 | ||
545 | // TODO: Deal with *flags. | 535 | // TODO: Deal with *flags. |
546 | 536 | ||
547 | if (!parse_options(vol, opt)) { | 537 | if (!parse_options(vol, opt)) |
548 | unlock_kernel(); | ||
549 | return -EINVAL; | 538 | return -EINVAL; |
550 | } | 539 | |
551 | unlock_kernel(); | ||
552 | ntfs_debug("Done."); | 540 | ntfs_debug("Done."); |
553 | return 0; | 541 | return 0; |
554 | } | 542 | } |
@@ -2261,8 +2249,6 @@ static void ntfs_put_super(struct super_block *sb) | |||
2261 | 2249 | ||
2262 | ntfs_debug("Entering."); | 2250 | ntfs_debug("Entering."); |
2263 | 2251 | ||
2264 | lock_kernel(); | ||
2265 | |||
2266 | #ifdef NTFS_RW | 2252 | #ifdef NTFS_RW |
2267 | /* | 2253 | /* |
2268 | * Commit all inodes while they are still open in case some of them | 2254 | * Commit all inodes while they are still open in case some of them |
@@ -2433,8 +2419,6 @@ static void ntfs_put_super(struct super_block *sb) | |||
2433 | 2419 | ||
2434 | sb->s_fs_info = NULL; | 2420 | sb->s_fs_info = NULL; |
2435 | kfree(vol); | 2421 | kfree(vol); |
2436 | |||
2437 | unlock_kernel(); | ||
2438 | } | 2422 | } |
2439 | 2423 | ||
2440 | /** | 2424 | /** |
@@ -2772,8 +2756,6 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
2772 | init_rwsem(&vol->mftbmp_lock); | 2756 | init_rwsem(&vol->mftbmp_lock); |
2773 | init_rwsem(&vol->lcnbmp_lock); | 2757 | init_rwsem(&vol->lcnbmp_lock); |
2774 | 2758 | ||
2775 | unlock_kernel(); | ||
2776 | |||
2777 | /* By default, enable sparse support. */ | 2759 | /* By default, enable sparse support. */ |
2778 | NVolSetSparseEnabled(vol); | 2760 | NVolSetSparseEnabled(vol); |
2779 | 2761 | ||
@@ -2929,8 +2911,8 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
2929 | goto unl_upcase_iput_tmp_ino_err_out_now; | 2911 | goto unl_upcase_iput_tmp_ino_err_out_now; |
2930 | } | 2912 | } |
2931 | if ((sb->s_root = d_alloc_root(vol->root_ino))) { | 2913 | if ((sb->s_root = d_alloc_root(vol->root_ino))) { |
2932 | /* We increment i_count simulating an ntfs_iget(). */ | 2914 | /* We grab a reference, simulating an ntfs_iget(). */ |
2933 | atomic_inc(&vol->root_ino->i_count); | 2915 | ihold(vol->root_ino); |
2934 | ntfs_debug("Exiting, status successful."); | 2916 | ntfs_debug("Exiting, status successful."); |
2935 | /* Release the default upcase if it has no users. */ | 2917 | /* Release the default upcase if it has no users. */ |
2936 | mutex_lock(&ntfs_lock); | 2918 | mutex_lock(&ntfs_lock); |
@@ -2940,7 +2922,6 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent) | |||
2940 | } | 2922 | } |
2941 | mutex_unlock(&ntfs_lock); | 2923 | mutex_unlock(&ntfs_lock); |
2942 | sb->s_export_op = &ntfs_export_ops; | 2924 | sb->s_export_op = &ntfs_export_ops; |
2943 | lock_kernel(); | ||
2944 | lockdep_on(); | 2925 | lockdep_on(); |
2945 | return 0; | 2926 | return 0; |
2946 | } | 2927 | } |
@@ -3040,24 +3021,8 @@ iput_tmp_ino_err_out_now: | |||
3040 | if (vol->mft_ino && vol->mft_ino != tmp_ino) | 3021 | if (vol->mft_ino && vol->mft_ino != tmp_ino) |
3041 | iput(vol->mft_ino); | 3022 | iput(vol->mft_ino); |
3042 | vol->mft_ino = NULL; | 3023 | vol->mft_ino = NULL; |
3043 | /* | ||
3044 | * This is needed to get ntfs_clear_extent_inode() called for each | ||
3045 | * inode we have ever called ntfs_iget()/iput() on, otherwise we A) | ||
3046 | * leak resources and B) a subsequent mount fails automatically due to | ||
3047 | * ntfs_iget() never calling down into our ntfs_read_locked_inode() | ||
3048 | * method again... FIXME: Do we need to do this twice now because of | ||
3049 | * attribute inodes? I think not, so leave as is for now... (AIA) | ||
3050 | */ | ||
3051 | if (invalidate_inodes(sb)) { | ||
3052 | ntfs_error(sb, "Busy inodes left. This is most likely a NTFS " | ||
3053 | "driver bug."); | ||
3054 | /* Copied from fs/super.c. I just love this message. (-; */ | ||
3055 | printk("NTFS: Busy inodes after umount. Self-destruct in 5 " | ||
3056 | "seconds. Have a nice day...\n"); | ||
3057 | } | ||
3058 | /* Errors at this stage are irrelevant. */ | 3024 | /* Errors at this stage are irrelevant. */ |
3059 | err_out_now: | 3025 | err_out_now: |
3060 | lock_kernel(); | ||
3061 | sb->s_fs_info = NULL; | 3026 | sb->s_fs_info = NULL; |
3062 | kfree(vol); | 3027 | kfree(vol); |
3063 | ntfs_debug("Failed, returning -EINVAL."); | 3028 | ntfs_debug("Failed, returning -EINVAL."); |
@@ -3094,17 +3059,16 @@ struct kmem_cache *ntfs_index_ctx_cache; | |||
3094 | /* Driver wide mutex. */ | 3059 | /* Driver wide mutex. */ |
3095 | DEFINE_MUTEX(ntfs_lock); | 3060 | DEFINE_MUTEX(ntfs_lock); |
3096 | 3061 | ||
3097 | static int ntfs_get_sb(struct file_system_type *fs_type, | 3062 | static struct dentry *ntfs_mount(struct file_system_type *fs_type, |
3098 | int flags, const char *dev_name, void *data, struct vfsmount *mnt) | 3063 | int flags, const char *dev_name, void *data) |
3099 | { | 3064 | { |
3100 | return get_sb_bdev(fs_type, flags, dev_name, data, ntfs_fill_super, | 3065 | return mount_bdev(fs_type, flags, dev_name, data, ntfs_fill_super); |
3101 | mnt); | ||
3102 | } | 3066 | } |
3103 | 3067 | ||
3104 | static struct file_system_type ntfs_fs_type = { | 3068 | static struct file_system_type ntfs_fs_type = { |
3105 | .owner = THIS_MODULE, | 3069 | .owner = THIS_MODULE, |
3106 | .name = "ntfs", | 3070 | .name = "ntfs", |
3107 | .get_sb = ntfs_get_sb, | 3071 | .mount = ntfs_mount, |
3108 | .kill_sb = kill_block_super, | 3072 | .kill_sb = kill_block_super, |
3109 | .fs_flags = FS_REQUIRES_DEV, | 3073 | .fs_flags = FS_REQUIRES_DEV, |
3110 | }; | 3074 | }; |