System crash can leave FS in inconsistent state. This can be repaired using FS checkers, however they are slow. Modern FS prefer journaling also known as “Write-ahead” logging. It is a technique when before actual writing of data, operation is logged. This helps in case of crash where only the journal log is replayed instead of whole disk scan. Journal can be a file within FS or different device. Journal normally contains a “Transaction” start, followed by what needs to be updated, finally it has an end marker called “transaction” end. These set of information have enough information to replay in case of crash. A Journaled FS, first writes the journaled log (also only called log) and once this is successful it “checkpoints” or updates the metadata with the latest information.
Every write can be divide into two operations. 1) First, write to metadata, 2) Second, The Data itself. (block write)
- Data journaling - Where both metadata and data are journaled. Downside, is that data is written twice.
- Metadata journaling (ordered) - Where only metadata is journaled. In this case data is first wirtten followed by Metadata.
- FS is consistent. All failure.
- Here there will no updated inode pointing to data.
- from FS point of view it is still consistent
- Inode points to latest updated data. Which is not there but garbage
- FS is in in-consistent state.
Write barrieres gurantees that the write before the issue of barrier would be executed first and would not be reorderd due to buffereing or cacheing. Journaling
- blk_queue_flag_set
- blk_queue_flag_clear
- blk_queue_flag_test_and_set
- blk_rq_init
- errno_to_blk_status
- blk_status_to_errno
- blk_dump_rq_flags
- blk_sync_queue
- blk_set_pm_only
- blk_clear_pm_only
- blk_put_queue
- blk_set_queue_dying
- blk_cleanup_queue
- blk_alloc_queue
- blk_alloc_queue_node
- blk_get_queue
- blk_get_request
- blk_put_request
- blk_init_request_from_bio
- generic_make_request
- direct_make_request
- submit_bio
- blk_insert_cloned_request
- blk_rq_err_bytes
- blk_steal_bios
- blk_update_request
- rq_flush_dcache_pages
- blk_lld_busy
- blk_rq_unprep_clone
- blk_rq_prep_clone
- kblockd_schedule_work
- kblockd_schedule_work_on
- kblockd_mod_delayed_work_on
- blk_start_plug
- blk_check_plugged
- blk_finish_plug
- blkdev_issue_discard
- blkdev_issue_write_same
- blkdev_issue_zeroout
- fs_bio_set
- bio_uninit
- bio_init
- bio_reset
- bio_chain
- bio_alloc_bioset
- zero_fill_bio_iter
- bio_put
- bio_clone_fast
- bio_add_pc_page
- bio_add_page
- submit_bio_wait
- bio_advance
- bio_copy_data_iter
- bio_copy_data
- bio_list_copy_data
- bio_free_pages
- bio_map_kern
- generic_start_io_acct
- generic_end_io_acct
- bio_flush_dcache_pages
- bio_endio
- bio_split
- bio_trim
- bioset_exit
- bioset_init
- bioset_init_from_src
- bio_disassociate_blkg
- bio_associate_blkg_from_css
- bio_associate_blkg
- bio_clone_blkg_association