From: Jan Kara <jack@suse.cz>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-fsdevel@vger.kernel.org, Jan Kara <jack@suse.cz>
Subject: [PATCH 01/14] quota: Add callbacks for allocating and destroying dquot structures
Date: Mon, 27 Oct 2008 13:11:39 +0100 [thread overview]
Message-ID: <12251095123763-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1225109512852-git-send-email-jack@suse.cz>
Some filesystems would like to keep private information together with each
dquot. Add callbacks alloc_dquot and destroy_dquot allowing filesystem to
allocate larger dquots from their private slab in a similar fashion we
currently allocate inodes.
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/dquot.c | 19 +++++++++++++++----
include/linux/quota.h | 2 ++
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/fs/dquot.c b/fs/dquot.c
index 5e95261..e2ceb28 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -415,6 +415,14 @@ out_dqlock:
return ret;
}
+static void destroy_dquot(struct dquot *dquot)
+{
+ if (dquot->dq_sb->dq_op->destroy_dquot)
+ dquot->dq_sb->dq_op->destroy_dquot(dquot);
+ else
+ kmem_cache_free(dquot_cachep, dquot);
+}
+
/* Invalidate all dquots on the list. Note that this function is called after
* quota is disabled and pointers from inodes removed so there cannot be new
* quota users. There can still be some users of quotas due to inodes being
@@ -463,7 +471,7 @@ restart:
remove_dquot_hash(dquot);
remove_free_dquot(dquot);
remove_inuse(dquot);
- kmem_cache_free(dquot_cachep, dquot);
+ destroy_dquot(dquot);
}
spin_unlock(&dq_list_lock);
}
@@ -527,7 +535,7 @@ static void prune_dqcache(int count)
remove_dquot_hash(dquot);
remove_free_dquot(dquot);
remove_inuse(dquot);
- kmem_cache_free(dquot_cachep, dquot);
+ destroy_dquot(dquot);
count--;
head = free_dquots.prev;
}
@@ -629,7 +637,10 @@ static struct dquot *get_empty_dquot(struct super_block *sb, int type)
{
struct dquot *dquot;
- dquot = kmem_cache_zalloc(dquot_cachep, GFP_NOFS);
+ if (sb->dq_op->alloc_dquot)
+ dquot = sb->dq_op->alloc_dquot(sb, type);
+ else
+ dquot = kmem_cache_zalloc(dquot_cachep, GFP_NOFS);
if(!dquot)
return NODQUOT;
@@ -682,7 +693,7 @@ we_slept:
dqstats.lookups++;
spin_unlock(&dq_list_lock);
if (empty)
- kmem_cache_free(dquot_cachep, empty);
+ destroy_dquot(empty);
}
/* Wait for dq_lock - after this we know that either dquot_release() is already
* finished or it will be canceled due to dq_count > 1 test */
diff --git a/include/linux/quota.h b/include/linux/quota.h
index 40401b5..a46df6d 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -292,6 +292,8 @@ struct dquot_operations {
int (*free_inode) (const struct inode *, unsigned long);
int (*transfer) (struct inode *, struct iattr *);
int (*write_dquot) (struct dquot *); /* Ordinary dquot write */
+ struct dquot *(*alloc_dquot)(struct super_block *, int); /* Allocate memory for new dquot (can be NULL if no special entries dquot are needed) */
+ void (*destroy_dquot)(struct dquot *); /* Free memory for dquot (can be NULL if alloc_dquot is NULL) */
int (*acquire_dquot) (struct dquot *); /* Quota is going to be created on disk */
int (*release_dquot) (struct dquot *); /* Quota is going to be deleted from disk */
int (*mark_dirty) (struct dquot *); /* Dquot is marked dirty */
--
1.5.6
next prev parent reply other threads:[~2008-10-27 12:11 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-27 12:11 [PATCH 00/14] 64-bit quotas and preparations for OCFS2 quotas Jan Kara
2008-10-27 12:11 ` Jan Kara [this message]
2008-10-27 12:11 ` [PATCH 02/14] quota: Increase size of variables for limits and inode usage Jan Kara
2008-10-27 12:11 ` [PATCH 03/14] quota: Remove bogus 'optimization' in check_idq() and check_bdq() Jan Kara
2008-10-27 12:11 ` [PATCH 04/14] quota: Make _SUSPENDED just a flag Jan Kara
2008-10-27 12:11 ` [PATCH 05/14] quota: Allow to separately enable quota accounting and enforcing limits Jan Kara
2008-10-27 12:11 ` [PATCH 06/14] ext3: Use sb_any_quota_loaded() instead of sb_any_quota_enabled() Jan Kara
2008-10-27 12:11 ` [PATCH 07/14] ext4: " Jan Kara
2008-10-27 12:11 ` [PATCH 08/14] reiserfs: " Jan Kara
2008-10-27 12:11 ` [PATCH 09/14] quota: Remove compatibility function sb_any_quota_enabled() Jan Kara
2008-10-27 12:11 ` [PATCH 10/14] quota: Introduce DQUOT_QUOTA_SYS_FILE flag Jan Kara
2008-10-27 12:11 ` [PATCH 11/14] quota: Move quotaio_v[12].h from include/linux/ to fs/ Jan Kara
2008-10-27 12:11 ` [PATCH 12/14] quota: Split off quota tree handling into a separate file Jan Kara
2008-10-27 12:11 ` [PATCH 13/14] quota: Convert union in mem_dqinfo to a pointer Jan Kara
2008-10-27 12:11 ` [PATCH 14/14] quota: Support 64-bit quota format Jan Kara
2008-10-28 5:29 ` Andrew Morton
2008-10-29 2:39 ` Jan Kara
2008-10-29 0:41 ` Mingming Cao
2008-10-29 1:02 ` Andrew Morton
2008-10-29 21:31 ` Mingming Cao
2008-10-28 5:55 ` [PATCH 13/14] quota: Convert union in mem_dqinfo to a pointer Andrew Morton
2008-10-29 2:40 ` Jan Kara
2008-10-28 5:52 ` [PATCH 12/14] quota: Split off quota tree handling into a separate file Andrew Morton
2008-10-29 2:43 ` Jan Kara
2008-10-28 22:32 ` [PATCH 11/14] quota: Move quotaio_v[12].h from include/linux/ to fs/ Andrew Morton
2008-10-29 3:21 ` Jan Kara
2008-10-28 5:44 ` [PATCH 10/14] quota: Introduce DQUOT_QUOTA_SYS_FILE flag Andrew Morton
2008-10-28 17:51 ` Joel Becker
2008-10-28 5:40 ` [PATCH 02/14] quota: Increase size of variables for limits and inode usage Andrew Morton
2008-10-28 9:11 ` Boaz Harrosh
2008-10-29 3:01 ` Jan Kara
2008-10-28 5:33 ` [PATCH 01/14] quota: Add callbacks for allocating and destroying dquot structures Andrew Morton
2008-10-29 3:05 ` 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=12251095123763-git-send-email-jack@suse.cz \
--to=jack@suse.cz \
--cc=akpm@linux-foundation.org \
--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).