提交 07dc3f07 编写于 作者: B Benjamin LaHaise 提交者: David S. Miller

[NET]: Make use of ->private_data in sockfd_lookup

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: NBenjamin LaHaise <bcrl@linux.intel.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 cef07fd6
...@@ -404,6 +404,7 @@ int sock_map_fd(struct socket *sock) ...@@ -404,6 +404,7 @@ int sock_map_fd(struct socket *sock)
file->f_mode = FMODE_READ | FMODE_WRITE; file->f_mode = FMODE_READ | FMODE_WRITE;
file->f_flags = O_RDWR; file->f_flags = O_RDWR;
file->f_pos = 0; file->f_pos = 0;
file->private_data = sock;
fd_install(fd, file); fd_install(fd, file);
} }
...@@ -436,6 +437,9 @@ struct socket *sockfd_lookup(int fd, int *err) ...@@ -436,6 +437,9 @@ struct socket *sockfd_lookup(int fd, int *err)
return NULL; return NULL;
} }
if (file->f_op == &socket_file_ops)
return file->private_data; /* set in sock_map_fd */
inode = file->f_dentry->d_inode; inode = file->f_dentry->d_inode;
if (!S_ISSOCK(inode->i_mode)) { if (!S_ISSOCK(inode->i_mode)) {
*err = -ENOTSOCK; *err = -ENOTSOCK;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册