linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / fs / ntfs / super.c
index 74e0ee8..368a8ec 100644 (file)
@@ -1099,38 +1099,26 @@ static BOOL check_mft_mirror(ntfs_volume *vol)
                        kmirr = page_address(mirr_page);
                        ++index;
                }
-               /* Do not check the record if it is not in use. */
-               if (((MFT_RECORD*)kmft)->flags & MFT_RECORD_IN_USE) {
-                       /* Make sure the record is ok. */
-                       if (ntfs_is_baad_recordp((le32*)kmft)) {
-                               ntfs_error(sb, "Incomplete multi sector "
-                                               "transfer detected in mft "
-                                               "record %i.", i);
+               /* Make sure the record is ok. */
+               if (ntfs_is_baad_recordp((le32*)kmft)) {
+                       ntfs_error(sb, "Incomplete multi sector transfer "
+                                       "detected in mft record %i.", i);
 mm_unmap_out:
-                               ntfs_unmap_page(mirr_page);
+                       ntfs_unmap_page(mirr_page);
 mft_unmap_out:
-                               ntfs_unmap_page(mft_page);
-                               return FALSE;
-                       }
+                       ntfs_unmap_page(mft_page);
+                       return FALSE;
                }
-               /* Do not check the mirror record if it is not in use. */
-               if (((MFT_RECORD*)kmirr)->flags & MFT_RECORD_IN_USE) {
-                       if (ntfs_is_baad_recordp((le32*)kmirr)) {
-                               ntfs_error(sb, "Incomplete multi sector "
-                                               "transfer detected in mft "
-                                               "mirror record %i.", i);
-                               goto mm_unmap_out;
-                       }
+               if (ntfs_is_baad_recordp((le32*)kmirr)) {
+                       ntfs_error(sb, "Incomplete multi sector transfer "
+                                       "detected in mft mirror record %i.", i);
+                       goto mm_unmap_out;
                }
                /* Get the amount of data in the current record. */
                bytes = le32_to_cpu(((MFT_RECORD*)kmft)->bytes_in_use);
-               if (bytes < sizeof(MFT_RECORD_OLD) ||
-                               bytes > vol->mft_record_size ||
-                               ntfs_is_baad_recordp((le32*)kmft)) {
+               if (!bytes || bytes > vol->mft_record_size) {
                        bytes = le32_to_cpu(((MFT_RECORD*)kmirr)->bytes_in_use);
-                       if (bytes < sizeof(MFT_RECORD_OLD) ||
-                                       bytes > vol->mft_record_size ||
-                                       ntfs_is_baad_recordp((le32*)kmirr))
+                       if (!bytes || bytes > vol->mft_record_size)
                                bytes = vol->mft_record_size;
                }
                /* Compare the two records. */
@@ -1677,11 +1665,11 @@ read_partial_upcase_page:
        ntfs_debug("Read %llu bytes from $UpCase (expected %zu bytes).",
                        i_size, 64 * 1024 * sizeof(ntfschar));
        iput(ino);
-       mutex_lock(&ntfs_lock);
+       down(&ntfs_lock);
        if (!default_upcase) {
                ntfs_debug("Using volume specified $UpCase since default is "
                                "not present.");
-               mutex_unlock(&ntfs_lock);
+               up(&ntfs_lock);
                return TRUE;
        }
        max = default_upcase_len;
@@ -1695,12 +1683,12 @@ read_partial_upcase_page:
                vol->upcase = default_upcase;
                vol->upcase_len = max;
                ntfs_nr_upcase_users++;
-               mutex_unlock(&ntfs_lock);
+               up(&ntfs_lock);
                ntfs_debug("Volume specified $UpCase matches default. Using "
                                "default.");
                return TRUE;
        }
-       mutex_unlock(&ntfs_lock);
+       up(&ntfs_lock);
        ntfs_debug("Using volume specified $UpCase since it does not match "
                        "the default.");
        return TRUE;
@@ -1709,29 +1697,21 @@ iput_upcase_failed:
        ntfs_free(vol->upcase);
        vol->upcase = NULL;
 upcase_failed:
-       mutex_lock(&ntfs_lock);
+       down(&ntfs_lock);
        if (default_upcase) {
                vol->upcase = default_upcase;
                vol->upcase_len = default_upcase_len;
                ntfs_nr_upcase_users++;
-               mutex_unlock(&ntfs_lock);
+               up(&ntfs_lock);
                ntfs_error(sb, "Failed to load $UpCase from the volume. Using "
                                "default.");
                return TRUE;
        }
-       mutex_unlock(&ntfs_lock);
+       up(&ntfs_lock);
        ntfs_error(sb, "Failed to initialize upcase table.");
        return FALSE;
 }
 
-/*
- * The lcn and mft bitmap inodes are NTFS-internal inodes with
- * their own special locking rules:
- */
-static struct lock_class_key
-       lcnbmp_runlist_lock_key, lcnbmp_mrec_lock_key,
-       mftbmp_runlist_lock_key, mftbmp_mrec_lock_key;
-
 /**
  * load_system_files - open the system files using normal functions
  * @vol:       ntfs super block describing device whose system files to load
@@ -1788,10 +1768,6 @@ static BOOL load_system_files(ntfs_volume *vol)
                ntfs_error(sb, "Failed to load $MFT/$BITMAP attribute.");
                goto iput_mirr_err_out;
        }
-       lockdep_set_class(&NTFS_I(vol->mftbmp_ino)->runlist.lock,
-                          &mftbmp_runlist_lock_key);
-       lockdep_set_class(&NTFS_I(vol->mftbmp_ino)->mrec_lock,
-                          &mftbmp_mrec_lock_key);
        /* Read upcase table and setup @vol->upcase and @vol->upcase_len. */
        if (!load_and_init_upcase(vol))
                goto iput_mftbmp_err_out;
@@ -1814,11 +1790,6 @@ static BOOL load_system_files(ntfs_volume *vol)
                        iput(vol->lcnbmp_ino);
                goto bitmap_failed;
        }
-       lockdep_set_class(&NTFS_I(vol->lcnbmp_ino)->runlist.lock,
-                          &lcnbmp_runlist_lock_key);
-       lockdep_set_class(&NTFS_I(vol->lcnbmp_ino)->mrec_lock,
-                          &lcnbmp_mrec_lock_key);
-
        NInoSetSparseDisabled(NTFS_I(vol->lcnbmp_ino));
        if ((vol->nr_clusters + 7) >> 3 > i_size_read(vol->lcnbmp_ino)) {
                iput(vol->lcnbmp_ino);
@@ -2212,12 +2183,12 @@ iput_attrdef_err_out:
 iput_upcase_err_out:
 #endif /* NTFS_RW */
        vol->upcase_len = 0;
-       mutex_lock(&ntfs_lock);
+       down(&ntfs_lock);
        if (vol->upcase == default_upcase) {
                ntfs_nr_upcase_users--;
                vol->upcase = NULL;
        }
-       mutex_unlock(&ntfs_lock);
+       up(&ntfs_lock);
        if (vol->upcase) {
                ntfs_free(vol->upcase);
                vol->upcase = NULL;
@@ -2422,7 +2393,7 @@ static void ntfs_put_super(struct super_block *sb)
         * Destroy the global default upcase table if necessary.  Also decrease
         * the number of upcase users if we are a user.
         */
-       mutex_lock(&ntfs_lock);
+       down(&ntfs_lock);
        if (vol->upcase == default_upcase) {
                ntfs_nr_upcase_users--;
                vol->upcase = NULL;
@@ -2433,7 +2404,7 @@ static void ntfs_put_super(struct super_block *sb)
        }
        if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users)
                free_compression_buffers();
-       mutex_unlock(&ntfs_lock);
+       up(&ntfs_lock);
        if (vol->upcase) {
                ntfs_free(vol->upcase);
                vol->upcase = NULL;
@@ -2618,10 +2589,10 @@ static unsigned long __get_nr_free_mft_records(ntfs_volume *vol,
 
 /**
  * ntfs_statfs - return information about mounted NTFS volume
- * @dentry:    dentry from mounted volume
+ * @sb:                super block of mounted volume
  * @sfs:       statfs structure in which to return the information
  *
- * Return information about the mounted NTFS volume @dentry in the statfs structure
+ * Return information about the mounted NTFS volume @sb in the statfs structure
  * pointed to by @sfs (this is initialized with zeros before ntfs_statfs is
  * called). We interpret the values to be correct of the moment in time at
  * which we are called. Most values are variable otherwise and this isn't just
@@ -2634,9 +2605,8 @@ static unsigned long __get_nr_free_mft_records(ntfs_volume *vol,
  *
  * Return 0 on success or -errno on error.
  */
-static int ntfs_statfs(struct dentry *dentry, struct kstatfs *sfs)
+static int ntfs_statfs(struct super_block *sb, struct kstatfs *sfs)
 {
-       struct super_block *sb = dentry->d_sb;
        s64 size;
        ntfs_volume *vol = NTFS_SB(sb);
        ntfs_inode *mft_ni = NTFS_I(vol->mft_ino);
@@ -2760,17 +2730,6 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
        struct inode *tmp_ino;
        int blocksize, result;
 
-       /*
-        * We do a pretty difficult piece of bootstrap by reading the
-        * MFT (and other metadata) from disk into memory. We'll only
-        * release this metadata during umount, so the locking patterns
-        * observed during bootstrap do not count. So turn off the
-        * observation of locking patterns (strictly for this context
-        * only) while mounting NTFS. [The validator is still active
-        * otherwise, even for this context: it will for example record
-        * lock class registrations.]
-        */
-       lockdep_off();
        ntfs_debug("Entering.");
 #ifndef NTFS_RW
        sb->s_flags |= MS_RDONLY;
@@ -2782,7 +2741,6 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
                if (!silent)
                        ntfs_error(sb, "Allocation of NTFS volume structure "
                                        "failed. Aborting mount...");
-               lockdep_on();
                return -ENOMEM;
        }
        /* Initialize ntfs_volume structure. */
@@ -2920,7 +2878,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
                        ntfs_error(sb, "Failed to load essential metadata.");
                goto iput_tmp_ino_err_out_now;
        }
-       mutex_lock(&ntfs_lock);
+       down(&ntfs_lock);
        /*
         * The current mount is a compression user if the cluster size is
         * less than or equal 4kiB.
@@ -2931,7 +2889,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
                        ntfs_error(NULL, "Failed to allocate buffers "
                                        "for compression engine.");
                        ntfs_nr_compression_users--;
-                       mutex_unlock(&ntfs_lock);
+                       up(&ntfs_lock);
                        goto iput_tmp_ino_err_out_now;
                }
        }
@@ -2943,7 +2901,7 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
        if (!default_upcase)
                default_upcase = generate_default_upcase();
        ntfs_nr_upcase_users++;
-       mutex_unlock(&ntfs_lock);
+       up(&ntfs_lock);
        /*
         * From now on, ignore @silent parameter. If we fail below this line,
         * it will be due to a corrupt fs or a system error, so we report it.
@@ -2961,15 +2919,14 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
                atomic_inc(&vol->root_ino->i_count);
                ntfs_debug("Exiting, status successful.");
                /* Release the default upcase if it has no users. */
-               mutex_lock(&ntfs_lock);
+               down(&ntfs_lock);
                if (!--ntfs_nr_upcase_users && default_upcase) {
                        ntfs_free(default_upcase);
                        default_upcase = NULL;
                }
-               mutex_unlock(&ntfs_lock);
+               up(&ntfs_lock);
                sb->s_export_op = &ntfs_export_ops;
                lock_kernel();
-               lockdep_on();
                return 0;
        }
        ntfs_error(sb, "Failed to allocate root directory.");
@@ -3035,12 +2992,12 @@ static int ntfs_fill_super(struct super_block *sb, void *opt, const int silent)
                vol->attrdef = NULL;
        }
        vol->upcase_len = 0;
-       mutex_lock(&ntfs_lock);
+       down(&ntfs_lock);
        if (vol->upcase == default_upcase) {
                ntfs_nr_upcase_users--;
                vol->upcase = NULL;
        }
-       mutex_unlock(&ntfs_lock);
+       up(&ntfs_lock);
        if (vol->upcase) {
                ntfs_free(vol->upcase);
                vol->upcase = NULL;
@@ -3055,14 +3012,14 @@ unl_upcase_iput_tmp_ino_err_out_now:
         * Decrease the number of upcase users and destroy the global default
         * upcase table if necessary.
         */
-       mutex_lock(&ntfs_lock);
+       down(&ntfs_lock);
        if (!--ntfs_nr_upcase_users && default_upcase) {
                ntfs_free(default_upcase);
                default_upcase = NULL;
        }
        if (vol->cluster_size <= 4096 && !--ntfs_nr_compression_users)
                free_compression_buffers();
-       mutex_unlock(&ntfs_lock);
+       up(&ntfs_lock);
 iput_tmp_ino_err_out_now:
        iput(tmp_ino);
        if (vol->mft_ino && vol->mft_ino != tmp_ino)
@@ -3089,7 +3046,6 @@ err_out_now:
        sb->s_fs_info = NULL;
        kfree(vol);
        ntfs_debug("Failed, returning -EINVAL.");
-       lockdep_on();
        return -EINVAL;
 }
 
@@ -3122,14 +3078,13 @@ static void ntfs_big_inode_init_once(void *foo, struct kmem_cache *cachep,
 struct kmem_cache *ntfs_attr_ctx_cache;
 struct kmem_cache *ntfs_index_ctx_cache;
 
-/* Driver wide mutex. */
-DEFINE_MUTEX(ntfs_lock);
+/* Driver wide semaphore. */
+DECLARE_MUTEX(ntfs_lock);
 
-static int ntfs_get_sb(struct file_system_type *fs_type,
-       int flags, const char *dev_name, void *data, struct vfsmount *mnt)
+static struct super_block *ntfs_get_sb(struct file_system_type *fs_type,
+       int flags, const char *dev_name, void *data)
 {
-       return get_sb_bdev(fs_type, flags, dev_name, data, ntfs_fill_super,
-                          mnt);
+       return get_sb_bdev(fs_type, flags, dev_name, data, ntfs_fill_super);
 }
 
 static struct file_system_type ntfs_fs_type = {
@@ -3196,7 +3151,7 @@ static int __init init_ntfs_fs(void)
 
        ntfs_inode_cache = kmem_cache_create(ntfs_inode_cache_name,
                        sizeof(ntfs_inode), 0,
-                       SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD, NULL, NULL);
+                       SLAB_RECLAIM_ACCOUNT, NULL, NULL);
        if (!ntfs_inode_cache) {
                printk(KERN_CRIT "NTFS: Failed to create %s!\n",
                                ntfs_inode_cache_name);
@@ -3205,7 +3160,7 @@ static int __init init_ntfs_fs(void)
 
        ntfs_big_inode_cache = kmem_cache_create(ntfs_big_inode_cache_name,
                        sizeof(big_ntfs_inode), 0,
-                       SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
+                       SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT,
                        ntfs_big_inode_init_once, NULL);
        if (!ntfs_big_inode_cache) {
                printk(KERN_CRIT "NTFS: Failed to create %s!\n",
@@ -3279,7 +3234,7 @@ static void __exit exit_ntfs_fs(void)
 }
 
 MODULE_AUTHOR("Anton Altaparmakov <aia21@cantab.net>");
-MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2006 Anton Altaparmakov");
+MODULE_DESCRIPTION("NTFS 1.2/3.x driver - Copyright (c) 2001-2005 Anton Altaparmakov");
 MODULE_VERSION(NTFS_VERSION);
 MODULE_LICENSE("GPL");
 #ifdef DEBUG