
;
; Virtual Server Project
; Per Context Quota Support
;
; (C) 2003 Herbert Pötzl <herbert@13thfloor.at>
;
; Changelog:
;
;   0.03  - first public release
;         - whitespace cleanups
;   0.04  - quota hash totals
;   0.05  - dqhash remove extended
;         - fixed a debug bug ;)
;   0.06  - removed buggy totals
;         - changed quotactl return
;   0.07  - added quota security
;   0.08  - lowered security (fix) 
;   0.09  - fixed potential race
;         - removed DQUOT_DROP bug()
;   0.10  - fixed bug in invalidate_dquots()
;         - fixed bug in read_inode()
;         - fixed bug in add_dquot_ref()
;         - added some debug messages
;   0.11  - added dqhash_transfer check
;         - fixed bug in transfer to list
;   0.12  - adapted to vs1.1 devel branch
;         - changed internal nomenclature
;
; this patch is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 2
; of the License, or (at your option) any later version.
;
; this patch is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.
;

diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/drivers/char/sysrq.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/drivers/char/sysrq.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/drivers/char/sysrq.c	Sat Nov 29 17:13:22 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/drivers/char/sysrq.c	Sat Nov 29 17:16:05 2003
@@ -146,6 +146,7 @@ static void go_sync(struct super_block *
 	if (remount_flag) { /* Remount R/O */
 		int ret, flags;
 		struct list_head *p;
+		struct dqhash *dqh;
 
 		if (sb->s_flags & MS_RDONLY) {
 			printk("R/O\n");
@@ -160,7 +161,9 @@ static void go_sync(struct super_block *
 				file->f_mode &= ~2;
 		}
 		file_list_unlock();
-		DQUOT_OFF(sb->s_dqh);
+		
+		list_for_each_entry(dqh, &sb->s_dqhs, dqh_sblist)
+			DQUOT_OFF(dqh);
 		fsync_dev(sb->s_dev);
 		flags = MS_RDONLY;
 		if (sb->s_op && sb->s_op->remount_fs) {
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/buffer.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/buffer.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/buffer.c	Sat Nov 29 17:13:22 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/buffer.c	Sat Nov 29 17:16:05 2003
@@ -338,12 +338,14 @@ int sync_buffers(kdev_t dev, int wait)
 
 int fsync_super(struct super_block *sb)
 {
+	struct dqhash *dqh;
 	kdev_t dev = sb->s_dev;
 	sync_buffers(dev, 0);
 
 	lock_kernel();
 	sync_inodes_sb(sb);
-	DQUOT_SYNC_DQH(sb->s_dqh);
+	list_for_each_entry(dqh, &sb->s_dqhs, dqh_sblist)
+		DQUOT_SYNC_DQH(dqh);
 	lock_super(sb);
 	if (sb->s_dirt && sb->s_op && sb->s_op->write_super)
 		sb->s_op->write_super(sb);
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/dquot.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/dquot.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/dquot.c	Sat Nov 29 17:13:22 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/dquot.c	Sat Nov 29 17:16:05 2003
@@ -175,9 +175,52 @@ static inline void put_dquot_dup_ref(str
 	dquot->dq_dup_ref--;
 }
 
+	/* dqhash hash (meta) */
+
+static struct list_head dqhash_hash[NR_DQH_HASH];
+
+#define HASHSB(sb) ((unsigned int ) (sb))
+
+static inline int const dqh_hashfn(struct super_block *sb, unsigned int ctx)
+{
+	return (HASHSB(sb) ^ ctx) % NR_DQH_HASH;
+}
+
+static inline void insert_dqhash_hash(struct dqhash *hash)
+{
+	unsigned int hashent = dqh_hashfn(hash->dqh_sb, hash->dqh_xid);
+	struct list_head *head = dqhash_hash + hashent;
+	
+	list_add(&hash->dqh_list, head);
+	list_add(&hash->dqh_sblist, &hash->dqh_sb->s_dqhs);
+}
+
+static inline void remove_dqhash_hash(struct dqhash *hash)
+{
+	list_del_init(&hash->dqh_list);
+	list_del_init(&hash->dqh_sblist);
+}
+
+static inline struct dqhash *find_dqhash(unsigned int hashent, struct super_block *sb, unsigned int ctx)
+{
+	struct list_head *head;
+	struct dqhash *dqh;
+
+	for (head = dqhash_hash[hashent].next; head != dqhash_hash+hashent; head = head->next) {
+		dqh = list_entry(head, struct dqhash, dqh_list);
+		if (dqh->dqh_sb == sb && dqh->dqh_xid == ctx)
+			return dqh;
+	}
+	return NULL;
+}
+
+/* Add a dquot to the head of the free list */
+
+	/* dquot hash functions */
+
 static inline int const hashfn(unsigned int id, int type)
 {
-	return (id * (MAXQUOTAS - type)) % NR_DQHASH;
+	return ((id + 42) * (MAXQUOTAS - type)) % NR_DQHASH;
 }
 
 static inline void insert_dquot_hash(struct dqhash *hash, struct dquot *dquot)
@@ -189,9 +232,13 @@ static inline void insert_dquot_hash(str
 
 static inline void remove_dquot_hash(struct dquot *dquot)
 {
+	struct dqhash *dqh = dquot->dq_dqh;
+
+	if (!dqh)
+		BUG();
 	list_del_init(&dquot->dq_hash);
-	dqhput(dquot->dq_dqh);
 	dquot->dq_dqh = NULL;
+	dqhput(dqh);
 }
 
 static inline struct dquot *find_dquot(struct dqhash *hash, unsigned int hashent, unsigned int id, int type)
@@ -344,7 +391,7 @@ static int commit_dqblk(struct dquot *dq
  * inuse list, we don't have to restart searching... */
 static void invalidate_dquots(struct dqhash *hash, int type)
 {
-	int i;
+	int i, temp;
 
 	for (i=0; i<NR_DQHASH; i++) {
 		struct list_head *head = &hash->dqh_hash[i];
@@ -354,15 +401,21 @@ static void invalidate_dquots(struct dqh
 
 			if (dquot->dq_type != type)
 				continue;
-			dquot->dq_flags |= DQ_INVAL;
 
-			if (dquot->dq_count)
+			temp = dquot->dq_flags;
+			dquot->dq_flags |= DQ_INVAL;
+			if (dquot->dq_count) {
+				printk("··· quota in use: %p (%d)\n", dquot, dquot->dq_count);
+				printk("··· dquot (%d,%d,%d) dqh: %p (%d)\n",
+					dquot->dq_id, dquot->dq_type, temp,
+					dquot->dq_dqh, (dquot->dq_dqh?dquot->dq_dqh->dqh_xid:-1));
 				/*
 				 *  Wait for any users of quota. As we have already cleared the flags in
 				 *  superblock and cleared all pointers from inodes we are assured
 				 *  that there will be no new users of this quota.
 				 */
 				__wait_dquot_unused(dquot);
+			}
 				
 			remove_dquot_hash(dquot);
 			remove_free_dquot(dquot);
@@ -376,9 +429,9 @@ static void invalidate_dquots(struct dqh
 
 /* Dquota Hash Management Functions */
 
-static LIST_HEAD(dqhash_list);
+static unsigned int dqhash_id = 0;
 
-struct dqhash *new_dqhash(struct super_block *sb, unsigned int id)
+struct dqhash *new_dqhash(struct super_block *sb, unsigned int ctx)
 {
 	struct dqhash *hash;
 	int i;
@@ -388,9 +441,11 @@ struct dqhash *new_dqhash(struct super_b
 		return ERR_PTR(-ENOMEM);
 
 	memset(hash, 0, sizeof(struct dqhash));
-	hash->dqh_id = id;
+	hash->dqh_id = dqhash_id++;
+	hash->dqh_xid = ctx;
 	atomic_set(&hash->dqh_count, 1);
 	INIT_LIST_HEAD(&hash->dqh_list);
+	INIT_LIST_HEAD(&hash->dqh_sblist);
 	for (i = 0; i < NR_DQHASH; i++)
 		INIT_LIST_HEAD(hash->dqh_hash + i);
 	sema_init(&hash->dqh_dqopt.dqio_sem, 1);
@@ -400,9 +455,9 @@ struct dqhash *new_dqhash(struct super_b
 	hash->dqh_sb = sb;
 
 	lock_kernel();
-	list_add(&hash->dqh_list, &dqhash_list);
+	dprintk ("··· new_dqhash: #%d %p (sb=%p,ctx=%d)\n", hash->dqh_id, hash, hash->dqh_sb, hash->dqh_xid);
+	insert_dqhash_hash(hash);
 	unlock_kernel();
-	dprintk ("··· new_dqhash: %p [#%d]\n", hash, hash->dqh_id);
 	return hash;
 }
 
@@ -410,33 +465,24 @@ void destroy_dqhash(struct dqhash *hash)
 {
 	int cnt;
 
-	dprintk ("··· destroy_dqhash: %p [#%d] c=%d\n", hash, hash->dqh_id, atomic_read(&hash->dqh_count));
+	dprintk ("··· destroy_dqhash: #%d %p (sb=%p,ctx=%d)\n", hash->dqh_id, hash, hash->dqh_sb, hash->dqh_xid);
 	lock_kernel();
-	list_del_init(&hash->dqh_list);
+	remove_dqhash_hash(hash);
 	unlock_kernel();
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++)	/* should not be required anymore! */
 		invalidate_dquots(hash, cnt);
+	hash->dqh_xid = -1;
 	kfree(hash);
 }
 
-
-struct dqhash *find_dqhash(unsigned int id)
+struct dqhash *get_dqhash(struct super_block *sb, unsigned int ctx)
 {
-	struct list_head *head;
+	unsigned int hashent = dqh_hashfn(sb, ctx);
 	struct dqhash *hash;
 
-	lock_kernel();
-	list_for_each(head, &dqhash_list) {
-		hash = list_entry(head, struct dqhash, dqh_list);
-		if (hash->dqh_id == id)
-			goto dqh_found;
-	}
-	unlock_kernel();
+	if ((hash = find_dqhash(hashent, sb, ctx)))
+		return dqhget(hash);
 	return NULL;
-	
-dqh_found:
-	unlock_kernel();
-	return dqhget(hash);
 }
 
 
@@ -490,12 +536,19 @@ restart:
 	spin_lock(&sb_lock);
 	list_for_each(head, &super_blocks) {
 		struct super_block *sb = list_entry(head, struct super_block, s_list);
-		struct dqhash *dqh = sb->s_dqh;
+		struct list_head *qhead;
 
-		for (cnt = 0, dirty = 0; cnt < MAXQUOTAS; cnt++)
-			if ((type == cnt || type == -1) && dqh_has_quota_enabled(dqh, cnt)
-			    && dqh_dqopt(dqh)->info[cnt].dqi_flags & DQF_ANY_DQUOT_DIRTY)
-				dirty = 1;
+		dirty = 0;
+		list_for_each(qhead, &sb->s_dqhs) {
+			struct dqhash *dqh = list_entry(qhead, struct dqhash, dqh_sblist);
+
+			for (cnt = 0; cnt < MAXQUOTAS; cnt++)
+				if ((type == cnt || type == -1) && dqh_has_quota_enabled(dqh, cnt)
+				&& dqh_dqopt(dqh)->info[cnt].dqi_flags & DQF_ANY_DQUOT_DIRTY)
+					dirty = 1;
+			if (dirty)
+				break;
+		}
 		if (!dirty)
 			continue;
 		sb->s_count++;
@@ -511,28 +564,34 @@ restart:
 	return NULL;
 }
 
+void sync_dquots_sb(struct super_block *sb, int type)
+{
+	struct list_head *head;
+	
+	lock_kernel();
+	list_for_each(head, &sb->s_dqhs) {
+		struct dqhash *dqh = list_entry(head, struct dqhash, dqh_sblist);
+
+		if (dqh->dqh_qcop->quota_sync)
+			dqh->dqh_qcop->quota_sync(dqh, type);
+	}
+	unlock_kernel();
+}
+
+
 void sync_dquots_dev(kdev_t dev, int type)
 {
 	struct super_block *sb;
-	struct dqhash *dqh;
 
 	if (dev) {
 		if ((sb = get_super(dev))) {
-			lock_kernel();
-			dqh = sb->s_dqh;
-			if (dqhash_valid(dqh) && dqh->dqh_qcop->quota_sync)
-				dqh->dqh_qcop->quota_sync(dqh, type);
-			unlock_kernel();
+			sync_dquots_sb(sb, type);
 			drop_super(sb);
 		}
 	}
 	else {
 		while ((sb = get_super_to_sync(type))) {
-			lock_kernel();
-			dqh = sb->s_dqh;
-			if (dqhash_valid(dqh) && dqh->dqh_qcop->quota_sync)
-				dqh->dqh_qcop->quota_sync(dqh, type);
-			unlock_kernel();
+			sync_dquots_sb(sb, type);
 			drop_super(sb);
 		}
 	}
@@ -760,9 +819,19 @@ restart:
 	list_for_each(p, &sb->s_files) {
 		struct file *filp = list_entry(p, struct file, f_list);
 		struct inode *inode = filp->f_dentry->d_inode;
-		if (filp->f_mode & FMODE_WRITE && dqinit_needed(inode, type)) {
+
+		CHECK_DQHASH(inode);
+		if (filp->f_mode & FMODE_WRITE
+			&& hash->dqh_xid == inode->i_xid
+			&& dqinit_needed(inode, type)) {
 			struct vfsmount *mnt = mntget(filp->f_vfsmnt);
 			struct dentry *dentry = dget(filp->f_dentry);
+
+			if (hash != inode->i_dqh)
+				printk("··· BAD INODE: add_dquot_ref(%p[%d], %d) %p[%d] »%*s«\n",
+					hash, hash->dqh_xid, type, inode, inode->i_xid,
+					filp->f_dentry->d_name.len, filp->f_dentry->d_name.name);
+
 			file_list_unlock();
 			hash->dqh_qop->initialize(inode, type);
 			dput(dentry);
@@ -772,6 +841,7 @@ restart:
 		}
 	}
 	file_list_unlock();
+	dqhget(hash);
 }
 
 /* Return 0 if dqput() won't block (note that 1 doesn't necessarily mean blocking) */
@@ -1021,12 +1091,15 @@ static int check_bdq(struct dquot *dquot
 void dquot_initialize(struct inode *inode, int type)
 {
 	struct dquot *dquot[MAXQUOTAS];
-	struct dqhash *dqh = inode->i_sb->s_dqh;
+	struct dqhash *dqh = NULL;
 	unsigned int id = 0;
 	int cnt;
 
 	if (IS_NOQUOTA(inode))
 		return;
+
+	dqh = get_dqhash(inode->i_sb, current->vx_id);
+	dprintk("··· dquot_initialize: #%d %p\n", (dqh)?dqh->dqh_id:0, dqh);
 	/* Build list of quotas to initialize... We can block here */
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		dquot[cnt] = NODQUOT;
@@ -1046,6 +1119,8 @@ void dquot_initialize(struct inode *inod
 			dquot[cnt] = dqget(dqh, id, cnt);
 		}
 	}
+	dqhput(dqh);
+
 	/* NOBLOCK START: Here we shouldn't block */
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		if (dquot[cnt] == NODQUOT || !dqh_has_quota_enabled(dqh, cnt) || inode->i_dquot[cnt] != NODQUOT)
@@ -1196,19 +1271,28 @@ void dquot_free_inode(const struct inode
 
 /*
  * Transfer the number of inode and blocks from one diskquota to an other.
- *
+ * If requested this, is also done from one quota hash to another.
  * This operation can block, but only after everything is updated
  */
-int dquot_transfer(struct inode *inode, struct iattr *iattr)
+int __dquot_transfer(struct inode *inode, struct iattr *iattr, struct dqhash *hash)
 {
 	qsize_t space;
 	struct dquot *transfer_from[MAXQUOTAS];
 	struct dquot *transfer_to[MAXQUOTAS];
-	struct dqhash *dqh = inode->i_sb->s_dqh;
-	int cnt, ret = NO_QUOTA, chuid = (iattr->ia_valid & ATTR_UID) && inode->i_uid != iattr->ia_uid,
-	    chgid = (iattr->ia_valid & ATTR_GID) && inode->i_gid != iattr->ia_gid;
+	struct dqhash *dqh = inode->i_dqh; /* use find_ctx_dqhash(inode->i_sb) */
+	uid_t new_uid = (iattr->ia_valid & ATTR_UID) ? iattr->ia_uid : inode->i_uid;
+	gid_t new_gid = (iattr->ia_valid & ATTR_GID) ? iattr->ia_gid : inode->i_gid;
+	int cnt, chuid, chgid;
 	char warntype[MAXQUOTAS];
 
+	if (hash == dqh) {
+		chuid = (iattr->ia_valid & ATTR_UID) && inode->i_uid != iattr->ia_uid;
+		chgid = (iattr->ia_valid & ATTR_GID) && inode->i_gid != iattr->ia_gid;
+	}
+	/* transfer between quota hashes */
+	else
+		chuid = chgid = 1;
+
 	/* Clear the arrays */
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		transfer_to[cnt] = transfer_from[cnt] = NODQUOT;
@@ -1216,30 +1300,35 @@ int dquot_transfer(struct inode *inode, 
 	}
 	/* First build the transfer_to list - here we can block on reading of dquots... */
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-		if (!dqh_has_quota_enabled(dqh, cnt))
+		if (!dqh_has_quota_enabled(hash, cnt))
 			continue;
 		switch (cnt) {
 			case USRQUOTA:
 				if (!chuid)
 					continue;
-				transfer_to[cnt] = dqget(dqh, iattr->ia_uid, cnt);
+				transfer_to[cnt] = dqget(hash, new_uid, cnt);
 				break;
 			case GRPQUOTA:
 				if (!chgid)
 					continue;
-				transfer_to[cnt] = dqget(dqh, iattr->ia_gid, cnt);
+				transfer_to[cnt] = dqget(hash, new_gid, cnt);
 				break;
 		}
 	}
+
 	/* NOBLOCK START: From now on we shouldn't block */
 	space = inode_get_bytes(inode);
 	/* Build the transfer_from list and check the limits */
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-		/* The second test can fail when quotaoff is in progress... */
-		if (transfer_to[cnt] == NODQUOT || !dqh_has_quota_enabled(dqh, cnt))
+		if (!dqh_has_quota_enabled(dqh, cnt))
+			/* transfer from noquota domain ... */
 			continue;
 		transfer_from[cnt] = dqduplicate(inode->i_dquot[cnt]);
-		if (transfer_from[cnt] == NODQUOT)	/* Can happen on quotafiles (quota isn't initialized on them)... */
+		if (transfer_from[cnt] == NODQUOT)	
+			/* Can happen on quotafiles (quota isn't initialized on them)... */
+			continue;
+		if (transfer_to[cnt] == NODQUOT || !dqh_has_quota_enabled(hash, cnt))
+			/* transfer to noquota domain ... */
 			continue;
 		if (check_idq(transfer_to[cnt], 1, warntype+cnt) == NO_QUOTA ||
 		    check_bdq(transfer_to[cnt], space, 0, warntype+cnt) == NO_QUOTA)
@@ -1250,29 +1339,34 @@ int dquot_transfer(struct inode *inode, 
 	 * Finally perform the needed transfer from transfer_from to transfer_to
 	 */
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
-		/*
-		 * Skip changes for same uid or gid or for non-existing quota-type.
-		 */
-		if (transfer_from[cnt] == NODQUOT || transfer_to[cnt] == NODQUOT)
+		if (transfer_from[cnt] == NODQUOT && transfer_to[cnt] == NODQUOT)
+			/* nothing to transfer ... */
 			continue;
 
-		dquot_decr_inodes(transfer_from[cnt], 1);
-		dquot_decr_space(transfer_from[cnt], space);
+		if (transfer_from[cnt] != NODQUOT) {
+			dquot_decr_inodes(transfer_from[cnt], 1);
+			dquot_decr_space(transfer_from[cnt], space);
+		}
 
-		dquot_incr_inodes(transfer_to[cnt], 1);
-		dquot_incr_space(transfer_to[cnt], space);
+		if (transfer_to[cnt] != NODQUOT) {
+			dquot_incr_inodes(transfer_to[cnt], 1);
+			dquot_incr_space(transfer_to[cnt], space);
+		}
 
-		if (inode->i_dquot[cnt] == NODQUOT)
-			BUG();
 		inode->i_dquot[cnt] = transfer_to[cnt];
-		/*
-		 * We've got to release transfer_from[] twice - once for dquot_transfer() and
-		 * once for inode. We don't want to release transfer_to[] as it's now placed in inode
-		 */
-		transfer_to[cnt] = transfer_from[cnt];
 	}
 	/* NOBLOCK END. From now on we can block as we wish */
-	ret = QUOTA_OK;
+
+	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
+		/* First we must put duplicate - otherwise we might deadlock */
+		if (transfer_from[cnt] != NODQUOT) {
+			dqputduplicate(transfer_from[cnt]);
+			/* release for inode */
+			dqput(transfer_from[cnt]);
+		}
+	}
+	return QUOTA_OK;
+
 warn_put_all:
 	flush_warnings(transfer_to, warntype);
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
@@ -1282,6 +1376,27 @@ warn_put_all:
 		if (transfer_to[cnt] != NODQUOT)
 			dqput(transfer_to[cnt]);
 	}
+	return NO_QUOTA;
+}
+
+int dquot_transfer(struct inode *inode, struct iattr *iattr)
+{
+	return __dquot_transfer(inode, iattr, inode->i_dqh);
+}
+
+int dqhash_transfer(struct inode *inode, struct dqhash *hash)
+{
+	struct iattr iattr;
+	int ret = 0;
+	
+	if (hash == inode->i_dqh)
+		return ret;
+	if (!IS_QUOTAINIT(inode) || IS_NOQUOTA(inode))
+		return ret;
+	dprintk("··· dqhash_transfer: %p [#%d], hash: %p->%p\n",
+		inode, inode->i_xid, inode->i_dqh, hash);
+	iattr.ia_valid = 0;
+	ret = __dquot_transfer(inode, &iattr, hash);
 	return ret;
 }
 
@@ -1333,7 +1448,7 @@ static inline void reset_enable_flags(st
 extern void remove_dquot_ref(struct dqhash *, int);
 
 /*
- * Turn quota off on a device. type == -1 ==> quotaoff for all types (umount)
+ * Turn quota off on a hash. type == -1 ==> quotaoff for all types (umount)
  */
 int vfs_quota_off(struct dqhash *hash, int type)
 {
@@ -1388,9 +1503,11 @@ int vfs_quota_on(struct dqhash *hash, in
 	}
 
 	down(&dqopt->dqoff_sem);
+	dprintk("··· vfs_quota_on: %p, type=%d, format=%d, path=%s\n", hash, type, format_id, path);
 
 	f = filp_open(path, O_RDWR, 0600);
 
+	dprintk("··· vfs_quota_on: file=%p\n", f);
 	error = PTR_ERR(f);
 	if (IS_ERR(f))
 		goto out_lock;
@@ -1580,6 +1697,16 @@ static ctl_table sys_table[] = {
 	{CTL_FS, "fs", NULL, 0, 0555, fs_table},
 	{},
 };
+
+int	__init init_dqhash_hash(void)
+{
+	int i;
+
+	dprintk("··· dqhash init?\n");
+	for (i = 0; i < NR_DQH_HASH; i++)
+		INIT_LIST_HEAD(dqhash_hash + i);
+	return 0;
+}
 
 static int __init dquot_init(void)
 {
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/ext2/inode.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/ext2/inode.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/ext2/inode.c	Sat Nov 29 17:14:59 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/ext2/inode.c	Sat Nov 29 17:16:05 2003
@@ -963,8 +963,10 @@ void ext2_read_inode (struct inode * ino
 	}
 	inode->i_uid = INOXID_UID(uid, gid);
 	inode->i_gid = INOXID_GID(uid, gid);
-	if (inode->i_sb->s_flags & MS_TAGXID)
-		inode->i_xid = INOXID_XID(uid, gid, le16_to_cpu(raw_inode->i_raw_xid));
+	if (inode->i_sb->s_flags & MS_TAGXID) {
+		int ctx = INOXID_XID(uid, gid, le16_to_cpu(raw_inode->i_raw_xid));
+		__vx_dq_modify(inode, ctx);
+	}	
 
 	inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
 	inode->i_size = le32_to_cpu(raw_inode->i_size);
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/ext3/inode.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/ext3/inode.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/ext3/inode.c	Sat Nov 29 17:14:59 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/ext3/inode.c	Sat Nov 29 17:16:05 2003
@@ -2115,8 +2115,10 @@ void ext3_read_inode(struct inode * inod
 	}
 	inode->i_uid = INOXID_UID(uid, gid);
 	inode->i_gid = INOXID_GID(uid, gid);
-	if (inode->i_sb->s_flags & MS_TAGXID)
-		inode->i_xid = INOXID_XID(uid, gid, le16_to_cpu(raw_inode->i_raw_xid));
+	if (inode->i_sb->s_flags & MS_TAGXID) {
+		int ctx = INOXID_XID(uid, gid, le16_to_cpu(raw_inode->i_raw_xid));
+		__vx_dq_modify(inode, ctx);
+	}
 	
 	inode->i_nlink = le16_to_cpu(raw_inode->i_links_count);
 	inode->i_size = le32_to_cpu(raw_inode->i_size);
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/ext3/super.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/ext3/super.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/ext3/super.c	Sat Nov 29 17:14:59 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/ext3/super.c	Sat Nov 29 17:16:05 2003
@@ -1136,7 +1136,6 @@ struct super_block * ext3_read_super (st
 	 */
 	sb->s_op = &ext3_sops;
 	sb->s_qop = &ext3_qops;
-	sb->s_dqh->dqh_qop = &ext3_qops;
 	INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
 
 	sb->s_root = 0;
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/inode.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/inode.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/inode.c	Sat Nov 29 17:14:59 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/inode.c	Sat Nov 29 17:16:05 2003
@@ -97,7 +97,8 @@ static struct inode *alloc_inode(struct 
 		inode->i_sb = sb;
 		if (sb->s_flags & MS_TAGXID)
 			inode->i_xid = current->vx_id;
-		inode->i_dqh = dqhget(sb->s_dqh);
+		inode->i_xid = 0;       /* maybe ctx -1 would be better? */
+		inode->i_dqh = get_dqhash(sb, inode->i_xid);
 		inode->i_dev = sb->s_dev;
 		inode->i_blkbits = sb->s_blocksize_bits;
 		inode->i_flags = 0;
@@ -1349,5 +1350,41 @@ void remove_dquot_ref(struct dqhash *has
 	put_dquot_list(&tofree_head);
 	dqhput(hash); /* is this required? */
 }
+
+int remove_inode_dqhash_ref(struct inode *);
+
+void remove_dqhash_ref(struct dqhash *hash)
+{
+	struct list_head *act_head;
+	struct super_block *sb = hash->dqh_sb;
+	struct inode *inode;
+
+	lock_kernel();          /* This lock is for quota code */
+	spin_lock(&inode_lock); /* This lock is for inodes code */
+
+	list_for_each(act_head, &inode_in_use) {
+		inode = list_entry(act_head, struct inode, i_list);
+		if (inode->i_dqh == hash)
+			remove_inode_dqhash_ref(inode);
+	}
+	list_for_each(act_head, &inode_unused) {
+		inode = list_entry(act_head, struct inode, i_list);
+		if (inode->i_dqh == hash)
+			remove_inode_dqhash_ref(inode);
+	}
+	list_for_each(act_head, &sb->s_dirty) {
+		inode = list_entry(act_head, struct inode, i_list);
+		if (inode->i_dqh == hash)
+			remove_inode_dqhash_ref(inode);
+	}
+	list_for_each(act_head, &sb->s_locked_inodes) {
+		inode = list_entry(act_head, struct inode, i_list);
+		if (inode->i_dqh == hash)
+			remove_inode_dqhash_ref(inode);
+	}
+	spin_unlock(&inode_lock);
+	unlock_kernel();
+}
+
 
 #endif
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/ioctl.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/ioctl.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/ioctl.c	Sat Nov 29 17:14:59 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/ioctl.c	Sat Nov 29 17:16:05 2003
@@ -154,7 +154,6 @@ asmlinkage long sys_ioctl(unsigned int f
 	}
 	unlock_kernel();
 	fput(filp);
-
 out:
 	return error;
 }
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/namespace.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/namespace.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/namespace.c	Sat Nov 29 17:13:22 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/namespace.c	Sat Nov 29 17:16:05 2003
@@ -25,6 +25,7 @@ struct vfsmount *do_kern_mount(const cha
 int do_remount_sb(struct super_block *sb, int flags, void * data);
 void kill_super(struct super_block *sb);
 extern int __init init_rootfs(void);
+extern int __init init_dqhash_hash(void);
 
 static struct list_head *mount_hashtable;
 static int hash_mask, hash_bits;
@@ -334,10 +335,12 @@ static int do_umount(struct vfsmount *mn
 	spin_lock(&dcache_lock);
 
 	if (atomic_read(&sb->s_active) == 1) {
+		struct list_head *head;
 		/* last instance - try to be smart */
 		spin_unlock(&dcache_lock);
 		lock_kernel();
-		DQUOT_OFF(sb->s_dqh);
+		list_for_each(head, &sb->s_dqhs)
+			DQUOT_OFF(list_entry(head, struct dqhash, dqh_sblist));
 		acct_auto_close(sb->s_dev);
 		unlock_kernel();
 		spin_lock(&dcache_lock);
@@ -1065,6 +1068,7 @@ void __init mnt_init(unsigned long mempa
 		d++;
 		i--;
 	} while (i);
+	init_dqhash_hash();
 	init_rootfs();
 	init_mount_tree();
 }
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/quota.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/quota.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/quota.c	Sat Nov 29 17:13:22 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/quota.c	Sat Nov 29 17:16:05 2003
@@ -516,6 +516,49 @@ static int do_compat_quotactl(struct dqh
 #define NEW_COMMAND(c) ((c) & (0x80 << 16))
 #define XQM_COMMAND(c) (((c) & ('X' << 8)) == ('X' << 8))
 
+int remove_dqhash_ref(struct dqhash *hash);
+
+int remove_inode_dqhash_ref(struct inode *inode)
+{
+	lock_kernel();
+	if (!dqhash_valid(inode->i_dqh))
+		BUG();
+	if (inode->i_dqh->dqh_qop->drop)
+		inode->i_dqh->dqh_qop->drop(inode);
+	dqhput(inode->i_dqh);
+	if (inode->i_flags & S_QUOTA)
+		printk("··· QUOTA still on for %p (%d)", inode, inode->i_xid);
+	inode->i_dqh = NULL;
+	unlock_kernel();
+	return 0;
+}
+
+int do_dqhashctl(struct super_block *sb, int ctx, uint cmds)
+{
+	int ret = -EINVAL;
+	struct dqhash *dqh = get_dqhash(sb, ctx);
+
+	if (!dqhash_valid(dqh) && (cmds == Q_ADD_DQHASH)) {
+		if (!(sb->s_flags & MS_TAGXID))
+			return -ENOSYS;
+		dqh = new_dqhash(sb, ctx);
+		/* keep one refcount to hash */
+		return 0;
+	}
+	if (dqhash_valid(dqh) && (cmds == Q_REM_DQHASH)) {
+		remove_dqhash_ref(dqh);
+
+		dprintk("··· dqhash : %p [%d]\n", dqh, atomic_read(&dqh->dqh_count));
+		ret = 0;
+		if (atomic_read(&dqh->dqh_count) > 2)
+			ret = -EBUSY;
+		else	/* put last but one refcount */
+			dqhput(dqh);
+	}
+	dqhput(dqh);
+	return ret;
+}
+
 /*
  * This is the system call interface. This communicates with
  * the user-level programs. Currently this only supports diskquota
@@ -536,13 +579,22 @@ asmlinkage long sys_quotactl(unsigned in
 	if (cmds != Q_V1_GETSTATS && cmds != Q_V2_GETSTATS && IS_ERR(sb = resolve_dev(special))) {
 		ret = PTR_ERR(sb);
 		sb = NULL;
-		goto out;
+		goto out_sb;
+	}
+	else if (sb) {
+		int ctx = current->vx_id;
+
+		if ((cmds == Q_ADD_DQHASH) || (cmds == Q_REM_DQHASH)) {
+			ret = -EPERM;
+			if (ctx == 0)
+				ret = do_dqhashctl(sb, id, cmds);
+			goto out_sb;
+		}
+		ret = -ENXIO;
+		dqh = get_dqhash(sb, current->vx_id);
+		if (!dqhash_valid(dqh))
+			goto out;
 	}
-	else if (sb)
-		dqh = sb->s_dqh;
-	if (!dqhash_valid(dqh))
-		goto out;
-		
 	if (!NEW_COMMAND(cmds) && !XQM_COMMAND(cmds)) {
 		if ((ret = check_compat_quotactl_valid(dqh, type, cmds, id)) < 0)
 			goto out;
@@ -553,6 +605,9 @@ asmlinkage long sys_quotactl(unsigned in
 		goto out;
 	ret = do_quotactl(dqh, type, cmds, id, addr);
 out:
+	if (dqh)
+		dqhput(dqh);
+out_sb:
 	if (sb)
 		drop_super(sb);
 	unlock_kernel();
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/super.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/super.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/super.c	Sat Nov 29 17:13:22 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/super.c	Sat Nov 29 17:16:05 2003
@@ -271,6 +271,7 @@ static struct super_block *alloc_super(v
 		INIT_LIST_HEAD(&s->s_locked_inodes);
 		INIT_LIST_HEAD(&s->s_files);
 		INIT_LIST_HEAD(&s->s_instances);
+		INIT_LIST_HEAD(&s->s_dqhs);
 		init_rwsem(&s->s_umount);
 		sema_init(&s->s_lock, 1);
 		down_write(&s->s_umount);
@@ -282,8 +283,6 @@ static struct super_block *alloc_super(v
 		s->s_op = &empty_sops;
 		s->s_qop = sb_dquot_ops;
 		s->s_qcop = sb_quotactl_ops;
-		/* quick hack to make dqhash id unique, sufficient for now */
-		s->s_dqh = new_dqhash(s, (unsigned int)s);
 	}
 	return s;
 }
@@ -296,7 +295,12 @@ static struct super_block *alloc_super(v
  */
 static inline void destroy_super(struct super_block *s)
 {
-	dqhput(s->s_dqh);
+	struct list_head *pos, *n;
+
+	list_for_each_safe(pos, n, &s->s_dqhs)
+		dqhput(list_entry(pos, struct dqhash, dqh_sblist));
+	list_for_each_safe(pos, n, &s->s_dqhs)
+		destroy_dqhash(list_entry(pos, struct dqhash, dqh_sblist));
 	kfree(s);
 }
 
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/udf/super.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/udf/super.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/udf/super.c	Sat Nov 29 17:13:22 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/udf/super.c	Sat Nov 29 17:16:05 2003
@@ -1436,7 +1436,6 @@ udf_read_super(struct super_block *sb, v
 	/* Fill in the rest of the superblock */
 	sb->s_op = &udf_sb_ops;
 	sb->s_qop = NULL;
-	sb->s_dqh->dqh_qop = NULL;
 	sb->s_dirt = 0;
 	sb->s_magic = UDF_SUPER_MAGIC;
 
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/ufs/super.c linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/ufs/super.c
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/fs/ufs/super.c	Sat Nov 29 17:13:22 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/fs/ufs/super.c	Sat Nov 29 17:16:05 2003
@@ -745,7 +745,6 @@ magic_found:
 	sb->s_blocksize_bits = fs32_to_cpu(sb, usb1->fs_fshift);
 	sb->s_op = &ufs_super_ops;
 	sb->s_qop = NULL;
-	sb->s_dqh->dqh_qop = NULL;
 	sb->s_magic = fs32_to_cpu(sb, usb3->fs_magic);
 
 	uspi->s_sblkno = fs32_to_cpu(sb, usb1->fs_sblkno);
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/include/linux/fs.h linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/include/linux/fs.h
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/include/linux/fs.h	Sat Nov 29 17:14:59 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/include/linux/fs.h	Sat Nov 29 17:19:45 2003
@@ -771,7 +771,7 @@ struct super_block {
 
 	struct block_device	*s_bdev;
 	struct list_head	s_instances;
-	struct dqhash		*s_dqh;		/* Diskquota hash */
+	struct list_head	s_dqhs;		/* Diskquota hashes */
 
 	union {
 		struct minix_sb_info	minix_sb;
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/include/linux/quota.h linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/include/linux/quota.h
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/include/linux/quota.h	Sat Nov 29 17:13:22 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/include/linux/quota.h	Sat Nov 29 17:16:05 2003
@@ -58,6 +58,7 @@ typedef __u64 qsize_t;          /* Type 
 #define toqb(x) (((x) + QUOTABLOCK_SIZE - 1) >> QUOTABLOCK_BITS)
 
 /* are NULL dqhash ptrs valid? */
+#define	HANDLE_DQHASH_NULL
 #ifdef	HANDLE_DQHASH_NULL
 #define	dqhash_valid(hash)	((hash) != NULL)
 #else
@@ -205,6 +206,7 @@ struct dqstats {
 extern struct dqstats dqstats;
 
 #define NR_DQHASH	13	/* Just an arbitrary number */
+#define NR_DQH_HASH	17	/* Just an arbitrary number */
 
 #define DQ_LOCKED     0x01	/* dquot under IO */
 #define DQ_MOD        0x02	/* dquot modified since read */
@@ -317,9 +319,11 @@ void unregister_quota_format(struct quot
 void init_dquot_operations(struct dquot_operations *fsdqops);
 
 struct dqhash {
-	struct list_head dqh_list;	/* List of all quota hashes */
-	unsigned int dqh_id;		/* ID for hash */
+	struct list_head dqh_list;	/* quota hashes within hash slot */
+	struct list_head dqh_sblist;	/* all superblock quota hashes */
 	atomic_t dqh_count;		/* Use count */
+	unsigned int dqh_id;		/* ID for hash */
+	unsigned int dqh_xid;		/* context */
 	struct quota_info dqh_dqopt;	/* Diskquota specific options */
 	struct dquot_operations	*dqh_qop;
 	struct quotactl_ops *dqh_qcop;
@@ -331,8 +335,9 @@ struct dqhash {
 
 
 struct dqhash *new_dqhash(struct super_block *, unsigned int);
+struct dqhash *get_dqhash(struct super_block *, unsigned int);
+
 void destroy_dqhash(struct dqhash *);
-struct dqhash *find_dqhash(unsigned int);
 
 static inline void dqhput(struct dqhash *hash)
 {
@@ -357,8 +362,8 @@ static inline void mark_dquot_dirty(stru
 
 #else /* CONFIG_QUOTA */
 
-#define new_dqhash(sb, dqdom)		(0)
-#define find_dqhash(dqdom)		(0)
+#define new_dqhash(sb, ctx)		(0)
+#define get_dqhash(sb, ctx)		(0)
 #define destroy_dqhash(hash)		do { } while(0)
 
 #define dqhput(hash)			do { } while(0)
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/include/linux/quotacompat.h linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/include/linux/quotacompat.h
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/include/linux/quotacompat.h	Fri Nov 28 04:06:34 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/include/linux/quotacompat.h	Sat Nov 29 17:16:05 2003
@@ -83,4 +83,7 @@ struct v2c_dqstats {
 #define Q_V2_SETUSE   0x0F00	/* set usage */
 #define Q_V2_GETSTATS 0x1100	/* get collected stats */
 
+#define Q_ADD_DQHASH  0x2100	/* add dqhash */
+#define Q_REM_DQHASH  0x2200	/* remove dqhash */
+
 #endif
diff -NurpP --minimal linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/include/linux/quotaops.h linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/include/linux/quotaops.h
--- linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07/include/linux/quotaops.h	Sat Nov 29 17:14:59 2003
+++ linux-2.4.23-rc5-vs1.1.6-qh0.12-cx0.07-cq0.12/include/linux/quotaops.h	Sat Nov 29 17:16:05 2003
@@ -35,14 +35,28 @@ extern void dquot_free_space(struct inod
 extern void dquot_free_inode(const struct inode *inode, unsigned long number);
 
 extern int  dquot_transfer(struct inode *inode, struct iattr *iattr);
+extern int  dqhash_transfer(struct inode *inode, struct dqhash *hash);
+
 
+static __inline__ void __vx_dq_modify(struct inode *inode, unsigned int ctx)
+{
+	struct dqhash *dqh = get_dqhash(inode->i_sb, ctx);
+
+	if (dqh != inode->i_dqh) {
+		dqhash_transfer(inode, dqh);
+		dqhput(inode->i_dqh);
+		inode->i_dqh = dqh;
+	} else
+		dqhput(dqh);
+	inode->i_xid = ctx;
+}
 
 static __inline__ void vx_dq_modify(struct inode *inode, unsigned int ctx)
 {
 	if (!(inode->i_sb->s_flags & MS_TAGXID))
 		return;
 	dprintk("··· vx_dq_modify: %p #%d -> #%d\n", inode, inode->i_xid, ctx);
-	inode->i_xid = ctx;
+	__vx_dq_modify(inode, ctx);
 	mark_inode_dirty(inode);
 }
 
@@ -66,6 +80,18 @@ static __inline__ void vx_dq_unlink(stru
 	vx_dq_modify(inode, 0);
 }
 
+static __inline__ void CHECK_DQHASH(struct inode *inode)
+{
+	if (!dqhash_valid(inode->i_dqh))
+		return;
+	if (inode->i_xid != inode->i_dqh->dqh_xid) {
+		printk("··· inode: %p [#%d] != dqh: %p [%d,#%d]\n", inode, inode->i_xid,
+			inode->i_dqh, inode->i_dqh->dqh_id, inode->i_dqh->dqh_xid);
+		dump_stack();
+		// BUG();
+	}
+}
+
 
 /*
  * Operations supported for diskquotas.
@@ -76,8 +102,6 @@ extern struct quotactl_ops vfs_quotactl_
 #define sb_dquot_ops (&dquot_operations)
 #define sb_quotactl_ops (&vfs_quotactl_ops)
 
-#define CHECK_DQHASH(inode)			do { } while(0)
-
 static __inline__ void DQUOT_INIT(struct inode *inode)
 {
 	if (!inode->i_sb)
@@ -96,9 +120,10 @@ static __inline__ void DQUOT_DROP(struct
 {
 	lock_kernel();
 	if (IS_QUOTAINIT(inode)) {
-		if (!inode->i_dqh)
-			out_of_line_bug();
-		inode->i_dqh->dqh_qop->drop(inode);	/* Ops must be set when there's any quota... */
+		if (inode->i_dqh)
+			inode->i_dqh->dqh_qop->drop(inode);	/* Ops must be set when there's any quota... */
+		else
+			printk("DQUOT_DROP: inode without dqh!");
 	}
 	unlock_kernel();
 }
@@ -236,6 +261,10 @@ static __inline__ int DQUOT_OFF(struct d
 #define DQUOT_SYNC_DQH(hash)			do { } while(0)
 #define DQUOT_OFF(hash)				do { } while(0)
 #define DQUOT_TRANSFER(inode, iattr)		(0)
+
+#define new_dqhash(sb, ctx)			(0)
+#define get_dqhash(sb, ctx)			(0)
+#define destroy_dqhash(hash)			do { } while(0)
 
 #define vx_dq_modify(inode, ctx)		do { } while(0)
 #define vx_dq_cond_modify(inode, ctx)		do { } while(0)
