aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2014-04-03 17:46:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-03 19:20:54 -0400
commit9f985cb6c45bc3f8b7e161c9658d409d051d576f (patch)
treec9c9d1431fd3a7a002ed17b095e981bcf2cb30a3
parentbd62ad7aebd8e8895bb7649ace948040332f27d3 (diff)
quota: provide function to grab quota structure reference
Provide dqgrab() function to get quota structure reference when we are sure it already has at least one active reference. Make use of this function inside quota code. Signed-off-by: Jan Kara <jack@suse.cz> Reviewed-by: Mark Fasheh <mfasheh@suse.de> Reviewed-by: Srinivas Eeda <srinivas.eeda@oracle.com> Cc: Joel Becker <jlbec@evilplan.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/quota/dquot.c4
-rw-r--r--include/linux/quotaops.h8
2 files changed, 10 insertions, 2 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index cfc8dcc16043..9cd5f63715c0 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -528,7 +528,7 @@ restart:
528 if (atomic_read(&dquot->dq_count)) { 528 if (atomic_read(&dquot->dq_count)) {
529 DEFINE_WAIT(wait); 529 DEFINE_WAIT(wait);
530 530
531 atomic_inc(&dquot->dq_count); 531 dqgrab(dquot);
532 prepare_to_wait(&dquot->dq_wait_unused, &wait, 532 prepare_to_wait(&dquot->dq_wait_unused, &wait,
533 TASK_UNINTERRUPTIBLE); 533 TASK_UNINTERRUPTIBLE);
534 spin_unlock(&dq_list_lock); 534 spin_unlock(&dq_list_lock);
@@ -632,7 +632,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
632 /* Now we have active dquot from which someone is 632 /* Now we have active dquot from which someone is
633 * holding reference so we can safely just increase 633 * holding reference so we can safely just increase
634 * use count */ 634 * use count */
635 atomic_inc(&dquot->dq_count); 635 dqgrab(dquot);
636 spin_unlock(&dq_list_lock); 636 spin_unlock(&dq_list_lock);
637 dqstats_inc(DQST_LOOKUPS); 637 dqstats_inc(DQST_LOOKUPS);
638 err = sb->dq_op->write_dquot(dquot); 638 err = sb->dq_op->write_dquot(dquot);
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 6965fe394c3b..1d3eee594cd6 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -46,6 +46,14 @@ void inode_reclaim_rsv_space(struct inode *inode, qsize_t number);
46void dquot_initialize(struct inode *inode); 46void dquot_initialize(struct inode *inode);
47void dquot_drop(struct inode *inode); 47void dquot_drop(struct inode *inode);
48struct dquot *dqget(struct super_block *sb, struct kqid qid); 48struct dquot *dqget(struct super_block *sb, struct kqid qid);
49static inline struct dquot *dqgrab(struct dquot *dquot)
50{
51 /* Make sure someone else has active reference to dquot */
52 WARN_ON_ONCE(!atomic_read(&dquot->dq_count));
53 WARN_ON_ONCE(!test_bit(DQ_ACTIVE_B, &dquot->dq_flags));
54 atomic_inc(&dquot->dq_count);
55 return dquot;
56}
49void dqput(struct dquot *dquot); 57void dqput(struct dquot *dquot);
50int dquot_scan_active(struct super_block *sb, 58int dquot_scan_active(struct super_block *sb,
51 int (*fn)(struct dquot *dquot, unsigned long priv), 59 int (*fn)(struct dquot *dquot, unsigned long priv),