Lines Matching +full:boot +full:- +full:blks
1 // SPDX-License-Identifier: GPL-2.0
17 * -----------------
21 * Fast commits are organized as a log of tag-length-value (TLV) structs. (See
29 * - EXT4_FC_TAG_UNLINK - records directory entry unlink
30 * - EXT4_FC_TAG_LINK - records directory entry link
31 * - EXT4_FC_TAG_CREAT - records inode and directory entry creation
35 * - EXT4_FC_TAG_ADD_RANGE - records addition of new blocks to an inode
36 * - EXT4_FC_TAG_DEL_RANGE - records deletion of blocks from an inode
40 * - EXT4_FC_TAG_INODE - record the inode that should be replayed
45 * ----------------
47 * order in which they are issued in an in-memory queue. This queue is flushed
67 * -------------------------
72 * - ext4_fc_mark_ineligible(): This makes next fast commit operation to fall
75 * - ext4_fc_start_ineligible() and ext4_fc_stop_ineligible() - This makes all
85 * --------------------
94 * - Create a new file A and remove existing file B
95 * - fsync()
96 * - Append contents to file A
97 * - Truncate file A
98 * - fsync()
102 * |<--- Fast Commit 1 --->|<--- Fast Commit 2 ---->|
107 * -----
126 ext4_debug("%s: Block %lld up-to-date", in ext4_end_buffer_io_sync()
127 __func__, bh->b_blocknr); in ext4_end_buffer_io_sync()
130 ext4_debug("%s: Block %lld not up-to-date", in ext4_end_buffer_io_sync()
131 __func__, bh->b_blocknr); in ext4_end_buffer_io_sync()
142 ei->i_fc_lblk_start = 0; in ext4_fc_reset_inode()
143 ei->i_fc_lblk_len = 0; in ext4_fc_reset_inode()
152 INIT_LIST_HEAD(&ei->i_fc_list); in ext4_fc_init_inode()
153 init_waitqueue_head(&ei->i_fc_wait); in ext4_fc_init_inode()
154 atomic_set(&ei->i_fc_updates, 0); in ext4_fc_init_inode()
157 /* This function must be called with sbi->s_fc_lock held. */
159 __releases(&EXT4_SB(inode->i_sb)->s_fc_lock) in ext4_fc_wait_committing_inode()
165 DEFINE_WAIT_BIT(wait, &ei->i_state_flags, in ext4_fc_wait_committing_inode()
167 wq = bit_waitqueue(&ei->i_state_flags, in ext4_fc_wait_committing_inode()
170 DEFINE_WAIT_BIT(wait, &ei->i_flags, in ext4_fc_wait_committing_inode()
172 wq = bit_waitqueue(&ei->i_flags, in ext4_fc_wait_committing_inode()
175 lockdep_assert_held(&EXT4_SB(inode->i_sb)->s_fc_lock); in ext4_fc_wait_committing_inode()
177 spin_unlock(&EXT4_SB(inode->i_sb)->s_fc_lock); in ext4_fc_wait_committing_inode()
193 if (!test_opt2(inode->i_sb, JOURNAL_FAST_COMMIT) || in ext4_fc_start_update()
194 (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)) in ext4_fc_start_update()
198 spin_lock(&EXT4_SB(inode->i_sb)->s_fc_lock); in ext4_fc_start_update()
199 if (list_empty(&ei->i_fc_list)) in ext4_fc_start_update()
207 atomic_inc(&ei->i_fc_updates); in ext4_fc_start_update()
208 spin_unlock(&EXT4_SB(inode->i_sb)->s_fc_lock); in ext4_fc_start_update()
218 if (!test_opt2(inode->i_sb, JOURNAL_FAST_COMMIT) || in ext4_fc_stop_update()
219 (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)) in ext4_fc_stop_update()
222 if (atomic_dec_and_test(&ei->i_fc_updates)) in ext4_fc_stop_update()
223 wake_up_all(&ei->i_fc_wait); in ext4_fc_stop_update()
234 if (!test_opt2(inode->i_sb, JOURNAL_FAST_COMMIT) || in ext4_fc_del()
235 (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)) in ext4_fc_del()
239 spin_lock(&EXT4_SB(inode->i_sb)->s_fc_lock); in ext4_fc_del()
240 if (list_empty(&ei->i_fc_list)) { in ext4_fc_del()
241 spin_unlock(&EXT4_SB(inode->i_sb)->s_fc_lock); in ext4_fc_del()
249 list_del_init(&ei->i_fc_list); in ext4_fc_del()
250 spin_unlock(&EXT4_SB(inode->i_sb)->s_fc_lock); in ext4_fc_del()
262 (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) in ext4_fc_mark_ineligible()
267 sbi->s_fc_stats.fc_ineligible_reason_count[reason]++; in ext4_fc_mark_ineligible()
279 (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) in ext4_fc_start_ineligible()
283 sbi->s_fc_stats.fc_ineligible_reason_count[reason]++; in ext4_fc_start_ineligible()
284 atomic_inc(&sbi->s_fc_ineligible_updates); in ext4_fc_start_ineligible()
295 (EXT4_SB(sb)->s_mount_state & EXT4_FC_REPLAY)) in ext4_fc_stop_ineligible()
299 atomic_dec(&EXT4_SB(sb)->s_fc_ineligible_updates); in ext4_fc_stop_ineligible()
305 atomic_read(&EXT4_SB(sb)->s_fc_ineligible_updates)); in ext4_fc_is_ineligible()
325 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); in ext4_fc_track_template()
329 if (!test_opt2(inode->i_sb, JOURNAL_FAST_COMMIT) || in ext4_fc_track_template()
330 (sbi->s_mount_state & EXT4_FC_REPLAY)) in ext4_fc_track_template()
331 return -EOPNOTSUPP; in ext4_fc_track_template()
333 if (ext4_fc_is_ineligible(inode->i_sb)) in ext4_fc_track_template()
334 return -EINVAL; in ext4_fc_track_template()
336 tid = handle->h_transaction->t_tid; in ext4_fc_track_template()
337 mutex_lock(&ei->i_fc_lock); in ext4_fc_track_template()
338 if (tid == ei->i_sync_tid) { in ext4_fc_track_template()
342 ei->i_sync_tid = tid; in ext4_fc_track_template()
345 mutex_unlock(&ei->i_fc_lock); in ext4_fc_track_template()
350 spin_lock(&sbi->s_fc_lock); in ext4_fc_track_template()
351 if (list_empty(&EXT4_I(inode)->i_fc_list)) in ext4_fc_track_template()
352 list_add_tail(&EXT4_I(inode)->i_fc_list, in ext4_fc_track_template()
353 (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_COMMITTING)) ? in ext4_fc_track_template()
354 &sbi->s_fc_q[FC_Q_STAGING] : in ext4_fc_track_template()
355 &sbi->s_fc_q[FC_Q_MAIN]); in ext4_fc_track_template()
356 spin_unlock(&sbi->s_fc_lock); in ext4_fc_track_template()
366 /* __track_fn for directory entry updates. Called with ei->i_fc_lock. */
373 struct dentry *dentry = dentry_update->dentry; in __track_dentry_update()
374 struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); in __track_dentry_update()
376 mutex_unlock(&ei->i_fc_lock); in __track_dentry_update()
379 ext4_fc_mark_ineligible(inode->i_sb, EXT4_FC_REASON_NOMEM); in __track_dentry_update()
380 mutex_lock(&ei->i_fc_lock); in __track_dentry_update()
381 return -ENOMEM; in __track_dentry_update()
384 node->fcd_op = dentry_update->op; in __track_dentry_update()
385 node->fcd_parent = dentry->d_parent->d_inode->i_ino; in __track_dentry_update()
386 node->fcd_ino = inode->i_ino; in __track_dentry_update()
387 if (dentry->d_name.len > DNAME_INLINE_LEN) { in __track_dentry_update()
388 node->fcd_name.name = kmalloc(dentry->d_name.len, GFP_NOFS); in __track_dentry_update()
389 if (!node->fcd_name.name) { in __track_dentry_update()
391 ext4_fc_mark_ineligible(inode->i_sb, in __track_dentry_update()
393 mutex_lock(&ei->i_fc_lock); in __track_dentry_update()
394 return -ENOMEM; in __track_dentry_update()
396 memcpy((u8 *)node->fcd_name.name, dentry->d_name.name, in __track_dentry_update()
397 dentry->d_name.len); in __track_dentry_update()
399 memcpy(node->fcd_iname, dentry->d_name.name, in __track_dentry_update()
400 dentry->d_name.len); in __track_dentry_update()
401 node->fcd_name.name = node->fcd_iname; in __track_dentry_update()
403 node->fcd_name.len = dentry->d_name.len; in __track_dentry_update()
405 spin_lock(&sbi->s_fc_lock); in __track_dentry_update()
406 if (ext4_test_mount_flag(inode->i_sb, EXT4_MF_FC_COMMITTING)) in __track_dentry_update()
407 list_add_tail(&node->fcd_list, in __track_dentry_update()
408 &sbi->s_fc_dentry_q[FC_Q_STAGING]); in __track_dentry_update()
410 list_add_tail(&node->fcd_list, &sbi->s_fc_dentry_q[FC_Q_MAIN]); in __track_dentry_update()
411 spin_unlock(&sbi->s_fc_lock); in __track_dentry_update()
412 mutex_lock(&ei->i_fc_lock); in __track_dentry_update()
478 return -EEXIST; in __track_inode()
480 EXT4_I(inode)->i_fc_lblk_len = 0; in __track_inode()
489 if (S_ISDIR(inode->i_mode)) in ext4_fc_track_inode()
493 ext4_fc_mark_ineligible(inode->i_sb, in ext4_fc_track_inode()
514 if (inode->i_ino < EXT4_FIRST_INO(inode->i_sb)) { in __track_range()
515 ext4_debug("Special inode %ld being modified\n", inode->i_ino); in __track_range()
516 return -ECANCELED; in __track_range()
519 oldstart = ei->i_fc_lblk_start; in __track_range()
521 if (update && ei->i_fc_lblk_len > 0) { in __track_range()
522 ei->i_fc_lblk_start = min(ei->i_fc_lblk_start, __arg->start); in __track_range()
523 ei->i_fc_lblk_len = in __track_range()
524 max(oldstart + ei->i_fc_lblk_len - 1, __arg->end) - in __track_range()
525 ei->i_fc_lblk_start + 1; in __track_range()
527 ei->i_fc_lblk_start = __arg->start; in __track_range()
528 ei->i_fc_lblk_len = __arg->end - __arg->start + 1; in __track_range()
540 if (S_ISDIR(inode->i_mode)) in ext4_fc_track_range()
554 struct buffer_head *bh = EXT4_SB(sb)->s_fc_bh; in ext4_fc_submit_bh()
562 bh->b_end_io = ext4_end_buffer_io_sync; in ext4_fc_submit_bh()
564 EXT4_SB(sb)->s_fc_bh = NULL; in ext4_fc_submit_bh()
597 int bsize = sbi->s_journal->j_blocksize; in ext4_fc_reserve_space()
598 int ret, off = sbi->s_fc_bytes % bsize; in ext4_fc_reserve_space()
608 if (bsize - off - 1 > len + sizeof(struct ext4_fc_tl)) { in ext4_fc_reserve_space()
613 if (!sbi->s_fc_bh) { in ext4_fc_reserve_space()
614 ret = jbd2_fc_get_buf(EXT4_SB(sb)->s_journal, &bh); in ext4_fc_reserve_space()
617 sbi->s_fc_bh = bh; in ext4_fc_reserve_space()
619 sbi->s_fc_bytes += len; in ext4_fc_reserve_space()
620 return sbi->s_fc_bh->b_data + off; in ext4_fc_reserve_space()
623 tl = (struct ext4_fc_tl *)(sbi->s_fc_bh->b_data + off); in ext4_fc_reserve_space()
624 tl->fc_tag = cpu_to_le16(EXT4_FC_TAG_PAD); in ext4_fc_reserve_space()
625 pad_len = bsize - off - 1 - sizeof(struct ext4_fc_tl); in ext4_fc_reserve_space()
626 tl->fc_len = cpu_to_le16(pad_len); in ext4_fc_reserve_space()
633 ret = jbd2_fc_get_buf(EXT4_SB(sb)->s_journal, &bh); in ext4_fc_reserve_space()
636 sbi->s_fc_bh = bh; in ext4_fc_reserve_space()
637 sbi->s_fc_bytes = (sbi->s_fc_bytes / bsize + 1) * bsize + len; in ext4_fc_reserve_space()
638 return sbi->s_fc_bh->b_data; in ext4_fc_reserve_space()
663 int off, bsize = sbi->s_journal->j_blocksize; in ext4_fc_write_tail()
672 return -ENOSPC; in ext4_fc_write_tail()
674 off = sbi->s_fc_bytes % bsize; in ext4_fc_write_tail()
677 tl.fc_len = cpu_to_le16(bsize - off - 1 + sizeof(struct ext4_fc_tail)); in ext4_fc_write_tail()
678 sbi->s_fc_bytes = round_up(sbi->s_fc_bytes, bsize); in ext4_fc_write_tail()
682 tail.fc_tid = cpu_to_le32(sbi->s_journal->j_running_transaction->t_tid); in ext4_fc_write_tail()
762 if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE) in ext4_fc_write_inode()
763 inode_len += ei->i_extra_isize; in ext4_fc_write_inode()
765 fc_inode.fc_ino = cpu_to_le32(inode->i_ino); in ext4_fc_write_inode()
769 ret = -ECANCELED; in ext4_fc_write_inode()
770 dst = ext4_fc_reserve_space(inode->i_sb, in ext4_fc_write_inode()
775 if (!ext4_fc_memcpy(inode->i_sb, dst, &tl, sizeof(tl), crc)) in ext4_fc_write_inode()
778 if (!ext4_fc_memcpy(inode->i_sb, dst, &fc_inode, sizeof(fc_inode), crc)) in ext4_fc_write_inode()
781 if (!ext4_fc_memcpy(inode->i_sb, dst, (u8 *)ext4_raw_inode(&iloc), in ext4_fc_write_inode()
804 mutex_lock(&ei->i_fc_lock); in ext4_fc_write_inode_data()
805 if (ei->i_fc_lblk_len == 0) { in ext4_fc_write_inode_data()
806 mutex_unlock(&ei->i_fc_lock); in ext4_fc_write_inode_data()
809 old_blk_size = ei->i_fc_lblk_start; in ext4_fc_write_inode_data()
810 new_blk_size = ei->i_fc_lblk_start + ei->i_fc_lblk_len - 1; in ext4_fc_write_inode_data()
811 ei->i_fc_lblk_len = 0; in ext4_fc_write_inode_data()
812 mutex_unlock(&ei->i_fc_lock); in ext4_fc_write_inode_data()
816 __func__, cur_lblk_off, new_blk_size, inode->i_ino); in ext4_fc_write_inode_data()
820 map.m_len = new_blk_size - cur_lblk_off + 1; in ext4_fc_write_inode_data()
823 return -ECANCELED; in ext4_fc_write_inode_data()
831 lrange.fc_ino = cpu_to_le32(inode->i_ino); in ext4_fc_write_inode_data()
834 if (!ext4_fc_add_tlv(inode->i_sb, EXT4_FC_TAG_DEL_RANGE, in ext4_fc_write_inode_data()
836 return -ENOSPC; in ext4_fc_write_inode_data()
844 fc_ext.fc_ino = cpu_to_le32(inode->i_ino); in ext4_fc_write_inode_data()
846 ex->ee_block = cpu_to_le32(map.m_lblk); in ext4_fc_write_inode_data()
847 ex->ee_len = cpu_to_le16(map.m_len); in ext4_fc_write_inode_data()
853 if (!ext4_fc_add_tlv(inode->i_sb, EXT4_FC_TAG_ADD_RANGE, in ext4_fc_write_inode_data()
855 return -ENOSPC; in ext4_fc_write_inode_data()
868 struct super_block *sb = (struct super_block *)(journal->j_private); in ext4_fc_submit_inode_data_all()
874 spin_lock(&sbi->s_fc_lock); in ext4_fc_submit_inode_data_all()
876 list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) { in ext4_fc_submit_inode_data_all()
878 ext4_set_inode_state(&ei->vfs_inode, EXT4_STATE_FC_COMMITTING); in ext4_fc_submit_inode_data_all()
879 while (atomic_read(&ei->i_fc_updates)) { in ext4_fc_submit_inode_data_all()
882 prepare_to_wait(&ei->i_fc_wait, &wait, in ext4_fc_submit_inode_data_all()
884 if (atomic_read(&ei->i_fc_updates)) { in ext4_fc_submit_inode_data_all()
885 spin_unlock(&sbi->s_fc_lock); in ext4_fc_submit_inode_data_all()
887 spin_lock(&sbi->s_fc_lock); in ext4_fc_submit_inode_data_all()
889 finish_wait(&ei->i_fc_wait, &wait); in ext4_fc_submit_inode_data_all()
891 spin_unlock(&sbi->s_fc_lock); in ext4_fc_submit_inode_data_all()
892 ret = jbd2_submit_inode_data(ei->jinode); in ext4_fc_submit_inode_data_all()
895 spin_lock(&sbi->s_fc_lock); in ext4_fc_submit_inode_data_all()
897 spin_unlock(&sbi->s_fc_lock); in ext4_fc_submit_inode_data_all()
905 struct super_block *sb = (struct super_block *)(journal->j_private); in ext4_fc_wait_inode_data_all()
910 spin_lock(&sbi->s_fc_lock); in ext4_fc_wait_inode_data_all()
911 list_for_each_entry_safe(pos, n, &sbi->s_fc_q[FC_Q_MAIN], i_fc_list) { in ext4_fc_wait_inode_data_all()
912 if (!ext4_test_inode_state(&pos->vfs_inode, in ext4_fc_wait_inode_data_all()
915 spin_unlock(&sbi->s_fc_lock); in ext4_fc_wait_inode_data_all()
917 ret = jbd2_wait_inode_data(journal, pos->jinode); in ext4_fc_wait_inode_data_all()
920 spin_lock(&sbi->s_fc_lock); in ext4_fc_wait_inode_data_all()
922 spin_unlock(&sbi->s_fc_lock); in ext4_fc_wait_inode_data_all()
929 __acquires(&sbi->s_fc_lock) in ext4_fc_commit_dentry_updates()
930 __releases(&sbi->s_fc_lock) in ext4_fc_commit_dentry_updates()
932 struct super_block *sb = (struct super_block *)(journal->j_private); in ext4_fc_commit_dentry_updates()
940 if (list_empty(&sbi->s_fc_dentry_q[FC_Q_MAIN])) in ext4_fc_commit_dentry_updates()
942 list_for_each_safe(fcd_pos, fcd_n, &sbi->s_fc_dentry_q[FC_Q_MAIN]) { in ext4_fc_commit_dentry_updates()
945 if (fc_dentry->fcd_op != EXT4_FC_TAG_CREAT) { in ext4_fc_commit_dentry_updates()
946 spin_unlock(&sbi->s_fc_lock); in ext4_fc_commit_dentry_updates()
948 sb, fc_dentry->fcd_op, in ext4_fc_commit_dentry_updates()
949 fc_dentry->fcd_parent, fc_dentry->fcd_ino, in ext4_fc_commit_dentry_updates()
950 fc_dentry->fcd_name.len, in ext4_fc_commit_dentry_updates()
951 fc_dentry->fcd_name.name, crc)) { in ext4_fc_commit_dentry_updates()
952 ret = -ENOSPC; in ext4_fc_commit_dentry_updates()
955 spin_lock(&sbi->s_fc_lock); in ext4_fc_commit_dentry_updates()
960 list_for_each_safe(pos, n, &sbi->s_fc_q[FC_Q_MAIN]) { in ext4_fc_commit_dentry_updates()
962 if (ei->vfs_inode.i_ino == fc_dentry->fcd_ino) { in ext4_fc_commit_dentry_updates()
963 inode = &ei->vfs_inode; in ext4_fc_commit_dentry_updates()
973 spin_unlock(&sbi->s_fc_lock); in ext4_fc_commit_dentry_updates()
991 sb, fc_dentry->fcd_op, in ext4_fc_commit_dentry_updates()
992 fc_dentry->fcd_parent, fc_dentry->fcd_ino, in ext4_fc_commit_dentry_updates()
993 fc_dentry->fcd_name.len, in ext4_fc_commit_dentry_updates()
994 fc_dentry->fcd_name.name, crc)) { in ext4_fc_commit_dentry_updates()
995 ret = -ENOSPC; in ext4_fc_commit_dentry_updates()
999 spin_lock(&sbi->s_fc_lock); in ext4_fc_commit_dentry_updates()
1003 spin_lock(&sbi->s_fc_lock); in ext4_fc_commit_dentry_updates()
1009 struct super_block *sb = (struct super_block *)(journal->j_private); in ext4_fc_perform_commit()
1031 if (journal->j_fs_dev != journal->j_dev) in ext4_fc_perform_commit()
1032 blkdev_issue_flush(journal->j_fs_dev, GFP_NOFS); in ext4_fc_perform_commit()
1035 if (sbi->s_fc_bytes == 0) { in ext4_fc_perform_commit()
1042 sbi->s_journal->j_running_transaction->t_tid); in ext4_fc_perform_commit()
1045 ret = -ENOSPC; in ext4_fc_perform_commit()
1050 spin_lock(&sbi->s_fc_lock); in ext4_fc_perform_commit()
1053 spin_unlock(&sbi->s_fc_lock); in ext4_fc_perform_commit()
1057 list_for_each(pos, &sbi->s_fc_q[FC_Q_MAIN]) { in ext4_fc_perform_commit()
1059 inode = &iter->vfs_inode; in ext4_fc_perform_commit()
1063 spin_unlock(&sbi->s_fc_lock); in ext4_fc_perform_commit()
1070 spin_lock(&sbi->s_fc_lock); in ext4_fc_perform_commit()
1072 spin_unlock(&sbi->s_fc_lock); in ext4_fc_perform_commit()
1089 struct super_block *sb = (struct super_block *)(journal->j_private); in ext4_fc_commit()
1091 int nblks = 0, ret, bsize = journal->j_blocksize; in ext4_fc_commit()
1092 int subtid = atomic_read(&sbi->s_fc_subtid); in ext4_fc_commit()
1108 if (ret == -EALREADY) { in ext4_fc_commit()
1110 if (atomic_read(&sbi->s_fc_subtid) <= subtid && in ext4_fc_commit()
1111 commit_tid > journal->j_commit_sequence) in ext4_fc_commit()
1116 sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++; in ext4_fc_commit()
1121 fc_bufs_before = (sbi->s_fc_bytes + bsize - 1) / bsize; in ext4_fc_commit()
1124 sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++; in ext4_fc_commit()
1128 nblks = (sbi->s_fc_bytes + bsize - 1) / bsize - fc_bufs_before; in ext4_fc_commit()
1131 sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++; in ext4_fc_commit()
1135 atomic_inc(&sbi->s_fc_subtid); in ext4_fc_commit()
1140 sbi->s_fc_stats.fc_ineligible_reason_count[EXT4_FC_COMMIT_FAILED]++; in ext4_fc_commit()
1144 spin_lock(&sbi->s_fc_lock); in ext4_fc_commit()
1147 sbi->s_fc_stats.fc_ineligible_commits++; in ext4_fc_commit()
1149 sbi->s_fc_stats.fc_num_commits++; in ext4_fc_commit()
1150 sbi->s_fc_stats.fc_numblks += nblks; in ext4_fc_commit()
1152 spin_unlock(&sbi->s_fc_lock); in ext4_fc_commit()
1160 if (likely(sbi->s_fc_avg_commit_time)) in ext4_fc_commit()
1161 sbi->s_fc_avg_commit_time = (commit_time + in ext4_fc_commit()
1162 sbi->s_fc_avg_commit_time * 3) / 4; in ext4_fc_commit()
1164 sbi->s_fc_avg_commit_time = commit_time; in ext4_fc_commit()
1166 "Fast commit ended with blks = %d, reason = %d, subtid - %d", in ext4_fc_commit()
1182 struct super_block *sb = journal->j_private; in ext4_fc_cleanup()
1188 if (full && sbi->s_fc_bh) in ext4_fc_cleanup()
1189 sbi->s_fc_bh = NULL; in ext4_fc_cleanup()
1193 spin_lock(&sbi->s_fc_lock); in ext4_fc_cleanup()
1194 list_for_each_safe(pos, n, &sbi->s_fc_q[FC_Q_MAIN]) { in ext4_fc_cleanup()
1196 list_del_init(&iter->i_fc_list); in ext4_fc_cleanup()
1197 ext4_clear_inode_state(&iter->vfs_inode, in ext4_fc_cleanup()
1199 ext4_fc_reset_inode(&iter->vfs_inode); in ext4_fc_cleanup()
1203 wake_up_bit(&iter->i_state_flags, EXT4_STATE_FC_COMMITTING); in ext4_fc_cleanup()
1205 wake_up_bit(&iter->i_flags, EXT4_STATE_FC_COMMITTING); in ext4_fc_cleanup()
1209 while (!list_empty(&sbi->s_fc_dentry_q[FC_Q_MAIN])) { in ext4_fc_cleanup()
1210 fc_dentry = list_first_entry(&sbi->s_fc_dentry_q[FC_Q_MAIN], in ext4_fc_cleanup()
1213 list_del_init(&fc_dentry->fcd_list); in ext4_fc_cleanup()
1214 spin_unlock(&sbi->s_fc_lock); in ext4_fc_cleanup()
1216 if (fc_dentry->fcd_name.name && in ext4_fc_cleanup()
1217 fc_dentry->fcd_name.len > DNAME_INLINE_LEN) in ext4_fc_cleanup()
1218 kfree(fc_dentry->fcd_name.name); in ext4_fc_cleanup()
1220 spin_lock(&sbi->s_fc_lock); in ext4_fc_cleanup()
1223 list_splice_init(&sbi->s_fc_dentry_q[FC_Q_STAGING], in ext4_fc_cleanup()
1224 &sbi->s_fc_dentry_q[FC_Q_MAIN]); in ext4_fc_cleanup()
1225 list_splice_init(&sbi->s_fc_q[FC_Q_STAGING], in ext4_fc_cleanup()
1226 &sbi->s_fc_q[FC_Q_MAIN]); in ext4_fc_cleanup()
1232 sbi->s_fc_bytes = 0; in ext4_fc_cleanup()
1233 spin_unlock(&sbi->s_fc_lock); in ext4_fc_cleanup()
1252 darg->parent_ino = le32_to_cpu(fcd.fc_parent_ino); in tl_to_darg()
1253 darg->ino = le32_to_cpu(fcd.fc_ino); in tl_to_darg()
1254 darg->dname = val + offsetof(struct ext4_fc_dentry_info, fc_dname); in tl_to_darg()
1255 darg->dname_len = le16_to_cpu(tl->fc_len) - in tl_to_darg()
1291 /* -ENOENT ok coz it might not exist anymore. */ in ext4_fc_replay_unlink()
1292 if (ret == -ENOENT) in ext4_fc_replay_unlink()
1305 struct qstr qstr_dname = QSTR_INIT(darg->dname, darg->dname_len); in ext4_fc_replay_link_internal()
1308 dir = ext4_iget(sb, darg->parent_ino, EXT4_IGET_NORMAL); in ext4_fc_replay_link_internal()
1310 jbd_debug(1, "Dir with inode %d not found.", darg->parent_ino); in ext4_fc_replay_link_internal()
1325 ret = -ENOMEM; in ext4_fc_replay_link_internal()
1336 if (ret && ret != -EEXIST) { in ext4_fc_replay_link_internal()
1389 state = &EXT4_SB(sb)->s_fc_replay_state; in ext4_fc_record_modified_inode()
1390 for (i = 0; i < state->fc_modified_inodes_used; i++) in ext4_fc_record_modified_inode()
1391 if (state->fc_modified_inodes[i] == ino) in ext4_fc_record_modified_inode()
1393 if (state->fc_modified_inodes_used == state->fc_modified_inodes_size) { in ext4_fc_record_modified_inode()
1396 fc_modified_inodes = krealloc(state->fc_modified_inodes, in ext4_fc_record_modified_inode()
1397 sizeof(int) * (state->fc_modified_inodes_size + in ext4_fc_record_modified_inode()
1401 return -ENOMEM; in ext4_fc_record_modified_inode()
1402 state->fc_modified_inodes = fc_modified_inodes; in ext4_fc_record_modified_inode()
1403 state->fc_modified_inodes_size += in ext4_fc_record_modified_inode()
1406 state->fc_modified_inodes[state->fc_modified_inodes_used++] = ino; in ext4_fc_record_modified_inode()
1421 int inode_len, ino, ret, tag = le16_to_cpu(tl->fc_tag); in ext4_fc_replay_inode()
1446 inode_len = le16_to_cpu(tl->fc_len) - sizeof(struct ext4_fc_inode); in ext4_fc_replay_inode()
1450 memcpy(&raw_inode->i_generation, &raw_fc_inode->i_generation, in ext4_fc_replay_inode()
1451 inode_len - offsetof(struct ext4_inode, i_generation)); in ext4_fc_replay_inode()
1452 if (le32_to_cpu(raw_inode->i_flags) & EXT4_EXTENTS_FL) { in ext4_fc_replay_inode()
1453 eh = (struct ext4_extent_header *)(&raw_inode->i_block[0]); in ext4_fc_replay_inode()
1454 if (eh->eh_magic != EXT4_EXT_MAGIC) { in ext4_fc_replay_inode()
1456 eh->eh_magic = EXT4_EXT_MAGIC; in ext4_fc_replay_inode()
1457 eh->eh_max = cpu_to_le16( in ext4_fc_replay_inode()
1458 (sizeof(raw_inode->i_block) - in ext4_fc_replay_inode()
1462 } else if (le32_to_cpu(raw_inode->i_flags) & EXT4_INLINE_DATA_FL) { in ext4_fc_replay_inode()
1463 memcpy(raw_inode->i_block, raw_fc_inode->i_block, in ext4_fc_replay_inode()
1464 sizeof(raw_inode->i_block)); in ext4_fc_replay_inode()
1482 return -EFSCORRUPTED; in ext4_fc_replay_inode()
1492 inode->i_generation = le32_to_cpu(ext4_raw_inode(&iloc)->i_generation); in ext4_fc_replay_inode()
1502 blkdev_issue_flush(sb->s_bdev, GFP_KERNEL); in ext4_fc_replay_inode()
1536 ret = -EINVAL; in ext4_fc_replay_create()
1540 if (S_ISDIR(inode->i_mode)) { in ext4_fc_replay_create()
1579 state = &EXT4_SB(sb)->s_fc_replay_state; in ext4_fc_record_regions()
1584 if (replay && state->fc_regions_used != state->fc_regions_valid) in ext4_fc_record_regions()
1585 state->fc_regions_used = state->fc_regions_valid; in ext4_fc_record_regions()
1586 if (state->fc_regions_used == state->fc_regions_size) { in ext4_fc_record_regions()
1589 fc_regions = krealloc(state->fc_regions, in ext4_fc_record_regions()
1591 (state->fc_regions_size + in ext4_fc_record_regions()
1595 return -ENOMEM; in ext4_fc_record_regions()
1596 state->fc_regions_size += in ext4_fc_record_regions()
1598 state->fc_regions = fc_regions; in ext4_fc_record_regions()
1600 region = &state->fc_regions[state->fc_regions_used++]; in ext4_fc_record_regions()
1601 region->ino = ino; in ext4_fc_record_regions()
1602 region->lblk = lblk; in ext4_fc_record_regions()
1603 region->pblk = pblk; in ext4_fc_record_regions()
1604 region->len = len; in ext4_fc_record_regions()
1607 state->fc_regions_valid++; in ext4_fc_record_regions()
1630 le32_to_cpu(fc_add_ex.fc_ino), le32_to_cpu(ex->ee_block), in ext4_fc_replay_add_range()
1639 ret = ext4_fc_record_modified_inode(sb, inode->i_ino); in ext4_fc_replay_add_range()
1643 start = le32_to_cpu(ex->ee_block); in ext4_fc_replay_add_range()
1651 inode->i_ino); in ext4_fc_replay_add_range()
1670 &newex, start_pblk + cur - start); in ext4_fc_replay_add_range()
1674 down_write(&EXT4_I(inode)->i_data_sem); in ext4_fc_replay_add_range()
1677 up_write((&EXT4_I(inode)->i_data_sem)); in ext4_fc_replay_add_range()
1685 if (start_pblk + cur - start != map.m_pblk) { in ext4_fc_replay_add_range()
1693 start_pblk + cur - start); in ext4_fc_replay_add_range()
1705 ext4_mb_mark_bb(inode->i_sb, map.m_pblk, map.m_len, 0); in ext4_fc_replay_add_range()
1724 remaining -= map.m_len; in ext4_fc_replay_add_range()
1727 sb->s_blocksize_bits); in ext4_fc_replay_add_range()
1757 ret = ext4_fc_record_modified_inode(sb, inode->i_ino); in ext4_fc_replay_del_range()
1762 inode->i_ino, le32_to_cpu(lrange.fc_lblk), in ext4_fc_replay_del_range()
1772 remaining -= ret; in ext4_fc_replay_del_range()
1774 ext4_mb_mark_bb(inode->i_sb, map.m_pblk, map.m_len, 0); in ext4_fc_replay_del_range()
1776 remaining -= map.m_len; in ext4_fc_replay_del_range()
1781 down_write(&EXT4_I(inode)->i_data_sem); in ext4_fc_replay_del_range()
1784 le32_to_cpu(lrange.fc_len) - 1); in ext4_fc_replay_del_range()
1785 up_write(&EXT4_I(inode)->i_data_sem); in ext4_fc_replay_del_range()
1789 i_size_read(inode) >> sb->s_blocksize_bits); in ext4_fc_replay_del_range()
1831 state = &EXT4_SB(sb)->s_fc_replay_state; in ext4_fc_set_bitmaps_and_counters()
1832 for (i = 0; i < state->fc_modified_inodes_used; i++) { in ext4_fc_set_bitmaps_and_counters()
1833 inode = ext4_iget(sb, state->fc_modified_inodes[i], in ext4_fc_set_bitmaps_and_counters()
1837 state->fc_modified_inodes[i]); in ext4_fc_set_bitmaps_and_counters()
1844 map.m_len = end - cur; in ext4_fc_set_bitmaps_and_counters()
1853 for (j = 0; j < path->p_depth; j++) in ext4_fc_set_bitmaps_and_counters()
1854 ext4_mb_mark_bb(inode->i_sb, in ext4_fc_set_bitmaps_and_counters()
1860 ext4_mb_mark_bb(inode->i_sb, map.m_pblk, in ext4_fc_set_bitmaps_and_counters()
1880 state = &EXT4_SB(sb)->s_fc_replay_state; in ext4_fc_replay_check_excluded()
1881 for (i = 0; i < state->fc_regions_valid; i++) { in ext4_fc_replay_check_excluded()
1882 if (state->fc_regions[i].ino == 0 || in ext4_fc_replay_check_excluded()
1883 state->fc_regions[i].len == 0) in ext4_fc_replay_check_excluded()
1885 if (blk >= state->fc_regions[i].pblk && in ext4_fc_replay_check_excluded()
1886 blk < state->fc_regions[i].pblk + state->fc_regions[i].len) in ext4_fc_replay_check_excluded()
1897 sbi->s_mount_state &= ~EXT4_FC_REPLAY; in ext4_fc_replay_cleanup()
1898 kfree(sbi->s_fc_replay_state.fc_regions); in ext4_fc_replay_cleanup()
1899 kfree(sbi->s_fc_replay_state.fc_modified_inodes); in ext4_fc_replay_cleanup()
1907 * - Make sure the fast commit area has valid tags for replay
1908 * - Count number of tags that need to be replayed by the replay handler
1909 * - Verify CRC
1910 * - Create a list of excluded blocks for allocation during replay phase
1916 * of a successful scan phase, sbi->s_fc_replay_state.fc_replay_num_tags is set
1923 struct super_block *sb = journal->j_private; in ext4_fc_replay_scan()
1934 state = &sbi->s_fc_replay_state; in ext4_fc_replay_scan()
1936 start = (u8 *)bh->b_data; in ext4_fc_replay_scan()
1937 end = (__u8 *)bh->b_data + journal->j_blocksize - 1; in ext4_fc_replay_scan()
1939 if (state->fc_replay_expected_off == 0) { in ext4_fc_replay_scan()
1940 state->fc_cur_tag = 0; in ext4_fc_replay_scan()
1941 state->fc_replay_num_tags = 0; in ext4_fc_replay_scan()
1942 state->fc_crc = 0; in ext4_fc_replay_scan()
1943 state->fc_regions = NULL; in ext4_fc_replay_scan()
1944 state->fc_regions_valid = state->fc_regions_used = in ext4_fc_replay_scan()
1945 state->fc_regions_size = 0; in ext4_fc_replay_scan()
1947 if (le16_to_cpu(((struct ext4_fc_tl *)start)->fc_tag) in ext4_fc_replay_scan()
1952 if (off != state->fc_replay_expected_off) { in ext4_fc_replay_scan()
1953 ret = -EFSCORRUPTED; in ext4_fc_replay_scan()
1957 state->fc_replay_expected_off++; in ext4_fc_replay_scan()
1962 tag2str(le16_to_cpu(tl.fc_tag)), bh->b_blocknr); in ext4_fc_replay_scan()
1969 le32_to_cpu(ex->ee_block), ext4_ext_pblock(ex), in ext4_fc_replay_scan()
1981 state->fc_cur_tag++; in ext4_fc_replay_scan()
1982 state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur, in ext4_fc_replay_scan()
1986 state->fc_cur_tag++; in ext4_fc_replay_scan()
1988 state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur, in ext4_fc_replay_scan()
1993 le32_to_cpu(tail.fc_crc) == state->fc_crc) { in ext4_fc_replay_scan()
1994 state->fc_replay_num_tags = state->fc_cur_tag; in ext4_fc_replay_scan()
1995 state->fc_regions_valid = in ext4_fc_replay_scan()
1996 state->fc_regions_used; in ext4_fc_replay_scan()
1998 ret = state->fc_replay_num_tags ? in ext4_fc_replay_scan()
1999 JBD2_FC_REPLAY_STOP : -EFSBADCRC; in ext4_fc_replay_scan()
2001 state->fc_crc = 0; in ext4_fc_replay_scan()
2007 ret = -EOPNOTSUPP; in ext4_fc_replay_scan()
2014 state->fc_cur_tag++; in ext4_fc_replay_scan()
2015 state->fc_crc = ext4_chksum(sbi, state->fc_crc, cur, in ext4_fc_replay_scan()
2019 ret = state->fc_replay_num_tags ? in ext4_fc_replay_scan()
2020 JBD2_FC_REPLAY_STOP : -ECANCELED; in ext4_fc_replay_scan()
2038 struct super_block *sb = journal->j_private; in ext4_fc_replay()
2043 struct ext4_fc_replay_state *state = &sbi->s_fc_replay_state; in ext4_fc_replay()
2047 state->fc_current_pass = PASS_SCAN; in ext4_fc_replay()
2051 if (state->fc_current_pass != pass) { in ext4_fc_replay()
2052 state->fc_current_pass = pass; in ext4_fc_replay()
2053 sbi->s_mount_state |= EXT4_FC_REPLAY; in ext4_fc_replay()
2055 if (!sbi->s_fc_replay_state.fc_replay_num_tags) { in ext4_fc_replay()
2062 if (sbi->s_fc_debug_max_replay && off >= sbi->s_fc_debug_max_replay) { in ext4_fc_replay()
2068 start = (u8 *)bh->b_data; in ext4_fc_replay()
2069 end = (__u8 *)bh->b_data + journal->j_blocksize - 1; in ext4_fc_replay()
2075 if (state->fc_replay_num_tags == 0) { in ext4_fc_replay()
2082 state->fc_replay_num_tags--; in ext4_fc_replay()
2117 ret = -ECANCELED; in ext4_fc_replay()
2134 journal->j_fc_replay_callback = ext4_fc_replay; in ext4_fc_init()
2137 journal->j_fc_cleanup_callback = ext4_fc_cleanup; in ext4_fc_init()
2145 "Swap boot",
2155 struct ext4_sb_info *sbi = EXT4_SB((struct super_block *)seq->private); in ext4_fc_info_show()
2156 struct ext4_fc_stats *stats = &sbi->s_fc_stats; in ext4_fc_info_show()
2164 stats->fc_num_commits, stats->fc_ineligible_commits, in ext4_fc_info_show()
2165 stats->fc_numblks, in ext4_fc_info_show()
2166 div_u64(sbi->s_fc_avg_commit_time, 1000)); in ext4_fc_info_show()
2170 stats->fc_ineligible_reason_count[i]); in ext4_fc_info_show()
2181 return -ENOMEM; in ext4_fc_init_dentry_cache()