dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: dm-devel@redhat.com, Alasdair G Kergon <agk@redhat.com>
Subject: Re: [PATCH 1/4] Check that the target supports discard
Date: Fri, 2 Jul 2010 14:05:29 -0400	[thread overview]
Message-ID: <20100702180529.GC26916@redhat.com> (raw)
In-Reply-To: <Pine.LNX.4.64.1007021112340.7296@hs20-bc2-1.build.redhat.com>

On Fri, Jul 02 2010 at 11:17am -0400,
Mikulas Patocka <mpatocka@redhat.com> wrote:

> Check that the target supports discard
> 
> Because of a various race conditions, discard request may be submitted to
> device mapper even if device mapper advertises that it doesn't support
> discards. (for example, the device is linear, dm advertises discard support,
> discard request is constructed, the table is reloaded with mirror, the discard
> is submitted to the mirror target that doesn't support it).
> 
> To solve these problems we must check that the target supports discard
> just before submitting discard request to it.
> 
> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
> 
> ---
>  drivers/md/dm.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> Index: linux-2.6.35-rc3-fast/drivers/md/dm.c
> ===================================================================
> --- linux-2.6.35-rc3-fast.orig/drivers/md/dm.c	2010-07-02 16:10:25.000000000 +0200
> +++ linux-2.6.35-rc3-fast/drivers/md/dm.c	2010-07-02 16:11:22.000000000 +0200
> @@ -1223,6 +1223,9 @@ static int __clone_and_map_discard(struc
>  	if (!dm_target_is_valid(ti))
>  		return -EIO;
>  
> +	if (!(ti->type->features & DM_TARGET_SUPPORTS_DISCARDS))
> +		return -EOPNOTSUPP;
> +
>  	max = max_io_len(ci->md, ci->sector, ti);
>  
>  	if (ci->sector_count > max)
> 

The current model is that the static DM_TARGET_SUPPORTS_DISCARDS is
consulted when the target is added to table.  And then at the end of the
table load we check all devices to see if they actually do support
discards.

That said, I understand that IOs in flight before a table is suspended
will be attempted after the table is reload.  So this patch is good.

It should be noted that checking for this race condition gets much
harder once DM supports splitting discards that span devices.  We'll
have potential for partial completion that in the end returns
-EOPNOTSUPP.  Which is fine; but I think we'll need to be careful to not
return -EOPNOTSUPP before outstanding IO (associated with the discard
we're intending to return -EOPNOTSUPP for) completes?

Anyway, we'll cross that bridge later.  Nice catch.

Acked-by: Mike Snitzer <snitzer@redhat.com>

  parent reply	other threads:[~2010-07-02 18:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-02 15:12 [PATCH 0/4] discard updates Mikulas Patocka
2010-07-02 15:17 ` [PATCH 1/4] Check that the target supports discard Mikulas Patocka
2010-07-02 15:18   ` [PATCH 2/4] Clear the discard flag if the device loses discard capability Mikulas Patocka
2010-07-02 15:19     ` [PATCH 3/4] Support discard for multiple devices Mikulas Patocka
2010-07-02 15:19       ` [PATCH 4/4] Support discard if at least one underlying device supports it Mikulas Patocka
2010-07-02 18:14         ` Mike Snitzer
2010-07-02 19:49           ` Mikulas Patocka
2010-07-02 20:00             ` Mikulas Patocka
2010-07-02 20:08               ` GFP_KERNEL in ext4 (was: [PATCH 4/4] Support discard if at least one underlying device supports it) Mikulas Patocka
2010-07-06 16:11                 ` [PATCH] disallow FS recursion from sb_issue_discard allocation Mike Snitzer
2010-07-27 13:44                   ` Ted Ts'o
2010-07-27 15:33                     ` Mike Snitzer
2010-07-28 18:12                       ` Jens Axboe
2010-07-28 23:15                         ` Ted Ts'o
2010-07-02 20:47               ` [PATCH 4/4] Support discard if at least one underlying device supports it Mike Snitzer
2010-07-02 20:54                 ` Alasdair G Kergon
2010-07-05  7:03                 ` Dmitry Monakhov
2010-07-05 11:32                 ` Mikulas Patocka
2010-07-02 20:29             ` Mike Snitzer
2010-07-08  0:07         ` Alasdair G Kergon
2010-07-02 17:50       ` [PATCH 3/4] Support discard for multiple devices Mike Snitzer
2010-07-07 23:23       ` Alasdair G Kergon
2010-07-02 17:51     ` [PATCH 2/4] Clear the discard flag if the device loses discard capability Mike Snitzer
2010-07-07 23:18     ` Alasdair G Kergon
2010-07-02 18:05   ` Mike Snitzer [this message]
2010-07-07 23:14   ` [PATCH 1/4] Check that the target supports discard Alasdair G Kergon

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=20100702180529.GC26916@redhat.com \
    --to=snitzer@redhat.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=mpatocka@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).