Lines Matching defs:dqp

52 	struct xfs_dquot	*dqp)
54 ASSERT(list_empty(&dqp->q_lru));
56 kmem_free(dqp->q_logitem.qli_item.li_lv_shadow);
57 mutex_destroy(&dqp->q_qlock);
59 XFS_STATS_DEC(dqp->q_mount, xs_qm_dquot);
60 kmem_cache_free(xfs_qm_dqzone, dqp);
265 xfs_dquot_set_prealloc_limits(struct xfs_dquot *dqp)
269 dqp->q_prealloc_hi_wmark = dqp->q_blk.hardlimit;
270 dqp->q_prealloc_lo_wmark = dqp->q_blk.softlimit;
271 if (!dqp->q_prealloc_lo_wmark) {
272 dqp->q_prealloc_lo_wmark = dqp->q_prealloc_hi_wmark;
273 do_div(dqp->q_prealloc_lo_wmark, 100);
274 dqp->q_prealloc_lo_wmark *= 95;
277 space = dqp->q_prealloc_hi_wmark;
280 dqp->q_low_space[XFS_QLOWSP_1_PCNT] = space;
281 dqp->q_low_space[XFS_QLOWSP_3_PCNT] = space * 3;
282 dqp->q_low_space[XFS_QLOWSP_5_PCNT] = space * 5;
293 struct xfs_dquot *dqp,
300 xfs_dqtype_t qtype = xfs_dquot_type(dqp);
305 trace_xfs_dqalloc(dqp);
308 if (!xfs_this_quota_on(dqp->q_mount, qtype)) {
319 error = xfs_bmapi_write(tp, quotip, dqp->q_fileoffset,
332 dqp->q_blkno = XFS_FSB_TO_DADDR(mp, map.br_startblock);
335 error = xfs_trans_get_buf(tp, mp->m_ddev_targp, dqp->q_blkno,
345 xfs_qm_init_dquot_blk(tp, mp, dqp->q_id, qtype, bp);
387 struct xfs_dquot *dqp,
392 xfs_dqtype_t qtype = xfs_dquot_type(dqp);
411 error = xfs_bmapi_read(quotip, dqp->q_fileoffset,
423 trace_xfs_dqtobp_read(dqp);
429 dqp->q_blkno = XFS_FSB_TO_DADDR(mp, map.br_startblock);
431 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno,
453 struct xfs_dquot *dqp;
455 dqp = kmem_cache_zalloc(xfs_qm_dqzone, GFP_KERNEL | __GFP_NOFAIL);
457 dqp->q_type = type;
458 dqp->q_id = id;
459 dqp->q_mount = mp;
460 INIT_LIST_HEAD(&dqp->q_lru);
461 mutex_init(&dqp->q_qlock);
462 init_waitqueue_head(&dqp->q_pinwait);
463 dqp->q_fileoffset = (xfs_fileoff_t)id / mp->m_quotainfo->qi_dqperchunk;
467 dqp->q_bufoffset = (id % mp->m_quotainfo->qi_dqperchunk) *
475 init_completion(&dqp->q_flush);
476 complete(&dqp->q_flush);
487 lockdep_set_class(&dqp->q_qlock, &xfs_dquot_group_class);
490 lockdep_set_class(&dqp->q_qlock, &xfs_dquot_project_class);
497 xfs_qm_dquot_logitem_init(dqp);
500 return dqp;
506 struct xfs_dquot *dqp,
513 dqp_type = xfs_dquot_type(dqp);
515 if (be32_to_cpu(ddqp->d_id) != dqp->q_id)
523 if (xfs_sb_version_hascrc(&dqp->q_mount->m_sb) ||
524 dqp_type == XFS_DQTYPE_USER || dqp->q_id != 0)
542 struct xfs_dquot *dqp,
545 struct xfs_disk_dquot *ddqp = bp->b_addr + dqp->q_bufoffset;
551 if (!xfs_dquot_check_type(dqp, ddqp)) {
554 __this_address, dqp->q_id);
560 dqp->q_type = ddqp->d_type;
561 dqp->q_blk.hardlimit = be64_to_cpu(ddqp->d_blk_hardlimit);
562 dqp->q_blk.softlimit = be64_to_cpu(ddqp->d_blk_softlimit);
563 dqp->q_ino.hardlimit = be64_to_cpu(ddqp->d_ino_hardlimit);
564 dqp->q_ino.softlimit = be64_to_cpu(ddqp->d_ino_softlimit);
565 dqp->q_rtb.hardlimit = be64_to_cpu(ddqp->d_rtb_hardlimit);
566 dqp->q_rtb.softlimit = be64_to_cpu(ddqp->d_rtb_softlimit);
568 dqp->q_blk.count = be64_to_cpu(ddqp->d_bcount);
569 dqp->q_ino.count = be64_to_cpu(ddqp->d_icount);
570 dqp->q_rtb.count = be64_to_cpu(ddqp->d_rtbcount);
572 dqp->q_blk.warnings = be16_to_cpu(ddqp->d_bwarns);
573 dqp->q_ino.warnings = be16_to_cpu(ddqp->d_iwarns);
574 dqp->q_rtb.warnings = be16_to_cpu(ddqp->d_rtbwarns);
576 dqp->q_blk.timer = xfs_dquot_from_disk_ts(ddqp, ddqp->d_btimer);
577 dqp->q_ino.timer = xfs_dquot_from_disk_ts(ddqp, ddqp->d_itimer);
578 dqp->q_rtb.timer = xfs_dquot_from_disk_ts(ddqp, ddqp->d_rtbtimer);
584 dqp->q_blk.reserved = dqp->q_blk.count;
585 dqp->q_ino.reserved = dqp->q_ino.count;
586 dqp->q_rtb.reserved = dqp->q_rtb.count;
589 xfs_dquot_set_prealloc_limits(dqp);
597 struct xfs_dquot *dqp)
601 ddqp->d_type = dqp->q_type;
602 ddqp->d_id = cpu_to_be32(dqp->q_id);
606 ddqp->d_blk_hardlimit = cpu_to_be64(dqp->q_blk.hardlimit);
607 ddqp->d_blk_softlimit = cpu_to_be64(dqp->q_blk.softlimit);
608 ddqp->d_ino_hardlimit = cpu_to_be64(dqp->q_ino.hardlimit);
609 ddqp->d_ino_softlimit = cpu_to_be64(dqp->q_ino.softlimit);
610 ddqp->d_rtb_hardlimit = cpu_to_be64(dqp->q_rtb.hardlimit);
611 ddqp->d_rtb_softlimit = cpu_to_be64(dqp->q_rtb.softlimit);
613 ddqp->d_bcount = cpu_to_be64(dqp->q_blk.count);
614 ddqp->d_icount = cpu_to_be64(dqp->q_ino.count);
615 ddqp->d_rtbcount = cpu_to_be64(dqp->q_rtb.count);
617 ddqp->d_bwarns = cpu_to_be16(dqp->q_blk.warnings);
618 ddqp->d_iwarns = cpu_to_be16(dqp->q_ino.warnings);
619 ddqp->d_rtbwarns = cpu_to_be16(dqp->q_rtb.warnings);
621 ddqp->d_btimer = xfs_dquot_to_disk_ts(dqp, dqp->q_blk.timer);
622 ddqp->d_itimer = xfs_dquot_to_disk_ts(dqp, dqp->q_ino.timer);
623 ddqp->d_rtbtimer = xfs_dquot_to_disk_ts(dqp, dqp->q_rtb.timer);
630 struct xfs_dquot *dqp,
641 error = xfs_dquot_disk_alloc(&tp, dqp, bpp);
676 struct xfs_dquot *dqp;
680 dqp = xfs_dquot_alloc(mp, id, type);
681 trace_xfs_dqread(dqp);
684 error = xfs_dquot_disk_read(mp, dqp, &bp);
686 error = xfs_qm_dqread_alloc(mp, dqp, &bp);
697 error = xfs_dquot_from_disk(dqp, bp);
702 *dqpp = dqp;
706 trace_xfs_dqread_fail(dqp);
707 xfs_qm_dqdestroy(dqp);
776 struct xfs_dquot *dqp;
780 dqp = radix_tree_lookup(tree, id);
781 if (!dqp) {
787 xfs_dqlock(dqp);
788 if (dqp->q_flags & XFS_DQFLAG_FREEING) {
789 xfs_dqunlock(dqp);
791 trace_xfs_dqget_freeing(dqp);
796 dqp->q_nrefs++;
799 trace_xfs_dqget_hit(dqp);
801 return dqp;
816 struct xfs_dquot *dqp)
821 error = radix_tree_insert(tree, id, dqp);
826 trace_xfs_dqget_dup(dqp);
831 xfs_dqlock(dqp);
832 dqp->q_nrefs = 1;
882 struct xfs_dquot *dqp;
890 dqp = xfs_qm_dqget_cache_lookup(mp, qi, tree, id);
891 if (dqp) {
892 *O_dqpp = dqp;
896 error = xfs_qm_dqread(mp, id, type, can_alloc, &dqp);
900 error = xfs_qm_dqget_cache_insert(mp, qi, tree, id, dqp);
906 xfs_qm_dqdestroy(dqp);
911 trace_xfs_dqget_miss(dqp);
912 *O_dqpp = dqp;
971 struct xfs_dquot *dqp;
985 dqp = xfs_qm_dqget_cache_lookup(mp, qi, tree, id);
986 if (dqp) {
987 *O_dqpp = dqp;
999 error = xfs_qm_dqread(mp, id, type, can_alloc, &dqp);
1013 xfs_qm_dqdestroy(dqp);
1014 dqp = dqp1;
1015 xfs_dqlock(dqp);
1020 xfs_qm_dqdestroy(dqp);
1024 error = xfs_qm_dqget_cache_insert(mp, qi, tree, id, dqp);
1030 xfs_qm_dqdestroy(dqp);
1037 trace_xfs_dqget_miss(dqp);
1038 *O_dqpp = dqp;
1053 struct xfs_dquot *dqp;
1058 error = xfs_qm_dqget(mp, id, type, false, &dqp);
1064 if (!XFS_IS_DQUOT_UNINITIALIZED(dqp)) {
1065 *dqpp = dqp;
1069 xfs_qm_dqput(dqp);
1083 struct xfs_dquot *dqp)
1085 ASSERT(dqp->q_nrefs > 0);
1086 ASSERT(XFS_DQ_IS_LOCKED(dqp));
1088 trace_xfs_dqput(dqp);
1090 if (--dqp->q_nrefs == 0) {
1091 struct xfs_quotainfo *qi = dqp->q_mount->m_quotainfo;
1092 trace_xfs_dqput_free(dqp);
1094 if (list_lru_add(&qi->qi_lru, &dqp->q_lru))
1095 XFS_STATS_INC(dqp->q_mount, xs_qm_dquot_unused);
1097 xfs_dqunlock(dqp);
1106 struct xfs_dquot *dqp)
1108 if (!dqp)
1111 trace_xfs_dqrele(dqp);
1113 xfs_dqlock(dqp);
1120 xfs_qm_dqput(dqp);
1135 struct xfs_dquot *dqp = qip->qli_dquot;
1165 xfs_dqfunlock(dqp);
1195 struct xfs_dquot *dqp)
1197 xfs_dqtype_t type = xfs_dquot_type(dqp);
1204 if (dqp->q_id == 0)
1207 if (dqp->q_blk.softlimit && dqp->q_blk.count > dqp->q_blk.softlimit &&
1208 !dqp->q_blk.timer)
1211 if (dqp->q_ino.softlimit && dqp->q_ino.count > dqp->q_ino.softlimit &&
1212 !dqp->q_ino.timer)
1215 if (dqp->q_rtb.softlimit && dqp->q_rtb.count > dqp->q_rtb.softlimit &&
1216 !dqp->q_rtb.timer)
1220 if (dqp->q_type & XFS_DQTYPE_BIGTIME) {
1221 if (!xfs_sb_version_hasbigtime(&dqp->q_mount->m_sb))
1223 if (dqp->q_id == 0)
1240 struct xfs_dquot *dqp,
1243 struct xfs_mount *mp = dqp->q_mount;
1244 struct xfs_log_item *lip = &dqp->q_logitem.qli_item;
1250 ASSERT(XFS_DQ_IS_LOCKED(dqp));
1251 ASSERT(!completion_done(&dqp->q_flush));
1253 trace_xfs_dqflush(dqp);
1257 xfs_qm_dqunpin_wait(dqp);
1262 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno,
1270 fa = xfs_qm_dqflush_check(dqp);
1273 dqp->q_id, fa);
1280 dqblk = bp->b_addr + dqp->q_bufoffset;
1281 xfs_dquot_to_disk(&dqblk->dd_diskdq, dqp);
1286 dqp->q_flags &= ~XFS_DQFLAG_DIRTY;
1288 xfs_trans_ail_copy_lsn(mp->m_ail, &dqp->q_logitem.qli_flush_lsn,
1289 &dqp->q_logitem.qli_item.li_lsn);
1301 dqblk->dd_lsn = cpu_to_be64(dqp->q_logitem.qli_item.li_lsn);
1311 list_add_tail(&dqp->q_logitem.qli_item.li_bio_list, &bp->b_li_list);
1318 trace_xfs_dqflush_force(dqp);
1322 trace_xfs_dqflush_done(dqp);
1327 dqp->q_flags &= ~XFS_DQFLAG_DIRTY;
1331 xfs_dqfunlock(dqp);