]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/ocfs2/journal.c
Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc
[linux-2.6-omap-h63xx.git] / fs / ocfs2 / journal.c
index 1d7f4ab1e5ede4b362a5e8f2bcd4523269c5a456..dbfb20bb27ea426e57ff71b031f247de699f1ff7 100644 (file)
@@ -144,8 +144,10 @@ handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs)
                        ocfs2_abort(osb->sb, "Detected aborted journal");
                        handle = ERR_PTR(-EROFS);
                }
-       } else
-               atomic_inc(&(osb->journal->j_num_trans));
+       } else {
+               if (!ocfs2_mount_local(osb))
+                       atomic_inc(&(osb->journal->j_num_trans));
+       }
 
        return handle;
 }
@@ -433,7 +435,8 @@ static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb,
                 * handle the errors in a specific manner, so no need
                 * to call ocfs2_error() here. */
                mlog(ML_ERROR, "Journal dinode %llu  has invalid "
-                    "signature: %.*s", (unsigned long long)fe->i_blkno, 7,
+                    "signature: %.*s",
+                    (unsigned long long)le64_to_cpu(fe->i_blkno), 7,
                     fe->i_signature);
                status = -EIO;
                goto out;
@@ -507,9 +510,23 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
 
        BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0);
 
-       status = ocfs2_journal_toggle_dirty(osb, 0);
-       if (status < 0)
-               mlog_errno(status);
+       if (ocfs2_mount_local(osb)) {
+               journal_lock_updates(journal->j_journal);
+               status = journal_flush(journal->j_journal);
+               journal_unlock_updates(journal->j_journal);
+               if (status < 0)
+                       mlog_errno(status);
+       }
+
+       if (status == 0) {
+               /*
+                * Do not toggle if flush was unsuccessful otherwise
+                * will leave dirty metadata in a "clean" journal
+                */
+               status = ocfs2_journal_toggle_dirty(osb, 0);
+               if (status < 0)
+                       mlog_errno(status);
+       }
 
        /* Shutdown the kernel journal system */
        journal_destroy(journal->j_journal);
@@ -549,7 +566,7 @@ static void ocfs2_clear_journal_error(struct super_block *sb,
        }
 }
 
-int ocfs2_journal_load(struct ocfs2_journal *journal)
+int ocfs2_journal_load(struct ocfs2_journal *journal, int local)
 {
        int status = 0;
        struct ocfs2_super *osb;
@@ -576,14 +593,18 @@ int ocfs2_journal_load(struct ocfs2_journal *journal)
        }
 
        /* Launch the commit thread */
-       osb->commit_task = kthread_run(ocfs2_commit_thread, osb, "ocfs2cmt");
-       if (IS_ERR(osb->commit_task)) {
-               status = PTR_ERR(osb->commit_task);
+       if (!local) {
+               osb->commit_task = kthread_run(ocfs2_commit_thread, osb,
+                                              "ocfs2cmt");
+               if (IS_ERR(osb->commit_task)) {
+                       status = PTR_ERR(osb->commit_task);
+                       osb->commit_task = NULL;
+                       mlog(ML_ERROR, "unable to launch ocfs2commit thread, "
+                            "error=%d", status);
+                       goto done;
+               }
+       } else
                osb->commit_task = NULL;
-               mlog(ML_ERROR, "unable to launch ocfs2commit thread, error=%d",
-                    status);
-               goto done;
-       }
 
 done:
        mlog_exit(status);
@@ -629,29 +650,20 @@ bail:
 static int ocfs2_force_read_journal(struct inode *inode)
 {
        int status = 0;
-       int i, p_blocks;
-       u64 v_blkno, p_blkno;
-#define CONCURRENT_JOURNAL_FILL 32
+       int i;
+       u64 v_blkno, p_blkno, p_blocks, num_blocks;
+#define CONCURRENT_JOURNAL_FILL 32ULL
        struct buffer_head *bhs[CONCURRENT_JOURNAL_FILL];
 
        mlog_entry_void();
 
-       BUG_ON(inode->i_blocks !=
-                    ocfs2_align_bytes_to_sectors(i_size_read(inode)));
-
        memset(bhs, 0, sizeof(struct buffer_head *) * CONCURRENT_JOURNAL_FILL);
 
-       mlog(0, "Force reading %llu blocks\n",
-               (unsigned long long)(inode->i_blocks >>
-                       (inode->i_sb->s_blocksize_bits - 9)));
-
+       num_blocks = ocfs2_blocks_for_bytes(inode->i_sb, inode->i_size);
        v_blkno = 0;
-       while (v_blkno <
-              (inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9))) {
-
+       while (v_blkno < num_blocks) {
                status = ocfs2_extent_map_get_blocks(inode, v_blkno,
-                                                    1, &p_blkno,
-                                                    &p_blocks);
+                                                    &p_blkno, &p_blocks, NULL);
                if (status < 0) {
                        mlog_errno(status);
                        goto bail;
@@ -710,8 +722,7 @@ void ocfs2_complete_recovery(struct work_struct *work)
                container_of(work, struct ocfs2_journal, j_recovery_work);
        struct ocfs2_super *osb = journal->j_osb;
        struct ocfs2_dinode *la_dinode, *tl_dinode;
-       struct ocfs2_la_recovery_item *item;
-       struct list_head *p, *n;
+       struct ocfs2_la_recovery_item *item, *n;
        LIST_HEAD(tmp_la_list);
 
        mlog_entry_void();
@@ -722,8 +733,7 @@ void ocfs2_complete_recovery(struct work_struct *work)
        list_splice_init(&journal->j_la_cleanups, &tmp_la_list);
        spin_unlock(&journal->j_lock);
 
-       list_for_each_safe(p, n, &tmp_la_list) {
-               item = list_entry(p, struct ocfs2_la_recovery_item, lri_list);
+       list_for_each_entry_safe(item, n, &tmp_la_list, lri_list) {
                list_del_init(&item->lri_list);
 
                mlog(0, "Complete recovery for slot %d\n", item->lri_slot);
@@ -731,7 +741,7 @@ void ocfs2_complete_recovery(struct work_struct *work)
                la_dinode = item->lri_la_dinode;
                if (la_dinode) {
                        mlog(0, "Clean up local alloc %llu\n",
-                            (unsigned long long)la_dinode->i_blkno);
+                            (unsigned long long)le64_to_cpu(la_dinode->i_blkno));
 
                        ret = ocfs2_complete_local_alloc_recovery(osb,
                                                                  la_dinode);
@@ -744,7 +754,7 @@ void ocfs2_complete_recovery(struct work_struct *work)
                tl_dinode = item->lri_tl_dinode;
                if (tl_dinode) {
                        mlog(0, "Clean up truncate log %llu\n",
-                            (unsigned long long)tl_dinode->i_blkno);
+                            (unsigned long long)le64_to_cpu(tl_dinode->i_blkno));
 
                        ret = ocfs2_complete_truncate_log_recovery(osb,
                                                                   tl_dinode);
@@ -1286,7 +1296,7 @@ static int ocfs2_queue_orphans(struct ocfs2_super *osb,
                                continue;
 
                        iter = ocfs2_iget(osb, le64_to_cpu(de->inode),
-                                         OCFS2_FI_FLAG_NOLOCK);
+                                         OCFS2_FI_FLAG_ORPHAN_RECOVERY);
                        if (IS_ERR(iter))
                                continue;
 
@@ -1398,7 +1408,6 @@ static int ocfs2_recover_orphans(struct ocfs2_super *osb,
                /* Set the proper information to get us going into
                 * ocfs2_delete_inode. */
                oi->ip_flags |= OCFS2_INODE_MAYBE_ORPHANED;
-               oi->ip_orphaned_slot = slot;
                spin_unlock(&oi->ip_lock);
 
                iput(inode);