Status of quota support for reiserfs on 2.6.x kernels
Subsystems (5)
Hello,
Currently we use some Linux NFS servers with 2.4.25 kernel patched to support quotas.
Since we face some I/O issues, i'd like to try out a 2.6.x kernel but quota support is mandatory.
So my question: is quota support for 2.6.x ( 2.6.9 and above preferably) available and considered stable enough to be used in heavy production environment ( high I/O pretty much 24/24 ) ?
If yes, which kernel do i need, and where can i find the quota patches ?
I've found some old quota patch (for 2.6.5 from march 2004) on Chris Mason suse FTP experimental directory and i also saw that Jan Kara has posted several quota patches recently.
Thanks for a quick update on this topic.
Truly yours,
Philippe
--
Philippe Gramoullé <[email protected]> System & Network Administrator
Lycos Europe
Quoted 4 lines · Philippe Gramoullé
Hello,
Currently we use some Linux NFS servers with 2.4.25 kernel patched to
support quotas.
Quoted 2 lines
Since we face some I/O issues, i'd like to try out a 2.6.x kernel but quota
support is mandatory.
Quoted 2 lines
So my question: is quota support for 2.6.x ( 2.6.9 and above preferably)
available and considered stable enough
Quoted 5 lines
to be used in heavy production environment ( high I/O pretty much 24/24 ) ?
If yes, which kernel do i need, and where can i find the quota patches ?
I've found some old quota patch (for 2.6.5 from march 2004) on Chris Mason
suse FTP experimental directory and i also
Quoted 6 lines
saw that Jan Kara has posted several quota patches recently.
Thanks for a quick update on this topic.
Truly yours,
Quoted 8 lines
Philippe
--
Philippe Gramoullé <[email protected]> System & Network Administrator
Lycos Europe
Quotas are in kernel 2.6 and supported by ext2,ext3,reiserfs,xfs. Reiserfs doesn't need an extra patch for quotas, data journalling or extended attributes. Everything is right there for kernels > 2.6.5 if I remember right.
Jan Kara from SuSE labs recently discoverd a deadlock in the linux quota system, see:
http://marc.theaimsgroup.com/?t=110085816900002&r=1&w=2
I guess it would be wise to wait with the migration till these patches make it into some official 2.6 kernel release.
Signature · 1 line
lg, Chris
Hello Chris,
On Tue, 23 Nov 2004 14:06:43 +0100
Christian Mayrhuber <[email protected]> wrote:
| Quotas are in kernel 2.6 and supported by ext2,ext3,reiserfs,xfs. | Reiserfs doesn't need an extra patch for quotas, data journalling | or extended attributes. Everything is right there for | kernels > 2.6.5 if I remember right.
Ok, good to know.
| | Jan Kara from SuSE labs recently discoverd a deadlock in the linux | quota system, see: | http://marc.theaimsgroup.com/?t=110085816900002&r=1&w=2
yes saw that.
| I guess it would be wise to wait with the migration till these patches | make it into some official 2.6 kernel release.
True, as mentioned in latest -mm release (2.6.10-rc2-mm3) :
"There's a pretty big revamp of the filesystem quota code in here. If you
use quotas, please test"
I 'll test in the meantime and wait for 2.6.10.
Thanks,
Philippe
--
Philippe Gramoullé <[email protected]> System & Network Administrator
Lycos Europe
Jan Kara
reviewerHello,
Quoted 9 lines
On Tue, 23 Nov 2004 14:06:43 +0100
Christian Mayrhuber <[email protected]> wrote:| | Jan Kara from SuSE labs recently discoverd a deadlock in the linux | quota system, see: | http://marc.theaimsgroup.com/?t=110085816900002&r=1&w=2yes saw that.
Actually it was discovered quite some time ago but it took me quite a
while to fix it as it needed bigger changes...
Quoted 8 lines
| I guess it would be wise to wait with the migration till these patches | make it into some official 2.6 kernel release.
True, as mentioned in latest -mm release (2.6.10-rc2-mm3) :
"There's a pretty big revamp of the filesystem quota code in here. If you
use quotas, please test"I 'll test in the meantime and wait for 2.6.10.
Actually the similar bugs are in 2.4 kernels so if you don't happen to
hit them there you are probably safe to try some 2.6 kernel (my quota fixes will take some time to be tested enough to get into Linus's tree..).
Honza
Signature · 2 lines
Jan Kara <[email protected]> SuSE CR Labs
Quoted 4 lines · Christian Mayrhuber <christian.mayrhuber <at> gmx.net> writes:
Quotas are in kernel 2.6 and supported by ext2,ext3,reiserfs,xfs. Reiserfs doesn't need an extra patch for quotas, data journalling or extended attributes. Everything is right there for kernels > 2.6.5 if I remember right.
I tried to use quota with 2.6.7 and got two serious problems:
1. soft quotas were treated like hard quotas
(grace time 8 days but behaved like 0 days)
2. after a few days no access to the file system was possible, fs-options usrquota and grpquota were doubled
when listed by the mount command.
(all 14 clients, samba and nfs paralyzed,
a whole radio station silent, yes I had better days) After reboot the problem was gone but I turned quota off.
so imho quota with reiserfs is experimental and buggy
Quoted 2 lines
I guess it would be wise to wait with the migration till these patches make it into some official 2.6 kernel release.
damn. I can't switch to ext3 since my filesystem is too big to be copied somewhere else.
I'm stuck and need quota with reiserfs and linux 2.6. What can I do?
Hello,
Quoted 8 lines · Klaus Thorn
Quoted 4 lines · Christian Mayrhuber <christian.mayrhuber <at> gmx.net> writes:
Quotas are in kernel 2.6 and supported by ext2,ext3,reiserfs,xfs. Reiserfs doesn't need an extra patch for quotas, data journalling or extended attributes. Everything is right there for kernels > 2.6.5 if I remember right.
I tried to use quota with 2.6.7 and got two serious problems:
I'm running 2.6.9 kernel with quota and ACL support enabled and both are running just fine. I'm able to mount (at bootup) the Reiserfs partition with user quota and group quota enabled.
I was facing some problems with 2.6.4 kernel, though.
Regards,
Signature · 2 lines
B S Srinidhi <[email protected]> DeepRoot Linux Pvt. Ltd.
Quoted 21 lines · Klaus Thorn
Quoted 4 lines · Christian Mayrhuber <christian.mayrhuber <at> gmx.net> writes:
Quotas are in kernel 2.6 and supported by ext2,ext3,reiserfs,xfs. Reiserfs doesn't need an extra patch for quotas, data journalling or extended attributes. Everything is right there for kernels > 2.6.5 if I remember right.
I tried to use quota with 2.6.7 and got two serious problems:
1. soft quotas were treated like hard quotas
(grace time 8 days but behaved like 0 days)2. after a few days no access to the file system was possible, fs-options usrquota and grpquota were doubled
when listed by the mount command.
(all 14 clients, samba and nfs paralyzed,
a whole radio station silent, yes I had better days) After reboot the problem was gone but I turned quota off.so imho quota with reiserfs is experimental and buggy
Quoted 7 lines
Quoted 2 lines
I guess it would be wise to wait with the migration till these patches make it into some official 2.6 kernel release.
damn. I can't switch to ext3 since my filesystem is too big to be copied somewhere else.
I'm stuck and need quota with reiserfs and linux 2.6. What can I do?
There is a deadlock bug in the linux quota system (not just reiserfs) and a fix for it in the -mm (2.6.10-rc3-mm1 for instance).
See:
http://marc.theaimsgroup.com/?l=linux-fsdevel&m=110085813716139&w=2
http://www.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.10-rc3/2.6.10-rc3-mm1/announce.txt
I don't know how stable these patches are nor how stable 2.6.10-rc3-mm1 is, nor if you need those. Maybe you just hit the quota race fixed in 2.6.8.
There are quite a lot of quota and nfs changes between 2.6.7 and newer kernels. (See the kernel changelogs and search for nfs and quota)
As nfs is involved you may want to bug [email protected], too.
Signature · 1 line
lg, Chris
Hello!
Quoted 8 lines
Quoted 4 lines · Christian Mayrhuber <christian.mayrhuber <at> gmx.net> writes:
Quotas are in kernel 2.6 and supported by ext2,ext3,reiserfs,xfs. Reiserfs doesn't need an extra patch for quotas, data journalling or extended attributes. Everything is right there for kernels > 2.6.5 if I remember right.
I tried to use quota with 2.6.7 and got two serious problems:
I suggest trying some newer kernel - either 2.6.10-rc3-mm1 or
just plain 2.6.10-rc3 with attached patch applied (the patch fixes the deadlock you seem to hit).
Quoted 2 lines
1. soft quotas were treated like hard quotas
(grace time 8 days but behaved like 0 days)
That is rather strange - I never heard about such problem. If this
problem remains after changing the kernel then mail me please and we try to sort that out.
Quoted 6 lines
2. after a few days no access to the file system was possible, fs-options usrquota and grpquota were doubled
when listed by the mount command.
(all 14 clients, samba and nfs paralyzed,
a whole radio station silent, yes I had better days) After reboot the problem was gone but I turned quota off.
That looks like a deadlock which should be fixed by now.
Honza
fs/dquot.c +102 -81
@@ -49,7 +49,7 @@* New SMP locking. * Jan Kara, <[email protected]>, 10/2002 * -* Added journalled quota support +* Added journalled quota support, fix lock inversion problems * Jan Kara, <[email protected]>, 2003,2004 * * (C) Copyright 1994 - 1997 Marco van Wieringen
@@ -75,7 +75,8 @@#include <linux/proc_fs.h> #include <linux/security.h> #include <linux/kmod.h> -#include <linux/pagemap.h> +#include <linux/namei.h> +#include <linux/buffer_head.h> #include <asm/uaccess.h>
@@ -114,7 +115,7 @@* operations on dquots don't hold dq_lock as they copy data under dq_data_lock * spinlock to internal buffers before writing. * -* Lock ordering (including related VFS locks) is following: +* Lock ordering (including related VFS locks) is the following: * i_sem > dqonoff_sem > iprune_sem > journal_lock > dqptr_sem > * > dquot->dq_lock > dqio_sem * i_sem on quota files is special (it's below dqio_sem)
@@ -183,8 +184,7 @@ static void put_quota_format(struct quot* on all three lists, depending on its current state. * * All dquots are placed to the end of inuse_list when first created, and this -* list is used for the sync and invalidate operations, which must look -* at every dquot. +* list is used for invalidate operation, which must look at every dquot. * * Unused dquots (dq_count == 0) are added to the free_dquots list when freed, * and this list is searched whenever we need an available dquot. Dquots are
@@ -1314,10 +1314,14 @@ int vfs_quota_off(struct super_block *sb {int cnt;struct quota_info *dqopt =sb_dqopt (sb); +struct inode *toputinode[MAXQUOTAS ]; +struct vfsmount *toputmnt[MAXQUOTAS ];/* We need to serialize quota_off() for device */ down (&dqopt->dqonoff_sem);for (cnt =0 ; cnt <MAXQUOTAS ; cnt++) { + toputinode[cnt] =NULL ; + toputmnt[cnt] =NULL ;if (type !=-1 && cnt != type)continue ;if (!sb_has_quota_enabled (sb, cnt))
@@ -1337,14 +1341,50 @@ int vfs_quota_off(struct super_block *sb dqopt->ops[cnt]->free_file_info (sb, cnt);put_quota_format (dqopt->info[cnt].dqi_format); -fput (dqopt->files[cnt]); + toputinode[cnt] = dqopt->files[cnt]; + toputmnt[cnt] = dqopt->mnt[cnt]; dqopt->files[cnt] =NULL ; + dqopt->mnt[cnt] =NULL ; dqopt->info[cnt].dqi_flags =0 ; dqopt->info[cnt].dqi_igrace =0 ; dqopt->info[cnt].dqi_bgrace =0 ; dqopt->ops[cnt] =NULL ; }up (&dqopt->dqonoff_sem); +/* Sync the superblock so that buffers with quota data are written to +* disk (and so userspace sees correct data afterwards). +* The reference to vfsmnt we are still holding protects us from +* umount (we don't have it only when quotas are turned on/off for +* journal replay but in that case we are guarded by the fs anyway). */ +if (sb->s_op->sync_fs) + sb->s_op->sync_fs (sb,1 ); +sync_blockdev (sb->s_bdev); +/* Now the quota files are just ordinary files and we can set the +* inode flags back. Moreover we discard the pagecache so that +* userspace sees the writes we did bypassing the pagecache. We +* must also discard the blockdev buffers so that we see the +* changes done by userspace on the next quotaon() */ +for (cnt =0 ; cnt <MAXQUOTAS ; cnt++) +if (toputinode[cnt]) { +down (&dqopt->dqonoff_sem); +/* If quota was reenabled in the meantime, we have +* nothing to do */ +if (!sb_has_quota_enabled (sb, cnt)) { +down (&toputinode[cnt]->i_sem); + toputinode[cnt]->i_flags &= ~(S_IMMUTABLE | +S_NOATIME |S_NOQUOTA ); +truncate_inode_pages (&toputinode[cnt]->i_data,0 ); +up (&toputinode[cnt]->i_sem); +mark_inode_dirty (toputinode[cnt]); +iput (toputinode[cnt]); + } +up (&dqopt->dqonoff_sem); +/* We don't hold the reference when we turned on quotas +* just for the journal replay... */ +if (toputmnt[cnt]) +mntput (toputmnt[cnt]); + } +invalidate_bdev (sb->s_bdev,0 );return 0 ; }
@@ -1352,68 +1392,56 @@ int vfs_quota_off(struct super_block *sb* Turn quotas on on a device */ -/* Helper function when we already have file open */ -static int vfs_quota_on_file (struct file *f,int type,int format_id) +/* Helper function when we already have the inode */ +static int vfs_quota_on_inode (struct inode *inode,int type,int format_id) {struct quota_format_type *fmt =find_quota_format (format_id); -struct inode *inode; -struct super_block *sb = f->f_dentry->d_sb; +struct super_block *sb = inode->i_sb;struct quota_info *dqopt =sb_dqopt (sb); -struct dquot *to_drop[MAXQUOTAS ]; -int error, cnt; -unsigned int oldflags =-1 ; +int error; +int oldflags =-1 ;if (!fmt)return -ESRCH ; - error = -EIO ; -if (!f->f_op || !f->f_op->read || !f->f_op->write) +if (!S_ISREG (inode->i_mode)) { + error = -EACCES ; + goto out_fmt; + } +if (IS_RDONLY (inode)) { + error = -EROFS ; goto out_fmt; - inode = f->f_dentry->d_inode; - error = -EACCES ; -if (!S_ISREG (inode->i_mode)) + } +if (!sb->s_op->quota_write || !sb->s_op->quota_read) { + error = -EINVAL ; goto out_fmt; + } +/* As we bypass the pagecache we must now flush the inode so that +* we see all the changes from userspace... */ +write_inode_now (inode,1 ); +/* And now flush the block cache so that kernel sees the changes */ +invalidate_bdev (sb->s_bdev,0 );down (&inode->i_sem);down (&dqopt->dqonoff_sem);if (sb_has_quota_enabled (sb, type)) { -up (&inode->i_sem); error = -EBUSY ; goto out_lock; }/* 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 */ +* Also nobody should write to the file - we use special IO operations +* which ignore the immutable bit. */ down_write (&dqopt->dqptr_sem); - oldflags = inode->i_flags & (S_NOATIME |S_NOQUOTA ); - inode->i_flags |=S_NOQUOTA |S_NOATIME ; + oldflags = inode->i_flags & (S_NOATIME |S_IMMUTABLE |S_NOQUOTA ); + inode->i_flags |=S_NOQUOTA |S_NOATIME |S_IMMUTABLE ;up_write (&dqopt->dqptr_sem); -up (&inode->i_sem); - dqopt->files[type] = f; + error = -EIO ; + dqopt->files[type] =igrab (inode); +if (!dqopt->files[type]) + goto out_lock; error = -EINVAL ;if (!fmt->qf_ops->check_quota_file (sb, type)) goto out_file_init; -/* -* 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); - -down_write (&dqopt->dqptr_sem); -for (cnt =0 ; cnt <MAXQUOTAS ; cnt++) { - to_drop[cnt] = inode->i_dquot[cnt]; - inode->i_dquot[cnt] =NODQUOT ; - } -up_write (&dqopt->dqptr_sem); -/* We must put dquots outside of dqptr_sem because we may need to -* start transaction for dquot_release() */ -for (cnt =0 ; cnt <MAXQUOTAS ; cnt++) { -if (to_drop[cnt]) -dqput (to_drop[cnt]); - } dqopt->ops[type] = fmt->qf_ops; dqopt->info[type].dqi_format = fmt;
@@ -1424,6 +1452,7 @@ static int vfs_quota_on_file(struct file goto out_file_init; }up (&dqopt->dqio_sem); +up (&inode->i_sem);set_enable_flags (dqopt, type);add_dquot_ref (sb, type);
@@ -1433,19 +1462,18 @@ static int vfs_quota_on_file(struct file out_file_init: dqopt->files[type] =NULL ; +iput (inode); out_lock:up (&dqopt->dqonoff_sem);if (oldflags !=-1 ) { -down (&inode->i_sem);down_write (&dqopt->dqptr_sem); -/* Reset the NOATIME flag back. I know it could change in the -* mean time but playing with NOATIME flags on a quota file is -* never a good idea */ - inode->i_flags &= ~(S_NOATIME |S_NOQUOTA ); +/* Set the flags back (in the case of accidental quotaon() +* on a wrong file we don't want to mess up the flags) */ + inode->i_flags &= ~(S_NOATIME |S_NOQUOTA |S_IMMUTABLE ); inode->i_flags |= oldflags;up_write (&dqopt->dqptr_sem); -up (&inode->i_sem); } +up (&inode->i_sem); out_fmt:put_quota_format (fmt);
@@ -1455,47 +1483,40 @@ out_fmt:/* Actual function called from quotactl() */ int vfs_quota_on (struct super_block *sb,int type,int format_id,char *path) { -struct file *f; +struct nameidata nd;int error; - f =filp_open (path,O_RDWR ,0600 ); -if (IS_ERR (f)) -return PTR_ERR (f); - error =security_quota_on (f); + error =path_lookup (path,LOOKUP_FOLLOW , &nd); +if (error <0 ) +return error; + error =security_quota_on (nd.dentry);if (error) - goto out_f; - error =vfs_quota_on_file (f, type, format_id); -if (!error) -return 0 ; -out_f: -filp_close (f,NULL ); + goto out_path; +/* Quota file not on the same filesystem? */ +if (nd.mnt->mnt_sb != sb) + error = -EXDEV ; +else { + error =vfs_quota_on_inode (nd.dentry->d_inode, type, format_id); +if (!error) +sb_dqopt (sb)->mnt[type] =mntget (nd.mnt); + } +out_path: +path_release (&nd);return error; }/* -* Function used by filesystems when filp_open() would fail (filesystem is -* being mounted now). We will use a private file structure. Caller is -* responsible that it's IO functions won't need vfsmnt structure or -* some dentry tricks... +* This function is used when filesystem needs to initialize quotas +* during mount time. */ int vfs_quota_on_mount (int type,int format_id,struct dentry *dentry) { -struct file *f;int error; -dget (dentry);/* Get a reference for struct file */ - f =dentry_open (dentry,NULL ,O_RDWR ); -if (IS_ERR (f)) { - error =PTR_ERR (f); - goto out_dentry; - } - error =vfs_quota_on_file (f, type, format_id); -if (!error) -return 0 ; -fput (f); -out_dentry: -dput (dentry); -return error; + error =security_quota_on (dentry); +if (error) +return error; +return vfs_quota_on_inode (dentry->d_inode, type, format_id); }/* Generic routine for getting common part of quota structure */
fs/ext2/ext2.h +1 -0
@@ -119,6 +119,7 @@ extern int ext2_write_inode (struct inodextern void ext2_delete_inode (struct inode *);extern int ext2_sync_inode (struct inode *);extern void ext2_discard_prealloc (struct inode *); +extern int ext2_get_block (struct inode *,sector_t ,struct buffer_head *,int );extern void ext2_truncate (struct inode *);extern int ext2_setattr (struct dentry *,struct iattr *);extern void ext2_set_inode_flags (struct inode *inode);
fs/ext2/inode.c +1 -1
@@ -524,7 +524,7 @@ changed:* reachable from inode. */ -static int ext2_get_block (struct inode *inode,sector_t iblock,struct buffer_head *bh_result,int create) +int ext2_get_block (struct inode *inode,sector_t iblock,struct buffer_head *bh_result,int create) {int err = -EIO ;int offsets[4 ];
fs/ext2/super.c +114 -0
132 lines not on this page · raw message
fs/ext3/inode.c +1 -1
@@ -1025,7 +1025,7 @@ out:return ret; } -static int +int ext3_journal_dirty_data (handle_t *handle,struct buffer_head *bh) {int err =journal_dirty_data (handle, bh);
fs/ext3/super.c +132 -31
234 lines not on this page · raw message
fs/quota.c +42 -3
64 lines not on this page · raw message
fs/quota_v1.c +12 -50
153 lines not on this page · raw message
fs/quota_v2.c +101 -126
563 lines not on this page · raw message
fs/reiserfs/bitmap.c +4 -4
@@ -956,14 +956,14 @@ static inline int blocknrs_and_prealloc_if (!hint->formatted_node) {int quota_ret;#ifdef REISERQUOTA_DEBUG -reiserfs_debug (s,"reiserquota: allocating %d blocks id=%u" , amount_needed, hint->inode->i_uid); +reiserfs_debug (s,REISERFS_DEBUG_CODE ,"reiserquota: allocating %d blocks id=%u" , amount_needed, hint->inode->i_uid);#endif quota_ret =DQUOT_ALLOC_BLOCK_NODIRTY (hint->inode, amount_needed);if (quota_ret)/* Quota exceeded? */ return QUOTA_EXCEEDED ;if (hint->preallocate && hint->prealloc_size ) {#ifdef REISERQUOTA_DEBUG -reiserfs_debug (s,"reiserquota: allocating (prealloc) %d blocks id=%u" , hint->prealloc_size, hint->inode->i_uid); +reiserfs_debug (s,REISERFS_DEBUG_CODE ,"reiserquota: allocating (prealloc) %d blocks id=%u" , hint->prealloc_size, hint->inode->i_uid);#endif quota_ret =DQUOT_PREALLOC_BLOCK_NODIRTY (hint->inode, hint->prealloc_size);if (quota_ret)
@@ -1009,7 +1009,7 @@ static inline int blocknrs_and_prealloc_/* Free the blocks */ if (!hint->formatted_node) {#ifdef REISERQUOTA_DEBUG -reiserfs_debug (s,"reiserquota: freeing (nospace) %d blocks id=%u" , amount_needed + hint->prealloc_size - nr_allocated, hint->inode->i_uid); +reiserfs_debug (s,REISERFS_DEBUG_CODE ,"reiserquota: freeing (nospace) %d blocks id=%u" , amount_needed + hint->prealloc_size - nr_allocated, hint->inode->i_uid);#endif DQUOT_FREE_BLOCK_NODIRTY (hint->inode, amount_needed + hint->prealloc_size - nr_allocated);/* Free not allocated blocks */ }
@@ -1029,7 +1029,7 @@ static inline int blocknrs_and_prealloc_ nr_allocated + REISERFS_I(hint->inode)->i_prealloc_count) {/* Some of preallocation blocks were not allocated */ #ifdef REISERQUOTA_DEBUG -reiserfs_debug (s,"reiserquota: freeing (failed prealloc) %d blocks id=%u" , amount_needed + hint->prealloc_size - nr_allocated -INODE_INFO (hint->inode)->i_prealloc_count, hint->inode->i_uid); +reiserfs_debug (s,REISERFS_DEBUG_CODE ,"reiserquota: freeing (failed prealloc) %d blocks id=%u" , amount_needed + hint->prealloc_size - nr_allocated -REISERFS_I (hint->inode)->i_prealloc_count, hint->inode->i_uid);#endif DQUOT_FREE_BLOCK_NODIRTY(hint->inode, amount_needed + hint->prealloc_size - nr_allocated -
fs/reiserfs/file.c +3 -3
@@ -54,7 +54,7 @@ static int reiserfs_file_release (struct/* freeing preallocation only involves relogging blocks that * are already in the current transaction. preallocation gets * freed at the end of each transaction, so it is impossible for -* us to log any additional blocks +* us to log any additional blocks (including quota blocks) */ err =journal_begin (&th, inode->i_sb,1 );if (err) {
@@ -201,7 +201,7 @@ int reiserfs_allocate_blocks_for_region(/* If we came here, it means we absolutely need to open a transaction, since we need to allocate some blocks */ reiserfs_write_lock (inode->i_sb);// Journaling stuff and we need that. - res =journal_begin (th, inode->i_sb,JOURNAL_PER_BALANCE_CNT *3 +1 );// Wish I know if this number enough + res =journal_begin (th, inode->i_sb,JOURNAL_PER_BALANCE_CNT *3 +1 +2 *REISERFS_QUOTA_TRANS_BLOCKS );// Wish I know if this number enough if (res) goto error_exit;reiserfs_update_inode_transaction (inode) ;
@@ -576,7 +576,7 @@ error_exit:int err;// update any changes we made to blk count reiserfs_update_sd (th, inode); - err =journal_end (th, inode->i_sb,JOURNAL_PER_BALANCE_CNT *3 +1 ); + err =journal_end (th, inode->i_sb,JOURNAL_PER_BALANCE_CNT *3 +1 +2 *REISERFS_QUOTA_TRANS_BLOCKS );if (err) res = err; }
fs/reiserfs/inode.c +37 -17
101 lines not on this page · raw message
fs/reiserfs/namei.c +27 -33
148 lines not on this page · raw message
fs/reiserfs/stree.c +7 -7
@@ -1388,7 +1388,7 @@ int reiserfs_delete_item (struct reiserfdo_balance (&s_del_balance,NULL ,NULL ,M_DELETE );#ifdef REISERQUOTA_DEBUG -reiserfs_debug (p_s_sb,"reiserquota delete_item(): freeing %u, id=%u type=%c" , quota_cut_bytes, p_s_inode->i_uid,head2type (&s_ih)); +reiserfs_debug (p_s_sb,REISERFS_DEBUG_CODE ,"reiserquota delete_item(): freeing %u, id=%u type=%c" , quota_cut_bytes, p_s_inode->i_uid,head2type (&s_ih));#endif DQUOT_FREE_SPACE_NODIRTY (p_s_inode, quota_cut_bytes);
@@ -1465,7 +1465,7 @@ void reiserfs_delete_solid_item (structdo_balance (&tb,NULL ,NULL ,M_DELETE );if (inode) {/* Should we count quota for item? (we don't count quotas for save-links) */ #ifdef REISERQUOTA_DEBUG -reiserfs_debug (th->t_super,"reiserquota delete_solid_item(): freeing %u id=%u type=%c" , quota_cut_bytes, inode->i_uid,key2type (key)); +reiserfs_debug (th->t_super,REISERFS_DEBUG_CODE ,"reiserquota delete_solid_item(): freeing %u id=%u type=%c" , quota_cut_bytes, inode->i_uid,key2type (key));#endif DQUOT_FREE_SPACE_NODIRTY (inode, quota_cut_bytes); }
@@ -1786,7 +1786,7 @@ int reiserfs_cut_from_item (struct reiseREISERFS_I (p_s_inode)->i_flags &= ~i_pack_on_close_mask ; }#ifdef REISERQUOTA_DEBUG -reiserfs_debug (p_s_inode->i_sb,"reiserquota cut_from_item(): freeing %u id=%u type=%c" , quota_cut_bytes, p_s_inode->i_uid,'?' ); +reiserfs_debug (p_s_inode->i_sb,REISERFS_DEBUG_CODE ,"reiserquota cut_from_item(): freeing %u id=%u type=%c" , quota_cut_bytes, p_s_inode->i_uid,'?' );#endif DQUOT_FREE_SPACE_NODIRTY (p_s_inode, quota_cut_bytes);return n_ret_value;
@@ -1999,7 +1999,7 @@ int reiserfs_paste_into_item (struct rei fs_gen =get_generation (inode->i_sb) ;#ifdef REISERQUOTA_DEBUG -reiserfs_debug (inode->i_sb,"reiserquota paste_into_item(): allocating %u id=%u type=%c" , n_pasted_size, inode->i_uid,key2type (&(p_s_key->on_disk_key))); +reiserfs_debug (inode->i_sb,REISERFS_DEBUG_CODE ,"reiserquota paste_into_item(): allocating %u id=%u type=%c" , n_pasted_size, inode->i_uid,key2type (&(p_s_key->on_disk_key)));#endif if (DQUOT_ALLOC_SPACE_NODIRTY (inode, n_pasted_size)) {
@@ -2048,7 +2048,7 @@ error_out:/* this also releases the path */ unfix_nodes (&s_paste_balance);#ifdef REISERQUOTA_DEBUG -reiserfs_debug (inode->i_sb,"reiserquota paste_into_item(): freeing %u id=%u type=%c" , n_pasted_size, inode->i_uid,key2type (&(p_s_key->on_disk_key))); +reiserfs_debug (inode->i_sb,REISERFS_DEBUG_CODE ,"reiserquota paste_into_item(): freeing %u id=%u type=%c" , n_pasted_size, inode->i_uid,key2type (&(p_s_key->on_disk_key)));#endif DQUOT_FREE_SPACE_NODIRTY (inode, n_pasted_size);return retval ;
@@ -2081,7 +2081,7 @@ int reiserfs_insert_item(struct reiserfs quota_bytes = inode->i_sb->s_blocksize +UNFM_P_SIZE ; }#ifdef REISERQUOTA_DEBUG -reiserfs_debug (inode->i_sb,"reiserquota insert_item(): allocating %u id=%u type=%c" , quota_bytes, inode->i_uid,head2type (p_s_ih)); +reiserfs_debug (inode->i_sb,REISERFS_DEBUG_CODE ,"reiserquota insert_item(): allocating %u id=%u type=%c" , quota_bytes, inode->i_uid,head2type (p_s_ih));#endif /* We can't dirty inode here. It would be immediately written but * appropriate stat item isn't inserted yet... */
@@ -2127,7 +2127,7 @@ error_out:/* also releases the path */ unfix_nodes (&s_ins_balance);#ifdef REISERQUOTA_DEBUG -reiserfs_debug (th->t_super,"reiserquota insert_item(): freeing %u id=%u type=%c" , quota_bytes, inode->i_uid,head2type (p_s_ih)); +reiserfs_debug (th->t_super,REISERFS_DEBUG_CODE ,"reiserquota insert_item(): freeing %u id=%u type=%c" , quota_bytes, inode->i_uid,head2type (p_s_ih));#endif if (inode)DQUOT_FREE_SPACE_NODIRTY (inode, quota_bytes) ;
fs/reiserfs/super.c +407 -7
545 lines not on this page · raw message
include/linux/ext3_jbd.h +2 -0
@@ -188,6 +188,8 @@ __ext3_journal_dirty_metadata(const char#define ext3_journal_dirty_metadata (handle, bh) \ __ext3_journal_dirty_metadata(__FUNCTION__, (handle), (bh)) +int ext3_journal_dirty_data (handle_t *handle,struct buffer_head *bh); +handle_t *ext3_journal_start_sb (struct super_block *sb,int nblocks);int __ext3_journal_stop (const char *where,handle_t *handle);
include/linux/fs.h +3 -0
@@ -992,6 +992,9 @@ struct super_operations {void (*umount_begin) (struct super_block *);int (*show_options)(struct seq_file *,struct vfsmount *); + +ssize_t (*quota_read)(struct super_block *,int ,char *,size_t ,loff_t ); +ssize_t (*quota_write)(struct super_block *,int ,const char *,size_t ,loff_t ); };/* Inode state bits. Protected by inode_lock. */
include/linux/quota.h +2 -1
@@ -285,7 +285,8 @@ struct quota_info {struct semaphore dqio_sem;/* lock device while I/O in progress */ struct semaphore dqonoff_sem;/* Serialize quotaon & quotaoff */ struct rw_semaphore dqptr_sem;/* serialize ops using quota_info struct, pointers from inode to dquots */ -struct file *files[MAXQUOTAS ];/* fp's to quotafiles */ +struct inode *files[MAXQUOTAS ];/* inodes of quotafiles */ +struct vfsmount *mnt[MAXQUOTAS ];/* mountpoint entries of filesystems with quota files */ struct mem_dqinfo info[MAXQUOTAS ];/* Information for each quota type */ struct quota_format_ops *ops[MAXQUOTAS ];/* Operations for each type */ };
include/linux/quotaops.h +1 -1
@@ -177,7 +177,7 @@ static __inline__ int DQUOT_OFF(struct s {int ret = -ENOSYS ; -if (sb->s_qcop && sb->s_qcop->quota_off) +if (sb_any_quota_enabled (sb) && sb->s_qcop && sb->s_qcop->quota_off) ret = sb->s_qcop->quota_off (sb,-1 );return ret; }
include/linux/reiserfs_fs.h +16 -0
@@ -1688,6 +1688,13 @@ struct reiserfs_journal_header {#define JOURNAL_MAX_COMMIT_AGE 30#define JOURNAL_MAX_TRANS_AGE 30#define JOURNAL_PER_BALANCE_CNT (3 * (MAX_HEIGHT-2) + 9) +#ifdef CONFIG_QUOTA +#define REISERFS_QUOTA_TRANS_BLOCKS 2/* We need to update data and inode (atime) */ +#define REISERFS_QUOTA_INIT_BLOCKS (DQUOT_MAX_WRITES*(JOURNAL_PER_BALANCE_CNT+2)+1)/* 1 balancing, 1 bitmap, 1 data per write + stat data update */ +#else +#define REISERFS_QUOTA_TRANS_BLOCKS 0 +#define REISERFS_QUOTA_INIT_BLOCKS 0 +#endif /* both of these can be as low as 1, or as high as you want. The min is the ** number of 4k bitmap nodes preallocated on mount. New nodes are allocated
@@ -1930,12 +1937,21 @@ int reiserfs_do_truncate (struct reiserfvoid padd_item (char * item,int total_length,int length);/* inode.c */ +/* args for the create parameter of reiserfs_get_block */ +#define GET_BLOCK_NO_CREATE 0/* don't create new blocks or convert tails */ +#define GET_BLOCK_CREATE 1/* add anything you need to find block */ +#define GET_BLOCK_NO_HOLE 2/* return -ENOENT for file holes */ +#define GET_BLOCK_READ_DIRECT 4/* read the tail if indirect item not found */ +#define GET_BLOCK_NO_ISEM 8/* i_sem is not held, don't preallocate */ +#define GET_BLOCK_NO_DANGLE 16/* don't leave any transactions running */ +int restart_transaction (struct reiserfs_transaction_handle *th,struct inode *inode,struct path *path);void reiserfs_read_locked_inode (struct inode * inode,struct reiserfs_iget_args *args) ;int reiserfs_find_actor (struct inode * inode,void *p) ;int reiserfs_init_locked_inode (struct inode * inode,void *p) ;void reiserfs_delete_inode (struct inode * inode);int reiserfs_write_inode (struct inode * inode,int ) ; +int reiserfs_get_block (struct inode * inode,sector_t block,struct buffer_head * bh_result,int create);struct dentry *reiserfs_get_dentry (struct super_block *,void *) ; struct dentry *reiserfs_decode_fh(struct super_block *sb, __u32 *data, int len, int fhtype,
include/linux/reiserfs_fs_sb.h +4 -0
@@ -410,6 +410,10 @@ struct reiserfs_sb_infostruct rw_semaphore xattr_dir_sem;int j_errno; +#ifdef CONFIG_QUOTA +char *s_qf_names[MAXQUOTAS ]; +int s_jquota_fmt; +#endif };/* Definitions of reiserfs on-disk properties: */
include/linux/security.h +4 -4
@@ -1034,7 +1034,7 @@ struct security_operations {int (*sysctl) (struct ctl_table * table,int op);int (*capable) (struct task_struct * tsk,int cap);int (*quotactl) (int cmds,int type,int id,struct super_block * sb); -int (*quota_on) (struct file * f); +int (*quota_on) (struct dentry * dentry);int (*syslog) (int type);int (*settime) (struct timespec *ts,struct timezone *tz);int (*vm_enough_memory) (long pages);
@@ -1281,9 +1281,9 @@ static inline int security_quotactl (intreturn security_ops->quotactl (cmds, type, id, sb); } -static inline int security_quota_on (struct file * file) +static inline int security_quota_on (struct dentry * dentry) { -return security_ops->quota_on (file); +return security_ops->quota_on (dentry); }static inline int security_syslog (int type)
@@ -1959,7 +1959,7 @@ static inline int security_quotactl (intreturn 0 ; } -static inline int security_quota_on (struct file * file) +static inline int security_quota_on (struct dentry * dentry) {return 0 ; }
security/dummy.c +1 -1
@@ -92,7 +92,7 @@ static int dummy_quotactl (int cmds, intreturn 0 ; } -static int dummy_quota_on (struct file *f) +static int dummy_quota_on (struct dentry *dentry) {return 0 ; }
security/selinux/hooks.c +2 -2
@@ -1491,9 +1491,9 @@ static int selinux_quotactl(int cmds, inreturn rc; } -static int selinux_quota_on (struct file *f) +static int selinux_quota_on (struct dentry *dentry) { -return file_has_perm (current, f,FILE__QUOTAON ); +return dentry_has_perm (current,NULL , dentry,FILE__QUOTAON ); }static int selinux_syslog (int type)
Thanks for your patch and your comments!
Quoted 4 lines · Jan Kara
Quoted 1 line
I tried to use quota with 2.6.7 and got two serious problems
I suggest trying some newer kernel - either 2.6.10-rc3-mm1 or
just plain 2.6.10-rc3 with attached patch applied (the patch fixes the deadlock you seem to hit).
It tried the latter on another server and the filesystem was accessible at all time but other problems occured (maybe not quota-related) that made my co-admins downgrade to 2.6.9:
1. suddenly, after running the patched kernel for days,
su, sudo and authentication through courier webmailer was not possible, ssh-root-login went fine. After reboot problem was gone but pam_rootok.so was missing (file system curruption?)
2. after a few hours stress-testing the quota-partition:
kernel crash: code ff 21 e2 8b 0a ...
... 76 60 e0 ff 6a 00
kernel BUG at lib/kernel_lock:120!
invalid operand: 0000
Do you think they are quota-related or related to you quota-fixall patch?
Is your fix appliable for vanilla 2.6.10 or is it already integrated or is there a newer patch?
Signature · 1 line
klaus thorn [email protected]
Sorry for a bit late reply but I was on a holidays.
Quoted 6 lines · Jan Kara
Quoted 4 lines
Quoted 1 line
I tried to use quota with 2.6.7 and got two serious problems
I suggest trying some newer kernel - either 2.6.10-rc3-mm1 or
just plain 2.6.10-rc3 with attached patch applied (the patch fixes the deadlock you seem to hit).
Quoted 8 lines
It tried the latter on another server and the filesystem was accessible at all time but other problems occured (maybe not quota-related) that made my co-admins downgrade to 2.6.9:
1. suddenly, after running the patched kernel for days,
su, sudo and authentication through courier webmailer was not possible, ssh-root-login went fine. After reboot problem was gone but pam_rootok.so was missing (file system curruption?)
Are there any error messages in the log? If that was filesystem
corruption there should be some.... Otherwise it's hard to guess what was going on.
Quoted 5 lines
2. after a few hours stress-testing the quota-partition:
kernel crash: code ff 21 e2 8b 0a ...
... 76 60 e0 ff 6a 00
kernel BUG atlib/kernel_lock:120!
invalid operand: 0000
This does not look nice. Do you have all the error message? From this
part it's hard to guess what has happened.
Quoted 1 line
Do you think they are quota-related or related to you quota-fixall patch?
They might be - you can try to stress-test the filesystem without
quotas enabled and see if some error occurs.
Quoted 2 lines
Is your fix appliable for vanilla 2.6.10 or is it already integrated or is there a newer patch?
The patch I sent you should be applicable to 2.6.10 kernel. There's also one
other bugfix to my quota-fixall patch which I attached (but you don't seem to actually hit that problem).
Honza
When CONFIG_QUOTA is defined reiserfs's finish_unfinished sets and clears MS_ACTIVE bit in s_flags field of super block. If that bit was set already it should not be set.
fs/reiserfs/super.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-)
fs/reiserfs/super.c renamed from fs/reiserfs/super.c~reiserfs-do-not-clear-MS_ACTIVE +10 -3
@@ -158,6 +158,7 @@ static int finish_unfinished (struct supint truncate;#ifdef CONFIG_QUOTA int i; +int ms_active_set;#endif
@@ -168,7 +169,12 @@ static int finish_unfinished (struct sup#ifdef CONFIG_QUOTA /* Needed for iput() to work correctly and not trash data */ - s->s_flags |=MS_ACTIVE ; +if (s->s_flags &MS_ACTIVE ) { + ms_active_set =0 ; + }else { + ms_active_set =1 ; + s->s_flags |=MS_ACTIVE ; + }/* Turn on quotas so that they are updated correctly */ for (i =0 ; i <MAXQUOTAS ; i++) {if (REISERFS_SB (s)->s_qf_names[i]) {
@@ -276,8 +282,9 @@ static int finish_unfinished (struct supif (sb_dqopt (s)->files[i]) vfs_quota_off_mount(s, i); } -/* Restore the flag back */ - s->s_flags &= ~MS_ACTIVE ; +if (ms_active_set) +/* Restore the flag back */ + s->s_flags &= ~MS_ACTIVE ;#endif pathrelse (&path);if (done)
_