Merge branch 'for-linus-4.1' of git://git.kernel.org/pub/scm/linux/kernel/git/mason...
[cascardo/linux.git] / fs / btrfs / inode.c
index 0020b56..8bb0136 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/writeback.h>
 #include <linux/statfs.h>
 #include <linux/compat.h>
-#include <linux/aio.h>
 #include <linux/bit_spinlock.h>
 #include <linux/xattr.h>
 #include <linux/posix_acl.h>
@@ -4024,16 +4023,16 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
 {
        struct btrfs_root *root = BTRFS_I(dir)->root;
        struct btrfs_trans_handle *trans;
-       struct inode *inode = dentry->d_inode;
+       struct inode *inode = d_inode(dentry);
        int ret;
 
        trans = __unlink_start_trans(dir);
        if (IS_ERR(trans))
                return PTR_ERR(trans);
 
-       btrfs_record_unlink_dir(trans, dir, dentry->d_inode, 0);
+       btrfs_record_unlink_dir(trans, dir, d_inode(dentry), 0);
 
-       ret = btrfs_unlink_inode(trans, root, dir, dentry->d_inode,
+       ret = btrfs_unlink_inode(trans, root, dir, d_inode(dentry),
                                 dentry->d_name.name, dentry->d_name.len);
        if (ret)
                goto out;
@@ -4132,7 +4131,7 @@ out:
 
 static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
 {
-       struct inode *inode = dentry->d_inode;
+       struct inode *inode = d_inode(dentry);
        int err = 0;
        struct btrfs_root *root = BTRFS_I(dir)->root;
        struct btrfs_trans_handle *trans;
@@ -4159,7 +4158,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
                goto out;
 
        /* now the directory is empty */
-       err = btrfs_unlink_inode(trans, root, dir, dentry->d_inode,
+       err = btrfs_unlink_inode(trans, root, dir, d_inode(dentry),
                                 dentry->d_name.name, dentry->d_name.len);
        if (!err)
                btrfs_i_size_write(inode, 0);
@@ -4919,7 +4918,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
 
 static int btrfs_setattr(struct dentry *dentry, struct iattr *attr)
 {
-       struct inode *inode = dentry->d_inode;
+       struct inode *inode = d_inode(dentry);
        struct btrfs_root *root = BTRFS_I(inode)->root;
        int err;
 
@@ -5551,10 +5550,10 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)
 static int btrfs_dentry_delete(const struct dentry *dentry)
 {
        struct btrfs_root *root;
-       struct inode *inode = dentry->d_inode;
+       struct inode *inode = d_inode(dentry);
 
        if (!inode && !IS_ROOT(dentry))
-               inode = dentry->d_parent->d_inode;
+               inode = d_inode(dentry->d_parent);
 
        if (inode) {
                root = BTRFS_I(inode)->root;
@@ -6361,7 +6360,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
 {
        struct btrfs_trans_handle *trans;
        struct btrfs_root *root = BTRFS_I(dir)->root;
-       struct inode *inode = old_dentry->d_inode;
+       struct inode *inode = d_inode(old_dentry);
        u64 index;
        int err;
        int drop_inode = 0;
@@ -8216,7 +8215,7 @@ free_ordered:
        bio_endio(dio_bio, ret);
 }
 
-static ssize_t check_direct_IO(struct btrfs_root *root, int rw, struct kiocb *iocb,
+static ssize_t check_direct_IO(struct btrfs_root *root, struct kiocb *iocb,
                        const struct iov_iter *iter, loff_t offset)
 {
        int seg;
@@ -8231,7 +8230,7 @@ static ssize_t check_direct_IO(struct btrfs_root *root, int rw, struct kiocb *io
                goto out;
 
        /* If this is a write we don't need to check anymore */
-       if (rw & WRITE)
+       if (iov_iter_rw(iter) == WRITE)
                return 0;
        /*
         * Check to make sure we don't have duplicate iov_base's in this
@@ -8249,8 +8248,8 @@ out:
        return retval;
 }
 
-static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
-                       struct iov_iter *iter, loff_t offset)
+static ssize_t btrfs_direct_IO(struct kiocb *iocb, struct iov_iter *iter,
+                              loff_t offset)
 {
        struct file *file = iocb->ki_filp;
        struct inode *inode = file->f_mapping->host;
@@ -8261,10 +8260,10 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
        bool relock = false;
        ssize_t ret;
 
-       if (check_direct_IO(BTRFS_I(inode)->root, rw, iocb, iter, offset))
+       if (check_direct_IO(BTRFS_I(inode)->root, iocb, iter, offset))
                return 0;
 
-       atomic_inc(&inode->i_dio_count);
+       inode_dio_begin(inode);
        smp_mb__after_atomic();
 
        /*
@@ -8279,7 +8278,7 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
                filemap_fdatawrite_range(inode->i_mapping, offset,
                                         offset + count - 1);
 
-       if (rw & WRITE) {
+       if (iov_iter_rw(iter) == WRITE) {
                /*
                 * If the write DIO is beyond the EOF, we need update
                 * the isize, but it is protected by i_mutex. So we can
@@ -8304,16 +8303,16 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
                current->journal_info = &outstanding_extents;
        } else if (test_bit(BTRFS_INODE_READDIO_NEED_LOCK,
                                     &BTRFS_I(inode)->runtime_flags)) {
-               inode_dio_done(inode);
+               inode_dio_end(inode);
                flags = DIO_LOCKING | DIO_SKIP_HOLES;
                wakeup = false;
        }
 
-       ret = __blockdev_direct_IO(rw, iocb, inode,
-                       BTRFS_I(inode)->root->fs_info->fs_devices->latest_bdev,
-                       iter, offset, btrfs_get_blocks_direct, NULL,
-                       btrfs_submit_direct, flags);
-       if (rw & WRITE) {
+       ret = __blockdev_direct_IO(iocb, inode,
+                                  BTRFS_I(inode)->root->fs_info->fs_devices->latest_bdev,
+                                  iter, offset, btrfs_get_blocks_direct, NULL,
+                                  btrfs_submit_direct, flags);
+       if (iov_iter_rw(iter) == WRITE) {
                current->journal_info = NULL;
                if (ret < 0 && ret != -EIOCBQUEUED)
                        btrfs_delalloc_release_space(inode, count);
@@ -8323,7 +8322,7 @@ static ssize_t btrfs_direct_IO(int rw, struct kiocb *iocb,
        }
 out:
        if (wakeup)
-               inode_dio_done(inode);
+               inode_dio_end(inode);
        if (relock)
                mutex_lock(&inode->i_mutex);
 
@@ -9010,7 +9009,7 @@ static int btrfs_getattr(struct vfsmount *mnt,
                         struct dentry *dentry, struct kstat *stat)
 {
        u64 delalloc_bytes;
-       struct inode *inode = dentry->d_inode;
+       struct inode *inode = d_inode(dentry);
        u32 blocksize = inode->i_sb->s_blocksize;
 
        generic_fillattr(inode, stat);
@@ -9031,8 +9030,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        struct btrfs_trans_handle *trans;
        struct btrfs_root *root = BTRFS_I(old_dir)->root;
        struct btrfs_root *dest = BTRFS_I(new_dir)->root;
-       struct inode *new_inode = new_dentry->d_inode;
-       struct inode *old_inode = old_dentry->d_inode;
+       struct inode *new_inode = d_inode(new_dentry);
+       struct inode *old_inode = d_inode(old_dentry);
        struct timespec ctime = CURRENT_TIME;
        u64 index = 0;
        u64 root_objectid;
@@ -9144,7 +9143,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                                        old_dentry->d_name.len);
        } else {
                ret = __btrfs_unlink_inode(trans, root, old_dir,
-                                       old_dentry->d_inode,
+                                       d_inode(old_dentry),
                                        old_dentry->d_name.name,
                                        old_dentry->d_name.len);
                if (!ret)
@@ -9168,12 +9167,12 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        BUG_ON(new_inode->i_nlink == 0);
                } else {
                        ret = btrfs_unlink_inode(trans, dest, new_dir,
-                                                new_dentry->d_inode,
+                                                d_inode(new_dentry),
                                                 new_dentry->d_name.name,
                                                 new_dentry->d_name.len);
                }
                if (!ret && new_inode->i_nlink == 0)
-                       ret = btrfs_orphan_add(trans, new_dentry->d_inode);
+                       ret = btrfs_orphan_add(trans, d_inode(new_dentry));
                if (ret) {
                        btrfs_abort_transaction(trans, root, ret);
                        goto out_fail;