linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-fsdevel@vger.kernel.org
Cc: jack@suse.cz, Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 2/3] quota: introduce  get_id callback
Date: Tue,  2 Feb 2010 18:00:24 +0300	[thread overview]
Message-ID: <1265122826-5370-3-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1265122826-5370-2-git-send-email-dmonakhov@openvz.org>

During some quota oparations we have to determine quota_id for given inode
according to quota_type. But only USRQUOTA/GRPQUOTA id are intermediately
accessible from generic vfs-inode. This patch introduce new per_sb quota
operation for this purpose.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/ext3/super.c          |    1 +
 fs/ext4/super.c          |    1 +
 fs/ocfs2/quota_global.c  |    1 +
 fs/quota/dquot.c         |   26 ++++++++++++++++++--------
 fs/reiserfs/super.c      |    1 +
 include/linux/quota.h    |    1 +
 include/linux/quotaops.h |    1 +
 7 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 241c520..82bf9c8 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -757,6 +757,7 @@ static const struct dquot_operations ext3_quota_operations = {
 	.free_space	= dquot_free_space,
 	.free_inode	= dquot_free_inode,
 	.transfer	= dquot_transfer,
+	.get_id		= dquot_get_id,
 	.write_dquot	= ext3_write_dquot,
 	.acquire_dquot	= ext3_acquire_dquot,
 	.release_dquot	= ext3_release_dquot,
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index e2435ac..ae417a2 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1025,6 +1025,7 @@ static const struct dquot_operations ext4_quota_operations = {
 	.free_space	= dquot_free_space,
 	.free_inode	= dquot_free_inode,
 	.transfer	= dquot_transfer,
+	.get_id		= dquot_get_id,
 	.write_dquot	= ext4_write_dquot,
 	.acquire_dquot	= ext4_acquire_dquot,
 	.release_dquot	= ext4_release_dquot,
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index b437dc0..1ede78f 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -858,6 +858,7 @@ const struct dquot_operations ocfs2_quota_operations = {
 	.free_space	= dquot_free_space,
 	.free_inode	= dquot_free_inode,
 	.transfer	= dquot_transfer,
+	.get_id		= dquot_get_id,
 	.write_dquot	= ocfs2_write_dquot,
 	.acquire_dquot	= ocfs2_acquire_dquot,
 	.release_dquot	= ocfs2_release_dquot,
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 3fdb668..36569c9 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -1246,6 +1246,20 @@ static int info_bdq_free(struct dquot *dquot, qsize_t space)
 		return QUOTA_NL_BHARDBELOW;
 	return QUOTA_NL_NOWARN;
 }
+
+qid_t dquot_get_id(struct inode *inode, int type)
+{
+	switch (type) {
+	case USRQUOTA:
+		return inode->i_uid;
+	case GRPQUOTA:
+		return inode->i_gid;
+	default:
+		BUG();
+	}
+}
+EXPORT_SYMBOL(dquot_get_id);
+
 /*
  *	Initialize quota pointers in inode
  *	We do things in a bit complicated way but by that we avoid calling
@@ -1267,14 +1281,9 @@ int dquot_initialize(struct inode *inode, int type)
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		if (type != -1 && cnt != type)
 			continue;
-		switch (cnt) {
-		case USRQUOTA:
-			id = inode->i_uid;
-			break;
-		case GRPQUOTA:
-			id = inode->i_gid;
-			break;
-		}
+		if (!sb_has_quota_active(sb, cnt))
+			continue;
+		id = inode->i_sb->dq_op->get_id(inode, cnt);
 		got[cnt] = dqget(sb, id, cnt);
 	}
 
@@ -1788,6 +1797,7 @@ const struct dquot_operations dquot_operations = {
 	.free_space	= dquot_free_space,
 	.free_inode	= dquot_free_inode,
 	.transfer	= dquot_transfer,
+	.get_id		= dquot_get_id,
 	.write_dquot	= dquot_commit,
 	.acquire_dquot	= dquot_acquire,
 	.release_dquot	= dquot_release,
diff --git a/fs/reiserfs/super.c b/fs/reiserfs/super.c
index b4a7dd0..897f2bc 100644
--- a/fs/reiserfs/super.c
+++ b/fs/reiserfs/super.c
@@ -623,6 +623,7 @@ static const struct dquot_operations reiserfs_quota_operations = {
 	.free_space = dquot_free_space,
 	.free_inode = dquot_free_inode,
 	.transfer = dquot_transfer,
+	.get_id		= dquot_get_id,
 	.write_dquot = reiserfs_write_dquot,
 	.acquire_dquot = reiserfs_acquire_dquot,
 	.release_dquot = reiserfs_release_dquot,
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 74738e9..7f06086 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -303,6 +303,7 @@ struct dquot_operations {
 	int (*free_inode) (const struct inode *, qsize_t);
 	int (*transfer) (struct inode *, qid_t *, unsigned long);
 	int (*write_dquot) (struct dquot *);		/* Ordinary dquot write */
+	qid_t (*get_id)(struct inode *, int); 		/* Quota id for given type */
 	struct dquot *(*alloc_dquot)(struct super_block *, int);	/* Allocate memory for new dquot */
 	void (*destroy_dquot)(struct dquot *);		/* Free memory for dquot */
 	int (*acquire_dquot) (struct dquot *);		/* Quota is going to be created on disk */
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index d459f7c..e679fbe 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -26,6 +26,7 @@ static inline void writeout_quota_sb(struct super_block *sb, int type)
 		sb->s_qcop->quota_sync(sb, type);
 }
 
+qid_t dquot_get_id(struct inode *inode, int type);
 int dquot_initialize(struct inode *inode, int type);
 int dquot_drop(struct inode *inode);
 struct dquot *dqget(struct super_block *sb, unsigned int id, int type);
-- 
1.6.3.3


  reply	other threads:[~2010-02-02 15:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-02 15:00 [PATCH 0/3] quota: RFC add extend quota types Dmitry Monakhov
2010-02-02 15:00 ` [PATCH 1/3] quota: generalize quota transfer interface Dmitry Monakhov
2010-02-02 15:00   ` Dmitry Monakhov [this message]
2010-02-02 15:00     ` [PATCH 3/3] quota: add generic treeid quota support Dmitry Monakhov
2010-02-02 16:10       ` Jan Kara
2010-02-02 16:05     ` [PATCH 2/3] quota: introduce get_id callback Jan Kara
2010-02-03  5:38       ` Dmitry Monakhov
2010-02-03 10:47         ` Jan Kara
2010-02-03 19:54           ` Dmitry Monakhov
2010-02-02 15:48   ` [PATCH 1/3] quota: generalize quota transfer interface 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=1265122826-5370-3-git-send-email-dmonakhov@openvz.org \
    --to=dmonakhov@openvz.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).