// SPDX-License-Identifier: GPL-2.0+ /* * linux/fs/jbd2/commit.c * * Written by Stephen C. Tweedie <[email protected]>, 1998 * * Copyright 1998 Red Hat corp --- All Rights Reserved * * Journal commit routines for the generic filesystem journaling code; * part of the ext2fs journaling system. */ #include <linux/time.h> #include <linux/fs.h> #include <linux/jbd2.h> #include <linux/errno.h> #include <linux/slab.h> #include <linux/mm.h> #include <linux/pagemap.h> #include <linux/jiffies.h> #include <linux/crc32.h> #include <linux/writeback.h> #include <linux/backing-dev.h> #include <linux/bio.h> #include <linux/blkdev.h> #include <linux/bitops.h> #include <trace/events/jbd2.h> /* * IO end handler for temporary buffer_heads handling writes to the journal. */ static void journal_end_buffer_io_sync(struct buffer_head *bh, int uptodate) { … } /* * When an ext4 file is truncated, it is possible that some pages are not * successfully freed, because they are attached to a committing transaction. * After the transaction commits, these pages are left on the LRU, with no * ->mapping, and with attached buffers. These pages are trivially reclaimable * by the VM, but their apparent absence upsets the VM accounting, and it makes * the numbers in /proc/meminfo look odd. * * So here, we have a buffer which has just come off the forget list. Look to * see if we can strip all buffers from the backing page. * * Called under lock_journal(), and possibly under journal_datalist_lock. The * caller provided us with a ref against the buffer, and we drop that here. */ static void release_buffer_page(struct buffer_head *bh) { … } static void jbd2_commit_block_csum_set(journal_t *j, struct buffer_head *bh) { … } /* * Done it all: now submit the commit record. We should have * cleaned up our previous buffers by now, so if we are in abort * mode we can now just skip the rest of the journal write * entirely. * * Returns 1 if the journal needs to be aborted or 0 on success */ static int journal_submit_commit_record(journal_t *journal, transaction_t *commit_transaction, struct buffer_head **cbh, __u32 crc32_sum) { … } /* * This function along with journal_submit_commit_record * allows to write the commit record asynchronously. */ static int journal_wait_on_commit_record(journal_t *journal, struct buffer_head *bh) { … } /* Send all the data buffers related to an inode */ int jbd2_submit_inode_data(journal_t *journal, struct jbd2_inode *jinode) { … } EXPORT_SYMBOL(…); int jbd2_wait_inode_data(journal_t *journal, struct jbd2_inode *jinode) { … } EXPORT_SYMBOL(…); /* * Submit all the data buffers of inode associated with the transaction to * disk. * * We are in a committing transaction. Therefore no new inode can be added to * our inode list. We use JI_COMMIT_RUNNING flag to protect inode we currently * operate on from being released while we write out pages. */ static int journal_submit_data_buffers(journal_t *journal, transaction_t *commit_transaction) { … } int jbd2_journal_finish_inode_data_buffers(struct jbd2_inode *jinode) { … } /* * Wait for data submitted for writeout, refile inodes to proper * transaction if needed. * */ static int journal_finish_inode_data_buffers(journal_t *journal, transaction_t *commit_transaction) { … } static __u32 jbd2_checksum_data(__u32 crc32_sum, struct buffer_head *bh) { … } static void write_tag_block(journal_t *j, journal_block_tag_t *tag, unsigned long long block) { … } static void jbd2_block_tag_csum_set(journal_t *j, journal_block_tag_t *tag, struct buffer_head *bh, __u32 sequence) { … } /* * jbd2_journal_commit_transaction * * The primary function for committing a transaction to the log. This * function is called by the journal thread to begin a complete commit. */ void jbd2_journal_commit_transaction(journal_t *journal) { … }