ocfs2-devel.oss.oracle.com archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 3/6] quota: Provide function to grab quota structure reference
Date: Thu, 20 Feb 2014 16:18:28 +0100	[thread overview]
Message-ID: <1392909511-2933-4-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1392909511-2933-1-git-send-email-jack@suse.cz>

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>
---
 fs/quota/dquot.c         | 4 ++--
 include/linux/quotaops.h | 8 ++++++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 831d49a4111f..e3f09e34d0b2 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -528,7 +528,7 @@ restart:
 		if (atomic_read(&dquot->dq_count)) {
 			DEFINE_WAIT(wait);
 
-			atomic_inc(&dquot->dq_count);
+			dqgrab(dquot);
 			prepare_to_wait(&dquot->dq_wait_unused, &wait,
 					TASK_UNINTERRUPTIBLE);
 			spin_unlock(&dq_list_lock);
@@ -624,7 +624,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
 			/* Now we have active dquot from which someone is
  			 * holding reference so we can safely just increase
 			 * use count */
-			atomic_inc(&dquot->dq_count);
+			dqgrab(dquot);
 			spin_unlock(&dq_list_lock);
 			dqstats_inc(DQST_LOOKUPS);
 			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);
 void dquot_initialize(struct inode *inode);
 void dquot_drop(struct inode *inode);
 struct dquot *dqget(struct super_block *sb, struct kqid qid);
+static inline struct dquot *dqgrab(struct dquot *dquot)
+{
+	/* Make sure someone else has active reference to dquot */
+	WARN_ON_ONCE(!atomic_read(&dquot->dq_count));
+	WARN_ON_ONCE(!test_bit(DQ_ACTIVE_B, &dquot->dq_flags));
+	atomic_inc(&dquot->dq_count);
+	return dquot;
+}
 void dqput(struct dquot *dquot);
 int dquot_scan_active(struct super_block *sb,
 		      int (*fn)(struct dquot *dquot, unsigned long priv),
-- 
1.8.1.4

  parent reply	other threads:[~2014-02-20 15:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-20 15:18 [Ocfs2-devel] [PATCH 0/6 v2] ocfs2: Avoid pending orphaned inodes Jan Kara
2014-02-20 15:18 ` [Ocfs2-devel] [PATCH 1/6] ocfs2: Remove OCFS2_INODE_SKIP_DELETE flag Jan Kara
2014-02-21  5:14   ` Srinivas Eeda
2014-02-20 15:18 ` [Ocfs2-devel] [PATCH 2/6] ocfs2: Move dquot_initialize() in ocfs2_delete_inode() somewhat later Jan Kara
2014-02-21  5:14   ` Srinivas Eeda
2014-02-20 15:18 ` Jan Kara [this message]
2014-02-21  5:14   ` [Ocfs2-devel] [PATCH 3/6] quota: Provide function to grab quota structure reference Srinivas Eeda
2014-02-20 15:18 ` [Ocfs2-devel] [PATCH 4/6] ocfs2: Implement delayed dropping of last dquot reference Jan Kara
2014-02-21  5:15   ` Srinivas Eeda
2014-02-20 15:18 ` [Ocfs2-devel] [PATCH 5/6] ocfs2: Avoid blocking in ocfs2_mark_lockres_freeing() in downconvert thread Jan Kara
2014-02-21  5:21   ` Srinivas Eeda
2014-02-21  9:14     ` Jan Kara
2014-02-21  9:35       ` Jan Kara
2014-02-20 15:18 ` [Ocfs2-devel] [PATCH 6/6] ocfs2: Revert iput deferring code in ocfs2_drop_dentry_lock Jan Kara
2014-02-21  5:13 ` [Ocfs2-devel] [PATCH 0/6 v2] ocfs2: Avoid pending orphaned inodes Srinivas Eeda
  -- strict thread matches above, loose matches on Subject: below --
2014-02-21  9:44 [Ocfs2-devel] [PATCH 0/6 v3] " Jan Kara
2014-02-21  9:45 ` [Ocfs2-devel] [PATCH 3/6] quota: Provide function to grab quota structure reference Jan Kara
2014-02-25 18:58   ` Mark Fasheh
2014-02-26 11:05 [Ocfs2-devel] [PATCH 0/6 v4] ocfs2: Avoid pending orphaned inodes Jan Kara
2014-02-26 11:05 ` [Ocfs2-devel] [PATCH 3/6] quota: Provide function to grab quota structure reference Jan Kara
2014-02-26 16:49 [Ocfs2-devel] [PATCH 0/6 v5] ocfs2: Avoid pending orphaned inodes Jan Kara
2014-02-26 16:49 ` [Ocfs2-devel] [PATCH 3/6] quota: Provide function to grab quota structure reference Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1392909511-2933-4-git-send-email-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=ocfs2-devel@oss.oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).