aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd2/transaction.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jbd2/transaction.c')
-rw-r--r--fs/jbd2/transaction.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 9dc71a6b62e6..70245d6638b7 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1243,6 +1243,7 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
1243 struct journal_head *jh; 1243 struct journal_head *jh;
1244 int drop_reserve = 0; 1244 int drop_reserve = 0;
1245 int err = 0; 1245 int err = 0;
1246 int was_modified = 0;
1246 1247
1247 BUFFER_TRACE(bh, "entry"); 1248 BUFFER_TRACE(bh, "entry");
1248 1249
@@ -1261,6 +1262,9 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
1261 goto not_jbd; 1262 goto not_jbd;
1262 } 1263 }
1263 1264
1265 /* keep track of wether or not this transaction modified us */
1266 was_modified = jh->b_modified;
1267
1264 /* 1268 /*
1265 * The buffer's going from the transaction, we must drop 1269 * The buffer's going from the transaction, we must drop
1266 * all references -bzzz 1270 * all references -bzzz
@@ -1278,7 +1282,12 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
1278 1282
1279 JBUFFER_TRACE(jh, "belongs to current transaction: unfile"); 1283 JBUFFER_TRACE(jh, "belongs to current transaction: unfile");
1280 1284
1281 drop_reserve = 1; 1285 /*
1286 * we only want to drop a reference if this transaction
1287 * modified the buffer
1288 */
1289 if (was_modified)
1290 drop_reserve = 1;
1282 1291
1283 /* 1292 /*
1284 * We are no longer going to journal this buffer. 1293 * We are no longer going to journal this buffer.
@@ -1318,7 +1327,13 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
1318 if (jh->b_next_transaction) { 1327 if (jh->b_next_transaction) {
1319 J_ASSERT(jh->b_next_transaction == transaction); 1328 J_ASSERT(jh->b_next_transaction == transaction);
1320 jh->b_next_transaction = NULL; 1329 jh->b_next_transaction = NULL;
1321 drop_reserve = 1; 1330
1331 /*
1332 * only drop a reference if this transaction modified
1333 * the buffer
1334 */
1335 if (was_modified)
1336 drop_reserve = 1;
1322 } 1337 }
1323 } 1338 }
1324 1339
@@ -2090,7 +2105,7 @@ void __jbd2_journal_refile_buffer(struct journal_head *jh)
2090 jh->b_transaction = jh->b_next_transaction; 2105 jh->b_transaction = jh->b_next_transaction;
2091 jh->b_next_transaction = NULL; 2106 jh->b_next_transaction = NULL;
2092 __jbd2_journal_file_buffer(jh, jh->b_transaction, 2107 __jbd2_journal_file_buffer(jh, jh->b_transaction,
2093 was_dirty ? BJ_Metadata : BJ_Reserved); 2108 jh->b_modified ? BJ_Metadata : BJ_Reserved);
2094 J_ASSERT_JH(jh, jh->b_transaction->t_state == T_RUNNING); 2109 J_ASSERT_JH(jh, jh->b_transaction->t_state == T_RUNNING);
2095 2110
2096 if (was_dirty) 2111 if (was_dirty)