aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs/super.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /fs/ntfs/super.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'fs/ntfs/super.c')
-rw-r--r--fs/ntfs/super.c72
1 files changed, 18 insertions, 54 deletions
diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 512806171bfa..b52706da4645 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * super.c - NTFS kernel super block handling. Part of the Linux-NTFS project. 2 * super.c - NTFS kernel super block handling. Part of the Linux-NTFS project.
3 * 3 *
4 * Copyright (c) 2001-2007 Anton Altaparmakov 4 * Copyright (c) 2001-2011 Anton Altaparmakov and Tuxera Inc.
5 * Copyright (c) 2001,2002 Richard Russon 5 * Copyright (c) 2001,2002 Richard Russon
6 * 6 *
7 * This program/include file is free software; you can redistribute it and/or 7 * This program/include file is free software; you can redistribute it and/or
@@ -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;
@@ -460,7 +458,7 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *opt)
460 * the volume on boot and updates them. 458 * the volume on boot and updates them.
461 * 459 *
462 * When remounting read-only, mark the volume clean if no volume errors 460 * When remounting read-only, mark the volume clean if no volume errors
463 * have occured. 461 * have occurred.
464 */ 462 */
465 if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { 463 if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
466 static const char *es = ". Cannot remount read-write."; 464 static const char *es = ". Cannot remount read-write.";
@@ -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}
@@ -1281,7 +1269,7 @@ static int check_windows_hibernation_status(ntfs_volume *vol)
1281 "hibernated on the volume."); 1269 "hibernated on the volume.");
1282 return 0; 1270 return 0;
1283 } 1271 }
1284 /* A real error occured. */ 1272 /* A real error occurred. */
1285 ntfs_error(vol->sb, "Failed to find inode number for " 1273 ntfs_error(vol->sb, "Failed to find inode number for "
1286 "hiberfil.sys."); 1274 "hiberfil.sys.");
1287 return ret; 1275 return ret;
@@ -1382,7 +1370,7 @@ static bool load_and_init_quota(ntfs_volume *vol)
1382 NVolSetQuotaOutOfDate(vol); 1370 NVolSetQuotaOutOfDate(vol);
1383 return true; 1371 return true;
1384 } 1372 }
1385 /* A real error occured. */ 1373 /* A real error occurred. */
1386 ntfs_error(vol->sb, "Failed to find inode number for $Quota."); 1374 ntfs_error(vol->sb, "Failed to find inode number for $Quota.");
1387 return false; 1375 return false;
1388 } 1376 }
@@ -1466,7 +1454,7 @@ not_enabled:
1466 NVolSetUsnJrnlStamped(vol); 1454 NVolSetUsnJrnlStamped(vol);
1467 return true; 1455 return true;
1468 } 1456 }
1469 /* A real error occured. */ 1457 /* A real error occurred. */
1470 ntfs_error(vol->sb, "Failed to find inode number for " 1458 ntfs_error(vol->sb, "Failed to find inode number for "
1471 "$UsnJrnl."); 1459 "$UsnJrnl.");
1472 return false; 1460 return false;
@@ -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
@@ -2306,7 +2292,7 @@ static void ntfs_put_super(struct super_block *sb)
2306 ntfs_commit_inode(vol->mft_ino); 2292 ntfs_commit_inode(vol->mft_ino);
2307 2293
2308 /* 2294 /*
2309 * If a read-write mount and no volume errors have occured, mark the 2295 * If a read-write mount and no volume errors have occurred, mark the
2310 * volume clean. Also, re-commit all affected inodes. 2296 * volume clean. Also, re-commit all affected inodes.
2311 */ 2297 */
2312 if (!(sb->s_flags & MS_RDONLY)) { 2298 if (!(sb->s_flags & MS_RDONLY)) {
@@ -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/**
@@ -2512,7 +2496,7 @@ static s64 get_nr_free_clusters(ntfs_volume *vol)
2512 if (vol->nr_clusters & 63) 2496 if (vol->nr_clusters & 63)
2513 nr_free += 64 - (vol->nr_clusters & 63); 2497 nr_free += 64 - (vol->nr_clusters & 63);
2514 up_read(&vol->lcnbmp_lock); 2498 up_read(&vol->lcnbmp_lock);
2515 /* If errors occured we may well have gone below zero, fix this. */ 2499 /* If errors occurred we may well have gone below zero, fix this. */
2516 if (nr_free < 0) 2500 if (nr_free < 0)
2517 nr_free = 0; 2501 nr_free = 0;
2518 ntfs_debug("Exiting."); 2502 ntfs_debug("Exiting.");
@@ -2577,7 +2561,7 @@ static unsigned long __get_nr_free_mft_records(ntfs_volume *vol,
2577 } 2561 }
2578 ntfs_debug("Finished reading $MFT/$BITMAP, last index = 0x%lx.", 2562 ntfs_debug("Finished reading $MFT/$BITMAP, last index = 0x%lx.",
2579 index - 1); 2563 index - 1);
2580 /* If errors occured we may well have gone below zero, fix this. */ 2564 /* If errors occurred we may well have gone below zero, fix this. */
2581 if (nr_free < 0) 2565 if (nr_free < 0)
2582 nr_free = 0; 2566 nr_free = 0;
2583 ntfs_debug("Exiting."); 2567 ntfs_debug("Exiting.");
@@ -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. */
3059err_out_now: 3025err_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. */
3095DEFINE_MUTEX(ntfs_lock); 3060DEFINE_MUTEX(ntfs_lock);
3096 3061
3097static int ntfs_get_sb(struct file_system_type *fs_type, 3062static 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
3104static struct file_system_type ntfs_fs_type = { 3068static 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};
@@ -3229,8 +3193,8 @@ static void __exit exit_ntfs_fs(void)
3229 ntfs_sysctl(0); 3193 ntfs_sysctl(0);
3230} 3194}
3231 3195
3232MODULE_AUTHOR("Anton Altaparmakov <aia21@cantab.net>"); 3196MODULE_AUTHOR("Anton Altaparmakov <anton@tuxera.com>");
3233MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2007 Anton Altaparmakov"); 3197MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2011 Anton Altaparmakov and Tuxera Inc.");
3234MODULE_VERSION(NTFS_VERSION); 3198MODULE_VERSION(NTFS_VERSION);
3235MODULE_LICENSE("GPL"); 3199MODULE_LICENSE("GPL");
3236#ifdef DEBUG 3200#ifdef DEBUG