aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_rtalloc.c
diff options
context:
space:
mode:
authorDave Chinner <david@fromorbit.com>2008-11-27 22:23:34 -0500
committerNiv Sardi <xaiki@sgi.com>2008-11-30 19:11:36 -0500
commit0924b585fc49bf371bc700c23e516a538bf589af (patch)
tree9d53fce5e84c40804540e9ee0b98a96feb89e1cf /fs/xfs/xfs_rtalloc.c
parent2e6560929d8ab4b650fecc3a87013852b34f0922 (diff)
[XFS] fix uninitialised variable bug in dquot release.
gcc is warning about an uninitialised variable in xfs_growfs_rt(). This is a false positive. Fix it by changing the scope of the transaction pointer to wholly within the internal loop inside the function. While there, preemptively change xfs_growfs_rt_alloc() in the same way as it has exactly the same structure as xfs_growfs_rt() but gcc is not warning about it. Yet. Signed-off-by: Dave Chinner <david@fromorbit.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Niv Sardi <xaiki@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_rtalloc.c')
-rw-r--r--fs/xfs/xfs_rtalloc.c39
1 files changed, 18 insertions, 21 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index e2f68de16159..f18b9b281799 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -85,7 +85,6 @@ xfs_growfs_rt_alloc(
85{ 85{
86 xfs_fileoff_t bno; /* block number in file */ 86 xfs_fileoff_t bno; /* block number in file */
87 xfs_buf_t *bp; /* temporary buffer for zeroing */ 87 xfs_buf_t *bp; /* temporary buffer for zeroing */
88 int cancelflags; /* flags for xfs_trans_cancel */
89 int committed; /* transaction committed flag */ 88 int committed; /* transaction committed flag */
90 xfs_daddr_t d; /* disk block address */ 89 xfs_daddr_t d; /* disk block address */
91 int error; /* error return value */ 90 int error; /* error return value */
@@ -96,15 +95,16 @@ xfs_growfs_rt_alloc(
96 xfs_bmbt_irec_t map; /* block map output */ 95 xfs_bmbt_irec_t map; /* block map output */
97 int nmap; /* number of block maps */ 96 int nmap; /* number of block maps */
98 int resblks; /* space reservation */ 97 int resblks; /* space reservation */
99 xfs_trans_t *tp; /* transaction pointer */
100 98
101 /* 99 /*
102 * Allocate space to the file, as necessary. 100 * Allocate space to the file, as necessary.
103 */ 101 */
104 while (oblocks < nblocks) { 102 while (oblocks < nblocks) {
103 int cancelflags = 0;
104 xfs_trans_t *tp;
105
105 tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFSRT_ALLOC); 106 tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFSRT_ALLOC);
106 resblks = XFS_GROWFSRT_SPACE_RES(mp, nblocks - oblocks); 107 resblks = XFS_GROWFSRT_SPACE_RES(mp, nblocks - oblocks);
107 cancelflags = 0;
108 /* 108 /*
109 * Reserve space & log for one extent added to the file. 109 * Reserve space & log for one extent added to the file.
110 */ 110 */
@@ -171,7 +171,9 @@ xfs_growfs_rt_alloc(
171 mp->m_bsize, 0); 171 mp->m_bsize, 0);
172 if (bp == NULL) { 172 if (bp == NULL) {
173 error = XFS_ERROR(EIO); 173 error = XFS_ERROR(EIO);
174 goto error_cancel; 174error_cancel:
175 xfs_trans_cancel(tp, cancelflags);
176 goto error;
175 } 177 }
176 memset(XFS_BUF_PTR(bp), 0, mp->m_sb.sb_blocksize); 178 memset(XFS_BUF_PTR(bp), 0, mp->m_sb.sb_blocksize);
177 xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1); 179 xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1);
@@ -188,8 +190,6 @@ xfs_growfs_rt_alloc(
188 oblocks = map.br_startoff + map.br_blockcount; 190 oblocks = map.br_startoff + map.br_blockcount;
189 } 191 }
190 return 0; 192 return 0;
191error_cancel:
192 xfs_trans_cancel(tp, cancelflags);
193error: 193error:
194 return error; 194 return error;
195} 195}
@@ -1856,7 +1856,6 @@ xfs_growfs_rt(
1856{ 1856{
1857 xfs_rtblock_t bmbno; /* bitmap block number */ 1857 xfs_rtblock_t bmbno; /* bitmap block number */
1858 xfs_buf_t *bp; /* temporary buffer */ 1858 xfs_buf_t *bp; /* temporary buffer */
1859 int cancelflags; /* flags for xfs_trans_cancel */
1860 int error; /* error return value */ 1859 int error; /* error return value */
1861 xfs_inode_t *ip; /* bitmap inode, used as lock */ 1860 xfs_inode_t *ip; /* bitmap inode, used as lock */
1862 xfs_mount_t *nmp; /* new (fake) mount structure */ 1861 xfs_mount_t *nmp; /* new (fake) mount structure */
@@ -1872,10 +1871,8 @@ xfs_growfs_rt(
1872 xfs_extlen_t rsumblocks; /* current number of rt summary blks */ 1871 xfs_extlen_t rsumblocks; /* current number of rt summary blks */
1873 xfs_sb_t *sbp; /* old superblock */ 1872 xfs_sb_t *sbp; /* old superblock */
1874 xfs_fsblock_t sumbno; /* summary block number */ 1873 xfs_fsblock_t sumbno; /* summary block number */
1875 xfs_trans_t *tp; /* transaction pointer */
1876 1874
1877 sbp = &mp->m_sb; 1875 sbp = &mp->m_sb;
1878 cancelflags = 0;
1879 /* 1876 /*
1880 * Initial error checking. 1877 * Initial error checking.
1881 */ 1878 */
@@ -1942,6 +1939,9 @@ xfs_growfs_rt(
1942 ((sbp->sb_rextents & ((1 << mp->m_blkbit_log) - 1)) != 0); 1939 ((sbp->sb_rextents & ((1 << mp->m_blkbit_log) - 1)) != 0);
1943 bmbno < nrbmblocks; 1940 bmbno < nrbmblocks;
1944 bmbno++) { 1941 bmbno++) {
1942 xfs_trans_t *tp;
1943 int cancelflags = 0;
1944
1945 *nmp = *mp; 1945 *nmp = *mp;
1946 nsbp = &nmp->m_sb; 1946 nsbp = &nmp->m_sb;
1947 /* 1947 /*
@@ -1967,16 +1967,15 @@ xfs_growfs_rt(
1967 * Start a transaction, get the log reservation. 1967 * Start a transaction, get the log reservation.
1968 */ 1968 */
1969 tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFSRT_FREE); 1969 tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFSRT_FREE);
1970 cancelflags = 0;
1971 if ((error = xfs_trans_reserve(tp, 0, 1970 if ((error = xfs_trans_reserve(tp, 0,
1972 XFS_GROWRTFREE_LOG_RES(nmp), 0, 0, 0))) 1971 XFS_GROWRTFREE_LOG_RES(nmp), 0, 0, 0)))
1973 break; 1972 goto error_cancel;
1974 /* 1973 /*
1975 * Lock out other callers by grabbing the bitmap inode lock. 1974 * Lock out other callers by grabbing the bitmap inode lock.
1976 */ 1975 */
1977 if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, 1976 if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0,
1978 XFS_ILOCK_EXCL, &ip))) 1977 XFS_ILOCK_EXCL, &ip)))
1979 break; 1978 goto error_cancel;
1980 ASSERT(ip == mp->m_rbmip); 1979 ASSERT(ip == mp->m_rbmip);
1981 /* 1980 /*
1982 * Update the bitmap inode's size. 1981 * Update the bitmap inode's size.
@@ -1990,7 +1989,7 @@ xfs_growfs_rt(
1990 */ 1989 */
1991 if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, 1990 if ((error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0,
1992 XFS_ILOCK_EXCL, &ip))) 1991 XFS_ILOCK_EXCL, &ip)))
1993 break; 1992 goto error_cancel;
1994 ASSERT(ip == mp->m_rsumip); 1993 ASSERT(ip == mp->m_rsumip);
1995 /* 1994 /*
1996 * Update the summary inode's size. 1995 * Update the summary inode's size.
@@ -2005,7 +2004,7 @@ xfs_growfs_rt(
2005 mp->m_rsumlevels != nmp->m_rsumlevels) { 2004 mp->m_rsumlevels != nmp->m_rsumlevels) {
2006 error = xfs_rtcopy_summary(mp, nmp, tp); 2005 error = xfs_rtcopy_summary(mp, nmp, tp);
2007 if (error) 2006 if (error)
2008 break; 2007 goto error_cancel;
2009 } 2008 }
2010 /* 2009 /*
2011 * Update superblock fields. 2010 * Update superblock fields.
@@ -2031,8 +2030,11 @@ xfs_growfs_rt(
2031 bp = NULL; 2030 bp = NULL;
2032 error = xfs_rtfree_range(nmp, tp, sbp->sb_rextents, 2031 error = xfs_rtfree_range(nmp, tp, sbp->sb_rextents,
2033 nsbp->sb_rextents - sbp->sb_rextents, &bp, &sumbno); 2032 nsbp->sb_rextents - sbp->sb_rextents, &bp, &sumbno);
2034 if (error) 2033 if (error) {
2034error_cancel:
2035 xfs_trans_cancel(tp, cancelflags);
2035 break; 2036 break;
2037 }
2036 /* 2038 /*
2037 * Mark more blocks free in the superblock. 2039 * Mark more blocks free in the superblock.
2038 */ 2040 */
@@ -2045,15 +2047,10 @@ xfs_growfs_rt(
2045 mp->m_rsumsize = nrsumsize; 2047 mp->m_rsumsize = nrsumsize;
2046 2048
2047 error = xfs_trans_commit(tp, 0); 2049 error = xfs_trans_commit(tp, 0);
2048 if (error) { 2050 if (error)
2049 tp = NULL;
2050 break; 2051 break;
2051 }
2052 } 2052 }
2053 2053
2054 if (error && tp)
2055 xfs_trans_cancel(tp, cancelflags);
2056
2057 /* 2054 /*
2058 * Free the fake mp structure. 2055 * Free the fake mp structure.
2059 */ 2056 */