vfs: remove get_xip_mem
[linux-drm-fsl-dcu.git] / fs / ext2 / inode.c
index 36d35c36311d69a025c5b804e8d8597cbd9cb2b2..59d6c7d43740bf771bf2ea80befbe0bd3498d74f 100644 (file)
@@ -731,12 +731,14 @@ static int ext2_get_blocks(struct inode *inode,
                goto cleanup;
        }
 
-       if (ext2_use_xip(inode->i_sb)) {
+       if (IS_DAX(inode)) {
                /*
-                * we need to clear the block
+                * block must be initialised before we put it in the tree
+                * so that it's not found by another thread before it's
+                * initialised
                 */
-               err = ext2_clear_xip_target (inode,
-                       le32_to_cpu(chain[depth-1].key));
+               err = dax_clear_blocks(inode, le32_to_cpu(chain[depth-1].key),
+                                               1 << inode->i_blkbits);
                if (err) {
                        mutex_unlock(&ei->truncate_mutex);
                        goto cleanup;
@@ -859,7 +861,12 @@ ext2_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter,
        size_t count = iov_iter_count(iter);
        ssize_t ret;
 
-       ret = blockdev_direct_IO(rw, iocb, inode, iter, offset, ext2_get_block);
+       if (IS_DAX(inode))
+               ret = dax_do_io(rw, iocb, inode, iter, offset, ext2_get_block,
+                               NULL, DIO_LOCKING);
+       else
+               ret = blockdev_direct_IO(rw, iocb, inode, iter, offset,
+                                        ext2_get_block);
        if (ret < 0 && (rw & WRITE))
                ext2_write_failed(mapping, offset + count);
        return ret;
@@ -887,7 +894,7 @@ const struct address_space_operations ext2_aops = {
 
 const struct address_space_operations ext2_aops_xip = {
        .bmap                   = ext2_bmap,
-       .get_xip_mem            = ext2_get_xip_mem,
+       .direct_IO              = ext2_direct_IO,
 };
 
 const struct address_space_operations ext2_nobh_aops = {
@@ -1201,8 +1208,8 @@ static int ext2_setsize(struct inode *inode, loff_t newsize)
 
        inode_dio_wait(inode);
 
-       if (mapping_is_xip(inode->i_mapping))
-               error = xip_truncate_page(inode->i_mapping, newsize);
+       if (IS_DAX(inode))
+               error = dax_truncate_page(inode, newsize, ext2_get_block);
        else if (test_opt(inode->i_sb, NOBH))
                error = nobh_truncate_page(inode->i_mapping,
                                newsize, ext2_get_block);
@@ -1273,7 +1280,8 @@ void ext2_set_inode_flags(struct inode *inode)
 {
        unsigned int flags = EXT2_I(inode)->i_flags;
 
-       inode->i_flags &= ~(S_SYNC|S_APPEND|S_IMMUTABLE|S_NOATIME|S_DIRSYNC);
+       inode->i_flags &= ~(S_SYNC | S_APPEND | S_IMMUTABLE | S_NOATIME |
+                               S_DIRSYNC | S_DAX);
        if (flags & EXT2_SYNC_FL)
                inode->i_flags |= S_SYNC;
        if (flags & EXT2_APPEND_FL)
@@ -1284,6 +1292,8 @@ void ext2_set_inode_flags(struct inode *inode)
                inode->i_flags |= S_NOATIME;
        if (flags & EXT2_DIRSYNC_FL)
                inode->i_flags |= S_DIRSYNC;
+       if (test_opt(inode->i_sb, XIP))
+               inode->i_flags |= S_DAX;
 }
 
 /* Propagate flags from i_flags to EXT2_I(inode)->i_flags */