[PATCH 02/17] fs: Save pointer in struct inode by better unioning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



i_rcu (struct rcu_head) has two pointers but it is unioned with i_dentry
(struct hlist_head) which has only one pointer. Union i_rcu with
i_sb_list instead and thus safe one pointer in struct inode.

Signed-off-by: Jan Kara <jack@xxxxxxx>
---
 Documentation/filesystems/porting | 5 -----
 fs/inode.c                        | 3 ++-
 include/linux/fs.h                | 4 ++--
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting
index fe2b7ae6f962..26ce6cd742c6 100644
--- a/Documentation/filesystems/porting
+++ b/Documentation/filesystems/porting
@@ -354,11 +354,6 @@ protects *all* the dcache state of a given dentry.
 via rcu-walk path walk (basically, if the file can have had a path name in the
 vfs namespace).
 
-	Even though i_dentry and i_rcu share storage in a union, we will
-initialize the former in inode_init_always(), so just leave it alone in
-the callback.  It used to be necessary to clean it there, but not anymore
-(starting at 3.2).
-
 --
 [recommended]
 	vfs now tries to do path walking in "rcu-walk mode", which avoids
diff --git a/fs/inode.c b/fs/inode.c
index e89be4c4c9f4..1b888eb524ca 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -183,7 +183,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
 	}
 	inode->i_private = NULL;
 	inode->i_mapping = mapping;
-	INIT_HLIST_HEAD(&inode->i_dentry);	/* buggered by rcu freeing */
+	INIT_LIST_HEAD(&inode->i_sb_list);	/* buggered by rcu freeing */
 #ifdef CONFIG_FS_POSIX_ACL
 	inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;
 #endif
@@ -258,6 +258,7 @@ static void i_callback(struct rcu_head *head)
 static void destroy_inode(struct inode *inode)
 {
 	BUG_ON(!list_empty(&inode->i_lru));
+	BUG_ON(!list_empty(&inode->i_sb_list));
 	__destroy_inode(inode);
 	if (inode->i_sb->s_op->destroy_inode)
 		inode->i_sb->s_op->destroy_inode(inode);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index ac6e06a09980..b76720852f5f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -579,9 +579,9 @@ struct inode {
 	struct hlist_node	i_hash;
 	struct list_head	i_wb_list;	/* backing dev IO list */
 	struct list_head	i_lru;		/* inode LRU list */
-	struct list_head	i_sb_list;
+	struct hlist_head	i_dentry;
 	union {
-		struct hlist_head	i_dentry;
+		struct list_head	i_sb_list;
 		struct rcu_head		i_rcu;
 	};
 	u64			i_version;
-- 
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux