Merge tag 'bitmap-6.0-rc1' of https://github.com/norov/linux
[linux-2.6-microblaze.git] / fs / xfs / xfs_iomap.c
index 5d50fed..07da039 100644 (file)
@@ -159,7 +159,7 @@ xfs_iomap_eof_align_last_fsb(
        struct xfs_inode        *ip,
        xfs_fileoff_t           end_fsb)
 {
-       struct xfs_ifork        *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
+       struct xfs_ifork        *ifp = xfs_ifork_ptr(ip, XFS_DATA_FORK);
        xfs_extlen_t            extsz = xfs_get_extsz_hint(ip);
        xfs_extlen_t            align = xfs_eof_alignment(ip);
        struct xfs_bmbt_irec    irec;
@@ -370,7 +370,7 @@ xfs_iomap_prealloc_size(
        struct xfs_iext_cursor  ncur = *icur;
        struct xfs_bmbt_irec    prev, got;
        struct xfs_mount        *mp = ip->i_mount;
-       struct xfs_ifork        *ifp = XFS_IFORK_PTR(ip, whichfork);
+       struct xfs_ifork        *ifp = xfs_ifork_ptr(ip, whichfork);
        xfs_fileoff_t           offset_fsb = XFS_B_TO_FSBT(mp, offset);
        int64_t                 freesp;
        xfs_fsblock_t           qblocks;
@@ -773,7 +773,8 @@ xfs_direct_write_iomap_begin(
 
                /* may drop and re-acquire the ilock */
                error = xfs_reflink_allocate_cow(ip, &imap, &cmap, &shared,
-                               &lockmode, flags & IOMAP_DIRECT);
+                               &lockmode,
+                               (flags & IOMAP_DIRECT) || IS_DAX(inode));
                if (error)
                        goto out_unlock;
                if (shared)
@@ -867,6 +868,33 @@ const struct iomap_ops xfs_direct_write_iomap_ops = {
        .iomap_begin            = xfs_direct_write_iomap_begin,
 };
 
+static int
+xfs_dax_write_iomap_end(
+       struct inode            *inode,
+       loff_t                  pos,
+       loff_t                  length,
+       ssize_t                 written,
+       unsigned                flags,
+       struct iomap            *iomap)
+{
+       struct xfs_inode        *ip = XFS_I(inode);
+
+       if (!xfs_is_cow_inode(ip))
+               return 0;
+
+       if (!written) {
+               xfs_reflink_cancel_cow_range(ip, pos, length, true);
+               return 0;
+       }
+
+       return xfs_reflink_end_cow(ip, pos, written);
+}
+
+const struct iomap_ops xfs_dax_write_iomap_ops = {
+       .iomap_begin    = xfs_direct_write_iomap_begin,
+       .iomap_end      = xfs_dax_write_iomap_end,
+};
+
 static int
 xfs_buffered_write_iomap_begin(
        struct inode            *inode,
@@ -1310,12 +1338,12 @@ xfs_xattr_iomap_begin(
        lockmode = xfs_ilock_attr_map_shared(ip);
 
        /* if there are no attribute fork or extents, return ENOENT */
-       if (!XFS_IFORK_Q(ip) || !ip->i_afp->if_nextents) {
+       if (!xfs_inode_has_attr_fork(ip) || !ip->i_af.if_nextents) {
                error = -ENOENT;
                goto out_unlock;
        }
 
-       ASSERT(ip->i_afp->if_format != XFS_DINODE_FMT_LOCAL);
+       ASSERT(ip->i_af.if_format != XFS_DINODE_FMT_LOCAL);
        error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, &imap,
                               &nimaps, XFS_BMAPI_ATTRFORK);
 out_unlock: