Skip to contentSkip to conversation

fs-writeback: writeback_sb_inodes: Recalculate 'wrote' according skipped pages

PATCH Zhihao Cheng 1 participant 1 message Apr 18, 2022 1 message not in the archive VFS

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

HI Hillf,

Quoted 5 lines · On Mon, 18 Apr 2022 17:28:24 +0800 Zhihao Cheng wrote:
Quoted 4 lines

Commit 505a666ee3fc ("writeback: plug writeback in wb_writeback() and writeback_inodes_wb()") has us holding a plug during wb_writeback, which may cause a potential ABBA dead lock:

Quoted 7 lines
Quoted 7 lines

wb_writeback fat_file_fsync
blk_start_plug(&plug)
for (;;) {
iter i-1: some reqs have been added into plug->mq_list // LOCK A iter i:
progress = __writeback_inodes_wb(wb, work)
. writeback_sb_inodes // fat's bdev

See comments " fat's bdev".

Quoted 9 lines
	if (inode->i_state & I_SYNC) {
		/* Wait for I_SYNC. This function drops i_lock... */
		inode_sleep_on_writeback(inode);
		/* Inode may be gone, start again */
		spin_lock(&wb->list_lock);
		continue;
	}
	inode->i_state |= I_SYNC;

This inode is fat's bdev's inode.

Quoted 9 lines
Quoted 7 lines
     .   __writeback_single_inode
     .   . generic_writepages
     .   .   __block_write_full_page
     .   .   . . 	    __generic_file_fsync
     .   .   . . 	      sync_inode_metadata
     .   .   . . 	        writeback_single_inode
				if (inode->i_state & I_SYNC) {

This inode is fat's inode.

Quoted 21 lines
					/*
					 * Writeback is already running on the inode.  For WB_SYNC_NONE,
					 * that's enough and we can just return.  For WB_SYNC_ALL, we
					 * must wait for the existing writeback to complete, then do
					 * writeback again if there's anything left.
					 */
					if (wbc->sync_mode != WB_SYNC_ALL)
						goto out;
					__inode_wait_for_writeback(inode);
				}
				inode->i_state |= I_SYNC;
Quoted 8 lines
     .   .   . . 		  __writeback_single_inode
     .   .   . . 		    fat_write_inode
     .   .   . . 		      __fat_write_inode
     .   .   . . 		        sync_dirty_buffer	// fat's bdev
     .   .   . . 			  lock_buffer(bh)	// LOCK B
     .   .   . . 			    submit_bh
     .   .   . . 			      blk_mq_get_tag	// LOCK A
     .   .   . trylock_buffer(bh)  // LOCK B
Quoted 1 line

Given I_SYNC checked on both sides, the chance for ABBA deadlock is zero.

Above two inodes are not same.