[NET]: Make use of ->private_data in sockfd_lookup
authorBenjamin LaHaise <bcrl@linux.intel.com>
Wed, 10 Aug 2005 21:16:04 +0000 (14:16 -0700)
committerDavid S. Miller <davem@sunset.davemloft.net>
Mon, 29 Aug 2005 22:56:38 +0000 (15:56 -0700)
Please consider the patch below which makes use of file->private_data to
store the pointer to the socket, which avoids touching several unused
cachelines in the dentry and inode in sockfd_lookup.

Signed-off-by: Benjamin LaHaise <bcrl@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/socket.c

index 6f2a178819726b7b878aa22a6d79954b61c1e239..5f76ab8a15944fa5dd2374f75078d6eb52f00530 100644 (file)
@@ -404,6 +404,7 @@ int sock_map_fd(struct socket *sock)
                file->f_mode = FMODE_READ | FMODE_WRITE;
                file->f_flags = O_RDWR;
                file->f_pos = 0;
+               file->private_data = sock;
                fd_install(fd, file);
        }
 
@@ -436,6 +437,9 @@ struct socket *sockfd_lookup(int fd, int *err)
                return NULL;
        }
 
+       if (file->f_op == &socket_file_ops)
+               return file->private_data;      /* set in sock_map_fd */
+
        inode = file->f_dentry->d_inode;
        if (!S_ISSOCK(inode->i_mode)) {
                *err = -ENOTSOCK;