diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-05 16:20:53 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-05 16:20:53 -0500 |
commit | e213e26ab3988c516c06eba4dcd030ac052f6dc9 (patch) | |
tree | 6e26fbdbb842b387697d73daf6e70cf718269a77 /fs/ext3 | |
parent | c812a51d11bbe983f4c24e32b59b265705ddd3c2 (diff) | |
parent | efd8f0e6f6c1faa041f228d7113bd3a9db802d49 (diff) |
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs-2.6
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs-2.6: (33 commits)
quota: stop using QUOTA_OK / NO_QUOTA
dquot: cleanup dquot initialize routine
dquot: move dquot initialization responsibility into the filesystem
dquot: cleanup dquot drop routine
dquot: move dquot drop responsibility into the filesystem
dquot: cleanup dquot transfer routine
dquot: move dquot transfer responsibility into the filesystem
dquot: cleanup inode allocation / freeing routines
dquot: cleanup space allocation / freeing routines
ext3: add writepage sanity checks
ext3: Truncate allocated blocks if direct IO write fails to update i_size
quota: Properly invalidate caches even for filesystems with blocksize < pagesize
quota: generalize quota transfer interface
quota: sb_quota state flags cleanup
jbd: Delay discarding buffers in journal_unmap_buffer
ext3: quota_write cross block boundary behaviour
quota: drop permission checks from xfs_fs_set_xstate/xfs_fs_set_xquota
quota: split out compat_sys_quotactl support from quota.c
quota: split out netlink notification support from quota.c
quota: remove invalid optimization from quota_sync_all
...
Fixed trivial conflicts in fs/namei.c and fs/ufs/inode.c
Diffstat (limited to 'fs/ext3')
-rw-r--r-- | fs/ext3/balloc.c | 11 | ||||
-rw-r--r-- | fs/ext3/file.c | 7 | ||||
-rw-r--r-- | fs/ext3/ialloc.c | 16 | ||||
-rw-r--r-- | fs/ext3/inode.c | 41 | ||||
-rw-r--r-- | fs/ext3/namei.c | 24 | ||||
-rw-r--r-- | fs/ext3/super.c | 246 | ||||
-rw-r--r-- | fs/ext3/xattr.c | 22 |
7 files changed, 200 insertions, 167 deletions
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c index 27967f92e820..161da2d3f890 100644 --- a/fs/ext3/balloc.c +++ b/fs/ext3/balloc.c | |||
@@ -676,7 +676,7 @@ void ext3_free_blocks(handle_t *handle, struct inode *inode, | |||
676 | } | 676 | } |
677 | ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks); | 677 | ext3_free_blocks_sb(handle, sb, block, count, &dquot_freed_blocks); |
678 | if (dquot_freed_blocks) | 678 | if (dquot_freed_blocks) |
679 | vfs_dq_free_block(inode, dquot_freed_blocks); | 679 | dquot_free_block(inode, dquot_freed_blocks); |
680 | return; | 680 | return; |
681 | } | 681 | } |
682 | 682 | ||
@@ -1502,8 +1502,9 @@ ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode, | |||
1502 | /* | 1502 | /* |
1503 | * Check quota for allocation of this block. | 1503 | * Check quota for allocation of this block. |
1504 | */ | 1504 | */ |
1505 | if (vfs_dq_alloc_block(inode, num)) { | 1505 | err = dquot_alloc_block(inode, num); |
1506 | *errp = -EDQUOT; | 1506 | if (err) { |
1507 | *errp = err; | ||
1507 | return 0; | 1508 | return 0; |
1508 | } | 1509 | } |
1509 | 1510 | ||
@@ -1713,7 +1714,7 @@ allocated: | |||
1713 | 1714 | ||
1714 | *errp = 0; | 1715 | *errp = 0; |
1715 | brelse(bitmap_bh); | 1716 | brelse(bitmap_bh); |
1716 | vfs_dq_free_block(inode, *count-num); | 1717 | dquot_free_block(inode, *count-num); |
1717 | *count = num; | 1718 | *count = num; |
1718 | return ret_block; | 1719 | return ret_block; |
1719 | 1720 | ||
@@ -1728,7 +1729,7 @@ out: | |||
1728 | * Undo the block allocation | 1729 | * Undo the block allocation |
1729 | */ | 1730 | */ |
1730 | if (!performed_allocation) | 1731 | if (!performed_allocation) |
1731 | vfs_dq_free_block(inode, *count); | 1732 | dquot_free_block(inode, *count); |
1732 | brelse(bitmap_bh); | 1733 | brelse(bitmap_bh); |
1733 | return 0; | 1734 | return 0; |
1734 | } | 1735 | } |
diff --git a/fs/ext3/file.c b/fs/ext3/file.c index 388bbdfa0b4e..f55df0e61cbd 100644 --- a/fs/ext3/file.c +++ b/fs/ext3/file.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/time.h> | 21 | #include <linux/time.h> |
22 | #include <linux/fs.h> | 22 | #include <linux/fs.h> |
23 | #include <linux/jbd.h> | 23 | #include <linux/jbd.h> |
24 | #include <linux/quotaops.h> | ||
24 | #include <linux/ext3_fs.h> | 25 | #include <linux/ext3_fs.h> |
25 | #include <linux/ext3_jbd.h> | 26 | #include <linux/ext3_jbd.h> |
26 | #include "xattr.h" | 27 | #include "xattr.h" |
@@ -33,9 +34,9 @@ | |||
33 | */ | 34 | */ |
34 | static int ext3_release_file (struct inode * inode, struct file * filp) | 35 | static int ext3_release_file (struct inode * inode, struct file * filp) |
35 | { | 36 | { |
36 | if (EXT3_I(inode)->i_state & EXT3_STATE_FLUSH_ON_CLOSE) { | 37 | if (ext3_test_inode_state(inode, EXT3_STATE_FLUSH_ON_CLOSE)) { |
37 | filemap_flush(inode->i_mapping); | 38 | filemap_flush(inode->i_mapping); |
38 | EXT3_I(inode)->i_state &= ~EXT3_STATE_FLUSH_ON_CLOSE; | 39 | ext3_clear_inode_state(inode, EXT3_STATE_FLUSH_ON_CLOSE); |
39 | } | 40 | } |
40 | /* if we are the last writer on the inode, drop the block reservation */ | 41 | /* if we are the last writer on the inode, drop the block reservation */ |
41 | if ((filp->f_mode & FMODE_WRITE) && | 42 | if ((filp->f_mode & FMODE_WRITE) && |
@@ -62,7 +63,7 @@ const struct file_operations ext3_file_operations = { | |||
62 | .compat_ioctl = ext3_compat_ioctl, | 63 | .compat_ioctl = ext3_compat_ioctl, |
63 | #endif | 64 | #endif |
64 | .mmap = generic_file_mmap, | 65 | .mmap = generic_file_mmap, |
65 | .open = generic_file_open, | 66 | .open = dquot_file_open, |
66 | .release = ext3_release_file, | 67 | .release = ext3_release_file, |
67 | .fsync = ext3_sync_file, | 68 | .fsync = ext3_sync_file, |
68 | .splice_read = generic_file_splice_read, | 69 | .splice_read = generic_file_splice_read, |
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index b39991285136..ef9008b885b5 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c | |||
@@ -123,10 +123,10 @@ void ext3_free_inode (handle_t *handle, struct inode * inode) | |||
123 | * Note: we must free any quota before locking the superblock, | 123 | * Note: we must free any quota before locking the superblock, |
124 | * as writing the quota to disk may need the lock as well. | 124 | * as writing the quota to disk may need the lock as well. |
125 | */ | 125 | */ |
126 | vfs_dq_init(inode); | 126 | dquot_initialize(inode); |
127 | ext3_xattr_delete_inode(handle, inode); | 127 | ext3_xattr_delete_inode(handle, inode); |
128 | vfs_dq_free_inode(inode); | 128 | dquot_free_inode(inode); |
129 | vfs_dq_drop(inode); | 129 | dquot_drop(inode); |
130 | 130 | ||
131 | is_directory = S_ISDIR(inode->i_mode); | 131 | is_directory = S_ISDIR(inode->i_mode); |
132 | 132 | ||
@@ -588,10 +588,10 @@ got: | |||
588 | sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0; | 588 | sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0; |
589 | 589 | ||
590 | ret = inode; | 590 | ret = inode; |
591 | if (vfs_dq_alloc_inode(inode)) { | 591 | dquot_initialize(inode); |
592 | err = -EDQUOT; | 592 | err = dquot_alloc_inode(inode); |
593 | if (err) | ||
593 | goto fail_drop; | 594 | goto fail_drop; |
594 | } | ||
595 | 595 | ||
596 | err = ext3_init_acl(handle, inode, dir); | 596 | err = ext3_init_acl(handle, inode, dir); |
597 | if (err) | 597 | if (err) |
@@ -619,10 +619,10 @@ really_out: | |||
619 | return ret; | 619 | return ret; |
620 | 620 | ||
621 | fail_free_drop: | 621 | fail_free_drop: |
622 | vfs_dq_free_inode(inode); | 622 | dquot_free_inode(inode); |
623 | 623 | ||
624 | fail_drop: | 624 | fail_drop: |
625 | vfs_dq_drop(inode); | 625 | dquot_drop(inode); |
626 | inode->i_flags |= S_NOQUOTA; | 626 | inode->i_flags |= S_NOQUOTA; |
627 | inode->i_nlink = 0; | 627 | inode->i_nlink = 0; |
628 | unlock_new_inode(inode); | 628 | unlock_new_inode(inode); |
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 7aca55fcc976..7f920b7263a4 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c | |||
@@ -196,6 +196,9 @@ void ext3_delete_inode (struct inode * inode) | |||
196 | { | 196 | { |
197 | handle_t *handle; | 197 | handle_t *handle; |
198 | 198 | ||
199 | if (!is_bad_inode(inode)) | ||
200 | dquot_initialize(inode); | ||
201 | |||
199 | truncate_inode_pages(&inode->i_data, 0); | 202 | truncate_inode_pages(&inode->i_data, 0); |
200 | 203 | ||
201 | if (is_bad_inode(inode)) | 204 | if (is_bad_inode(inode)) |
@@ -1378,7 +1381,7 @@ static int ext3_journalled_write_end(struct file *file, | |||
1378 | */ | 1381 | */ |
1379 | if (pos + len > inode->i_size && ext3_can_truncate(inode)) | 1382 | if (pos + len > inode->i_size && ext3_can_truncate(inode)) |
1380 | ext3_orphan_add(handle, inode); | 1383 | ext3_orphan_add(handle, inode); |
1381 | EXT3_I(inode)->i_state |= EXT3_STATE_JDATA; | 1384 | ext3_set_inode_state(inode, EXT3_STATE_JDATA); |
1382 | if (inode->i_size > EXT3_I(inode)->i_disksize) { | 1385 | if (inode->i_size > EXT3_I(inode)->i_disksize) { |
1383 | EXT3_I(inode)->i_disksize = inode->i_size; | 1386 | EXT3_I(inode)->i_disksize = inode->i_size; |
1384 | ret2 = ext3_mark_inode_dirty(handle, inode); | 1387 | ret2 = ext3_mark_inode_dirty(handle, inode); |
@@ -1417,7 +1420,7 @@ static sector_t ext3_bmap(struct address_space *mapping, sector_t block) | |||
1417 | journal_t *journal; | 1420 | journal_t *journal; |
1418 | int err; | 1421 | int err; |
1419 | 1422 | ||
1420 | if (EXT3_I(inode)->i_state & EXT3_STATE_JDATA) { | 1423 | if (ext3_test_inode_state(inode, EXT3_STATE_JDATA)) { |
1421 | /* | 1424 | /* |
1422 | * This is a REALLY heavyweight approach, but the use of | 1425 | * This is a REALLY heavyweight approach, but the use of |
1423 | * bmap on dirty files is expected to be extremely rare: | 1426 | * bmap on dirty files is expected to be extremely rare: |
@@ -1436,7 +1439,7 @@ static sector_t ext3_bmap(struct address_space *mapping, sector_t block) | |||
1436 | * everything they get. | 1439 | * everything they get. |
1437 | */ | 1440 | */ |
1438 | 1441 | ||
1439 | EXT3_I(inode)->i_state &= ~EXT3_STATE_JDATA; | 1442 | ext3_clear_inode_state(inode, EXT3_STATE_JDATA); |
1440 | journal = EXT3_JOURNAL(inode); | 1443 | journal = EXT3_JOURNAL(inode); |
1441 | journal_lock_updates(journal); | 1444 | journal_lock_updates(journal); |
1442 | err = journal_flush(journal); | 1445 | err = journal_flush(journal); |
@@ -1528,6 +1531,7 @@ static int ext3_ordered_writepage(struct page *page, | |||
1528 | int err; | 1531 | int err; |
1529 | 1532 | ||
1530 | J_ASSERT(PageLocked(page)); | 1533 | J_ASSERT(PageLocked(page)); |
1534 | WARN_ON_ONCE(IS_RDONLY(inode)); | ||
1531 | 1535 | ||
1532 | /* | 1536 | /* |
1533 | * We give up here if we're reentered, because it might be for a | 1537 | * We give up here if we're reentered, because it might be for a |
@@ -1600,6 +1604,9 @@ static int ext3_writeback_writepage(struct page *page, | |||
1600 | int ret = 0; | 1604 | int ret = 0; |
1601 | int err; | 1605 | int err; |
1602 | 1606 | ||
1607 | J_ASSERT(PageLocked(page)); | ||
1608 | WARN_ON_ONCE(IS_RDONLY(inode)); | ||
1609 | |||
1603 | if (ext3_journal_current_handle()) | 1610 | if (ext3_journal_current_handle()) |
1604 | goto out_fail; | 1611 | goto out_fail; |
1605 | 1612 | ||
@@ -1642,6 +1649,9 @@ static int ext3_journalled_writepage(struct page *page, | |||
1642 | int ret = 0; | 1649 | int ret = 0; |
1643 | int err; | 1650 | int err; |
1644 | 1651 | ||
1652 | J_ASSERT(PageLocked(page)); | ||
1653 | WARN_ON_ONCE(IS_RDONLY(inode)); | ||
1654 | |||
1645 | if (ext3_journal_current_handle()) | 1655 | if (ext3_journal_current_handle()) |
1646 | goto no_write; | 1656 | goto no_write; |
1647 | 1657 | ||
@@ -1670,7 +1680,7 @@ static int ext3_journalled_writepage(struct page *page, | |||
1670 | PAGE_CACHE_SIZE, NULL, write_end_fn); | 1680 | PAGE_CACHE_SIZE, NULL, write_end_fn); |
1671 | if (ret == 0) | 1681 | if (ret == 0) |
1672 | ret = err; | 1682 | ret = err; |
1673 | EXT3_I(inode)->i_state |= EXT3_STATE_JDATA; | 1683 | ext3_set_inode_state(inode, EXT3_STATE_JDATA); |
1674 | unlock_page(page); | 1684 | unlock_page(page); |
1675 | } else { | 1685 | } else { |
1676 | /* | 1686 | /* |
@@ -1785,8 +1795,9 @@ retry: | |||
1785 | handle = ext3_journal_start(inode, 2); | 1795 | handle = ext3_journal_start(inode, 2); |
1786 | if (IS_ERR(handle)) { | 1796 | if (IS_ERR(handle)) { |
1787 | /* This is really bad luck. We've written the data | 1797 | /* This is really bad luck. We've written the data |
1788 | * but cannot extend i_size. Bail out and pretend | 1798 | * but cannot extend i_size. Truncate allocated blocks |
1789 | * the write failed... */ | 1799 | * and pretend the write failed... */ |
1800 | ext3_truncate(inode); | ||
1790 | ret = PTR_ERR(handle); | 1801 | ret = PTR_ERR(handle); |
1791 | goto out; | 1802 | goto out; |
1792 | } | 1803 | } |
@@ -2402,7 +2413,7 @@ void ext3_truncate(struct inode *inode) | |||
2402 | goto out_notrans; | 2413 | goto out_notrans; |
2403 | 2414 | ||
2404 | if (inode->i_size == 0 && ext3_should_writeback_data(inode)) | 2415 | if (inode->i_size == 0 && ext3_should_writeback_data(inode)) |
2405 | ei->i_state |= EXT3_STATE_FLUSH_ON_CLOSE; | 2416 | ext3_set_inode_state(inode, EXT3_STATE_FLUSH_ON_CLOSE); |
2406 | 2417 | ||
2407 | /* | 2418 | /* |
2408 | * We have to lock the EOF page here, because lock_page() nests | 2419 | * We have to lock the EOF page here, because lock_page() nests |
@@ -2721,7 +2732,7 @@ int ext3_get_inode_loc(struct inode *inode, struct ext3_iloc *iloc) | |||
2721 | { | 2732 | { |
2722 | /* We have all inode data except xattrs in memory here. */ | 2733 | /* We have all inode data except xattrs in memory here. */ |
2723 | return __ext3_get_inode_loc(inode, iloc, | 2734 | return __ext3_get_inode_loc(inode, iloc, |
2724 | !(EXT3_I(inode)->i_state & EXT3_STATE_XATTR)); | 2735 | !ext3_test_inode_state(inode, EXT3_STATE_XATTR)); |
2725 | } | 2736 | } |
2726 | 2737 | ||
2727 | void ext3_set_inode_flags(struct inode *inode) | 2738 | void ext3_set_inode_flags(struct inode *inode) |
@@ -2893,7 +2904,7 @@ struct inode *ext3_iget(struct super_block *sb, unsigned long ino) | |||
2893 | EXT3_GOOD_OLD_INODE_SIZE + | 2904 | EXT3_GOOD_OLD_INODE_SIZE + |
2894 | ei->i_extra_isize; | 2905 | ei->i_extra_isize; |
2895 | if (*magic == cpu_to_le32(EXT3_XATTR_MAGIC)) | 2906 | if (*magic == cpu_to_le32(EXT3_XATTR_MAGIC)) |
2896 | ei->i_state |= EXT3_STATE_XATTR; | 2907 | ext3_set_inode_state(inode, EXT3_STATE_XATTR); |
2897 | } | 2908 | } |
2898 | } else | 2909 | } else |
2899 | ei->i_extra_isize = 0; | 2910 | ei->i_extra_isize = 0; |
@@ -2955,7 +2966,7 @@ again: | |||
2955 | 2966 | ||
2956 | /* For fields not not tracking in the in-memory inode, | 2967 | /* For fields not not tracking in the in-memory inode, |
2957 | * initialise them to zero for new inodes. */ | 2968 | * initialise them to zero for new inodes. */ |
2958 | if (ei->i_state & EXT3_STATE_NEW) | 2969 | if (ext3_test_inode_state(inode, EXT3_STATE_NEW)) |
2959 | memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size); | 2970 | memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size); |
2960 | 2971 | ||
2961 | ext3_get_inode_flags(ei); | 2972 | ext3_get_inode_flags(ei); |
@@ -3052,7 +3063,7 @@ again: | |||
3052 | rc = ext3_journal_dirty_metadata(handle, bh); | 3063 | rc = ext3_journal_dirty_metadata(handle, bh); |
3053 | if (!err) | 3064 | if (!err) |
3054 | err = rc; | 3065 | err = rc; |
3055 | ei->i_state &= ~EXT3_STATE_NEW; | 3066 | ext3_clear_inode_state(inode, EXT3_STATE_NEW); |
3056 | 3067 | ||
3057 | atomic_set(&ei->i_sync_tid, handle->h_transaction->t_tid); | 3068 | atomic_set(&ei->i_sync_tid, handle->h_transaction->t_tid); |
3058 | out_brelse: | 3069 | out_brelse: |
@@ -3140,6 +3151,8 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr) | |||
3140 | if (error) | 3151 | if (error) |
3141 | return error; | 3152 | return error; |
3142 | 3153 | ||
3154 | if (ia_valid & ATTR_SIZE) | ||
3155 | dquot_initialize(inode); | ||
3143 | if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || | 3156 | if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
3144 | (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) { | 3157 | (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) { |
3145 | handle_t *handle; | 3158 | handle_t *handle; |
@@ -3152,7 +3165,7 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr) | |||
3152 | error = PTR_ERR(handle); | 3165 | error = PTR_ERR(handle); |
3153 | goto err_out; | 3166 | goto err_out; |
3154 | } | 3167 | } |
3155 | error = vfs_dq_transfer(inode, attr) ? -EDQUOT : 0; | 3168 | error = dquot_transfer(inode, attr); |
3156 | if (error) { | 3169 | if (error) { |
3157 | ext3_journal_stop(handle); | 3170 | ext3_journal_stop(handle); |
3158 | return error; | 3171 | return error; |
@@ -3237,7 +3250,7 @@ static int ext3_writepage_trans_blocks(struct inode *inode) | |||
3237 | ret = 2 * (bpp + indirects) + 2; | 3250 | ret = 2 * (bpp + indirects) + 2; |
3238 | 3251 | ||
3239 | #ifdef CONFIG_QUOTA | 3252 | #ifdef CONFIG_QUOTA |
3240 | /* We know that structure was already allocated during vfs_dq_init so | 3253 | /* We know that structure was already allocated during dquot_initialize so |
3241 | * we will be updating only the data blocks + inodes */ | 3254 | * we will be updating only the data blocks + inodes */ |
3242 | ret += EXT3_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb); | 3255 | ret += EXT3_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb); |
3243 | #endif | 3256 | #endif |
@@ -3328,7 +3341,7 @@ int ext3_mark_inode_dirty(handle_t *handle, struct inode *inode) | |||
3328 | * i_size has been changed by generic_commit_write() and we thus need | 3341 | * i_size has been changed by generic_commit_write() and we thus need |
3329 | * to include the updated inode in the current transaction. | 3342 | * to include the updated inode in the current transaction. |
3330 | * | 3343 | * |
3331 | * Also, vfs_dq_alloc_space() will always dirty the inode when blocks | 3344 | * Also, dquot_alloc_space() will always dirty the inode when blocks |
3332 | * are allocated to the file. | 3345 | * are allocated to the file. |
3333 | * | 3346 | * |
3334 | * If the inode is marked synchronous, we don't honour that here - doing | 3347 | * If the inode is marked synchronous, we don't honour that here - doing |
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 7b0e44f7d66f..ee184084ca42 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
@@ -1696,6 +1696,8 @@ static int ext3_create (struct inode * dir, struct dentry * dentry, int mode, | |||
1696 | struct inode * inode; | 1696 | struct inode * inode; |
1697 | int err, retries = 0; | 1697 | int err, retries = 0; |
1698 | 1698 | ||
1699 | dquot_initialize(dir); | ||
1700 | |||
1699 | retry: | 1701 | retry: |
1700 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + | 1702 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + |
1701 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1703 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
@@ -1730,6 +1732,8 @@ static int ext3_mknod (struct inode * dir, struct dentry *dentry, | |||
1730 | if (!new_valid_dev(rdev)) | 1732 | if (!new_valid_dev(rdev)) |
1731 | return -EINVAL; | 1733 | return -EINVAL; |
1732 | 1734 | ||
1735 | dquot_initialize(dir); | ||
1736 | |||
1733 | retry: | 1737 | retry: |
1734 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + | 1738 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + |
1735 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1739 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
@@ -1766,6 +1770,8 @@ static int ext3_mkdir(struct inode * dir, struct dentry * dentry, int mode) | |||
1766 | if (dir->i_nlink >= EXT3_LINK_MAX) | 1770 | if (dir->i_nlink >= EXT3_LINK_MAX) |
1767 | return -EMLINK; | 1771 | return -EMLINK; |
1768 | 1772 | ||
1773 | dquot_initialize(dir); | ||
1774 | |||
1769 | retry: | 1775 | retry: |
1770 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + | 1776 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + |
1771 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1777 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
@@ -2060,7 +2066,9 @@ static int ext3_rmdir (struct inode * dir, struct dentry *dentry) | |||
2060 | 2066 | ||
2061 | /* Initialize quotas before so that eventual writes go in | 2067 | /* Initialize quotas before so that eventual writes go in |
2062 | * separate transaction */ | 2068 | * separate transaction */ |
2063 | vfs_dq_init(dentry->d_inode); | 2069 | dquot_initialize(dir); |
2070 | dquot_initialize(dentry->d_inode); | ||
2071 | |||
2064 | handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); | 2072 | handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); |
2065 | if (IS_ERR(handle)) | 2073 | if (IS_ERR(handle)) |
2066 | return PTR_ERR(handle); | 2074 | return PTR_ERR(handle); |
@@ -2119,7 +2127,9 @@ static int ext3_unlink(struct inode * dir, struct dentry *dentry) | |||
2119 | 2127 | ||
2120 | /* Initialize quotas before so that eventual writes go | 2128 | /* Initialize quotas before so that eventual writes go |
2121 | * in separate transaction */ | 2129 | * in separate transaction */ |
2122 | vfs_dq_init(dentry->d_inode); | 2130 | dquot_initialize(dir); |
2131 | dquot_initialize(dentry->d_inode); | ||
2132 | |||
2123 | handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); | 2133 | handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); |
2124 | if (IS_ERR(handle)) | 2134 | if (IS_ERR(handle)) |
2125 | return PTR_ERR(handle); | 2135 | return PTR_ERR(handle); |
@@ -2174,6 +2184,8 @@ static int ext3_symlink (struct inode * dir, | |||
2174 | if (l > dir->i_sb->s_blocksize) | 2184 | if (l > dir->i_sb->s_blocksize) |
2175 | return -ENAMETOOLONG; | 2185 | return -ENAMETOOLONG; |
2176 | 2186 | ||
2187 | dquot_initialize(dir); | ||
2188 | |||
2177 | retry: | 2189 | retry: |
2178 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + | 2190 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + |
2179 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 + | 2191 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 + |
@@ -2228,6 +2240,9 @@ static int ext3_link (struct dentry * old_dentry, | |||
2228 | 2240 | ||
2229 | if (inode->i_nlink >= EXT3_LINK_MAX) | 2241 | if (inode->i_nlink >= EXT3_LINK_MAX) |
2230 | return -EMLINK; | 2242 | return -EMLINK; |
2243 | |||
2244 | dquot_initialize(dir); | ||
2245 | |||
2231 | /* | 2246 | /* |
2232 | * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing | 2247 | * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing |
2233 | * otherwise has the potential to corrupt the orphan inode list. | 2248 | * otherwise has the potential to corrupt the orphan inode list. |
@@ -2278,12 +2293,15 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry, | |||
2278 | struct ext3_dir_entry_2 * old_de, * new_de; | 2293 | struct ext3_dir_entry_2 * old_de, * new_de; |
2279 | int retval, flush_file = 0; | 2294 | int retval, flush_file = 0; |
2280 | 2295 | ||
2296 | dquot_initialize(old_dir); | ||
2297 | dquot_initialize(new_dir); | ||
2298 | |||
2281 | old_bh = new_bh = dir_bh = NULL; | 2299 | old_bh = new_bh = dir_bh = NULL; |
2282 | 2300 | ||
2283 | /* Initialize quotas before so that eventual writes go | 2301 | /* Initialize quotas before so that eventual writes go |
2284 | * in separate transaction */ | 2302 | * in separate transaction */ |
2285 | if (new_dentry->d_inode) | 2303 | if (new_dentry->d_inode) |
2286 | vfs_dq_init(new_dentry->d_inode); | 2304 | dquot_initialize(new_dentry->d_inode); |
2287 | handle = ext3_journal_start(old_dir, 2 * | 2305 | handle = ext3_journal_start(old_dir, 2 * |
2288 | EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) + | 2306 | EXT3_DATA_TRANS_BLOCKS(old_dir->i_sb) + |
2289 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2); | 2307 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 2); |
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index afa2b569da10..e844accbf55d 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -181,7 +181,7 @@ static void ext3_handle_error(struct super_block *sb) | |||
181 | if (!test_opt (sb, ERRORS_CONT)) { | 181 | if (!test_opt (sb, ERRORS_CONT)) { |
182 | journal_t *journal = EXT3_SB(sb)->s_journal; | 182 | journal_t *journal = EXT3_SB(sb)->s_journal; |
183 | 183 | ||
184 | EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; | 184 | set_opt(EXT3_SB(sb)->s_mount_opt, ABORT); |
185 | if (journal) | 185 | if (journal) |
186 | journal_abort(journal, -EIO); | 186 | journal_abort(journal, -EIO); |
187 | } | 187 | } |
@@ -296,7 +296,7 @@ void ext3_abort (struct super_block * sb, const char * function, | |||
296 | "error: remounting filesystem read-only"); | 296 | "error: remounting filesystem read-only"); |
297 | EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; | 297 | EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; |
298 | sb->s_flags |= MS_RDONLY; | 298 | sb->s_flags |= MS_RDONLY; |
299 | EXT3_SB(sb)->s_mount_opt |= EXT3_MOUNT_ABORT; | 299 | set_opt(EXT3_SB(sb)->s_mount_opt, ABORT); |
300 | if (EXT3_SB(sb)->s_journal) | 300 | if (EXT3_SB(sb)->s_journal) |
301 | journal_abort(EXT3_SB(sb)->s_journal, -EIO); | 301 | journal_abort(EXT3_SB(sb)->s_journal, -EIO); |
302 | } | 302 | } |
@@ -528,6 +528,8 @@ static void destroy_inodecache(void) | |||
528 | static void ext3_clear_inode(struct inode *inode) | 528 | static void ext3_clear_inode(struct inode *inode) |
529 | { | 529 | { |
530 | struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info; | 530 | struct ext3_block_alloc_info *rsv = EXT3_I(inode)->i_block_alloc_info; |
531 | |||
532 | dquot_drop(inode); | ||
531 | ext3_discard_reservation(inode); | 533 | ext3_discard_reservation(inode); |
532 | EXT3_I(inode)->i_block_alloc_info = NULL; | 534 | EXT3_I(inode)->i_block_alloc_info = NULL; |
533 | if (unlikely(rsv)) | 535 | if (unlikely(rsv)) |
@@ -562,10 +564,10 @@ static inline void ext3_show_quota_options(struct seq_file *seq, struct super_bl | |||
562 | if (sbi->s_qf_names[GRPQUOTA]) | 564 | if (sbi->s_qf_names[GRPQUOTA]) |
563 | seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]); | 565 | seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]); |
564 | 566 | ||
565 | if (sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA) | 567 | if (test_opt(sb, USRQUOTA)) |
566 | seq_puts(seq, ",usrquota"); | 568 | seq_puts(seq, ",usrquota"); |
567 | 569 | ||
568 | if (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) | 570 | if (test_opt(sb, GRPQUOTA)) |
569 | seq_puts(seq, ",grpquota"); | 571 | seq_puts(seq, ",grpquota"); |
570 | #endif | 572 | #endif |
571 | } | 573 | } |
@@ -656,8 +658,7 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
656 | if (test_opt(sb, NOBH)) | 658 | if (test_opt(sb, NOBH)) |
657 | seq_puts(seq, ",nobh"); | 659 | seq_puts(seq, ",nobh"); |
658 | 660 | ||
659 | seq_printf(seq, ",data=%s", data_mode_string(sbi->s_mount_opt & | 661 | seq_printf(seq, ",data=%s", data_mode_string(test_opt(sb, DATA_FLAGS))); |
660 | EXT3_MOUNT_DATA_FLAGS)); | ||
661 | if (test_opt(sb, DATA_ERR_ABORT)) | 662 | if (test_opt(sb, DATA_ERR_ABORT)) |
662 | seq_puts(seq, ",data_err=abort"); | 663 | seq_puts(seq, ",data_err=abort"); |
663 | 664 | ||
@@ -751,13 +752,6 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type, | |||
751 | const char *data, size_t len, loff_t off); | 752 | const char *data, size_t len, loff_t off); |
752 | 753 | ||
753 | static const struct dquot_operations ext3_quota_operations = { | 754 | static const struct dquot_operations ext3_quota_operations = { |
754 | .initialize = dquot_initialize, | ||
755 | .drop = dquot_drop, | ||
756 | .alloc_space = dquot_alloc_space, | ||
757 | .alloc_inode = dquot_alloc_inode, | ||
758 | .free_space = dquot_free_space, | ||
759 | .free_inode = dquot_free_inode, | ||
760 | .transfer = dquot_transfer, | ||
761 | .write_dquot = ext3_write_dquot, | 755 | .write_dquot = ext3_write_dquot, |
762 | .acquire_dquot = ext3_acquire_dquot, | 756 | .acquire_dquot = ext3_acquire_dquot, |
763 | .release_dquot = ext3_release_dquot, | 757 | .release_dquot = ext3_release_dquot, |
@@ -896,6 +890,63 @@ static ext3_fsblk_t get_sb_block(void **data, struct super_block *sb) | |||
896 | return sb_block; | 890 | return sb_block; |
897 | } | 891 | } |
898 | 892 | ||
893 | #ifdef CONFIG_QUOTA | ||
894 | static int set_qf_name(struct super_block *sb, int qtype, substring_t *args) | ||
895 | { | ||
896 | struct ext3_sb_info *sbi = EXT3_SB(sb); | ||
897 | char *qname; | ||
898 | |||
899 | if (sb_any_quota_loaded(sb) && | ||
900 | !sbi->s_qf_names[qtype]) { | ||
901 | ext3_msg(sb, KERN_ERR, | ||
902 | "Cannot change journaled " | ||
903 | "quota options when quota turned on"); | ||
904 | return 0; | ||
905 | } | ||
906 | qname = match_strdup(args); | ||
907 | if (!qname) { | ||
908 | ext3_msg(sb, KERN_ERR, | ||
909 | "Not enough memory for storing quotafile name"); | ||
910 | return 0; | ||
911 | } | ||
912 | if (sbi->s_qf_names[qtype] && | ||
913 | strcmp(sbi->s_qf_names[qtype], qname)) { | ||
914 | ext3_msg(sb, KERN_ERR, | ||
915 | "%s quota file already specified", QTYPE2NAME(qtype)); | ||
916 | kfree(qname); | ||
917 | return 0; | ||
918 | } | ||
919 | sbi->s_qf_names[qtype] = qname; | ||
920 | if (strchr(sbi->s_qf_names[qtype], '/')) { | ||
921 | ext3_msg(sb, KERN_ERR, | ||
922 | "quotafile must be on filesystem root"); | ||
923 | kfree(sbi->s_qf_names[qtype]); | ||
924 | sbi->s_qf_names[qtype] = NULL; | ||
925 | return 0; | ||
926 | } | ||
927 | set_opt(sbi->s_mount_opt, QUOTA); | ||
928 | return 1; | ||
929 | } | ||
930 | |||
931 | static int clear_qf_name(struct super_block *sb, int qtype) { | ||
932 | |||
933 | struct ext3_sb_info *sbi = EXT3_SB(sb); | ||
934 | |||
935 | if (sb_any_quota_loaded(sb) && | ||
936 | sbi->s_qf_names[qtype]) { | ||
937 | ext3_msg(sb, KERN_ERR, "Cannot change journaled quota options" | ||
938 | " when quota turned on"); | ||
939 | return 0; | ||
940 | } | ||
941 | /* | ||
942 | * The space will be released later when all options are confirmed | ||
943 | * to be correct | ||
944 | */ | ||
945 | sbi->s_qf_names[qtype] = NULL; | ||
946 | return 1; | ||
947 | } | ||
948 | #endif | ||
949 | |||
899 | static int parse_options (char *options, struct super_block *sb, | 950 | static int parse_options (char *options, struct super_block *sb, |
900 | unsigned int *inum, unsigned long *journal_devnum, | 951 | unsigned int *inum, unsigned long *journal_devnum, |
901 | ext3_fsblk_t *n_blocks_count, int is_remount) | 952 | ext3_fsblk_t *n_blocks_count, int is_remount) |
@@ -906,8 +957,7 @@ static int parse_options (char *options, struct super_block *sb, | |||
906 | int data_opt = 0; | 957 | int data_opt = 0; |
907 | int option; | 958 | int option; |
908 | #ifdef CONFIG_QUOTA | 959 | #ifdef CONFIG_QUOTA |
909 | int qtype, qfmt; | 960 | int qfmt; |
910 | char *qname; | ||
911 | #endif | 961 | #endif |
912 | 962 | ||
913 | if (!options) | 963 | if (!options) |
@@ -1065,20 +1115,19 @@ static int parse_options (char *options, struct super_block *sb, | |||
1065 | data_opt = EXT3_MOUNT_WRITEBACK_DATA; | 1115 | data_opt = EXT3_MOUNT_WRITEBACK_DATA; |
1066 | datacheck: | 1116 | datacheck: |
1067 | if (is_remount) { | 1117 | if (is_remount) { |
1068 | if ((sbi->s_mount_opt & EXT3_MOUNT_DATA_FLAGS) | 1118 | if (test_opt(sb, DATA_FLAGS) == data_opt) |
1069 | == data_opt) | ||
1070 | break; | 1119 | break; |
1071 | ext3_msg(sb, KERN_ERR, | 1120 | ext3_msg(sb, KERN_ERR, |
1072 | "error: cannot change " | 1121 | "error: cannot change " |
1073 | "data mode on remount. The filesystem " | 1122 | "data mode on remount. The filesystem " |
1074 | "is mounted in data=%s mode and you " | 1123 | "is mounted in data=%s mode and you " |
1075 | "try to remount it in data=%s mode.", | 1124 | "try to remount it in data=%s mode.", |
1076 | data_mode_string(sbi->s_mount_opt & | 1125 | data_mode_string(test_opt(sb, |
1077 | EXT3_MOUNT_DATA_FLAGS), | 1126 | DATA_FLAGS)), |
1078 | data_mode_string(data_opt)); | 1127 | data_mode_string(data_opt)); |
1079 | return 0; | 1128 | return 0; |
1080 | } else { | 1129 | } else { |
1081 | sbi->s_mount_opt &= ~EXT3_MOUNT_DATA_FLAGS; | 1130 | clear_opt(sbi->s_mount_opt, DATA_FLAGS); |
1082 | sbi->s_mount_opt |= data_opt; | 1131 | sbi->s_mount_opt |= data_opt; |
1083 | } | 1132 | } |
1084 | break; | 1133 | break; |
@@ -1090,62 +1139,20 @@ static int parse_options (char *options, struct super_block *sb, | |||
1090 | break; | 1139 | break; |
1091 | #ifdef CONFIG_QUOTA | 1140 | #ifdef CONFIG_QUOTA |
1092 | case Opt_usrjquota: | 1141 | case Opt_usrjquota: |
1093 | qtype = USRQUOTA; | 1142 | if (!set_qf_name(sb, USRQUOTA, &args[0])) |
1094 | goto set_qf_name; | ||
1095 | case Opt_grpjquota: | ||
1096 | qtype = GRPQUOTA; | ||
1097 | set_qf_name: | ||
1098 | if (sb_any_quota_loaded(sb) && | ||
1099 | !sbi->s_qf_names[qtype]) { | ||
1100 | ext3_msg(sb, KERN_ERR, | ||
1101 | "error: cannot change journaled " | ||
1102 | "quota options when quota turned on."); | ||
1103 | return 0; | ||
1104 | } | ||
1105 | qname = match_strdup(&args[0]); | ||
1106 | if (!qname) { | ||
1107 | ext3_msg(sb, KERN_ERR, | ||
1108 | "error: not enough memory for " | ||
1109 | "storing quotafile name."); | ||
1110 | return 0; | 1143 | return 0; |
1111 | } | 1144 | break; |
1112 | if (sbi->s_qf_names[qtype] && | 1145 | case Opt_grpjquota: |
1113 | strcmp(sbi->s_qf_names[qtype], qname)) { | 1146 | if (!set_qf_name(sb, GRPQUOTA, &args[0])) |
1114 | ext3_msg(sb, KERN_ERR, | ||
1115 | "error: %s quota file already " | ||
1116 | "specified.", QTYPE2NAME(qtype)); | ||
1117 | kfree(qname); | ||
1118 | return 0; | ||
1119 | } | ||
1120 | sbi->s_qf_names[qtype] = qname; | ||
1121 | if (strchr(sbi->s_qf_names[qtype], '/')) { | ||
1122 | ext3_msg(sb, KERN_ERR, | ||
1123 | "error: quotafile must be on " | ||
1124 | "filesystem root."); | ||
1125 | kfree(sbi->s_qf_names[qtype]); | ||
1126 | sbi->s_qf_names[qtype] = NULL; | ||
1127 | return 0; | 1147 | return 0; |
1128 | } | ||
1129 | set_opt(sbi->s_mount_opt, QUOTA); | ||
1130 | break; | 1148 | break; |
1131 | case Opt_offusrjquota: | 1149 | case Opt_offusrjquota: |
1132 | qtype = USRQUOTA; | 1150 | if (!clear_qf_name(sb, USRQUOTA)) |
1133 | goto clear_qf_name; | 1151 | return 0; |
1152 | break; | ||
1134 | case Opt_offgrpjquota: | 1153 | case Opt_offgrpjquota: |
1135 | qtype = GRPQUOTA; | 1154 | if (!clear_qf_name(sb, GRPQUOTA)) |
1136 | clear_qf_name: | ||
1137 | if (sb_any_quota_loaded(sb) && | ||
1138 | sbi->s_qf_names[qtype]) { | ||
1139 | ext3_msg(sb, KERN_ERR, "error: cannot change " | ||
1140 | "journaled quota options when " | ||
1141 | "quota turned on."); | ||
1142 | return 0; | 1155 | return 0; |
1143 | } | ||
1144 | /* | ||
1145 | * The space will be released later when all options | ||
1146 | * are confirmed to be correct | ||
1147 | */ | ||
1148 | sbi->s_qf_names[qtype] = NULL; | ||
1149 | break; | 1156 | break; |
1150 | case Opt_jqfmt_vfsold: | 1157 | case Opt_jqfmt_vfsold: |
1151 | qfmt = QFMT_VFS_OLD; | 1158 | qfmt = QFMT_VFS_OLD; |
@@ -1244,18 +1251,12 @@ set_qf_format: | |||
1244 | } | 1251 | } |
1245 | #ifdef CONFIG_QUOTA | 1252 | #ifdef CONFIG_QUOTA |
1246 | if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { | 1253 | if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { |
1247 | if ((sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA) && | 1254 | if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA]) |
1248 | sbi->s_qf_names[USRQUOTA]) | ||
1249 | clear_opt(sbi->s_mount_opt, USRQUOTA); | 1255 | clear_opt(sbi->s_mount_opt, USRQUOTA); |
1250 | 1256 | if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA]) | |
1251 | if ((sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA) && | ||
1252 | sbi->s_qf_names[GRPQUOTA]) | ||
1253 | clear_opt(sbi->s_mount_opt, GRPQUOTA); | 1257 | clear_opt(sbi->s_mount_opt, GRPQUOTA); |
1254 | 1258 | ||
1255 | if ((sbi->s_qf_names[USRQUOTA] && | 1259 | if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) { |
1256 | (sbi->s_mount_opt & EXT3_MOUNT_GRPQUOTA)) || | ||
1257 | (sbi->s_qf_names[GRPQUOTA] && | ||
1258 | (sbi->s_mount_opt & EXT3_MOUNT_USRQUOTA))) { | ||
1259 | ext3_msg(sb, KERN_ERR, "error: old and new quota " | 1260 | ext3_msg(sb, KERN_ERR, "error: old and new quota " |
1260 | "format mixing."); | 1261 | "format mixing."); |
1261 | return 0; | 1262 | return 0; |
@@ -1478,7 +1479,7 @@ static void ext3_orphan_cleanup (struct super_block * sb, | |||
1478 | } | 1479 | } |
1479 | 1480 | ||
1480 | list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan); | 1481 | list_add(&EXT3_I(inode)->i_orphan, &EXT3_SB(sb)->s_orphan); |
1481 | vfs_dq_init(inode); | 1482 | dquot_initialize(inode); |
1482 | if (inode->i_nlink) { | 1483 | if (inode->i_nlink) { |
1483 | printk(KERN_DEBUG | 1484 | printk(KERN_DEBUG |
1484 | "%s: truncating inode %lu to %Ld bytes\n", | 1485 | "%s: truncating inode %lu to %Ld bytes\n", |
@@ -1671,11 +1672,11 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1671 | set_opt(sbi->s_mount_opt, POSIX_ACL); | 1672 | set_opt(sbi->s_mount_opt, POSIX_ACL); |
1672 | #endif | 1673 | #endif |
1673 | if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_DATA) | 1674 | if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_DATA) |
1674 | sbi->s_mount_opt |= EXT3_MOUNT_JOURNAL_DATA; | 1675 | set_opt(sbi->s_mount_opt, JOURNAL_DATA); |
1675 | else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_ORDERED) | 1676 | else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_ORDERED) |
1676 | sbi->s_mount_opt |= EXT3_MOUNT_ORDERED_DATA; | 1677 | set_opt(sbi->s_mount_opt, ORDERED_DATA); |
1677 | else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_WBACK) | 1678 | else if ((def_mount_opts & EXT3_DEFM_JMODE) == EXT3_DEFM_JMODE_WBACK) |
1678 | sbi->s_mount_opt |= EXT3_MOUNT_WRITEBACK_DATA; | 1679 | set_opt(sbi->s_mount_opt, WRITEBACK_DATA); |
1679 | 1680 | ||
1680 | if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_PANIC) | 1681 | if (le16_to_cpu(sbi->s_es->s_errors) == EXT3_ERRORS_PANIC) |
1681 | set_opt(sbi->s_mount_opt, ERRORS_PANIC); | 1682 | set_opt(sbi->s_mount_opt, ERRORS_PANIC); |
@@ -1694,7 +1695,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1694 | goto failed_mount; | 1695 | goto failed_mount; |
1695 | 1696 | ||
1696 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | | 1697 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | |
1697 | ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); | 1698 | (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0); |
1698 | 1699 | ||
1699 | if (le32_to_cpu(es->s_rev_level) == EXT3_GOOD_OLD_REV && | 1700 | if (le32_to_cpu(es->s_rev_level) == EXT3_GOOD_OLD_REV && |
1700 | (EXT3_HAS_COMPAT_FEATURE(sb, ~0U) || | 1701 | (EXT3_HAS_COMPAT_FEATURE(sb, ~0U) || |
@@ -2561,11 +2562,11 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data) | |||
2561 | goto restore_opts; | 2562 | goto restore_opts; |
2562 | } | 2563 | } |
2563 | 2564 | ||
2564 | if (sbi->s_mount_opt & EXT3_MOUNT_ABORT) | 2565 | if (test_opt(sb, ABORT)) |
2565 | ext3_abort(sb, __func__, "Abort forced by user"); | 2566 | ext3_abort(sb, __func__, "Abort forced by user"); |
2566 | 2567 | ||
2567 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | | 2568 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | |
2568 | ((sbi->s_mount_opt & EXT3_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); | 2569 | (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0); |
2569 | 2570 | ||
2570 | es = sbi->s_es; | 2571 | es = sbi->s_es; |
2571 | 2572 | ||
@@ -2573,7 +2574,7 @@ static int ext3_remount (struct super_block * sb, int * flags, char * data) | |||
2573 | 2574 | ||
2574 | if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) || | 2575 | if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) || |
2575 | n_blocks_count > le32_to_cpu(es->s_blocks_count)) { | 2576 | n_blocks_count > le32_to_cpu(es->s_blocks_count)) { |
2576 | if (sbi->s_mount_opt & EXT3_MOUNT_ABORT) { | 2577 | if (test_opt(sb, ABORT)) { |
2577 | err = -EROFS; | 2578 | err = -EROFS; |
2578 | goto restore_opts; | 2579 | goto restore_opts; |
2579 | } | 2580 | } |
@@ -2734,7 +2735,7 @@ static int ext3_statfs (struct dentry * dentry, struct kstatfs * buf) | |||
2734 | * Process 1 Process 2 | 2735 | * Process 1 Process 2 |
2735 | * ext3_create() quota_sync() | 2736 | * ext3_create() quota_sync() |
2736 | * journal_start() write_dquot() | 2737 | * journal_start() write_dquot() |
2737 | * vfs_dq_init() down(dqio_mutex) | 2738 | * dquot_initialize() down(dqio_mutex) |
2738 | * down(dqio_mutex) journal_start() | 2739 | * down(dqio_mutex) journal_start() |
2739 | * | 2740 | * |
2740 | */ | 2741 | */ |
@@ -2942,9 +2943,7 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type, | |||
2942 | sector_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb); | 2943 | sector_t blk = off >> EXT3_BLOCK_SIZE_BITS(sb); |
2943 | int err = 0; | 2944 | int err = 0; |
2944 | int offset = off & (sb->s_blocksize - 1); | 2945 | int offset = off & (sb->s_blocksize - 1); |
2945 | int tocopy; | ||
2946 | int journal_quota = EXT3_SB(sb)->s_qf_names[type] != NULL; | 2946 | int journal_quota = EXT3_SB(sb)->s_qf_names[type] != NULL; |
2947 | size_t towrite = len; | ||
2948 | struct buffer_head *bh; | 2947 | struct buffer_head *bh; |
2949 | handle_t *handle = journal_current_handle(); | 2948 | handle_t *handle = journal_current_handle(); |
2950 | 2949 | ||
@@ -2955,53 +2954,54 @@ static ssize_t ext3_quota_write(struct super_block *sb, int type, | |||
2955 | (unsigned long long)off, (unsigned long long)len); | 2954 | (unsigned long long)off, (unsigned long long)len); |
2956 | return -EIO; | 2955 | return -EIO; |
2957 | } | 2956 | } |
2957 | |||
2958 | /* | ||
2959 | * Since we account only one data block in transaction credits, | ||
2960 | * then it is impossible to cross a block boundary. | ||
2961 | */ | ||
2962 | if (sb->s_blocksize - offset < len) { | ||
2963 | ext3_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" | ||
2964 | " cancelled because not block aligned", | ||
2965 | (unsigned long long)off, (unsigned long long)len); | ||
2966 | return -EIO; | ||
2967 | } | ||
2958 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); | 2968 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); |
2959 | while (towrite > 0) { | 2969 | bh = ext3_bread(handle, inode, blk, 1, &err); |
2960 | tocopy = sb->s_blocksize - offset < towrite ? | 2970 | if (!bh) |
2961 | sb->s_blocksize - offset : towrite; | 2971 | goto out; |
2962 | bh = ext3_bread(handle, inode, blk, 1, &err); | 2972 | if (journal_quota) { |
2963 | if (!bh) | 2973 | err = ext3_journal_get_write_access(handle, bh); |
2974 | if (err) { | ||
2975 | brelse(bh); | ||
2964 | goto out; | 2976 | goto out; |
2965 | if (journal_quota) { | ||
2966 | err = ext3_journal_get_write_access(handle, bh); | ||
2967 | if (err) { | ||
2968 | brelse(bh); | ||
2969 | goto out; | ||
2970 | } | ||
2971 | } | ||
2972 | lock_buffer(bh); | ||
2973 | memcpy(bh->b_data+offset, data, tocopy); | ||
2974 | flush_dcache_page(bh->b_page); | ||
2975 | unlock_buffer(bh); | ||
2976 | if (journal_quota) | ||
2977 | err = ext3_journal_dirty_metadata(handle, bh); | ||
2978 | else { | ||
2979 | /* Always do at least ordered writes for quotas */ | ||
2980 | err = ext3_journal_dirty_data(handle, bh); | ||
2981 | mark_buffer_dirty(bh); | ||
2982 | } | 2977 | } |
2983 | brelse(bh); | ||
2984 | if (err) | ||
2985 | goto out; | ||
2986 | offset = 0; | ||
2987 | towrite -= tocopy; | ||
2988 | data += tocopy; | ||
2989 | blk++; | ||
2990 | } | 2978 | } |
2979 | lock_buffer(bh); | ||
2980 | memcpy(bh->b_data+offset, data, len); | ||
2981 | flush_dcache_page(bh->b_page); | ||
2982 | unlock_buffer(bh); | ||
2983 | if (journal_quota) | ||
2984 | err = ext3_journal_dirty_metadata(handle, bh); | ||
2985 | else { | ||
2986 | /* Always do at least ordered writes for quotas */ | ||
2987 | err = ext3_journal_dirty_data(handle, bh); | ||
2988 | mark_buffer_dirty(bh); | ||
2989 | } | ||
2990 | brelse(bh); | ||
2991 | out: | 2991 | out: |
2992 | if (len == towrite) { | 2992 | if (err) { |
2993 | mutex_unlock(&inode->i_mutex); | 2993 | mutex_unlock(&inode->i_mutex); |
2994 | return err; | 2994 | return err; |
2995 | } | 2995 | } |
2996 | if (inode->i_size < off+len-towrite) { | 2996 | if (inode->i_size < off + len) { |
2997 | i_size_write(inode, off+len-towrite); | 2997 | i_size_write(inode, off + len); |
2998 | EXT3_I(inode)->i_disksize = inode->i_size; | 2998 | EXT3_I(inode)->i_disksize = inode->i_size; |
2999 | } | 2999 | } |
3000 | inode->i_version++; | 3000 | inode->i_version++; |
3001 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 3001 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
3002 | ext3_mark_inode_dirty(handle, inode); | 3002 | ext3_mark_inode_dirty(handle, inode); |
3003 | mutex_unlock(&inode->i_mutex); | 3003 | mutex_unlock(&inode->i_mutex); |
3004 | return len - towrite; | 3004 | return len; |
3005 | } | 3005 | } |
3006 | 3006 | ||
3007 | #endif | 3007 | #endif |
diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c index 66895ccf76c7..534a94c3a933 100644 --- a/fs/ext3/xattr.c +++ b/fs/ext3/xattr.c | |||
@@ -274,7 +274,7 @@ ext3_xattr_ibody_get(struct inode *inode, int name_index, const char *name, | |||
274 | void *end; | 274 | void *end; |
275 | int error; | 275 | int error; |
276 | 276 | ||
277 | if (!(EXT3_I(inode)->i_state & EXT3_STATE_XATTR)) | 277 | if (!ext3_test_inode_state(inode, EXT3_STATE_XATTR)) |
278 | return -ENODATA; | 278 | return -ENODATA; |
279 | error = ext3_get_inode_loc(inode, &iloc); | 279 | error = ext3_get_inode_loc(inode, &iloc); |
280 | if (error) | 280 | if (error) |
@@ -403,7 +403,7 @@ ext3_xattr_ibody_list(struct dentry *dentry, char *buffer, size_t buffer_size) | |||
403 | void *end; | 403 | void *end; |
404 | int error; | 404 | int error; |
405 | 405 | ||
406 | if (!(EXT3_I(inode)->i_state & EXT3_STATE_XATTR)) | 406 | if (!ext3_test_inode_state(inode, EXT3_STATE_XATTR)) |
407 | return 0; | 407 | return 0; |
408 | error = ext3_get_inode_loc(inode, &iloc); | 408 | error = ext3_get_inode_loc(inode, &iloc); |
409 | if (error) | 409 | if (error) |
@@ -500,7 +500,7 @@ ext3_xattr_release_block(handle_t *handle, struct inode *inode, | |||
500 | error = ext3_journal_dirty_metadata(handle, bh); | 500 | error = ext3_journal_dirty_metadata(handle, bh); |
501 | if (IS_SYNC(inode)) | 501 | if (IS_SYNC(inode)) |
502 | handle->h_sync = 1; | 502 | handle->h_sync = 1; |
503 | vfs_dq_free_block(inode, 1); | 503 | dquot_free_block(inode, 1); |
504 | ea_bdebug(bh, "refcount now=%d; releasing", | 504 | ea_bdebug(bh, "refcount now=%d; releasing", |
505 | le32_to_cpu(BHDR(bh)->h_refcount)); | 505 | le32_to_cpu(BHDR(bh)->h_refcount)); |
506 | if (ce) | 506 | if (ce) |
@@ -775,8 +775,8 @@ inserted: | |||
775 | else { | 775 | else { |
776 | /* The old block is released after updating | 776 | /* The old block is released after updating |
777 | the inode. */ | 777 | the inode. */ |
778 | error = -EDQUOT; | 778 | error = dquot_alloc_block(inode, 1); |
779 | if (vfs_dq_alloc_block(inode, 1)) | 779 | if (error) |
780 | goto cleanup; | 780 | goto cleanup; |
781 | error = ext3_journal_get_write_access(handle, | 781 | error = ext3_journal_get_write_access(handle, |
782 | new_bh); | 782 | new_bh); |
@@ -850,7 +850,7 @@ cleanup: | |||
850 | return error; | 850 | return error; |
851 | 851 | ||
852 | cleanup_dquot: | 852 | cleanup_dquot: |
853 | vfs_dq_free_block(inode, 1); | 853 | dquot_free_block(inode, 1); |
854 | goto cleanup; | 854 | goto cleanup; |
855 | 855 | ||
856 | bad_block: | 856 | bad_block: |
@@ -882,7 +882,7 @@ ext3_xattr_ibody_find(struct inode *inode, struct ext3_xattr_info *i, | |||
882 | is->s.base = is->s.first = IFIRST(header); | 882 | is->s.base = is->s.first = IFIRST(header); |
883 | is->s.here = is->s.first; | 883 | is->s.here = is->s.first; |
884 | is->s.end = (void *)raw_inode + EXT3_SB(inode->i_sb)->s_inode_size; | 884 | is->s.end = (void *)raw_inode + EXT3_SB(inode->i_sb)->s_inode_size; |
885 | if (EXT3_I(inode)->i_state & EXT3_STATE_XATTR) { | 885 | if (ext3_test_inode_state(inode, EXT3_STATE_XATTR)) { |
886 | error = ext3_xattr_check_names(IFIRST(header), is->s.end); | 886 | error = ext3_xattr_check_names(IFIRST(header), is->s.end); |
887 | if (error) | 887 | if (error) |
888 | return error; | 888 | return error; |
@@ -914,10 +914,10 @@ ext3_xattr_ibody_set(handle_t *handle, struct inode *inode, | |||
914 | header = IHDR(inode, ext3_raw_inode(&is->iloc)); | 914 | header = IHDR(inode, ext3_raw_inode(&is->iloc)); |
915 | if (!IS_LAST_ENTRY(s->first)) { | 915 | if (!IS_LAST_ENTRY(s->first)) { |
916 | header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC); | 916 | header->h_magic = cpu_to_le32(EXT3_XATTR_MAGIC); |
917 | EXT3_I(inode)->i_state |= EXT3_STATE_XATTR; | 917 | ext3_set_inode_state(inode, EXT3_STATE_XATTR); |
918 | } else { | 918 | } else { |
919 | header->h_magic = cpu_to_le32(0); | 919 | header->h_magic = cpu_to_le32(0); |
920 | EXT3_I(inode)->i_state &= ~EXT3_STATE_XATTR; | 920 | ext3_clear_inode_state(inode, EXT3_STATE_XATTR); |
921 | } | 921 | } |
922 | return 0; | 922 | return 0; |
923 | } | 923 | } |
@@ -967,10 +967,10 @@ ext3_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, | |||
967 | if (error) | 967 | if (error) |
968 | goto cleanup; | 968 | goto cleanup; |
969 | 969 | ||
970 | if (EXT3_I(inode)->i_state & EXT3_STATE_NEW) { | 970 | if (ext3_test_inode_state(inode, EXT3_STATE_NEW)) { |
971 | struct ext3_inode *raw_inode = ext3_raw_inode(&is.iloc); | 971 | struct ext3_inode *raw_inode = ext3_raw_inode(&is.iloc); |
972 | memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size); | 972 | memset(raw_inode, 0, EXT3_SB(inode->i_sb)->s_inode_size); |
973 | EXT3_I(inode)->i_state &= ~EXT3_STATE_NEW; | 973 | ext3_clear_inode_state(inode, EXT3_STATE_NEW); |
974 | } | 974 | } |
975 | 975 | ||
976 | error = ext3_xattr_ibody_find(inode, &i, &is); | 976 | error = ext3_xattr_ibody_find(inode, &i, &is); |