All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: dm-devel@redhat.com,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	agk@redhat.com, Srinivas Eeda <srinivas.eeda@oracle.com>
Subject: Re: dm-io: reject unsupported DISCARD/WRITE SAME requests with EOPNOTSUPP
Date: Fri, 13 Feb 2015 10:55:50 -0500	[thread overview]
Message-ID: <20150213155550.GA32670@redhat.com> (raw)
In-Reply-To: <20150213092432.GC11034@birch.djwong.org>

On Fri, Feb 13 2015 at  4:24am -0500,
Darrick J. Wong <darrick.wong@oracle.com> wrote:

> I created a dm-raid1 device backed by a device that supports DISCARD
> and another device that does NOT support DISCARD with the following
> dm configuration:
> 
> # echo '0 2048 mirror core 1 512 2 /dev/sda 0 /dev/sdb 0' | dmsetup create moo
> # lsblk -D
> NAME         DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
> sda                 0        4K       1G         0
> `-moo (dm-0)        0        4K       1G         0
> sdb                 0        0B       0B         0
> `-moo (dm-0)        0        4K       1G         0
> 
> Notice that the mirror device /dev/mapper/moo advertises DISCARD
> support even though one of the mirror halves doesn't.
> 
> If I issue a DISCARD request (via fstrim, mount -o discard, or ioctl
> BLKDISCARD) through the mirror, kmirrord gets stuck in an infinite
> loop in do_region() when it tries to issue a DISCARD request to sdb.
> The problem is that when we call do_region() against sdb, num_sectors
> is set to zero because q->limits.max_discard_sectors is zero.
> Therefore, "remaining" never decreases and the loop never terminates.
> 
> Before entering the loop, check for the combination of REQ_DISCARD and
> no discard and return -EOPNOTSUPP to avoid hanging up the mirror
> device.  Fix the same problem with WRITE_DISCARD while we're at it.
> 
> This bug was found by the unfortunate coincidence of pvmove and a
> discard operation in the RHEL 6.5 kernel; 3.19 is also affected.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Srinivas Eeda <srinivas.eeda@oracle.com>

Your patch looks fine but it is laser focused on dm-io.  Again, that is
fine (fixes a real problem).  But I'm wondering how other targets will
respond in the face of partial discard support across the logical
address space of the DM device.

When I implemented dm_table_supports_discards() I consciously allowed a
DM table to contain a mix of discard support.  I'm now wondering where
it is we benefit from that?  Seems like more of a liability than
anything -- so a bigger hammer approach to fixing this would be to
require all targets and all devices in a DM table support discard.
Which amounts to changing dm_table_supports_discards() to be like
dm_table_supports_write_same().

BTW, given dm_table_supports_write_same(), your patch shouldn't need to
worry about WRITE SAME.  Did you experience issues with WRITE SAME too
or were you just being proactive?

Mike

  reply	other threads:[~2015-02-13 15:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-13  9:24 [PATCH] dm-io: reject unsupported DISCARD/WRITE SAME requests with EOPNOTSUPP Darrick J. Wong
2015-02-13 15:55 ` Mike Snitzer [this message]
2015-02-13 17:01   ` Darrick J. Wong
2015-02-13 19:21   ` Martin K. Petersen
2015-02-13 20:07     ` Darrick J. Wong
2015-02-13 20:58       ` Mike Snitzer
2015-02-13 21:12         ` Martin K. Petersen
2015-02-26 19:56   ` Mikulas Patocka
2015-02-26 20:10     ` Mikulas Patocka
2015-02-27 18:42     ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150213155550.GA32670@redhat.com \
    --to=snitzer@redhat.com \
    --cc=agk@redhat.com \
    --cc=darrick.wong@oracle.com \
    --cc=dm-devel@redhat.com \
    --cc=martin.petersen@oracle.com \
    --cc=srinivas.eeda@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.