From: Christoph Hellwig Date: Tue, 20 Sep 2011 21:59:21 +0000 (+0000) Subject: libxfs: add b_error X-Git-Tag: v3.1.6~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a6a7776a86b2b58cb10c62f41d6cd2946ce01b26;p=thirdparty%2Fxfsprogs-dev.git libxfs: add b_error 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 Signed-off-by: Alex Elder --- diff --git a/include/libxfs.h b/include/libxfs.h index 91adef714..f92ef6fbe 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -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; diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c index 59cd82bb6..fe8ae0980 100644 --- a/libxfs/rdwr.c +++ b/libxfs/rdwr.c @@ -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; } diff --git a/libxfs/trans.c b/libxfs/trans.c index 86a6ac7fd..a745d5157 100644 --- a/libxfs/trans.c +++ b/libxfs/trans.c @@ -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; } /*