Fix of quota deadlock on pagelock
Subsystems (5)
Jan Kara
reviewerPATCH 1/1 Fix of quota deadlock on pagelock
Hello!
The four patches in the next mails fix deadlocks with quotas of
pagelock (the problem was lock inversion on PageLock and transaction start - quota code needed to first start a transaction and then write the data which subsequently needed acquisition of PageLock while the standard ordering - PageLock first and transaction start later - was used e.g. by pdflush). They implement a new way of quota access to disk:
Every filesystem that would like to implement quotas now has to provide quota_read() and quota_write() functions. These functions must obey quota lock ordering (in particular they should not take PageLock inside a transaction).
The first patch implements the changes in the quota core, the other
three patches implement needed functions in ext2, ext3 and reiserfs. The patch for reiserfs also fixes several other lock inversion problems (similar as ext3 had) and implements the journaled quota functionality (which comes almost for free after the locking fixes...).
The quota core patch makes quota support in other filesystems (except
XFS which implements everything on its own ;)) unfunctional (quotaon() will refuse to turn on quotas on them). When the patches get reasonable wide testing and it will seem that no major changes will be needed I can make fixes also for the other filesystems (JFS, UDF, UFS).
Could you Andrew merge the patches in the -mm tree for testing please?
The patch for reiserfs was not yet checked by any reiserfs maintainer so I'm not sure about the policy here...
Any comments are welcome.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SuSE CR Labs
Jan Kara
reviewerHello,
the attached patch implements the new way of quota io in the quota
core. Every filesystem wanting to support quotas has to provide functions quota_read() and quota_write() obeying quota locking rules. As the writes and reads bypass the pagecache there is some ugly stuff ensuring that userspace can see all the data after quotaoff() (or Q_SYNC quotactl). In future I plan to make quota files inaccessible from userspace (with the exception of quotacheck(8) which will take care about the cache flushing and such stuff itself) so that this synchronization stuff can be removed... Please apply.
Honza
The rewrite of the quota core. Quota uses the filesystem read() and write() functions no more to avoid possible deadlocks on PageLock. From now on every filesystem supporting quotas must provide functions quota_read() and quota_write() which obey the quota locking rules (e.g. they cannot acquire the PageLock).
fs/dquot.c +81 -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,12 @@ int vfs_quota_off(struct super_block *sb {int cnt;struct quota_info *dqopt =sb_dqopt (sb); +struct inode *toput[MAXQUOTAS ];/* We need to serialize quota_off() for device */ down (&dqopt->dqonoff_sem);for (cnt =0 ; cnt <MAXQUOTAS ; cnt++) { + toput[cnt] =NULL ;if (type !=-1 && cnt != type)continue ;if (!sb_has_quota_enabled (sb, cnt))
@@ -1337,7 +1339,7 @@ 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]); + toput[cnt] = dqopt->files[cnt]; dqopt->files[cnt] =NULL ; dqopt->info[cnt].dqi_flags =0 ; dqopt->info[cnt].dqi_igrace =0 ;
@@ -1345,6 +1347,26 @@ int vfs_quota_off(struct super_block *sb 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) */ +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 (toput[cnt]) { +down (&toput[cnt]->i_sem); + toput[cnt]->i_flags &= ~(S_IMMUTABLE |S_NOATIME |S_NOQUOTA ); +truncate_inode_pages (&toput[cnt]->i_data,0 ); +up (&toput[cnt]->i_sem); +mark_inode_dirty (toput[cnt]); +iput (toput[cnt]); + } +invalidate_bdev (sb->s_bdev,0 );return 0 ; }
@@ -1352,68 +1374,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; - inode = f->f_dentry->d_inode; - error = -EACCES ; -if (!S_ISREG (inode->i_mode)) + } +if (IS_RDONLY (inode)) { + error = -EROFS ; + goto out_fmt; + } +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 +1434,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 +1444,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 +1465,37 @@ 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); +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/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
include/linux/fs.h +3 -0
@@ -1069,6 +1069,9 @@ struct super_operations {void (*sync_inodes) (struct super_block *sb,struct writeback_control *wbc);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 +1 -1
@@ -285,7 +285,7 @@ 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 mem_dqinfo info[MAXQUOTAS ];/* Information for each quota type */ struct quota_format_ops *ops[MAXQUOTAS ];/* Operations for each type */ };
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
@@ -1478,9 +1478,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)
What prevents vfs_quota_off() from racing with unmount?
If you look at, say, sync_filesystems() you'll see that we take ->s_umount and then test ->s_root to check that we didn't race with an unmount attempt.
Jan Kara
reviewerQuoted 6 lines
What prevents
vfs_quota_off()from racing with unmount?If you look at, say,
sync_filesystems()you'll see that we take ->s_umount and then test ->s_root to check that we didn't race with an unmount attempt.
I thought that the sync_fs and stuff is guarded by the fact that quota
code is holding references to inodes on the filesystem. And invalidate_bdev() should not care about the filesystem. Or do I miss something? Anyway adding a comment about this is really a good idea...
I've found a subtle bug though - there can be vfs_quota_off() racing
against vfs_quota_on() resulting in the flags on the inode being set wrong... I'll fix that one.
Thanks for checking
Honza
Signature · 2 lines
Jan Kara <[email protected]> SuSE CR Labs
Quoted 11 lines · Jan Kara
Quoted 7 lines
What prevents
vfs_quota_off()from racing with unmount?If you look at, say,
sync_filesystems()you'll see that we take ->s_umount and then test ->s_root to check that we didn't race with an unmount attempt.I thought that the
sync_fsand stuff is guarded by the fact that quota
code is holding references to inodes on the filesystem. Andinvalidate_bdev()should not care about the filesystem. Or do I miss something? Anyway adding a comment about this is really a good idea...
Holding a ref on an inode will not cause umount to block. It'll just cause nasty "Busy inodes after unmount" warnings.
Jan Kara
reviewerQuoted 8 lines
Quoted 7 lines · Jan Kara
Quoted 7 lines
What prevents
vfs_quota_off()from racing with unmount?If you look at, say,
sync_filesystems()you'll see that we take ->s_umount and then test ->s_root to check that we didn't race with an unmount attempt.
Quoted 7 lines
Quoted 4 lines
I thought that the
sync_fsand stuff is guarded by the fact that quota
code is holding references to inodes on the filesystem. Andinvalidate_bdev()should not care about the filesystem. Or do I miss something? Anyway adding a comment about this is really a good idea...Holding a ref on an inode will not cause umount to block. It'll just cause nasty "Busy inodes after unmount" warnings.
I see, thanks. I'll fix that also.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SuSE CR Labs
Jan Kara
reviewerQuoted 8 lines
Quoted 7 lines · Jan Kara
Quoted 7 lines
What prevents
vfs_quota_off()from racing with unmount?If you look at, say,
sync_filesystems()you'll see that we take ->s_umount and then test ->s_root to check that we didn't race with an unmount attempt.
Quoted 7 lines
Quoted 4 lines
I thought that the
sync_fsand stuff is guarded by the fact that quota
code is holding references to inodes on the filesystem. Andinvalidate_bdev()should not care about the filesystem. Or do I miss something? Anyway adding a comment about this is really a good idea...Holding a ref on an inode will not cause umount to block. It'll just cause nasty "Busy inodes after unmount" warnings.
Attached patch should solve the problem. Finally I decided to take a
reference to vfsmount during vfs_quota_on() and to drop it after the final cleanup in the vfs_quota_off(). This way we should be all the time guarded against umount. This way was protected also the old code which used filp_open() for opening quota files. I was also thinking about other ways of protection but there would be always a window (provided I don't want to play much with namespace locks) where vfs_quota_on() could be called while umount() is in progress resulting in the "Busy inodes after unmount" messages...
Honza
Signature · 2 lines
Jan Kara <[email protected]> SuSE CR Labs
Get a reference to vfsmount during quotaon() so that we are guarded against umount (as was the old code using filp_open()).
fs/dquot.c +33 -12
@@ -1320,12 +1320,14 @@ int vfs_quota_off(struct super_block *sb {int cnt;struct quota_info *dqopt =sb_dqopt (sb); -struct inode *toput[MAXQUOTAS ]; +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++) { - toput[cnt] =NULL ; + toputinode[cnt] =NULL ; + toputmnt[cnt] =NULL ;if (type !=-1 && cnt != type)continue ;if (!sb_has_quota_enabled (sb, cnt))
@@ -1345,8 +1347,10 @@ int vfs_quota_off(struct super_block *sb dqopt->ops[cnt]->free_file_info (sb, cnt);put_quota_format (dqopt->info[cnt].dqi_format); - toput[cnt] = 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 ;
@@ -1354,7 +1358,10 @@ int vfs_quota_off(struct super_block *sb }up (&dqopt->dqonoff_sem);/* Sync the superblock so that buffers with quota data are written to -* disk (and so userspace sees correct data afterwards) */ +* 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);
@@ -1364,13 +1371,24 @@ int vfs_quota_off(struct super_block *sb* 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 (toput[cnt]) { -down (&toput[cnt]->i_sem); - toput[cnt]->i_flags &= ~(S_IMMUTABLE |S_NOATIME |S_NOQUOTA ); -truncate_inode_pages (&toput[cnt]->i_data,0 ); -up (&toput[cnt]->i_sem); -mark_inode_dirty (toput[cnt]); -iput (toput[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 ;
@@ -1483,8 +1501,11 @@ int vfs_quota_on(struct super_block *sb,/* Quota file not on the same filesystem? */ if (nd.mnt->mnt_sb != sb) error = -EXDEV ; -else +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;
include/linux/quota.h +1 -0
@@ -286,6 +286,7 @@ struct quota_info {struct semaphore dqonoff_sem;/* Serialize quotaon & quotaoff */ struct rw_semaphore dqptr_sem;/* serialize ops using quota_info struct, pointers from inode to dquots */ 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; }
Jan Kara
reviewerQuoted 15 lines
Quoted 8 lines
Quoted 7 lines · Jan Kara
Quoted 7 lines
What prevents
vfs_quota_off()from racing with unmount?If you look at, say,
sync_filesystems()you'll see that we take ->s_umount and then test ->s_root to check that we didn't race with an unmount attempt.Quoted 7 lines
Quoted 4 lines
I thought that the
sync_fsand stuff is guarded by the fact that quota
code is holding references to inodes on the filesystem. Andinvalidate_bdev()should not care about the filesystem. Or do I miss something? Anyway adding a comment about this is really a good idea...Holding a ref on an inode will not cause umount to block. It'll just cause nasty "Busy inodes after unmount" warnings.
Quoted 9 lines
Attached patch should solve the problem. Finally I decided to take a
reference to vfsmount duringvfs_quota_on()and to drop it after the final cleanup in thevfs_quota_off(). This way we should be all the time guarded against umount. This way was protected also the old code which usedfilp_open()for opening quota files. I was also thinking about other ways of protection but there would be always a window (provided I don't want to play much with namespace locks) wherevfs_quota_on()could be called whileumount()is in progress resulting in the "Busy inodes after unmount" messages...
Sorry for replying myself but the last patch was against -mm3 kernel
without your fix of bdev==NULL problems. Attached patch should apply better..
Honza
Signature · 2 lines
Jan Kara <[email protected]> SuSE CR Labs
Get a reference to vfsmount during quotaon() so that we are guarded against umount (as was the old code using filp_open()).
fs/dquot.c +33 -12
@@ -1320,12 +1320,14 @@ int vfs_quota_off(struct super_block *sb {int cnt;struct quota_info *dqopt =sb_dqopt (sb); -struct inode *toput[MAXQUOTAS ]; +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++) { - toput[cnt] =NULL ; + toputinode[cnt] =NULL ; + toputmnt[cnt] =NULL ;if (type !=-1 && cnt != type)continue ;if (!sb_has_quota_enabled (sb, cnt))
@@ -1345,8 +1347,10 @@ int vfs_quota_off(struct super_block *sb dqopt->ops[cnt]->free_file_info (sb, cnt);put_quota_format (dqopt->info[cnt].dqi_format); - toput[cnt] = 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 ;
@@ -1354,7 +1358,10 @@ int vfs_quota_off(struct super_block *sb }up (&dqopt->dqonoff_sem);/* Sync the superblock so that buffers with quota data are written to -* disk (and so userspace sees correct data afterwards) */ +* 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);
@@ -1364,13 +1371,24 @@ int vfs_quota_off(struct super_block *sb* 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 (toput[cnt]) { -down (&toput[cnt]->i_sem); - toput[cnt]->i_flags &= ~(S_IMMUTABLE |S_NOATIME |S_NOQUOTA ); -truncate_inode_pages (&toput[cnt]->i_data,0 ); -up (&toput[cnt]->i_sem); -mark_inode_dirty (toput[cnt]); -iput (toput[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]); }if (sb->s_bdev)invalidate_bdev (sb->s_bdev,0 );
@@ -1484,8 +1502,11 @@ int vfs_quota_on(struct super_block *sb,/* Quota file not on the same filesystem? */ if (nd.mnt->mnt_sb != sb) error = -EXDEV ; -else +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;
include/linux/quota.h +1 -0
@@ -286,6 +286,7 @@ struct quota_info {struct semaphore dqonoff_sem;/* Serialize quotaon & quotaoff */ struct rw_semaphore dqptr_sem;/* serialize ops using quota_info struct, pointers from inode to dquots */ 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; }
Jan Kara
reviewerHello!
Attached patch implements quota_read() and quota_write() functions for
ext2. Please apply.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SuSE CR Labs
Implementation of quota reading and writing functions for ext2.
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 +105 -0
123 lines not on this page · raw message
fs/ext2/super.c static struct super_block *ext2_get_sb(s · line 1023
Quoted 6 lines · Jan Kara
fs/ext2/super.c +5
-0+static ssize_t ext2_quota_read (struct super_block *sb,int type,char *data, +size_t len,loff_t off) +{ +struct inode *inode =sb_dqopt (sb)->files[type]; +unsigned long blk = off >>EXT2_BLOCK_SIZE_BITS (sb);
`blk' should have sector_t type.
Review
Quoted 1 line
(quoted diff) +1
-0+ int err = 0, offset = off & (sb->s_blocksize - 1), tocopy;
Please do
int err = 0; int offset = off & (sb->s_blocksize - 1); int tocopy;
I'll make the above changes.
Quoted 18 lines · Jan Kara
(quoted diff) +17
-0+static ssize_t ext2_quota_write(struct super_block *sb, int type, + const char *data, size_t len, loff_t off) +{ + struct inode *inode = sb_dqopt(sb)->files[type]; + unsigned long blk = off >> EXT2_BLOCK_SIZE_BITS(sb); + int err = 0, offset = off & (sb->s_blocksize - 1), tocopy; + size_t towrite = len; + struct buffer_head tmp_bh, *bh; + + down(&inode->i_sem); + while (towrite > 0) { + tocopy = sb->s_blocksize - offset < towrite ? + sb->s_blocksize - offset : towrite; + + tmp_bh.b_state = 0; + err = ext2_get_block(inode, blk, &tmp_bh, 1); + if (err)
Review
Quoted 10 lines
(quoted diff) +10
-0+ goto out; + if (offset || tocopy != EXT2_BLOCK_SIZE(sb)) + bh = sb_bread(sb, tmp_bh.b_blocknr); + else + bh = sb_getblk(sb, tmp_bh.b_blocknr); + if (!bh) { + err = -EIO; + goto out; + } + memcpy(bh->b_data+offset, data, tocopy);
It is possible to mmap block devices, so we should do a flush_dcache_page() after the memset here.
Also, we should lock the buffer. Because a concurrent read of the blockdev would cause the disk DMA transfer to stomp all over the data whihc you just wrote. Say, someone is doing `cp /dev/hda1 /dev/null' at the same time.
So my accumulated patch against this one is:
fs/ext2/super.c renamed from fs/ext2/super.c~fix-of-quota-deadlock-on-pagelock-ext2-tweaks +15 -6
@@ -1020,10 +1020,13 @@ static ssize_t ext2_quota_read(struct su size_t len, loff_t off) {struct inode *inode =sb_dqopt (sb)->files[type]; -unsigned long blk = off >>EXT2_BLOCK_SIZE_BITS (sb); -int err =0 , offset = off & (sb->s_blocksize -1 ), tocopy; +sector_t blk = off >>EXT2_BLOCK_SIZE_BITS (sb); +int err =0 ; +int offset = off & (sb->s_blocksize -1 ); +int tocopy;size_t toread; -struct buffer_head tmp_bh, *bh; +struct buffer_head tmp_bh; +struct buffer_head *bh;loff_t i_size =i_size_read (inode);if (off > i_size)
@@ -1061,10 +1064,13 @@ static ssize_t ext2_quota_write(struct s const char *data, size_t len, loff_t off) { struct inode *inode = sb_dqopt(sb)->files[type]; -unsigned long blk = off >>EXT2_BLOCK_SIZE_BITS (sb); -int err =0 , offset = off & (sb->s_blocksize -1 ), tocopy; +sector_t blk = off >>EXT2_BLOCK_SIZE_BITS (sb); +int err =0 ; +int offset = off & (sb->s_blocksize -1 ); +int tocopy;size_t towrite = len; -struct buffer_head tmp_bh, *bh; +struct buffer_head tmp_bh; +struct buffer_head *bh;down (&inode->i_sem);while (towrite >0 ) {
@@ -1083,9 +1089,12 @@ static ssize_t ext2_quota_write(struct s err = -EIO ; goto out; } +lock_buffer (bh);memcpy (bh->b_data+offset, data, tocopy); +flush_dcache_page (&bh->b_page);set_buffer_uptodate (bh);mark_buffer_dirty (bh); +unlock_buffer (bh);brelse (bh); offset =0 ; towrite -= tocopy;
_
I suspect things in there are still a bit racy against a concurrent `blockdev --flushbufs' though.
Quoted 78 lines · Andrew Morton
Quoted 18 lines · Jan Kara
(quoted diff) +17
-0+static ssize_t ext2_quota_write(struct super_block *sb, int type, + const char *data, size_t len, loff_t off) +{ + struct inode *inode = sb_dqopt(sb)->files[type]; + unsigned long blk = off >> EXT2_BLOCK_SIZE_BITS(sb); + int err = 0, offset = off & (sb->s_blocksize - 1), tocopy; + size_t towrite = len; + struct buffer_head tmp_bh, *bh; + + down(&inode->i_sem); + while (towrite > 0) { + tocopy = sb->s_blocksize - offset < towrite ? + sb->s_blocksize - offset : towrite; + + tmp_bh.b_state = 0; + err = ext2_get_block(inode, blk, &tmp_bh, 1); + if (err)Review
Quoted 10 lines
(quoted diff) +10
-0+ goto out; + if (offset || tocopy != EXT2_BLOCK_SIZE(sb)) + bh = sb_bread(sb, tmp_bh.b_blocknr); + else + bh = sb_getblk(sb, tmp_bh.b_blocknr); + if (!bh) { + err = -EIO; + goto out; + } + memcpy(bh->b_data+offset, data, tocopy);It is possible to mmap block devices, so we should do a
flush_dcache_page()after the memset here.Also, we should lock the buffer. Because a concurrent read of the blockdev would cause the disk DMA transfer to stomp all over the data whihc you just wrote. Say, someone is doing `cp
/dev/hda1/dev/null' at the same time.So my accumulated patch against this one is:
diff -puN
fs/ext2/super.c~fix-of-quota-deadlock-on-pagelock-ext2-tweaksfs/ext2/super.cfs/ext2/super.c renamed from fs/ext2/super.c~fix-of-quota-deadlock-on-pagelock-ext2-tweaks +12
-6@@ -1020,10 +1020,13 @@ static ssize_t ext2_quota_read(struct su size_t len, loff_t off) {struct inode *inode =sb_dqopt (sb)->files[type]; -unsigned long blk = off >>EXT2_BLOCK_SIZE_BITS (sb); -int err =0 , offset = off & (sb->s_blocksize -1 ), tocopy; +sector_t blk = off >>EXT2_BLOCK_SIZE_BITS (sb); +int err =0 ; +int offset = off & (sb->s_blocksize -1 ); +int tocopy;size_t toread; -struct buffer_head tmp_bh, *bh; +struct buffer_head tmp_bh; +struct buffer_head *bh;loff_t i_size =i_size_read (inode);if (off > i_size)@@ -1061,10 +1064,13 @@ static ssize_t ext2_quota_write(struct s const char *data, size_t len, loff_t off) { struct inode *inode = sb_dqopt(sb)->files[type]; -unsigned long blk = off >>EXT2_BLOCK_SIZE_BITS (sb); -int err =0 , offset = off & (sb->s_blocksize -1 ), tocopy; +sector_t blk = off >>EXT2_BLOCK_SIZE_BITS (sb); +int err =0 ; +int offset = off & (sb->s_blocksize -1 ); +int tocopy;size_t towrite = len; -struct buffer_head tmp_bh, *bh; +struct buffer_head tmp_bh; +struct buffer_head *bh;down (&inode->i_sem);while (towrite >0 ) {
fs/ext2/super.c static ssize_t ext2_quota_write(struct s · line 1094
Quoted 6 lines
fs/ext2/super.c renamed from fs/ext2/super.c~fix-of-quota-deadlock-on-pagelock-ext2-tweaks +2
-0@@ -1083,9 +1089,12 @@ static ssize_t ext2_quota_write(struct s err = -EIO ; goto out; } +lock_buffer (bh);memcpy (bh->b_data+offset, data, tocopy); +flush_dcache_page (&bh->b_page);
^^^
bh->b_page
Signature · 1 line
Jens Axboe
Jan Kara
reviewerQuoted 24 lines
Quoted 23 lines · Jan Kara
(quoted diff) +22
-0+static ssize_t ext2_quota_write(struct super_block *sb, int type, + const char *data, size_t len, loff_t off) +{ + struct inode *inode = sb_dqopt(sb)->files[type]; + unsigned long blk = off >> EXT2_BLOCK_SIZE_BITS(sb); + int err = 0, offset = off & (sb->s_blocksize - 1), tocopy; + size_t towrite = len; + struct buffer_head tmp_bh, *bh; + + down(&inode->i_sem); + while (towrite > 0) { + tocopy = sb->s_blocksize - offset < towrite ? + sb->s_blocksize - offset : towrite; + + tmp_bh.b_state = 0; + err = ext2_get_block(inode, blk, &tmp_bh, 1); + if (err) + goto out; + if (offset || tocopy != EXT2_BLOCK_SIZE(sb)) + bh = sb_bread(sb, tmp_bh.b_blocknr); + else + bh = sb_getblk(sb, tmp_bh.b_blocknr);
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ if (!bh) { + err = -EIO; + goto out; + } + memcpy(bh->b_data+offset, data, tocopy);It is possible to mmap block devices, so we should do a
flush_dcache_page()after the memset here.
Thanks I didn't know about this.
Quoted 3 lines
Also, we should lock the buffer. Because a concurrent read of the blockdev would cause the disk DMA transfer to stomp all over the data whihc you just wrote. Say, someone is doing `cp
/dev/hda1/dev/null' at the same time.
Yes, obviously the buffer should be locked. Thanks for spotting.
Quoted 52 lines
So my accumulated patch against this one is:
diff -puN
fs/ext2/super.c~fix-of-quota-deadlock-on-pagelock-ext2-tweaksfs/ext2/super.cfs/ext2/super.c renamed from fs/ext2/super.c~fix-of-quota-deadlock-on-pagelock-ext2-tweaks +15
-6@@ -1020,10 +1020,13 @@ static ssize_t ext2_quota_read(struct su size_t len, loff_t off) {struct inode *inode =sb_dqopt (sb)->files[type]; -unsigned long blk = off >>EXT2_BLOCK_SIZE_BITS (sb); -int err =0 , offset = off & (sb->s_blocksize -1 ), tocopy; +sector_t blk = off >>EXT2_BLOCK_SIZE_BITS (sb); +int err =0 ; +int offset = off & (sb->s_blocksize -1 ); +int tocopy;size_t toread; -struct buffer_head tmp_bh, *bh; +struct buffer_head tmp_bh; +struct buffer_head *bh;loff_t i_size =i_size_read (inode);if (off > i_size)@@ -1061,10 +1064,13 @@ static ssize_t ext2_quota_write(struct s const char *data, size_t len, loff_t off) { struct inode *inode = sb_dqopt(sb)->files[type]; -unsigned long blk = off >>EXT2_BLOCK_SIZE_BITS (sb); -int err =0 , offset = off & (sb->s_blocksize -1 ), tocopy; +sector_t blk = off >>EXT2_BLOCK_SIZE_BITS (sb); +int err =0 ; +int offset = off & (sb->s_blocksize -1 ); +int tocopy;size_t towrite = len; -struct buffer_head tmp_bh, *bh; +struct buffer_head tmp_bh; +struct buffer_head *bh;down (&inode->i_sem);while (towrite >0 ) {@@ -1083,9 +1089,12 @@ static ssize_t ext2_quota_write(struct s err = -EIO ; goto out; } +lock_buffer (bh);memcpy (bh->b_data+offset, data, tocopy); +flush_dcache_page (&bh->b_page);set_buffer_uptodate (bh);mark_buffer_dirty (bh); +unlock_buffer (bh);brelse (bh); offset =0 ; towrite -= tocopy;
Quoted 2 lines
_
Thanks, the patch looks OK (only Jens spotted a minor bug there).
Quoted 2 lines
I suspect things in there are still a bit racy against a concurrent `blockdev --flushbufs' though.
Thanks for notifying. I'll check that.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SuSE CR Labs
Jan Kara
reviewer<snip>
Quoted 56 lines
So my accumulated patch against this one is:
diff -puN
fs/ext2/super.c~fix-of-quota-deadlock-on-pagelock-ext2-tweaksfs/ext2/super.cfs/ext2/super.c renamed from fs/ext2/super.c~fix-of-quota-deadlock-on-pagelock-ext2-tweaks +15
-6@@ -1020,10 +1020,13 @@ static ssize_t ext2_quota_read(struct su size_t len, loff_t off) {struct inode *inode =sb_dqopt (sb)->files[type]; -unsigned long blk = off >>EXT2_BLOCK_SIZE_BITS (sb); -int err =0 , offset = off & (sb->s_blocksize -1 ), tocopy; +sector_t blk = off >>EXT2_BLOCK_SIZE_BITS (sb); +int err =0 ; +int offset = off & (sb->s_blocksize -1 ); +int tocopy;size_t toread; -struct buffer_head tmp_bh, *bh; +struct buffer_head tmp_bh; +struct buffer_head *bh;loff_t i_size =i_size_read (inode);if (off > i_size)@@ -1061,10 +1064,13 @@ static ssize_t ext2_quota_write(struct s const char *data, size_t len, loff_t off) { struct inode *inode = sb_dqopt(sb)->files[type]; -unsigned long blk = off >>EXT2_BLOCK_SIZE_BITS (sb); -int err =0 , offset = off & (sb->s_blocksize -1 ), tocopy; +sector_t blk = off >>EXT2_BLOCK_SIZE_BITS (sb); +int err =0 ; +int offset = off & (sb->s_blocksize -1 ); +int tocopy;size_t towrite = len; -struct buffer_head tmp_bh, *bh; +struct buffer_head tmp_bh; +struct buffer_head *bh;down (&inode->i_sem);while (towrite >0 ) {@@ -1083,9 +1089,12 @@ static ssize_t ext2_quota_write(struct s err = -EIO ; goto out; } +lock_buffer (bh);memcpy (bh->b_data+offset, data, tocopy); +flush_dcache_page (&bh->b_page);set_buffer_uptodate (bh);mark_buffer_dirty (bh); +unlock_buffer (bh);brelse (bh); offset =0 ; towrite -= tocopy;_
Quoted 2 lines
I suspect things in there are still a bit racy against a concurrent `blockdev --flushbufs' though.
I've now checked the code and to me it seems OK. invalidate_bdev()
will eventually end up calling try_to_free_buffers() which refuses to free buffers someone holds reference to. So while we are holding the reference we are safe. And after we call mark_buffer_dirty() the bdev page is marked dirty and hence we are safe again (because invalidate_complete_page() rechecks for the page being dirty after try_to_free_buffers() succeeds)...
I'm now going to have a look on the umount vs vfs_quota_off() race.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SuSE CR Labs
Jan Kara
reviewerHello!
Attached patch implements quota_read() and quota_write() functions for
ext3. Furthermore it contains some other changes related to the changes of quota core interfaces... Please apply.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SuSE CR Labs
Implementation of quota reading and writing functions for ext3.
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 +125 -31
227 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);
Jan Kara
reviewerHi!
The last patch in the row ;). It implements quota_read(),quota_write() for reiserfs, fixes several lock inversion problems on various locks and journal_begin and implements journaled quota. Hopefuly some of the reiserfs maintainers will have a look at it and either accept it or tells me what's wrong. In the meantime accept it if you like it (I'm not sure how much Hans insists on seeing the patches that are going in...).
Honza
Signature · 2 lines
Jan Kara <[email protected]> SuSE CR Labs
Implement quota journaling and quota reading and writing functions for reiserfs. Solves also several other deadlocks possible for reiserfs due to the lock inversion on journal_begin and quota locks.
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/journal.c +1 -0
@@ -2647,6 +2647,7 @@ static int do_journal_begin_r(struct reiint retval;reiserfs_check_lock_depth (p_s_sb,"journal_begin" ) ; +RFALSE (SB_JOURNAL_MAX_BATCH (p_s_sb) < nblocks+2 ,"transaction too big (%u < %u)" ,SB_JOURNAL_MAX_BATCH (p_s_sb), nblocks+2 );PROC_INFO_INC ( p_s_sb, journal.journal_being );/* set here for journal_join */
fs/reiserfs/namei.c +27 -33
148 lines not on this page · raw message
fs/reiserfs/super.c +403 -5
519 lines not on this page · raw message
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: */