xfs: include reservations in quota reporting
[linux-2.6.git] / fs / xfs / xfs_log_recover.c
index aaf61d5..7c75c73 100644 (file)
@@ -179,13 +179,11 @@ xlog_bread_noalign(
        XFS_BUF_SET_ADDR(bp, log->l_logBBstart + blk_no);
        XFS_BUF_READ(bp);
        XFS_BUF_SET_COUNT(bp, BBTOB(nbblks));
-       XFS_BUF_SET_TARGET(bp, log->l_mp->m_logdev_targp);
 
        xfsbdstrat(log->l_mp, bp);
        error = xfs_buf_iowait(bp);
        if (error)
-               xfs_ioerror_alert("xlog_bread", log->l_mp,
-                                 bp, XFS_BUF_ADDR(bp));
+               xfs_buf_ioerror_alert(bp, __func__);
        return error;
 }
 
@@ -268,11 +266,11 @@ xlog_bwrite(
        xfs_buf_hold(bp);
        xfs_buf_lock(bp);
        XFS_BUF_SET_COUNT(bp, BBTOB(nbblks));
-       XFS_BUF_SET_TARGET(bp, log->l_mp->m_logdev_targp);
 
-       if ((error = xfs_bwrite(log->l_mp, bp)))
-               xfs_ioerror_alert("xlog_bwrite", log->l_mp,
-                                 bp, XFS_BUF_ADDR(bp));
+       error = xfs_bwrite(bp);
+       if (error)
+               xfs_buf_ioerror_alert(bp, __func__);
+       xfs_buf_relse(bp);
        return error;
 }
 
@@ -363,9 +361,7 @@ xlog_recover_iodone(
                 * We're not going to bother about retrying
                 * this during recovery. One strike!
                 */
-               xfs_ioerror_alert("xlog_recover_iodone",
-                                       bp->b_target->bt_mount, bp,
-                                       XFS_BUF_ADDR(bp));
+               xfs_buf_ioerror_alert(bp, __func__);
                xfs_force_shutdown(bp->b_target->bt_mount,
                                        SHUTDOWN_META_IO_ERROR);
        }
@@ -969,9 +965,9 @@ xlog_find_tail(
                log->l_curr_cycle++;
        atomic64_set(&log->l_tail_lsn, be64_to_cpu(rhead->h_tail_lsn));
        atomic64_set(&log->l_last_sync_lsn, be64_to_cpu(rhead->h_lsn));
-       xlog_assign_grant_head(&log->l_grant_reserve_head, log->l_curr_cycle,
+       xlog_assign_grant_head(&log->l_reserve_head.grant, log->l_curr_cycle,
                                        BBTOB(log->l_curr_block));
-       xlog_assign_grant_head(&log->l_grant_write_head, log->l_curr_cycle,
+       xlog_assign_grant_head(&log->l_write_head.grant, log->l_curr_cycle,
                                        BBTOB(log->l_curr_block));
 
        /*
@@ -1493,7 +1489,7 @@ xlog_recover_add_to_cont_trans(
        old_ptr = item->ri_buf[item->ri_cnt-1].i_addr;
        old_len = item->ri_buf[item->ri_cnt-1].i_len;
 
-       ptr = kmem_realloc(old_ptr, len+old_len, old_len, 0u);
+       ptr = kmem_realloc(old_ptr, len+old_len, old_len, KM_SLEEP);
        memcpy(&ptr[old_len], dp, len); /* d, s, l */
        item->ri_buf[item->ri_cnt-1].i_len += len;
        item->ri_buf[item->ri_cnt-1].i_addr = ptr;
@@ -1985,7 +1981,7 @@ xfs_qm_dqcheck(
 
        if (!errs && ddq->d_id) {
                if (ddq->d_blk_softlimit &&
-                   be64_to_cpu(ddq->d_bcount) >=
+                   be64_to_cpu(ddq->d_bcount) >
                                be64_to_cpu(ddq->d_blk_softlimit)) {
                        if (!ddq->d_btimer) {
                                if (flags & XFS_QMOPT_DOWARN)
@@ -1996,7 +1992,7 @@ xfs_qm_dqcheck(
                        }
                }
                if (ddq->d_ino_softlimit &&
-                   be64_to_cpu(ddq->d_icount) >=
+                   be64_to_cpu(ddq->d_icount) >
                                be64_to_cpu(ddq->d_ino_softlimit)) {
                        if (!ddq->d_itimer) {
                                if (flags & XFS_QMOPT_DOWARN)
@@ -2007,7 +2003,7 @@ xfs_qm_dqcheck(
                        }
                }
                if (ddq->d_rtb_softlimit &&
-                   be64_to_cpu(ddq->d_rtbcount) >=
+                   be64_to_cpu(ddq->d_rtbcount) >
                                be64_to_cpu(ddq->d_rtb_softlimit)) {
                        if (!ddq->d_rtbtimer) {
                                if (flags & XFS_QMOPT_DOWARN)
@@ -2133,10 +2129,11 @@ xlog_recover_buffer_pass2(
 
        bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len,
                          buf_flags);
-       error = xfs_buf_geterror(bp);
+       if (!bp)
+               return XFS_ERROR(ENOMEM);
+       error = bp->b_error;
        if (error) {
-               xfs_ioerror_alert("xlog_recover_do..(read#1)", mp,
-                                 bp, buf_f->blf_blkno);
+               xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#1)");
                xfs_buf_relse(bp);
                return error;
        }
@@ -2171,15 +2168,16 @@ xlog_recover_buffer_pass2(
            be16_to_cpu(*((__be16 *)xfs_buf_offset(bp, 0))) &&
            (XFS_BUF_COUNT(bp) != MAX(log->l_mp->m_sb.sb_blocksize,
                        (__uint32_t)XFS_INODE_CLUSTER_SIZE(log->l_mp)))) {
-               XFS_BUF_STALE(bp);
-               error = xfs_bwrite(mp, bp);
+               xfs_buf_stale(bp);
+               error = xfs_bwrite(bp);
        } else {
                ASSERT(bp->b_target->bt_mount == mp);
                bp->b_iodone = xlog_recover_iodone;
-               xfs_bdwrite(mp, bp);
+               xfs_buf_delwri_queue(bp);
        }
 
-       return (error);
+       xfs_buf_relse(bp);
+       return error;
 }
 
 STATIC int
@@ -2224,10 +2222,13 @@ xlog_recover_inode_pass2(
 
        bp = xfs_buf_read(mp->m_ddev_targp, in_f->ilf_blkno, in_f->ilf_len,
                          XBF_LOCK);
-       error = xfs_buf_geterror(bp);
+       if (!bp) {
+               error = ENOMEM;
+               goto error;
+       }
+       error = bp->b_error;
        if (error) {
-               xfs_ioerror_alert("xlog_recover_do..(read#2)", mp,
-                                 bp, in_f->ilf_blkno);
+               xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#2)");
                xfs_buf_relse(bp);
                goto error;
        }
@@ -2279,7 +2280,7 @@ xlog_recover_inode_pass2(
        /* Take the opportunity to reset the flush iteration count */
        dicp->di_flushiter = 0;
 
-       if (unlikely((dicp->di_mode & S_IFMT) == S_IFREG)) {
+       if (unlikely(S_ISREG(dicp->di_mode))) {
                if ((dicp->di_format != XFS_DINODE_FMT_EXTENTS) &&
                    (dicp->di_format != XFS_DINODE_FMT_BTREE)) {
                        XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(3)",
@@ -2292,7 +2293,7 @@ xlog_recover_inode_pass2(
                        error = EFSCORRUPTED;
                        goto error;
                }
-       } else if (unlikely((dicp->di_mode & S_IFMT) == S_IFDIR)) {
+       } else if (unlikely(S_ISDIR(dicp->di_mode))) {
                if ((dicp->di_format != XFS_DINODE_FMT_EXTENTS) &&
                    (dicp->di_format != XFS_DINODE_FMT_BTREE) &&
                    (dicp->di_format != XFS_DINODE_FMT_LOCAL)) {
@@ -2435,7 +2436,8 @@ xlog_recover_inode_pass2(
 write_inode_buffer:
        ASSERT(bp->b_target->bt_mount == mp);
        bp->b_iodone = xlog_recover_iodone;
-       xfs_bdwrite(mp, bp);
+       xfs_buf_delwri_queue(bp);
+       xfs_buf_relse(bp);
 error:
        if (need_free)
                kmem_free(in_f);
@@ -2533,8 +2535,7 @@ xlog_recover_dquot_pass2(
                             XFS_FSB_TO_BB(mp, dq_f->qlf_len),
                             0, &bp);
        if (error) {
-               xfs_ioerror_alert("xlog_recover_do..(read#3)", mp,
-                                 bp, dq_f->qlf_blkno);
+               xfs_buf_ioerror_alert(bp, "xlog_recover_do..(read#3)");
                return error;
        }
        ASSERT(bp);
@@ -2557,7 +2558,8 @@ xlog_recover_dquot_pass2(
        ASSERT(dq_f->qlf_size == 2);
        ASSERT(bp->b_target->bt_mount == mp);
        bp->b_iodone = xlog_recover_iodone;
-       xfs_bdwrite(mp, bp);
+       xfs_buf_delwri_queue(bp);
+       xfs_buf_relse(bp);
 
        return (0);
 }
@@ -3652,7 +3654,7 @@ xlog_do_recover(
                return error;
        }
 
-       XFS_bflush(log->l_mp->m_ddev_targp);
+       xfs_flush_buftarg(log->l_mp->m_ddev_targp, 1);
 
        /*
         * If IO errors happened during recovery, bail out.
@@ -3685,8 +3687,7 @@ xlog_do_recover(
        xfsbdstrat(log->l_mp, bp);
        error = xfs_buf_iowait(bp);
        if (error) {
-               xfs_ioerror_alert("xlog_do_recover",
-                                 log->l_mp, bp, XFS_BUF_ADDR(bp));
+               xfs_buf_ioerror_alert(bp, __func__);
                ASSERT(0);
                xfs_buf_relse(bp);
                return error;
@@ -3694,7 +3695,7 @@ xlog_do_recover(
 
        /* Convert superblock from on-disk format */
        sbp = &log->l_mp->m_sb;
-       xfs_sb_from_disk(sbp, XFS_BUF_TO_SBP(bp));
+       xfs_sb_from_disk(log->l_mp, XFS_BUF_TO_SBP(bp));
        ASSERT(sbp->sb_magicnum == XFS_SB_MAGIC);
        ASSERT(xfs_sb_good_version(sbp));
        xfs_buf_relse(bp);