ocfs2: Fix extent lookup to return true size of holes
[deliverable/linux.git] / fs / ocfs2 / journal.c
index 1d7f4ab1e5ede4b362a5e8f2bcd4523269c5a456..12d2340eee29ebf1761c2ed93df6ebe3bebd435c 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;
 }
@@ -507,9 +509,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 +565,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 +592,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,9 +649,9 @@ 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;
+#define CONCURRENT_JOURNAL_FILL 32ULL
        struct buffer_head *bhs[CONCURRENT_JOURNAL_FILL];
 
        mlog_entry_void();
@@ -650,8 +670,7 @@ static int ocfs2_force_read_journal(struct inode *inode)
               (inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9))) {
 
                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;
@@ -1286,7 +1305,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 +1417,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);
This page took 0.025425 seconds and 5 git commands to generate.