#include <linux/suspend.h>
#include <linux/pagemap.h>
#include <asm/uaccess.h>
+#include <asm/page.h>
#include <linux/proc_fs.h>
EXPORT_SYMBOL(journal_start);
#endif
EXPORT_SYMBOL(journal_flush);
EXPORT_SYMBOL(journal_revoke);
-EXPORT_SYMBOL(journal_callback_set);
EXPORT_SYMBOL(journal_init_dev);
EXPORT_SYMBOL(journal_init_inode);
EXPORT_SYMBOL(journal_clear_err);
EXPORT_SYMBOL(log_wait_commit);
EXPORT_SYMBOL(journal_start_commit);
+EXPORT_SYMBOL(journal_force_commit_nested);
EXPORT_SYMBOL(journal_wipe);
EXPORT_SYMBOL(journal_blocks_per_page);
EXPORT_SYMBOL(journal_invalidatepage);
EXPORT_SYMBOL(journal_try_to_free_buffers);
-EXPORT_SYMBOL(journal_bmap);
EXPORT_SYMBOL(journal_force_commit);
static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *);
spin_lock(&journal->j_state_lock);
loop:
+ if (journal->j_flags & JFS_UNMOUNT)
+ goto end_loop;
+
jbd_debug(1, "commit_sequence=%d, commit_request=%d\n",
journal->j_commit_sequence, journal->j_commit_request);
del_timer_sync(journal->j_commit_timer);
journal_commit_transaction(journal);
spin_lock(&journal->j_state_lock);
- goto end_loop;
+ goto loop;
}
wake_up(&journal->j_wait_done_commit);
journal->j_commit_request = transaction->t_tid;
jbd_debug(1, "woke because of timeout\n");
}
-end_loop:
- if (!(journal->j_flags & JFS_UNMOUNT))
- goto loop;
+ goto loop;
+end_loop:
spin_unlock(&journal->j_state_lock);
del_timer_sync(journal->j_commit_timer);
journal->j_task = NULL;
/*
* Check for escaping
*/
- if (*((unsigned int *)(mapped_data + new_offset)) ==
- htonl(JFS_MAGIC_NUMBER)) {
+ if (*((__be32 *)(mapped_data + new_offset)) ==
+ cpu_to_be32(JFS_MAGIC_NUMBER)) {
need_copy_out = 1;
do_escape = 1;
}
return ret;
}
+/*
+ * Force and wait upon a commit if the calling process is not within
+ * transaction. This is used for forcing out undo-protected data which contains
+ * bitmaps, when the fs is running out of space.
+ *
+ * We can only force the running transaction if we don't have an active handle;
+ * otherwise, we will deadlock.
+ *
+ * Returns true if a transaction was started.
+ */
+int journal_force_commit_nested(journal_t *journal)
+{
+ transaction_t *transaction = NULL;
+ tid_t tid;
+
+ spin_lock(&journal->j_state_lock);
+ if (journal->j_running_transaction && !current->journal_info) {
+ transaction = journal->j_running_transaction;
+ __log_start_commit(journal, transaction->t_tid);
+ } else if (journal->j_committing_transaction)
+ transaction = journal->j_committing_transaction;
+
+ if (!transaction) {
+ spin_unlock(&journal->j_state_lock);
+ return 0; /* Nothing to retry */
+ }
+
+ tid = transaction->t_tid;
+ spin_unlock(&journal->j_state_lock);
+ log_wait_commit(journal, tid);
+ return 1;
+}
+
/*
* Start a commit of the current running transaction (if any). Returns true
* if a transaction was started, and fills its tid in at *ptid
journal_superblock_t *sb = journal->j_superblock;
unsigned int first, last;
- first = ntohl(sb->s_first);
- last = ntohl(sb->s_maxlen);
+ first = be32_to_cpu(sb->s_first);
+ last = be32_to_cpu(sb->s_maxlen);
journal->j_first = first;
journal->j_last = last;
/* OK, fill in the initial static fields in the new superblock */
sb = journal->j_superblock;
- sb->s_header.h_magic = htonl(JFS_MAGIC_NUMBER);
- sb->s_header.h_blocktype = htonl(JFS_SUPERBLOCK_V2);
+ sb->s_header.h_magic = cpu_to_be32(JFS_MAGIC_NUMBER);
+ sb->s_header.h_blocktype = cpu_to_be32(JFS_SUPERBLOCK_V2);
- sb->s_blocksize = htonl(journal->j_blocksize);
- sb->s_maxlen = htonl(journal->j_maxlen);
- sb->s_first = htonl(1);
+ sb->s_blocksize = cpu_to_be32(journal->j_blocksize);
+ sb->s_maxlen = cpu_to_be32(journal->j_maxlen);
+ sb->s_first = cpu_to_be32(1);
journal->j_transaction_sequence = 1;
jbd_debug(1,"JBD: updating superblock (start %ld, seq %d, errno %d)\n",
journal->j_tail, journal->j_tail_sequence, journal->j_errno);
- sb->s_sequence = htonl(journal->j_tail_sequence);
- sb->s_start = htonl(journal->j_tail);
- sb->s_errno = htonl(journal->j_errno);
+ sb->s_sequence = cpu_to_be32(journal->j_tail_sequence);
+ sb->s_start = cpu_to_be32(journal->j_tail);
+ sb->s_errno = cpu_to_be32(journal->j_errno);
spin_unlock(&journal->j_state_lock);
BUFFER_TRACE(bh, "marking dirty");
err = -EINVAL;
- if (sb->s_header.h_magic != htonl(JFS_MAGIC_NUMBER) ||
- sb->s_blocksize != htonl(journal->j_blocksize)) {
+ if (sb->s_header.h_magic != cpu_to_be32(JFS_MAGIC_NUMBER) ||
+ sb->s_blocksize != cpu_to_be32(journal->j_blocksize)) {
printk(KERN_WARNING "JBD: no valid journal superblock found\n");
goto out;
}
- switch(ntohl(sb->s_header.h_blocktype)) {
+ switch(be32_to_cpu(sb->s_header.h_blocktype)) {
case JFS_SUPERBLOCK_V1:
journal->j_format_version = 1;
break;
goto out;
}
- if (ntohl(sb->s_maxlen) < journal->j_maxlen)
- journal->j_maxlen = ntohl(sb->s_maxlen);
- else if (ntohl(sb->s_maxlen) > journal->j_maxlen) {
+ if (be32_to_cpu(sb->s_maxlen) < journal->j_maxlen)
+ journal->j_maxlen = be32_to_cpu(sb->s_maxlen);
+ else if (be32_to_cpu(sb->s_maxlen) > journal->j_maxlen) {
printk (KERN_WARNING "JBD: journal file too short\n");
goto out;
}
sb = journal->j_superblock;
- journal->j_tail_sequence = ntohl(sb->s_sequence);
- journal->j_tail = ntohl(sb->s_start);
- journal->j_first = ntohl(sb->s_first);
- journal->j_last = ntohl(sb->s_maxlen);
- journal->j_errno = ntohl(sb->s_errno);
+ journal->j_tail_sequence = be32_to_cpu(sb->s_sequence);
+ journal->j_tail = be32_to_cpu(sb->s_start);
+ journal->j_first = be32_to_cpu(sb->s_first);
+ journal->j_last = be32_to_cpu(sb->s_maxlen);
+ journal->j_errno = be32_to_cpu(sb->s_errno);
return 0;
}
sb = journal->j_superblock;
- switch (ntohl(sb->s_header.h_blocktype)) {
+ switch (be32_to_cpu(sb->s_header.h_blocktype)) {
case JFS_SUPERBLOCK_V2:
return 0;
case JFS_SUPERBLOCK_V1:
/* Pre-initialise new fields to zero */
offset = ((char *) &(sb->s_feature_compat)) - ((char *) sb);
- blocksize = ntohl(sb->s_blocksize);
+ blocksize = be32_to_cpu(sb->s_blocksize);
memset(&sb->s_feature_compat, 0, blocksize-offset);
sb->s_nr_users = cpu_to_be32(1);
{
J_ASSERT(journal_head_cache != NULL);
kmem_cache_destroy(journal_head_cache);
- journal_head_cache = 0;
+ journal_head_cache = NULL;
}
/*