Skip to contentSkip to conversation

Remove i_sock

PATCH In review Matthew Wilcox 2 participants 2 messages Mar 26, 2005 – Apr 1, 2005

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove i_sock

Remove i_sock from struct inode. Also remove some checks for SOCKET_I() returning NULL -- it can never return NULL for a valid inode.

Index: ./fs/inode.c
===================================================================
RCS file: /var/lib/cvs/linux-2.6/fs/inode.c,v
retrieving revision 1.17

fs/inode.c +0 -1
diff -u -p -r1.17 inode.c
@@ -118,7 +118,6 @@ static struct inode *alloc_inode(struct 
 		inode->i_blkbits = sb->s_blocksize_bits;
 		inode->i_flags = 0;
 		atomic_set(&inode->i_count, 1);
-		inode->i_sock = 0;
 		inode->i_op = &empty_iops;
 		inode->i_fop = &empty_fops;
 		inode->i_nlink = 1;

Index: ./include/linux/fs.h
===================================================================
RCS file: /var/lib/cvs/linux-2.6/include/linux/fs.h,v retrieving revision 1.29

include/linux/fs.h +0 -1
diff -u -p -r1.29 fs.h
@@ -445,7 +445,6 @@ struct inode {
 	unsigned long		i_version;
 	unsigned long		i_blocks;
 	unsigned short          i_bytes;
-	unsigned char		i_sock;
 	spinlock_t		i_lock;	/* i_blocks, i_bytes, maybe i_size */
 	struct semaphore	i_sem;
 	struct rw_semaphore	i_alloc_sem;

Index: ./net/socket.c
===================================================================
RCS file: /var/lib/cvs/linux-2.6/net/socket.c,v
retrieving revision 1.16

net/socket.c +2 -3
diff -u -p -r1.16 socket.c
@@ -437,13 +437,13 @@ struct socket *sockfd_lookup(int fd, int
 	}
 
 	inode = file->f_dentry->d_inode;
-	if (!inode->i_sock || !(sock = SOCKET_I(inode)))
-	{
+	if (!S_ISSOCK(inode->i_mode)) {
 		*err = -ENOTSOCK;
 		fput(file);
 		return NULL;
 	}
 
+	sock = SOCKET_I(inode);
 	if (sock->file != file) {
 		printk(KERN_ERR "socki_lookup: socket file changed!\n");
 		sock->file = file;
@@ -471,7 +471,6 @@ static struct socket *sock_alloc(void)
 	sock = SOCKET_I(inode);
 
 	inode->i_mode = S_IFSOCK|S_IRWXUGO;
-	inode->i_sock = 1;
 	inode->i_uid = current->fsuid;
 	inode->i_gid = current->fsgid;
 

Index: ./net/netlink/af_netlink.c
===================================================================
RCS file: /var/lib/cvs/linux-2.6/net/netlink/af_netlink.c,v retrieving revision 1.20

net/netlink/af_netlink.c +2 -3
diff -u -p -r1.20 af_netlink.c
@@ -563,13 +563,12 @@ static struct sock *netlink_getsockbypid
 struct sock *netlink_getsockbyfilp(struct file *filp)
 {
 	struct inode *inode = filp->f_dentry->d_inode;
-	struct socket *socket;
 	struct sock *sock;
 
-	if (!inode->i_sock || !(socket = SOCKET_I(inode)))
+	if (!S_ISSOCK(inode->i_mode))
 		return ERR_PTR(-ENOTSOCK);
 
-	sock = socket->sk;
+	sock = SOCKET_I(inode)->sk;
 	if (sock->sk_family != AF_NETLINK)
 		return ERR_PTR(-EINVAL);
 

Index: ./net/unix/garbage.c
===================================================================
RCS file: /var/lib/cvs/linux-2.6/net/unix/garbage.c,v retrieving revision 1.1

net/unix/garbage.c +1 -1
diff -u -p -r1.1 garbage.c
@@ -100,7 +100,7 @@ static struct sock *unix_get_socket(stru
 	/*
 	 *	Socket ?
 	 */
-	if (inode->i_sock) {
+	if (S_ISSOCK(inode->i_mode)) {
 		struct socket * sock = SOCKET_I(inode);
 		struct sock * s = sock->sk;
 
Signature · 6 lines
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain