mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	xfs: shutdown on failure to add page to log bio
If the bio_add_page() call fails, we proceed to write out a
partially constructed log buffer. This corrupts the physical log
such that log recovery is not possible. Worse, persistent
occurrences of this error eventually lead to a BUG_ON() failure in
bio_split() as iclogs wrap the end of the physical log, which
triggers log recovery on subsequent mount.
Rather than warn about writing out a corrupted log buffer, shutdown
the fs as is done for any log I/O related error. This preserves the
consistency of the physical log such that log recovery succeeds on a
subsequent mount. Note that this was observed on a 64k page debug
kernel without upstream commit 59bb47985c ("mm, sl[aou]b:
guarantee natural alignment for kmalloc(power-of-two)"), which
demonstrated frequent iclog bio overflows due to unaligned (slab
allocated) iclog data buffers.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
			
			
This commit is contained in:
		
							parent
							
								
									d59f44d3e7
								
							
						
					
					
						commit
						842a42d126
					
				
					 1 changed files with 9 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -1703,7 +1703,7 @@ xlog_bio_end_io(
 | 
			
		|||
		   &iclog->ic_end_io_work);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
static int
 | 
			
		||||
xlog_map_iclog_data(
 | 
			
		||||
	struct bio		*bio,
 | 
			
		||||
	void			*data,
 | 
			
		||||
| 
						 | 
				
			
			@ -1714,11 +1714,14 @@ xlog_map_iclog_data(
 | 
			
		|||
		unsigned int	off = offset_in_page(data);
 | 
			
		||||
		size_t		len = min_t(size_t, count, PAGE_SIZE - off);
 | 
			
		||||
 | 
			
		||||
		WARN_ON_ONCE(bio_add_page(bio, page, len, off) != len);
 | 
			
		||||
		if (bio_add_page(bio, page, len, off) != len)
 | 
			
		||||
			return -EIO;
 | 
			
		||||
 | 
			
		||||
		data += len;
 | 
			
		||||
		count -= len;
 | 
			
		||||
	} while (count);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
STATIC void
 | 
			
		||||
| 
						 | 
				
			
			@ -1762,7 +1765,10 @@ xlog_write_iclog(
 | 
			
		|||
	if (need_flush)
 | 
			
		||||
		iclog->ic_bio.bi_opf |= REQ_PREFLUSH;
 | 
			
		||||
 | 
			
		||||
	xlog_map_iclog_data(&iclog->ic_bio, iclog->ic_data, count);
 | 
			
		||||
	if (xlog_map_iclog_data(&iclog->ic_bio, iclog->ic_data, count)) {
 | 
			
		||||
		xfs_force_shutdown(log->l_mp, SHUTDOWN_LOG_IO_ERROR);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
	if (is_vmalloc_addr(iclog->ic_data))
 | 
			
		||||
		flush_kernel_vmap_range(iclog->ic_data, count);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue