ARM: OMAP: Fix map_io for Amstrad E3
[firefly-linux-kernel-4.4.55.git] / fs / xfs / xfs_vnodeops.c
index 51fc429527bc0cc31839888c8e9597de551abac5..4ecf2a549060295b0d354847a538eba890083631 100644 (file)
@@ -72,8 +72,8 @@ xfs_readlink_bmap(
        xfs_buf_t       *bp;
        int             error = 0;
 
-       error = xfs_bmapi(NULL, ip, 0, XFS_B_TO_FSB(mp, pathlen), 0, NULL, 0,
-                       mval, &nmaps, NULL);
+       error = xfs_bmapi_read(ip, 0, XFS_B_TO_FSB(mp, pathlen), mval, &nmaps,
+                              0);
        if (error)
                goto out;
 
@@ -87,8 +87,7 @@ xfs_readlink_bmap(
                        return XFS_ERROR(ENOMEM);
                error = bp->b_error;
                if (error) {
-                       xfs_ioerror_alert("xfs_readlink",
-                                 ip->i_mount, bp, XFS_BUF_ADDR(bp));
+                       xfs_buf_ioerror_alert(bp, __func__);
                        xfs_buf_relse(bp);
                        goto out;
                }
@@ -178,8 +177,7 @@ xfs_free_eofblocks(
 
        nimaps = 1;
        xfs_ilock(ip, XFS_ILOCK_SHARED);
-       error = xfs_bmapi(NULL, ip, end_fsb, map_len, 0,
-                         NULL, 0, &imap, &nimaps, NULL);
+       error = xfs_bmapi_read(ip, end_fsb, map_len, &imap, &nimaps, 0);
        xfs_iunlock(ip, XFS_ILOCK_SHARED);
 
        if (!error && (nimaps != 0) &&
@@ -220,7 +218,7 @@ xfs_free_eofblocks(
                }
 
                xfs_ilock(ip, XFS_ILOCK_EXCL);
-               xfs_trans_ijoin(tp, ip);
+               xfs_trans_ijoin(tp, ip, 0);
 
                error = xfs_itruncate_data(&tp, ip, ip->i_size);
                if (error) {
@@ -289,7 +287,7 @@ xfs_inactive_symlink_rmt(
        xfs_ilock(ip, XFS_IOLOCK_EXCL | XFS_ILOCK_EXCL);
        size = (int)ip->i_d.di_size;
        ip->i_d.di_size = 0;
-       xfs_trans_ijoin(tp, ip);
+       xfs_trans_ijoin(tp, ip, 0);
        xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
        /*
         * Find the block(s) so we can inval and unmap them.
@@ -297,9 +295,9 @@ xfs_inactive_symlink_rmt(
        done = 0;
        xfs_bmap_init(&free_list, &first_block);
        nmaps = ARRAY_SIZE(mval);
-       if ((error = xfs_bmapi(tp, ip, 0, XFS_B_TO_FSB(mp, size),
-                       XFS_BMAPI_METADATA, &first_block, 0, mval, &nmaps,
-                       &free_list)))
+       error = xfs_bmapi_read(ip, 0, XFS_B_TO_FSB(mp, size),
+                               mval, &nmaps, 0);
+       if (error)
                goto error0;
        /*
         * Invalidate the block(s).
@@ -308,6 +306,10 @@ xfs_inactive_symlink_rmt(
                bp = xfs_trans_get_buf(tp, mp->m_ddev_targp,
                        XFS_FSB_TO_DADDR(mp, mval[i].br_startblock),
                        XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0);
+               if (!bp) {
+                       error = ENOMEM;
+                       goto error1;
+               }
                xfs_trans_binval(tp, bp);
        }
        /*
@@ -333,7 +335,7 @@ xfs_inactive_symlink_rmt(
         * Mark it dirty so it will be logged and moved forward in the log as
         * part of every commit.
         */
-       xfs_trans_ijoin(tp, ip);
+       xfs_trans_ijoin(tp, ip, 0);
        xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
        /*
         * Get a new, empty transaction to return to our caller.
@@ -466,7 +468,7 @@ xfs_inactive_attrs(
                goto error_cancel;
 
        xfs_ilock(ip, XFS_ILOCK_EXCL);
-       xfs_trans_ijoin(tp, ip);
+       xfs_trans_ijoin(tp, ip, 0);
        xfs_idestroy_fork(ip, XFS_ATTR_FORK);
 
        ASSERT(ip->i_d.di_anextents == 0);
@@ -647,8 +649,6 @@ xfs_inactive(
        if (truncate) {
                xfs_ilock(ip, XFS_IOLOCK_EXCL);
 
-               xfs_ioend_wait(ip);
-
                error = xfs_trans_reserve(tp, 0,
                                          XFS_ITRUNCATE_LOG_RES(mp),
                                          0, XFS_TRANS_PERM_LOG_RES,
@@ -662,7 +662,7 @@ xfs_inactive(
                }
 
                xfs_ilock(ip, XFS_ILOCK_EXCL);
-               xfs_trans_ijoin(tp, ip);
+               xfs_trans_ijoin(tp, ip, 0);
 
                error = xfs_itruncate_data(&tp, ip, 0);
                if (error) {
@@ -686,7 +686,7 @@ xfs_inactive(
                        return VN_INACTIVE_CACHE;
                }
 
-               xfs_trans_ijoin(tp, ip);
+               xfs_trans_ijoin(tp, ip, 0);
        } else {
                error = xfs_trans_reserve(tp, 0,
                                          XFS_IFREE_LOG_RES(mp),
@@ -699,7 +699,7 @@ xfs_inactive(
                }
 
                xfs_ilock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
-               xfs_trans_ijoin(tp, ip);
+               xfs_trans_ijoin(tp, ip, 0);
        }
 
        /*
@@ -939,7 +939,7 @@ xfs_create(
         * the transaction cancel unlocking dp so don't do it explicitly in the
         * error path.
         */
-       xfs_trans_ijoin_ref(tp, dp, XFS_ILOCK_EXCL);
+       xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
        unlock_dp_on_error = B_FALSE;
 
        error = xfs_dir_createname(tp, dp, name, ip->i_ino,
@@ -1260,8 +1260,8 @@ xfs_remove(
 
        xfs_lock_two_inodes(dp, ip, XFS_ILOCK_EXCL);
 
-       xfs_trans_ijoin_ref(tp, dp, XFS_ILOCK_EXCL);
-       xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL);
+       xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
+       xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 
        /*
         * If we're removing a directory perform some additional validation.
@@ -1406,8 +1406,8 @@ xfs_link(
 
        xfs_lock_two_inodes(sip, tdp, XFS_ILOCK_EXCL);
 
-       xfs_trans_ijoin_ref(tp, sip, XFS_ILOCK_EXCL);
-       xfs_trans_ijoin_ref(tp, tdp, XFS_ILOCK_EXCL);
+       xfs_trans_ijoin(tp, sip, XFS_ILOCK_EXCL);
+       xfs_trans_ijoin(tp, tdp, XFS_ILOCK_EXCL);
 
        /*
         * If the source has too many links, we can't make any more to it.
@@ -1601,7 +1601,7 @@ xfs_symlink(
         * transaction cancel unlocking dp so don't do it explicitly in the
         * error path.
         */
-       xfs_trans_ijoin_ref(tp, dp, XFS_ILOCK_EXCL);
+       xfs_trans_ijoin(tp, dp, XFS_ILOCK_EXCL);
        unlock_dp_on_error = B_FALSE;
 
        /*
@@ -1632,10 +1632,9 @@ xfs_symlink(
                first_fsb = 0;
                nmaps = SYMLINK_MAPS;
 
-               error = xfs_bmapi(tp, ip, first_fsb, fs_blocks,
-                                 XFS_BMAPI_WRITE | XFS_BMAPI_METADATA,
-                                 &first_block, resblks, mval, &nmaps,
-                                 &free_list);
+               error = xfs_bmapi_write(tp, ip, first_fsb, fs_blocks,
+                                 XFS_BMAPI_METADATA, &first_block, resblks,
+                                 mval, &nmaps, &free_list);
                if (error)
                        goto error2;
 
@@ -1650,7 +1649,10 @@ xfs_symlink(
                        byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
                        bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
                                               BTOBB(byte_cnt), 0);
-                       ASSERT(!xfs_buf_geterror(bp));
+                       if (!bp) {
+                               error = ENOMEM;
+                               goto error2;
+                       }
                        if (pathlen < byte_cnt) {
                                byte_cnt = pathlen;
                        }
@@ -1732,7 +1734,7 @@ xfs_set_dmattrs(
                return error;
        }
        xfs_ilock(ip, XFS_ILOCK_EXCL);
-       xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL);
+       xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 
        ip->i_d.di_dmevmask = evmask;
        ip->i_d.di_dmstate  = state;
@@ -1778,7 +1780,6 @@ xfs_alloc_file_space(
        xfs_fileoff_t           startoffset_fsb;
        xfs_fsblock_t           firstfsb;
        int                     nimaps;
-       int                     bmapi_flag;
        int                     quota_flag;
        int                     rt;
        xfs_trans_t             *tp;
@@ -1806,7 +1807,6 @@ xfs_alloc_file_space(
        count = len;
        imapp = &imaps[0];
        nimaps = 1;
-       bmapi_flag = XFS_BMAPI_WRITE | alloc_type;
        startoffset_fsb = XFS_B_TO_FSBT(mp, offset);
        allocatesize_fsb = XFS_B_TO_FSB(mp, count);
 
@@ -1877,16 +1877,12 @@ xfs_alloc_file_space(
                if (error)
                        goto error1;
 
-               xfs_trans_ijoin(tp, ip);
+               xfs_trans_ijoin(tp, ip, 0);
 
-               /*
-                * Issue the xfs_bmapi() call to allocate the blocks
-                */
                xfs_bmap_init(&free_list, &firstfsb);
-               error = xfs_bmapi(tp, ip, startoffset_fsb,
-                                 allocatesize_fsb, bmapi_flag,
-                                 &firstfsb, 0, imapp, &nimaps,
-                                 &free_list);
+               error = xfs_bmapi_write(tp, ip, startoffset_fsb,
+                                       allocatesize_fsb, alloc_type, &firstfsb,
+                                       0, imapp, &nimaps, &free_list);
                if (error) {
                        goto error0;
                }
@@ -1976,8 +1972,7 @@ xfs_zero_remaining_bytes(
        for (offset = startoff; offset <= endoff; offset = lastoffset + 1) {
                offset_fsb = XFS_B_TO_FSBT(mp, offset);
                nimap = 1;
-               error = xfs_bmapi(NULL, ip, offset_fsb, 1, 0,
-                       NULL, 0, &imap, &nimap, NULL);
+               error = xfs_bmapi_read(ip, offset_fsb, 1, &imap, &nimap, 0);
                if (error || nimap < 1)
                        break;
                ASSERT(imap.br_blockcount >= 1);
@@ -1997,8 +1992,8 @@ xfs_zero_remaining_bytes(
                xfsbdstrat(mp, bp);
                error = xfs_buf_iowait(bp);
                if (error) {
-                       xfs_ioerror_alert("xfs_zero_remaining_bytes(read)",
-                                         mp, bp, XFS_BUF_ADDR(bp));
+                       xfs_buf_ioerror_alert(bp,
+                                       "xfs_zero_remaining_bytes(read)");
                        break;
                }
                memset(bp->b_addr +
@@ -2010,8 +2005,8 @@ xfs_zero_remaining_bytes(
                xfsbdstrat(mp, bp);
                error = xfs_buf_iowait(bp);
                if (error) {
-                       xfs_ioerror_alert("xfs_zero_remaining_bytes(write)",
-                                         mp, bp, XFS_BUF_ADDR(bp));
+                       xfs_buf_ioerror_alert(bp,
+                                       "xfs_zero_remaining_bytes(write)");
                        break;
                }
        }
@@ -2076,7 +2071,7 @@ xfs_free_file_space(
        if (need_iolock) {
                xfs_ilock(ip, XFS_IOLOCK_EXCL);
                /* wait for the completion of any pending DIOs */
-               xfs_ioend_wait(ip);
+               inode_dio_wait(VFS_I(ip));
        }
 
        rounding = max_t(uint, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
@@ -2096,8 +2091,8 @@ xfs_free_file_space(
         */
        if (rt && !xfs_sb_version_hasextflgbit(&mp->m_sb)) {
                nimap = 1;
-               error = xfs_bmapi(NULL, ip, startoffset_fsb,
-                       1, 0, NULL, 0, &imap, &nimap, NULL);
+               error = xfs_bmapi_read(ip, startoffset_fsb, 1,
+                                       &imap, &nimap, 0);
                if (error)
                        goto out_unlock_iolock;
                ASSERT(nimap == 0 || nimap == 1);
@@ -2111,8 +2106,8 @@ xfs_free_file_space(
                                startoffset_fsb += mp->m_sb.sb_rextsize - mod;
                }
                nimap = 1;
-               error = xfs_bmapi(NULL, ip, endoffset_fsb - 1,
-                       1, 0, NULL, 0, &imap, &nimap, NULL);
+               error = xfs_bmapi_read(ip, endoffset_fsb - 1, 1,
+                                       &imap, &nimap, 0);
                if (error)
                        goto out_unlock_iolock;
                ASSERT(nimap == 0 || nimap == 1);
@@ -2180,7 +2175,7 @@ xfs_free_file_space(
                if (error)
                        goto error1;
 
-               xfs_trans_ijoin(tp, ip);
+               xfs_trans_ijoin(tp, ip, 0);
 
                /*
                 * issue the bunmapi() call to free the blocks
@@ -2353,8 +2348,7 @@ xfs_change_file_space(
        }
 
        xfs_ilock(ip, XFS_ILOCK_EXCL);
-
-       xfs_trans_ijoin(tp, ip);
+       xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
 
        if ((attr_flags & XFS_ATTR_DMI) == 0) {
                ip->i_d.di_mode &= ~S_ISUID;
@@ -2379,10 +2373,5 @@ xfs_change_file_space(
        xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
        if (attr_flags & XFS_ATTR_SYNC)
                xfs_trans_set_sync(tp);
-
-       error = xfs_trans_commit(tp, 0);
-
-       xfs_iunlock(ip, XFS_ILOCK_EXCL);
-
-       return error;
+       return xfs_trans_commit(tp, 0);
 }