Lines Matching refs:dqp
51 struct xfs_dquot *dqp) in xfs_dquot_mark_sick() argument
53 struct xfs_mount *mp = dqp->q_mount; in xfs_dquot_mark_sick()
55 switch (dqp->q_type) { in xfs_dquot_mark_sick()
76 struct xfs_dquot *dqp) in xfs_qm_dqdestroy() argument
78 ASSERT(list_empty(&dqp->q_lru)); in xfs_qm_dqdestroy()
80 kvfree(dqp->q_logitem.qli_item.li_lv_shadow); in xfs_qm_dqdestroy()
81 mutex_destroy(&dqp->q_qlock); in xfs_qm_dqdestroy()
83 XFS_STATS_DEC(dqp->q_mount, xs_qm_dquot); in xfs_qm_dqdestroy()
84 kmem_cache_free(xfs_dquot_cache, dqp); in xfs_qm_dqdestroy()
286 xfs_dquot_set_prealloc_limits(struct xfs_dquot *dqp) in xfs_dquot_set_prealloc_limits() argument
290 dqp->q_prealloc_hi_wmark = dqp->q_blk.hardlimit; in xfs_dquot_set_prealloc_limits()
291 dqp->q_prealloc_lo_wmark = dqp->q_blk.softlimit; in xfs_dquot_set_prealloc_limits()
292 if (!dqp->q_prealloc_lo_wmark) { in xfs_dquot_set_prealloc_limits()
293 dqp->q_prealloc_lo_wmark = dqp->q_prealloc_hi_wmark; in xfs_dquot_set_prealloc_limits()
294 do_div(dqp->q_prealloc_lo_wmark, 100); in xfs_dquot_set_prealloc_limits()
295 dqp->q_prealloc_lo_wmark *= 95; in xfs_dquot_set_prealloc_limits()
298 space = dqp->q_prealloc_hi_wmark; in xfs_dquot_set_prealloc_limits()
301 dqp->q_low_space[XFS_QLOWSP_1_PCNT] = space; in xfs_dquot_set_prealloc_limits()
302 dqp->q_low_space[XFS_QLOWSP_3_PCNT] = space * 3; in xfs_dquot_set_prealloc_limits()
303 dqp->q_low_space[XFS_QLOWSP_5_PCNT] = space * 5; in xfs_dquot_set_prealloc_limits()
313 struct xfs_dquot *dqp, in xfs_dquot_disk_alloc() argument
318 struct xfs_mount *mp = dqp->q_mount; in xfs_dquot_disk_alloc()
320 xfs_dqtype_t qtype = xfs_dquot_type(dqp); in xfs_dquot_disk_alloc()
325 trace_xfs_dqalloc(dqp); in xfs_dquot_disk_alloc()
335 if (!xfs_this_quota_on(dqp->q_mount, qtype)) { in xfs_dquot_disk_alloc()
350 error = xfs_bmapi_write(tp, quotip, dqp->q_fileoffset, in xfs_dquot_disk_alloc()
363 dqp->q_blkno = XFS_FSB_TO_DADDR(mp, map.br_startblock); in xfs_dquot_disk_alloc()
366 error = xfs_trans_get_buf(tp, mp->m_ddev_targp, dqp->q_blkno, in xfs_dquot_disk_alloc()
376 xfs_qm_init_dquot_blk(tp, dqp->q_id, qtype, bp); in xfs_dquot_disk_alloc()
427 struct xfs_dquot *dqp, in xfs_dquot_disk_read() argument
432 xfs_dqtype_t qtype = xfs_dquot_type(dqp); in xfs_dquot_disk_read()
451 error = xfs_bmapi_read(quotip, dqp->q_fileoffset, in xfs_dquot_disk_read()
463 trace_xfs_dqtobp_read(dqp); in xfs_dquot_disk_read()
469 dqp->q_blkno = XFS_FSB_TO_DADDR(mp, map.br_startblock); in xfs_dquot_disk_read()
471 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno, in xfs_dquot_disk_read()
475 xfs_dquot_mark_sick(dqp); in xfs_dquot_disk_read()
495 struct xfs_dquot *dqp; in xfs_dquot_alloc() local
497 dqp = kmem_cache_zalloc(xfs_dquot_cache, GFP_KERNEL | __GFP_NOFAIL); in xfs_dquot_alloc()
499 dqp->q_type = type; in xfs_dquot_alloc()
500 dqp->q_id = id; in xfs_dquot_alloc()
501 dqp->q_mount = mp; in xfs_dquot_alloc()
502 INIT_LIST_HEAD(&dqp->q_lru); in xfs_dquot_alloc()
503 mutex_init(&dqp->q_qlock); in xfs_dquot_alloc()
504 init_waitqueue_head(&dqp->q_pinwait); in xfs_dquot_alloc()
505 dqp->q_fileoffset = (xfs_fileoff_t)id / mp->m_quotainfo->qi_dqperchunk; in xfs_dquot_alloc()
509 dqp->q_bufoffset = (id % mp->m_quotainfo->qi_dqperchunk) * in xfs_dquot_alloc()
517 init_completion(&dqp->q_flush); in xfs_dquot_alloc()
518 complete(&dqp->q_flush); in xfs_dquot_alloc()
529 lockdep_set_class(&dqp->q_qlock, &xfs_dquot_group_class); in xfs_dquot_alloc()
532 lockdep_set_class(&dqp->q_qlock, &xfs_dquot_project_class); in xfs_dquot_alloc()
539 xfs_qm_dquot_logitem_init(dqp); in xfs_dquot_alloc()
542 return dqp; in xfs_dquot_alloc()
548 struct xfs_dquot *dqp, in xfs_dquot_check_type() argument
555 dqp_type = xfs_dquot_type(dqp); in xfs_dquot_check_type()
557 if (be32_to_cpu(ddqp->d_id) != dqp->q_id) in xfs_dquot_check_type()
565 if (xfs_has_crc(dqp->q_mount) || in xfs_dquot_check_type()
566 dqp_type == XFS_DQTYPE_USER || dqp->q_id != 0) in xfs_dquot_check_type()
584 struct xfs_dquot *dqp, in xfs_dquot_from_disk() argument
587 struct xfs_dqblk *dqb = xfs_buf_offset(bp, dqp->q_bufoffset); in xfs_dquot_from_disk()
594 if (!xfs_dquot_check_type(dqp, ddqp)) { in xfs_dquot_from_disk()
597 __this_address, dqp->q_id); in xfs_dquot_from_disk()
599 xfs_dquot_mark_sick(dqp); in xfs_dquot_from_disk()
604 dqp->q_type = ddqp->d_type; in xfs_dquot_from_disk()
605 dqp->q_blk.hardlimit = be64_to_cpu(ddqp->d_blk_hardlimit); in xfs_dquot_from_disk()
606 dqp->q_blk.softlimit = be64_to_cpu(ddqp->d_blk_softlimit); in xfs_dquot_from_disk()
607 dqp->q_ino.hardlimit = be64_to_cpu(ddqp->d_ino_hardlimit); in xfs_dquot_from_disk()
608 dqp->q_ino.softlimit = be64_to_cpu(ddqp->d_ino_softlimit); in xfs_dquot_from_disk()
609 dqp->q_rtb.hardlimit = be64_to_cpu(ddqp->d_rtb_hardlimit); in xfs_dquot_from_disk()
610 dqp->q_rtb.softlimit = be64_to_cpu(ddqp->d_rtb_softlimit); in xfs_dquot_from_disk()
612 dqp->q_blk.count = be64_to_cpu(ddqp->d_bcount); in xfs_dquot_from_disk()
613 dqp->q_ino.count = be64_to_cpu(ddqp->d_icount); in xfs_dquot_from_disk()
614 dqp->q_rtb.count = be64_to_cpu(ddqp->d_rtbcount); in xfs_dquot_from_disk()
616 dqp->q_blk.timer = xfs_dquot_from_disk_ts(ddqp, ddqp->d_btimer); in xfs_dquot_from_disk()
617 dqp->q_ino.timer = xfs_dquot_from_disk_ts(ddqp, ddqp->d_itimer); in xfs_dquot_from_disk()
618 dqp->q_rtb.timer = xfs_dquot_from_disk_ts(ddqp, ddqp->d_rtbtimer); in xfs_dquot_from_disk()
624 dqp->q_blk.reserved = dqp->q_blk.count; in xfs_dquot_from_disk()
625 dqp->q_ino.reserved = dqp->q_ino.count; in xfs_dquot_from_disk()
626 dqp->q_rtb.reserved = dqp->q_rtb.count; in xfs_dquot_from_disk()
629 xfs_dquot_set_prealloc_limits(dqp); in xfs_dquot_from_disk()
637 struct xfs_dquot *dqp) in xfs_dquot_to_disk() argument
641 ddqp->d_type = dqp->q_type; in xfs_dquot_to_disk()
642 ddqp->d_id = cpu_to_be32(dqp->q_id); in xfs_dquot_to_disk()
646 ddqp->d_blk_hardlimit = cpu_to_be64(dqp->q_blk.hardlimit); in xfs_dquot_to_disk()
647 ddqp->d_blk_softlimit = cpu_to_be64(dqp->q_blk.softlimit); in xfs_dquot_to_disk()
648 ddqp->d_ino_hardlimit = cpu_to_be64(dqp->q_ino.hardlimit); in xfs_dquot_to_disk()
649 ddqp->d_ino_softlimit = cpu_to_be64(dqp->q_ino.softlimit); in xfs_dquot_to_disk()
650 ddqp->d_rtb_hardlimit = cpu_to_be64(dqp->q_rtb.hardlimit); in xfs_dquot_to_disk()
651 ddqp->d_rtb_softlimit = cpu_to_be64(dqp->q_rtb.softlimit); in xfs_dquot_to_disk()
653 ddqp->d_bcount = cpu_to_be64(dqp->q_blk.count); in xfs_dquot_to_disk()
654 ddqp->d_icount = cpu_to_be64(dqp->q_ino.count); in xfs_dquot_to_disk()
655 ddqp->d_rtbcount = cpu_to_be64(dqp->q_rtb.count); in xfs_dquot_to_disk()
661 ddqp->d_btimer = xfs_dquot_to_disk_ts(dqp, dqp->q_blk.timer); in xfs_dquot_to_disk()
662 ddqp->d_itimer = xfs_dquot_to_disk_ts(dqp, dqp->q_ino.timer); in xfs_dquot_to_disk()
663 ddqp->d_rtbtimer = xfs_dquot_to_disk_ts(dqp, dqp->q_rtb.timer); in xfs_dquot_to_disk()
679 struct xfs_dquot *dqp; in xfs_qm_dqread() local
683 dqp = xfs_dquot_alloc(mp, id, type); in xfs_qm_dqread()
684 trace_xfs_dqread(dqp); in xfs_qm_dqread()
687 error = xfs_dquot_disk_read(mp, dqp, &bp); in xfs_qm_dqread()
689 error = xfs_dquot_disk_alloc(dqp, &bp); in xfs_qm_dqread()
700 error = xfs_dquot_from_disk(dqp, bp); in xfs_qm_dqread()
705 *dqpp = dqp; in xfs_qm_dqread()
709 trace_xfs_dqread_fail(dqp); in xfs_qm_dqread()
710 xfs_qm_dqdestroy(dqp); in xfs_qm_dqread()
777 struct xfs_dquot *dqp; in xfs_qm_dqget_cache_lookup() local
781 dqp = radix_tree_lookup(tree, id); in xfs_qm_dqget_cache_lookup()
782 if (!dqp) { in xfs_qm_dqget_cache_lookup()
788 xfs_dqlock(dqp); in xfs_qm_dqget_cache_lookup()
789 if (dqp->q_flags & XFS_DQFLAG_FREEING) { in xfs_qm_dqget_cache_lookup()
790 xfs_dqunlock(dqp); in xfs_qm_dqget_cache_lookup()
792 trace_xfs_dqget_freeing(dqp); in xfs_qm_dqget_cache_lookup()
797 dqp->q_nrefs++; in xfs_qm_dqget_cache_lookup()
800 trace_xfs_dqget_hit(dqp); in xfs_qm_dqget_cache_lookup()
802 return dqp; in xfs_qm_dqget_cache_lookup()
823 struct xfs_dquot *dqp) in xfs_qm_dqget_cache_insert() argument
830 error = radix_tree_insert(tree, id, dqp); in xfs_qm_dqget_cache_insert()
833 trace_xfs_dqget_dup(dqp); in xfs_qm_dqget_cache_insert()
838 xfs_dqlock(dqp); in xfs_qm_dqget_cache_insert()
839 dqp->q_nrefs = 1; in xfs_qm_dqget_cache_insert()
887 struct xfs_dquot *dqp; in xfs_qm_dqget() local
895 dqp = xfs_qm_dqget_cache_lookup(mp, qi, tree, id); in xfs_qm_dqget()
896 if (dqp) { in xfs_qm_dqget()
897 *O_dqpp = dqp; in xfs_qm_dqget()
901 error = xfs_qm_dqread(mp, id, type, can_alloc, &dqp); in xfs_qm_dqget()
905 error = xfs_qm_dqget_cache_insert(mp, qi, tree, id, dqp); in xfs_qm_dqget()
911 xfs_qm_dqdestroy(dqp); in xfs_qm_dqget()
916 trace_xfs_dqget_miss(dqp); in xfs_qm_dqget()
917 *O_dqpp = dqp; in xfs_qm_dqget()
976 struct xfs_dquot *dqp; in xfs_qm_dqget_inode() local
990 dqp = xfs_qm_dqget_cache_lookup(mp, qi, tree, id); in xfs_qm_dqget_inode()
991 if (dqp) { in xfs_qm_dqget_inode()
992 *O_dqpp = dqp; in xfs_qm_dqget_inode()
1004 error = xfs_qm_dqread(mp, id, type, can_alloc, &dqp); in xfs_qm_dqget_inode()
1018 xfs_qm_dqdestroy(dqp); in xfs_qm_dqget_inode()
1019 dqp = dqp1; in xfs_qm_dqget_inode()
1020 xfs_dqlock(dqp); in xfs_qm_dqget_inode()
1025 xfs_qm_dqdestroy(dqp); in xfs_qm_dqget_inode()
1029 error = xfs_qm_dqget_cache_insert(mp, qi, tree, id, dqp); in xfs_qm_dqget_inode()
1035 xfs_qm_dqdestroy(dqp); in xfs_qm_dqget_inode()
1042 trace_xfs_dqget_miss(dqp); in xfs_qm_dqget_inode()
1043 *O_dqpp = dqp; in xfs_qm_dqget_inode()
1058 struct xfs_dquot *dqp; in xfs_qm_dqget_next() local
1063 error = xfs_qm_dqget(mp, id, type, false, &dqp); in xfs_qm_dqget_next()
1069 if (!XFS_IS_DQUOT_UNINITIALIZED(dqp)) { in xfs_qm_dqget_next()
1070 *dqpp = dqp; in xfs_qm_dqget_next()
1074 xfs_qm_dqput(dqp); in xfs_qm_dqget_next()
1088 struct xfs_dquot *dqp) in xfs_qm_dqput() argument
1090 ASSERT(dqp->q_nrefs > 0); in xfs_qm_dqput()
1091 ASSERT(XFS_DQ_IS_LOCKED(dqp)); in xfs_qm_dqput()
1093 trace_xfs_dqput(dqp); in xfs_qm_dqput()
1095 if (--dqp->q_nrefs == 0) { in xfs_qm_dqput()
1096 struct xfs_quotainfo *qi = dqp->q_mount->m_quotainfo; in xfs_qm_dqput()
1097 trace_xfs_dqput_free(dqp); in xfs_qm_dqput()
1099 if (list_lru_add_obj(&qi->qi_lru, &dqp->q_lru)) in xfs_qm_dqput()
1100 XFS_STATS_INC(dqp->q_mount, xs_qm_dquot_unused); in xfs_qm_dqput()
1102 xfs_dqunlock(dqp); in xfs_qm_dqput()
1111 struct xfs_dquot *dqp) in xfs_qm_dqrele() argument
1113 if (!dqp) in xfs_qm_dqrele()
1116 trace_xfs_dqrele(dqp); in xfs_qm_dqrele()
1118 xfs_dqlock(dqp); in xfs_qm_dqrele()
1125 xfs_qm_dqput(dqp); in xfs_qm_dqrele()
1140 struct xfs_dquot *dqp = qip->qli_dquot; in xfs_qm_dqflush_done() local
1170 xfs_dqfunlock(dqp); in xfs_qm_dqflush_done()
1200 struct xfs_dquot *dqp) in xfs_qm_dqflush_check() argument
1202 xfs_dqtype_t type = xfs_dquot_type(dqp); in xfs_qm_dqflush_check()
1209 if (dqp->q_id == 0) in xfs_qm_dqflush_check()
1212 if (dqp->q_blk.softlimit && dqp->q_blk.count > dqp->q_blk.softlimit && in xfs_qm_dqflush_check()
1213 !dqp->q_blk.timer) in xfs_qm_dqflush_check()
1216 if (dqp->q_ino.softlimit && dqp->q_ino.count > dqp->q_ino.softlimit && in xfs_qm_dqflush_check()
1217 !dqp->q_ino.timer) in xfs_qm_dqflush_check()
1220 if (dqp->q_rtb.softlimit && dqp->q_rtb.count > dqp->q_rtb.softlimit && in xfs_qm_dqflush_check()
1221 !dqp->q_rtb.timer) in xfs_qm_dqflush_check()
1225 if (dqp->q_type & XFS_DQTYPE_BIGTIME) { in xfs_qm_dqflush_check()
1226 if (!xfs_has_bigtime(dqp->q_mount)) in xfs_qm_dqflush_check()
1228 if (dqp->q_id == 0) in xfs_qm_dqflush_check()
1245 struct xfs_dquot *dqp, in xfs_qm_dqflush() argument
1248 struct xfs_mount *mp = dqp->q_mount; in xfs_qm_dqflush()
1249 struct xfs_log_item *lip = &dqp->q_logitem.qli_item; in xfs_qm_dqflush()
1255 ASSERT(XFS_DQ_IS_LOCKED(dqp)); in xfs_qm_dqflush()
1256 ASSERT(!completion_done(&dqp->q_flush)); in xfs_qm_dqflush()
1258 trace_xfs_dqflush(dqp); in xfs_qm_dqflush()
1262 xfs_qm_dqunpin_wait(dqp); in xfs_qm_dqflush()
1267 error = xfs_trans_read_buf(mp, NULL, mp->m_ddev_targp, dqp->q_blkno, in xfs_qm_dqflush()
1273 xfs_dquot_mark_sick(dqp); in xfs_qm_dqflush()
1277 fa = xfs_qm_dqflush_check(dqp); in xfs_qm_dqflush()
1280 dqp->q_id, fa); in xfs_qm_dqflush()
1282 xfs_dquot_mark_sick(dqp); in xfs_qm_dqflush()
1288 dqblk = xfs_buf_offset(bp, dqp->q_bufoffset); in xfs_qm_dqflush()
1289 xfs_dquot_to_disk(&dqblk->dd_diskdq, dqp); in xfs_qm_dqflush()
1294 dqp->q_flags &= ~XFS_DQFLAG_DIRTY; in xfs_qm_dqflush()
1296 xfs_trans_ail_copy_lsn(mp->m_ail, &dqp->q_logitem.qli_flush_lsn, in xfs_qm_dqflush()
1297 &dqp->q_logitem.qli_item.li_lsn); in xfs_qm_dqflush()
1309 dqblk->dd_lsn = cpu_to_be64(dqp->q_logitem.qli_item.li_lsn); in xfs_qm_dqflush()
1319 list_add_tail(&dqp->q_logitem.qli_item.li_bio_list, &bp->b_li_list); in xfs_qm_dqflush()
1326 trace_xfs_dqflush_force(dqp); in xfs_qm_dqflush()
1330 trace_xfs_dqflush_done(dqp); in xfs_qm_dqflush()
1335 dqp->q_flags &= ~XFS_DQFLAG_DIRTY; in xfs_qm_dqflush()
1339 xfs_dqfunlock(dqp); in xfs_qm_dqflush()