* [Ocfs2-devel] [PATCH] quota: Add callbacks for allocating and destroying dquot structures
@ 2008-10-20 17:23 Jan Kara
2008-10-21 17:22 ` Joel Becker
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kara @ 2008-10-20 17:23 UTC (permalink / raw)
To: ocfs2-devel
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 8ec4d6c..e1dac3e 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -417,6 +417,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
@@ -465,7 +473,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);
}
@@ -529,7 +537,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;
}
@@ -631,7 +639,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;
@@ -684,7 +695,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 376a050..1ac868e 100644
--- a/include/linux/quota.h
+++ b/include/linux/quota.h
@@ -294,6 +294,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 */
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.2.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Ocfs2-devel] [PATCH] quota: Add callbacks for allocating and destroying dquot structures
2008-10-20 17:23 [Ocfs2-devel] [PATCH] quota: Add callbacks for allocating and destroying dquot structures Jan Kara
@ 2008-10-21 17:22 ` Joel Becker
0 siblings, 0 replies; 2+ messages in thread
From: Joel Becker @ 2008-10-21 17:22 UTC (permalink / raw)
To: ocfs2-devel
On Mon, Oct 20, 2008 at 07:23:34PM +0200, Jan Kara wrote:
> 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.
...
> --- a/include/linux/quota.h
> +++ b/include/linux/quota.h
> @@ -294,6 +294,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 */
Probably want to mention that ->destroy_dquot() is optional and
really matches ->alloc_dquot().
Joel
--
"Every day I get up and look through the Forbes list of the richest
people in America. If I'm not there, I go to work."
- Robert Orben
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-10-21 17:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-20 17:23 [Ocfs2-devel] [PATCH] quota: Add callbacks for allocating and destroying dquot structures Jan Kara
2008-10-21 17:22 ` Joel Becker
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.