From: Chandra Seetharaman <sekharan@us.ibm.com>
To: xfs@oss.sgi.com
Cc: Chandra Seetharaman <sekharan@us.ibm.com>
Subject: [RFC PATCH 2/4] Define a new function xfs_inode_dquot()
Date: Thu, 27 Oct 2011 17:05:34 -0500 [thread overview]
Message-ID: <20111027220534.2638.54570.sendpatchset@chandra-lucid.austin.ibm.com> (raw)
In-Reply-To: <20111027220523.2638.12351.sendpatchset@chandra-lucid.austin.ibm.com>
Define a new function xfs_inode_dquot() that takes a inode pointer
and a disk quota type and returns the quota pointer for the specified
quota type.
This simplifies the xfs_qm_dqget() error path significantly.
Signed-off-by: Chandra Seetharaman <sekharan@us.ibm.com>
---
fs/xfs/xfs_dquot.c | 33 +++++++++------------------------
fs/xfs/xfs_dquot.h | 14 ++++++++++++++
2 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 815e231..3c983a7 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -808,7 +808,7 @@ xfs_qm_dqget(
uint flags, /* DQALLOC, DQSUSER, DQREPAIR, DOWARN */
xfs_dquot_t **O_dqpp) /* OUT : locked incore dquot */
{
- xfs_dquot_t *dqp;
+ xfs_dquot_t *dqp, *dqp1;
xfs_dqhash_t *h;
uint version;
int error;
@@ -839,10 +839,7 @@ xfs_qm_dqget(
type == XFS_DQ_GROUP);
if (ip) {
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
- if (type == XFS_DQ_USER)
- ASSERT(ip->i_udquot == NULL);
- else
- ASSERT(ip->i_gdquot == NULL);
+ ASSERT(xfs_inode_dquot(ip, type) == NULL);
}
#endif
mutex_lock(&h->qh_lock);
@@ -921,30 +918,18 @@ xfs_qm_dqget(
* A dquot could be attached to this inode by now, since
* we had dropped the ilock.
*/
- if (type == XFS_DQ_USER) {
- if (!XFS_IS_UQUOTA_ON(mp)) {
- /* inode stays locked on return */
- xfs_qm_dqdestroy(dqp);
- return XFS_ERROR(ESRCH);
- }
- if (ip->i_udquot) {
+ if (xfs_this_quota_on(mp, type)) {
+ dqp1 = xfs_inode_dquot(ip, type);
+ if (dqp1) {
xfs_qm_dqdestroy(dqp);
- dqp = ip->i_udquot;
+ dqp = dqp1;
xfs_dqlock(dqp);
goto dqret;
}
} else {
- if (!XFS_IS_OQUOTA_ON(mp)) {
- /* inode stays locked on return */
- xfs_qm_dqdestroy(dqp);
- return XFS_ERROR(ESRCH);
- }
- if (ip->i_gdquot) {
- xfs_qm_dqdestroy(dqp);
- dqp = ip->i_gdquot;
- xfs_dqlock(dqp);
- goto dqret;
- }
+ /* inode stays locked on return */
+ xfs_qm_dqdestroy(dqp);
+ return XFS_ERROR(ESRCH);
}
}
diff --git a/fs/xfs/xfs_dquot.h b/fs/xfs/xfs_dquot.h
index ef7a312..c09510a 100644
--- a/fs/xfs/xfs_dquot.h
+++ b/fs/xfs/xfs_dquot.h
@@ -115,6 +115,20 @@ static inline int xfs_this_quota_on(struct xfs_mount *mp, int type)
}
}
+static inline xfs_dquot_t *xfs_inode_dquot(struct xfs_inode *ip, int type)
+{
+ type &= XFS_DQ_ALLTYPES;
+ switch(type) {
+ case XFS_DQ_USER:
+ return ip->i_udquot;
+ case XFS_DQ_PROJ:
+ case XFS_DQ_GROUP:
+ return ip->i_gdquot;
+ default:
+ return NULL;
+ }
+}
+
#define XFS_DQ_IS_LOCKED(dqp) (mutex_is_locked(&((dqp)->q_qlock)))
#define XFS_DQ_IS_DIRTY(dqp) ((dqp)->dq_flags & XFS_DQ_DIRTY)
#define XFS_QM_ISUDQ(dqp) ((dqp)->dq_flags & XFS_DQ_USER)
--
1.7.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2011-10-27 22:08 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-27 22:05 [RFC PATCH 0/4] Rearrange code to make the code more readable Chandra Seetharaman
2011-10-27 22:05 ` [RFC PATCH 1/4] Define a new function xfs_this_quota_on() Chandra Seetharaman
2011-10-27 22:24 ` Christoph Hellwig
2011-11-11 20:29 ` Alex Elder
2011-10-27 22:05 ` Chandra Seetharaman [this message]
2011-11-11 20:29 ` [RFC PATCH 2/4] Define a new function xfs_inode_dquot() Alex Elder
2011-10-27 22:05 ` [RFC PATCH 3/4] Change xfs_sb_from_disk() interface to take a mount pointer Chandra Seetharaman
2011-11-11 20:29 ` Alex Elder
2011-10-27 22:05 ` [RFC PATCH 4/4] Define new macro XFS_ALL_QUOTA_ACTIVE and simply some usage Chandra Seetharaman
2011-11-07 20:05 ` [RFC PATCH 0/4] Rearrange code to make the code more readable Ben Myers
-- strict thread matches above, loose matches on Subject: below --
2012-01-23 17:31 Chandra Seetharaman
2012-01-23 17:31 ` [RFC PATCH 2/4] Define a new function xfs_inode_dquot() Chandra Seetharaman
2012-01-24 17:48 ` Christoph Hellwig
2012-01-24 19:41 ` Chandra Seetharaman
2012-02-03 16:21 ` Ben Myers
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=20111027220534.2638.54570.sendpatchset@chandra-lucid.austin.ibm.com \
--to=sekharan@us.ibm.com \
--cc=xfs@oss.sgi.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