From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mike Snitzer Subject: Re: [PATCH 3/3] dm-thin: fix discard_granularity Date: Tue, 17 Jul 2012 11:31:41 -0400 Message-ID: <20120717153140.GA18345@redhat.com> References: Reply-To: device-mapper development Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: Mikulas Patocka Cc: dm-devel@redhat.com, Edward Thornber , "Alasdair G. Kergon" List-Id: dm-devel.ids On Mon, Jul 16 2012 at 2:35pm -0400, Mikulas Patocka wrote: > dm-thin: fix discard_granularity > > The kernel expects that limits->discard_granularity is a power of two. > Set this limit only if we use a power of two block size. > > Signed-off-by: Mikulas Patocka > > --- > drivers/md/dm-thin.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > Index: linux-3.5-rc6-fast/drivers/md/dm-thin.c > =================================================================== > --- linux-3.5-rc6-fast.orig/drivers/md/dm-thin.c 2012-07-16 20:07:49.000000000 +0200 > +++ linux-3.5-rc6-fast/drivers/md/dm-thin.c 2012-07-16 20:08:01.000000000 +0200 > @@ -2502,7 +2502,8 @@ static void set_discard_limits(struct po > * bios cover a block partially. A discard that spans a block boundary > * is not sent to this target. > */ > - limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT; > + if (pool->sectors_per_block_shift >= 0) > + limits->discard_granularity = pool->sectors_per_block << SECTOR_SHIFT; > limits->discard_zeroes_data = pool->pf.zero_new_blocks; > } Given the block layer's assumption that discard_granularity is always a power of 2: thinp should disable discard if the thinp blocksize is a non power of 2. So this patch isn't correct (discard support should be disabled in pool_ctr based on the specified blocksize). Future work should be: 1) explore/eliminate the block layer's power of 2 constraints 2) divorce thinp's discard limits (for discard passdown) from the pool's blocksize