]> wimlib.net Git - wimlib/commitdiff
Save memory by using hlist for i_dentry
authorEric Biggers <ebiggers3@gmail.com>
Sun, 31 May 2015 05:18:00 +0000 (00:18 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 5 Jun 2015 03:45:34 +0000 (22:45 -0500)
include/wimlib/dentry.h
include/wimlib/inode.h
src/inode.c

index efaf176830e71c4a7af53fcb987e630c9511b1b3..74cb7ad6be1d03f2e4ad30c4cfdad74bc6b20757 100644 (file)
@@ -57,7 +57,7 @@ struct wim_dentry {
 
        /* Linked list node that places this dentry in the list of aliases for
         * its inode (d_inode) */
 
        /* Linked list node that places this dentry in the list of aliases for
         * its inode (d_inode) */
-       struct list_head d_alias;
+       struct hlist_node d_alias;
 
        /* Pointer to the UTF-16LE short filename (malloc()ed buffer), or NULL
         * if this dentry has no short name.  */
 
        /* Pointer to the UTF-16LE short filename (malloc()ed buffer), or NULL
         * if this dentry has no short name.  */
index 777a05b5440501e66a247bc99bef57d10e9ee835..20e1b5ccc018526a47daccda00ab8d6275ea0ff5 100644 (file)
@@ -119,7 +119,7 @@ struct wim_inode {
 
        /* List of dentries that are aliases for this inode.  There will be
         * i_nlink dentries in this list.  */
 
        /* List of dentries that are aliases for this inode.  There will be
         * i_nlink dentries in this list.  */
-       struct list_head i_dentry;
+       struct hlist_head i_dentry;
 
        /* Field to place this inode into a list.  While reading a WIM image or
         * adding files to a WIM image this is owned by the inode table;
 
        /* Field to place this inode into a list.  While reading a WIM image or
         * adding files to a WIM image this is owned by the inode table;
@@ -268,11 +268,11 @@ new_inode(struct wim_dentry *dentry, bool set_timestamps);
 
 /* Iterate through each alias of the specified inode.  */
 #define inode_for_each_dentry(dentry, inode) \
 
 /* Iterate through each alias of the specified inode.  */
 #define inode_for_each_dentry(dentry, inode) \
-       list_for_each_entry((dentry), &(inode)->i_dentry, d_alias)
+       hlist_for_each_entry((dentry), &(inode)->i_dentry, d_alias)
 
 /* Return an alias of the specified inode.  */
 #define inode_first_dentry(inode) \
 
 /* Return an alias of the specified inode.  */
 #define inode_first_dentry(inode) \
-       container_of(inode->i_dentry.next, struct wim_dentry, d_alias)
+       hlist_entry(inode->i_dentry.first, struct wim_dentry, d_alias)
 
 /* Return the full path of an alias of the specified inode, or NULL if a full
  * path could not be determined.  */
 
 /* Return the full path of an alias of the specified inode, or NULL if a full
  * path could not be determined.  */
index e43fd2d0d1b446f70a5b334f45ad05a76a2d1deb..a181e885753efde4b5a054b38166c0c0f8b90cd5 100644 (file)
@@ -57,7 +57,7 @@ new_inode(struct wim_dentry *dentry, bool set_timestamps)
        inode->i_security_id = -1;
        /*inode->i_nlink = 0;*/
        inode->i_rp_flags = WIM_RP_FLAG_NOT_FIXED;
        inode->i_security_id = -1;
        /*inode->i_nlink = 0;*/
        inode->i_rp_flags = WIM_RP_FLAG_NOT_FIXED;
-       INIT_LIST_HEAD(&inode->i_dentry);
+       INIT_HLIST_HEAD(&inode->i_dentry);
        inode->i_streams = inode->i_embedded_streams;
        if (set_timestamps) {
                u64 now = now_as_wim_timestamp();
        inode->i_streams = inode->i_embedded_streams;
        if (set_timestamps) {
                u64 now = now_as_wim_timestamp();
@@ -108,7 +108,7 @@ d_associate(struct wim_dentry *dentry, struct wim_inode *inode)
 {
        wimlib_assert(!dentry->d_inode);
 
 {
        wimlib_assert(!dentry->d_inode);
 
-       list_add_tail(&dentry->d_alias, &inode->i_dentry);
+       hlist_add_head(&dentry->d_alias, &inode->i_dentry);
        dentry->d_inode = inode;
        inode->i_nlink++;
 }
        dentry->d_inode = inode;
        inode->i_nlink++;
 }
@@ -125,7 +125,7 @@ d_disassociate(struct wim_dentry *dentry)
 
        wimlib_assert(inode->i_nlink > 0);
 
 
        wimlib_assert(inode->i_nlink > 0);
 
-       list_del(&dentry->d_alias);
+       hlist_del(&dentry->d_alias);
        dentry->d_inode = NULL;
        inode->i_nlink--;
 
        dentry->d_inode = NULL;
        inode->i_nlink--;