Commit b69aee04 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

[NET]: Use file->private_data to get socket pointer.

Avoid touching file->f_dentry on sockets, since file->private_data
directly gives us the socket pointer.
Signed-off-by: default avatarEric Dumazet <dada1@cosmosbay.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 4706df3d
...@@ -1535,8 +1535,7 @@ static unsigned int packet_poll(struct file * file, struct socket *sock, ...@@ -1535,8 +1535,7 @@ static unsigned int packet_poll(struct file * file, struct socket *sock,
static void packet_mm_open(struct vm_area_struct *vma) static void packet_mm_open(struct vm_area_struct *vma)
{ {
struct file *file = vma->vm_file; struct file *file = vma->vm_file;
struct inode *inode = file->f_dentry->d_inode; struct socket * sock = file->private_data;
struct socket * sock = SOCKET_I(inode);
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
if (sk) if (sk)
...@@ -1546,8 +1545,7 @@ static void packet_mm_open(struct vm_area_struct *vma) ...@@ -1546,8 +1545,7 @@ static void packet_mm_open(struct vm_area_struct *vma)
static void packet_mm_close(struct vm_area_struct *vma) static void packet_mm_close(struct vm_area_struct *vma)
{ {
struct file *file = vma->vm_file; struct file *file = vma->vm_file;
struct inode *inode = file->f_dentry->d_inode; struct socket * sock = file->private_data;
struct socket * sock = SOCKET_I(inode);
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
if (sk) if (sk)
......
...@@ -667,7 +667,7 @@ static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf, ...@@ -667,7 +667,7 @@ static ssize_t sock_aio_read(struct kiocb *iocb, char __user *ubuf,
} }
iocb->private = x; iocb->private = x;
x->kiocb = iocb; x->kiocb = iocb;
sock = SOCKET_I(iocb->ki_filp->f_dentry->d_inode); sock = iocb->ki_filp->private_data;
x->async_msg.msg_name = NULL; x->async_msg.msg_name = NULL;
x->async_msg.msg_namelen = 0; x->async_msg.msg_namelen = 0;
...@@ -709,7 +709,7 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf, ...@@ -709,7 +709,7 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const char __user *ubuf,
} }
iocb->private = x; iocb->private = x;
x->kiocb = iocb; x->kiocb = iocb;
sock = SOCKET_I(iocb->ki_filp->f_dentry->d_inode); sock = iocb->ki_filp->private_data;
x->async_msg.msg_name = NULL; x->async_msg.msg_name = NULL;
x->async_msg.msg_namelen = 0; x->async_msg.msg_namelen = 0;
...@@ -732,7 +732,7 @@ static ssize_t sock_sendpage(struct file *file, struct page *page, ...@@ -732,7 +732,7 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
struct socket *sock; struct socket *sock;
int flags; int flags;
sock = SOCKET_I(file->f_dentry->d_inode); sock = file->private_data;
flags = !(file->f_flags & O_NONBLOCK) ? 0 : MSG_DONTWAIT; flags = !(file->f_flags & O_NONBLOCK) ? 0 : MSG_DONTWAIT;
if (more) if (more)
...@@ -741,14 +741,14 @@ static ssize_t sock_sendpage(struct file *file, struct page *page, ...@@ -741,14 +741,14 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
return sock->ops->sendpage(sock, page, offset, size, flags); return sock->ops->sendpage(sock, page, offset, size, flags);
} }
static int sock_readv_writev(int type, struct inode * inode, static int sock_readv_writev(int type,
struct file * file, const struct iovec * iov, struct file * file, const struct iovec * iov,
long count, size_t size) long count, size_t size)
{ {
struct msghdr msg; struct msghdr msg;
struct socket *sock; struct socket *sock;
sock = SOCKET_I(inode); sock = file->private_data;
msg.msg_name = NULL; msg.msg_name = NULL;
msg.msg_namelen = 0; msg.msg_namelen = 0;
...@@ -775,7 +775,7 @@ static ssize_t sock_readv(struct file *file, const struct iovec *vector, ...@@ -775,7 +775,7 @@ static ssize_t sock_readv(struct file *file, const struct iovec *vector,
int i; int i;
for (i = 0 ; i < count ; i++) for (i = 0 ; i < count ; i++)
tot_len += vector[i].iov_len; tot_len += vector[i].iov_len;
return sock_readv_writev(VERIFY_WRITE, file->f_dentry->d_inode, return sock_readv_writev(VERIFY_WRITE,
file, vector, count, tot_len); file, vector, count, tot_len);
} }
...@@ -786,7 +786,7 @@ static ssize_t sock_writev(struct file *file, const struct iovec *vector, ...@@ -786,7 +786,7 @@ static ssize_t sock_writev(struct file *file, const struct iovec *vector,
int i; int i;
for (i = 0 ; i < count ; i++) for (i = 0 ; i < count ; i++)
tot_len += vector[i].iov_len; tot_len += vector[i].iov_len;
return sock_readv_writev(VERIFY_READ, file->f_dentry->d_inode, return sock_readv_writev(VERIFY_READ,
file, vector, count, tot_len); file, vector, count, tot_len);
} }
...@@ -840,7 +840,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) ...@@ -840,7 +840,7 @@ static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
int pid, err; int pid, err;
sock = SOCKET_I(file->f_dentry->d_inode); sock = file->private_data;
if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) { if (cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) {
err = dev_ioctl(cmd, argp); err = dev_ioctl(cmd, argp);
} else } else
...@@ -939,13 +939,13 @@ static unsigned int sock_poll(struct file *file, poll_table * wait) ...@@ -939,13 +939,13 @@ static unsigned int sock_poll(struct file *file, poll_table * wait)
/* /*
* We can't return errors to poll, so it's either yes or no. * We can't return errors to poll, so it's either yes or no.
*/ */
sock = SOCKET_I(file->f_dentry->d_inode); sock = file->private_data;
return sock->ops->poll(file, sock, wait); return sock->ops->poll(file, sock, wait);
} }
static int sock_mmap(struct file * file, struct vm_area_struct * vma) static int sock_mmap(struct file * file, struct vm_area_struct * vma)
{ {
struct socket *sock = SOCKET_I(file->f_dentry->d_inode); struct socket *sock = file->private_data;
return sock->ops->mmap(file, sock, vma); return sock->ops->mmap(file, sock, vma);
} }
...@@ -995,7 +995,7 @@ static int sock_fasync(int fd, struct file *filp, int on) ...@@ -995,7 +995,7 @@ static int sock_fasync(int fd, struct file *filp, int on)
return -ENOMEM; return -ENOMEM;
} }
sock = SOCKET_I(filp->f_dentry->d_inode); sock = filp->private_data;
if ((sk=sock->sk) == NULL) { if ((sk=sock->sk) == NULL) {
kfree(fna); kfree(fna);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment