new helper: file_inode(file)
[linux-block.git] / net / sunrpc / cache.c
index fc2f7aa4dca7aa04b3e7bc45cd39d47b744a1da4..f3897d10f649ff41e5ca717a82560d51412f61fa 100644 (file)
@@ -755,7 +755,7 @@ static ssize_t cache_read(struct file *filp, char __user *buf, size_t count,
 {
        struct cache_reader *rp = filp->private_data;
        struct cache_request *rq;
-       struct inode *inode = filp->f_path.dentry->d_inode;
+       struct inode *inode = file_inode(filp);
        int err;
 
        if (count == 0)
@@ -775,11 +775,11 @@ static ssize_t cache_read(struct file *filp, char __user *buf, size_t count,
        if (rp->q.list.next == &cd->queue) {
                spin_unlock(&queue_lock);
                mutex_unlock(&inode->i_mutex);
-               BUG_ON(rp->offset);
+               WARN_ON_ONCE(rp->offset);
                return 0;
        }
        rq = container_of(rp->q.list.next, struct cache_request, q.list);
-       BUG_ON(rq->q.reader);
+       WARN_ON_ONCE(rq->q.reader);
        if (rp->offset == 0)
                rq->readers++;
        spin_unlock(&queue_lock);
@@ -886,7 +886,7 @@ static ssize_t cache_write(struct file *filp, const char __user *buf,
                           struct cache_detail *cd)
 {
        struct address_space *mapping = filp->f_mapping;
-       struct inode *inode = filp->f_path.dentry->d_inode;
+       struct inode *inode = file_inode(filp);
        ssize_t ret = -EINVAL;
 
        if (!cd->cache_parse)
@@ -1454,7 +1454,7 @@ static ssize_t write_flush(struct file *file, const char __user *buf,
 static ssize_t cache_read_procfs(struct file *filp, char __user *buf,
                                 size_t count, loff_t *ppos)
 {
-       struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
+       struct cache_detail *cd = PDE(file_inode(filp))->data;
 
        return cache_read(filp, buf, count, ppos, cd);
 }
@@ -1462,14 +1462,14 @@ static ssize_t cache_read_procfs(struct file *filp, char __user *buf,
 static ssize_t cache_write_procfs(struct file *filp, const char __user *buf,
                                  size_t count, loff_t *ppos)
 {
-       struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
+       struct cache_detail *cd = PDE(file_inode(filp))->data;
 
        return cache_write(filp, buf, count, ppos, cd);
 }
 
 static unsigned int cache_poll_procfs(struct file *filp, poll_table *wait)
 {
-       struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
+       struct cache_detail *cd = PDE(file_inode(filp))->data;
 
        return cache_poll(filp, wait, cd);
 }
@@ -1477,7 +1477,7 @@ static unsigned int cache_poll_procfs(struct file *filp, poll_table *wait)
 static long cache_ioctl_procfs(struct file *filp,
                               unsigned int cmd, unsigned long arg)
 {
-       struct inode *inode = filp->f_path.dentry->d_inode;
+       struct inode *inode = file_inode(filp);
        struct cache_detail *cd = PDE(inode)->data;
 
        return cache_ioctl(inode, filp, cmd, arg, cd);
@@ -1546,7 +1546,7 @@ static int release_flush_procfs(struct inode *inode, struct file *filp)
 static ssize_t read_flush_procfs(struct file *filp, char __user *buf,
                            size_t count, loff_t *ppos)
 {
-       struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
+       struct cache_detail *cd = PDE(file_inode(filp))->data;
 
        return read_flush(filp, buf, count, ppos, cd);
 }
@@ -1555,7 +1555,7 @@ static ssize_t write_flush_procfs(struct file *filp,
                                  const char __user *buf,
                                  size_t count, loff_t *ppos)
 {
-       struct cache_detail *cd = PDE(filp->f_path.dentry->d_inode)->data;
+       struct cache_detail *cd = PDE(file_inode(filp))->data;
 
        return write_flush(filp, buf, count, ppos, cd);
 }
@@ -1686,7 +1686,7 @@ EXPORT_SYMBOL_GPL(cache_destroy_net);
 static ssize_t cache_read_pipefs(struct file *filp, char __user *buf,
                                 size_t count, loff_t *ppos)
 {
-       struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
+       struct cache_detail *cd = RPC_I(file_inode(filp))->private;
 
        return cache_read(filp, buf, count, ppos, cd);
 }
@@ -1694,14 +1694,14 @@ static ssize_t cache_read_pipefs(struct file *filp, char __user *buf,
 static ssize_t cache_write_pipefs(struct file *filp, const char __user *buf,
                                  size_t count, loff_t *ppos)
 {
-       struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
+       struct cache_detail *cd = RPC_I(file_inode(filp))->private;
 
        return cache_write(filp, buf, count, ppos, cd);
 }
 
 static unsigned int cache_poll_pipefs(struct file *filp, poll_table *wait)
 {
-       struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
+       struct cache_detail *cd = RPC_I(file_inode(filp))->private;
 
        return cache_poll(filp, wait, cd);
 }
@@ -1709,7 +1709,7 @@ static unsigned int cache_poll_pipefs(struct file *filp, poll_table *wait)
 static long cache_ioctl_pipefs(struct file *filp,
                              unsigned int cmd, unsigned long arg)
 {
-       struct inode *inode = filp->f_dentry->d_inode;
+       struct inode *inode = file_inode(filp);
        struct cache_detail *cd = RPC_I(inode)->private;
 
        return cache_ioctl(inode, filp, cmd, arg, cd);
@@ -1778,7 +1778,7 @@ static int release_flush_pipefs(struct inode *inode, struct file *filp)
 static ssize_t read_flush_pipefs(struct file *filp, char __user *buf,
                            size_t count, loff_t *ppos)
 {
-       struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
+       struct cache_detail *cd = RPC_I(file_inode(filp))->private;
 
        return read_flush(filp, buf, count, ppos, cd);
 }
@@ -1787,7 +1787,7 @@ static ssize_t write_flush_pipefs(struct file *filp,
                                  const char __user *buf,
                                  size_t count, loff_t *ppos)
 {
-       struct cache_detail *cd = RPC_I(filp->f_path.dentry->d_inode)->private;
+       struct cache_detail *cd = RPC_I(file_inode(filp))->private;
 
        return write_flush(filp, buf, count, ppos, cd);
 }