public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* dm-cache not writing out cache metadata at reboot?
@ 2013-05-08 21:48 Darrick J. Wong
  2013-05-08 22:05 ` Mike Snitzer
  0 siblings, 1 reply; 15+ messages in thread
From: Darrick J. Wong @ 2013-05-08 21:48 UTC (permalink / raw)
  To: Mike Snitzer, Joe Thornber; +Cc: device-mapper development, linux-kernel

Hi,

So I've been watching the hit/miss counters in dmcache and I've noticed a
couple of things that look like errors to me:

First, I noticed that if I reboot the system, neither cache_postsuspend nor
cache_dtr get called.  This might simply be expected behavior, but it means
that the in-memory superblock structure doesn't get written out to disk upon
reboot.  Just to be sure, I put a printk into __commit_transaction.  It prints
out for 'dmsetup info' and 'dmsetup remove' but nothing at reboot.

Second, cache_status calls dm_cache_commit, which writes out a superblock to
the metadata device.  However, there's no call to save_stats to copy the
current values of the counters out to the disk's copy prior to calling
dm_cache_commit.  Therefore, we seem to be writing out stale copies of
superblock fields.

The second one seems fixable with the attached patch, but the first one I don't
know about.  Any ideas?

---
Subject: [PATCH] dmcache: flush superblock when retrieving status info

When userspace queries dmcache for stats info, we should ensure that all the
metadata gets flushed out of memory to disk.  The current code neglects to
update at least the hit/miss counters, so take care of everything.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 drivers/md/dm-cache-target.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c
index 1074409..f476ada 100644
--- a/drivers/md/dm-cache-target.c
+++ b/drivers/md/dm-cache-target.c
@@ -2451,8 +2451,7 @@ static void cache_status(struct dm_target *ti, status_type_t type,
 	case STATUSTYPE_INFO:
 		/* Commit to ensure statistics aren't out-of-date */
 		if (!(status_flags & DM_STATUS_NOFLUSH_FLAG) && !dm_suspended(ti)) {
-			r = dm_cache_commit(cache->cmd, false);
-			if (r)
+			if (!sync_metadata(cache))
 				DMERR("could not commit metadata for accurate status");
 		}
 

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2013-05-13 21:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-08 21:48 dm-cache not writing out cache metadata at reboot? Darrick J. Wong
2013-05-08 22:05 ` Mike Snitzer
2013-05-08 23:23   ` Darrick J. Wong
2013-05-09 20:36   ` Darrick J. Wong
2013-05-09 20:44     ` [PATCH 1/2] dmcache: flush superblock stats when retrieving status info Darrick J. Wong
2013-05-10 10:10       ` Joe Thornber
2013-05-10 12:53         ` Mike Snitzer
2013-05-09 20:47     ` dm-cache not writing out cache metadata at reboot? Mike Snitzer
2013-05-09 20:47     ` [PATCH 2/2] dmcache: Implement a flush message Darrick J. Wong
2013-05-10 10:22       ` [dm-devel] " Joe Thornber
2013-05-10 17:51         ` Darrick J. Wong
2013-05-11 15:25           ` Mike Snitzer
2013-05-13 12:04             ` Peter Rajnoha
2013-05-13 21:36               ` [dm-devel] " Darrick J. Wong
2013-05-10 10:05   ` [dm-devel] dm-cache not writing out cache metadata at reboot? Joe Thornber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox