[RFC] [PATCH 7/8] inode-diet: Use a union for i_blocks and i_size, i_rdev and i_devices

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

 



The i_blocks and i_size fields are only used for regular files.  So we
move them into the union, along with i_rdev and i_devices, which are
only used by block or character devices.

Signed-off-by: "Theodore Ts'o" <[email protected]>

Index: linux-2.6.17/include/linux/fs.h
===================================================================
--- linux-2.6.17.orig/include/linux/fs.h	2006-06-20 23:37:20.000000000 -0400
+++ linux-2.6.17/include/linux/fs.h	2006-06-20 23:37:29.000000000 -0400
@@ -486,15 +486,12 @@
 	unsigned int		i_nlink;
 	uid_t			i_uid;
 	gid_t			i_gid;
-	dev_t			i_rdev;
 	loff_t			i_size;
 	struct timespec		i_atime;
 	struct timespec		i_mtime;
 	struct timespec		i_ctime;
 	unsigned int		i_blkbits;
 	unsigned long		i_version;
-	blkcnt_t		i_blocks;
-	unsigned short          i_bytes;
 	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
 	struct mutex		i_mutex;
 	struct rw_semaphore	i_alloc_sem;
@@ -507,11 +504,20 @@
 #ifdef CONFIG_QUOTA
 	struct dquot		*i_dquot[MAXQUOTAS];
 #endif
-	struct list_head	i_devices;
 	union {
 		struct pipe_inode_info	*i_pipe;
-		struct block_device	*i_bdev;
-		struct cdev		*i_cdev;
+		struct {
+			union {
+				struct block_device	*i_bdev;
+				struct cdev		*i_cdev;
+			};
+			dev_t			i_rdev;
+			struct list_head	i_devices;
+		};
+		struct {
+			unsigned short          i_bytes;
+			blkcnt_t		i_blocks;
+		};
 	};
 
 	__u32			i_generation;
Index: linux-2.6.17/fs/stat.c
===================================================================
--- linux-2.6.17.orig/fs/stat.c	2006-06-20 22:04:21.000000000 -0400
+++ linux-2.6.17/fs/stat.c	2006-06-20 23:38:00.000000000 -0400
@@ -33,7 +33,7 @@
 	stat->mtime = inode->i_mtime;
 	stat->ctime = inode->i_ctime;
 	stat->size = i_size_read(inode);
-	stat->blocks = inode->i_blocks;
+	stat->blocks = S_ISREG(inode->i_mode) ? inode->i_blocks : 0;
 	stat->blksize = PAGE_CACHE_SIZE;
 }
 

--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux