Merge tag 'xfs-5.20-merge-6' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[linux-2.6-microblaze.git] / fs / xfs / xfs_iomap.c
index 5a39325..2817d3d 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;
@@ -664,7 +664,7 @@ xfs_ilock_for_iomap(
        unsigned                flags,
        unsigned                *lockmode)
 {
-       unsigned                mode = XFS_ILOCK_SHARED;
+       unsigned int            mode = *lockmode;
        bool                    is_write = flags & (IOMAP_WRITE | IOMAP_ZERO);
 
        /*
@@ -742,7 +742,7 @@ xfs_direct_write_iomap_begin(
        int                     nimaps = 1, error = 0;
        bool                    shared = false;
        u16                     iomap_flags = 0;
-       unsigned                lockmode;
+       unsigned int            lockmode = XFS_ILOCK_SHARED;
 
        ASSERT(flags & (IOMAP_WRITE | IOMAP_ZERO));
 
@@ -886,6 +886,7 @@ xfs_buffered_write_iomap_begin(
        bool                    eof = false, cow_eof = false, shared = false;
        int                     allocfork = XFS_DATA_FORK;
        int                     error = 0;
+       unsigned int            lockmode = XFS_ILOCK_EXCL;
 
        if (xfs_is_shutdown(mp))
                return -EIO;
@@ -897,7 +898,9 @@ xfs_buffered_write_iomap_begin(
 
        ASSERT(!XFS_IS_REALTIME_INODE(ip));
 
-       xfs_ilock(ip, XFS_ILOCK_EXCL);
+       error = xfs_ilock_for_iomap(ip, flags, &lockmode);
+       if (error)
+               return error;
 
        if (XFS_IS_CORRUPT(mp, !xfs_ifork_has_extents(&ip->i_df)) ||
            XFS_TEST_ERROR(false, mp, XFS_ERRTAG_BMAPIFORMAT)) {
@@ -1172,7 +1175,7 @@ xfs_read_iomap_begin(
        xfs_fileoff_t           end_fsb = xfs_iomap_end_fsb(mp, offset, length);
        int                     nimaps = 1, error = 0;
        bool                    shared = false;
-       unsigned                lockmode;
+       unsigned int            lockmode = XFS_ILOCK_SHARED;
 
        ASSERT(!(flags & (IOMAP_WRITE | IOMAP_ZERO)));
 
@@ -1307,12 +1310,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: