From patchwork Wed May 8 21:48:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2541891 Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by patchwork2.kernel.org (Postfix) with ESMTP id 93CC2DF2E5 for ; Wed, 8 May 2013 21:52:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r48LmpPl027355; Wed, 8 May 2013 17:48:54 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r48Lmoip029757 for ; Wed, 8 May 2013 17:48:50 -0400 Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.18]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r48LmoFe000442; Wed, 8 May 2013 17:48:50 -0400 Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r48LmnG8017544; Wed, 8 May 2013 17:48:49 -0400 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r48LmlqN002990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 8 May 2013 21:48:48 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r48LmlrD004916 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Wed, 8 May 2013 21:48:47 GMT Received: from abhmt108.oracle.com (abhmt108.oracle.com [141.146.116.60]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r48Lmln1001134; Wed, 8 May 2013 21:48:47 GMT Received: from localhost (/67.171.138.228) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 08 May 2013 14:48:46 -0700 Date: Wed, 8 May 2013 14:48:45 -0700 From: "Darrick J. Wong" To: Mike Snitzer , Joe Thornber Message-ID: <20130508214845.GA7729@blackbox.djwong.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: ucsinet21.oracle.com [156.151.31.93] X-RedHat-Spam-Score: -105.552 (BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_IN_WHITELIST) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.18 X-loop: dm-devel@redhat.com Cc: device-mapper development , linux-kernel@vger.kernel.org Subject: [dm-devel] dm-cache not writing out cache metadata at reboot? X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com 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 --- drivers/md/dm-cache-target.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel 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"); }