[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-ntfs-cvs
Subject: [Linux-NTFS-cvs] CVS: ntfs-driver-tng/linux/fs/ntfs attrib.c,1.52,1.53 compress.c,1.23,1.24 dir.c,1.
From: Anton Altaparmakov <antona () users ! sourceforge ! net>
Date: 2002-01-31 2:21:38
[Download RAW message or body]
Changes by: antona
Update of /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs
In directory usw-pr-cvs1:/tmp/cvs-serv8743/linux/fs/ntfs
Modified Files:
attrib.c compress.c dir.c inode.c inode.h layout.h mft.c
namei.c ntfs.h super.c
Log Message:
Move to new inode allocation scheme, change ntfs_debug et all to allow gcc to verify \
parameters, fixes, etc see updated ChangeLog...
Index: attrib.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/attrib.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -U2 -r1.52 -r1.53
--- attrib.c 2002/01/30 12:07:21 1.52
+++ attrib.c 2002/01/31 02:21:36 1.53
@@ -921,8 +921,8 @@
u8 *al_end = al + size;
struct buffer_head *bh;
- kdev_t dev = vol->sb->s_dev;
- unsigned long block_size = vol->sb->s_blocksize;
+ struct super_block *sb = vol->sb;
+ unsigned long block_size = sb->s_blocksize;
unsigned long block, max_block;
- unsigned char block_size_bits = vol->sb->s_blocksize_bits;
+ unsigned char block_size_bits = sb->s_blocksize_bits;
ntfs_debug("Entering.\n");
@@ -945,5 +945,5 @@
do {
ntfs_debug("Reading block = 0x%lx.\n", block);
- bh = bread(dev, block, block_size);
+ bh = sb_bread(sb, block);
if (!bh)
goto bread_err;
@@ -974,13 +974,13 @@
}
/* Real overflow! */
- ntfs_error(vol->sb, "Attribute list buffer overflow. Read attribute "
- "list is truncated.");
+ ntfs_error(sb, "Attribute list buffer overflow. Read attribute list "
+ "is truncated.");
err_out:
return -EIO;
rl_err:
- ntfs_error(vol->sb, "vcn_to_lcn() failed. Cannot read attribute list.");
+ ntfs_error(sb, "vcn_to_lcn() failed. Cannot read attribute list.");
goto err_out;
bread_err:
- ntfs_error(vol->sb, "bread() failed. Cannot read attribute list.");
+ ntfs_error(sb, "sb_bread() failed. Cannot read attribute list.");
goto err_out;
}
Index: compress.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/compress.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -U2 -r1.23 -r1.24
--- compress.c 2002/01/28 07:01:17 1.23
+++ compress.c 2002/01/31 02:21:36 1.24
@@ -691,8 +691,8 @@
/*
* TODO: As a big optimization, we could detect this case
- * before we bread() all the pages and use
- * block_read_full_page() on all full pages instead (we still
- * have to treat partial pages especially but at least we are
- * getting rid of the synchronous io for the majority of pages.
+ * before we read all the pages and use block_read_full_page()
+ * on all full pages instead (we still have to treat partial
+ * pages especially but at least we are getting rid of the
+ * synchronous io for the majority of pages.
* Or if we choose not to do the read-ahead/-behind stuff, we
* could just return block_read_full_page(pages[xpage]) as long
Index: dir.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/dir.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -U2 -r1.36 -r1.37
--- dir.c 2002/01/30 12:07:23 1.36
+++ dir.c 2002/01/31 02:21:36 1.37
@@ -191,5 +191,5 @@
/* Get the starting vcn of the index_block holding the child node. */
vcn = sle64_to_cpup((char*)ie + le16_to_cpu(ie->length) - 8);
- ia_mapping = dir_ni->inode->i_mapping;
+ ia_mapping = VFS_I(dir_ni)->i_mapping;
descend_into_child_node:
/*
@@ -198,19 +198,16 @@
* disk if necessary.
*/
- if (vol->cluster_size <= dir_ni->index_block_size)
- page = ntfs_map_page(ia_mapping, vcn << vol->cluster_size_bits
- >> PAGE_CACHE_SHIFT);
- else
- page = ntfs_map_page(ia_mapping, vcn << vol->sector_size_bits
- >> PAGE_CACHE_SHIFT);
+ page = ntfs_map_page(ia_mapping, vcn << dir_ni->index_vcn_size_bits
+ >> PAGE_CACHE_SHIFT);
+ if (IS_ERR(page)) {
+ ntfs_error(sb, "Failed to map directory index page, error %ld.",
+ -PTR_ERR(page));
+ goto put_unm_err_out;
+ }
kaddr = (char*)page_address(page);
fast_descend_into_child_node:
/* Get to the index allocation block. */
- if (vol->cluster_size <= dir_ni->index_block_size)
- ia = (INDEX_ALLOCATION*)(kaddr + ((vcn <<
- vol->cluster_size_bits) & ~PAGE_CACHE_MASK));
- else
- ia = (INDEX_ALLOCATION*)(kaddr + ((vcn <<
- vol->sector_size_bits) & ~PAGE_CACHE_MASK));
+ ia = (INDEX_ALLOCATION*)(kaddr + ((vcn << dir_ni->index_vcn_size_bits) &
+ ~PAGE_CACHE_MASK));
/* Bounds checks. */
if ((char*)ia < kaddr || (char*)ia > kaddr + PAGE_CACHE_SIZE) {
@@ -425,16 +422,10 @@
/* Advance the position even if going to skip the entry. */
- if (index_type == INDEX_TYPE_ALLOCATION) {
- if (vol->cluster_size <= ndir->index_block_size)
- filp->f_pos = (u8*)ie - (u8*)iu.ia +
- (sle64_to_cpu(iu.ia->index_block_vcn) <<
- vol->cluster_size_bits) +
- vol->mft_record_size;
- else
- filp->f_pos = (u8*)ie - (u8*)iu.ia +
- (sle64_to_cpu(iu.ia->index_block_vcn) <<
- vol->sector_size_bits) +
- vol->mft_record_size;
- } else /* if (index_type == INDEX_TYPE_ROOT) */
+ if (index_type == INDEX_TYPE_ALLOCATION)
+ filp->f_pos = (u8*)ie - (u8*)iu.ia +
+ (sle64_to_cpu(iu.ia->index_block_vcn) <<
+ ndir->index_vcn_size_bits) +
+ vol->mft_record_size;
+ else /* if (index_type == INDEX_TYPE_ROOT) */
filp->f_pos = (u8*)ie - (u8*)iu.ir;
if (ie->key.file_name.file_name_type == FILE_NAME_DOS) {
@@ -659,36 +650,16 @@
goto unm_dir_err_out;
}
- /*
- * If the cluster size exceeds the index block size index_block_vcn
- * counts in sectors rather than clusters.
- */
- if (vol->cluster_size <= ndir->index_block_size) {
- if (sle64_to_cpu(ia->index_block_vcn) != (ia_pos &
- ~(s64)(ndir->index_block_size - 1)) >>
- vol->cluster_size_bits) {
- ntfs_error(sb, "Actual VCN (%Li) of index buffer is "
- "different from expected VCN (%Li). "
- "Directory inode %Li is corrupt or "
- "driver bug. ",
- sle64_to_cpu(ia->index_block_vcn),
- ia_pos >> vol->cluster_size_bits,
- ndir->mft_no);
- err = -EIO;
- goto unm_dir_err_out;
- }
- } else {
- if (sle64_to_cpu(ia->index_block_vcn) != (ia_pos &
- ~(s64)(ndir->index_block_size - 1)) >>
- vol->sector_size_bits) {
- ntfs_error(sb, "Actual VCN (%Li) of index buffer is "
- "different from expected VCN (%Li). "
- "Directory inode %Li is corrupt or "
- "driver bug.",
- sle64_to_cpu(ia->index_block_vcn),
- ia_pos >> vol->sector_size_bits,
- ndir->mft_no);
- err = -EIO;
- goto unm_dir_err_out;
- }
+ if (sle64_to_cpu(ia->index_block_vcn) != (ia_pos &
+ ~(s64)(ndir->index_block_size - 1)) >>
+ ndir->index_vcn_size_bits) {
+ ntfs_error(sb, "Actual VCN (%Li) of index buffer is "
+ "different from expected VCN (%Li). "
+ "Directory inode %Li is corrupt or "
+ "driver bug. ",
+ sle64_to_cpu(ia->index_block_vcn),
+ ia_pos >> ndir->index_vcn_size_bits,
+ ndir->mft_no);
+ err = -EIO;
+ goto unm_dir_err_out;
}
if (le32_to_cpu(ia->index.allocated_size) + 0x18 !=
@@ -698,5 +669,5 @@
"specified size (%u). Directory inode is "
"corrupt or driver bug.", ia_pos >>
- vol->cluster_size_bits, ndir->mft_no,
+ ndir->index_vcn_size_bits, ndir->mft_no,
le32_to_cpu(ia->index.allocated_size) + 0x18,
ndir->index_block_size);
@@ -709,5 +680,5 @@
"crosses page boundary. Impossible! Cannot "
"access! This is probably a bug in the "
- "driver.", ia_pos >> vol->cluster_size_bits,
+ "driver.", ia_pos >> ndir->index_vcn_size_bits,
ndir->mft_no);
err = -EIO;
@@ -719,5 +690,5 @@
ntfs_error(sb, "Size of index buffer (VCN %Li) of directory "
"inode %Li exceeds maximum size.", ia_pos >>
- vol->cluster_size_bits, ndir->mft_no);
+ ndir->index_vcn_size_bits, ndir->mft_no);
err = -EIO;
goto unm_dir_err_out;
Index: inode.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/inode.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -U2 -r1.55 -r1.56
--- inode.c 2002/01/30 12:07:23 1.55
+++ inode.c 2002/01/31 02:21:36 1.56
@@ -22,58 +22,91 @@
#include <linux/pagemap.h>
-ntfs_inode *ntfs_new_inode(void)
+struct inode *ntfs_alloc_big_inode(struct super_block *sb)
{
- ntfs_inode *ni = kmem_cache_alloc(ntfs_inode_cache, SLAB_NOFS);
- if (ni) {
- memset(ni, 0, sizeof(ntfs_inode));
- ni->inode = NULL;
- atomic_set(&ni->count, 1);
- ni->vol = NULL;
- ni->run_list = NULL;
- init_rwsem(&ni->mrec_lock);
- atomic_set(&ni->mft_count, 0);
- ni->page = NULL;
- ni->attr_list = NULL;
- ni->attr_list_rl = NULL;
- ni->bmp_rl = NULL;
- init_MUTEX(&ni->extent_lock);
- ni->base_ntfs_ino = NULL;
- return ni;
+ ntfs_inode *ni;
+
+ ntfs_debug("Entering.\n");
+ ni = (ntfs_inode *)kmem_cache_alloc(ntfs_big_inode_cache,
+ SLAB_NOFS);
+ if (!ni) {
+ ntfs_error(sb, "Allocation of NTFS big inode structure "
+ "failed.");
+ return NULL;
}
- ntfs_error(NULL, "Allocation of NTFS inode structure failed.");
- return NULL;
+ return VFS_I(ni);
}
-void ntfs_free_inode(ntfs_inode *ni)
+void ntfs_destroy_big_inode(struct inode *inode)
{
+ ntfs_inode *ni = NTFS_I(inode);
+
+ ntfs_debug("Entering.\n");
BUG_ON(atomic_read(&ni->mft_count) || !atomic_dec_and_test(&ni->count));
+ kmem_cache_free(ntfs_big_inode_cache, NTFS_I(inode));
+}
+
+ntfs_inode *ntfs_alloc_inode(void)
+{
+ ntfs_inode *ni = (ntfs_inode *)kmem_cache_alloc(ntfs_inode_cache,
+ SLAB_NOFS);
+ ntfs_debug("Entering.\n");
+ if (unlikely(!ni))
+ ntfs_error(NULL, "Allocation of NTFS inode structure failed.");
+ return ni;
+}
+
+void ntfs_destroy_inode(ntfs_inode *ni)
+{
+ ntfs_debug("Entering.\n");
+ BUG_ON(atomic_read(&ni->mft_count) || !atomic_dec_and_test(&ni->count));
kmem_cache_free(ntfs_inode_cache, ni);
}
/**
- * ntfs_init_inode - initialize ntfs specific part of an inode
- * @vi: VFS inode whose ntfs specific part to initialize
+ * __ntfs_init_inode - initialize ntfs specific part of an inode
*
- * Allocate and initialize ntfs specific part of the inode @vi to defaults.
+ * Initialize an ntfs inode to defaults.
*
* Return zero on success and -ENOMEM on error.
*/
-static int ntfs_init_inode(struct inode *vi)
+static void __ntfs_init_inode(struct super_block *sb, ntfs_inode *ni)
{
- ntfs_inode *ni;
+ ntfs_debug("Entering.\n");
+ memset(ni, 0, sizeof(ntfs_inode));
+ atomic_set(&ni->count, 1);
+ ni->vol = NULL;
+ ni->run_list = NULL;
+ init_rwsem(&ni->mrec_lock);
+ atomic_set(&ni->mft_count, 0);
+ ni->page = NULL;
+ ni->attr_list = NULL;
+ ni->attr_list_rl = NULL;
+ ni->bmp_rl = NULL;
+ init_MUTEX(&ni->extent_lock);
+ ni->base_ntfs_ino = NULL;
+ ni->vol = NTFS_SB(sb);
+ return;
+}
- vi->u.generic_ip = ntfs_new_inode();
- ni = NTFS_I(vi);
- if (ni) {
- ni->inode = vi;
- ni->mft_no = vi->i_ino;
- ni->vol = NTFS_SB(vi->i_sb);
- return 0;
- }
- ntfs_error(vi->i_sb, "Cannot read inode. Aborting and marking inode "
- "as bad.");
- return -ENOMEM;
+static void ntfs_init_big_inode(struct inode *vi)
+{
+ ntfs_inode *ni = NTFS_I(vi);
+
+ ntfs_debug("Entering.\n");
+ __ntfs_init_inode(vi->i_sb, ni);
+ ni->mft_no = vi->i_ino;
+ return;
}
+ntfs_inode *ntfs_new_inode(struct super_block *sb)
+{
+ ntfs_inode *ni = ntfs_alloc_inode();
+
+ ntfs_debug("Entering.\n");
+ if (ni)
+ __ntfs_init_inode(sb, ni);
+ return ni;
+}
+
/**
* ntfs_read_inode - read an inode from its device
@@ -109,11 +142,4 @@
ntfs_debug("Entering for i_ino 0x%lx.\n", vi->i_ino);
- /*
- * Initialize the ntfs specific part of @vi special casing
- * FILE_MFT which we need to do at mount time.
- */
- if (vi->i_ino != FILE_MFT && (err = ntfs_init_inode(vi)))
- goto imm_err_out;
- ni = NTFS_I(vi);
/* Setup the generic vfs inode parts now. */
@@ -132,4 +158,13 @@
vi->i_mode = 0;
+ /*
+ * Initialize the ntfs specific part of @vi special casing
+ * FILE_MFT which we need to do at mount time.
+ */
+ if (vi->i_ino != FILE_MFT)
+ ntfs_init_big_inode(vi);
+
+ ni = NTFS_I(vi);
+
/* Map, pin and lock the mft record for reading. */
m = map_mft_record(READ, ni);
@@ -378,4 +413,12 @@
}
ni->index_block_size_bits = ffs(ni->index_block_size) - 1;
+ /* Determine the size of a vcn in the directory index. */
+ if (vol->cluster_size <= ni->index_block_size) {
+ ni->index_vcn_size = vol->cluster_size;
+ ni->index_vcn_size_bits = vol->cluster_size_bits;
+ } else {
+ ni->index_vcn_size = vol->sector_size;
+ ni->index_vcn_size_bits = vol->sector_size_bits;
+ }
if (!(ir->index.flags & LARGE_INDEX)) {
/* No index allocation. */
@@ -622,22 +665,4 @@
ntfs_error(vi->i_sb, "Failed with error code %i. Marking inode "
"%li (0x%lx) as bad.", -err, vi->i_ino, vi->i_ino);
- /* No need to lock at this stage... */
- if (ni->nr_extents > 0) {
- int i;
-
- for (i = 0; i < ni->nr_extents; i++)
- ntfs_free_inode(ni->extent_ntfs_inos[i]);
- ni->nr_extents = 0;
- kfree(ni->extent_ntfs_inos);
- ni->extent_ntfs_inos = NULL;
- }
- vi->u.generic_ip = NULL;
- ntfs_free(ni->run_list);
- ntfs_free(ni->attr_list);
- ntfs_free(ni->attr_list_rl);
- if (S_ISDIR(vi->i_mode))
- ntfs_free(ni->bmp_rl);
- ntfs_free_inode(ni);
-imm_err_out:
make_bad_inode(vi);
return;
@@ -687,10 +712,9 @@
/* Initialize the ntfs specific part of @vi. */
- if (ntfs_init_inode(vi))
- goto imm_err_out;
+ ntfs_init_big_inode(vi);
ni = NTFS_I(vi);
if (vi->i_ino != FILE_MFT) {
- ntfs_error(sb, "Called for inode %ld but only inode %d allowed.",
- vi->i_ino, FILE_MFT);
+ ntfs_error(sb, "Called for inode %ld but only inode %d "
+ "allowed.", vi->i_ino, FILE_MFT);
goto err_out;
}
@@ -723,5 +747,5 @@
/* Load $MFT/$DATA's first mft record. */
for (i = 0; i < nr_blocks; i++) {
- bh = bread(vi->i_dev, block++, sb->s_blocksize);
+ bh = sb_bread(sb, block++);
if (!bh) {
ntfs_error(sb, "Device read failed.");
@@ -1012,22 +1036,6 @@
put_attr_search_ctx(ctx);
err_out:
- /* No need to lock at this stage... */
- if (ni->nr_extents > 0) {
- int i;
-
- for (i = 0; i < ni->nr_extents; i++)
- ntfs_free_inode(ni->extent_ntfs_inos[i]);
- ni->nr_extents = 0;
- kfree(ni->extent_ntfs_inos);
- ni->extent_ntfs_inos = NULL;
- }
/* Make sure we revert to the safe super operations. */
sb->s_op = &ntfs_mount_sops;
- vi->u.generic_ip = NULL;
- ntfs_free(ni->run_list);
- ntfs_free(ni->attr_list);
- ntfs_free(ni->attr_list_rl);
- ntfs_free_inode(ni);
-imm_err_out:
ntfs_error(sb, "Failed. Marking inode as bad.");
make_bad_inode(vi);
@@ -1080,29 +1088,13 @@
}
-/**
- * ntfs_clear_inode - clean up the ntfs specific part of an inode
- * @vi: vfs inode pending annihilation
- *
- * When the VFS is going to remove an inode from memory, ntfs_clear_inode() is
- * called, which deallocates all memory belonging to the NTFS specific part of
- * the inode and returns.
- *
- * If the MFT record is dirty, we commit it before doing anything else.
- */
-void ntfs_clear_inode(struct inode *vi)
+void __ntfs_clear_inode(ntfs_inode *ni)
{
- ntfs_inode *ni = NTFS_I(vi);
int err;
- if (unlikely(!ni)) {
- if (!is_bad_inode(vi))
- ntfs_error(vi->i_sb, "Double clear!");
- return;
- }
ntfs_debug("Entering for inode 0x%Lx.\n", ni->mft_no);
if (NInoDirty(ni)) {
err = ntfs_commit_inode(ni);
if (err) {
- ntfs_error(vi->i_sb, "Failed to commit dirty "
+ ntfs_error(ni->vol->sb, "Failed to commit dirty "
"inode synchronously.");
// FIXME: Do something!!!
@@ -1113,5 +1105,5 @@
up_write(&ni->mrec_lock);
if (NInoDirty(ni)) {
- ntfs_error(vi->i_sb, "Failed to commit dirty inode "
+ ntfs_error(ni->vol->sb, "Failed to commit dirty inode "
"asynchronously.");
// FIXME: Do something!!!
@@ -1123,16 +1115,39 @@
// FIXME: Handle dirty case for each extent inode!
for (i = 0; i < ni->nr_extents; i++)
- ntfs_free_inode(ni->extent_ntfs_inos[i]);
+ ntfs_destroy_inode(ni->extent_ntfs_inos[i]);
kfree(ni->extent_ntfs_inos);
}
/* Free all alocated memory. */
- vi->u.generic_ip = NULL;
ntfs_free(ni->run_list);
ntfs_free(ni->attr_list);
ntfs_free(ni->attr_list_rl);
+}
+
+void ntfs_clear_inode(ntfs_inode *ni)
+{
+ __ntfs_clear_inode(ni);
+
+ /* Bye, bye... */
+ ntfs_destroy_inode(ni);
+}
+
+/**
+ * ntfs_clear_inode - clean up the ntfs specific part of an inode
+ * @vi: vfs inode pending annihilation
+ *
+ * When the VFS is going to remove an inode from memory, ntfs_clear_inode() is
+ * called, which deallocates all memory belonging to the NTFS specific part of
+ * the inode and returns.
+ *
+ * If the MFT record is dirty, we commit it before doing anything else.
+ */
+void ntfs_clear_big_inode(struct inode *vi)
+{
+ ntfs_inode *ni = NTFS_I(vi);
+
+ __ntfs_clear_inode(ni);
+
if (S_ISDIR(vi->i_mode))
ntfs_free(ni->bmp_rl);
- /* Bye, bye... */
- ntfs_free_inode(ni);
return;
}
Index: inode.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/inode.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -U2 -r1.9 -r1.10
--- inode.h 2002/01/28 07:01:17 1.9
+++ inode.h 2002/01/31 02:21:36 1.10
@@ -33,6 +33,4 @@
*/
struct _ntfs_inode {
- struct inode *inode; /* Pointer to the inode structure of this
- ntfs_inode. NULL for extent inodes. */
unsigned long state; /* NTFS specific flags describing this inode.
See fs/ntfs/ntfs.h:ntfs_inode_state_bits. */
@@ -72,6 +70,8 @@
struct { /* It is a directory. */
u32 index_block_size; /* Size of an index block. */
- u8 index_block_size_bits; /* Log2 of the size of an
- index block. */
+ u8 index_block_size_bits; /* Log2 of the above. */
+ u32 index_vcn_size; /* Size of a vcn in this
+ directory index. */
+ u8 index_vcn_size_bits; /* Log2 of the above. */
s64 bmp_size; /* Size of the $I30 bitmap. */
run_list *bmp_rl; /* Run list for the $I30 bitmap
@@ -90,7 +90,6 @@
struct semaphore extent_lock; /* Lock for accessing/modifying the
below . */
- s32 nr_extents; /* The number of extent inodes, if this is a base
- mft record, -1 if this is an extent record, and
- 0 if there are no loaded extents. */
+ s32 nr_extents; /* For a base mft record, the number of attached extent
+ inodes (0 if none), for extent records this is -1. */
union { /* This union is only used if nr_extents != 0. */
ntfs_inode **extent_ntfs_inos; /* For nr_extents > 0, array of
@@ -105,13 +104,36 @@
};
-extern ntfs_inode *ntfs_new_inode(void);
-extern void ntfs_free_inode(ntfs_inode *ni);
+typedef struct {
+ ntfs_inode ntfs_inode;
+ struct inode vfs_inode; /* The vfs inode structure. */
+} big_ntfs_inode;
+/**
+ * NTFS_I - return the ntfs inode given a vfs inode
+ * @inode: VFS inode
+ *
+ * NTFS_I() returns the ntfs inode associated with the VFS @inode.
+ */
+static inline ntfs_inode *NTFS_I(struct inode *inode)
+{
+ return (ntfs_inode *)list_entry(inode, big_ntfs_inode, vfs_inode);
+}
+
+static inline struct inode *VFS_I(ntfs_inode *ni)
+{
+ return &((big_ntfs_inode*)ni)->vfs_inode;
+}
+
+extern struct inode *ntfs_alloc_big_inode(struct super_block *sb);
+extern void ntfs_destroy_big_inode(struct inode *inode);
+extern void ntfs_clear_big_inode(struct inode *vi);
+
+extern ntfs_inode *ntfs_new_inode(struct super_block *sb);
+extern void ntfs_clear_inode(ntfs_inode *ni);
+
extern void ntfs_read_inode(struct inode *vi);
extern void ntfs_read_inode_mount(struct inode *vi);
extern void ntfs_dirty_inode(struct inode *vi);
-
-extern void ntfs_clear_inode(struct inode *ni);
#endif /* _LINUX_NTFS_FS_INODE_H */
Index: layout.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/layout.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -U2 -r1.6 -r1.7
--- layout.h 2001/12/13 20:58:41 1.6
+++ layout.h 2002/01/31 02:21:36 1.7
@@ -1864,5 +1864,9 @@
/* 8*/ s64 lsn; /* $LogFile sequence number of the last
modification of this index block. */
-/* 16*/ VCN index_block_vcn; /* Virtual cluster number of the index block. */
+/* 16*/ VCN index_block_vcn; /* Virtual cluster number of the index block.
+ If the cluster_size on the volume is <= the
+ index_block_size of the directory,
+ index_block_vcn counts in units of clusters,
+ and in units of sectors otherwise. */
/* 24*/ INDEX_HEADER index; /* Describes the following index entries. */
/* sizeof()= 40 (0x28) bytes */
Index: mft.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/mft.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -U2 -r1.39 -r1.40
--- mft.c 2002/01/30 12:07:23 1.39
+++ mft.c 2002/01/31 02:21:36 1.40
@@ -679,5 +679,5 @@
}
/* Record wasn't there. Get a new ntfs inode and initialize it. */
- ni = ntfs_new_inode();
+ ni = ntfs_new_inode(base_ni->vol->sb);
if (!ni) {
up(&base_ni->extent_lock);
@@ -695,5 +695,5 @@
up(&base_ni->extent_lock);
atomic_dec(&base_ni->count);
- ntfs_free_inode(ni);
+ ntfs_clear_inode(ni);
goto map_err_out;
}
@@ -736,8 +736,8 @@
/*
* If the extent inode is not attached to the base inode we need to
- * terminate it with extreme prejudice or we will leak memory.
+ * release it or we will leak memory.
*/
if (destroy_ni)
- ntfs_free_inode(ni);
+ ntfs_clear_inode(ni);
return m;
}
Index: namei.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/namei.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -U2 -r1.15 -r1.16
--- namei.c 2002/01/28 07:01:17 1.15
+++ namei.c 2002/01/31 02:21:36 1.16
@@ -70,5 +70,5 @@
if (dent_inode) {
// FIXME: quick consistency check with MSEQNO(mref) and
- // dent_inode->i_generation possible here.
+ // NTFS_I(dent_inode)->seq_no possible here.
d_add(dent, dent_inode);
return NULL;
Index: ntfs.h
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/ntfs.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -U2 -r1.21 -r1.22
--- ntfs.h 2002/01/28 07:01:17 1.21
+++ ntfs.h 2002/01/31 02:21:36 1.22
@@ -97,4 +97,5 @@
extern kmem_cache_t *ntfs_name_cache;
extern kmem_cache_t *ntfs_inode_cache;
+extern kmem_cache_t *ntfs_big_inode_cache;
extern kmem_cache_t *ntfs_attr_ctx_cache;
@@ -130,15 +131,4 @@
{
return sb->u.generic_sbp;
-}
-
-/**
- * NTFS_I - return the ntfs inode given a vfs inode
- * @inode: VFS inode
- *
- * NTFS_I() returns the ntfs inode associated with the VFS @inode.
- */
-static inline ntfs_inode *NTFS_I(struct inode *inode)
-{
- return inode->u.generic_ip;
}
Index: super.c
===================================================================
RCS file: /cvsroot/linux-ntfs/ntfs-driver-tng/linux/fs/ntfs/super.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -U2 -r1.66 -r1.67
--- super.c 2002/01/30 12:07:23 1.66
+++ super.c 2002/01/31 02:21:36 1.67
@@ -381,12 +381,9 @@
{
const char *read_err_str = "Unable to read %s boot sector.";
- kdev_t dev = sb->s_dev;
struct buffer_head *bh_primary, *bh_backup;
- ntfs_volume *vol = NTFS_SB(sb);
- long nr_blocks = vol->nr_blocks;
- unsigned long blocksize = sb->s_blocksize;
+ long nr_blocks = NTFS_SB(sb)->nr_blocks;
/* Try to read primary boot sector. */
- if ((bh_primary = bread(dev, 0, blocksize))) {
+ if ((bh_primary = sb_bread(sb, 0))) {
if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
bh_primary->b_data, silent))
@@ -396,5 +393,5 @@
} else if (!silent)
ntfs_error(sb, read_err_str, "primary");
- if (vol->on_errors & ~ON_ERRORS_RECOVER) {
+ if (NTFS_SB(sb)->on_errors & ~ON_ERRORS_RECOVER) {
if (bh_primary)
brelse(bh_primary);
@@ -405,5 +402,5 @@
}
/* Try to read NT4+ backup boot sector. */
- if ((bh_backup = bread(dev, nr_blocks - 1, blocksize))) {
+ if ((bh_backup = sb_bread(sb, nr_blocks - 1))) {
if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
bh_backup->b_data, silent))
@@ -413,5 +410,5 @@
ntfs_error(sb, read_err_str, "backup");
/* Try to read NT3.51- backup boot sector. */
- if ((bh_backup = bread(dev, nr_blocks >> 1, blocksize))) {
+ if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
bh_backup->b_data, silent))
@@ -438,5 +435,5 @@
"boot sector from backup copy.");
memcpy(bh_primary->b_data, bh_backup->b_data,
- blocksize);
+ sb->s_blocksize);
mark_buffer_dirty(bh_primary);
ll_rw_block(WRITE, 1, &bh_primary);
@@ -926,7 +923,4 @@
return TRUE;
/* NTFS 3.0+ specific initialization. */
-#if 0
- // FIXME: $Secure doesn't have an unnamed data attribute so the current
- // iget() fails. Hm.
/* Get the security descriptors inode. */
vol->secure_ino = iget(sb, FILE_Secure);
@@ -934,8 +928,7 @@
if (is_bad_inode(vol->secure_ino))
iput(vol->secure_ino);
- ntfs_error(sb, __FUNCTION__ "(): Failed to load $Secure.");
+ ntfs_error(sb, "Failed to load $Secure.");
goto iput_root_vol_bmp_mirr_err_out;
}
-#endif
// FIXME: Initialize security.
/* Get the extended system files' directory inode. */
@@ -955,6 +948,6 @@
return TRUE;
iput_sec_root_vol_bmp_mirr_err_out:
- // FIXME: iput(vol->secure_ino);
-// iput_root_vol_bmp_mirr_err_out:
+ iput(vol->secure_ino);
+iput_root_vol_bmp_mirr_err_out:
iput(vol->root_ino);
iput_vol_bmp_mirr_err_out:
@@ -1294,11 +1287,15 @@
*/
struct super_operations ntfs_mount_sops = {
+ alloc_inode: ntfs_alloc_big_inode, /* VFS: Allocate a new inode. */
+ destroy_inode: ntfs_destroy_big_inode, /* VFS: Deallocate an inode. */
read_inode: ntfs_read_inode_mount, /* VFS: Load inode from disk,
called from iget(). */
- clear_inode: ntfs_clear_inode, /* VFS: Called when an inode is
+ clear_inode: ntfs_clear_big_inode, /* VFS: Called when an inode is
removed from memory. */
};
struct super_operations ntfs_sops = {
+ alloc_inode: ntfs_alloc_big_inode, /* VFS: Allocate a new inode. */
+ destroy_inode: ntfs_destroy_big_inode, /* VFS: Deallocate an inode. */
read_inode: ntfs_read_inode, /* VFS: Load inode from disk,
called from iget(). */
@@ -1319,5 +1316,5 @@
statfs: ntfs_statfs, /* Syscall: statfs */
remount_fs: ntfs_remount, /* Syscall: mount -o remount. */
- clear_inode: ntfs_clear_inode, /* VFS: Called when an inode is
+ clear_inode: ntfs_clear_big_inode, /* VFS: Called when an inode is
removed from memory. */
umount_begin: NULL, /* Forced umount. */
@@ -1330,4 +1327,5 @@
fh_to_dentry: NULL, /* Get dentry for given file handle. */
dentry_to_fh: NULL, /* Get file handle for given dentry. */
+ show_options: NULL, /* Show mount options in proc. */
};
@@ -1367,5 +1365,5 @@
if (!silent)
ntfs_error(sb, "Allocation of NTFS volume structure "
- "failed. Aborting...");
+ "failed. Aborting mount...");
goto imm_err_out_now;
}
@@ -1415,17 +1413,18 @@
if (get_hardsect_size(dev) > NTFS_BLOCK_SIZE) {
if (!silent)
- ntfs_error(sb, "Device has unsupported hardsect_size. "
- "Cannot mount.");
+ ntfs_error(sb, "Device has unsupported hardsect_size.");
goto err_out_now;
}
/* Setup the device access block size to NTFS_BLOCK_SIZE. */
- sb->s_blocksize = NTFS_BLOCK_SIZE;
- sb->s_blocksize_bits = NTFS_BLOCK_SIZE_BITS;
if (!blksize_size[major(dev)])
old_blocksize = BLOCK_SIZE;
else
old_blocksize = blksize_size[major(dev)][minor(dev)];
- set_blocksize(dev, sb->s_blocksize);
+ if (sb_set_blocksize(sb, NTFS_BLOCK_SIZE) != NTFS_BLOCK_SIZE) {
+ if (!silent)
+ ntfs_error(sb, "Unable to set block size.");
+ goto set_blk_size_err_out_now;
+ }
/* Get the size of the device in NTFS_BLOCK_SIZE byte blocks. */
@@ -1506,6 +1505,6 @@
result = allocate_compression_buffers();
if (result) {
- ntfs_error(NULL, "Failed to allocate buffers for "
- "compression engine.");
+ ntfs_error(NULL, "Failed to allocate per CPU buffers "
+ "for compression engine.");
ntfs_nr_compression_users--;
up(&ntfs_lock);
@@ -1614,5 +1613,6 @@
}
set_blk_size_err_out_now:
- set_blocksize(dev, old_blocksize);
+ /* Errors at this stage are irrelevant. */
+ sb_set_blocksize(sb, old_blocksize);
err_out_now:
sb->u.generic_sbp = NULL;
@@ -1630,11 +1630,19 @@
kmem_cache_t *ntfs_name_cache;
-/*
- * Slab cache for efficient allocation/deallocation of the ntfs specific part
- * of inodes. We attach the allocated memory to generic_ip pointer in struct
- * inode.
- */
+/* Slab caches for efficient allocation/deallocation of of inodes. */
kmem_cache_t *ntfs_inode_cache;
+kmem_cache_t *ntfs_big_inode_cache;
+/* Init once constructor for the inode slab cache. */
+static void ntfs_big_inode_init_once(void *foo, kmem_cache_t *cachep,
+ unsigned long flags)
+{
+ ntfs_inode *ni = (ntfs_inode *)foo;
+
+ if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
+ SLAB_CTOR_CONSTRUCTOR)
+ inode_init_once(VFS_I(ni));
+}
+
/*
* Slab cache to optimize allocations and deallocations of attribute search
@@ -1692,6 +1700,5 @@
ntfs_inode_cache = kmem_cache_create("ntfs_inode_cache",
- sizeof(ntfs_inode), 0, SLAB_HWCACHE_ALIGN,
- NULL, NULL);
+ sizeof(ntfs_inode), 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
if (!ntfs_inode_cache) {
printk(KERN_CRIT "NTFS: Failed to create ntfs_inode_cache!\n");
@@ -1699,4 +1706,13 @@
}
+ ntfs_big_inode_cache = kmem_cache_create("ntfs_b_inode_cache",
+ sizeof(big_ntfs_inode), 0, SLAB_HWCACHE_ALIGN,
+ ntfs_big_inode_init_once, NULL);
+ if (!ntfs_big_inode_cache) {
+ printk(KERN_CRIT "NTFS: Failed to create "
+ "ntfs_big_inode_cache!\n");
+ goto big_inode_err_out;
+ }
+
err = register_filesystem(&ntfs_fs_type);
if (!err)
@@ -1704,4 +1720,6 @@
printk(KERN_CRIT "NTFS: Failed to register NTFS file system driver!\n");
+ kmem_cache_destroy(ntfs_big_inode_cache);
+big_inode_err_out:
kmem_cache_destroy(ntfs_inode_cache);
inode_err_out:
@@ -1724,4 +1742,9 @@
ntfs_debug("Entering.\n");
+ ntfs_debug("Unregistering NTFS driver.\n");
+ unregister_filesystem(&ntfs_fs_type);
+ if (kmem_cache_destroy(ntfs_big_inode_cache) && (err = 1))
+ printk(KERN_CRIT "NTFS: Failed to destory "
+ "ntfs_big_inode_cache.\n");
if (kmem_cache_destroy(ntfs_inode_cache) && (err = 1))
printk(KERN_CRIT "NTFS: Failed to destory ntfs_inode_cache.\n");
@@ -1729,6 +1752,5 @@
printk(KERN_CRIT "NTFS: Failed to destory ntfs_name_cache.\n");
if (kmem_cache_destroy(ntfs_attr_ctx_cache) && (err = 1))
- printk(KERN_CRIT "NTFS: Failed to destory "
- "ntfs_actx_cache.\n");
+ printk(KERN_CRIT "NTFS: Failed to destory ntfs_actx_cache.\n");
if (err)
printk(KERN_CRIT "NTFS: This causes memory to leak! There is "
@@ -1736,6 +1758,4 @@
"you saw this message to "
"linux-ntfs-dev@lists.sf.net\n");
- unregister_filesystem(&ntfs_fs_type);
- ntfs_debug("Unregistering NTFS driver.\n");
}
_______________________________________________
Linux-NTFS-cvs mailing list
Linux-NTFS-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-ntfs-cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic