aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/journal.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/journal.c')
-rw-r--r--fs/ocfs2/journal.c64
1 files changed, 39 insertions, 25 deletions
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index f9d01e25298d..f31c7e8c19c3 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -44,7 +44,6 @@
44#include "localalloc.h" 44#include "localalloc.h"
45#include "slot_map.h" 45#include "slot_map.h"
46#include "super.h" 46#include "super.h"
47#include "vote.h"
48#include "sysfile.h" 47#include "sysfile.h"
49 48
50#include "buffer_head_io.h" 49#include "buffer_head_io.h"
@@ -103,7 +102,7 @@ static int ocfs2_commit_cache(struct ocfs2_super *osb)
103 mlog(0, "commit_thread: flushed transaction %lu (%u handles)\n", 102 mlog(0, "commit_thread: flushed transaction %lu (%u handles)\n",
104 journal->j_trans_id, flushed); 103 journal->j_trans_id, flushed);
105 104
106 ocfs2_kick_vote_thread(osb); 105 ocfs2_wake_downconvert_thread(osb);
107 wake_up(&journal->j_checkpointed); 106 wake_up(&journal->j_checkpointed);
108finally: 107finally:
109 mlog_exit(status); 108 mlog_exit(status);
@@ -174,6 +173,12 @@ int ocfs2_commit_trans(struct ocfs2_super *osb,
174 * transaction. extend_trans will either extend the current handle by 173 * transaction. extend_trans will either extend the current handle by
175 * nblocks, or commit it and start a new one with nblocks credits. 174 * nblocks, or commit it and start a new one with nblocks credits.
176 * 175 *
176 * This might call journal_restart() which will commit dirty buffers
177 * and then restart the transaction. Before calling
178 * ocfs2_extend_trans(), any changed blocks should have been
179 * dirtied. After calling it, all blocks which need to be changed must
180 * go through another set of journal_access/journal_dirty calls.
181 *
177 * WARNING: This will not release any semaphores or disk locks taken 182 * WARNING: This will not release any semaphores or disk locks taken
178 * during the transaction, so make sure they were taken *before* 183 * during the transaction, so make sure they were taken *before*
179 * start_trans or we'll have ordering deadlocks. 184 * start_trans or we'll have ordering deadlocks.
@@ -193,11 +198,15 @@ int ocfs2_extend_trans(handle_t *handle, int nblocks)
193 198
194 mlog(0, "Trying to extend transaction by %d blocks\n", nblocks); 199 mlog(0, "Trying to extend transaction by %d blocks\n", nblocks);
195 200
201#ifdef OCFS2_DEBUG_FS
202 status = 1;
203#else
196 status = journal_extend(handle, nblocks); 204 status = journal_extend(handle, nblocks);
197 if (status < 0) { 205 if (status < 0) {
198 mlog_errno(status); 206 mlog_errno(status);
199 goto bail; 207 goto bail;
200 } 208 }
209#endif
201 210
202 if (status > 0) { 211 if (status > 0) {
203 mlog(0, "journal_extend failed, trying journal_restart\n"); 212 mlog(0, "journal_extend failed, trying journal_restart\n");
@@ -304,14 +313,18 @@ int ocfs2_journal_dirty_data(handle_t *handle,
304 return err; 313 return err;
305} 314}
306 315
307#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * 5) 316#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * JBD_DEFAULT_MAX_COMMIT_AGE)
308 317
309void ocfs2_set_journal_params(struct ocfs2_super *osb) 318void ocfs2_set_journal_params(struct ocfs2_super *osb)
310{ 319{
311 journal_t *journal = osb->journal->j_journal; 320 journal_t *journal = osb->journal->j_journal;
321 unsigned long commit_interval = OCFS2_DEFAULT_COMMIT_INTERVAL;
322
323 if (osb->osb_commit_interval)
324 commit_interval = osb->osb_commit_interval;
312 325
313 spin_lock(&journal->j_state_lock); 326 spin_lock(&journal->j_state_lock);
314 journal->j_commit_interval = OCFS2_DEFAULT_COMMIT_INTERVAL; 327 journal->j_commit_interval = commit_interval;
315 if (osb->s_mount_opt & OCFS2_MOUNT_BARRIER) 328 if (osb->s_mount_opt & OCFS2_MOUNT_BARRIER)
316 journal->j_flags |= JFS_BARRIER; 329 journal->j_flags |= JFS_BARRIER;
317 else 330 else
@@ -327,7 +340,7 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty)
327 struct ocfs2_dinode *di = NULL; 340 struct ocfs2_dinode *di = NULL;
328 struct buffer_head *bh = NULL; 341 struct buffer_head *bh = NULL;
329 struct ocfs2_super *osb; 342 struct ocfs2_super *osb;
330 int meta_lock = 0; 343 int inode_lock = 0;
331 344
332 mlog_entry_void(); 345 mlog_entry_void();
333 346
@@ -357,14 +370,14 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty)
357 /* Skip recovery waits here - journal inode metadata never 370 /* Skip recovery waits here - journal inode metadata never
358 * changes in a live cluster so it can be considered an 371 * changes in a live cluster so it can be considered an
359 * exception to the rule. */ 372 * exception to the rule. */
360 status = ocfs2_meta_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY); 373 status = ocfs2_inode_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY);
361 if (status < 0) { 374 if (status < 0) {
362 if (status != -ERESTARTSYS) 375 if (status != -ERESTARTSYS)
363 mlog(ML_ERROR, "Could not get lock on journal!\n"); 376 mlog(ML_ERROR, "Could not get lock on journal!\n");
364 goto done; 377 goto done;
365 } 378 }
366 379
367 meta_lock = 1; 380 inode_lock = 1;
368 di = (struct ocfs2_dinode *)bh->b_data; 381 di = (struct ocfs2_dinode *)bh->b_data;
369 382
370 if (inode->i_size < OCFS2_MIN_JOURNAL_SIZE) { 383 if (inode->i_size < OCFS2_MIN_JOURNAL_SIZE) {
@@ -404,8 +417,8 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty)
404 status = 0; 417 status = 0;
405done: 418done:
406 if (status < 0) { 419 if (status < 0) {
407 if (meta_lock) 420 if (inode_lock)
408 ocfs2_meta_unlock(inode, 1); 421 ocfs2_inode_unlock(inode, 1);
409 if (bh != NULL) 422 if (bh != NULL)
410 brelse(bh); 423 brelse(bh);
411 if (inode) { 424 if (inode) {
@@ -534,7 +547,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
534 OCFS2_I(inode)->ip_open_count--; 547 OCFS2_I(inode)->ip_open_count--;
535 548
536 /* unlock our journal */ 549 /* unlock our journal */
537 ocfs2_meta_unlock(inode, 1); 550 ocfs2_inode_unlock(inode, 1);
538 551
539 brelse(journal->j_bh); 552 brelse(journal->j_bh);
540 journal->j_bh = NULL; 553 journal->j_bh = NULL;
@@ -873,8 +886,8 @@ restart:
873 ocfs2_super_unlock(osb, 1); 886 ocfs2_super_unlock(osb, 1);
874 887
875 /* We always run recovery on our own orphan dir - the dead 888 /* We always run recovery on our own orphan dir - the dead
876 * node(s) may have voted "no" on an inode delete earlier. A 889 * node(s) may have disallowd a previos inode delete. Re-processing
877 * revote is therefore required. */ 890 * is therefore required. */
878 ocfs2_queue_recovery_completion(osb->journal, osb->slot_num, NULL, 891 ocfs2_queue_recovery_completion(osb->journal, osb->slot_num, NULL,
879 NULL); 892 NULL);
880 893
@@ -963,9 +976,9 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
963 } 976 }
964 SET_INODE_JOURNAL(inode); 977 SET_INODE_JOURNAL(inode);
965 978
966 status = ocfs2_meta_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY); 979 status = ocfs2_inode_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY);
967 if (status < 0) { 980 if (status < 0) {
968 mlog(0, "status returned from ocfs2_meta_lock=%d\n", status); 981 mlog(0, "status returned from ocfs2_inode_lock=%d\n", status);
969 if (status != -ERESTARTSYS) 982 if (status != -ERESTARTSYS)
970 mlog(ML_ERROR, "Could not lock journal!\n"); 983 mlog(ML_ERROR, "Could not lock journal!\n");
971 goto done; 984 goto done;
@@ -1037,7 +1050,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
1037done: 1050done:
1038 /* drop the lock on this nodes journal */ 1051 /* drop the lock on this nodes journal */
1039 if (got_lock) 1052 if (got_lock)
1040 ocfs2_meta_unlock(inode, 1); 1053 ocfs2_inode_unlock(inode, 1);
1041 1054
1042 if (inode) 1055 if (inode)
1043 iput(inode); 1056 iput(inode);
@@ -1152,14 +1165,14 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb,
1152 SET_INODE_JOURNAL(inode); 1165 SET_INODE_JOURNAL(inode);
1153 1166
1154 flags = OCFS2_META_LOCK_RECOVERY | OCFS2_META_LOCK_NOQUEUE; 1167 flags = OCFS2_META_LOCK_RECOVERY | OCFS2_META_LOCK_NOQUEUE;
1155 status = ocfs2_meta_lock_full(inode, NULL, 1, flags); 1168 status = ocfs2_inode_lock_full(inode, NULL, 1, flags);
1156 if (status < 0) { 1169 if (status < 0) {
1157 if (status != -EAGAIN) 1170 if (status != -EAGAIN)
1158 mlog_errno(status); 1171 mlog_errno(status);
1159 goto bail; 1172 goto bail;
1160 } 1173 }
1161 1174
1162 ocfs2_meta_unlock(inode, 1); 1175 ocfs2_inode_unlock(inode, 1);
1163bail: 1176bail:
1164 if (inode) 1177 if (inode)
1165 iput(inode); 1178 iput(inode);
@@ -1231,7 +1244,7 @@ static int ocfs2_orphan_filldir(void *priv, const char *name, int name_len,
1231 1244
1232 /* Skip bad inodes so that recovery can continue */ 1245 /* Skip bad inodes so that recovery can continue */
1233 iter = ocfs2_iget(p->osb, ino, 1246 iter = ocfs2_iget(p->osb, ino,
1234 OCFS2_FI_FLAG_ORPHAN_RECOVERY); 1247 OCFS2_FI_FLAG_ORPHAN_RECOVERY, 0);
1235 if (IS_ERR(iter)) 1248 if (IS_ERR(iter))
1236 return 0; 1249 return 0;
1237 1250
@@ -1267,7 +1280,7 @@ static int ocfs2_queue_orphans(struct ocfs2_super *osb,
1267 } 1280 }
1268 1281
1269 mutex_lock(&orphan_dir_inode->i_mutex); 1282 mutex_lock(&orphan_dir_inode->i_mutex);
1270 status = ocfs2_meta_lock(orphan_dir_inode, NULL, 0); 1283 status = ocfs2_inode_lock(orphan_dir_inode, NULL, 0);
1271 if (status < 0) { 1284 if (status < 0) {
1272 mlog_errno(status); 1285 mlog_errno(status);
1273 goto out; 1286 goto out;
@@ -1277,12 +1290,13 @@ static int ocfs2_queue_orphans(struct ocfs2_super *osb,
1277 ocfs2_orphan_filldir); 1290 ocfs2_orphan_filldir);
1278 if (status) { 1291 if (status) {
1279 mlog_errno(status); 1292 mlog_errno(status);
1280 goto out; 1293 goto out_cluster;
1281 } 1294 }
1282 1295
1283 *head = priv.head; 1296 *head = priv.head;
1284 1297
1285 ocfs2_meta_unlock(orphan_dir_inode, 0); 1298out_cluster:
1299 ocfs2_inode_unlock(orphan_dir_inode, 0);
1286out: 1300out:
1287 mutex_unlock(&orphan_dir_inode->i_mutex); 1301 mutex_unlock(&orphan_dir_inode->i_mutex);
1288 iput(orphan_dir_inode); 1302 iput(orphan_dir_inode);
@@ -1369,10 +1383,10 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
1369 iter = oi->ip_next_orphan; 1383 iter = oi->ip_next_orphan;
1370 1384
1371 spin_lock(&oi->ip_lock); 1385 spin_lock(&oi->ip_lock);
1372 /* Delete voting may have set these on the assumption 1386 /* The remote delete code may have set these on the
1373 * that the other node would wipe them successfully. 1387 * assumption that the other node would wipe them
1374 * If they are still in the node's orphan dir, we need 1388 * successfully. If they are still in the node's
1375 * to reset that state. */ 1389 * orphan dir, we need to reset that state. */
1376 oi->ip_flags &= ~(OCFS2_INODE_DELETED|OCFS2_INODE_SKIP_DELETE); 1390 oi->ip_flags &= ~(OCFS2_INODE_DELETED|OCFS2_INODE_SKIP_DELETE);
1377 1391
1378 /* Set the proper information to get us going into 1392 /* Set the proper information to get us going into