diff options
Diffstat (limited to 'fs/jbd2/transaction.c')
| -rw-r--r-- | fs/jbd2/transaction.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 98d04c5fe3d2..2c56c3e32194 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c | |||
| @@ -764,13 +764,11 @@ void jbd2_journal_unlock_updates (journal_t *journal) | |||
| 764 | 764 | ||
| 765 | static void warn_dirty_buffer(struct buffer_head *bh) | 765 | static void warn_dirty_buffer(struct buffer_head *bh) |
| 766 | { | 766 | { |
| 767 | char b[BDEVNAME_SIZE]; | ||
| 768 | |||
| 769 | printk(KERN_WARNING | 767 | printk(KERN_WARNING |
| 770 | "JBD2: Spotted dirty metadata buffer (dev = %s, blocknr = %llu). " | 768 | "JBD2: Spotted dirty metadata buffer (dev = %pg, blocknr = %llu). " |
| 771 | "There's a risk of filesystem corruption in case of system " | 769 | "There's a risk of filesystem corruption in case of system " |
| 772 | "crash.\n", | 770 | "crash.\n", |
| 773 | bdevname(bh->b_bdev, b), (unsigned long long)bh->b_blocknr); | 771 | bh->b_bdev, (unsigned long long)bh->b_blocknr); |
| 774 | } | 772 | } |
| 775 | 773 | ||
| 776 | /* Call t_frozen trigger and copy buffer data into jh->b_frozen_data. */ | 774 | /* Call t_frozen trigger and copy buffer data into jh->b_frozen_data. */ |
| @@ -968,14 +966,8 @@ repeat: | |||
| 968 | if (!frozen_buffer) { | 966 | if (!frozen_buffer) { |
| 969 | JBUFFER_TRACE(jh, "allocate memory for buffer"); | 967 | JBUFFER_TRACE(jh, "allocate memory for buffer"); |
| 970 | jbd_unlock_bh_state(bh); | 968 | jbd_unlock_bh_state(bh); |
| 971 | frozen_buffer = jbd2_alloc(jh2bh(jh)->b_size, GFP_NOFS); | 969 | frozen_buffer = jbd2_alloc(jh2bh(jh)->b_size, |
| 972 | if (!frozen_buffer) { | 970 | GFP_NOFS | __GFP_NOFAIL); |
| 973 | printk(KERN_ERR "%s: OOM for frozen_buffer\n", | ||
| 974 | __func__); | ||
| 975 | JBUFFER_TRACE(jh, "oom!"); | ||
| 976 | error = -ENOMEM; | ||
| 977 | goto out; | ||
| 978 | } | ||
| 979 | goto repeat; | 971 | goto repeat; |
| 980 | } | 972 | } |
| 981 | jh->b_frozen_data = frozen_buffer; | 973 | jh->b_frozen_data = frozen_buffer; |
| @@ -1009,7 +1001,8 @@ out: | |||
| 1009 | } | 1001 | } |
| 1010 | 1002 | ||
| 1011 | /* Fast check whether buffer is already attached to the required transaction */ | 1003 | /* Fast check whether buffer is already attached to the required transaction */ |
| 1012 | static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh) | 1004 | static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh, |
| 1005 | bool undo) | ||
| 1013 | { | 1006 | { |
| 1014 | struct journal_head *jh; | 1007 | struct journal_head *jh; |
| 1015 | bool ret = false; | 1008 | bool ret = false; |
| @@ -1036,6 +1029,9 @@ static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh) | |||
| 1036 | jh = READ_ONCE(bh->b_private); | 1029 | jh = READ_ONCE(bh->b_private); |
| 1037 | if (!jh) | 1030 | if (!jh) |
| 1038 | goto out; | 1031 | goto out; |
| 1032 | /* For undo access buffer must have data copied */ | ||
| 1033 | if (undo && !jh->b_committed_data) | ||
| 1034 | goto out; | ||
| 1039 | if (jh->b_transaction != handle->h_transaction && | 1035 | if (jh->b_transaction != handle->h_transaction && |
| 1040 | jh->b_next_transaction != handle->h_transaction) | 1036 | jh->b_next_transaction != handle->h_transaction) |
| 1041 | goto out; | 1037 | goto out; |
| @@ -1073,7 +1069,7 @@ int jbd2_journal_get_write_access(handle_t *handle, struct buffer_head *bh) | |||
| 1073 | struct journal_head *jh; | 1069 | struct journal_head *jh; |
| 1074 | int rc; | 1070 | int rc; |
| 1075 | 1071 | ||
| 1076 | if (jbd2_write_access_granted(handle, bh)) | 1072 | if (jbd2_write_access_granted(handle, bh, false)) |
| 1077 | return 0; | 1073 | return 0; |
| 1078 | 1074 | ||
| 1079 | jh = jbd2_journal_add_journal_head(bh); | 1075 | jh = jbd2_journal_add_journal_head(bh); |
| @@ -1210,7 +1206,7 @@ int jbd2_journal_get_undo_access(handle_t *handle, struct buffer_head *bh) | |||
| 1210 | char *committed_data = NULL; | 1206 | char *committed_data = NULL; |
| 1211 | 1207 | ||
| 1212 | JBUFFER_TRACE(jh, "entry"); | 1208 | JBUFFER_TRACE(jh, "entry"); |
| 1213 | if (jbd2_write_access_granted(handle, bh)) | 1209 | if (jbd2_write_access_granted(handle, bh, true)) |
| 1214 | return 0; | 1210 | return 0; |
| 1215 | 1211 | ||
| 1216 | jh = jbd2_journal_add_journal_head(bh); | 1212 | jh = jbd2_journal_add_journal_head(bh); |
| @@ -1224,15 +1220,9 @@ int jbd2_journal_get_undo_access(handle_t *handle, struct buffer_head *bh) | |||
| 1224 | goto out; | 1220 | goto out; |
| 1225 | 1221 | ||
| 1226 | repeat: | 1222 | repeat: |
| 1227 | if (!jh->b_committed_data) { | 1223 | if (!jh->b_committed_data) |
| 1228 | committed_data = jbd2_alloc(jh2bh(jh)->b_size, GFP_NOFS); | 1224 | committed_data = jbd2_alloc(jh2bh(jh)->b_size, |
| 1229 | if (!committed_data) { | 1225 | GFP_NOFS|__GFP_NOFAIL); |
| 1230 | printk(KERN_ERR "%s: No memory for committed data\n", | ||
| 1231 | __func__); | ||
| 1232 | err = -ENOMEM; | ||
| 1233 | goto out; | ||
| 1234 | } | ||
| 1235 | } | ||
| 1236 | 1226 | ||
| 1237 | jbd_lock_bh_state(bh); | 1227 | jbd_lock_bh_state(bh); |
| 1238 | if (!jh->b_committed_data) { | 1228 | if (!jh->b_committed_data) { |
| @@ -1937,8 +1927,8 @@ out: | |||
| 1937 | * @journal: journal for operation | 1927 | * @journal: journal for operation |
| 1938 | * @page: to try and free | 1928 | * @page: to try and free |
| 1939 | * @gfp_mask: we use the mask to detect how hard should we try to release | 1929 | * @gfp_mask: we use the mask to detect how hard should we try to release |
| 1940 | * buffers. If __GFP_WAIT and __GFP_FS is set, we wait for commit code to | 1930 | * buffers. If __GFP_DIRECT_RECLAIM and __GFP_FS is set, we wait for commit |
| 1941 | * release the buffers. | 1931 | * code to release the buffers. |
| 1942 | * | 1932 | * |
| 1943 | * | 1933 | * |
| 1944 | * For all the buffers on this page, | 1934 | * For all the buffers on this page, |
| @@ -2152,6 +2142,7 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh, | |||
| 2152 | 2142 | ||
| 2153 | if (!buffer_dirty(bh)) { | 2143 | if (!buffer_dirty(bh)) { |
| 2154 | /* bdflush has written it. We can drop it now */ | 2144 | /* bdflush has written it. We can drop it now */ |
| 2145 | __jbd2_journal_remove_checkpoint(jh); | ||
| 2155 | goto zap_buffer; | 2146 | goto zap_buffer; |
| 2156 | } | 2147 | } |
| 2157 | 2148 | ||
| @@ -2181,6 +2172,7 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh, | |||
| 2181 | /* The orphan record's transaction has | 2172 | /* The orphan record's transaction has |
| 2182 | * committed. We can cleanse this buffer */ | 2173 | * committed. We can cleanse this buffer */ |
| 2183 | clear_buffer_jbddirty(bh); | 2174 | clear_buffer_jbddirty(bh); |
| 2175 | __jbd2_journal_remove_checkpoint(jh); | ||
| 2184 | goto zap_buffer; | 2176 | goto zap_buffer; |
| 2185 | } | 2177 | } |
| 2186 | } | 2178 | } |
| @@ -2271,7 +2263,7 @@ int jbd2_journal_invalidatepage(journal_t *journal, | |||
| 2271 | struct buffer_head *head, *bh, *next; | 2263 | struct buffer_head *head, *bh, *next; |
| 2272 | unsigned int stop = offset + length; | 2264 | unsigned int stop = offset + length; |
| 2273 | unsigned int curr_off = 0; | 2265 | unsigned int curr_off = 0; |
| 2274 | int partial_page = (offset || length < PAGE_CACHE_SIZE); | 2266 | int partial_page = (offset || length < PAGE_SIZE); |
| 2275 | int may_free = 1; | 2267 | int may_free = 1; |
| 2276 | int ret = 0; | 2268 | int ret = 0; |
| 2277 | 2269 | ||
| @@ -2280,7 +2272,7 @@ int jbd2_journal_invalidatepage(journal_t *journal, | |||
| 2280 | if (!page_has_buffers(page)) | 2272 | if (!page_has_buffers(page)) |
| 2281 | return 0; | 2273 | return 0; |
| 2282 | 2274 | ||
| 2283 | BUG_ON(stop > PAGE_CACHE_SIZE || stop < length); | 2275 | BUG_ON(stop > PAGE_SIZE || stop < length); |
| 2284 | 2276 | ||
| 2285 | /* We will potentially be playing with lists other than just the | 2277 | /* We will potentially be playing with lists other than just the |
| 2286 | * data lists (especially for journaled data mode), so be | 2278 | * data lists (especially for journaled data mode), so be |
