25 #include <linux/module.h>
26 #include <linux/time.h>
29 #include <linux/errno.h>
30 #include <linux/slab.h>
36 #include <linux/poison.h>
41 #include <linux/hash.h>
45 #include <linux/bitops.h>
48 #define CREATE_TRACE_POINTS
51 #include <asm/uaccess.h>
97 static void __journal_abort_soft (journal_t *journal,
int errno);
98 static int jbd2_journal_create_slab(
size_t slab_size);
126 return sb->
s_checksum == jbd2_superblock_csum(j, sb);
141 static void commit_timeout(
unsigned long __data)
164 static int kjournald2(
void *
arg)
166 journal_t *journal =
arg;
173 setup_timer(&journal->j_commit_timer, commit_timeout,
180 wake_up(&journal->j_wait_done_commit);
188 if (journal->j_flags & JBD2_UNMOUNT)
191 jbd_debug(1,
"commit_sequence=%d, commit_request=%d\n",
192 journal->j_commit_sequence, journal->j_commit_request);
194 if (journal->j_commit_sequence != journal->j_commit_request) {
203 wake_up(&journal->j_wait_done_commit);
210 jbd_debug(1,
"Now suspending kjournald2\n");
220 int should_sleep = 1;
224 if (journal->j_commit_sequence != journal->j_commit_request)
226 transaction = journal->j_running_transaction;
228 transaction->t_expires))
230 if (journal->j_flags & JBD2_UNMOUNT)
245 transaction = journal->j_running_transaction;
246 if (transaction &&
time_after_eq(jiffies, transaction->t_expires)) {
247 journal->j_commit_request = transaction->t_tid;
248 jbd_debug(1,
"woke because of timeout\n");
255 journal->j_task =
NULL;
256 wake_up(&journal->j_wait_done_commit);
257 jbd_debug(1,
"Journal thread exiting.\n");
261 static int jbd2_journal_start_thread(journal_t *journal)
274 static void journal_kill_thread(journal_t *journal)
277 journal->j_flags |= JBD2_UNMOUNT;
279 while (journal->j_task) {
280 wake_up(&journal->j_wait_commit);
330 int need_copy_out = 0;
331 int done_copy_out = 0;
334 struct buffer_head *new_bh;
336 struct page *new_page;
337 unsigned int new_offset;
338 struct buffer_head *bh_in = jh2bh(jh_in);
339 journal_t *journal = transaction->t_journal;
350 J_ASSERT_BH(bh_in, buffer_jbddirty(bh_in));
373 jbd_lock_bh_state(bh_in);
380 new_page = jh2bh(jh_in)->b_page;
398 if (*((
__be32 *)(mapped_data + new_offset)) ==
408 if (need_copy_out && !done_copy_out) {
411 jbd_unlock_bh_state(bh_in);
417 jbd_lock_bh_state(bh_in);
425 memcpy(tmp, mapped_data + new_offset, jh2bh(jh_in)->b_size);
446 *((
unsigned int *)(mapped_data + new_offset)) = 0;
452 new_bh->b_size = jh2bh(jh_in)->b_size;
453 new_bh->b_bdev = transaction->t_journal->j_dev;
455 set_buffer_mapped(new_bh);
456 set_buffer_dirty(new_bh);
465 JBUFFER_TRACE(jh_in,
"file as BJ_Shadow");
466 spin_lock(&journal->j_list_lock);
468 spin_unlock(&journal->j_list_lock);
469 jbd_unlock_bh_state(bh_in);
471 JBUFFER_TRACE(new_jh,
"file as BJ_IO");
474 return do_escape | (done_copy_out << 1);
492 int left = journal->j_free;
501 #define MIN_LOG_RESERVED_BLOCKS 32
522 if (journal->j_running_transaction &&
523 journal->j_running_transaction->t_tid == target) {
529 journal->j_commit_request =
target;
530 jbd_debug(1,
"JBD2: requesting commit %d/%d\n",
531 journal->j_commit_request,
532 journal->j_commit_sequence);
533 wake_up(&journal->j_wait_commit);
535 }
else if (!tid_geq(journal->j_commit_request, target))
539 WARN_ONCE(1,
"JBD2: bad log_start_commit: %u %u %u %u\n",
540 journal->j_commit_request,
541 journal->j_commit_sequence,
542 target, journal->j_running_transaction ?
543 journal->j_running_transaction->t_tid : 0);
571 int need_to_start = 0;
574 if (journal->j_running_transaction && !
current->journal_info) {
575 transaction = journal->j_running_transaction;
576 if (!tid_geq(journal->j_commit_request, transaction->t_tid))
578 }
else if (journal->j_committing_transaction)
579 transaction = journal->j_committing_transaction;
586 tid = transaction->t_tid;
604 if (journal->j_running_transaction) {
605 tid_t tid = journal->j_running_transaction->t_tid;
613 }
else if (journal->j_committing_transaction) {
619 *ptid = journal->j_committing_transaction->t_tid;
637 if (!(journal->j_flags & JBD2_BARRIER))
641 if (tid_geq(journal->j_commit_sequence, tid))
643 commit_trans = journal->j_committing_transaction;
644 if (!commit_trans || commit_trans->t_tid != tid) {
652 if (journal->j_fs_dev != journal->j_dev) {
653 if (!commit_trans->t_need_data_flush ||
654 commit_trans->t_state >= T_COMMIT_DFLUSH)
657 if (commit_trans->t_state >= T_COMMIT_JFLUSH)
676 #ifdef CONFIG_JBD2_DEBUG
677 if (!tid_geq(journal->j_commit_request, tid)) {
679 "%s: error: j_commit_request=%d, tid=%d\n",
680 __func__, journal->j_commit_request, tid);
683 while (tid_gt(tid, journal->j_commit_sequence)) {
684 jbd_debug(1,
"JBD2: want %d, j_commit_sequence=%d\n",
685 tid, journal->j_commit_sequence);
686 wake_up(&journal->j_wait_commit);
689 !tid_gt(tid, journal->j_commit_sequence));
694 if (
unlikely(is_journal_aborted(journal))) {
710 J_ASSERT(journal->j_free > 1);
712 blocknr = journal->j_head;
715 if (journal->j_head == journal->j_last)
716 journal->j_head = journal->j_first;
729 unsigned long long *retp)
732 unsigned long long ret;
734 if (journal->j_inode) {
735 ret =
bmap(journal->j_inode, blocknr);
740 "at offset %lu on %s\n",
741 __func__, blocknr, journal->j_devname);
743 __journal_abort_soft(journal, err);
763 struct buffer_head *bh;
772 bh =
__getblk(journal->j_dev, blocknr, journal->j_blocksize);
776 memset(bh->b_data, 0, journal->j_blocksize);
777 set_buffer_uptodate(bh);
779 BUFFER_TRACE(bh,
"return this buffer");
794 unsigned long *
block)
800 spin_lock(&journal->j_list_lock);
801 transaction = journal->j_checkpoint_transactions;
803 *tid = transaction->t_tid;
804 *block = transaction->t_log_start;
805 }
else if ((transaction = journal->j_committing_transaction) !=
NULL) {
806 *tid = transaction->t_tid;
807 *block = transaction->t_log_start;
808 }
else if ((transaction = journal->j_running_transaction) !=
NULL) {
809 *tid = transaction->t_tid;
810 *block = journal->j_head;
812 *tid = journal->j_transaction_sequence;
813 *block = journal->j_head;
815 ret = tid_gt(*tid, journal->j_tail_sequence);
816 spin_unlock(&journal->j_list_lock);
836 BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
846 freed = block - journal->j_tail;
848 freed += journal->j_last - journal->j_first;
850 trace_jbd2_update_log_tail(journal, tid, block, freed);
852 "Cleaning journal tail from %d to %d (offset %lu), "
854 journal->j_tail_sequence, tid, block, freed);
856 journal->j_free += freed;
857 journal->j_tail_sequence = tid;
858 journal->j_tail =
block;
870 if (tid_gt(tid, journal->j_tail_sequence))
882 static void *jbd2_seq_info_start(
struct seq_file *seq, loff_t *
pos)
887 static void *jbd2_seq_info_next(
struct seq_file *seq,
void *
v, loff_t *
pos)
892 static int jbd2_seq_info_show(
struct seq_file *seq,
void *
v)
898 seq_printf(seq,
"%lu transaction, each up to %u blocks\n",
900 s->
journal->j_max_transaction_buffers);
901 if (s->
stats->ts_tid == 0)
903 seq_printf(seq,
"average: \n %ums waiting for transaction\n",
905 seq_printf(seq,
" %ums running transaction\n",
907 seq_printf(seq,
" %ums transaction was being locked\n",
909 seq_printf(seq,
" %ums flushing data (in ordered mode)\n",
911 seq_printf(seq,
" %ums logging transaction\n",
913 seq_printf(seq,
" %lluus average transaction commit time\n",
914 div_u64(s->
journal->j_average_commit_time, 1000));
915 seq_printf(seq,
" %lu handles per transaction\n",
916 s->
stats->run.rs_handle_count / s->
stats->ts_tid);
917 seq_printf(seq,
" %lu blocks per transaction\n",
919 seq_printf(seq,
" %lu logged blocks per transaction\n",
920 s->
stats->run.rs_blocks_logged / s->
stats->ts_tid);
924 static void jbd2_seq_info_stop(
struct seq_file *seq,
void *v)
929 .start = jbd2_seq_info_start,
930 .next = jbd2_seq_info_next,
931 .stop = jbd2_seq_info_stop,
932 .show = jbd2_seq_info_show,
937 journal_t *journal = PDE(inode)->data;
944 size =
sizeof(
struct transaction_stats_s);
950 spin_lock(&journal->j_history_lock);
953 spin_unlock(&journal->j_history_lock);
955 rc =
seq_open(file, &jbd2_seq_info_ops);
967 static int jbd2_seq_info_release(
struct inode *inode,
struct file *file)
978 .open = jbd2_seq_info_open,
981 .release = jbd2_seq_info_release,
986 static void jbd2_stats_proc_init(journal_t *journal)
988 journal->j_proc_entry =
proc_mkdir(journal->j_devname, proc_jbd2_stats);
989 if (journal->j_proc_entry) {
991 &jbd2_seq_info_fops, journal);
995 static void jbd2_stats_proc_exit(journal_t *journal)
1010 static journal_t * journal_init_common (
void)
1015 journal = kzalloc(
sizeof(*journal),
GFP_KERNEL);
1032 journal->j_min_batch_time = 0;
1033 journal->j_max_batch_time = 15000;
1036 journal->j_flags = JBD2_ABORT;
1075 unsigned long long start,
int len,
int blocksize)
1077 journal_t *journal = journal_init_common();
1078 struct buffer_head *bh;
1086 journal->j_blocksize = blocksize;
1087 journal->j_dev = bdev;
1088 journal->j_fs_dev = fs_dev;
1089 journal->j_blk_offset =
start;
1090 journal->j_maxlen = len;
1091 bdevname(journal->j_dev, journal->j_devname);
1092 p = journal->j_devname;
1093 while ((p =
strchr(p,
'/')))
1095 jbd2_stats_proc_init(journal);
1097 journal->j_wbufsize =
n;
1099 if (!journal->j_wbuf) {
1105 bh =
__getblk(journal->j_dev, start, journal->j_blocksize);
1108 "%s: Cannot get buffer for journal superblock\n",
1112 journal->j_sb_buffer = bh;
1117 kfree(journal->j_wbuf);
1118 jbd2_stats_proc_exit(journal);
1133 struct buffer_head *bh;
1134 journal_t *journal = journal_init_common();
1143 journal->j_dev = journal->j_fs_dev = inode->
i_sb->s_bdev;
1144 journal->j_inode =
inode;
1145 bdevname(journal->j_dev, journal->j_devname);
1146 p = journal->j_devname;
1147 while ((p =
strchr(p,
'/')))
1149 p = journal->j_devname +
strlen(journal->j_devname);
1150 sprintf(p,
"-%lu", journal->j_inode->i_ino);
1152 "journal %p: inode %s/%ld, size %Ld, bits %d, blksize %ld\n",
1153 journal, inode->
i_sb->s_id, inode->
i_ino,
1154 (
long long) inode->
i_size,
1155 inode->
i_sb->s_blocksize_bits, inode->
i_sb->s_blocksize);
1157 journal->j_maxlen = inode->
i_size >> inode->
i_sb->s_blocksize_bits;
1158 journal->j_blocksize = inode->
i_sb->s_blocksize;
1159 jbd2_stats_proc_init(journal);
1163 journal->j_wbufsize =
n;
1165 if (!journal->j_wbuf) {
1179 bh =
__getblk(journal->j_dev, blocknr, journal->j_blocksize);
1182 "%s: Cannot get buffer for journal superblock\n",
1186 journal->j_sb_buffer = bh;
1191 kfree(journal->j_wbuf);
1192 jbd2_stats_proc_exit(journal);
1202 static void journal_fail_superblock (journal_t *journal)
1204 struct buffer_head *bh = journal->j_sb_buffer;
1206 journal->j_sb_buffer =
NULL;
1216 static int journal_reset(journal_t *journal)
1226 journal_fail_superblock(journal);
1230 journal->j_first =
first;
1231 journal->j_last = last;
1233 journal->j_head =
first;
1234 journal->j_tail =
first;
1235 journal->j_free = last -
first;
1237 journal->j_tail_sequence = journal->j_transaction_sequence;
1238 journal->j_commit_sequence = journal->j_transaction_sequence - 1;
1239 journal->j_commit_request = journal->j_commit_sequence;
1241 journal->j_max_transaction_buffers = journal->j_maxlen / 4;
1250 jbd_debug(1,
"JBD2: Skipping superblock update on recovered sb "
1251 "(start %ld, seq %d, errno %d)\n",
1252 journal->j_tail, journal->j_tail_sequence,
1254 journal->j_flags |= JBD2_FLUSHED;
1265 journal->j_tail_sequence,
1270 return jbd2_journal_start_thread(journal);
1273 static void jbd2_write_superblock(journal_t *journal,
int write_op)
1275 struct buffer_head *bh = journal->j_sb_buffer;
1278 trace_jbd2_write_superblock(journal, write_op);
1279 if (!(journal->j_flags & JBD2_BARRIER))
1282 if (buffer_write_io_error(bh)) {
1292 "for journal superblock update for %s.\n",
1293 journal->j_devname);
1294 clear_buffer_write_io_error(bh);
1295 set_buffer_uptodate(bh);
1301 if (buffer_write_io_error(bh)) {
1302 clear_buffer_write_io_error(bh);
1303 set_buffer_uptodate(bh);
1308 "journal superblock for %s.\n", ret,
1309 journal->j_devname);
1324 unsigned long tail_block,
int write_op)
1328 BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
1329 jbd_debug(1,
"JBD2: updating superblock (start %lu, seq %u)\n",
1330 tail_block, tail_tid);
1335 jbd2_write_superblock(journal, write_op);
1340 journal->j_flags &= ~JBD2_FLUSHED;
1351 static void jbd2_mark_journal_empty(journal_t *journal)
1355 BUG_ON(!mutex_is_locked(&journal->j_checkpoint_mutex));
1362 jbd_debug(1,
"JBD2: Marking journal as empty (seq %d)\n",
1363 journal->j_tail_sequence);
1369 jbd2_write_superblock(journal,
WRITE_FUA);
1373 journal->j_flags |= JBD2_FLUSHED;
1390 jbd_debug(1,
"JBD2: updating superblock error (errno %d)\n",
1404 static int journal_get_superblock(journal_t *journal)
1406 struct buffer_head *bh;
1410 bh = journal->j_sb_buffer;
1412 J_ASSERT(bh !=
NULL);
1413 if (!buffer_uptodate(bh)) {
1416 if (!buffer_uptodate(bh)) {
1418 "JBD2: IO error reading journal superblock\n");
1423 if (buffer_verified(bh))
1426 sb = journal->j_superblock;
1438 journal->j_format_version = 1;
1441 journal->j_format_version = 2;
1458 "JBD2: Invalid start block of journal: %u\n",
1467 "at the same time!\n");
1479 if (IS_ERR(journal->j_chksum_driver)) {
1481 err = PTR_ERR(journal->j_chksum_driver);
1482 journal->j_chksum_driver =
NULL;
1495 journal->j_csum_seed = jbd2_chksum(journal, ~0, sb->
s_uuid,
1498 set_buffer_verified(bh);
1503 journal_fail_superblock(journal);
1512 static int load_superblock(journal_t *journal)
1517 err = journal_get_superblock(journal);
1521 sb = journal->j_superblock;
1546 err = load_superblock(journal);
1550 sb = journal->j_superblock;
1554 if (journal->j_format_version >= 2) {
1560 "JBD2: Unrecognised features on journal\n");
1575 goto recovery_error;
1577 if (journal->j_failed_commit) {
1579 "is corrupt.\n", journal->j_failed_commit,
1580 journal->j_devname);
1587 if (journal_reset(journal))
1588 goto recovery_error;
1590 journal->j_flags &= ~JBD2_ABORT;
1591 journal->j_flags |= JBD2_LOADED;
1612 journal_kill_thread(journal);
1615 if (journal->j_running_transaction)
1621 spin_lock(&journal->j_list_lock);
1622 while (journal->j_checkpoint_transactions !=
NULL) {
1623 spin_unlock(&journal->j_list_lock);
1627 spin_lock(&journal->j_list_lock);
1630 J_ASSERT(journal->j_running_transaction ==
NULL);
1631 J_ASSERT(journal->j_committing_transaction ==
NULL);
1632 J_ASSERT(journal->j_checkpoint_transactions ==
NULL);
1633 spin_unlock(&journal->j_list_lock);
1635 if (journal->j_sb_buffer) {
1636 if (!is_journal_aborted(journal)) {
1638 jbd2_mark_journal_empty(journal);
1642 brelse(journal->j_sb_buffer);
1645 if (journal->j_proc_entry)
1646 jbd2_stats_proc_exit(journal);
1647 if (journal->j_inode)
1648 iput(journal->j_inode);
1649 if (journal->j_revoke)
1651 if (journal->j_chksum_driver)
1652 crypto_free_shash(journal->j_chksum_driver);
1653 kfree(journal->j_wbuf);
1672 unsigned long ro,
unsigned long incompat)
1676 if (!compat && !ro && !incompat)
1679 if (journal->j_format_version == 0 &&
1680 journal_get_superblock(journal) != 0)
1682 if (journal->j_format_version == 1)
1685 sb = journal->j_superblock;
1707 unsigned long ro,
unsigned long incompat)
1709 if (!compat && !ro && !incompat)
1716 if (journal->j_format_version != 2)
1740 unsigned long ro,
unsigned long incompat)
1742 #define INCOMPAT_FEATURE_ON(f) \
1743 ((incompat & (f)) && !(sb->s_feature_incompat & cpu_to_be32(f)))
1744 #define COMPAT_FEATURE_ON(f) \
1745 ((compat & (f)) && !(sb->s_feature_compat & cpu_to_be32(f)))
1757 compat &= ~JBD2_FEATURE_COMPAT_CHECKSUM;
1759 jbd_debug(1,
"Setting new features 0x%lx/0x%lx/0x%lx\n",
1760 compat, ro, incompat);
1762 sb = journal->j_superblock;
1771 if (journal->j_chksum_driver ==
NULL) {
1774 if (IS_ERR(journal->j_chksum_driver)) {
1777 journal->j_chksum_driver =
NULL;
1785 journal->j_csum_seed = jbd2_chksum(journal, ~0,
1800 #undef COMPAT_FEATURE_ON
1801 #undef INCOMPAT_FEATURE_ON
1816 unsigned long ro,
unsigned long incompat)
1820 jbd_debug(1,
"Clear features 0x%lx/0x%lx/0x%lx\n",
1821 compat, ro, incompat);
1823 sb = journal->j_superblock;
1848 if (journal->j_running_transaction) {
1849 transaction = journal->j_running_transaction;
1851 }
else if (journal->j_committing_transaction)
1852 transaction = journal->j_committing_transaction;
1865 spin_lock(&journal->j_list_lock);
1866 while (!err && journal->j_checkpoint_transactions !=
NULL) {
1867 spin_unlock(&journal->j_list_lock);
1871 spin_lock(&journal->j_list_lock);
1873 spin_unlock(&journal->j_list_lock);
1875 if (is_journal_aborted(journal))
1886 jbd2_mark_journal_empty(journal);
1889 J_ASSERT(!journal->j_running_transaction);
1890 J_ASSERT(!journal->j_committing_transaction);
1891 J_ASSERT(!journal->j_checkpoint_transactions);
1892 J_ASSERT(journal->j_head == journal->j_tail);
1893 J_ASSERT(journal->j_tail_sequence == journal->j_transaction_sequence);
1915 J_ASSERT (!(journal->j_flags & JBD2_LOADED));
1917 err = load_superblock(journal);
1921 if (!journal->j_tail)
1925 write ?
"Clearing" :
"Ignoring");
1931 jbd2_mark_journal_empty(journal);
1956 if (journal->j_flags & JBD2_ABORT)
1960 journal->j_devname);
1963 journal->j_flags |= JBD2_ABORT;
1964 transaction = journal->j_running_transaction;
1972 static void __journal_abort_soft (journal_t *journal,
int errno)
1974 if (journal->j_flags & JBD2_ABORT)
1977 if (!journal->j_errno)
1978 journal->j_errno = errno;
2034 __journal_abort_soft(journal, errno);
2053 if (journal->j_flags & JBD2_ABORT)
2056 err = journal->j_errno;
2073 if (journal->j_flags & JBD2_ABORT)
2076 journal->j_errno = 0;
2091 if (journal->j_errno)
2092 journal->j_flags |= JBD2_ACK_ERR;
2133 #define JBD2_MAX_SLABS 8
2137 "jbd2_1k",
"jbd2_2k",
"jbd2_4k",
"jbd2_8k",
2138 "jbd2_16k",
"jbd2_32k",
"jbd2_64k",
"jbd2_128k"
2142 static void jbd2_journal_destroy_slabs(
void)
2149 jbd2_slab[
i] =
NULL;
2153 static int jbd2_journal_create_slab(
size_t size)
2162 if (i >= JBD2_MAX_SLABS)
2173 slab_size = 1 << (i+10);
2175 slab_size, 0,
NULL);
2177 if (!jbd2_slab[i]) {
2184 static struct kmem_cache *get_slab(
size_t size)
2188 BUG_ON(i >= JBD2_MAX_SLABS);
2192 return jbd2_slab[
i];
2216 BUG_ON(((
unsigned long) ptr) & (size-1));
2242 static struct kmem_cache *jbd2_journal_head_cache;
2243 #ifdef CONFIG_JBD2_DEBUG
2247 static int jbd2_journal_init_journal_head_cache(
void)
2251 J_ASSERT(jbd2_journal_head_cache ==
NULL);
2258 if (!jbd2_journal_head_cache) {
2265 static void jbd2_journal_destroy_journal_head_cache(
void)
2267 if (jbd2_journal_head_cache) {
2269 jbd2_journal_head_cache =
NULL;
2276 static struct journal_head *journal_alloc_journal_head(
void)
2280 #ifdef CONFIG_JBD2_DEBUG
2285 jbd_debug(1,
"out of memory for journal_head\n");
2295 static void journal_free_journal_head(
struct journal_head *jh)
2297 #ifdef CONFIG_JBD2_DEBUG
2351 if (!buffer_jbd(bh)) {
2352 new_jh = journal_alloc_journal_head();
2353 memset(new_jh, 0,
sizeof(*new_jh));
2356 jbd_lock_bh_journal_head(bh);
2357 if (buffer_jbd(bh)) {
2362 (bh->b_page && bh->b_page->mapping));
2365 jbd_unlock_bh_journal_head(bh);
2375 BUFFER_TRACE(bh,
"added journal_head");
2378 jbd_unlock_bh_journal_head(bh);
2380 journal_free_journal_head(new_jh);
2381 return bh->b_private;
2392 jbd_lock_bh_journal_head(bh);
2393 if (buffer_jbd(bh)) {
2397 jbd_unlock_bh_journal_head(bh);
2401 static void __journal_remove_journal_head(
struct buffer_head *bh)
2405 J_ASSERT_JH(jh, jh->
b_jcount >= 0);
2410 J_ASSERT_BH(bh, buffer_jbd(bh));
2411 J_ASSERT_BH(bh, jh2bh(jh) == bh);
2412 BUFFER_TRACE(bh,
"remove journal_head");
2421 bh->b_private =
NULL;
2423 clear_buffer_jbd(bh);
2424 journal_free_journal_head(jh);
2433 struct buffer_head *bh = jh2bh(jh);
2435 jbd_lock_bh_journal_head(bh);
2439 __journal_remove_journal_head(bh);
2440 jbd_unlock_bh_journal_head(bh);
2443 jbd_unlock_bh_journal_head(bh);
2451 jinode->i_transaction =
NULL;
2452 jinode->i_next_transaction =
NULL;
2453 jinode->i_vfs_inode =
inode;
2454 jinode->i_flags = 0;
2455 INIT_LIST_HEAD(&jinode->i_list);
2464 struct jbd2_inode *jinode)
2469 spin_lock(&journal->j_list_lock);
2471 if (
test_bit(__JI_COMMIT_RUNNING, &jinode->i_flags)) {
2476 spin_unlock(&journal->j_list_lock);
2482 if (jinode->i_transaction) {
2484 jinode->i_transaction =
NULL;
2486 spin_unlock(&journal->j_list_lock);
2492 #ifdef CONFIG_JBD2_DEBUG
2496 #define JBD2_DEBUG_NAME "jbd2-debug"
2498 static struct dentry *jbd2_debugfs_dir;
2499 static struct dentry *jbd2_debug;
2501 static void __init jbd2_create_debugfs_entry(
void)
2504 if (jbd2_debugfs_dir)
2508 &jbd2_journal_enable_debug);
2511 static void __exit jbd2_remove_debugfs_entry(
void)
2519 static void __init jbd2_create_debugfs_entry(
void)
2523 static void __exit jbd2_remove_debugfs_entry(
void)
2529 #ifdef CONFIG_PROC_FS
2531 #define JBD2_STATS_PROC_NAME "fs/jbd2"
2540 if (proc_jbd2_stats)
2546 #define jbd2_create_jbd_stats_proc_entry() do {} while (0)
2547 #define jbd2_remove_jbd_stats_proc_entry() do {} while (0)
2553 static int __init jbd2_journal_init_handle_cache(
void)
2556 if (jbd2_handle_cache ==
NULL) {
2560 jbd2_inode_cache =
KMEM_CACHE(jbd2_inode, 0);
2561 if (jbd2_inode_cache ==
NULL) {
2569 static void jbd2_journal_destroy_handle_cache(
void)
2571 if (jbd2_handle_cache)
2573 if (jbd2_inode_cache)
2582 static int __init journal_init_caches(
void)
2588 ret = jbd2_journal_init_journal_head_cache();
2590 ret = jbd2_journal_init_handle_cache();
2596 static void jbd2_journal_destroy_caches(
void)
2599 jbd2_journal_destroy_journal_head_cache();
2600 jbd2_journal_destroy_handle_cache();
2602 jbd2_journal_destroy_slabs();
2605 static int __init journal_init(
void)
2611 ret = journal_init_caches();
2613 jbd2_create_debugfs_entry();
2616 jbd2_journal_destroy_caches();
2621 static void __exit journal_exit(
void)
2623 #ifdef CONFIG_JBD2_DEBUG
2628 jbd2_remove_debugfs_entry();
2630 jbd2_journal_destroy_caches();