diff options
author | Dave Chinner <dchinner@redhat.com> | 2014-10-01 19:05:32 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-10-01 19:05:32 -0400 |
commit | ba3726742c1712c43c5a18245476f3fe9fe74773 (patch) | |
tree | 6d0d0b63f3785fff34b194a9bf4da785e9abeba6 /fs/xfs/xfs_buf.c | |
parent | 595bff75dce51e0d6d94877b4b6d11b4747a63fd (diff) |
xfs: check xfs_buf_read_uncached returns correctly
xfs_buf_read_uncached() has two failure modes. If can either return
NULL or bp->b_error != 0 depending on the type of failure, and not
all callers check for both. Fix it so that xfs_buf_read_uncached()
always returns the error status, and the buffer is returned as a
function parameter. The buffer will only be returned on success.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_buf.c')
-rw-r--r-- | fs/xfs/xfs_buf.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index d99ec8335750..6fbcbbfb4d1a 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c | |||
@@ -688,29 +688,39 @@ xfs_buf_readahead_map( | |||
688 | * Read an uncached buffer from disk. Allocates and returns a locked | 688 | * Read an uncached buffer from disk. Allocates and returns a locked |
689 | * buffer containing the disk contents or nothing. | 689 | * buffer containing the disk contents or nothing. |
690 | */ | 690 | */ |
691 | struct xfs_buf * | 691 | int |
692 | xfs_buf_read_uncached( | 692 | xfs_buf_read_uncached( |
693 | struct xfs_buftarg *target, | 693 | struct xfs_buftarg *target, |
694 | xfs_daddr_t daddr, | 694 | xfs_daddr_t daddr, |
695 | size_t numblks, | 695 | size_t numblks, |
696 | int flags, | 696 | int flags, |
697 | struct xfs_buf **bpp, | ||
697 | const struct xfs_buf_ops *ops) | 698 | const struct xfs_buf_ops *ops) |
698 | { | 699 | { |
699 | struct xfs_buf *bp; | 700 | struct xfs_buf *bp; |
700 | 701 | ||
702 | *bpp = NULL; | ||
703 | |||
701 | bp = xfs_buf_get_uncached(target, numblks, flags); | 704 | bp = xfs_buf_get_uncached(target, numblks, flags); |
702 | if (!bp) | 705 | if (!bp) |
703 | return NULL; | 706 | return -ENOMEM; |
704 | 707 | ||
705 | /* set up the buffer for a read IO */ | 708 | /* set up the buffer for a read IO */ |
706 | ASSERT(bp->b_map_count == 1); | 709 | ASSERT(bp->b_map_count == 1); |
707 | bp->b_bn = daddr; | 710 | bp->b_bn = XFS_BUF_DADDR_NULL; /* always null for uncached buffers */ |
708 | bp->b_maps[0].bm_bn = daddr; | 711 | bp->b_maps[0].bm_bn = daddr; |
709 | bp->b_flags |= XBF_READ; | 712 | bp->b_flags |= XBF_READ; |
710 | bp->b_ops = ops; | 713 | bp->b_ops = ops; |
711 | 714 | ||
712 | xfs_buf_submit_wait(bp); | 715 | xfs_buf_submit_wait(bp); |
713 | return bp; | 716 | if (bp->b_error) { |
717 | int error = bp->b_error; | ||
718 | xfs_buf_relse(bp); | ||
719 | return error; | ||
720 | } | ||
721 | |||
722 | *bpp = bp; | ||
723 | return 0; | ||
714 | } | 724 | } |
715 | 725 | ||
716 | /* | 726 | /* |