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,
304 struct dquot *dquot;
306 hlist_for_each_entry(dquot, dquot_hash+hashent, dq_hash)
307 if (dquot->dq_sb == sb && qid_eq(dquot->dq_id, qid))
308 return dquot;
313 /* Add a dquot to the tail of the free list */
314 static inline void put_dquot_last(struct dquot *dquot)
316 list_add_tail(&dquot->dq_free, &free_dquots);
320 static inline void put_releasing_dquots(struct dquot *dquot)
322 list_add_tail(&dquot->dq_free, &releasing_dquots);
323 set_bit(DQ_RELEASING_B, &dquot->dq_flags);
326 static inline void remove_free_dquot(struct dquot *dquot)
328 if (list_empty(&dquot->dq_free))
330 list_del_init(&dquot->dq_free);
331 if (!test_bit(DQ_RELEASING_B, &dquot->dq_flags))
334 clear_bit(DQ_RELEASING_B, &dquot->dq_flags);
337 static inline void put_inuse(struct dquot *dquot)
341 list_add_tail(&dquot->dq_inuse, &inuse_list);
345 static inline void remove_inuse(struct dquot *dquot)
348 list_del(&dquot->dq_inuse);
354 static void wait_on_dquot(struct dquot *dquot)
356 mutex_lock(&dquot->dq_lock);
357 mutex_unlock(&dquot->dq_lock);
360 static inline int dquot_active(struct dquot *dquot)
362 return test_bit(DQ_ACTIVE_B, &dquot->dq_flags);
365 static inline int dquot_dirty(struct dquot *dquot)
367 return test_bit(DQ_MOD_B, &dquot->dq_flags);
370 static inline int mark_dquot_dirty(struct dquot *dquot)
372 return dquot->dq_sb->dq_op->mark_dirty(dquot);
375 /* Mark dquot dirty in atomic manner, and return it's old dirty flag state */
376 int dquot_mark_dquot_dirty(struct dquot *dquot)
380 if (!dquot_active(dquot))
383 if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NOLIST_DIRTY)
384 return test_and_set_bit(DQ_MOD_B, &dquot->dq_flags);
387 if (dquot_dirty(dquot))
391 if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) {
392 list_add(&dquot->dq_dirty, &sb_dqopt(dquot->dq_sb)->
393 info[dquot->dq_id.type].dqi_dirty_list);
402 static inline int mark_all_dquot_dirty(struct dquot __rcu * const *dquots)
405 struct dquot *dquot;
409 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
410 if (dquot)
412 ret = mark_dquot_dirty(dquot);
419 static inline void dqput_all(struct dquot **dquot)
424 dqput(dquot[cnt]);
427 static inline int clear_dquot_dirty(struct dquot *dquot)
429 if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NOLIST_DIRTY)
430 return test_and_clear_bit(DQ_MOD_B, &dquot->dq_flags);
433 if (!test_and_clear_bit(DQ_MOD_B, &dquot->dq_flags)) {
437 list_del_init(&dquot->dq_dirty);
451 * Read dquot from disk and alloc space for it
454 int dquot_acquire(struct dquot *dquot)
458 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
460 mutex_lock(&dquot->dq_lock);
462 if (!test_bit(DQ_READ_B, &dquot->dq_flags)) {
463 ret = dqopt->ops[dquot->dq_id.type]->read_dqblk(dquot);
467 /* Make sure flags update is visible after dquot has been filled */
469 set_bit(DQ_READ_B, &dquot->dq_flags);
470 /* Instantiate dquot if needed */
471 if (!dquot_active(dquot) && !dquot->dq_off) {
472 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
474 if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
475 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
476 dquot->dq_sb, dquot->dq_id.type);
490 set_bit(DQ_ACTIVE_B, &dquot->dq_flags);
493 mutex_unlock(&dquot->dq_lock);
499 * Write dquot to disk
501 int dquot_commit(struct dquot *dquot)
505 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
507 mutex_lock(&dquot->dq_lock);
509 if (!clear_dquot_dirty(dquot))
511 /* Inactive dquot can be only if there was error during read/init
513 if (dquot_active(dquot))
514 ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
519 mutex_unlock(&dquot->dq_lock);
525 * Release dquot
527 int dquot_release(struct dquot *dquot)
531 struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
533 mutex_lock(&dquot->dq_lock);
536 if (dquot_is_busy(dquot))
538 if (dqopt->ops[dquot->dq_id.type]->release_dqblk) {
539 ret = dqopt->ops[dquot->dq_id.type]->release_dqblk(dquot);
541 if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
542 ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
543 dquot->dq_sb, dquot->dq_id.type);
548 clear_bit(DQ_ACTIVE_B, &dquot->dq_flags);
551 mutex_unlock(&dquot->dq_lock);
556 void dquot_destroy(struct dquot *dquot)
558 kmem_cache_free(dquot_cachep, dquot);
562 static inline void do_destroy_dquot(struct dquot *dquot)
564 dquot->dq_sb->dq_op->destroy_dquot(dquot);
575 struct dquot *dquot, *tmp;
581 list_for_each_entry_safe(dquot, tmp, &inuse_list, dq_inuse) {
582 if (dquot->dq_sb != sb)
584 if (dquot->dq_id.type != type)
586 /* Wait for dquot users */
587 if (atomic_read(&dquot->dq_count)) {
588 atomic_inc(&dquot->dq_count);
592 * the dquot.
594 * at most one process waiting for dquot to free.
599 atomic_read(&dquot->dq_count) == 1);
600 dqput(dquot);
601 /* At this moment dquot() need not exist (it could be
607 * The last user already dropped its reference but dquot didn't
611 if (test_bit(DQ_RELEASING_B, &dquot->dq_flags)) {
619 remove_dquot_hash(dquot);
620 remove_free_dquot(dquot);
621 remove_inuse(dquot);
622 do_destroy_dquot(dquot);
627 /* Call callback for every active dquot on given filesystem */
629 int (*fn)(struct dquot *dquot, unsigned long priv),
632 struct dquot *dquot, *old_dquot = NULL;
638 list_for_each_entry(dquot, &inuse_list, dq_inuse) {
639 if (!dquot_active(dquot))
641 if (dquot->dq_sb != sb)
643 /* Now we have active dquot so we can just increase use count */
644 atomic_inc(&dquot->dq_count);
647 old_dquot = dquot;
653 wait_on_dquot(dquot);
654 if (dquot_active(dquot)) {
655 ret = fn(dquot, priv);
660 /* We are safe to continue now because our dquot could not
670 static inline int dquot_write_dquot(struct dquot *dquot)
672 int ret = dquot->dq_sb->dq_op->write_dquot(dquot);
674 quota_error(dquot->dq_sb, "Can't write quota structure "
677 clear_dquot_dirty(dquot);
682 /* Write all dquot structures to quota files */
686 struct dquot *dquot;
702 dquot = list_first_entry(&dirty, struct dquot,
705 WARN_ON(!dquot_active(dquot));
706 /* If the dquot is releasing we should not touch it */
707 if (test_bit(DQ_RELEASING_B, &dquot->dq_flags)) {
714 /* Now we have active dquot from which someone is
717 dqgrab(dquot);
719 err = dquot_write_dquot(dquot);
722 dqput(dquot);
738 /* Write all dquot structures to disk and make them visible from userspace */
784 struct dquot *dquot;
789 dquot = list_first_entry(&free_dquots, struct dquot, dq_free);
790 remove_dquot_hash(dquot);
791 remove_free_dquot(dquot);
792 remove_inuse(dquot);
793 do_destroy_dquot(dquot);
815 * Safely release dquot and put reference to dquot.
819 struct dquot *dquot;
831 dquot = list_first_entry(&rls_head, struct dquot, dq_free);
832 WARN_ON_ONCE(atomic_read(&dquot->dq_count));
836 * dquot even after we drop dq_list_lock.
838 if (dquot_dirty(dquot)) {
840 /* Commit dquot before releasing */
841 dquot_write_dquot(dquot);
844 if (dquot_active(dquot)) {
846 dquot->dq_sb->dq_op->release_dquot(dquot);
850 remove_free_dquot(dquot);
851 put_dquot_last(dquot);
857 * Put reference to dquot
859 void dqput(struct dquot *dquot)
861 if (!dquot)
864 if (!atomic_read(&dquot->dq_count)) {
865 quota_error(dquot->dq_sb, "trying to free free dquot of %s %d",
866 quotatypes[dquot->dq_id.type],
867 from_kqid(&init_user_ns, dquot->dq_id));
874 if (atomic_read(&dquot->dq_count) > 1) {
876 atomic_dec(&dquot->dq_count);
877 /* Releasing dquot during quotaoff phase? */
878 if (!sb_has_quota_active(dquot->dq_sb, dquot->dq_id.type) &&
879 atomic_read(&dquot->dq_count) == 1)
885 /* Need to release dquot? */
888 BUG_ON(!list_empty(&dquot->dq_free));
890 put_releasing_dquots(dquot);
891 atomic_dec(&dquot->dq_count);
897 struct dquot *dquot_alloc(struct super_block *sb, int type)
903 static struct dquot *get_empty_dquot(struct super_block *sb, int type)
905 struct dquot *dquot;
907 dquot = sb->dq_op->alloc_dquot(sb, type);
908 if(!dquot)
911 mutex_init(&dquot->dq_lock);
912 INIT_LIST_HEAD(&dquot->dq_free);
913 INIT_LIST_HEAD(&dquot->dq_inuse);
914 INIT_HLIST_NODE(&dquot->dq_hash);
915 INIT_LIST_HEAD(&dquot->dq_dirty);
916 dquot->dq_sb = sb;
917 dquot->dq_id = make_kqid_invalid(type);
918 atomic_set(&dquot->dq_count, 1);
919 spin_lock_init(&dquot->dq_dqb_lock);
921 return dquot;
925 * Get reference to dquot
928 * destroying our dquot by:
930 * b) getting a reference to dquot before we release dq_list_lock
932 struct dquot *dqget(struct super_block *sb, struct kqid qid)
935 struct dquot *dquot, *empty = NULL;
948 dquot = ERR_PTR(-ESRCH);
953 dquot = find_dquot(hashent, sb, qid);
954 if (!dquot) {
962 dquot = empty;
964 dquot->dq_id = qid;
966 put_inuse(dquot);
968 insert_dquot_hash(dquot);
972 if (!atomic_read(&dquot->dq_count))
973 remove_free_dquot(dquot);
974 atomic_inc(&dquot->dq_count);
981 wait_on_dquot(dquot);
982 /* Read the dquot / allocate space in quota file */
983 if (!dquot_active(dquot)) {
986 err = sb->dq_op->acquire_dquot(dquot);
988 dqput(dquot);
989 dquot = ERR_PTR(err);
999 BUG_ON(!dquot->dq_sb); /* Has somebody invalidated entry under us? */
1005 return dquot;
1009 static inline struct dquot __rcu **i_dquot(struct inode *inode)
1016 struct dquot __rcu * const *dquots;
1106 struct dquot __rcu **dquots = i_dquot(inode);
1107 struct dquot *dquot = srcu_dereference_check(
1116 if (dquot)
1117 dqput(dquot);
1139 void dquot_free_reserved_space(struct dquot *dquot, qsize_t number)
1141 if (dquot->dq_dqb.dqb_rsvspace >= number)
1142 dquot->dq_dqb.dqb_rsvspace -= number;
1145 dquot->dq_dqb.dqb_rsvspace = 0;
1147 if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <=
1148 dquot->dq_dqb.dqb_bsoftlimit)
1149 dquot->dq_dqb.dqb_btime = (time64_t) 0;
1150 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
1153 static void dquot_decr_inodes(struct dquot *dquot, qsize_t number)
1155 if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE ||
1156 dquot->dq_dqb.dqb_curinodes >= number)
1157 dquot->dq_dqb.dqb_curinodes -= number;
1159 dquot->dq_dqb.dqb_curinodes = 0;
1160 if (dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit)
1161 dquot->dq_dqb.dqb_itime = (time64_t) 0;
1162 clear_bit(DQ_INODES_B, &dquot->dq_flags);
1165 static void dquot_decr_space(struct dquot *dquot, qsize_t number)
1167 if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NEGATIVE_USAGE ||
1168 dquot->dq_dqb.dqb_curspace >= number)
1169 dquot->dq_dqb.dqb_curspace -= number;
1171 dquot->dq_dqb.dqb_curspace = 0;
1172 if (dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace <=
1173 dquot->dq_dqb.dqb_bsoftlimit)
1174 dquot->dq_dqb.dqb_btime = (time64_t) 0;
1175 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
1184 static int warning_issued(struct dquot *dquot, const int warntype)
1193 return test_and_set_bit(flag, &dquot->dq_flags);
1262 static void prepare_warning(struct dquot_warn *warn, struct dquot *dquot,
1265 if (warning_issued(dquot, warntype))
1268 warn->w_sb = dquot->dq_sb;
1269 warn->w_dq_id = dquot->dq_id;
1292 static int ignore_hardlimit(struct dquot *dquot)
1294 struct mem_dqinfo *info = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type];
1301 static int dquot_add_inodes(struct dquot *dquot, qsize_t inodes,
1307 spin_lock(&dquot->dq_dqb_lock);
1308 newinodes = dquot->dq_dqb.dqb_curinodes + inodes;
1309 if (!sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_id.type) ||
1310 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1313 if (dquot->dq_dqb.dqb_ihardlimit &&
1314 newinodes > dquot->dq_dqb.dqb_ihardlimit &&
1315 !ignore_hardlimit(dquot)) {
1316 prepare_warning(warn, dquot, QUOTA_NL_IHARDWARN);
1321 if (dquot->dq_dqb.dqb_isoftlimit &&
1322 newinodes > dquot->dq_dqb.dqb_isoftlimit &&
1323 dquot->dq_dqb.dqb_itime &&
1324 ktime_get_real_seconds() >= dquot->dq_dqb.dqb_itime &&
1325 !ignore_hardlimit(dquot)) {
1326 prepare_warning(warn, dquot, QUOTA_NL_ISOFTLONGWARN);
1331 if (dquot->dq_dqb.dqb_isoftlimit &&
1332 newinodes > dquot->dq_dqb.dqb_isoftlimit &&
1333 dquot->dq_dqb.dqb_itime == 0) {
1334 prepare_warning(warn, dquot, QUOTA_NL_ISOFTWARN);
1335 dquot->dq_dqb.dqb_itime = ktime_get_real_seconds() +
1336 sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type].dqi_igrace;
1339 dquot->dq_dqb.dqb_curinodes = newinodes;
1342 spin_unlock(&dquot->dq_dqb_lock);
1346 static int dquot_add_space(struct dquot *dquot, qsize_t space,
1351 struct super_block *sb = dquot->dq_sb;
1354 spin_lock(&dquot->dq_dqb_lock);
1355 if (!sb_has_quota_limits_enabled(sb, dquot->dq_id.type) ||
1356 test_bit(DQ_FAKE_B, &dquot->dq_flags))
1359 tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace
1362 if (dquot->dq_dqb.dqb_bhardlimit &&
1363 tspace > dquot->dq_dqb.dqb_bhardlimit &&
1364 !ignore_hardlimit(dquot)) {
1366 prepare_warning(warn, dquot, QUOTA_NL_BHARDWARN);
1371 if (dquot->dq_dqb.dqb_bsoftlimit &&
1372 tspace > dquot->dq_dqb.dqb_bsoftlimit &&
1373 dquot->dq_dqb.dqb_btime &&
1374 ktime_get_real_seconds() >= dquot->dq_dqb.dqb_btime &&
1375 !ignore_hardlimit(dquot)) {
1377 prepare_warning(warn, dquot, QUOTA_NL_BSOFTLONGWARN);
1382 if (dquot->dq_dqb.dqb_bsoftlimit &&
1383 tspace > dquot->dq_dqb.dqb_bsoftlimit &&
1384 dquot->dq_dqb.dqb_btime == 0) {
1386 prepare_warning(warn, dquot, QUOTA_NL_BSOFTWARN);
1387 dquot->dq_dqb.dqb_btime = ktime_get_real_seconds() +
1388 sb_dqopt(sb)->info[dquot->dq_id.type].dqi_bgrace;
1407 dquot->dq_dqb.dqb_rsvspace += rsv_space;
1408 dquot->dq_dqb.dqb_curspace += space;
1410 spin_unlock(&dquot->dq_dqb_lock);
1414 static int info_idq_free(struct dquot *dquot, qsize_t inodes)
1418 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
1419 dquot->dq_dqb.dqb_curinodes <= dquot->dq_dqb.dqb_isoftlimit ||
1420 !sb_has_quota_limits_enabled(dquot->dq_sb, dquot->dq_id.type))
1423 newinodes = dquot->dq_dqb.dqb_curinodes - inodes;
1424 if (newinodes <= dquot->dq_dqb.dqb_isoftlimit)
1426 if (dquot->dq_dqb.dqb_curinodes >= dquot->dq_dqb.dqb_ihardlimit &&
1427 newinodes < dquot->dq_dqb.dqb_ihardlimit)
1432 static int info_bdq_free(struct dquot *dquot, qsize_t space)
1436 tspace = dquot->dq_dqb.dqb_curspace + dquot->dq_dqb.dqb_rsvspace;
1438 if (test_bit(DQ_FAKE_B, &dquot->dq_flags) ||
1439 tspace <= dquot->dq_dqb.dqb_bsoftlimit)
1442 if (tspace - space <= dquot->dq_dqb.dqb_bsoftlimit)
1444 if (tspace >= dquot->dq_dqb.dqb_bhardlimit &&
1445 tspace - space < dquot->dq_dqb.dqb_bhardlimit)
1463 * might need a lot of space in journal for dquot structure allocation.
1468 struct dquot __rcu **dquots;
1469 struct dquot *got[MAXQUOTAS] = {};
1484 struct dquot *dquot;
1515 dquot = dqget(sb, qid);
1516 if (IS_ERR(dquot)) {
1518 if (PTR_ERR(dquot) != -ESRCH) {
1519 ret = PTR_ERR(dquot);
1522 dquot = NULL;
1524 got[cnt] = dquot;
1552 struct dquot *dquot = srcu_dereference_check(
1559 spin_lock(&dquot->dq_dqb_lock);
1560 dquot->dq_dqb.dqb_rsvspace += rsv;
1561 spin_unlock(&dquot->dq_dqb_lock);
1583 struct dquot __rcu **dquots;
1608 struct dquot __rcu **dquots = i_dquot(inode);
1609 struct dquot *put[MAXQUOTAS];
1623 struct dquot __rcu * const *dquots;
1684 * the current transaction so that dquot write and inode write go into the
1696 struct dquot __rcu **dquots;
1697 struct dquot *dquot;
1717 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1718 if (!dquot)
1721 ret = dquot_add_space(dquot, 0, number, flags, &warn[cnt]);
1723 ret = dquot_add_space(dquot, number, 0, flags, &warn[cnt]);
1728 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1729 if (!dquot)
1731 spin_lock(&dquot->dq_dqb_lock);
1733 dquot_free_reserved_space(dquot, number);
1735 dquot_decr_space(dquot, number);
1736 spin_unlock(&dquot->dq_dqb_lock);
1766 struct dquot __rcu * const *dquots;
1767 struct dquot *dquot;
1778 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1779 if (!dquot)
1781 ret = dquot_add_inodes(dquot, 1, &warn[cnt]);
1784 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1785 if (!dquot)
1788 spin_lock(&dquot->dq_dqb_lock);
1789 dquot_decr_inodes(dquot, 1);
1790 spin_unlock(&dquot->dq_dqb_lock);
1811 struct dquot __rcu **dquots;
1812 struct dquot *dquot;
1828 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1829 if (dquot) {
1830 spin_lock(&dquot->dq_dqb_lock);
1831 if (WARN_ON_ONCE(dquot->dq_dqb.dqb_rsvspace < number))
1832 number = dquot->dq_dqb.dqb_rsvspace;
1833 dquot->dq_dqb.dqb_curspace += number;
1834 dquot->dq_dqb.dqb_rsvspace -= number;
1835 spin_unlock(&dquot->dq_dqb_lock);
1853 struct dquot __rcu **dquots;
1854 struct dquot *dquot;
1870 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1871 if (dquot) {
1872 spin_lock(&dquot->dq_dqb_lock);
1873 if (WARN_ON_ONCE(dquot->dq_dqb.dqb_curspace < number))
1874 number = dquot->dq_dqb.dqb_curspace;
1875 dquot->dq_dqb.dqb_rsvspace += number;
1876 dquot->dq_dqb.dqb_curspace -= number;
1877 spin_unlock(&dquot->dq_dqb_lock);
1897 struct dquot __rcu **dquots;
1898 struct dquot *dquot;
1919 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1920 if (!dquot)
1922 spin_lock(&dquot->dq_dqb_lock);
1923 wtype = info_bdq_free(dquot, number);
1925 prepare_warning(&warn[cnt], dquot, wtype);
1927 dquot_free_reserved_space(dquot, number);
1929 dquot_decr_space(dquot, number);
1930 spin_unlock(&dquot->dq_dqb_lock);
1954 struct dquot __rcu * const *dquots;
1955 struct dquot *dquot;
1967 dquot = srcu_dereference(dquots[cnt], &dquot_srcu);
1968 if (!dquot)
1970 spin_lock(&dquot->dq_dqb_lock);
1971 wtype = info_idq_free(dquot, 1);
1973 prepare_warning(&warn[cnt], dquot, wtype);
1974 dquot_decr_inodes(dquot, 1);
1975 spin_unlock(&dquot->dq_dqb_lock);
1986 * On success, dquot references in transfer_to are consumed and references
1996 int __dquot_transfer(struct inode *inode, struct dquot **transfer_to)
2001 struct dquot __rcu **dquots;
2002 struct dquot *transfer_from[MAXQUOTAS] = {};
2095 * These arrays are local and we hold dquot references so we don't need
2100 mark_all_dquot_dirty((struct dquot __rcu **)transfer_from);
2101 mark_all_dquot_dirty((struct dquot __rcu **)transfer_to);
2136 struct dquot *transfer_to[MAXQUOTAS] = {};
2137 struct dquot *dquot;
2148 dquot = dqget(sb, make_kqid_uid(kuid));
2149 if (IS_ERR(dquot)) {
2150 if (PTR_ERR(dquot) != -ESRCH) {
2151 ret = PTR_ERR(dquot);
2154 dquot = NULL;
2156 transfer_to[USRQUOTA] = dquot;
2162 dquot = dqget(sb, make_kqid_gid(kgid));
2163 if (IS_ERR(dquot)) {
2164 if (PTR_ERR(dquot) != -ESRCH) {
2165 ret = PTR_ERR(dquot);
2168 dquot = NULL;
2170 transfer_to[GRPQUOTA] = dquot;
2406 * When S_NOQUOTA is set, remove dquot references as no more
2674 static void do_get_dqblk(struct dquot *dquot, struct qc_dqblk *di)
2676 struct mem_dqblk *dm = &dquot->dq_dqb;
2679 spin_lock(&dquot->dq_dqb_lock);
2688 spin_unlock(&dquot->dq_dqb_lock);
2694 struct dquot *dquot;
2696 dquot = dqget(sb, qid);
2697 if (IS_ERR(dquot))
2698 return PTR_ERR(dquot);
2699 do_get_dqblk(dquot, di);
2700 dqput(dquot);
2709 struct dquot *dquot;
2717 dquot = dqget(sb, *qid);
2718 if (IS_ERR(dquot))
2719 return PTR_ERR(dquot);
2720 do_get_dqblk(dquot, di);
2721 dqput(dquot);
2733 static int do_set_dqblk(struct dquot *dquot, struct qc_dqblk *di)
2735 struct mem_dqblk *dm = &dquot->dq_dqb;
2737 struct mem_dqinfo *dqi = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type];
2752 spin_lock(&dquot->dq_dqb_lock);
2756 set_bit(DQ_LASTSET_B + QIF_SPACE_B, &dquot->dq_flags);
2765 set_bit(DQ_LASTSET_B + QIF_BLIMITS_B, &dquot->dq_flags);
2771 set_bit(DQ_LASTSET_B + QIF_INODES_B, &dquot->dq_flags);
2780 set_bit(DQ_LASTSET_B + QIF_ILIMITS_B, &dquot->dq_flags);
2786 set_bit(DQ_LASTSET_B + QIF_BTIME_B, &dquot->dq_flags);
2792 set_bit(DQ_LASTSET_B + QIF_ITIME_B, &dquot->dq_flags);
2799 clear_bit(DQ_BLKS_B, &dquot->dq_flags);
2808 clear_bit(DQ_INODES_B, &dquot->dq_flags);
2815 clear_bit(DQ_FAKE_B, &dquot->dq_flags);
2817 set_bit(DQ_FAKE_B, &dquot->dq_flags);
2818 spin_unlock(&dquot->dq_dqb_lock);
2819 mark_dquot_dirty(dquot);
2827 struct dquot *dquot;
2830 dquot = dqget(sb, qid);
2831 if (IS_ERR(dquot)) {
2832 rc = PTR_ERR(dquot);
2835 rc = do_set_dqblk(dquot, di);
2836 dqput(dquot);
3017 dquot_cachep = kmem_cache_create("dquot",
3018 sizeof(struct dquot), sizeof(unsigned long) * 4,
3026 panic("Cannot create dquot hash table");
3031 panic("Cannot create dquot stat counters");
3047 panic("Cannot register dquot shrinker");