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_rtalloc.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_rtalloc.c')
-rw-r--r-- | fs/xfs/xfs_rtalloc.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 909e143b87ae..1ad00937b485 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c | |||
@@ -972,16 +972,11 @@ xfs_growfs_rt( | |||
972 | /* | 972 | /* |
973 | * Read in the last block of the device, make sure it exists. | 973 | * Read in the last block of the device, make sure it exists. |
974 | */ | 974 | */ |
975 | bp = xfs_buf_read_uncached(mp->m_rtdev_targp, | 975 | error = xfs_buf_read_uncached(mp->m_rtdev_targp, |
976 | XFS_FSB_TO_BB(mp, nrblocks - 1), | 976 | XFS_FSB_TO_BB(mp, nrblocks - 1), |
977 | XFS_FSB_TO_BB(mp, 1), 0, NULL); | 977 | XFS_FSB_TO_BB(mp, 1), 0, &bp, NULL); |
978 | if (!bp) | 978 | if (error) |
979 | return -EIO; | ||
980 | if (bp->b_error) { | ||
981 | error = bp->b_error; | ||
982 | xfs_buf_relse(bp); | ||
983 | return error; | 979 | return error; |
984 | } | ||
985 | xfs_buf_relse(bp); | 980 | xfs_buf_relse(bp); |
986 | 981 | ||
987 | /* | 982 | /* |
@@ -1235,11 +1230,12 @@ xfs_rtallocate_extent( | |||
1235 | */ | 1230 | */ |
1236 | int /* error */ | 1231 | int /* error */ |
1237 | xfs_rtmount_init( | 1232 | xfs_rtmount_init( |
1238 | xfs_mount_t *mp) /* file system mount structure */ | 1233 | struct xfs_mount *mp) /* file system mount structure */ |
1239 | { | 1234 | { |
1240 | xfs_buf_t *bp; /* buffer for last block of subvolume */ | 1235 | struct xfs_buf *bp; /* buffer for last block of subvolume */ |
1241 | xfs_daddr_t d; /* address of last block of subvolume */ | 1236 | struct xfs_sb *sbp; /* filesystem superblock copy in mount */ |
1242 | xfs_sb_t *sbp; /* filesystem superblock copy in mount */ | 1237 | xfs_daddr_t d; /* address of last block of subvolume */ |
1238 | int error; | ||
1243 | 1239 | ||
1244 | sbp = &mp->m_sb; | 1240 | sbp = &mp->m_sb; |
1245 | if (sbp->sb_rblocks == 0) | 1241 | if (sbp->sb_rblocks == 0) |
@@ -1265,14 +1261,12 @@ xfs_rtmount_init( | |||
1265 | (unsigned long long) mp->m_sb.sb_rblocks); | 1261 | (unsigned long long) mp->m_sb.sb_rblocks); |
1266 | return -EFBIG; | 1262 | return -EFBIG; |
1267 | } | 1263 | } |
1268 | bp = xfs_buf_read_uncached(mp->m_rtdev_targp, | 1264 | error = xfs_buf_read_uncached(mp->m_rtdev_targp, |
1269 | d - XFS_FSB_TO_BB(mp, 1), | 1265 | d - XFS_FSB_TO_BB(mp, 1), |
1270 | XFS_FSB_TO_BB(mp, 1), 0, NULL); | 1266 | XFS_FSB_TO_BB(mp, 1), 0, &bp, NULL); |
1271 | if (!bp || bp->b_error) { | 1267 | if (error) { |
1272 | xfs_warn(mp, "realtime device size check failed"); | 1268 | xfs_warn(mp, "realtime device size check failed"); |
1273 | if (bp) | 1269 | return error; |
1274 | xfs_buf_relse(bp); | ||
1275 | return -EIO; | ||
1276 | } | 1270 | } |
1277 | xfs_buf_relse(bp); | 1271 | xfs_buf_relse(bp); |
1278 | return 0; | 1272 | return 0; |