LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] Quota fix 2
@ 2004-05-15 19:28 Jan Kara
  2004-05-16  7:04 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kara @ 2004-05-15 19:28 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, Lukasz Trabinski, Jerome Borsboom, Eugene Crosser,
	torvalds

[-- Attachment #1: Type: text/plain, Size: 324 bytes --]

  Hello,

  another fix for quota code - it fixes the problem with recursion into
filesystem when inode of quota file needs a page + some other allocation
problems. I hope I got the GFP mask setting right.. The patch is against
2.6.6 with the patch you sent to Linus & my previous quota patch. Please
apply.

								Honza


[-- Attachment #2: quota-2.6.6-3-slabfix.diff --]
[-- Type: text/plain, Size: 1761 bytes --]

diff -ruX /home/jack/.kerndiffexclude linux-2.6.6-2-releasefix/fs/dquot.c linux-2.6.6-3-slabfix/fs/dquot.c
--- linux-2.6.6-2-releasefix/fs/dquot.c	2004-05-13 21:05:02.000000000 +0200
+++ linux-2.6.6-3-slabfix/fs/dquot.c	2004-05-14 15:19:38.000000000 +0200
@@ -75,6 +75,7 @@
 #include <linux/proc_fs.h>
 #include <linux/security.h>
 #include <linux/kmod.h>
+#include <linux/pagemap.h>
 
 #include <asm/uaccess.h>
 
@@ -547,7 +548,7 @@
 {
 	struct dquot *dquot;
 
-	dquot = kmem_cache_alloc(dquot_cachep, SLAB_KERNEL);
+	dquot = kmem_cache_alloc(dquot_cachep, SLAB_NOFS);
 	if(!dquot)
 		return NODQUOT;
 
@@ -1366,9 +1367,12 @@
 	error = -EINVAL;
 	if (!fmt->qf_ops->check_quota_file(sb, type))
 		goto out_file_init;
-	/* We don't want quota and atime on quota files (deadlocks possible) */
+	/* We don't want quota and atime on quota files (deadlocks possible)
+	 * We also need to set GFP mask differently because we cannot recurse
+	 * into filesystem when allocating page for quota inode */
 	down_write(&dqopt->dqptr_sem);
 	inode->i_flags |= S_NOQUOTA | S_NOATIME;
+	clear_bit(ffs(__GFP_FS), &inode->i_mapping->flags);
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		to_drop[cnt] = inode->i_dquot[cnt];
 		inode->i_dquot[cnt] = NODQUOT;
diff -ruX /home/jack/.kerndiffexclude linux-2.6.6-2-releasefix/fs/quota_v2.c linux-2.6.6-3-slabfix/fs/quota_v2.c
--- linux-2.6.6-2-releasefix/fs/quota_v2.c	2004-05-13 21:00:27.000000000 +0200
+++ linux-2.6.6-3-slabfix/fs/quota_v2.c	2004-05-14 15:14:28.000000000 +0200
@@ -135,7 +135,7 @@
 
 static dqbuf_t getdqbuf(void)
 {
-	dqbuf_t buf = kmalloc(V2_DQBLKSIZE, GFP_KERNEL);
+	dqbuf_t buf = kmalloc(V2_DQBLKSIZE, GFP_NOFS);
 	if (!buf)
 		printk(KERN_WARNING "VFS: Not enough memory for quota buffers.\n");
 	return buf;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Quota fix 2
  2004-05-15 19:28 [PATCH] Quota fix 2 Jan Kara
@ 2004-05-16  7:04 ` Andrew Morton
  2004-05-17  9:13   ` Jan Kara
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2004-05-16  7:04 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-kernel, lukasz, j.borsboom, crosser, torvalds

Jan Kara <jack@ucw.cz> wrote:
>
>   another fix for quota code - it fixes the problem with recursion into
>  filesystem when inode of quota file needs a page + some other allocation
>  problems.

It makes sense.

> I hope I got the GFP mask setting right..

nope!  Here's a fix against your patch.




---

 25-akpm/fs/dquot.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletion(-)

diff -puN fs/dquot.c~quota-recursion-fix-fix fs/dquot.c
--- 25/fs/dquot.c~quota-recursion-fix-fix	2004-05-15 23:58:31.365278768 -0700
+++ 25-akpm/fs/dquot.c	2004-05-16 00:02:52.667554784 -0700
@@ -1372,7 +1372,16 @@ static int vfs_quota_on_file(struct file
 	 * into filesystem when allocating page for quota inode */
 	down_write(&dqopt->dqptr_sem);
 	inode->i_flags |= S_NOQUOTA | S_NOATIME;
-	clear_bit(ffs(__GFP_FS), &inode->i_mapping->flags);
+
+	/*
+	 * We write to quota files deep within filesystem code.  We don't want
+	 * the VFS to reenter filesystem code when it tries to allocate a
+	 * pagecache page for the quota file write.  So clear __GFP_FS in
+	 * the quota file's allocation flags.
+	 */
+	mapping_set_gfp_mask(inode->i_mapping,
+		mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS);
+
 	for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
 		to_drop[cnt] = inode->i_dquot[cnt];
 		inode->i_dquot[cnt] = NODQUOT;

_


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Quota fix 2
  2004-05-16  7:04 ` Andrew Morton
@ 2004-05-17  9:13   ` Jan Kara
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kara @ 2004-05-17  9:13 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Jan Kara, linux-kernel, lukasz, j.borsboom, crosser, torvalds

> Jan Kara <jack@ucw.cz> wrote:
> >
> >   another fix for quota code - it fixes the problem with recursion into
> >  filesystem when inode of quota file needs a page + some other allocation
> >  problems.
> 
> It makes sense.
> 
> > I hope I got the GFP mask setting right..
> 
> nope!  Here's a fix against your patch.
  Originally I had in the patch something similar but then I read the
comment at mapping_set_gfp_mask():
/*
 * This is non-atomic.  Only to be used before the mapping is activated.
 * Probably needs a barrier...
 */
and so changed that to clear_bit(). Anyway thanks for fixing.

									Honza
-- 
Jan Kara <jack@suse.cz>
SuSE CR Labs

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-05-17  9:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-15 19:28 [PATCH] Quota fix 2 Jan Kara
2004-05-16  7:04 ` Andrew Morton
2004-05-17  9:13   ` Jan Kara

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).