All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Pelletier <plr.vincent@gmail.com>
To: dm-devel@redhat.com
Cc: ejt@redhat.com
Subject: dm-cache: resize_cache_dev resizing to wrong size ?
Date: Sat, 30 Nov 2013 12:58:42 +0100	[thread overview]
Message-ID: <20131130125842.098ad167@x2> (raw)

[-- Attachment #1: Type: text/plain, Size: 1061 bytes --]

Hi.

CC'ing f494a9c6b1b6dd9a9f21bbb75d9210d478eeb498 author.
Please keep me CC'ed in replies, I'm not subscribed.

Wandering aimlessly in dm-cache source as of current linus master
(3.13-rc2, dc1ccc48159d63eca5089e507c82c7d22ef60839), I noticed this:

dm-cache-metadata.c:
  int dm_cache_resize(struct dm_cache_metadata *cmd, dm_cblock_t new_cache_size)

Note second argument is new_cache_size. But caller is doing:

dm-cache-target.c:
  static int resize_cache_dev(struct cache *cache, dm_cblock_t new_size)
  [...]
    r = dm_cache_resize(cache->cmd, cache->cache_size);
  [...]
    cache->cache_size = new_size;

dm_cache_resize is called with cache->cache_size before it gets updated
to new_size, so it looks like a no-op.

Can someone confirm my reading ?

If confirmed, the effect is that a shrink (only ? I'm not familiar with
cache metadata) operation can result in metadata inconsistent with
cache device size.

See attachment for proposed (untested) fix.
It applies cleanly as of current device-mapper for-next branch.

Regards,
-- 
Vincent Pelletier

[-- Attachment #2: 0001-dm-cache-actually-shrink-cache-to-new-size.patch --]
[-- Type: text/x-patch, Size: 910 bytes --]

From 99fe12976eae6abd67be0c39798c61ca9acd683d Mon Sep 17 00:00:00 2001
Message-Id: <99fe12976eae6abd67be0c39798c61ca9acd683d.1385805937.git.plr.vincent@gmail.com>
From: Vincent Pelletier <plr.vincent@gmail.com>
Date: Sat, 30 Nov 2013 11:05:12 +0100
Subject: dm cache: actually shrink cache to new size

Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com>
---
 drivers/md/dm-cache-target.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 9efcf10..1b1469e 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -2755,7 +2755,7 @@ static int resize_cache_dev(struct cache *cache, dm_cblock_t new_size)
 {
 	int r;
 
-	r = dm_cache_resize(cache->cmd, cache->cache_size);
+	r = dm_cache_resize(cache->cmd, new_size);
 	if (r) {
 		DMERR("could not resize cache metadata");
 		return r;
-- 
1.8.4.4


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



             reply	other threads:[~2013-11-30 11:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-30 11:58 Vincent Pelletier [this message]
2013-12-02 13:18 ` dm-cache: resize_cache_dev resizing to wrong size ? Joe Thornber

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=20131130125842.098ad167@x2 \
    --to=plr.vincent@gmail.com \
    --cc=dm-devel@redhat.com \
    --cc=ejt@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 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.