]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/xfs/xfs_log_recover.c
[XFS] cleanup xfs_mountfs
[linux-2.6-omap-h63xx.git] / fs / xfs / xfs_log_recover.c
index 418582b709ebcdfcb99f35f84aeec037854842bb..82d46ce69d5f1e49b73f1842f92e06731af599fb 100644 (file)
@@ -121,7 +121,8 @@ xlog_bread(
        XFS_BUF_SET_TARGET(bp, log->l_mp->m_logdev_targp);
 
        xfsbdstrat(log->l_mp, bp);
-       if ((error = xfs_iowait(bp)))
+       error = xfs_iowait(bp);
+       if (error)
                xfs_ioerror_alert("xlog_bread", log->l_mp,
                                  bp, XFS_BUF_ADDR(bp));
        return error;
@@ -1161,10 +1162,14 @@ xlog_write_log_records(
                if (j == 0 && (start_block + endcount > ealign)) {
                        offset = XFS_BUF_PTR(bp);
                        balign = BBTOB(ealign - start_block);
-                       XFS_BUF_SET_PTR(bp, offset + balign, BBTOB(sectbb));
-                       if ((error = xlog_bread(log, ealign, sectbb, bp)))
+                       error = XFS_BUF_SET_PTR(bp, offset + balign,
+                                               BBTOB(sectbb));
+                       if (!error)
+                               error = xlog_bread(log, ealign, sectbb, bp);
+                       if (!error)
+                               error = XFS_BUF_SET_PTR(bp, offset, bufblks);
+                       if (error)
                                break;
-                       XFS_BUF_SET_PTR(bp, offset, bufblks);
                }
 
                offset = xlog_align(log, start_block, endcount, bp);
@@ -1710,8 +1715,7 @@ xlog_check_buffer_cancelled(
                                        } else {
                                                prevp->bc_next = bcp->bc_next;
                                        }
-                                       kmem_free(bcp,
-                                                 sizeof(xfs_buf_cancel_t));
+                                       kmem_free(bcp);
                                }
                        }
                        return 1;
@@ -2281,7 +2285,9 @@ xlog_recover_do_inode_trans(
                 * invalidate the buffer when we write it out below.
                 */
                imap.im_blkno = 0;
-               xfs_imap(log->l_mp, NULL, ino, &imap, 0);
+               error = xfs_imap(log->l_mp, NULL, ino, &imap, 0);
+               if (error)
+                       goto error;
        }
 
        /*
@@ -2512,7 +2518,7 @@ write_inode_buffer:
 
 error:
        if (need_free)
-               kmem_free(in_f, sizeof(*in_f));
+               kmem_free(in_f);
        return XFS_ERROR(error);
 }
 
@@ -2823,16 +2829,14 @@ xlog_recover_free_trans(
                item = item->ri_next;
                 /* Free the regions in the item. */
                for (i = 0; i < free_item->ri_cnt; i++) {
-                       kmem_free(free_item->ri_buf[i].i_addr,
-                                 free_item->ri_buf[i].i_len);
+                       kmem_free(free_item->ri_buf[i].i_addr);
                }
                /* Free the item itself */
-               kmem_free(free_item->ri_buf,
-                         (free_item->ri_total * sizeof(xfs_log_iovec_t)));
-               kmem_free(free_item, sizeof(xlog_recover_item_t));
+               kmem_free(free_item->ri_buf);
+               kmem_free(free_item);
        } while (first_item != item);
        /* Free the transaction recover structure */
-       kmem_free(trans, sizeof(xlog_recover_t));
+       kmem_free(trans);
 }
 
 STATIC int
@@ -3003,15 +3007,15 @@ xlog_recover_process_efi(
 
        tp = xfs_trans_alloc(mp, 0);
        error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0, 0, 0);
-       if (error) {
-               xfs_trans_cancel(tp, XFS_TRANS_ABORT);
-               return error;
-       }
+       if (error)
+               goto abort_error;
        efdp = xfs_trans_get_efd(tp, efip, efip->efi_format.efi_nextents);
 
        for (i = 0; i < efip->efi_format.efi_nextents; i++) {
                extp = &(efip->efi_format.efi_extents[i]);
-               xfs_free_extent(tp, extp->ext_start, extp->ext_len);
+               error = xfs_free_extent(tp, extp->ext_start, extp->ext_len);
+               if (error)
+                       goto abort_error;
                xfs_trans_log_efd_extent(tp, efdp, extp->ext_start,
                                         extp->ext_len);
        }
@@ -3019,6 +3023,10 @@ xlog_recover_process_efi(
        efip->efi_flags |= XFS_EFI_RECOVERED;
        error = xfs_trans_commit(tp, 0);
        return error;
+
+abort_error:
+       xfs_trans_cancel(tp, XFS_TRANS_ABORT);
+       return error;
 }
 
 /*
@@ -3623,15 +3631,19 @@ xlog_do_recovery_pass(
                                 *   _first_, then the log start (LR header end)
                                 *   - order is important.
                                 */
+                               wrapped_hblks = hblks - split_hblks;
                                bufaddr = XFS_BUF_PTR(hbp);
-                               XFS_BUF_SET_PTR(hbp,
+                               error = XFS_BUF_SET_PTR(hbp,
                                                bufaddr + BBTOB(split_hblks),
                                                BBTOB(hblks - split_hblks));
-                               wrapped_hblks = hblks - split_hblks;
-                               error = xlog_bread(log, 0, wrapped_hblks, hbp);
+                               if (!error)
+                                       error = xlog_bread(log, 0,
+                                                       wrapped_hblks, hbp);
+                               if (!error)
+                                       error = XFS_BUF_SET_PTR(hbp, bufaddr,
+                                                       BBTOB(hblks));
                                if (error)
                                        goto bread_err2;
-                               XFS_BUF_SET_PTR(hbp, bufaddr, BBTOB(hblks));
                                if (!offset)
                                        offset = xlog_align(log, 0,
                                                        wrapped_hblks, hbp);
@@ -3683,13 +3695,18 @@ xlog_do_recovery_pass(
                                 *   - order is important.
                                 */
                                bufaddr = XFS_BUF_PTR(dbp);
-                               XFS_BUF_SET_PTR(dbp,
+                               error = XFS_BUF_SET_PTR(dbp,
                                                bufaddr + BBTOB(split_bblks),
                                                BBTOB(bblks - split_bblks));
-                               if ((error = xlog_bread(log, wrapped_hblks,
-                                               bblks - split_bblks, dbp)))
+                               if (!error)
+                                       error = xlog_bread(log, wrapped_hblks,
+                                                       bblks - split_bblks,
+                                                       dbp);
+                               if (!error)
+                                       error = XFS_BUF_SET_PTR(dbp, bufaddr,
+                                                       h_size);
+                               if (error)
                                        goto bread_err2;
-                               XFS_BUF_SET_PTR(dbp, bufaddr, h_size);
                                if (!offset)
                                        offset = xlog_align(log, wrapped_hblks,
                                                bblks - split_bblks, dbp);
@@ -3766,8 +3783,7 @@ xlog_do_log_recovery(
        error = xlog_do_recovery_pass(log, head_blk, tail_blk,
                                      XLOG_RECOVER_PASS1);
        if (error != 0) {
-               kmem_free(log->l_buf_cancel_table,
-                         XLOG_BC_TABLE_SIZE * sizeof(xfs_buf_cancel_t*));
+               kmem_free(log->l_buf_cancel_table);
                log->l_buf_cancel_table = NULL;
                return error;
        }
@@ -3786,8 +3802,7 @@ xlog_do_log_recovery(
        }
 #endif /* DEBUG */
 
-       kmem_free(log->l_buf_cancel_table,
-                 XLOG_BC_TABLE_SIZE * sizeof(xfs_buf_cancel_t*));
+       kmem_free(log->l_buf_cancel_table);
        log->l_buf_cancel_table = NULL;
 
        return error;
@@ -3845,7 +3860,8 @@ xlog_do_recover(
        XFS_BUF_READ(bp);
        XFS_BUF_UNASYNC(bp);
        xfsbdstrat(log->l_mp, bp);
-       if ((error = xfs_iowait(bp))) {
+       error = xfs_iowait(bp);
+       if (error) {
                xfs_ioerror_alert("xlog_do_recover",
                                  log->l_mp, bp, XFS_BUF_ADDR(bp));
                ASSERT(0);
@@ -3924,8 +3940,7 @@ xlog_recover(
  */
 int
 xlog_recover_finish(
-       xlog_t          *log,
-       int             mfsi_flags)
+       xlog_t          *log)
 {
        /*
         * Now we're ready to do the transactions needed for the
@@ -3953,9 +3968,7 @@ xlog_recover_finish(
                xfs_log_force(log->l_mp, (xfs_lsn_t)0,
                              (XFS_LOG_FORCE | XFS_LOG_SYNC));
 
-               if ( (mfsi_flags & XFS_MFSI_NOUNLINK) == 0 ) {
-                       xlog_recover_process_iunlinks(log);
-               }
+               xlog_recover_process_iunlinks(log);
 
                xlog_recover_check_summary(log);