📄 xfs_dquot_item.c
字号:
} else { retval = XFS_ITEM_FLUSHING; xfs_dqunlock_nonotify(dqp); } } ASSERT(qip->qli_item.li_flags & XFS_LI_IN_AIL); return (retval);}/* * Unlock the dquot associated with the log item. * Clear the fields of the dquot and dquot log item that * are specific to the current transaction. If the * hold flags is set, do not unlock the dquot. */STATIC voidxfs_qm_dquot_logitem_unlock( xfs_dq_logitem_t *ql){ xfs_dquot_t *dqp; ASSERT(ql != NULL); dqp = ql->qli_dquot; ASSERT(XFS_DQ_IS_LOCKED(dqp)); /* * Clear the transaction pointer in the dquot */ dqp->q_transp = NULL; /* * dquots are never 'held' from getting unlocked at the end of * a transaction. Their locking and unlocking is hidden inside the * transaction layer, within trans_commit. Hence, no LI_HOLD flag * for the logitem. */ xfs_dqunlock(dqp);}/* * The transaction with the dquot locked has aborted. The dquot * must not be dirty within the transaction. We simply unlock just * as if the transaction had been cancelled. */STATIC voidxfs_qm_dquot_logitem_abort( xfs_dq_logitem_t *ql){ xfs_qm_dquot_logitem_unlock(ql);}/* * this needs to stamp an lsn into the dquot, I think. * rpc's that look at user dquot's would then have to * push on the dependency recorded in the dquot *//* ARGSUSED */STATIC voidxfs_qm_dquot_logitem_committing( xfs_dq_logitem_t *l, xfs_lsn_t lsn){ return;}/* * This is the ops vector for dquots */struct xfs_item_ops xfs_dquot_item_ops = { .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_size, .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) xfs_qm_dquot_logitem_format, .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_pin, .iop_unpin = (void(*)(xfs_log_item_t*, int)) xfs_qm_dquot_logitem_unpin, .iop_unpin_remove = (void(*)(xfs_log_item_t*, xfs_trans_t*)) xfs_qm_dquot_logitem_unpin_remove, .iop_trylock = (uint(*)(xfs_log_item_t*)) xfs_qm_dquot_logitem_trylock, .iop_unlock = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_unlock, .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) xfs_qm_dquot_logitem_committed, .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_push, .iop_abort = (void(*)(xfs_log_item_t*))xfs_qm_dquot_logitem_abort, .iop_pushbuf = (void(*)(xfs_log_item_t*)) xfs_qm_dquot_logitem_pushbuf, .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) xfs_qm_dquot_logitem_committing};/* * Initialize the dquot log item for a newly allocated dquot. * The dquot isn't locked at this point, but it isn't on any of the lists * either, so we don't care. */voidxfs_qm_dquot_logitem_init( struct xfs_dquot *dqp){ xfs_dq_logitem_t *lp; lp = &dqp->q_logitem; lp->qli_item.li_type = XFS_LI_DQUOT; lp->qli_item.li_ops = &xfs_dquot_item_ops; lp->qli_item.li_mountp = dqp->q_mount; lp->qli_dquot = dqp; lp->qli_format.qlf_type = XFS_LI_DQUOT; lp->qli_format.qlf_id = INT_GET(dqp->q_core.d_id, ARCH_CONVERT); lp->qli_format.qlf_blkno = dqp->q_blkno; lp->qli_format.qlf_len = 1; /* * This is just the offset of this dquot within its buffer * (which is currently 1 FSB and probably won't change). * Hence 32 bits for this offset should be just fine. * Alternatively, we can store (bufoffset / sizeof(xfs_dqblk_t)) * here, and recompute it at recovery time. */ lp->qli_format.qlf_boffset = (__uint32_t)dqp->q_bufoffset;}/*------------------ QUOTAOFF LOG ITEMS -------------------*//* * This returns the number of iovecs needed to log the given quotaoff item. * We only need 1 iovec for an quotaoff item. It just logs the * quotaoff_log_format structure. *//*ARGSUSED*/STATIC uintxfs_qm_qoff_logitem_size(xfs_qoff_logitem_t *qf){ return (1);}/* * This is called to fill in the vector of log iovecs for the * given quotaoff log item. We use only 1 iovec, and we point that * at the quotaoff_log_format structure embedded in the quotaoff item. * It is at this point that we assert that all of the extent * slots in the quotaoff item have been filled. */STATIC voidxfs_qm_qoff_logitem_format(xfs_qoff_logitem_t *qf, xfs_log_iovec_t *log_vector){ ASSERT(qf->qql_format.qf_type == XFS_LI_QUOTAOFF); log_vector->i_addr = (xfs_caddr_t)&(qf->qql_format); log_vector->i_len = sizeof(xfs_qoff_logitem_t); qf->qql_format.qf_size = 1;}/* * Pinning has no meaning for an quotaoff item, so just return. *//*ARGSUSED*/STATIC voidxfs_qm_qoff_logitem_pin(xfs_qoff_logitem_t *qf){ return;}/* * Since pinning has no meaning for an quotaoff item, unpinning does * not either. *//*ARGSUSED*/STATIC voidxfs_qm_qoff_logitem_unpin(xfs_qoff_logitem_t *qf, int stale){ return;}/*ARGSUSED*/STATIC voidxfs_qm_qoff_logitem_unpin_remove(xfs_qoff_logitem_t *qf, xfs_trans_t *tp){ return;}/* * Quotaoff items have no locking, so just return success. *//*ARGSUSED*/STATIC uintxfs_qm_qoff_logitem_trylock(xfs_qoff_logitem_t *qf){ return XFS_ITEM_LOCKED;}/* * Quotaoff items have no locking or pushing, so return failure * so that the caller doesn't bother with us. *//*ARGSUSED*/STATIC voidxfs_qm_qoff_logitem_unlock(xfs_qoff_logitem_t *qf){ return;}/* * The quotaoff-start-item is logged only once and cannot be moved in the log, * so simply return the lsn at which it's been logged. *//*ARGSUSED*/STATIC xfs_lsn_txfs_qm_qoff_logitem_committed(xfs_qoff_logitem_t *qf, xfs_lsn_t lsn){ return (lsn);}/* * The transaction of which this QUOTAOFF is a part has been aborted. * Just clean up after ourselves. * Shouldn't this never happen in the case of qoffend logitems? XXX */STATIC voidxfs_qm_qoff_logitem_abort(xfs_qoff_logitem_t *qf){ kmem_free(qf, sizeof(xfs_qoff_logitem_t));}/* * There isn't much you can do to push on an quotaoff item. It is simply * stuck waiting for the log to be flushed to disk. *//*ARGSUSED*/STATIC voidxfs_qm_qoff_logitem_push(xfs_qoff_logitem_t *qf){ return;}/*ARGSUSED*/STATIC xfs_lsn_txfs_qm_qoffend_logitem_committed( xfs_qoff_logitem_t *qfe, xfs_lsn_t lsn){ xfs_qoff_logitem_t *qfs; SPLDECL(s); qfs = qfe->qql_start_lip; AIL_LOCK(qfs->qql_item.li_mountp,s); /* * Delete the qoff-start logitem from the AIL. * xfs_trans_delete_ail() drops the AIL lock. */ xfs_trans_delete_ail(qfs->qql_item.li_mountp, (xfs_log_item_t *)qfs, s); kmem_free(qfs, sizeof(xfs_qoff_logitem_t)); kmem_free(qfe, sizeof(xfs_qoff_logitem_t)); return (xfs_lsn_t)-1;}/* * XXX rcc - don't know quite what to do with this. I think we can * just ignore it. The only time that isn't the case is if we allow * the client to somehow see that quotas have been turned off in which * we can't allow that to get back until the quotaoff hits the disk. * So how would that happen? Also, do we need different routines for * quotaoff start and quotaoff end? I suspect the answer is yes but * to be sure, I need to look at the recovery code and see how quota off * recovery is handled (do we roll forward or back or do something else). * If we roll forwards or backwards, then we need two separate routines, * one that does nothing and one that stamps in the lsn that matters * (truly makes the quotaoff irrevocable). If we do something else, * then maybe we don't need two. *//* ARGSUSED */STATIC voidxfs_qm_qoff_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn){ return;}/* ARGSUSED */STATIC voidxfs_qm_qoffend_logitem_committing(xfs_qoff_logitem_t *qip, xfs_lsn_t commit_lsn){ return;}struct xfs_item_ops xfs_qm_qoffend_logitem_ops = { .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size, .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) xfs_qm_qoff_logitem_format, .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_pin, .iop_unpin = (void(*)(xfs_log_item_t* ,int)) xfs_qm_qoff_logitem_unpin, .iop_unpin_remove = (void(*)(xfs_log_item_t*,xfs_trans_t*)) xfs_qm_qoff_logitem_unpin_remove, .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_trylock, .iop_unlock = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unlock, .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) xfs_qm_qoffend_logitem_committed, .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push, .iop_abort = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_abort, .iop_pushbuf = NULL, .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) xfs_qm_qoffend_logitem_committing};/* * This is the ops vector shared by all quotaoff-start log items. */struct xfs_item_ops xfs_qm_qoff_logitem_ops = { .iop_size = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_size, .iop_format = (void(*)(xfs_log_item_t*, xfs_log_iovec_t*)) xfs_qm_qoff_logitem_format, .iop_pin = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_pin, .iop_unpin = (void(*)(xfs_log_item_t*, int)) xfs_qm_qoff_logitem_unpin, .iop_unpin_remove = (void(*)(xfs_log_item_t*,xfs_trans_t*)) xfs_qm_qoff_logitem_unpin_remove, .iop_trylock = (uint(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_trylock, .iop_unlock = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_unlock, .iop_committed = (xfs_lsn_t(*)(xfs_log_item_t*, xfs_lsn_t)) xfs_qm_qoff_logitem_committed, .iop_push = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_push, .iop_abort = (void(*)(xfs_log_item_t*))xfs_qm_qoff_logitem_abort, .iop_pushbuf = NULL, .iop_committing = (void(*)(xfs_log_item_t*, xfs_lsn_t)) xfs_qm_qoff_logitem_committing};/* * Allocate and initialize an quotaoff item of the correct quota type(s). */xfs_qoff_logitem_t *xfs_qm_qoff_logitem_init( struct xfs_mount *mp, xfs_qoff_logitem_t *start, uint flags){ xfs_qoff_logitem_t *qf; qf = (xfs_qoff_logitem_t*) kmem_zalloc(sizeof(xfs_qoff_logitem_t), KM_SLEEP); qf->qql_item.li_type = XFS_LI_QUOTAOFF; if (start) qf->qql_item.li_ops = &xfs_qm_qoffend_logitem_ops; else qf->qql_item.li_ops = &xfs_qm_qoff_logitem_ops; qf->qql_item.li_mountp = mp; qf->qql_format.qf_type = XFS_LI_QUOTAOFF; qf->qql_format.qf_flags = flags; qf->qql_start_lip = start; return (qf);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -