[dm-devel] [PATCH] dm-mirror: do not degrade the mirror on discard error

Mikulas Patocka mpatocka at redhat.com
Thu Feb 12 15:43:07 UTC 2015



On Thu, 12 Feb 2015, Mikulas Patocka wrote:

> It may be possible that a device claims discard support but it rejects
> discards with -EOPNOTSUPP. It happens when using loopback on ext2/ext3
> filesystem driven by the ext4 driver. It may also happen if the underlying
> devices are moved from one disk on another.
> 
> If discard error happens, we reject the bio with -EOPNOTSUPP, but we do
> not degrade the array.
> 
> This patch fixes failed test shell/lvconvert-repair-transient.sh in the
> lvm2 testsuite if the testsuite is extracted on an ext2 or ext3 filesystem
> and it is being driven by the ext4 driver.
> 
> Signed-off-by: Mikulas Patocka <mpatocka at redhat.com>

I forgot to add

Cc: stable at kernel.org



BTW. that ext4 behavior is specific to RHEL 7. On upstream kernel, the 
ext4 driver can punch a hole in the ext2 or ext3 filesystem, but there are 
corruptions when doing it - see bug 1176840.

Mikulas

> Index: linux-2.6/drivers/md/dm-raid1.c
> ===================================================================
> --- linux-2.6.orig/drivers/md/dm-raid1.c
> +++ linux-2.6/drivers/md/dm-raid1.c
> @@ -604,6 +604,15 @@ static void write_callback(unsigned long
>  		return;
>  	}
>  
> +	/*
> +	 * If the bio is discard, return an error, but do not
> +	 * degrade the array.
> +	 */
> +	if (bio->bi_rw & REQ_DISCARD) {
> +		bio_endio(bio, -EOPNOTSUPP);
> +		return;
> +	}
> +
>  	for (i = 0; i < ms->nr_mirrors; i++)
>  		if (test_bit(i, &error))
>  			fail_mirror(ms->mirror + i, DM_RAID1_WRITE_ERROR);
> 




More information about the dm-devel mailing list