diff options
Diffstat (limited to 'fs/reiserfs/inode.c')
-rw-r--r-- | fs/reiserfs/inode.c | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index 290ae38fca8a..dc2c65e04853 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/smp_lock.h> | 11 | #include <linux/smp_lock.h> |
12 | #include <linux/pagemap.h> | 12 | #include <linux/pagemap.h> |
13 | #include <linux/highmem.h> | 13 | #include <linux/highmem.h> |
14 | #include <linux/slab.h> | ||
14 | #include <asm/uaccess.h> | 15 | #include <asm/uaccess.h> |
15 | #include <asm/unaligned.h> | 16 | #include <asm/unaligned.h> |
16 | #include <linux/buffer_head.h> | 17 | #include <linux/buffer_head.h> |
@@ -31,11 +32,15 @@ void reiserfs_delete_inode(struct inode *inode) | |||
31 | JOURNAL_PER_BALANCE_CNT * 2 + | 32 | JOURNAL_PER_BALANCE_CNT * 2 + |
32 | 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb); | 33 | 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb); |
33 | struct reiserfs_transaction_handle th; | 34 | struct reiserfs_transaction_handle th; |
35 | int depth; | ||
34 | int err; | 36 | int err; |
35 | 37 | ||
38 | if (!is_bad_inode(inode)) | ||
39 | dquot_initialize(inode); | ||
40 | |||
36 | truncate_inode_pages(&inode->i_data, 0); | 41 | truncate_inode_pages(&inode->i_data, 0); |
37 | 42 | ||
38 | reiserfs_write_lock(inode->i_sb); | 43 | depth = reiserfs_write_lock_once(inode->i_sb); |
39 | 44 | ||
40 | /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */ | 45 | /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */ |
41 | if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) { /* also handles bad_inode case */ | 46 | if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) { /* also handles bad_inode case */ |
@@ -53,7 +58,7 @@ void reiserfs_delete_inode(struct inode *inode) | |||
53 | * after delete_object so that quota updates go into the same transaction as | 58 | * after delete_object so that quota updates go into the same transaction as |
54 | * stat data deletion */ | 59 | * stat data deletion */ |
55 | if (!err) | 60 | if (!err) |
56 | vfs_dq_free_inode(inode); | 61 | dquot_free_inode(inode); |
57 | 62 | ||
58 | if (journal_end(&th, inode->i_sb, jbegin_count)) | 63 | if (journal_end(&th, inode->i_sb, jbegin_count)) |
59 | goto out; | 64 | goto out; |
@@ -74,7 +79,7 @@ void reiserfs_delete_inode(struct inode *inode) | |||
74 | out: | 79 | out: |
75 | clear_inode(inode); /* note this must go after the journal_end to prevent deadlock */ | 80 | clear_inode(inode); /* note this must go after the journal_end to prevent deadlock */ |
76 | inode->i_blocks = 0; | 81 | inode->i_blocks = 0; |
77 | reiserfs_write_unlock(inode->i_sb); | 82 | reiserfs_write_unlock_once(inode->i_sb, depth); |
78 | } | 83 | } |
79 | 84 | ||
80 | static void _make_cpu_key(struct cpu_key *key, int version, __u32 dirid, | 85 | static void _make_cpu_key(struct cpu_key *key, int version, __u32 dirid, |
@@ -1496,9 +1501,11 @@ struct inode *reiserfs_iget(struct super_block *s, const struct cpu_key *key) | |||
1496 | 1501 | ||
1497 | args.objectid = key->on_disk_key.k_objectid; | 1502 | args.objectid = key->on_disk_key.k_objectid; |
1498 | args.dirid = key->on_disk_key.k_dir_id; | 1503 | args.dirid = key->on_disk_key.k_dir_id; |
1504 | reiserfs_write_unlock(s); | ||
1499 | inode = iget5_locked(s, key->on_disk_key.k_objectid, | 1505 | inode = iget5_locked(s, key->on_disk_key.k_objectid, |
1500 | reiserfs_find_actor, reiserfs_init_locked_inode, | 1506 | reiserfs_find_actor, reiserfs_init_locked_inode, |
1501 | (void *)(&args)); | 1507 | (void *)(&args)); |
1508 | reiserfs_write_lock(s); | ||
1502 | if (!inode) | 1509 | if (!inode) |
1503 | return ERR_PTR(-ENOMEM); | 1510 | return ERR_PTR(-ENOMEM); |
1504 | 1511 | ||
@@ -1612,7 +1619,7 @@ int reiserfs_encode_fh(struct dentry *dentry, __u32 * data, int *lenp, | |||
1612 | ** to properly mark inodes for datasync and such, but only actually | 1619 | ** to properly mark inodes for datasync and such, but only actually |
1613 | ** does something when called for a synchronous update. | 1620 | ** does something when called for a synchronous update. |
1614 | */ | 1621 | */ |
1615 | int reiserfs_write_inode(struct inode *inode, int do_sync) | 1622 | int reiserfs_write_inode(struct inode *inode, struct writeback_control *wbc) |
1616 | { | 1623 | { |
1617 | struct reiserfs_transaction_handle th; | 1624 | struct reiserfs_transaction_handle th; |
1618 | int jbegin_count = 1; | 1625 | int jbegin_count = 1; |
@@ -1624,7 +1631,7 @@ int reiserfs_write_inode(struct inode *inode, int do_sync) | |||
1624 | ** inode needs to reach disk for safety, and they can safely be | 1631 | ** inode needs to reach disk for safety, and they can safely be |
1625 | ** ignored because the altered inode has already been logged. | 1632 | ** ignored because the altered inode has already been logged. |
1626 | */ | 1633 | */ |
1627 | if (do_sync && !(current->flags & PF_MEMALLOC)) { | 1634 | if (wbc->sync_mode == WB_SYNC_ALL && !(current->flags & PF_MEMALLOC)) { |
1628 | reiserfs_write_lock(inode->i_sb); | 1635 | reiserfs_write_lock(inode->i_sb); |
1629 | if (!journal_begin(&th, inode->i_sb, jbegin_count)) { | 1636 | if (!journal_begin(&th, inode->i_sb, jbegin_count)) { |
1630 | reiserfs_update_sd(&th, inode); | 1637 | reiserfs_update_sd(&th, inode); |
@@ -1762,10 +1769,10 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, | |||
1762 | 1769 | ||
1763 | BUG_ON(!th->t_trans_id); | 1770 | BUG_ON(!th->t_trans_id); |
1764 | 1771 | ||
1765 | if (vfs_dq_alloc_inode(inode)) { | 1772 | dquot_initialize(inode); |
1766 | err = -EDQUOT; | 1773 | err = dquot_alloc_inode(inode); |
1774 | if (err) | ||
1767 | goto out_end_trans; | 1775 | goto out_end_trans; |
1768 | } | ||
1769 | if (!dir->i_nlink) { | 1776 | if (!dir->i_nlink) { |
1770 | err = -EPERM; | 1777 | err = -EPERM; |
1771 | goto out_bad_inode; | 1778 | goto out_bad_inode; |
@@ -1956,12 +1963,12 @@ int reiserfs_new_inode(struct reiserfs_transaction_handle *th, | |||
1956 | INODE_PKEY(inode)->k_objectid = 0; | 1963 | INODE_PKEY(inode)->k_objectid = 0; |
1957 | 1964 | ||
1958 | /* Quota change must be inside a transaction for journaling */ | 1965 | /* Quota change must be inside a transaction for journaling */ |
1959 | vfs_dq_free_inode(inode); | 1966 | dquot_free_inode(inode); |
1960 | 1967 | ||
1961 | out_end_trans: | 1968 | out_end_trans: |
1962 | journal_end(th, th->t_super, th->t_blocks_allocated); | 1969 | journal_end(th, th->t_super, th->t_blocks_allocated); |
1963 | /* Drop can be outside and it needs more credits so it's better to have it outside */ | 1970 | /* Drop can be outside and it needs more credits so it's better to have it outside */ |
1964 | vfs_dq_drop(inode); | 1971 | dquot_drop(inode); |
1965 | inode->i_flags |= S_NOQUOTA; | 1972 | inode->i_flags |= S_NOQUOTA; |
1966 | make_bad_inode(inode); | 1973 | make_bad_inode(inode); |
1967 | 1974 | ||
@@ -3061,14 +3068,17 @@ static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb, | |||
3061 | int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) | 3068 | int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) |
3062 | { | 3069 | { |
3063 | struct inode *inode = dentry->d_inode; | 3070 | struct inode *inode = dentry->d_inode; |
3064 | int error; | ||
3065 | unsigned int ia_valid; | 3071 | unsigned int ia_valid; |
3072 | int depth; | ||
3073 | int error; | ||
3066 | 3074 | ||
3067 | /* must be turned off for recursive notify_change calls */ | 3075 | /* must be turned off for recursive notify_change calls */ |
3068 | ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID); | 3076 | ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID); |
3069 | 3077 | ||
3070 | reiserfs_write_lock(inode->i_sb); | 3078 | depth = reiserfs_write_lock_once(inode->i_sb); |
3071 | if (attr->ia_valid & ATTR_SIZE) { | 3079 | if (attr->ia_valid & ATTR_SIZE) { |
3080 | dquot_initialize(inode); | ||
3081 | |||
3072 | /* version 2 items will be caught by the s_maxbytes check | 3082 | /* version 2 items will be caught by the s_maxbytes check |
3073 | ** done for us in vmtruncate | 3083 | ** done for us in vmtruncate |
3074 | */ | 3084 | */ |
@@ -3130,8 +3140,7 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
3130 | jbegin_count); | 3140 | jbegin_count); |
3131 | if (error) | 3141 | if (error) |
3132 | goto out; | 3142 | goto out; |
3133 | error = | 3143 | error = dquot_transfer(inode, attr); |
3134 | vfs_dq_transfer(inode, attr) ? -EDQUOT : 0; | ||
3135 | if (error) { | 3144 | if (error) { |
3136 | journal_end(&th, inode->i_sb, | 3145 | journal_end(&th, inode->i_sb, |
3137 | jbegin_count); | 3146 | jbegin_count); |
@@ -3148,8 +3157,17 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
3148 | journal_end(&th, inode->i_sb, jbegin_count); | 3157 | journal_end(&th, inode->i_sb, jbegin_count); |
3149 | } | 3158 | } |
3150 | } | 3159 | } |
3151 | if (!error) | 3160 | if (!error) { |
3161 | /* | ||
3162 | * Relax the lock here, as it might truncate the | ||
3163 | * inode pages and wait for inode pages locks. | ||
3164 | * To release such page lock, the owner needs the | ||
3165 | * reiserfs lock | ||
3166 | */ | ||
3167 | reiserfs_write_unlock_once(inode->i_sb, depth); | ||
3152 | error = inode_setattr(inode, attr); | 3168 | error = inode_setattr(inode, attr); |
3169 | depth = reiserfs_write_lock_once(inode->i_sb); | ||
3170 | } | ||
3153 | } | 3171 | } |
3154 | 3172 | ||
3155 | if (!error && reiserfs_posixacl(inode->i_sb)) { | 3173 | if (!error && reiserfs_posixacl(inode->i_sb)) { |
@@ -3158,7 +3176,8 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
3158 | } | 3176 | } |
3159 | 3177 | ||
3160 | out: | 3178 | out: |
3161 | reiserfs_write_unlock(inode->i_sb); | 3179 | reiserfs_write_unlock_once(inode->i_sb, depth); |
3180 | |||
3162 | return error; | 3181 | return error; |
3163 | } | 3182 | } |
3164 | 3183 | ||