]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: add b_error
authorChristoph Hellwig <hch@infradead.org>
Tue, 20 Sep 2011 21:59:21 +0000 (21:59 +0000)
committerAlex Elder <aelder@sgi.com>
Wed, 21 Sep 2011 18:50:33 +0000 (13:50 -0500)
Add a b_error field to struct xfs_buf so that we can return the
exact error fro libxfs_readbuf.  And explicit error return would be
nice, but this requires large changes to common code that should be
done on the kernel side first.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Alex Elder <aelder@sgi.com>
include/libxfs.h
libxfs/rdwr.c
libxfs/trans.c

index 91adef714b5a1b436696bdc97ebe463848625c66..f92ef6fbea222214d8ecc33ba584e247da9a27a2 100644 (file)
@@ -230,6 +230,7 @@ typedef struct xfs_buf {
        void                    *b_fsprivate2;
        void                    *b_fsprivate3;
        char                    *b_addr;
+       int                     b_error;
 #ifdef XFS_BUF_TRACING
        struct list_head        b_lock_list;
        const char              *b_func;
index 59cd82bb6b09596ca430b41122935cae700f0c2d..fe8ae09801b6c7980a7b031344ad30f8c336b251 100644 (file)
@@ -314,6 +314,7 @@ libxfs_initbuf(xfs_buf_t *bp, dev_t device, xfs_daddr_t bno, unsigned int bytes)
        bp->b_blkno = bno;
        bp->b_bcount = bytes;
        bp->b_dev = device;
+       bp->b_error = 0;
        if (!bp->b_addr)
                bp->b_addr = memalign(libxfs_device_alignment(), bytes);
        if (!bp->b_addr) {
@@ -495,10 +496,8 @@ libxfs_readbuf(dev_t dev, xfs_daddr_t blkno, int len, int flags)
        bp = libxfs_getbuf(dev, blkno, len);
        if (bp && !(bp->b_flags & (LIBXFS_B_UPTODATE|LIBXFS_B_DIRTY))) {
                error = libxfs_readbufr(dev, blkno, bp, len, flags);
-               if (error) {
-                       libxfs_putbuf(bp);
-                       return NULL;
-               }
+               if (error)
+                       bp->b_error = error;
        }
        return bp;
 }
index 86a6ac7fdace127a9afd5dc656d7c9aee895f9e1..a745d515796dca142e522c069c918c5e9c9df1b0 100644 (file)
@@ -477,6 +477,7 @@ libxfs_trans_read_buf(
        xfs_buf_t               *bp;
        xfs_buf_log_item_t      *bip;
        xfs_buftarg_t           bdev;
+       int                     error;
 
        *bpp = NULL;
 
@@ -486,6 +487,8 @@ libxfs_trans_read_buf(
                        return (flags & XBF_TRYLOCK) ?
                                EAGAIN : XFS_ERROR(ENOMEM);
                }
+               if (bp->b_error)
+                       goto out_relse;
                goto done;
        }
 
@@ -504,6 +507,8 @@ libxfs_trans_read_buf(
                return (flags & XBF_TRYLOCK) ?
                        EAGAIN : XFS_ERROR(ENOMEM);
        }
+       if (bp->b_error)
+               goto out_relse;
 
 #ifdef XACT_DEBUG
        fprintf(stderr, "trans_read_buf buffer %p, transaction %p\n", bp, tp);
@@ -519,6 +524,10 @@ libxfs_trans_read_buf(
 done:
        *bpp = bp;
        return 0;
+out_relse:
+       error = bp->b_error;
+       xfs_buf_relse(bp);
+       return error;
 }
 
 /*