Lines Matching refs:osb
50 static int ocfs2_recover_node(struct ocfs2_super *osb,
53 static int ocfs2_commit_cache(struct ocfs2_super *osb);
54 static int __ocfs2_wait_on_mount(struct ocfs2_super *osb, int quota);
55 static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
57 static int ocfs2_trylock_journal(struct ocfs2_super *osb,
59 static int ocfs2_recover_orphans(struct ocfs2_super *osb,
70 static inline int ocfs2_wait_on_mount(struct ocfs2_super *osb)
72 return __ocfs2_wait_on_mount(osb, 0);
75 static inline int ocfs2_wait_on_quotas(struct ocfs2_super *osb)
77 return __ocfs2_wait_on_mount(osb, 1);
97 static void ocfs2_replay_map_set_state(struct ocfs2_super *osb, int state)
99 if (!osb->replay_map)
103 if (osb->replay_map->rm_state == REPLAY_DONE)
106 osb->replay_map->rm_state = state;
109 int ocfs2_compute_replay_slots(struct ocfs2_super *osb)
115 if (osb->replay_map)
119 (osb->max_slots * sizeof(char)), GFP_KERNEL);
126 spin_lock(&osb->osb_lock);
128 replay_map->rm_slots = osb->max_slots;
133 if (ocfs2_slot_to_node_num_locked(osb, i, &node_num) == -ENOENT)
137 osb->replay_map = replay_map;
138 spin_unlock(&osb->osb_lock);
142 static void ocfs2_queue_replay_slots(struct ocfs2_super *osb,
145 struct ocfs2_replay_map *replay_map = osb->replay_map;
156 ocfs2_queue_recovery_completion(osb->journal, i, NULL,
162 void ocfs2_free_replay_slots(struct ocfs2_super *osb)
164 struct ocfs2_replay_map *replay_map = osb->replay_map;
166 if (!osb->replay_map)
170 osb->replay_map = NULL;
173 int ocfs2_recovery_init(struct ocfs2_super *osb)
177 mutex_init(&osb->recovery_lock);
178 osb->disable_recovery = 0;
179 osb->recovery_thread_task = NULL;
180 init_waitqueue_head(&osb->recovery_event);
183 osb->max_slots * sizeof(unsigned int),
192 osb->recovery_map = rm;
200 static int ocfs2_recovery_thread_running(struct ocfs2_super *osb)
203 return osb->recovery_thread_task != NULL;
206 void ocfs2_recovery_exit(struct ocfs2_super *osb)
212 mutex_lock(&osb->recovery_lock);
213 osb->disable_recovery = 1;
214 mutex_unlock(&osb->recovery_lock);
215 wait_event(osb->recovery_event, !ocfs2_recovery_thread_running(osb));
220 if (osb->ocfs2_wq)
221 flush_workqueue(osb->ocfs2_wq);
224 * Now that recovery is shut down, and the osb is about to be
227 rm = osb->recovery_map;
233 static int __ocfs2_recovery_map_test(struct ocfs2_super *osb,
237 struct ocfs2_recovery_map *rm = osb->recovery_map;
239 assert_spin_locked(&osb->osb_lock);
250 static int ocfs2_recovery_map_set(struct ocfs2_super *osb,
253 struct ocfs2_recovery_map *rm = osb->recovery_map;
255 spin_lock(&osb->osb_lock);
256 if (__ocfs2_recovery_map_test(osb, node_num)) {
257 spin_unlock(&osb->osb_lock);
262 BUG_ON(rm->rm_used >= osb->max_slots);
266 spin_unlock(&osb->osb_lock);
271 static void ocfs2_recovery_map_clear(struct ocfs2_super *osb,
275 struct ocfs2_recovery_map *rm = osb->recovery_map;
277 spin_lock(&osb->osb_lock);
291 spin_unlock(&osb->osb_lock);
294 static int ocfs2_commit_cache(struct ocfs2_super *osb)
300 journal = osb->journal;
329 ocfs2_wake_downconvert_thread(osb);
335 handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs)
337 journal_t *journal = osb->journal->j_journal;
340 BUG_ON(!osb || !osb->journal->j_journal);
342 if (ocfs2_is_hard_readonly(osb))
345 BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE);
352 sb_start_intwrite(osb->sb);
354 down_read(&osb->journal->j_trans_barrier);
358 up_read(&osb->journal->j_trans_barrier);
359 sb_end_intwrite(osb->sb);
364 ocfs2_abort(osb->sb, "Detected aborted journal\n");
368 if (!ocfs2_mount_local(osb))
369 atomic_inc(&(osb->journal->j_num_trans));
375 int ocfs2_commit_trans(struct ocfs2_super *osb,
379 struct ocfs2_journal *journal = osb->journal;
390 sb_end_intwrite(osb->sb);
642 struct ocfs2_super *osb =
672 return ocfs2_error(osb->sb, "A previous attempt to "
684 ocfs2_set_ci_lock_trans(osb->journal, ci);
701 if (!status && ocfs2_meta_ecc(osb) && triggers)
798 void ocfs2_set_journal_params(struct ocfs2_super *osb)
800 journal_t *journal = osb->journal->j_journal;
803 if (osb->osb_commit_interval)
804 commit_interval = osb->osb_commit_interval;
808 if (osb->s_mount_opt & OCFS2_MOUNT_BARRIER)
822 struct ocfs2_super *osb;
827 osb = journal->j_osb;
830 inode = ocfs2_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE,
831 osb->slot_num);
893 ocfs2_set_journal_params(osb);
922 static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
927 struct ocfs2_journal *journal = osb->journal;
933 /* The journal bh on the osb always comes from ocfs2_journal_init()
948 ocfs2_compute_meta_ecc(osb->sb, bh->b_data, &fe->i_check);
949 status = ocfs2_write_block(osb, bh, INODE_CACHE(journal->j_inode));
960 void ocfs2_journal_shutdown(struct ocfs2_super *osb)
967 BUG_ON(!osb);
969 journal = osb->journal;
982 num_running_trans = atomic_read(&(osb->journal->j_num_trans));
994 if (osb->commit_task) {
996 trace_ocfs2_journal_shutdown_wait(osb->commit_task);
997 kthread_stop(osb->commit_task);
998 osb->commit_task = NULL;
1001 BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0);
1003 if (ocfs2_mount_local(osb)) {
1017 status = ocfs2_journal_toggle_dirty(osb, 0, 0);
1059 struct ocfs2_super *osb;
1063 osb = journal->j_osb;
1071 ocfs2_clear_journal_error(osb->sb, journal->j_journal, osb->slot_num);
1081 status = ocfs2_journal_toggle_dirty(osb, 1, replayed);
1089 osb->commit_task = kthread_run(ocfs2_commit_thread, osb,
1090 "ocfs2cmt-%s", osb->uuid_str);
1091 if (IS_ERR(osb->commit_task)) {
1092 status = PTR_ERR(osb->commit_task);
1093 osb->commit_task = NULL;
1099 osb->commit_task = NULL;
1128 static int ocfs2_recovery_completed(struct ocfs2_super *osb)
1131 struct ocfs2_recovery_map *rm = osb->recovery_map;
1133 spin_lock(&osb->osb_lock);
1135 spin_unlock(&osb->osb_lock);
1140 void ocfs2_wait_for_recovery(struct ocfs2_super *osb)
1142 wait_event(osb->recovery_event, ocfs2_recovery_completed(osb));
1161 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1174 bh = __find_get_block(osb->sb->s_bdev, p_blkno,
1175 osb->sb->s_blocksize);
1185 status = ocfs2_read_blocks_sync(osb, p_blkno, 1, &bh);
1226 struct ocfs2_super *osb = journal->j_osb;
1243 ocfs2_wait_on_quotas(osb);
1256 ret = ocfs2_complete_local_alloc_recovery(osb,
1265 ret = ocfs2_complete_truncate_log_recovery(osb,
1273 ret = ocfs2_recover_orphans(osb, item->lri_slot,
1279 ret = ocfs2_finish_quota_recovery(osb, qrec,
1334 void ocfs2_complete_mount_recovery(struct ocfs2_super *osb)
1336 struct ocfs2_journal *journal = osb->journal;
1338 if (ocfs2_is_hard_readonly(osb))
1343 ocfs2_queue_recovery_completion(journal, osb->slot_num,
1344 osb->local_alloc_copy, NULL, NULL,
1346 ocfs2_schedule_truncate_log_flush(osb, 0);
1348 osb->local_alloc_copy = NULL;
1351 ocfs2_replay_map_set_state(osb, REPLAY_NEEDED);
1352 ocfs2_queue_replay_slots(osb, ORPHAN_NEED_TRUNCATE);
1353 ocfs2_free_replay_slots(osb);
1356 void ocfs2_complete_quota_recovery(struct ocfs2_super *osb)
1358 if (osb->quota_rec) {
1359 ocfs2_queue_recovery_completion(osb->journal,
1360 osb->slot_num,
1363 osb->quota_rec,
1365 osb->quota_rec = NULL;
1372 struct ocfs2_super *osb = arg;
1373 struct ocfs2_recovery_map *rm = osb->recovery_map;
1379 int quota_enabled = OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb,
1381 || OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb,
1384 status = ocfs2_wait_on_mount(osb);
1390 rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS);
1397 status = ocfs2_super_lock(osb, 1);
1403 status = ocfs2_compute_replay_slots(osb);
1408 ocfs2_queue_recovery_completion(osb->journal, osb->slot_num, NULL,
1411 spin_lock(&osb->osb_lock);
1416 spin_unlock(&osb->osb_lock);
1417 slot_num = ocfs2_node_num_to_slot(osb, node_num);
1439 status = ocfs2_recover_node(osb, node_num, slot_num);
1442 ocfs2_recovery_map_clear(osb, node_num);
1447 MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
1451 spin_lock(&osb->osb_lock);
1453 spin_unlock(&osb->osb_lock);
1457 status = ocfs2_check_journals_nolocks(osb);
1467 qrec = ocfs2_begin_quota_recovery(osb, rm_quota[i]);
1473 ocfs2_queue_recovery_completion(osb->journal,
1480 ocfs2_super_unlock(osb, 1);
1483 ocfs2_queue_replay_slots(osb, ORPHAN_NEED_TRUNCATE);
1486 mutex_lock(&osb->recovery_lock);
1487 if (!status && !ocfs2_recovery_completed(osb)) {
1488 mutex_unlock(&osb->recovery_lock);
1492 ocfs2_free_replay_slots(osb);
1493 osb->recovery_thread_task = NULL;
1495 wake_up(&osb->recovery_event);
1497 mutex_unlock(&osb->recovery_lock);
1508 void ocfs2_recovery_thread(struct ocfs2_super *osb, int node_num)
1510 mutex_lock(&osb->recovery_lock);
1512 trace_ocfs2_recovery_thread(node_num, osb->node_num,
1513 osb->disable_recovery, osb->recovery_thread_task,
1514 osb->disable_recovery ?
1515 -1 : ocfs2_recovery_map_set(osb, node_num));
1517 if (osb->disable_recovery)
1520 if (osb->recovery_thread_task)
1523 osb->recovery_thread_task = kthread_run(__ocfs2_recovery_thread, osb,
1524 "ocfs2rec-%s", osb->uuid_str);
1525 if (IS_ERR(osb->recovery_thread_task)) {
1526 mlog_errno((int)PTR_ERR(osb->recovery_thread_task));
1527 osb->recovery_thread_task = NULL;
1531 mutex_unlock(&osb->recovery_lock);
1532 wake_up(&osb->recovery_event);
1535 static int ocfs2_read_journal_inode(struct ocfs2_super *osb,
1543 BUG_ON(slot_num >= osb->max_slots);
1545 inode = ocfs2_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE,
1573 static int ocfs2_replay_journal(struct ocfs2_super *osb,
1586 status = ocfs2_read_journal_inode(osb, slot_num, &bh, &inode);
1605 if (osb->slot_recovery_generations[slot_num] != slot_reco_gen) {
1607 osb->slot_recovery_generations[slot_num], slot_reco_gen);
1608 osb->slot_recovery_generations[slot_num] = slot_reco_gen;
1632 osb->slot_recovery_generations[slot_num] = slot_reco_gen;
1637 ocfs2_replay_map_set_state(osb, REPLAY_NEEDED);
1640 "device (%u,%u)\n", node_num, slot_num, MAJOR(osb->sb->s_dev),
1641 MINOR(osb->sb->s_dev));
1667 ocfs2_clear_journal_error(osb->sb, journal, slot_num);
1683 osb->slot_recovery_generations[slot_num] =
1686 ocfs2_compute_meta_ecc(osb->sb, bh->b_data, &fe->i_check);
1687 status = ocfs2_write_block(osb, bh, INODE_CACHE(inode));
1697 "device (%u,%u)\n", node_num, slot_num, MAJOR(osb->sb->s_dev),
1698 MINOR(osb->sb->s_dev));
1722 static int ocfs2_recover_node(struct ocfs2_super *osb,
1729 trace_ocfs2_recover_node(node_num, slot_num, osb->node_num);
1733 BUG_ON(osb->node_num == node_num);
1735 status = ocfs2_replay_journal(osb, node_num, slot_num);
1747 status = ocfs2_begin_local_alloc_recovery(osb, slot_num, &la_copy);
1756 status = ocfs2_begin_truncate_log_recovery(osb, slot_num, &tl_copy);
1762 status = ocfs2_clear_slot(osb, slot_num);
1767 ocfs2_queue_recovery_completion(osb->journal, slot_num, la_copy,
1779 static int ocfs2_trylock_journal(struct ocfs2_super *osb,
1785 inode = ocfs2_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE,
1818 int ocfs2_mark_dead_nodes(struct ocfs2_super *osb)
1829 for (i = 0; i < osb->max_slots; i++) {
1831 status = ocfs2_read_journal_inode(osb, i, &bh, NULL);
1841 spin_lock(&osb->osb_lock);
1842 osb->slot_recovery_generations[i] = gen;
1845 osb->slot_recovery_generations[i]);
1847 if (i == osb->slot_num) {
1848 spin_unlock(&osb->osb_lock);
1852 status = ocfs2_slot_to_node_num_locked(osb, i, &node_num);
1854 spin_unlock(&osb->osb_lock);
1858 if (__ocfs2_recovery_map_test(osb, node_num)) {
1859 spin_unlock(&osb->osb_lock);
1862 spin_unlock(&osb->osb_lock);
1867 status = ocfs2_trylock_journal(osb, i);
1872 ocfs2_recovery_thread(osb, node_num);
1925 static void ocfs2_queue_orphan_scan(struct ocfs2_super *osb)
1931 os = &osb->osb_orphan_scan;
1939 status = ocfs2_orphan_scan_lock(osb, &seqno);
1955 for (i = 0; i < osb->max_slots; i++)
1956 ocfs2_queue_recovery_completion(osb->journal, i, NULL, NULL,
1966 ocfs2_orphan_scan_unlock(osb, seqno);
1977 struct ocfs2_super *osb;
1981 osb = os->os_osb;
1984 ocfs2_queue_orphan_scan(osb);
1986 queue_delayed_work(osb->ocfs2_wq, &os->os_orphan_scan_work,
1991 void ocfs2_orphan_scan_stop(struct ocfs2_super *osb)
1995 os = &osb->osb_orphan_scan;
2004 void ocfs2_orphan_scan_init(struct ocfs2_super *osb)
2008 os = &osb->osb_orphan_scan;
2009 os->os_osb = osb;
2016 void ocfs2_orphan_scan_start(struct ocfs2_super *osb)
2020 os = &osb->osb_orphan_scan;
2022 if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb))
2026 queue_delayed_work(osb->ocfs2_wq, &os->os_orphan_scan_work,
2034 struct ocfs2_super *osb;
2058 iter = ocfs2_iget(p->osb, ino,
2083 static int ocfs2_queue_orphans(struct ocfs2_super *osb,
2092 .osb = osb,
2097 orphan_dir_inode = ocfs2_get_system_file_inode(osb,
2129 static int ocfs2_orphan_recovery_can_continue(struct ocfs2_super *osb,
2134 spin_lock(&osb->osb_lock);
2135 ret = !osb->osb_orphan_wipes[slot];
2136 spin_unlock(&osb->osb_lock);
2140 static void ocfs2_mark_recovering_orphan_dir(struct ocfs2_super *osb,
2143 spin_lock(&osb->osb_lock);
2146 ocfs2_node_map_set_bit(osb, &osb->osb_recovering_orphan_dirs, slot);
2147 while (osb->osb_orphan_wipes[slot]) {
2151 spin_unlock(&osb->osb_lock);
2152 wait_event_interruptible(osb->osb_wipe_event,
2153 ocfs2_orphan_recovery_can_continue(osb, slot));
2154 spin_lock(&osb->osb_lock);
2156 spin_unlock(&osb->osb_lock);
2159 static void ocfs2_clear_recovering_orphan_dir(struct ocfs2_super *osb,
2162 ocfs2_node_map_clear_bit(osb, &osb->osb_recovering_orphan_dirs, slot);
2183 static int ocfs2_recover_orphans(struct ocfs2_super *osb,
2196 ocfs2_mark_recovering_orphan_dir(osb, slot);
2197 ret = ocfs2_queue_orphans(osb, slot, &inode, orphan_reco_type);
2198 ocfs2_clear_recovering_orphan_dir(osb, slot);
2241 ret = ocfs2_del_inode_from_orphan(osb, inode,
2272 static int __ocfs2_wait_on_mount(struct ocfs2_super *osb, int quota)
2277 wait_event(osb->osb_mount_event,
2278 (!quota && atomic_read(&osb->vol_state) == VOLUME_MOUNTED) ||
2279 atomic_read(&osb->vol_state) == VOLUME_MOUNTED_QUOTAS ||
2280 atomic_read(&osb->vol_state) == VOLUME_DISABLED);
2285 if (atomic_read(&osb->vol_state) == VOLUME_DISABLED) {
2297 struct ocfs2_super *osb = arg;
2298 struct ocfs2_journal *journal = osb->journal;
2307 wait_event_interruptible(osb->checkpoint_event,
2311 status = ocfs2_commit_cache(osb);
2343 int ocfs2_check_journals_nolocks(struct ocfs2_super *osb)
2351 for(slot = 0; slot < osb->max_slots; slot++) {
2352 ret = ocfs2_read_journal_inode(osb, slot, &di_bh, NULL);
2360 osb->slot_recovery_generations[slot] =