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 95fff68..218829e 100644 (file)
@@ -304,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);
@@ -314,7 +315,7 @@ 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);
@@ -353,17 +354,15 @@ 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,
@@ -528,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);
@@ -627,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);
        }
 
@@ -966,7 +964,6 @@ xfs_trans_inode_alloc_buf(
        ASSERT(atomic_read(&bip->bli_refcount) > 0);
 
        bip->bli_flags |= XFS_BLI_INODE_ALLOC_BUF;
-       bip->bli_format.blf_flags |= XFS_BLI_INODE_NEW_BUF;
 }
 
 
@@ -1023,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;
@@ -1076,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;
@@ -1085,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;