aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_rtalloc.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2006-09-27 21:03:44 -0400
committerTim Shimmin <tes@sgi.com>2006-09-27 21:03:44 -0400
commitd432c80e68e3c283fc9a85021f5b65e0aabf254e (patch)
tree95bd72316cc4992d6dc1392f24a8d6786f15d221 /fs/xfs/xfs_rtalloc.c
parentb627259c602f3f1b995d09aad2b57bed889430b9 (diff)
[XFS] Minor code rearranging and cleanup to prevent some coverity false
positives. SGI-PV: 955502 SGI-Modid: xfs-linux-melb:xfs-kern:26805a Signed-off-by: Nathan Scott <nathans@sgi.com> Signed-off-by: Tim Shimmin <tes@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_rtalloc.c')
-rw-r--r--fs/xfs/xfs_rtalloc.c36
1 files changed, 15 insertions, 21 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 5a0b678956e0..e050987afe18 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -1976,7 +1976,10 @@ xfs_growfs_rt(
1976 if ((error = xfs_growfs_rt_alloc(mp, rsumblocks, nrsumblocks, 1976 if ((error = xfs_growfs_rt_alloc(mp, rsumblocks, nrsumblocks,
1977 mp->m_sb.sb_rsumino))) 1977 mp->m_sb.sb_rsumino)))
1978 return error; 1978 return error;
1979 nmp = NULL; 1979 /*
1980 * Allocate a new (fake) mount/sb.
1981 */
1982 nmp = kmem_alloc(sizeof(*nmp), KM_SLEEP);
1980 /* 1983 /*
1981 * Loop over the bitmap blocks. 1984 * Loop over the bitmap blocks.
1982 * We will do everything one bitmap block at a time. 1985 * We will do everything one bitmap block at a time.
@@ -1987,10 +1990,6 @@ xfs_growfs_rt(
1987 ((sbp->sb_rextents & ((1 << mp->m_blkbit_log) - 1)) != 0); 1990 ((sbp->sb_rextents & ((1 << mp->m_blkbit_log) - 1)) != 0);
1988 bmbno < nrbmblocks; 1991 bmbno < nrbmblocks;
1989 bmbno++) { 1992 bmbno++) {
1990 /*
1991 * Allocate a new (fake) mount/sb.
1992 */
1993 nmp = kmem_alloc(sizeof(*nmp), KM_SLEEP);
1994 *nmp = *mp; 1993 *nmp = *mp;
1995 nsbp = &nmp->m_sb; 1994 nsbp = &nmp->m_sb;
1996 /* 1995 /*
@@ -2018,13 +2017,13 @@ xfs_growfs_rt(
2018 cancelflags = 0; 2017 cancelflags = 0;
2019 if ((error = xfs_trans_reserve(tp, 0, 2018 if ((error = xfs_trans_reserve(tp, 0,
2020 XFS_GROWRTFREE_LOG_RES(nmp), 0, 0, 0))) 2019 XFS_GROWRTFREE_LOG_RES(nmp), 0, 0, 0)))
2021 goto error_exit; 2020 break;
2022 /* 2021 /*
2023 * Lock out other callers by grabbing the bitmap inode lock. 2022 * Lock out other callers by grabbing the bitmap inode lock.
2024 */ 2023 */
2025 if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, 2024 if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0,
2026 XFS_ILOCK_EXCL, &ip))) 2025 XFS_ILOCK_EXCL, &ip)))
2027 goto error_exit; 2026 break;
2028 ASSERT(ip == mp->m_rbmip); 2027 ASSERT(ip == mp->m_rbmip);
2029 /* 2028 /*
2030 * Update the bitmap inode's size. 2029 * Update the bitmap inode's size.
@@ -2038,7 +2037,7 @@ xfs_growfs_rt(
2038 */ 2037 */
2039 if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, 2038 if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0,
2040 XFS_ILOCK_EXCL, &ip))) 2039 XFS_ILOCK_EXCL, &ip)))
2041 goto error_exit; 2040 break;
2042 ASSERT(ip == mp->m_rsumip); 2041 ASSERT(ip == mp->m_rsumip);
2043 /* 2042 /*
2044 * Update the summary inode's size. 2043 * Update the summary inode's size.
@@ -2053,7 +2052,7 @@ xfs_growfs_rt(
2053 mp->m_rsumlevels != nmp->m_rsumlevels) { 2052 mp->m_rsumlevels != nmp->m_rsumlevels) {
2054 error = xfs_rtcopy_summary(mp, nmp, tp); 2053 error = xfs_rtcopy_summary(mp, nmp, tp);
2055 if (error) 2054 if (error)
2056 goto error_exit; 2055 break;
2057 } 2056 }
2058 /* 2057 /*
2059 * Update superblock fields. 2058 * Update superblock fields.
@@ -2080,18 +2079,13 @@ xfs_growfs_rt(
2080 error = xfs_rtfree_range(nmp, tp, sbp->sb_rextents, 2079 error = xfs_rtfree_range(nmp, tp, sbp->sb_rextents,
2081 nsbp->sb_rextents - sbp->sb_rextents, &bp, &sumbno); 2080 nsbp->sb_rextents - sbp->sb_rextents, &bp, &sumbno);
2082 if (error) 2081 if (error)
2083 goto error_exit; 2082 break;
2084 /* 2083 /*
2085 * Mark more blocks free in the superblock. 2084 * Mark more blocks free in the superblock.
2086 */ 2085 */
2087 xfs_trans_mod_sb(tp, XFS_TRANS_SB_FREXTENTS, 2086 xfs_trans_mod_sb(tp, XFS_TRANS_SB_FREXTENTS,
2088 nsbp->sb_rextents - sbp->sb_rextents); 2087 nsbp->sb_rextents - sbp->sb_rextents);
2089 /* 2088 /*
2090 * Free the fake mp structure.
2091 */
2092 kmem_free(nmp, sizeof(*nmp));
2093 nmp = NULL;
2094 /*
2095 * Update mp values into the real mp structure. 2089 * Update mp values into the real mp structure.
2096 */ 2090 */
2097 mp->m_rsumlevels = nrsumlevels; 2091 mp->m_rsumlevels = nrsumlevels;
@@ -2101,15 +2095,15 @@ xfs_growfs_rt(
2101 */ 2095 */
2102 xfs_trans_commit(tp, 0, NULL); 2096 xfs_trans_commit(tp, 0, NULL);
2103 } 2097 }
2104 return 0; 2098
2099 if (error)
2100 xfs_trans_cancel(tp, cancelflags);
2105 2101
2106 /* 2102 /*
2107 * Error paths come here. 2103 * Free the fake mp structure.
2108 */ 2104 */
2109error_exit: 2105 kmem_free(nmp, sizeof(*nmp));
2110 if (nmp) 2106
2111 kmem_free(nmp, sizeof(*nmp));
2112 xfs_trans_cancel(tp, cancelflags);
2113 return error; 2107 return error;
2114} 2108}
2115 2109