Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[safe/jmp/linux-2.6] / fs / xfs / xfs_trans_buf.c
index c74c31e..218829e 100644 (file)
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
-#include "xfs_dir.h"
 #include "xfs_dir2.h"
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
 #include "xfs_bmap_btree.h"
 #include "xfs_alloc_btree.h"
 #include "xfs_ialloc_btree.h"
-#include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
 #include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
@@ -306,9 +304,10 @@ xfs_trans_read_buf(
        if (tp == NULL) {
                bp = xfs_buf_read_flags(target, blkno, len, flags | BUF_BUSY);
                if (!bp)
-                       return XFS_ERROR(ENOMEM);
+                       return (flags & XFS_BUF_TRYLOCK) ?
+                                       EAGAIN : XFS_ERROR(ENOMEM);
 
-               if ((bp != NULL) && (XFS_BUF_GETERROR(bp) != 0)) {
+               if (XFS_BUF_GETERROR(bp) != 0) {
                        xfs_ioerror_alert("xfs_trans_read_buf", mp,
                                          bp, blkno);
                        error = XFS_BUF_GETERROR(bp);
@@ -316,11 +315,11 @@ xfs_trans_read_buf(
                        return error;
                }
 #ifdef DEBUG
-               if (xfs_do_error && (bp != NULL)) {
+               if (xfs_do_error) {
                        if (xfs_error_target == target) {
                                if (((xfs_req_num++) % xfs_error_mod) == 0) {
                                        xfs_buf_relse(bp);
-                                       printk("Returning error!\n");
+                                       cmn_err(CE_DEBUG, "Returning error!\n");
                                        return XFS_ERROR(EIO);
                                }
                        }
@@ -355,21 +354,19 @@ xfs_trans_read_buf(
                        ASSERT(!XFS_BUF_ISASYNC(bp));
                        XFS_BUF_READ(bp);
                        xfsbdstrat(tp->t_mountp, bp);
-                       xfs_iowait(bp);
-                       if (XFS_BUF_GETERROR(bp) != 0) {
+                       error = xfs_iowait(bp);
+                       if (error) {
                                xfs_ioerror_alert("xfs_trans_read_buf", mp,
                                                  bp, blkno);
-                               error = XFS_BUF_GETERROR(bp);
                                xfs_buf_relse(bp);
                                /*
-                                * We can gracefully recover from most
-                                * read errors. Ones we can't are those
-                                * that happen after the transaction's
-                                * already dirty.
+                                * We can gracefully recover from most read
+                                * errors. Ones we can't are those that happen
+                                * after the transaction's already dirty.
                                 */
                                if (tp->t_flags & XFS_TRANS_DIRTY)
                                        xfs_force_shutdown(tp->t_mountp,
-                                                          XFS_METADATA_IO_ERROR);
+                                                       SHUTDOWN_META_IO_ERROR);
                                return error;
                        }
                }
@@ -414,7 +411,7 @@ xfs_trans_read_buf(
                xfs_ioerror_alert("xfs_trans_read_buf", mp,
                                  bp, blkno);
                if (tp->t_flags & XFS_TRANS_DIRTY)
-                       xfs_force_shutdown(tp->t_mountp, XFS_METADATA_IO_ERROR);
+                       xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR);
                xfs_buf_relse(bp);
                return error;
        }
@@ -423,9 +420,9 @@ xfs_trans_read_buf(
                if (xfs_error_target == target) {
                        if (((xfs_req_num++) % xfs_error_mod) == 0) {
                                xfs_force_shutdown(tp->t_mountp,
-                                                  XFS_METADATA_IO_ERROR);
+                                                  SHUTDOWN_META_IO_ERROR);
                                xfs_buf_relse(bp);
-                               printk("Returning error in trans!\n");
+                               cmn_err(CE_DEBUG, "Returning trans error!\n");
                                return XFS_ERROR(EIO);
                        }
                }
@@ -530,9 +527,8 @@ xfs_trans_brelse(xfs_trans_t        *tp,
                        lip = XFS_BUF_FSPRIVATE(bp, xfs_log_item_t *);
                        if (lip->li_type == XFS_LI_BUF) {
                                bip = XFS_BUF_FSPRIVATE(bp,xfs_buf_log_item_t*);
-                               xfs_trans_unlocked_item(
-                                               bip->bli_item.li_mountp,
-                                               lip);
+                               xfs_trans_unlocked_item(bip->bli_item.li_ailp,
+                                                       lip);
                        }
                }
                xfs_buf_relse(bp);
@@ -629,7 +625,7 @@ xfs_trans_brelse(xfs_trans_t        *tp,
         * tell the AIL that the buffer is being unlocked.
         */
        if (bip != NULL) {
-               xfs_trans_unlocked_item(bip->bli_item.li_mountp,
+               xfs_trans_unlocked_item(bip->bli_item.li_ailp,
                                        (xfs_log_item_t*)bip);
        }
 
@@ -1024,16 +1020,16 @@ xfs_trans_buf_item_match(
        bp = NULL;
        len = BBTOB(len);
        licp = &tp->t_items;
-       if (!XFS_LIC_ARE_ALL_FREE(licp)) {
+       if (!xfs_lic_are_all_free(licp)) {
                for (i = 0; i < licp->lic_unused; i++) {
                        /*
                         * Skip unoccupied slots.
                         */
-                       if (XFS_LIC_ISFREE(licp, i)) {
+                       if (xfs_lic_isfree(licp, i)) {
                                continue;
                        }
 
-                       lidp = XFS_LIC_SLOT(licp, i);
+                       lidp = xfs_lic_slot(licp, i);
                        blip = (xfs_buf_log_item_t *)lidp->lid_item;
                        if (blip->bli_item.li_type != XFS_LI_BUF) {
                                continue;
@@ -1077,7 +1073,7 @@ xfs_trans_buf_item_match_all(
        bp = NULL;
        len = BBTOB(len);
        for (licp = &tp->t_items; licp != NULL; licp = licp->lic_next) {
-               if (XFS_LIC_ARE_ALL_FREE(licp)) {
+               if (xfs_lic_are_all_free(licp)) {
                        ASSERT(licp == &tp->t_items);
                        ASSERT(licp->lic_next == NULL);
                        return NULL;
@@ -1086,11 +1082,11 @@ xfs_trans_buf_item_match_all(
                        /*
                         * Skip unoccupied slots.
                         */
-                       if (XFS_LIC_ISFREE(licp, i)) {
+                       if (xfs_lic_isfree(licp, i)) {
                                continue;
                        }
 
-                       lidp = XFS_LIC_SLOT(licp, i);
+                       lidp = xfs_lic_slot(licp, i);
                        blip = (xfs_buf_log_item_t *)lidp->lid_item;
                        if (blip->bli_item.li_type != XFS_LI_BUF) {
                                continue;