32 journal->j_commit_request =
target;
33 jbd_debug(1,
"JBD: requesting commit %d/%d\n",
34 journal->j_commit_request,
35 journal->j_commit_sequence);
36 wake_up(&journal->j_wait_commit);
46 jbd_lock(&journal->j_state_lock);
48 jbd_unlock(&journal->j_state_lock);
69 if (journal->j_flags & JFS_ABORT)
72 jbd_lock(&journal->j_state_lock);
73 journal->j_flags |= JFS_ABORT;
74 transaction = journal->j_running_transaction;
77 jbd_unlock(&journal->j_state_lock);
84 if (journal->j_flags & JFS_ABORT)
87 if (!journal->j_errno)
88 journal->j_errno =
err;
163 jbd_lock(&journal->j_state_lock);
164 if (journal->j_flags & JFS_ABORT)
167 err = journal->j_errno;
168 jbd_unlock(&journal->j_state_lock);
183 jbd_lock(&journal->j_state_lock);
184 if (journal->j_flags & JFS_ABORT)
187 journal->j_errno = 0;
188 jbd_unlock(&journal->j_state_lock);
201 jbd_lock(&journal->j_state_lock);
202 if (journal->j_errno)
203 journal->j_flags |= JFS_ACK_ERR;
204 jbd_unlock(&journal->j_state_lock);
217#ifdef CONFIG_JBD_DEBUG
252 static unsigned long last_warning;
254#ifdef CONFIG_JBD_DEBUG
259 jbd_debug(1,
"out of memory for journal_head\n");
275#ifdef CONFIG_JBD_DEBUG
277 memset(jh, JBD_POISON_FREE,
sizeof(*jh));
331 if (!buffer_jbd(bh)) {
333 memset(new_jh, 0,
sizeof(*new_jh));
336 jbd_lock_bh_journal_head(bh);
337 if (buffer_jbd(bh)) {
345 jbd_unlock_bh_journal_head(bh);
355 BUFFER_TRACE(bh,
"added journal_head");
358 jbd_unlock_bh_journal_head(bh);
372 jbd_lock_bh_journal_head(bh);
373 if (buffer_jbd(bh)) {
377 jbd_unlock_bh_journal_head(bh);
393 J_ASSERT_BH(bh, buffer_jbd(bh));
394 J_ASSERT_BH(bh, jh2bh(jh) == bh);
395 BUFFER_TRACE(bh,
"remove journal_head");
404 "b_committed_data\n",
410 clear_buffer_jbd(bh);
414 BUFFER_TRACE(bh,
"journal_head was locked");
434 jbd_lock_bh_journal_head(bh);
436 jbd_unlock_bh_journal_head(bh);
447 jbd_lock_bh_journal_head(bh);
454 jbd_unlock_bh_journal_head(bh);
463 unsigned long blocknr;
465 jbd_lock(&journal->j_state_lock);
466 J_ASSERT(journal->j_free > 1);
468 blocknr = journal->j_head;
471 if (journal->j_head == journal->j_last)
472 journal->j_head = journal->j_first;
473 jbd_unlock(&journal->j_state_lock);
490 if (journal->j_inode) {
496 "at offset %lu ...\n",
521 unsigned long blocknr;
529 bh =
__getblk(journal->j_dev, blocknr, journal->j_blocksize);
532 set_buffer_uptodate(bh);
534 BUFFER_TRACE(bh,
"return this buffer");
564 jbd_lock_init(&journal->j_revoke_lock);
565 jbd_lock_init(&journal->j_list_lock);
566 jbd_lock_init(&journal->j_state_lock);
568 journal->j_commit_interval = (
HZ * JBD_DEFAULT_MAX_COMMIT_AGE);
571 journal->j_flags = JFS_ABORT;
598 unsigned long blocknr;
603 journal->j_dev = journal->j_fs_dev =
inode->
i_sb->s_bdev;
604 journal->j_inode =
inode;
606 "journal %p: inode %s/%ld, size %Ld, bits %d, blksize %ld\n",
612 journal->j_blocksize =
inode->
i_sb->s_blocksize;
616 journal->j_wbufsize =
n;
618 if (!journal->j_wbuf) {
622 J_ASSERT(journal->j_revoke !=
NULL);
623 if (journal->j_revoke)
636 J_ASSERT(journal->j_revoke !=
NULL);
637 if (journal->j_revoke)
639 J_ASSERT(journal->j_wbuf !=
NULL);
640 kfree(journal->j_wbuf);
645 bh =
__getblk(journal->j_dev, blocknr, journal->j_blocksize);
646 J_ASSERT(bh !=
NULL);
647 journal->j_sb_buffer = bh;
664 if (journal->j_sb_buffer) {
666 brelse(journal->j_sb_buffer);
667 journal->j_sb_buffer =
NULL;
682 journal_kill_thread(journal);
685 if (journal->j_running_transaction)
686 journal_commit_transaction(journal);
691 jbd_lock(&journal->j_list_lock);
692 while (journal->j_checkpoint_transactions !=
NULL) {
693 jbd_unlock(&journal->j_list_lock);
694 log_do_checkpoint(journal);
695 jbd_lock(&journal->j_list_lock);
698 J_ASSERT(journal->j_running_transaction ==
NULL);
699 J_ASSERT(journal->j_committing_transaction ==
NULL);
700 J_ASSERT(journal->j_checkpoint_transactions ==
NULL);
701 jbd_unlock(&journal->j_list_lock);
705 journal->j_tail_sequence = ++journal->j_transaction_sequence;
706 if (journal->j_sb_buffer) {
708 brelse(journal->j_sb_buffer);
712 if (journal->j_sb_buffer) {
713 brelse(journal->j_sb_buffer);
715 if (journal->j_inode)
716 iput(journal->j_inode);
717 if (journal->j_revoke)
719 kfree(journal->j_wbuf);
737 unsigned long ro,
unsigned long incompat)
741 if (!compat && !ro && !incompat)
743 if (journal->j_format_version == 1)
746 sb = journal->j_superblock;
748 if (((
be32_to_cpu(
sb->s_feature_compat) & compat) == compat) &&
750 ((
be32_to_cpu(
sb->s_feature_incompat) & incompat) == incompat))
768 unsigned long ro,
unsigned long incompat)
772 if (!compat && !ro && !incompat)
775 sb = journal->j_superblock;
781 if (journal->j_format_version != 2)
805 unsigned long ro,
unsigned long incompat)
815 jbd_debug(1,
"Setting new features 0x%lx/0x%lx/0x%lx\n",
816 compat, ro, incompat);
818 sb = journal->j_superblock;
834 "JBD: Converting superblock from version 1 to 2.\n");
843 journal->j_format_version = 2;
845 bh = journal->j_sb_buffer;
846 BUFFER_TRACE(bh,
"marking dirty");
862 journal->j_sb_buffer =
NULL;
877 bh = journal->j_sb_buffer;
879 J_ASSERT(bh !=
NULL);
880 if (!buffer_uptodate(bh)) {
883 if (!buffer_uptodate(bh)) {
885 "JBD: IO error reading journal superblock\n");
890 sb = journal->j_superblock;
902 journal->j_format_version = 1;
905 journal->j_format_version = 2;
940 sb = journal->j_superblock;
969 J_ASSERT (!(journal->j_flags & JFS_LOADED));
975 sb = journal->j_superblock;
977 if (!journal->j_tail)
981 write ?
"Clearing" :
"Ignoring");
1008 sb = journal->j_superblock;
1042 if (
sb->s_start == 0 && journal->j_tail_sequence ==
1043 journal->j_transaction_sequence) {
1044 jbd_debug(1,
"JBD: Skipping superblock update on recovered sb "
1045 "(start %ld, seq %d, errno %d)\n",
1046 journal->j_tail, journal->j_tail_sequence,
1051 jbd_lock(&journal->j_state_lock);
1052 jbd_debug(1,
"JBD: updating superblock (start %ld, seq %d, errno %d)\n",
1053 journal->j_tail, journal->j_tail_sequence, journal->j_errno);
1058 jbd_unlock(&journal->j_state_lock);
1060 BUFFER_TRACE(bh,
"marking dirty");
1072 jbd_lock(&journal->j_state_lock);
1074 journal->j_flags &= ~JFS_FLUSHED;
1076 journal->j_flags |= JFS_FLUSHED;
1077 jbd_unlock(&journal->j_state_lock);
1095 journal->j_first =
first;
1096 journal->j_last =
last;
1098 journal->j_head =
first;
1099 journal->j_tail =
first;
1102 journal->j_tail_sequence = journal->j_transaction_sequence;
1103 journal->j_commit_sequence = journal->j_transaction_sequence - 1;
1104 journal->j_commit_request = journal->j_commit_sequence;
1106 journal->j_max_transaction_buffers = journal->j_maxlen / 4;
1130 sb = journal->j_superblock;
1134 if (journal->j_format_version >= 2) {
1135 if ((
sb->s_feature_ro_compat &
1137 (
sb->s_feature_incompat &
1140 "JBD: Unrecognised features on journal\n");
1148 goto recovery_error;
1154 goto recovery_error;
1156 journal->j_flags &= ~JFS_ABORT;
1157 journal->j_flags |= JFS_LOADED;
1240 J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
1243 assert_jbd_locked(&transaction->t_journal->j_list_lock);
1247 J_ASSERT_JH(jh, transaction !=
NULL);
1253 list = &transaction->t_sync_datalist;
1256 transaction->t_nr_buffers--;
1257 J_ASSERT_JH(jh, transaction->t_nr_buffers >= 0);
1258 list = &transaction->t_buffers;
1261 list = &transaction->t_forget;
1264 list = &transaction->t_iobuf_list;
1267 list = &transaction->t_shadow_list;
1270 list = &transaction->t_log_list;
1273 list = &transaction->t_reserved_list;
1276 list = &transaction->t_locked_list;
1282 if (test_clear_buffer_jbddirty(bh))
1294 jbd_lock_bh_state(jh2bh(jh));
1295 jbd_lock(&journal->j_list_lock);
1297 jbd_unlock(&journal->j_list_lock);
1298 jbd_unlock_bh_state(jh2bh(jh));
1321 JBUFFER_TRACE(jh,
"on running+cp transaction");
1323 clear_buffer_jbddirty(bh);
1326 JBUFFER_TRACE(jh,
"on running transaction");
1344 J_ASSERT_JH(jh, jbd_is_locked_bh_state(bh));
1345 assert_jbd_locked(&transaction->t_journal->j_list_lock);
1360 if (test_clear_buffer_dirty(bh) ||
1361 test_clear_buffer_jbddirty(bh))
1375 list = &transaction->t_sync_datalist;
1378 transaction->t_nr_buffers++;
1379 list = &transaction->t_buffers;
1382 list = &transaction->t_forget;
1385 list = &transaction->t_iobuf_list;
1388 list = &transaction->t_shadow_list;
1391 list = &transaction->t_log_list;
1394 list = &transaction->t_reserved_list;
1397 list = &transaction->t_locked_list;
1405 set_buffer_jbddirty(bh);
1411 jbd_lock_bh_state(jh2bh(jh));
1412 jbd_lock(&transaction->t_journal->j_list_lock);
1414 jbd_unlock(&transaction->t_journal->j_list_lock);
1415 jbd_unlock_bh_state(jh2bh(jh));
1427 BUFFER_TRACE(bh,
"entry");
1450 journal_t *journal = transaction->t_journal;
1452 int drop_reserve = 0;
1455 BUFFER_TRACE(bh,
"entry");
1457 jbd_lock_bh_state(bh);
1458 jbd_lock(&journal->j_list_lock);
1460 if (!buffer_jbd(bh))
1467 "inconsistent data on disk")) {
1484 clear_buffer_dirty(bh);
1485 clear_buffer_jbddirty(bh);
1487 JBUFFER_TRACE(jh,
"belongs to current transaction: unfile");
1510 if (!buffer_jbd(bh)) {
1511 jbd_unlock(&journal->j_list_lock);
1512 jbd_unlock_bh_state(bh);
1519 journal->j_committing_transaction));
1522 JBUFFER_TRACE(jh,
"belongs to older transaction");
1534 jbd_unlock(&journal->j_list_lock);
1535 jbd_unlock_bh_state(bh);
1540 handle->h_buffer_credits++;
1548#ifdef CONFIG_JBD_DEBUG
1550u8 journal_enable_debug __read_mostly;
1553static struct dentry *jbd_debugfs_dir;
1554static struct dentry *jbd_debug;
1558 jbd_debugfs_dir = debugfs_create_dir(
"jbd",
NULL);
1559 if (jbd_debugfs_dir)
1560 jbd_debug = debugfs_create_u8(
"jbd-debug",
S_IRUGO,
1562 &journal_enable_debug);
1567 debugfs_remove(jbd_debug);
1568 debugfs_remove(jbd_debugfs_dir);
1643#ifdef CONFIG_JBD_DEBUG
static void atomic_inc(atomic_t volatile *v)
static void atomic_dec(atomic_t volatile *v)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
void iput(struct inode *inode)
ULONGLONG bmap(struct inode *i, ULONGLONG b)
unsigned __int64 sector_t
int journal_skip_recovery(journal_t *journal)
int journal_recover(journal_t *journal)
#define JFS_SUPERBLOCK_V1
struct journal_block_tag_s journal_block_tag_t
#define JFS_SUPERBLOCK_V2
#define JFS_KNOWN_ROCOMPAT_FEATURES
#define JFS_KNOWN_COMPAT_FEATURES
static int tid_geq(tid_t x, tid_t y)
#define JFS_KNOWN_INCOMPAT_FEATURES
struct transaction_s transaction_t
void __bforget(struct buffer_head *)
kmem_cache_t * kmem_cache_create(const char *name, size_t size, size_t offset, unsigned long flags, kmem_cache_cb_t ctor)
#define kmalloc(size, gfp)
static void lock_buffer(struct buffer_head *bh)
void kmem_cache_free(kmem_cache_t *kc, void *p)
void unlock_buffer(struct buffer_head *bh)
#define MODULE_LICENSE(x)
struct buffer_head * __getblk(struct block_device *bdev, sector_t block, unsigned long size)
void * kmem_cache_alloc(kmem_cache_t *kc, int flags)
int kmem_cache_destroy(kmem_cache_t *kc)
static void get_bh(struct buffer_head *bh)
void * kzalloc(int size, int flags)
static void wait_on_buffer(struct buffer_head *bh)
int wake_up(wait_queue_head_t *queue)
int sync_dirty_buffer(struct buffer_head *bh)
void ll_rw_block(int, int, struct buffer_head *bh[])
void init_waitqueue_head(wait_queue_head_t *q)
static void brelse(struct buffer_head *bh)
void __brelse(struct buffer_head *)
void mark_buffer_dirty(struct buffer_head *bh)
static void __journal_remove_journal_head(struct buffer_head *bh)
static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction)
int __log_start_commit(journal_t *journal, tid_t target)
struct journal_head * journal_grab_journal_head(struct buffer_head *bh)
struct journal_head * journal_get_descriptor_buffer(journal_t *journal)
struct journal_head * journal_add_journal_head(struct buffer_head *bh)
static int journal_init_journal_head_cache(void)
int journal_load(journal_t *journal)
static void __journal_abort_soft(journal_t *journal, int err)
int journal_set_features(journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
journal_t * journal_init_inode(struct inode *inode)
int journal_forget(handle_t *handle, struct buffer_head *bh)
int journal_bmap(journal_t *journal, unsigned long blocknr, unsigned long *retp)
static void __journal_abort_hard(journal_t *journal)
static void jbd_create_debugfs_entry(void)
static int load_superblock(journal_t *journal)
static void journal_destroy_caches(void)
int journal_clear_err(journal_t *journal)
static void __journal_temp_unlink_buffer(struct journal_head *jh)
static void __exit journal_exit(void)
static struct kmem_cache * journal_head_cache
void journal_file_buffer(struct journal_head *jh, transaction_t *transaction, int jlist)
void journal_release_buffer(handle_t *handle, struct buffer_head *bh)
void journal_unfile_buffer(journal_t *journal, struct journal_head *jh)
static void journal_destroy_handle_cache(void)
static int journal_convert_superblock_v1(journal_t *journal, journal_superblock_t *sb)
int journal_update_format(journal_t *journal)
static void __blist_add_buffer(struct journal_head **list, struct journal_head *jh)
int journal_next_log_block(journal_t *journal, unsigned long *retp)
static void __blist_del_buffer(struct journal_head **list, struct journal_head *jh)
static int journal_reset(journal_t *journal)
static struct journal_head * journal_alloc_journal_head(void)
struct kmem_cache * jbd_handle_cache
int log_start_commit(journal_t *journal, tid_t tid)
void journal_update_superblock(journal_t *journal, int wait)
static int __init journal_init_handle_cache(void)
static int __init journal_init_caches(void)
void journal_put_journal_head(struct journal_head *jh)
int journal_check_available_features(journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
void journal_wipe_recovery(journal_t *journal)
static void journal_destroy_journal_head_cache(void)
void __journal_file_buffer(struct journal_head *jh, transaction_t *transaction, int jlist)
void journal_ack_err(journal_t *journal)
int journal_wipe(journal_t *journal, int write)
static void journal_free_journal_head(struct journal_head *jh)
void journal_remove_journal_head(struct buffer_head *bh)
static int journal_get_superblock(journal_t *journal)
int journal_errno(journal_t *journal)
static void jbd_remove_debugfs_entry(void)
static void journal_fail_superblock(journal_t *journal)
void journal_destroy(journal_t *journal)
static journal_t * journal_init_common(void)
static int __init journal_init(void)
void __journal_unfile_buffer(struct journal_head *jh)
int journal_check_used_features(journal_t *journal, unsigned long compat, unsigned long ro, unsigned long incompat)
void journal_abort(journal_t *journal, int err)
int journal_blocks_per_page(struct inode *inode)
void journal_destroy_revoke_caches(void)
void journal_destroy_revoke(journal_t *journal)
int __init journal_init_revoke_caches(void)
int journal_init_revoke(journal_t *journal, int hash_size)
struct super_block * i_sb
transaction_t * b_next_transaction
transaction_t * b_cp_transaction
transaction_t * b_transaction
struct journal_head * b_tprev
struct buffer_head * b_bh
struct journal_head * b_tnext
#define READ(_gif, _buf, _len)