aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_rtalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_rtalloc.c')
-rw-r--r--fs/xfs/xfs_rtalloc.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 9cd6471cd60f..a0dc6e5bc5b9 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -124,14 +124,14 @@ xfs_growfs_rt_alloc(
124 XFS_GROWRTALLOC_LOG_RES(mp), 0, 124 XFS_GROWRTALLOC_LOG_RES(mp), 0,
125 XFS_TRANS_PERM_LOG_RES, 125 XFS_TRANS_PERM_LOG_RES,
126 XFS_DEFAULT_PERM_LOG_COUNT))) 126 XFS_DEFAULT_PERM_LOG_COUNT)))
127 goto error_exit; 127 goto error_cancel;
128 cancelflags = XFS_TRANS_RELEASE_LOG_RES; 128 cancelflags = XFS_TRANS_RELEASE_LOG_RES;
129 /* 129 /*
130 * Lock the inode. 130 * Lock the inode.
131 */ 131 */
132 if ((error = xfs_trans_iget(mp, tp, ino, 0, 132 if ((error = xfs_trans_iget(mp, tp, ino, 0,
133 XFS_ILOCK_EXCL, &ip))) 133 XFS_ILOCK_EXCL, &ip)))
134 goto error_exit; 134 goto error_cancel;
135 XFS_BMAP_INIT(&flist, &firstblock); 135 XFS_BMAP_INIT(&flist, &firstblock);
136 /* 136 /*
137 * Allocate blocks to the bitmap file. 137 * Allocate blocks to the bitmap file.
@@ -144,14 +144,16 @@ xfs_growfs_rt_alloc(
144 if (!error && nmap < 1) 144 if (!error && nmap < 1)
145 error = XFS_ERROR(ENOSPC); 145 error = XFS_ERROR(ENOSPC);
146 if (error) 146 if (error)
147 goto error_exit; 147 goto error_cancel;
148 /* 148 /*
149 * Free any blocks freed up in the transaction, then commit. 149 * Free any blocks freed up in the transaction, then commit.
150 */ 150 */
151 error = xfs_bmap_finish(&tp, &flist, &committed); 151 error = xfs_bmap_finish(&tp, &flist, &committed);
152 if (error) 152 if (error)
153 goto error_exit; 153 goto error_cancel;
154 xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES); 154 error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES);
155 if (error)
156 goto error;
155 /* 157 /*
156 * Now we need to clear the allocated blocks. 158 * Now we need to clear the allocated blocks.
157 * Do this one block per transaction, to keep it simple. 159 * Do this one block per transaction, to keep it simple.
@@ -166,13 +168,13 @@ xfs_growfs_rt_alloc(
166 */ 168 */
167 if ((error = xfs_trans_reserve(tp, 0, 169 if ((error = xfs_trans_reserve(tp, 0,
168 XFS_GROWRTZERO_LOG_RES(mp), 0, 0, 0))) 170 XFS_GROWRTZERO_LOG_RES(mp), 0, 0, 0)))
169 goto error_exit; 171 goto error_cancel;
170 /* 172 /*
171 * Lock the bitmap inode. 173 * Lock the bitmap inode.
172 */ 174 */
173 if ((error = xfs_trans_iget(mp, tp, ino, 0, 175 if ((error = xfs_trans_iget(mp, tp, ino, 0,
174 XFS_ILOCK_EXCL, &ip))) 176 XFS_ILOCK_EXCL, &ip)))
175 goto error_exit; 177 goto error_cancel;
176 /* 178 /*
177 * Get a buffer for the block. 179 * Get a buffer for the block.
178 */ 180 */
@@ -181,14 +183,16 @@ xfs_growfs_rt_alloc(
181 mp->m_bsize, 0); 183 mp->m_bsize, 0);
182 if (bp == NULL) { 184 if (bp == NULL) {
183 error = XFS_ERROR(EIO); 185 error = XFS_ERROR(EIO);
184 goto error_exit; 186 goto error_cancel;
185 } 187 }
186 memset(XFS_BUF_PTR(bp), 0, mp->m_sb.sb_blocksize); 188 memset(XFS_BUF_PTR(bp), 0, mp->m_sb.sb_blocksize);
187 xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1); 189 xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1);
188 /* 190 /*
189 * Commit the transaction. 191 * Commit the transaction.
190 */ 192 */
191 xfs_trans_commit(tp, 0); 193 error = xfs_trans_commit(tp, 0);
194 if (error)
195 goto error;
192 } 196 }
193 /* 197 /*
194 * Go on to the next extent, if any. 198 * Go on to the next extent, if any.
@@ -196,8 +200,9 @@ xfs_growfs_rt_alloc(
196 oblocks = map.br_startoff + map.br_blockcount; 200 oblocks = map.br_startoff + map.br_blockcount;
197 } 201 }
198 return 0; 202 return 0;
199error_exit: 203error_cancel:
200 xfs_trans_cancel(tp, cancelflags); 204 xfs_trans_cancel(tp, cancelflags);
205error:
201 return error; 206 return error;
202} 207}
203 208
@@ -1876,6 +1881,7 @@ xfs_growfs_rt(
1876 xfs_trans_t *tp; /* transaction pointer */ 1881 xfs_trans_t *tp; /* transaction pointer */
1877 1882
1878 sbp = &mp->m_sb; 1883 sbp = &mp->m_sb;
1884 cancelflags = 0;
1879 /* 1885 /*
1880 * Initial error checking. 1886 * Initial error checking.
1881 */ 1887 */
@@ -2042,13 +2048,15 @@ xfs_growfs_rt(
2042 */ 2048 */
2043 mp->m_rsumlevels = nrsumlevels; 2049 mp->m_rsumlevels = nrsumlevels;
2044 mp->m_rsumsize = nrsumsize; 2050 mp->m_rsumsize = nrsumsize;
2045 /* 2051
2046 * Commit the transaction. 2052 error = xfs_trans_commit(tp, 0);
2047 */ 2053 if (error) {
2048 xfs_trans_commit(tp, 0); 2054 tp = NULL;
2055 break;
2056 }
2049 } 2057 }
2050 2058
2051 if (error) 2059 if (error && tp)
2052 xfs_trans_cancel(tp, cancelflags); 2060 xfs_trans_cancel(tp, cancelflags);
2053 2061
2054 /* 2062 /*