Lines Matching defs:dq

96 static void dq_lock_internal(struct dquot *dq);
97 static void dq_unlock_internal(struct dquot *dq);
124 static int dqsync_locked(struct dquot *dq);
224 dq_lock_internal(struct dquot *dq)
226 while (dq->dq_lflags & DQ_LLOCK) {
227 dq->dq_lflags |= DQ_LWANT;
228 msleep(&dq->dq_lflags, quota_list_mtx_lock, PVFS, "dq_lock_internal", NULL);
230 dq->dq_lflags |= DQ_LLOCK;
237 dq_unlock_internal(struct dquot *dq)
239 int wanted = dq->dq_lflags & DQ_LWANT;
241 dq->dq_lflags &= ~(DQ_LLOCK | DQ_LWANT);
244 wakeup(&dq->dq_lflags);
248 dqlock(struct dquot *dq) {
252 dq_lock_internal(dq);
258 dqunlock(struct dquot *dq) {
262 dq_unlock_internal(dq);
499 struct dquot *dq;
539 for (dq = dqh->lh_first; dq; dq = dq->dq_hash.le_next) {
540 if (dq->dq_id != id ||
541 dq->dq_qfile->qf_vp != dqvp)
544 dq_lock_internal(dq);
546 dq_unlock_internal(dq);
552 * we need to re-evaluate the identity of this dq
554 if (dq->dq_id != id || dq->dq_qfile == NULL ||
555 dq->dq_qfile->qf_vp != dqvp) {
556 dq_unlock_internal(dq);
563 if (dq->dq_cnt++ == 0) {
564 if (dq->dq_flags & DQ_MOD)
565 TAILQ_REMOVE(&dqdirtylist, dq, dq_freelist);
567 TAILQ_REMOVE(&dqfreelist, dq, dq_freelist);
569 dq_unlock_internal(dq);
574 * but we found the dq we were looking for in
586 * but we found the dq we were looking for in
591 *dqp = dq;
608 dq = fdq;
617 ndq = (struct dquot *)_MALLOC(sizeof *dq, M_DQUOT, M_WAITOK);
618 bzero((char *)ndq, sizeof *dq);
633 dq = ndq;
654 dq = TAILQ_FIRST(&dqfreelist);
656 dq_lock_internal(dq);
658 if (dq_list_lock_changed(listlockval) || dq->dq_cnt || (dq->dq_flags & DQ_MOD)) {
662 * will drop it to msleep... this dq has been
665 dq_unlock_internal(dq);
674 TAILQ_REMOVE(&dqfreelist, dq, dq_freelist);
676 if (dq->dq_qfile != NULL) {
677 LIST_REMOVE(dq, dq_hash);
678 dq->dq_qfile = NULL;
679 dq->dq_id = 0;
681 dq_unlock_internal(dq);
687 * caused a dq with this identity to be created...
690 fdq = dq;
694 * we've either freshly allocated a dq
698 * one else can be trying to use this dq
700 dq_lock_internal(dq);
702 dq_unlock_internal(dq);
709 dq->dq_cnt = 1;
710 dq->dq_flags = 0;
711 dq->dq_id = id;
712 dq->dq_qfile = qfp;
713 dq->dq_type = type;
722 LIST_INSERT_HEAD(dqh, dq, dq_hash);
734 error = dqlookup(qfp, id, &dq->dq_dqb, &dq->dq_index);
743 dq->dq_id = 0;
744 dq->dq_qfile = NULL;
745 LIST_REMOVE(dq, dq_hash);
747 dq_unlock_internal(dq);
751 dqrele(dq);
760 if (dq->dq_isoftlimit == 0 && dq->dq_bsoftlimit == 0 &&
761 dq->dq_ihardlimit == 0 && dq->dq_bhardlimit == 0)
762 dq->dq_flags |= DQ_FAKE;
763 if (dq->dq_id != 0) {
767 if (dq->dq_btime == 0)
768 dq->dq_btime = tv.tv_sec + qfp->qf_btime;
769 if (dq->dq_itime == 0)
770 dq->dq_itime = tv.tv_sec + qfp->qf_itime;
773 dq_unlock_internal(dq);
777 *dqp = dq;
871 dqrele(struct dquot *dq)
874 if (dq == NODQUOT)
876 dqlock(dq);
878 if (dq->dq_cnt > 1) {
879 dq->dq_cnt--;
881 dqunlock(dq);
884 if (dq->dq_flags & DQ_MOD)
885 (void) dqsync_locked(dq);
886 dq->dq_cnt--;
889 TAILQ_INSERT_TAIL(&dqfreelist, dq, dq_freelist);
890 dq_unlock_internal(dq);
898 dqreclaim(struct dquot *dq)
901 if (dq == NODQUOT)
905 dq_lock_internal(dq);
907 if (--dq->dq_cnt > 0) {
908 dq_unlock_internal(dq);
912 if (dq->dq_flags & DQ_MOD)
913 TAILQ_INSERT_TAIL(&dqdirtylist, dq, dq_freelist);
915 TAILQ_INSERT_TAIL(&dqfreelist, dq, dq_freelist);
917 dq_unlock_internal(dq);
927 struct dquot *dq;
931 TAILQ_FOREACH(dq, &dqdirtylist, dq_freelist) {
932 if (dq->dq_qfile != qfp)
935 dq_lock_internal(dq);
937 if (dq->dq_qfile != qfp) {
939 * the identity of this dq changed while
943 dq_unlock_internal(dq);
946 if ((dq->dq_flags & DQ_MOD) == 0) {
949 * the dq from the dirty list while the
952 dq_unlock_internal(dq);
955 if (dq->dq_cnt != 0)
958 TAILQ_REMOVE(&dqdirtylist, dq, dq_freelist);
967 (void) dqsync_locked(dq);
971 TAILQ_INSERT_TAIL(&dqfreelist, dq, dq_freelist);
973 dq_unlock_internal(dq);
980 dqsync(struct dquot *dq)
984 if (dq != NODQUOT) {
985 dqlock(dq);
987 if ( (dq->dq_flags & DQ_MOD) )
988 error = dqsync_locked(dq);
990 dqunlock(dq);
1000 dqsync_locked(struct dquot *dq)
1009 if (dq->dq_id == 0) {
1010 dq->dq_flags &= ~DQ_MOD;
1013 if (dq->dq_qfile == NULL)
1015 if ((dqvp = dq->dq_qfile->qf_vp) == NULLVP)
1018 auio = uio_createwithbuffer(1, dqoffset(dq->dq_index), UIO_SYSSPACE,
1023 context.vc_ucred = dq->dq_qfile->qf_cred;
1025 dqblkp = &dq->dq_dqb;
1043 dq->dq_flags &= ~DQ_MOD;
1054 struct dquot *dq, *nextdq;
1068 for (dq = dqh->lh_first; dq; dq = nextdq) {
1069 nextdq = dq->dq_hash.le_next;
1070 if (dq->dq_qfile->qf_vp != vp)
1072 if (dq->dq_cnt)
1074 LIST_REMOVE(dq, dq_hash);
1075 dq->dq_qfile = NULL;