Commit a03a6e74 authored by Anton Altaparmakov's avatar Anton Altaparmakov

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: default avatarAnton Altaparmakov <aia21@cantab.net>
parent 1e632d02
......@@ -21,6 +21,11 @@ ToDo/Notes:
- 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().
2.1.17 - Fix bugs in mount time error code paths and other updates.
- Implement bitmap modification code (fs/ntfs/bitmap.[hc]). This
......
......@@ -6,7 +6,7 @@ ntfs-objs := aops.o attrib.o collate.o compress.o debug.o dir.o file.o \
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
......
......@@ -1900,8 +1900,6 @@ int ntfs_read_inode_mount(struct inode *vi)
/* 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 @@ int ntfs_read_inode_mount(struct inode *vi)
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
......
......@@ -2012,7 +2012,7 @@ static s64 get_nr_free_clusters(ntfs_volume *vol)
*/
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;
......@@ -2021,13 +2021,16 @@ static unsigned long __get_nr_free_mft_records(ntfs_volume *vol)
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.
* 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 = (((vol->nr_mft_records + 7) >> 3) + PAGE_CACHE_SIZE - 1) >>
PAGE_CACHE_SHIFT;
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 = "
......@@ -2122,9 +2125,9 @@ static int ntfs_statfs(struct super_block *sb, struct kstatfs *sfs)
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);
/*
......
......@@ -95,9 +95,6 @@ typedef struct {
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. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment