diff options
author | Ingo Molnar <mingo@elte.hu> | 2010-01-13 03:58:37 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-01-13 04:08:50 -0500 |
commit | 61405fea92c42d072d9b8bd189689f1502a838af (patch) | |
tree | 013ea3e7ed71f4114004d5852d40b6e89e128f76 /fs/reiserfs/inode.c | |
parent | 9c443dfdd31eddea6cbe6ee0ca469fbcc4e1dc3b (diff) | |
parent | 1703f2c321a8a531c393e137a82602e16c6061cb (diff) |
Merge branch 'perf/urgent' into perf/core
Merge reason: queue up dependent patch, update to -rc4
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs/reiserfs/inode.c')
-rw-r--r-- | fs/reiserfs/inode.c | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index 3a28e7751b3c..9087b10209e6 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
@@ -31,11 +31,12 @@ void reiserfs_delete_inode(struct inode *inode) | |||
31 | JOURNAL_PER_BALANCE_CNT * 2 + | 31 | JOURNAL_PER_BALANCE_CNT * 2 + |
32 | 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb); | 32 | 2 * REISERFS_QUOTA_INIT_BLOCKS(inode->i_sb); |
33 | struct reiserfs_transaction_handle th; | 33 | struct reiserfs_transaction_handle th; |
34 | int depth; | ||
34 | int err; | 35 | int err; |
35 | 36 | ||
36 | truncate_inode_pages(&inode->i_data, 0); | 37 | truncate_inode_pages(&inode->i_data, 0); |
37 | 38 | ||
38 | reiserfs_write_lock(inode->i_sb); | 39 | depth = reiserfs_write_lock_once(inode->i_sb); |
39 | 40 | ||
40 | /* The = 0 happens when we abort creating a new inode for some reason like lack of space.. */ | 41 | /* 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 */ | 42 | if (!(inode->i_state & I_NEW) && INODE_PKEY(inode)->k_objectid != 0) { /* also handles bad_inode case */ |
@@ -74,7 +75,7 @@ void reiserfs_delete_inode(struct inode *inode) | |||
74 | out: | 75 | out: |
75 | clear_inode(inode); /* note this must go after the journal_end to prevent deadlock */ | 76 | clear_inode(inode); /* note this must go after the journal_end to prevent deadlock */ |
76 | inode->i_blocks = 0; | 77 | inode->i_blocks = 0; |
77 | reiserfs_write_unlock(inode->i_sb); | 78 | reiserfs_write_unlock_once(inode->i_sb, depth); |
78 | } | 79 | } |
79 | 80 | ||
80 | static void _make_cpu_key(struct cpu_key *key, int version, __u32 dirid, | 81 | static void _make_cpu_key(struct cpu_key *key, int version, __u32 dirid, |
@@ -2538,6 +2539,12 @@ static int reiserfs_writepage(struct page *page, struct writeback_control *wbc) | |||
2538 | return reiserfs_write_full_page(page, wbc); | 2539 | return reiserfs_write_full_page(page, wbc); |
2539 | } | 2540 | } |
2540 | 2541 | ||
2542 | static void reiserfs_truncate_failed_write(struct inode *inode) | ||
2543 | { | ||
2544 | truncate_inode_pages(inode->i_mapping, inode->i_size); | ||
2545 | reiserfs_truncate_file(inode, 0); | ||
2546 | } | ||
2547 | |||
2541 | static int reiserfs_write_begin(struct file *file, | 2548 | static int reiserfs_write_begin(struct file *file, |
2542 | struct address_space *mapping, | 2549 | struct address_space *mapping, |
2543 | loff_t pos, unsigned len, unsigned flags, | 2550 | loff_t pos, unsigned len, unsigned flags, |
@@ -2604,6 +2611,8 @@ static int reiserfs_write_begin(struct file *file, | |||
2604 | if (ret) { | 2611 | if (ret) { |
2605 | unlock_page(page); | 2612 | unlock_page(page); |
2606 | page_cache_release(page); | 2613 | page_cache_release(page); |
2614 | /* Truncate allocated blocks */ | ||
2615 | reiserfs_truncate_failed_write(inode); | ||
2607 | } | 2616 | } |
2608 | return ret; | 2617 | return ret; |
2609 | } | 2618 | } |
@@ -2701,9 +2710,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping, | |||
2701 | ** transaction tracking stuff when the size changes. So, we have | 2710 | ** transaction tracking stuff when the size changes. So, we have |
2702 | ** to do the i_size updates here. | 2711 | ** to do the i_size updates here. |
2703 | */ | 2712 | */ |
2704 | pos += copied; | 2713 | if (pos + copied > inode->i_size) { |
2705 | |||
2706 | if (pos > inode->i_size) { | ||
2707 | struct reiserfs_transaction_handle myth; | 2714 | struct reiserfs_transaction_handle myth; |
2708 | lock_depth = reiserfs_write_lock_once(inode->i_sb); | 2715 | lock_depth = reiserfs_write_lock_once(inode->i_sb); |
2709 | locked = true; | 2716 | locked = true; |
@@ -2721,7 +2728,7 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping, | |||
2721 | goto journal_error; | 2728 | goto journal_error; |
2722 | 2729 | ||
2723 | reiserfs_update_inode_transaction(inode); | 2730 | reiserfs_update_inode_transaction(inode); |
2724 | inode->i_size = pos; | 2731 | inode->i_size = pos + copied; |
2725 | /* | 2732 | /* |
2726 | * this will just nest into our transaction. It's important | 2733 | * this will just nest into our transaction. It's important |
2727 | * to use mark_inode_dirty so the inode gets pushed around on the | 2734 | * to use mark_inode_dirty so the inode gets pushed around on the |
@@ -2751,6 +2758,10 @@ static int reiserfs_write_end(struct file *file, struct address_space *mapping, | |||
2751 | reiserfs_write_unlock_once(inode->i_sb, lock_depth); | 2758 | reiserfs_write_unlock_once(inode->i_sb, lock_depth); |
2752 | unlock_page(page); | 2759 | unlock_page(page); |
2753 | page_cache_release(page); | 2760 | page_cache_release(page); |
2761 | |||
2762 | if (pos + len > inode->i_size) | ||
2763 | reiserfs_truncate_failed_write(inode); | ||
2764 | |||
2754 | return ret == 0 ? copied : ret; | 2765 | return ret == 0 ? copied : ret; |
2755 | 2766 | ||
2756 | journal_error: | 2767 | journal_error: |
@@ -3051,13 +3062,14 @@ static ssize_t reiserfs_direct_IO(int rw, struct kiocb *iocb, | |||
3051 | int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) | 3062 | int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) |
3052 | { | 3063 | { |
3053 | struct inode *inode = dentry->d_inode; | 3064 | struct inode *inode = dentry->d_inode; |
3054 | int error; | ||
3055 | unsigned int ia_valid; | 3065 | unsigned int ia_valid; |
3066 | int depth; | ||
3067 | int error; | ||
3056 | 3068 | ||
3057 | /* must be turned off for recursive notify_change calls */ | 3069 | /* must be turned off for recursive notify_change calls */ |
3058 | ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID); | 3070 | ia_valid = attr->ia_valid &= ~(ATTR_KILL_SUID|ATTR_KILL_SGID); |
3059 | 3071 | ||
3060 | reiserfs_write_lock(inode->i_sb); | 3072 | depth = reiserfs_write_lock_once(inode->i_sb); |
3061 | if (attr->ia_valid & ATTR_SIZE) { | 3073 | if (attr->ia_valid & ATTR_SIZE) { |
3062 | /* version 2 items will be caught by the s_maxbytes check | 3074 | /* version 2 items will be caught by the s_maxbytes check |
3063 | ** done for us in vmtruncate | 3075 | ** done for us in vmtruncate |
@@ -3138,8 +3150,17 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
3138 | journal_end(&th, inode->i_sb, jbegin_count); | 3150 | journal_end(&th, inode->i_sb, jbegin_count); |
3139 | } | 3151 | } |
3140 | } | 3152 | } |
3141 | if (!error) | 3153 | if (!error) { |
3154 | /* | ||
3155 | * Relax the lock here, as it might truncate the | ||
3156 | * inode pages and wait for inode pages locks. | ||
3157 | * To release such page lock, the owner needs the | ||
3158 | * reiserfs lock | ||
3159 | */ | ||
3160 | reiserfs_write_unlock_once(inode->i_sb, depth); | ||
3142 | error = inode_setattr(inode, attr); | 3161 | error = inode_setattr(inode, attr); |
3162 | depth = reiserfs_write_lock_once(inode->i_sb); | ||
3163 | } | ||
3143 | } | 3164 | } |
3144 | 3165 | ||
3145 | if (!error && reiserfs_posixacl(inode->i_sb)) { | 3166 | if (!error && reiserfs_posixacl(inode->i_sb)) { |
@@ -3148,7 +3169,8 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
3148 | } | 3169 | } |
3149 | 3170 | ||
3150 | out: | 3171 | out: |
3151 | reiserfs_write_unlock(inode->i_sb); | 3172 | reiserfs_write_unlock_once(inode->i_sb, depth); |
3173 | |||
3152 | return error; | 3174 | return error; |
3153 | } | 3175 | } |
3154 | 3176 | ||