diff options
Diffstat (limited to 'fs/xfs/xfs_rtalloc.c')
-rw-r--r-- | fs/xfs/xfs_rtalloc.c | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index 47082c01872d..a0dc6e5bc5b9 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include "xfs_rw.h" | 44 | #include "xfs_rw.h" |
45 | #include "xfs_inode_item.h" | 45 | #include "xfs_inode_item.h" |
46 | #include "xfs_trans_space.h" | 46 | #include "xfs_trans_space.h" |
47 | #include "xfs_utils.h" | ||
47 | 48 | ||
48 | 49 | ||
49 | /* | 50 | /* |
@@ -123,14 +124,14 @@ xfs_growfs_rt_alloc( | |||
123 | XFS_GROWRTALLOC_LOG_RES(mp), 0, | 124 | XFS_GROWRTALLOC_LOG_RES(mp), 0, |
124 | XFS_TRANS_PERM_LOG_RES, | 125 | XFS_TRANS_PERM_LOG_RES, |
125 | XFS_DEFAULT_PERM_LOG_COUNT))) | 126 | XFS_DEFAULT_PERM_LOG_COUNT))) |
126 | goto error_exit; | 127 | goto error_cancel; |
127 | cancelflags = XFS_TRANS_RELEASE_LOG_RES; | 128 | cancelflags = XFS_TRANS_RELEASE_LOG_RES; |
128 | /* | 129 | /* |
129 | * Lock the inode. | 130 | * Lock the inode. |
130 | */ | 131 | */ |
131 | if ((error = xfs_trans_iget(mp, tp, ino, 0, | 132 | if ((error = xfs_trans_iget(mp, tp, ino, 0, |
132 | XFS_ILOCK_EXCL, &ip))) | 133 | XFS_ILOCK_EXCL, &ip))) |
133 | goto error_exit; | 134 | goto error_cancel; |
134 | XFS_BMAP_INIT(&flist, &firstblock); | 135 | XFS_BMAP_INIT(&flist, &firstblock); |
135 | /* | 136 | /* |
136 | * Allocate blocks to the bitmap file. | 137 | * Allocate blocks to the bitmap file. |
@@ -143,14 +144,16 @@ xfs_growfs_rt_alloc( | |||
143 | if (!error && nmap < 1) | 144 | if (!error && nmap < 1) |
144 | error = XFS_ERROR(ENOSPC); | 145 | error = XFS_ERROR(ENOSPC); |
145 | if (error) | 146 | if (error) |
146 | goto error_exit; | 147 | goto error_cancel; |
147 | /* | 148 | /* |
148 | * Free any blocks freed up in the transaction, then commit. | 149 | * Free any blocks freed up in the transaction, then commit. |
149 | */ | 150 | */ |
150 | error = xfs_bmap_finish(&tp, &flist, &committed); | 151 | error = xfs_bmap_finish(&tp, &flist, &committed); |
151 | if (error) | 152 | if (error) |
152 | goto error_exit; | 153 | goto error_cancel; |
153 | 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; | ||
154 | /* | 157 | /* |
155 | * Now we need to clear the allocated blocks. | 158 | * Now we need to clear the allocated blocks. |
156 | * Do this one block per transaction, to keep it simple. | 159 | * Do this one block per transaction, to keep it simple. |
@@ -165,13 +168,13 @@ xfs_growfs_rt_alloc( | |||
165 | */ | 168 | */ |
166 | if ((error = xfs_trans_reserve(tp, 0, | 169 | if ((error = xfs_trans_reserve(tp, 0, |
167 | XFS_GROWRTZERO_LOG_RES(mp), 0, 0, 0))) | 170 | XFS_GROWRTZERO_LOG_RES(mp), 0, 0, 0))) |
168 | goto error_exit; | 171 | goto error_cancel; |
169 | /* | 172 | /* |
170 | * Lock the bitmap inode. | 173 | * Lock the bitmap inode. |
171 | */ | 174 | */ |
172 | if ((error = xfs_trans_iget(mp, tp, ino, 0, | 175 | if ((error = xfs_trans_iget(mp, tp, ino, 0, |
173 | XFS_ILOCK_EXCL, &ip))) | 176 | XFS_ILOCK_EXCL, &ip))) |
174 | goto error_exit; | 177 | goto error_cancel; |
175 | /* | 178 | /* |
176 | * Get a buffer for the block. | 179 | * Get a buffer for the block. |
177 | */ | 180 | */ |
@@ -180,14 +183,16 @@ xfs_growfs_rt_alloc( | |||
180 | mp->m_bsize, 0); | 183 | mp->m_bsize, 0); |
181 | if (bp == NULL) { | 184 | if (bp == NULL) { |
182 | error = XFS_ERROR(EIO); | 185 | error = XFS_ERROR(EIO); |
183 | goto error_exit; | 186 | goto error_cancel; |
184 | } | 187 | } |
185 | memset(XFS_BUF_PTR(bp), 0, mp->m_sb.sb_blocksize); | 188 | memset(XFS_BUF_PTR(bp), 0, mp->m_sb.sb_blocksize); |
186 | 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); |
187 | /* | 190 | /* |
188 | * Commit the transaction. | 191 | * Commit the transaction. |
189 | */ | 192 | */ |
190 | xfs_trans_commit(tp, 0); | 193 | error = xfs_trans_commit(tp, 0); |
194 | if (error) | ||
195 | goto error; | ||
191 | } | 196 | } |
192 | /* | 197 | /* |
193 | * Go on to the next extent, if any. | 198 | * Go on to the next extent, if any. |
@@ -195,8 +200,9 @@ xfs_growfs_rt_alloc( | |||
195 | oblocks = map.br_startoff + map.br_blockcount; | 200 | oblocks = map.br_startoff + map.br_blockcount; |
196 | } | 201 | } |
197 | return 0; | 202 | return 0; |
198 | error_exit: | 203 | error_cancel: |
199 | xfs_trans_cancel(tp, cancelflags); | 204 | xfs_trans_cancel(tp, cancelflags); |
205 | error: | ||
200 | return error; | 206 | return error; |
201 | } | 207 | } |
202 | 208 | ||
@@ -1875,6 +1881,7 @@ xfs_growfs_rt( | |||
1875 | xfs_trans_t *tp; /* transaction pointer */ | 1881 | xfs_trans_t *tp; /* transaction pointer */ |
1876 | 1882 | ||
1877 | sbp = &mp->m_sb; | 1883 | sbp = &mp->m_sb; |
1884 | cancelflags = 0; | ||
1878 | /* | 1885 | /* |
1879 | * Initial error checking. | 1886 | * Initial error checking. |
1880 | */ | 1887 | */ |
@@ -2041,13 +2048,15 @@ xfs_growfs_rt( | |||
2041 | */ | 2048 | */ |
2042 | mp->m_rsumlevels = nrsumlevels; | 2049 | mp->m_rsumlevels = nrsumlevels; |
2043 | mp->m_rsumsize = nrsumsize; | 2050 | mp->m_rsumsize = nrsumsize; |
2044 | /* | 2051 | |
2045 | * Commit the transaction. | 2052 | error = xfs_trans_commit(tp, 0); |
2046 | */ | 2053 | if (error) { |
2047 | xfs_trans_commit(tp, 0); | 2054 | tp = NULL; |
2055 | break; | ||
2056 | } | ||
2048 | } | 2057 | } |
2049 | 2058 | ||
2050 | if (error) | 2059 | if (error && tp) |
2051 | xfs_trans_cancel(tp, cancelflags); | 2060 | xfs_trans_cancel(tp, cancelflags); |
2052 | 2061 | ||
2053 | /* | 2062 | /* |
@@ -2278,7 +2287,7 @@ xfs_rtmount_inodes( | |||
2278 | ASSERT(sbp->sb_rsumino != NULLFSINO); | 2287 | ASSERT(sbp->sb_rsumino != NULLFSINO); |
2279 | error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip, 0); | 2288 | error = xfs_iget(mp, NULL, sbp->sb_rsumino, 0, 0, &mp->m_rsumip, 0); |
2280 | if (error) { | 2289 | if (error) { |
2281 | VN_RELE(XFS_ITOV(mp->m_rbmip)); | 2290 | IRELE(mp->m_rbmip); |
2282 | return error; | 2291 | return error; |
2283 | } | 2292 | } |
2284 | ASSERT(mp->m_rsumip != NULL); | 2293 | ASSERT(mp->m_rsumip != NULL); |