diff options
Diffstat (limited to 'fs/xfs/quota/xfs_dquot_item.c')
-rw-r--r-- | fs/xfs/quota/xfs_dquot_item.c | 99 |
1 files changed, 18 insertions, 81 deletions
diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c index d0d4a9a0bbd7..4e4ee9a57194 100644 --- a/fs/xfs/quota/xfs_dquot_item.c +++ b/fs/xfs/quota/xfs_dquot_item.c | |||
@@ -74,11 +74,11 @@ xfs_qm_dquot_logitem_format( | |||
74 | 74 | ||
75 | logvec->i_addr = (xfs_caddr_t)&logitem->qli_format; | 75 | logvec->i_addr = (xfs_caddr_t)&logitem->qli_format; |
76 | logvec->i_len = sizeof(xfs_dq_logformat_t); | 76 | logvec->i_len = sizeof(xfs_dq_logformat_t); |
77 | XLOG_VEC_SET_TYPE(logvec, XLOG_REG_TYPE_QFORMAT); | 77 | logvec->i_type = XLOG_REG_TYPE_QFORMAT; |
78 | logvec++; | 78 | logvec++; |
79 | logvec->i_addr = (xfs_caddr_t)&logitem->qli_dquot->q_core; | 79 | logvec->i_addr = (xfs_caddr_t)&logitem->qli_dquot->q_core; |
80 | logvec->i_len = sizeof(xfs_disk_dquot_t); | 80 | logvec->i_len = sizeof(xfs_disk_dquot_t); |
81 | XLOG_VEC_SET_TYPE(logvec, XLOG_REG_TYPE_DQUOT); | 81 | logvec->i_type = XLOG_REG_TYPE_DQUOT; |
82 | 82 | ||
83 | ASSERT(2 == logitem->qli_item.li_desc->lid_size); | 83 | ASSERT(2 == logitem->qli_item.li_desc->lid_size); |
84 | logitem->qli_format.qlf_size = 2; | 84 | logitem->qli_format.qlf_size = 2; |
@@ -153,7 +153,7 @@ xfs_qm_dquot_logitem_push( | |||
153 | * lock without sleeping, then there must not have been | 153 | * lock without sleeping, then there must not have been |
154 | * anyone in the process of flushing the dquot. | 154 | * anyone in the process of flushing the dquot. |
155 | */ | 155 | */ |
156 | error = xfs_qm_dqflush(dqp, XFS_QMOPT_DELWRI); | 156 | error = xfs_qm_dqflush(dqp, 0); |
157 | if (error) | 157 | if (error) |
158 | xfs_fs_cmn_err(CE_WARN, dqp->q_mount, | 158 | xfs_fs_cmn_err(CE_WARN, dqp->q_mount, |
159 | "xfs_qm_dquot_logitem_push: push error %d on dqp %p", | 159 | "xfs_qm_dquot_logitem_push: push error %d on dqp %p", |
@@ -190,7 +190,7 @@ xfs_qm_dqunpin_wait( | |||
190 | /* | 190 | /* |
191 | * Give the log a push so we don't wait here too long. | 191 | * Give the log a push so we don't wait here too long. |
192 | */ | 192 | */ |
193 | xfs_log_force(dqp->q_mount, (xfs_lsn_t)0, XFS_LOG_FORCE); | 193 | xfs_log_force(dqp->q_mount, 0); |
194 | wait_event(dqp->q_pinwait, (atomic_read(&dqp->q_pincount) == 0)); | 194 | wait_event(dqp->q_pinwait, (atomic_read(&dqp->q_pincount) == 0)); |
195 | } | 195 | } |
196 | 196 | ||
@@ -212,68 +212,31 @@ xfs_qm_dquot_logitem_pushbuf( | |||
212 | xfs_dquot_t *dqp; | 212 | xfs_dquot_t *dqp; |
213 | xfs_mount_t *mp; | 213 | xfs_mount_t *mp; |
214 | xfs_buf_t *bp; | 214 | xfs_buf_t *bp; |
215 | uint dopush; | ||
216 | 215 | ||
217 | dqp = qip->qli_dquot; | 216 | dqp = qip->qli_dquot; |
218 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); | 217 | ASSERT(XFS_DQ_IS_LOCKED(dqp)); |
219 | 218 | ||
220 | /* | 219 | /* |
221 | * The qli_pushbuf_flag keeps others from | ||
222 | * trying to duplicate our effort. | ||
223 | */ | ||
224 | ASSERT(qip->qli_pushbuf_flag != 0); | ||
225 | ASSERT(qip->qli_push_owner == current_pid()); | ||
226 | |||
227 | /* | ||
228 | * If flushlock isn't locked anymore, chances are that the | 220 | * If flushlock isn't locked anymore, chances are that the |
229 | * inode flush completed and the inode was taken off the AIL. | 221 | * inode flush completed and the inode was taken off the AIL. |
230 | * So, just get out. | 222 | * So, just get out. |
231 | */ | 223 | */ |
232 | if (completion_done(&dqp->q_flush) || | 224 | if (completion_done(&dqp->q_flush) || |
233 | ((qip->qli_item.li_flags & XFS_LI_IN_AIL) == 0)) { | 225 | ((qip->qli_item.li_flags & XFS_LI_IN_AIL) == 0)) { |
234 | qip->qli_pushbuf_flag = 0; | ||
235 | xfs_dqunlock(dqp); | 226 | xfs_dqunlock(dqp); |
236 | return; | 227 | return; |
237 | } | 228 | } |
238 | mp = dqp->q_mount; | 229 | mp = dqp->q_mount; |
239 | bp = xfs_incore(mp->m_ddev_targp, qip->qli_format.qlf_blkno, | 230 | bp = xfs_incore(mp->m_ddev_targp, qip->qli_format.qlf_blkno, |
240 | XFS_QI_DQCHUNKLEN(mp), | 231 | XFS_QI_DQCHUNKLEN(mp), XBF_TRYLOCK); |
241 | XFS_INCORE_TRYLOCK); | 232 | xfs_dqunlock(dqp); |
242 | if (bp != NULL) { | 233 | if (!bp) |
243 | if (XFS_BUF_ISDELAYWRITE(bp)) { | ||
244 | dopush = ((qip->qli_item.li_flags & XFS_LI_IN_AIL) && | ||
245 | !completion_done(&dqp->q_flush)); | ||
246 | qip->qli_pushbuf_flag = 0; | ||
247 | xfs_dqunlock(dqp); | ||
248 | |||
249 | if (XFS_BUF_ISPINNED(bp)) { | ||
250 | xfs_log_force(mp, (xfs_lsn_t)0, | ||
251 | XFS_LOG_FORCE); | ||
252 | } | ||
253 | if (dopush) { | ||
254 | int error; | ||
255 | #ifdef XFSRACEDEBUG | ||
256 | delay_for_intr(); | ||
257 | delay(300); | ||
258 | #endif | ||
259 | error = xfs_bawrite(mp, bp); | ||
260 | if (error) | ||
261 | xfs_fs_cmn_err(CE_WARN, mp, | ||
262 | "xfs_qm_dquot_logitem_pushbuf: pushbuf error %d on qip %p, bp %p", | ||
263 | error, qip, bp); | ||
264 | } else { | ||
265 | xfs_buf_relse(bp); | ||
266 | } | ||
267 | } else { | ||
268 | qip->qli_pushbuf_flag = 0; | ||
269 | xfs_dqunlock(dqp); | ||
270 | xfs_buf_relse(bp); | ||
271 | } | ||
272 | return; | 234 | return; |
273 | } | 235 | if (XFS_BUF_ISDELAYWRITE(bp)) |
236 | xfs_buf_delwri_promote(bp); | ||
237 | xfs_buf_relse(bp); | ||
238 | return; | ||
274 | 239 | ||
275 | qip->qli_pushbuf_flag = 0; | ||
276 | xfs_dqunlock(dqp); | ||
277 | } | 240 | } |
278 | 241 | ||
279 | /* | 242 | /* |
@@ -291,50 +254,24 @@ xfs_qm_dquot_logitem_trylock( | |||
291 | xfs_dq_logitem_t *qip) | 254 | xfs_dq_logitem_t *qip) |
292 | { | 255 | { |
293 | xfs_dquot_t *dqp; | 256 | xfs_dquot_t *dqp; |
294 | uint retval; | ||
295 | 257 | ||
296 | dqp = qip->qli_dquot; | 258 | dqp = qip->qli_dquot; |
297 | if (atomic_read(&dqp->q_pincount) > 0) | 259 | if (atomic_read(&dqp->q_pincount) > 0) |
298 | return (XFS_ITEM_PINNED); | 260 | return XFS_ITEM_PINNED; |
299 | 261 | ||
300 | if (! xfs_qm_dqlock_nowait(dqp)) | 262 | if (! xfs_qm_dqlock_nowait(dqp)) |
301 | return (XFS_ITEM_LOCKED); | 263 | return XFS_ITEM_LOCKED; |
302 | 264 | ||
303 | retval = XFS_ITEM_SUCCESS; | ||
304 | if (!xfs_dqflock_nowait(dqp)) { | 265 | if (!xfs_dqflock_nowait(dqp)) { |
305 | /* | 266 | /* |
306 | * The dquot is already being flushed. It may have been | 267 | * dquot has already been flushed to the backing buffer, |
307 | * flushed delayed write, however, and we don't want to | 268 | * leave it locked, pushbuf routine will unlock it. |
308 | * get stuck waiting for that to complete. So, we want to check | ||
309 | * to see if we can lock the dquot's buffer without sleeping. | ||
310 | * If we can and it is marked for delayed write, then we | ||
311 | * hold it and send it out from the push routine. We don't | ||
312 | * want to do that now since we might sleep in the device | ||
313 | * strategy routine. We also don't want to grab the buffer lock | ||
314 | * here because we'd like not to call into the buffer cache | ||
315 | * while holding the AIL lock. | ||
316 | * Make sure to only return PUSHBUF if we set pushbuf_flag | ||
317 | * ourselves. If someone else is doing it then we don't | ||
318 | * want to go to the push routine and duplicate their efforts. | ||
319 | */ | 269 | */ |
320 | if (qip->qli_pushbuf_flag == 0) { | 270 | return XFS_ITEM_PUSHBUF; |
321 | qip->qli_pushbuf_flag = 1; | ||
322 | ASSERT(qip->qli_format.qlf_blkno == dqp->q_blkno); | ||
323 | #ifdef DEBUG | ||
324 | qip->qli_push_owner = current_pid(); | ||
325 | #endif | ||
326 | /* | ||
327 | * The dquot is left locked. | ||
328 | */ | ||
329 | retval = XFS_ITEM_PUSHBUF; | ||
330 | } else { | ||
331 | retval = XFS_ITEM_FLUSHING; | ||
332 | xfs_dqunlock_nonotify(dqp); | ||
333 | } | ||
334 | } | 271 | } |
335 | 272 | ||
336 | ASSERT(qip->qli_item.li_flags & XFS_LI_IN_AIL); | 273 | ASSERT(qip->qli_item.li_flags & XFS_LI_IN_AIL); |
337 | return (retval); | 274 | return XFS_ITEM_SUCCESS; |
338 | } | 275 | } |
339 | 276 | ||
340 | 277 | ||
@@ -467,7 +404,7 @@ xfs_qm_qoff_logitem_format(xfs_qoff_logitem_t *qf, | |||
467 | 404 | ||
468 | log_vector->i_addr = (xfs_caddr_t)&(qf->qql_format); | 405 | log_vector->i_addr = (xfs_caddr_t)&(qf->qql_format); |
469 | log_vector->i_len = sizeof(xfs_qoff_logitem_t); | 406 | log_vector->i_len = sizeof(xfs_qoff_logitem_t); |
470 | XLOG_VEC_SET_TYPE(log_vector, XLOG_REG_TYPE_QUOTAOFF); | 407 | log_vector->i_type = XLOG_REG_TYPE_QUOTAOFF; |
471 | qf->qql_format.qf_size = 1; | 408 | qf->qql_format.qf_size = 1; |
472 | } | 409 | } |
473 | 410 | ||