Lines Matching refs:dquot
38 * Write updated not to require dquot lock
90 * * dquot->dq_dqb_lock protects data from dq_dqb
92 * consistency of dquot->dq_dqb with inode->i_blocks, i_bytes so that
94 * * dq_data_lock protects mem_dqinfo structures and modifications of dquot
100 * dq_data_lock > dq_list_lock > i_lock > dquot->dq_dqb_lock,
104 * the life of the dquot structure and so needn't to be protected by a lock
109 * inode and before dropping dquot references to avoid use of dquots after
119 * Each dquot has its dq_lock mutex. Dquot is locked when it is being read to
126 * s_umount > i_mutex > journal_lock > dquot->dq_lock > dqio_sem
163 /* SLAB cache for dquot structures */
228 * The quota code uses five lists for dquot management: the inuse_list,
230 * A single dquot structure may be on some of those lists, depending on
234 * list is used for invalidate operation, which must look at every dquot.
236 * When the last reference of a dquot is dropped, the dquot is added to
239 * dquots on the list. Each cleaned up dquot is moved to free_dquots list.
240 * Both releasing_dquots and free_dquots use the dq_free list_head in the dquot
244 * searched whenever we need an available dquot. Dquots are removed from the
246 * of dquots on the list. When dquot is invalidated it's completely released
251 * quota file. Note that some filesystems do dirty dquot tracking on their
256 * mechanism to locate a specific dquot.
289 static inline void insert_dquot_hash(struct dquot *dquot)
292 head = dquot_hash + hashfn(dquot->dq_sb, dquot->dq_id);
293 hlist_add_head(&dquot->dq_hash, head);
296 static inline void remove_dquot_hash(struct dquot *dquot)
298 hlist_del_init(&dquot->dq_hash);
301 static struct dquot *find_dquot(unsigned int hashent, struct super_block *sb,
305 struct dquot *dquot;
308 dquot = hlist_entry(node, struct dquot, dq_hash);
309 if (dquot->dq_sb == sb && qid_eq(dquot->dq_id, qid))
310 return dquot;
315 /* Add a dquot to the tail of the free list */
316 static inline void put_dquot_last(struct dquot *dquot)
318 list_add_tail(&dquot->dq_free, &free_dquots);
322 static inline void put_releasing_dquots(struct dquot *dquot)
324 list_add_tail(&dquot->dq_free, &releasing_dquots);
325 set_bit(DQ_RELEASING_B, &dquot->dq_flags);
328 static inline void remove_free_dquot(struct dquot *dquot)
330 if (list_empty(&dquot->dq_free))
332 list_del_init(&dquot->dq_free);
333 if (!test_bit(DQ_RELEASING_B, &dquot->dq_flags))
336 clear_bit(DQ_RELEASING_B, &dquot->dq_flags);
339 static inline void put_inuse(struct dquot *dquot)
343 list_add_tail(&dquot->dq_inuse, &inuse_list);
347 static inline void remove_inuse(struct dquot *dquot)
350 list_del(&dquot->dq_inuse);
356 static void wait_on_dquot(struct dquot *dquot)
358 mutex_lock(&dquot->dq_lock);
359 mutex_unlock(&dquot->dq_lock);
362 static inline int dquot_active(struct dquot *dquot)
364 return test_bit(DQ_ACTIVE_B, &dquot->dq_flags);
367 static inline int dquot_dirty(struct dquot *dquot)
369 return test_bit(DQ_MOD_B, &dquot->dq_flags);
372 static inline int mark_dquot_dirty(struct dquot *dquot)
374 return dquot->dq_sb->dq_op->mark_dirty(dquot);
377 /* Mark dquot dirty in atomic manner, and return it's old dirty flag state */
378 int dquot_mark_dquot_dirty(struct dquot *dquot)
382 if (!dquot_active(dquot))
385 if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NOLIST_DIRTY)
386 return test_and_set_bit(DQ_MOD_B, &dquot->dq_flags);
389 if (dquot_dirty(dquot))
393 if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) {
394 list_add(&dquot->dq_dirty, &sb_dqopt(dquot->dq_sb)->
395 info[dquot->dq_id.type].dqi_dirty_list);
404 static inline int mark_all_dquot_dirty(struct dquot * const *dquots)
407 struct dquot *dquot;
411 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
412 if (dquot)
414 ret = mark_dquot_dirty(dquot);
421 static inline void dqput_all(struct dquot **dquot)
426 dqput(dquot[cnt]);
429 static inline int clear_dquot_dirty(struct dquot *dquot)
431 if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NOLIST_DIRTY)
432 return test_and_clear_bit(DQ_MOD_B, &dquot->dq_flags);
435 if (!test_and_clear_bit(DQ_MOD_B, &dquot->dq_flags)) {
439 list_del_init(&dquot->dq_dirty);
453 * Read dquot from disk and alloc space for it
456 int dquot_acquire(struct dquot *dquot)
460 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
462 mutex_lock(&dquot->dq_lock);
464 if (!test_bit(DQ_READ_B, &dquot->dq_flags)) {
465 ret = dqopt->ops[dquot->dq_id.type]->read_dqblk(dquot);
469 /* Make sure flags update is visible after dquot has been filled */
471 set_bit(DQ_READ_B, &dquot->dq_flags);
472 /* Instantiate dquot if needed */
473 if (!dquot_active(dquot) && !dquot->dq_off) {
474 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
476 if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
477 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
478 dquot->dq_sb, dquot->dq_id.type);
492 set_bit(DQ_ACTIVE_B, &dquot->dq_flags);
495 mutex_unlock(&dquot->dq_lock);
501 * Write dquot to disk
503 int dquot_commit(struct dquot *dquot)
507 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
509 mutex_lock(&dquot->dq_lock);
511 if (!clear_dquot_dirty(dquot))
513 /* Inactive dquot can be only if there was error during read/init
515 if (dquot_active(dquot))
516 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
521 mutex_unlock(&dquot->dq_lock);
527 * Release dquot
529 int dquot_release(struct dquot *dquot)
533 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
535 mutex_lock(&dquot->dq_lock);
538 if (dquot_is_busy(dquot))
540 if (dqopt->ops[dquot->dq_id.type]->release_dqblk) {
541 ret = dqopt->ops[dquot->dq_id.type]->release_dqblk(dquot);
543 if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
544 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
545 dquot->dq_sb, dquot->dq_id.type);
550 clear_bit(DQ_ACTIVE_B, &dquot->dq_flags);
553 mutex_unlock(&dquot->dq_lock);
558 void dquot_destroy(struct dquot *dquot)
560 kmem_cache_free(dquot_cachep, dquot);
564 static inline void do_destroy_dquot(struct dquot *dquot)
566 dquot->dq_sb->dq_op->destroy_dquot(dquot);
577 struct dquot *dquot, *tmp;
583 list_for_each_entry_safe(dquot, tmp, &inuse_list, dq_inuse) {
584 if (dquot->dq_sb != sb)
586 if (dquot->dq_id.type != type)
588 /* Wait for dquot users */
589 if (atomic_read(&dquot->dq_count)) {
590 atomic_inc(&dquot->dq_count);
594 * the dquot.
596 * at most one process waiting for dquot to free.
601 atomic_read(&dquot->dq_count) == 1);
602 dqput(dquot);
603 /* At this moment dquot() need not exist (it could be
609 * The last user already dropped its reference but dquot didn't
613 if (test_bit(DQ_RELEASING_B, &dquot->dq_flags)) {
621 remove_dquot_hash(dquot);
622 remove_free_dquot(dquot);
623 remove_inuse(dquot);
624 do_destroy_dquot(dquot);
629 /* Call callback for every active dquot on given filesystem */
631 int (*fn)(struct dquot *dquot, unsigned long priv),
634 struct dquot *dquot, *old_dquot = NULL;
640 list_for_each_entry(dquot, &inuse_list, dq_inuse) {
641 if (!dquot_active(dquot))
643 if (dquot->dq_sb != sb)
645 /* Now we have active dquot so we can just increase use count */
646 atomic_inc(&dquot->dq_count);
649 old_dquot = dquot;
655 wait_on_dquot(dquot);
656 if (dquot_active(dquot)) {
657 ret = fn(dquot, priv);
662 /* We are safe to continue now because our dquot could not
672 static inline int dquot_write_dquot(struct dquot *dquot)
674 int ret = dquot->dq_sb->dq_op->write_dquot(dquot);
676 quota_error(dquot->dq_sb, "Can't write quota structure "
679 clear_dquot_dirty(dquot);
684 /* Write all dquot structures to quota files */
688 struct dquot *dquot;
704 dquot = list_first_entry(&dirty, struct dquot,
707 WARN_ON(!dquot_active(dquot));
708 /* If the dquot is releasing we should not touch it */
709 if (test_bit(DQ_RELEASING_B, &dquot->dq_flags)) {
716 /* Now we have active dquot from which someone is
719 dqgrab(dquot);
721 err = dquot_write_dquot(dquot);
724 dqput(dquot);
740 /* Write all dquot structures to disk and make them visible from userspace */
786 struct dquot *dquot;
791 dquot = list_first_entry(&free_dquots, struct dquot, dq_free);
792 remove_dquot_hash(dquot);
793 remove_free_dquot(dquot);
794 remove_inuse(dquot);
795 do_destroy_dquot(dquot);
817 * Safely release dquot and put reference to dquot.
821 struct dquot *dquot;
833 dquot = list_first_entry(&rls_head, struct dquot, dq_free);
834 WARN_ON_ONCE(atomic_read(&dquot->dq_count));
838 * dquot even after we drop dq_list_lock.
840 if (dquot_dirty(dquot)) {
842 /* Commit dquot before releasing */
843 dquot_write_dquot(dquot);
846 if (dquot_active(dquot)) {
848 dquot->dq_sb->dq_op->release_dquot(dquot);
852 remove_free_dquot(dquot);
853 put_dquot_last(dquot);
859 * Put reference to dquot
861 void dqput(struct dquot *dquot)
863 if (!dquot)
866 if (!atomic_read(&dquot->dq_count)) {
867 quota_error(dquot->dq_sb, "trying to free free dquot of %s %d",
868 quotatypes[dquot->dq_id.type],
869 from_kqid(&init_user_ns, dquot->dq_id));
876 if (atomic_read(&dquot->dq_count) > 1) {
878 atomic_dec(&dquot->dq_count);
879 /* Releasing dquot during quotaoff phase? */
880 if (!sb_has_quota_active(dquot->dq_sb, dquot->dq_id.type) &&
881 atomic_read(&dquot->dq_count) == 1)
887 /* Need to release dquot? */
890 BUG_ON(!list_empty(&dquot->dq_free));
892 put_releasing_dquots(dquot);
893 atomic_dec(&dquot->dq_count);
899 struct dquot *dquot_alloc(struct super_block *sb, int type)
905 static struct dquot *get_empty_dquot(struct super_block *sb, int type)
907 struct dquot *dquot;
909 dquot = sb->dq_op->alloc_dquot(sb, type);
910 if(!dquot)
913 mutex_init(&dquot->dq_lock);
914 INIT_LIST_HEAD(&dquot->dq_free);
915 INIT_LIST_HEAD(&dquot->dq_inuse);
916 INIT_HLIST_NODE(&dquot->dq_hash);
917 INIT_LIST_HEAD(&dquot->dq_dirty);
918 dquot->dq_sb = sb;
919 dquot->dq_id = make_kqid_invalid(type);
920 atomic_set(&dquot->dq_count, 1);
921 spin_lock_init(&dquot->dq_dqb_lock);
923 return dquot;
927 * Get reference to dquot
930 * destroying our dquot by:
932 * b) getting a reference to dquot before we release dq_list_lock
934 struct dquot *dqget(struct super_block *sb, struct kqid qid)
937 struct dquot *dquot, *empty = NULL;
950 dquot = ERR_PTR(-ESRCH);
955 dquot = find_dquot(hashent, sb, qid);
956 if (!dquot) {
964 dquot = empty;
966 dquot->dq_id = qid;
968 put_inuse(dquot);
970 insert_dquot_hash(dquot);
974 if (!atomic_read(&dquot->dq_count))
975 remove_free_dquot(dquot);
976 atomic_inc(&dquot->dq_count);
983 wait_on_dquot(dquot);
984 /* Read the dquot / allocate space in quota file */
985 if (!dquot_active(dquot)) {
988 err = sb->dq_op->acquire_dquot(dquot);
990 dqput(dquot);
991 dquot = ERR_PTR(err);
1001 BUG_ON(!dquot->dq_sb); /* Has somebody invalidated entry under us? */
1007 return dquot;
1011 static inline struct dquot **i_dquot(struct inode *inode)
1018 struct dquot * const *dquots;
1092 * Remove references to dquots from inode and add dquot to list for freeing
1093 * if we have the last reference to dquot
1098 struct dquot **dquots = i_dquot(inode);
1099 struct dquot *dquot = dquots[type];
1101 if (!dquot)
1105 if (list_empty(&dquot->dq_free)) {
1107 * The inode still has reference to dquot so it can't be in the
1111 list_add(&dquot->dq_free, tofree_head);
1118 dqput(dquot);
1130 struct dquot *dquot;
1134 dquot = list_entry(act_head, struct dquot, dq_free);
1136 /* Remove dquot from the list so we won't have problems... */
1137 list_del_init(&dquot->dq_free);
1138 dqput(dquot);
1191 void dquot_free_reserved_space(struct dquot *dquot, qsize_t number)
1193 if (dquot->dq_dqb.dqb_rsvspace >= number)
1194 dquot->dq_dqb.dqb_rsvspace -= number;
1197 dquot->dq_dqb.dqb_rsvspace = 0;
1199 if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <=
1200 dquot->dq_dqb.dqb_bsoftlimit)
1201 dquot->dq_dqb.dqb_btime = (time64_t) 0;
1202 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
1205 static void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
1207 if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE ||
1208 dquot->dq_dqb.dqb_curinodes >= number)
1209 dquot->dq_dqb.dqb_curinodes -= number;
1211 dquot->dq_dqb.dqb_curinodes = 0;
1212 if (dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit)
1213 dquot->dq_dqb.dqb_itime = (time64_t) 0;
1214 clear_bit(DQ_INODES_B, &dquot->dq_flags);
1217 static void dquot_decr_space(struct dquot *dquot, qsize_t number)
1219 if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE ||
1220 dquot->dq_dqb.dqb_curspace >= number)
1221 dquot->dq_dqb.dqb_curspace -= number;
1223 dquot->dq_dqb.dqb_curspace = 0;
1224 if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <=
1225 dquot->dq_dqb.dqb_bsoftlimit)
1226 dquot->dq_dqb.dqb_btime = (time64_t) 0;
1227 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
1236 static int warning_issued(struct dquot *dquot, const int warntype)
1245 return test_and_set_bit(flag, &dquot->dq_flags);
1314 static void prepare_warning(struct dquot_warn *warn, struct dquot *dquot,
1317 if (warning_issued(dquot, warntype))
1320 warn->w_sb = dquot->dq_sb;
1321 warn->w_dq_id = dquot->dq_id;
1344 static int ignore_hardlimit(struct dquot *dquot)
1346 struct mem_dqinfo *info = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type];
1353 static int dquot_add_inodes(struct dquot *dquot, qsize_t inodes,
1359 spin_lock(&dquot->dq_dqb_lock);
1360 newinodes = dquot->dq_dqb.dqb_curinodes + inodes;
1361 if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_id.type) ||
1362 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1365 if (dquot->dq_dqb.dqb_ihardlimit &&
1366 newinodes > dquot->dq_dqb.dqb_ihardlimit &&
1367 !ignore_hardlimit(dquot)) {
1368 prepare_warning(warn, dquot, QUOTA_NL_IHARDWARN);
1373 if (dquot->dq_dqb.dqb_isoftlimit &&
1374 newinodes > dquot->dq_dqb.dqb_isoftlimit &&
1375 dquot->dq_dqb.dqb_itime &&
1376 ktime_get_real_seconds() >= dquot->dq_dqb.dqb_itime &&
1377 !ignore_hardlimit(dquot)) {
1378 prepare_warning(warn, dquot, QUOTA_NL_ISOFTLONGWARN);
1383 if (dquot->dq_dqb.dqb_isoftlimit &&
1384 newinodes > dquot->dq_dqb.dqb_isoftlimit &&
1385 dquot->dq_dqb.dqb_itime == 0) {
1386 prepare_warning(warn, dquot, QUOTA_NL_ISOFTWARN);
1387 dquot->dq_dqb.dqb_itime = ktime_get_real_seconds() +
1388 sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type].dqi_igrace;
1391 dquot->dq_dqb.dqb_curinodes = newinodes;
1394 spin_unlock(&dquot->dq_dqb_lock);
1398 static int dquot_add_space(struct dquot *dquot, qsize_t space,
1403 struct super_block *sb = dquot->dq_sb;
1406 spin_lock(&dquot->dq_dqb_lock);
1407 if (!sb_has_quota_limits_enabled(sb, dquot->dq_id.type) ||
1408 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1411 tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace
1414 if (dquot->dq_dqb.dqb_bhardlimit &&
1415 tspace > dquot->dq_dqb.dqb_bhardlimit &&
1416 !ignore_hardlimit(dquot)) {
1418 prepare_warning(warn, dquot, QUOTA_NL_BHARDWARN);
1423 if (dquot->dq_dqb.dqb_bsoftlimit &&
1424 tspace > dquot->dq_dqb.dqb_bsoftlimit &&
1425 dquot->dq_dqb.dqb_btime &&
1426 ktime_get_real_seconds() >= dquot->dq_dqb.dqb_btime &&
1427 !ignore_hardlimit(dquot)) {
1429 prepare_warning(warn, dquot, QUOTA_NL_BSOFTLONGWARN);
1434 if (dquot->dq_dqb.dqb_bsoftlimit &&
1435 tspace > dquot->dq_dqb.dqb_bsoftlimit &&
1436 dquot->dq_dqb.dqb_btime == 0) {
1438 prepare_warning(warn, dquot, QUOTA_NL_BSOFTWARN);
1439 dquot->dq_dqb.dqb_btime = ktime_get_real_seconds() +
1440 sb_dqopt(sb)->info[dquot->dq_id.type].dqi_bgrace;
1459 dquot->dq_dqb.dqb_rsvspace += rsv_space;
1460 dquot->dq_dqb.dqb_curspace += space;
1462 spin_unlock(&dquot->dq_dqb_lock);
1466 static int info_idq_free(struct dquot *dquot, qsize_t inodes)
1470 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
1471 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit ||
1472 !sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_id.type))
1475 newinodes = dquot->dq_dqb.dqb_curinodes - inodes;
1476 if (newinodes <= dquot->dq_dqb.dqb_isoftlimit)
1478 if (dquot->dq_dqb.dqb_curinodes >= dquot->dq_dqb.dqb_ihardlimit &&
1479 newinodes < dquot->dq_dqb.dqb_ihardlimit)
1484 static int info_bdq_free(struct dquot *dquot, qsize_t space)
1488 tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace;
1490 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
1491 tspace <= dquot->dq_dqb.dqb_bsoftlimit)
1494 if (tspace - space <= dquot->dq_dqb.dqb_bsoftlimit)
1496 if (tspace >= dquot->dq_dqb.dqb_bhardlimit &&
1497 tspace - space < dquot->dq_dqb.dqb_bhardlimit)
1515 * might need a lot of space in journal for dquot structure allocation.
1520 struct dquot **dquots, *got[MAXQUOTAS] = {};
1535 struct dquot *dquot;
1566 dquot = dqget(sb, qid);
1567 if (IS_ERR(dquot)) {
1569 if (PTR_ERR(dquot) != -ESRCH) {
1570 ret = PTR_ERR(dquot);
1573 dquot = NULL;
1575 got[cnt] = dquot;
1630 struct dquot **dquots;
1655 struct dquot **dquots = i_dquot(inode);
1656 struct dquot *put[MAXQUOTAS];
1669 struct dquot * const *dquots;
1730 * the current transaction so that dquot write and inode write go into the
1742 struct dquot **dquots;
1743 struct dquot *dquot;
1763 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1764 if (!dquot)
1767 ret = dquot_add_space(dquot, 0, number, flags, &warn[cnt]);
1769 ret = dquot_add_space(dquot, number, 0, flags, &warn[cnt]);
1774 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1775 if (!dquot)
1777 spin_lock(&dquot->dq_dqb_lock);
1779 dquot_free_reserved_space(dquot, number);
1781 dquot_decr_space(dquot, number);
1782 spin_unlock(&dquot->dq_dqb_lock);
1812 struct dquot * const *dquots;
1813 struct dquot *dquot;
1824 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1825 if (!dquot)
1827 ret = dquot_add_inodes(dquot, 1, &warn[cnt]);
1830 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1831 if (!dquot)
1834 spin_lock(&dquot->dq_dqb_lock);
1835 dquot_decr_inodes(dquot, 1);
1836 spin_unlock(&dquot->dq_dqb_lock);
1857 struct dquot **dquots;
1858 struct dquot *dquot;
1874 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1875 if (dquot) {
1876 spin_lock(&dquot->dq_dqb_lock);
1877 if (WARN_ON_ONCE(dquot->dq_dqb.dqb_rsvspace < number))
1878 number = dquot->dq_dqb.dqb_rsvspace;
1879 dquot->dq_dqb.dqb_curspace += number;
1880 dquot->dq_dqb.dqb_rsvspace -= number;
1881 spin_unlock(&dquot->dq_dqb_lock);
1899 struct dquot **dquots;
1900 struct dquot *dquot;
1916 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1917 if (dquot) {
1918 spin_lock(&dquot->dq_dqb_lock);
1919 if (WARN_ON_ONCE(dquot->dq_dqb.dqb_curspace < number))
1920 number = dquot->dq_dqb.dqb_curspace;
1921 dquot->dq_dqb.dqb_rsvspace += number;
1922 dquot->dq_dqb.dqb_curspace -= number;
1923 spin_unlock(&dquot->dq_dqb_lock);
1943 struct dquot **dquots;
1944 struct dquot *dquot;
1965 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1966 if (!dquot)
1968 spin_lock(&dquot->dq_dqb_lock);
1969 wtype = info_bdq_free(dquot, number);
1971 prepare_warning(&warn[cnt], dquot, wtype);
1973 dquot_free_reserved_space(dquot, number);
1975 dquot_decr_space(dquot, number);
1976 spin_unlock(&dquot->dq_dqb_lock);
2000 struct dquot * const *dquots;
2001 struct dquot *dquot;
2013 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
2014 if (!dquot)
2016 spin_lock(&dquot->dq_dqb_lock);
2017 wtype = info_idq_free(dquot, 1);
2019 prepare_warning(&warn[cnt], dquot, wtype);
2020 dquot_decr_inodes(dquot, 1);
2021 spin_unlock(&dquot->dq_dqb_lock);
2032 * On success, dquot references in transfer_to are consumed and references
2042 int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
2047 struct dquot *transfer_from[MAXQUOTAS] = {};
2138 * These arrays are local and we hold dquot references so we don't need
2178 struct dquot *transfer_to[MAXQUOTAS] = {};
2179 struct dquot *dquot;
2187 dquot = dqget(sb, make_kqid_uid(iattr->ia_uid));
2188 if (IS_ERR(dquot)) {
2189 if (PTR_ERR(dquot) != -ESRCH) {
2190 ret = PTR_ERR(dquot);
2193 dquot = NULL;
2195 transfer_to[USRQUOTA] = dquot;
2198 dquot = dqget(sb, make_kqid_gid(iattr->ia_gid));
2199 if (IS_ERR(dquot)) {
2200 if (PTR_ERR(dquot) != -ESRCH) {
2201 ret = PTR_ERR(dquot);
2204 dquot = NULL;
2206 transfer_to[GRPQUOTA] = dquot;
2442 * When S_NOQUOTA is set, remove dquot references as no more
2711 static void do_get_dqblk(struct dquot *dquot, struct qc_dqblk *di)
2713 struct mem_dqblk *dm = &dquot->dq_dqb;
2716 spin_lock(&dquot->dq_dqb_lock);
2725 spin_unlock(&dquot->dq_dqb_lock);
2731 struct dquot *dquot;
2733 dquot = dqget(sb, qid);
2734 if (IS_ERR(dquot))
2735 return PTR_ERR(dquot);
2736 do_get_dqblk(dquot, di);
2737 dqput(dquot);
2746 struct dquot *dquot;
2754 dquot = dqget(sb, *qid);
2755 if (IS_ERR(dquot))
2756 return PTR_ERR(dquot);
2757 do_get_dqblk(dquot, di);
2758 dqput(dquot);
2770 static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di)
2772 struct mem_dqblk *dm = &dquot->dq_dqb;
2774 struct mem_dqinfo *dqi = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type];
2789 spin_lock(&dquot->dq_dqb_lock);
2793 set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
2802 set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
2808 set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
2817 set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
2823 set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
2829 set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
2836 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
2845 clear_bit(DQ_INODES_B, &dquot->dq_flags);
2852 clear_bit(DQ_FAKE_B, &dquot->dq_flags);
2854 set_bit(DQ_FAKE_B, &dquot->dq_flags);
2855 spin_unlock(&dquot->dq_dqb_lock);
2856 mark_dquot_dirty(dquot);
2864 struct dquot *dquot;
2867 dquot = dqget(sb, qid);
2868 if (IS_ERR(dquot)) {
2869 rc = PTR_ERR(dquot);
2872 rc = do_set_dqblk(dquot, di);
2873 dqput(dquot);
3074 dquot_cachep = kmem_cache_create("dquot",
3075 sizeof(struct dquot), sizeof(unsigned long) * 4,
3083 panic("Cannot create dquot hash table");
3088 panic("Cannot create dquot stat counters");
3104 panic("Cannot register dquot shrinker");