linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Shaohua Li <shli@kernel.org>
Cc: NeilBrown <neilb@suse.de>,
	linux RAID <linux-raid@vger.kernel.org>,
	Jens Axboe <axboe@kernel.dk>, lkml <linux-kernel@vger.kernel.org>
Subject: Re: Problem with DISCARD and RAID5
Date: Tue, 6 Nov 2012 08:48:46 +1100	[thread overview]
Message-ID: <20121105214846.GM29378@dastard> (raw)
In-Reply-To: <20121102014058.GA20526@kernel.org>

On Fri, Nov 02, 2012 at 09:40:58AM +0800, Shaohua Li wrote:
> On Thu, Nov 01, 2012 at 05:38:54PM +1100, NeilBrown wrote:
> > 
> > Hi Shaohua,
> >  I've been doing some testing and discovered a problem with your discard
> >  support for RAID5.
> > 
> >  The code in blkdev_issue_discard assumes that the 'granularity' is a power
> >  of 2, and for example subtracts 1 to get a mask.
> > 
> >  However RAID5 sets the granularity to be the stripe size which often is not
> >  a power of two.  When this happens you can easily get into an infinite loop.
> > 
> >  I suspect that to make this work properly, blkdev_issue_discard will need to
> >  be changed to allow 'granularity' to be an arbitrary value.
> >  When it is a power of two, the current masking can be used.
> >  When it is anything else, it will need to use sector_div().
> 
> Yep, looks we need use sector_div. And this isn't the only problem. discard
> request can be merged, and the merge check only checks max_discard_sectors.
> That means the split requests in blkdev_issue_discard can be merged again. The
> split nerver works.
> 
> I'm wondering what's purpose of discard_alignment and discard_granularity. Are
> there devices with discard_granularity not 1 sector?

Most certainly. Thin provisioned storage often has granularity in the
order of megabytes....

> If bio isn't discard
> aligned, what device will do?

Up to the device.

> Further, why driver handles alignment/granularity
> if device will ignore misaligned request.

When you send a series of sequential unaligned requests, the device
may ignore them all. Hence you end up with nothing being discarded,
even though the entire range being discarded is much, much larger
than the discard granularity....

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2012-11-05 21:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-01  6:38 Problem with DISCARD and RAID5 NeilBrown
2012-11-02  1:40 ` Shaohua Li
2012-11-05 21:48   ` Dave Chinner [this message]
2012-11-06  8:06     ` Jens Axboe
2012-11-07  5:02       ` Shaohua Li

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=20121105214846.GM29378@dastard \
    --to=david@fromorbit.com \
    --cc=axboe@kernel.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=shli@kernel.org \
    /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).