aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dquot.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/dquot.c')
-rw-r--r--fs/dquot.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/dquot.c b/fs/dquot.c
index 2a62b3dc20ec..1966c890b48d 100644
--- a/fs/dquot.c
+++ b/fs/dquot.c
@@ -77,6 +77,7 @@
77#include <linux/kmod.h> 77#include <linux/kmod.h>
78#include <linux/namei.h> 78#include <linux/namei.h>
79#include <linux/buffer_head.h> 79#include <linux/buffer_head.h>
80#include <linux/capability.h>
80#include <linux/quotaops.h> 81#include <linux/quotaops.h>
81 82
82#include <asm/uaccess.h> 83#include <asm/uaccess.h>
@@ -100,7 +101,7 @@
100 * operation is just reading pointers from inode (or not using them at all) the 101 * operation is just reading pointers from inode (or not using them at all) the
101 * read lock is enough. If pointers are altered function must hold write lock 102 * read lock is enough. If pointers are altered function must hold write lock
102 * (these locking rules also apply for S_NOQUOTA flag in the inode - note that 103 * (these locking rules also apply for S_NOQUOTA flag in the inode - note that
103 * for altering the flag i_sem is also needed). If operation is holding 104 * for altering the flag i_mutex is also needed). If operation is holding
104 * reference to dquot in other way (e.g. quotactl ops) it must be guarded by 105 * reference to dquot in other way (e.g. quotactl ops) it must be guarded by
105 * dqonoff_sem. 106 * dqonoff_sem.
106 * This locking assures that: 107 * This locking assures that:
@@ -117,9 +118,9 @@
117 * spinlock to internal buffers before writing. 118 * spinlock to internal buffers before writing.
118 * 119 *
119 * Lock ordering (including related VFS locks) is the following: 120 * Lock ordering (including related VFS locks) is the following:
120 * i_sem > dqonoff_sem > iprune_sem > journal_lock > dqptr_sem > 121 * i_mutex > dqonoff_sem > iprune_sem > journal_lock > dqptr_sem >
121 * > dquot->dq_lock > dqio_sem 122 * > dquot->dq_lock > dqio_sem
122 * i_sem on quota files is special (it's below dqio_sem) 123 * i_mutex on quota files is special (it's below dqio_sem)
123 */ 124 */
124 125
125static DEFINE_SPINLOCK(dq_list_lock); 126static DEFINE_SPINLOCK(dq_list_lock);
@@ -1369,11 +1370,11 @@ int vfs_quota_off(struct super_block *sb, int type)
1369 /* If quota was reenabled in the meantime, we have 1370 /* If quota was reenabled in the meantime, we have
1370 * nothing to do */ 1371 * nothing to do */
1371 if (!sb_has_quota_enabled(sb, cnt)) { 1372 if (!sb_has_quota_enabled(sb, cnt)) {
1372 down(&toputinode[cnt]->i_sem); 1373 mutex_lock(&toputinode[cnt]->i_mutex);
1373 toputinode[cnt]->i_flags &= ~(S_IMMUTABLE | 1374 toputinode[cnt]->i_flags &= ~(S_IMMUTABLE |
1374 S_NOATIME | S_NOQUOTA); 1375 S_NOATIME | S_NOQUOTA);
1375 truncate_inode_pages(&toputinode[cnt]->i_data, 0); 1376 truncate_inode_pages(&toputinode[cnt]->i_data, 0);
1376 up(&toputinode[cnt]->i_sem); 1377 mutex_unlock(&toputinode[cnt]->i_mutex);
1377 mark_inode_dirty(toputinode[cnt]); 1378 mark_inode_dirty(toputinode[cnt]);
1378 iput(toputinode[cnt]); 1379 iput(toputinode[cnt]);
1379 } 1380 }
@@ -1417,7 +1418,7 @@ static int vfs_quota_on_inode(struct inode *inode, int type, int format_id)
1417 write_inode_now(inode, 1); 1418 write_inode_now(inode, 1);
1418 /* And now flush the block cache so that kernel sees the changes */ 1419 /* And now flush the block cache so that kernel sees the changes */
1419 invalidate_bdev(sb->s_bdev, 0); 1420 invalidate_bdev(sb->s_bdev, 0);
1420 down(&inode->i_sem); 1421 mutex_lock(&inode->i_mutex);
1421 down(&dqopt->dqonoff_sem); 1422 down(&dqopt->dqonoff_sem);
1422 if (sb_has_quota_enabled(sb, type)) { 1423 if (sb_has_quota_enabled(sb, type)) {
1423 error = -EBUSY; 1424 error = -EBUSY;
@@ -1449,7 +1450,7 @@ static int vfs_quota_on_inode(struct inode *inode, int type, int format_id)
1449 goto out_file_init; 1450 goto out_file_init;
1450 } 1451 }
1451 up(&dqopt->dqio_sem); 1452 up(&dqopt->dqio_sem);
1452 up(&inode->i_sem); 1453 mutex_unlock(&inode->i_mutex);
1453 set_enable_flags(dqopt, type); 1454 set_enable_flags(dqopt, type);
1454 1455
1455 add_dquot_ref(sb, type); 1456 add_dquot_ref(sb, type);
@@ -1470,7 +1471,7 @@ out_lock:
1470 inode->i_flags |= oldflags; 1471 inode->i_flags |= oldflags;
1471 up_write(&dqopt->dqptr_sem); 1472 up_write(&dqopt->dqptr_sem);
1472 } 1473 }
1473 up(&inode->i_sem); 1474 mutex_unlock(&inode->i_mutex);
1474out_fmt: 1475out_fmt:
1475 put_quota_format(fmt); 1476 put_quota_format(fmt);
1476 1477