From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-fsdevel@vger.kernel.org
Cc: jack@suse.cz, hch@infradead.org,
Dmitry Monakhov <dmonakhov@gmail.com>,
Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 17/19] quota: Some stylistic cleanup for dquot interface
Date: Fri, 22 Oct 2010 21:35:02 +0400 [thread overview]
Message-ID: <1287768904-27810-18-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1287768904-27810-1-git-send-email-dmonakhov@openvz.org>
From: Dmitry Monakhov <dmonakhov@gmail.com>
This patch performs only stylistic cleanup. No changes in logic at all.
- Rename dqget() to find_get_dquot()
- Wrap direct dq_count increment to helper function
Some places still access dq_count directly, but this is because
reference counting algorithm. It will be changed in later patches.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
fs/ocfs2/file.c | 8 ++++----
fs/ocfs2/quota_global.c | 2 +-
fs/ocfs2/quota_local.c | 3 ++-
fs/quota/dquot.c | 42 ++++++++++++++++++++++++++----------------
include/linux/quotaops.h | 3 ++-
5 files changed, 35 insertions(+), 23 deletions(-)
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 9a03c15..b7e7c9b 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1205,8 +1205,8 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
if (attr->ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid
&& OCFS2_HAS_RO_COMPAT_FEATURE(sb,
OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) {
- transfer_to[USRQUOTA] = dqget(sb, attr->ia_uid,
- USRQUOTA);
+ transfer_to[USRQUOTA] =
+ find_get_dquot(sb, attr->ia_uid, USRQUOTA);
if (!transfer_to[USRQUOTA]) {
status = -ESRCH;
goto bail_unlock;
@@ -1215,8 +1215,8 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
if (attr->ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid
&& OCFS2_HAS_RO_COMPAT_FEATURE(sb,
OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) {
- transfer_to[GRPQUOTA] = dqget(sb, attr->ia_gid,
- GRPQUOTA);
+ transfer_to[GRPQUOTA] =
+ find_get_dquot(sb, attr->ia_gid, GRPQUOTA);
if (!transfer_to[GRPQUOTA]) {
status = -ESRCH;
goto bail_unlock;
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index b768588..4e00341 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -693,7 +693,7 @@ static int ocfs2_release_dquot(struct dquot *dquot)
mlog_entry("id=%u, type=%d", dquot->dq_id, dquot->dq_type);
mutex_lock(&dquot->dq_mutex);
- /* Check whether we are not racing with some other dqget() */
+ /* Check whether we are not racing with some other find_get_dquot() */
if (atomic_read(&dquot->dq_count) > 1)
goto out;
status = ocfs2_lock_global_qf(oinfo, 1);
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index 1490cb0..1eaf835 100644
--- a/fs/ocfs2/quota_local.c
+++ b/fs/ocfs2/quota_local.c
@@ -500,7 +500,8 @@ static int ocfs2_recover_local_quota_file(struct inode *lqinode,
}
dqblk = (struct ocfs2_local_disk_dqblk *)(qbh->b_data +
ol_dqblk_block_off(sb, chunk, bit));
- dquot = dqget(sb, le64_to_cpu(dqblk->dqb_id), type);
+ dquot = find_get_dquot(sb, le64_to_cpu(dqblk->dqb_id),
+ type);
if (!dquot) {
status = -EIO;
mlog(ML_ERROR, "Failed to get quota structure "
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 1c7eea1..a7a7670 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -16,7 +16,8 @@
* Revised list management to avoid races
* -- Bill Hawes, <whawes@star.net>, 9/98
*
- * Fixed races in dquot_transfer(), dqget() and dquot_alloc_...().
+ * Fixed races in dquot_transfer(), find_get_dquot() and
+ * dquot_alloc_...().
* As the consequence the locking was moved from dquot_decr_...(),
* dquot_incr_...() to calling functions.
* invalidate_dquots() now writes modified dquots.
@@ -108,8 +109,9 @@
* Each dquot has its dq_mutex mutex. Locked dquots might not be referenced
* from inodes (dquot_alloc_space() and such don't check the dq_mutex).
* Currently dquot is locked only when it is being read to memory (or space for
- * it is being allocated) on the first dqget() and when it is being released on
- * the last dqput(). The allocation and release oparations are serialized by
+ * it is being allocated) on the first find_get_dquot() and when it is being
+ * released on the last dqput().
+ * The allocation and release oparations are serialized by
* the dq_mutex and by checking the use count in dquot_release(). Write
* operations on dquots don't hold dq_mutex as they copy data under dq_data_lock
* spinlock to internal buffers before writing.
@@ -526,7 +528,7 @@ int dquot_release(struct dquot *dquot)
struct quota_info *dqopt = sb_dqopts(dquot);
mutex_lock(&dquot->dq_mutex);
- /* Check whether we are not racing with some other dqget() */
+ /* Check whether we are not racing with some other find_get_dquot() */
if (atomic_read(&dquot->dq_count) > 1)
goto out_dqlock;
mutex_lock(&dqopt->dqio_mutex);
@@ -581,7 +583,7 @@ restart:
if (atomic_read(&dquot->dq_count)) {
DEFINE_WAIT(wait);
- atomic_inc(&dquot->dq_count);
+ dqget(dquot);
prepare_to_wait(&dquot->dq_wait_unused, &wait,
TASK_UNINTERRUPTIBLE);
spin_unlock(&dqopt->dq_list_lock);
@@ -631,7 +633,7 @@ int dquot_scan_active(struct super_block *sb,
if (dquot->dq_sb != sb)
continue;
/* Now we have active dquot so we can just increase use count */
- atomic_inc(&dquot->dq_count);
+ dqget(dquot);
spin_unlock(&dqopt->dq_list_lock);
dqstats_inc(DQST_LOOKUPS);
dqput(old_dquot);
@@ -678,7 +680,7 @@ int dquot_quota_sync(struct super_block *sb, int type, int wait)
/* Now we have active dquot from which someone is
* holding reference so we can safely just increase
* use count */
- atomic_inc(&dquot->dq_count);
+ dqget(dquot);
spin_unlock(&dqopt->dq_list_lock);
dqstats_inc(DQST_LOOKUPS);
dqctl(sb)->dq_op->write_dquot(dquot);
@@ -873,6 +875,11 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
return dquot;
}
+inline void dqget(struct dquot *dquot)
+{
+ atomic_inc(&dquot->dq_count);
+}
+
/*
* Get reference to dquot
*
@@ -881,7 +888,7 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
* a) checking for quota flags under dq_list_lock and
* b) getting a reference to dquot before we release dq_list_lock
*/
-struct dquot *dqget(struct super_block *sb, unsigned int id, int type)
+struct dquot *find_get_dquot(struct super_block *sb, unsigned int id, int type)
{
struct dquot *dquot = NULL, *empty = NULL;
struct quota_info *dqopt = dqopts(sb);
@@ -917,7 +924,7 @@ we_slept:
} else {
if (!atomic_read(&dquot->dq_count))
remove_free_dquot(dquot);
- atomic_inc(&dquot->dq_count);
+ dqget(dquot);
spin_unlock(&dqopt->dq_list_lock);
dqstats_inc(DQST_CACHE_HITS);
dqstats_inc(DQST_LOOKUPS);
@@ -941,7 +948,7 @@ out:
return dquot;
}
-EXPORT_SYMBOL(dqget);
+EXPORT_SYMBOL(find_get_dquot);
static int dqinit_needed(struct inode *inode, int type)
{
@@ -1420,7 +1427,7 @@ static int dquot_active(const struct inode *inode)
* Initialize quota pointers in inode
*
* We do things in a bit complicated way but by that we avoid calling
- * dqget() and thus filesystem callbacks under dqptr_sem.
+ * find_get_dquot() and thus filesystem callbacks under dqptr_sem.
*
* It is better to call this function outside of any transaction as it
* might need a lot of space in journal for dquot structure allocation.
@@ -1451,7 +1458,7 @@ static void __dquot_initialize(struct inode *inode, int type)
id = inode->i_gid;
break;
}
- got[cnt] = dqget(sb, id, cnt);
+ got[cnt] = find_get_dquot(sb, id, cnt);
}
down_write(&dqctl(sb)->dqptr_sem);
@@ -1948,9 +1955,12 @@ int dquot_transfer(struct inode *inode, struct iattr *iattr)
return 0;
if (iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid)
- transfer_to[USRQUOTA] = dqget(sb, iattr->ia_uid, USRQUOTA);
+ transfer_to[USRQUOTA] = find_get_dquot(sb, iattr->ia_uid,
+ USRQUOTA);
+
if (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)
- transfer_to[GRPQUOTA] = dqget(sb, iattr->ia_gid, GRPQUOTA);
+ transfer_to[GRPQUOTA] = find_get_dquot(sb, iattr->ia_gid,
+ GRPQUOTA);
ret = __dquot_transfer(inode, transfer_to);
dqput_all(transfer_to);
@@ -2526,7 +2536,7 @@ int dquot_get_dqblk(struct super_block *sb, int type, qid_t id,
{
struct dquot *dquot;
- dquot = dqget(sb, id, type);
+ dquot = find_get_dquot(sb, id, type);
if (!dquot)
return -ESRCH;
do_get_dqblk(dquot, di);
@@ -2639,7 +2649,7 @@ int dquot_set_dqblk(struct super_block *sb, int type, qid_t id,
struct dquot *dquot;
int rc;
- dquot = dqget(sb, id, type);
+ dquot = find_get_dquot(sb, id, type);
if (!dquot) {
rc = -ESRCH;
goto out;
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index 6f4cc74..4259da8 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -52,7 +52,8 @@ void inode_sub_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, unsigned int id, int type);
+struct dquot*find_get_dquot(struct super_block *sb, unsigned int id, int type);
+void dqget(struct dquot *dquot);
void dqput(struct dquot *dquot);
int dquot_scan_active(struct super_block *sb,
int (*fn)(struct dquot *dquot, unsigned long priv),
--
1.6.5.2
next prev parent reply other threads:[~2010-10-22 17:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-22 17:34 [PATCH 00/19] quota: RFC SMP improvements for generic quota V2 Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 01/19] quota: protect getfmt call with dqonoff_mutex lock Dmitry Monakhov
2010-10-28 14:27 ` Christoph Hellwig
2010-10-22 17:34 ` [PATCH 02/19] quota: Wrap common expression to helper function Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 03/19] quota: mode quota internals from sb to quota_info Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 04/19] quota: Convert dq_state_lock to per-sb dq_state_lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 05/19] quota: add quota format lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 06/19] quota: make dquot lists per-sb Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 07/19] quota: make per-sb hash array Dmitry Monakhov
2010-10-27 19:31 ` Al Viro
2010-10-28 10:58 ` Dmitry
2010-10-22 17:34 ` [PATCH 08/19] quota: remove global dq_list_lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 09/19] quota: rename dq_lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 10/19] quota: make per-sb dq_data_lock Dmitry Monakhov
2010-10-26 17:38 ` Dmitry
2010-10-22 17:34 ` [PATCH 11/19] quota: protect dquot mem info with object's lock Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 12/19] quota: drop dq_data_lock where possible Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 13/19] quota: relax dq_data_lock dq_lock locking consistency Dmitry Monakhov
2010-10-22 17:34 ` [PATCH 14/19] quota: protect dqget() from parallels quotaoff via RCU Dmitry Monakhov
2010-10-22 17:35 ` [PATCH 15/19] quota: remove dq_state_lock Dmitry Monakhov
2010-10-22 17:35 ` [PATCH 16/19] fs: add unlocked helpers Dmitry Monakhov
2010-10-22 17:35 ` Dmitry Monakhov [this message]
2010-10-22 17:35 ` [PATCH 18/19] quota: remove dqptr_sem Dmitry Monakhov
2010-10-22 17:35 ` [PATCH 19/19] quota: redesign dquot reference counting Dmitry Monakhov
-- strict thread matches above, loose matches on Subject: below --
2010-11-11 12:14 [PATCH 00/19] quota: RFC SMP improvements for generic quota V3 Dmitry Monakhov
2010-11-11 12:14 ` [PATCH 17/19] quota: Some stylistic cleanup for dquot interface Dmitry Monakhov
2010-11-23 11:37 ` 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=1287768904-27810-18-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=dmonakhov@gmail.com \
--cc=hch@infradead.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
/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).