mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-03 18:20:25 +02:00 
			
		
		
		
	btrfs: zoned: don't clear dirty flag of extent buffer
One a zoned filesystem, never clear the dirty flag of an extent buffer, but instead mark it as zeroout. On writeout, when encountering a marked extent_buffer, zero it out. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
		
							parent
							
								
									cbf44cd93d
								
							
						
					
					
						commit
						aa6313e6ff
					
				
					 3 changed files with 22 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -254,8 +254,13 @@ blk_status_t btree_csum_one_bio(struct btrfs_bio *bbio)
 | 
			
		|||
	if (WARN_ON_ONCE(bbio->bio.bi_iter.bi_size != eb->len))
 | 
			
		||||
		return BLK_STS_IOERR;
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * If an extent_buffer is marked as EXTENT_BUFFER_ZONED_ZEROOUT, don't
 | 
			
		||||
	 * checksum it but zero-out its content. This is done to preserve
 | 
			
		||||
	 * ordering of I/O without unnecessarily writing out data.
 | 
			
		||||
	 */
 | 
			
		||||
	if (test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags)) {
 | 
			
		||||
		WARN_ON_ONCE(found_start != 0);
 | 
			
		||||
		memzero_extent_buffer(eb, 0, eb->len);
 | 
			
		||||
		return BLK_STS_OK;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3761,6 +3761,20 @@ void btrfs_clear_buffer_dirty(struct btrfs_trans_handle *trans,
 | 
			
		|||
	if (trans && btrfs_header_generation(eb) != trans->transid)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * Instead of clearing the dirty flag off of the buffer, mark it as
 | 
			
		||||
	 * EXTENT_BUFFER_ZONED_ZEROOUT. This allows us to preserve
 | 
			
		||||
	 * write-ordering in zoned mode, without the need to later re-dirty
 | 
			
		||||
	 * the extent_buffer.
 | 
			
		||||
	 *
 | 
			
		||||
	 * The actual zeroout of the buffer will happen later in
 | 
			
		||||
	 * btree_csum_one_bio.
 | 
			
		||||
	 */
 | 
			
		||||
	if (btrfs_is_zoned(fs_info)) {
 | 
			
		||||
		set_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags);
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (!test_and_clear_bit(EXTENT_BUFFER_DIRTY, &eb->bflags))
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -4152,8 +4166,6 @@ static void __write_extent_buffer(const struct extent_buffer *eb,
 | 
			
		|||
	/* For unmapped (dummy) ebs, no need to check their uptodate status. */
 | 
			
		||||
	const bool check_uptodate = !test_bit(EXTENT_BUFFER_UNMAPPED, &eb->bflags);
 | 
			
		||||
 | 
			
		||||
	WARN_ON(test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags));
 | 
			
		||||
 | 
			
		||||
	if (check_eb_range(eb, start, len))
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1713,7 +1713,8 @@ void btrfs_redirty_list_add(struct btrfs_transaction *trans,
 | 
			
		|||
	    btrfs_header_flag(eb, BTRFS_HEADER_FLAG_WRITTEN))
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	ASSERT(!test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags));
 | 
			
		||||
	ASSERT(test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags));
 | 
			
		||||
	ASSERT(test_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags));
 | 
			
		||||
 | 
			
		||||
	memzero_extent_buffer(eb, 0, eb->len);
 | 
			
		||||
	set_bit(EXTENT_BUFFER_ZONED_ZEROOUT, &eb->bflags);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue