bk://linux-ntfs.bkbits.net/ntfs-2.6-devel
ntfs@flatcap.org|ChangeSet|20040915064439|06702 ntfs

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/09/14 14:26:30-07:00 akpm@bix.(none) 
#   Merge bk://linux-ntfs.bkbits.net/ntfs-2.6-devel
#   into bix.(none):/usr/src/bk-ntfs
# 
# fs/ntfs/super.c
#   2004/09/14 14:26:26-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# fs/ntfs/inode.c
#   2004/09/14 14:26:26-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2004/09/14 14:30:26+01:00 aia21@cantab.net 
#   NTFS: Fix scheduling latencies in ntfs_fill_super() by dropping the BKL
#         because the code itself is using the ntfs_lock semaphore which
#         provides safe locking.  (Ingo Molnar)
#   
#   Signed-off-by: Ingo Molnar <mingo@elte.hu>
#   Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
# 
# fs/ntfs/super.c
#   2004/09/14 14:30:16+01:00 aia21@cantab.net +5 -0
#   Fix scheduling latencies in ntfs_fill_super() by dropping the BKL
#   because the code itself is using the ntfs_lock semaphore which
#   provides safe locking.  (Ingo Molnar)
# 
# fs/ntfs/ChangeLog
#   2004/09/14 14:30:15+01:00 aia21@cantab.net +3 -0
#   Update
# 
# fs/ntfs/debug.c
#   2004/09/06 10:56:54+01:00 aia21@cantab.net +1 -1
#   Add parentheses after function name in ntfs_debug().
# 
# ChangeSet
#   2004/08/31 10:12:45+01:00 aia21@cantab.net 
#   Merge ssh://linux-ntfs@bkbits.net/ntfs-2.6-devel
#   into cantab.net:/home/src/ntfs-2.6-devel
# 
# fs/ntfs/super.c
#   2004/08/31 10:12:42+01:00 aia21@cantab.net +0 -0
#   Auto merged
# 
# ChangeSet
#   2004/08/27 13:55:53-07:00 akpm@bix.(none) 
#   Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-ntfs
# 
# fs/ntfs/super.c
#   2004/08/27 13:55:49-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2004/08/27 14:14:03+01:00 aia21@cantab.net 
#   NTFS: Remove vol->nr_mft_records as it was pretty meaningless and optimize
#         the calculation of total/free inodes as used by statfs().
#   
#   Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
# 
# fs/ntfs/volume.h
#   2004/08/27 14:13:55+01:00 aia21@cantab.net +0 -3
#   Remove vol->nr_mft_records as it was pretty meaningless and optimize
#   the calculation of total/free inodes as used by statfs().
# 
# fs/ntfs/super.c
#   2004/08/27 14:13:55+01:00 aia21@cantab.net +12 -9
#   Remove vol->nr_mft_records as it was pretty meaningless and optimize
#   the calculation of total/free inodes as used by statfs().
# 
# fs/ntfs/inode.c
#   2004/08/27 14:13:54+01:00 aia21@cantab.net +2 -6
#   Remove vol->nr_mft_records as it was pretty meaningless and optimize
#   the calculation of total/free inodes as used by statfs().
# 
# fs/ntfs/Makefile
#   2004/08/27 14:13:54+01:00 aia21@cantab.net +1 -1
#   Update
# 
# fs/ntfs/ChangeLog
#   2004/08/27 14:13:54+01:00 aia21@cantab.net +5 -0
#   Update
# 
# ChangeSet
#   2004/08/24 17:34:17-07:00 akpm@bix.(none) 
#   Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-ntfs
# 
# fs/ntfs/super.c
#   2004/08/24 17:34:13-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2004/08/23 16:42:55-07:00 akpm@bix.(none) 
#   Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-ntfs
# 
# fs/ntfs/inode.c
#   2004/08/23 16:42:51-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# fs/ntfs/dir.c
#   2004/08/23 16:42:51-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# fs/ntfs/attrib.c
#   2004/08/23 16:42:51-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# fs/ntfs/aops.c
#   2004/08/23 16:42:51-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2004/08/23 14:26:58-07:00 akpm@bix.(none) 
#   Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-ntfs
# 
# fs/ntfs/inode.c
#   2004/08/23 14:26:52-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# fs/ntfs/dir.c
#   2004/08/23 14:26:52-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# fs/ntfs/attrib.c
#   2004/08/23 14:26:52-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# fs/ntfs/aops.c
#   2004/08/23 14:26:52-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2004/08/18 12:24:54-07:00 akpm@bix.(none) 
#   Merge bk://linux-ntfs.bkbits.net/ntfs-2.6-devel
#   into bix.(none):/usr/src/bk-ntfs
# 
# fs/ntfs/super.c
#   2004/08/18 12:24:51-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2004/08/16 10:41:28-07:00 akpm@bix.(none) 
#   Merge bk://linux-ntfs.bkbits.net/ntfs-2.6-devel
#   into bix.(none):/usr/src/bk-ntfs
# 
# fs/ntfs/super.c
#   2004/08/16 10:41:24-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2004/08/07 14:39:35-07:00 akpm@bix.(none) 
#   Merge bk://linux-ntfs.bkbits.net/ntfs-2.6-devel
#   into bix.(none):/usr/src/bk-ntfs
# 
# fs/ntfs/super.c
#   2004/08/07 14:39:32-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# fs/ntfs/dir.c
#   2004/08/07 14:39:32-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# fs/ntfs/compress.c
#   2004/08/07 14:39:32-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# ChangeSet
#   2004/07/26 23:13:47-07:00 akpm@bix.(none) 
#   Merge bix.(none):/usr/src/bk25 into bix.(none):/usr/src/bk-ntfs
# 
# fs/ntfs/super.c
#   2004/07/26 23:13:44-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# fs/ntfs/dir.c
#   2004/07/26 23:13:43-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
# fs/ntfs/compress.c
#   2004/07/26 23:13:43-07:00 akpm@bix.(none) +0 -0
#   Auto merged
# 
diff -Nru a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
--- a/fs/ntfs/ChangeLog	2004-09-15 20:37:27 -07:00
+++ b/fs/ntfs/ChangeLog	2004-09-15 20:37:27 -07:00
@@ -21,6 +21,14 @@
 	- Enable the code for setting the NT4 compatibility flag when we start
 	  making NTFS 1.2 specific modifications.
 
+2.1.18-WIP
+
+	- Remove vol->nr_mft_records as it was pretty meaningless and optimize
+	  the calculation of total/free inodes as used by statfs().
+	- Fix scheduling latencies in ntfs_fill_super() by dropping the BKL
+	  because the code itself is using the ntfs_lock semaphore which
+	  provides safe locking.  (Ingo Molnar)
+
 2.1.17 - Fix bugs in mount time error code paths and other updates.
 
 	- Implement bitmap modification code (fs/ntfs/bitmap.[hc]).  This
diff -Nru a/fs/ntfs/Makefile b/fs/ntfs/Makefile
--- a/fs/ntfs/Makefile	2004-09-15 20:37:27 -07:00
+++ b/fs/ntfs/Makefile	2004-09-15 20:37:27 -07:00
@@ -6,7 +6,7 @@
 	     index.o inode.o mft.o mst.o namei.o super.o sysctl.o unistr.o \
 	     upcase.o
 
-EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.17\"
+EXTRA_CFLAGS = -DNTFS_VERSION=\"2.1.18-WIP\"
 
 ifeq ($(CONFIG_NTFS_DEBUG),y)
 EXTRA_CFLAGS += -DDEBUG
diff -Nru a/fs/ntfs/debug.c b/fs/ntfs/debug.c
--- a/fs/ntfs/debug.c	2004-09-15 20:37:27 -07:00
+++ b/fs/ntfs/debug.c	2004-09-15 20:37:27 -07:00
@@ -127,7 +127,7 @@
 	va_start(args, fmt);
 	vsnprintf(err_buf, sizeof(err_buf), fmt, args);
 	va_end(args);
-	printk(KERN_DEBUG "NTFS-fs DEBUG (%s, %d): %s: %s\n",
+	printk(KERN_DEBUG "NTFS-fs DEBUG (%s, %d): %s(): %s\n",
 		file, line, flen ? function : "", err_buf);
 	spin_unlock(&err_buf_lock);
 }
diff -Nru a/fs/ntfs/inode.c b/fs/ntfs/inode.c
--- a/fs/ntfs/inode.c	2004-09-15 20:37:27 -07:00
+++ b/fs/ntfs/inode.c	2004-09-15 20:37:27 -07:00
@@ -1900,8 +1900,6 @@
 
 		/* Are we in the first extent? */
 		if (!next_vcn) {
-			u64 ll;
-
 			if (attr->data.non_resident.lowest_vcn) {
 				ntfs_error(sb, "First extent of $DATA "
 						"attribute has non zero "
@@ -1920,17 +1918,15 @@
 					non_resident.initialized_size);
 			ni->allocated_size = sle64_to_cpu(
 					attr->data.non_resident.allocated_size);
-			/* Set the number of mft records. */
-			ll = vi->i_size >> vol->mft_record_size_bits;
 			/*
 			 * Verify the number of mft records does not exceed
 			 * 2^32 - 1.
 			 */
-			if (ll >= (1ULL << 32)) {
+			if ((vi->i_size >> vol->mft_record_size_bits) >=
+					(1ULL << 32)) {
 				ntfs_error(sb, "$MFT is too big! Aborting.");
 				goto put_err_out;
 			}
-			vol->nr_mft_records = ll;
 			/*
 			 * We have got the first extent of the runlist for
 			 * $MFT which means it is now relatively safe to call
diff -Nru a/fs/ntfs/super.c b/fs/ntfs/super.c
--- a/fs/ntfs/super.c	2004-09-15 20:37:27 -07:00
+++ b/fs/ntfs/super.c	2004-09-15 20:37:27 -07:00
@@ -29,6 +29,7 @@
 #include <linux/buffer_head.h>
 #include <linux/vfs.h>
 #include <linux/moduleparam.h>
+#include <linux/smp_lock.h>
 
 #include "ntfs.h"
 #include "sysctl.h"
@@ -2013,7 +2014,7 @@
  */
 static unsigned long __get_nr_free_mft_records(ntfs_volume *vol)
 {
-	s64 nr_free = vol->nr_mft_records;
+	s64 nr_free;
 	u32 *kaddr;
 	struct address_space *mapping = vol->mftbmp_ino->i_mapping;
 	filler_t *readpage = (filler_t*)mapping->a_ops->readpage;
@@ -2022,13 +2023,16 @@
 	unsigned int max_size;
 
 	ntfs_debug("Entering.");
+	/* Number of mft records in file system (at this point in time). */
+	nr_free = vol->mft_ino->i_size >> vol->mft_record_size_bits;
 	/*
-	 * Convert the number of bits into bytes rounded up, then convert into
-	 * multiples of PAGE_CACHE_SIZE, rounding up so that if we have one
-	 * full and one partial page max_index = 2.
-	 */
-	max_index = (((vol->nr_mft_records + 7) >> 3) + PAGE_CACHE_SIZE - 1) >>
-			PAGE_CACHE_SHIFT;
+	 * Convert the maximum number of set bits into bytes rounded up, then
+	 * convert into multiples of PAGE_CACHE_SIZE, rounding up so that if we
+	 * have one full and one partial page max_index = 2.
+	 */
+	max_index = ((((NTFS_I(vol->mft_ino)->initialized_size >>
+			vol->mft_record_size_bits) + 7) >> 3) +
+			PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 	/* Use multiples of 4 bytes. */
 	max_size = PAGE_CACHE_SIZE >> 2;
 	ntfs_debug("Reading $MFT/$BITMAP, max_index = 0x%lx, max_size = "
@@ -2123,9 +2127,9 @@
 	sfs->f_bavail = sfs->f_bfree = size;
 	/* Serialize accesses to the inode bitmap. */
 	down_read(&vol->mftbmp_lock);
-	/* Total file nodes in file system (at this moment in time). */
-	sfs->f_files  = vol->mft_ino->i_size >> vol->mft_record_size_bits;
-	/* Free file nodes in fs (based on current total count). */
+	/* Number of inodes in file system (at this point in time). */
+	sfs->f_files = vol->mft_ino->i_size >> vol->mft_record_size_bits;
+	/* Free inodes in fs (based on current total count). */
 	sfs->f_ffree = __get_nr_free_mft_records(vol);
 	up_read(&vol->mftbmp_lock);
 	/*
@@ -2288,6 +2292,8 @@
 	vol->fmask = 0177;
 	vol->dmask = 0077;
 
+	unlock_kernel();
+
 	/* Important to get the mount options dealt with now. */
 	if (!parse_options(vol, (char*)opt))
 		goto err_out_now;
@@ -2424,6 +2430,7 @@
 		}
 		up(&ntfs_lock);
 		sb->s_export_op = &ntfs_export_ops;
+		lock_kernel();
 		return 0;
 	}
 	ntfs_error(sb, "Failed to allocate root directory.");
@@ -2527,6 +2534,7 @@
 	}
 	/* Errors at this stage are irrelevant. */
 err_out_now:
+	lock_kernel();
 	sb->s_fs_info = NULL;
 	kfree(vol);
 	ntfs_debug("Failed, returning -EINVAL.");
diff -Nru a/fs/ntfs/volume.h b/fs/ntfs/volume.h
--- a/fs/ntfs/volume.h	2004-09-15 20:37:27 -07:00
+++ b/fs/ntfs/volume.h	2004-09-15 20:37:27 -07:00
@@ -95,9 +95,6 @@
 	struct inode *mftbmp_ino;	/* Attribute inode for $MFT/$BITMAP. */
 	struct rw_semaphore mftbmp_lock; /* Lock for serializing accesses to the
 					    mft record bitmap ($MFT/$BITMAP). */
-	unsigned long nr_mft_records;	/* Number of mft records == number of
-					   bits in mft bitmap. */
-
 #ifdef NTFS_RW
 	struct inode *mftmirr_ino;	/* The VFS inode of $MFTMirr. */
 	int mftmirr_size;		/* Size of mft mirror in mft records. */