From patchwork Thu Mar 15 10:42:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Coly Li X-Patchwork-Id: 10284211 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A90FD602C2 for ; Thu, 15 Mar 2018 10:43:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E533286CB for ; Thu, 15 Mar 2018 10:43:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72C7C28786; Thu, 15 Mar 2018 10:43:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EDAB286CB for ; Thu, 15 Mar 2018 10:43:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751739AbeCOKnE (ORCPT ); Thu, 15 Mar 2018 06:43:04 -0400 Received: from mx2.suse.de ([195.135.220.15]:54820 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751805AbeCOKnC (ORCPT ); Thu, 15 Mar 2018 06:43:02 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1FF01AECC; Thu, 15 Mar 2018 10:43:01 +0000 (UTC) From: Coly Li To: linux-bcache@vger.kernel.org Cc: linux-block@vger.kernel.org, Coly Li Subject: [PATCH 2/4] bcache-tools: only set/display sb.bucket_size for cache devices Date: Thu, 15 Mar 2018 18:42:38 +0800 Message-Id: <20180315104240.24647-3-colyli@suse.de> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180315104240.24647-1-colyli@suse.de> References: <20180315104240.24647-1-colyli@suse.de> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP bucket_size of struct cached_dev is not shared between cache devices and backing devices. Currently make-bcache.c assigns bucket_size to backing devices, and bcache-super-show.c displays bucket_size for backing devices, all these are incorrect. This patch fixes it by only set and display sb.bucket_size for cache device super block. Signed-off-by: Coly Li --- bcache-super-show.c | 9 ++++----- make-bcache.c | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/bcache-super-show.c b/bcache-super-show.c index 26cc40e..515c596 100644 --- a/bcache-super-show.c +++ b/bcache-super-show.c @@ -160,20 +160,19 @@ int main(int argc, char **argv) uuid_unparse(sb.uuid, uuid); printf("dev.uuid\t\t%s\n", uuid); - printf("dev.sectors_per_block\t%u\n" - "dev.sectors_per_bucket\t%u\n", - sb.block_size, - sb.bucket_size); + printf("dev.sectors_per_block\t%u\n", sb.block_size); if (!SB_IS_BDEV(&sb)) { // total_sectors includes the superblock; - printf("dev.cache.first_sector\t%u\n" + printf("dev.sectors_per_block\t%u\n" + "dev.cache.first_sector\t%u\n" "dev.cache.cache_sectors\t%ju\n" "dev.cache.total_sectors\t%ju\n" "dev.cache.ordered\t%s\n" "dev.cache.discard\t%s\n" "dev.cache.pos\t\t%u\n" "dev.cache.replacement\t%ju", + sb.bucket_size, sb.bucket_size * sb.first_bucket, sb.bucket_size * (sb.nbuckets - sb.first_bucket), sb.bucket_size * sb.nbuckets, diff --git a/make-bcache.c b/make-bcache.c index c626eae..14c605d 100644 --- a/make-bcache.c +++ b/make-bcache.c @@ -217,7 +217,6 @@ static void write_sb(char *dev, unsigned block_size, unsigned bucket_size, uuid_generate(sb.uuid); memcpy(sb.set_uuid, set_uuid, sizeof(sb.set_uuid)); - sb.bucket_size = bucket_size; sb.block_size = block_size; uuid_unparse(sb.uuid, uuid_str); @@ -242,6 +241,7 @@ static void write_sb(char *dev, unsigned block_size, unsigned bucket_size, sb.block_size, data_offset); } else { + sb.bucket_size = bucket_size; sb.nbuckets = getblocks(fd) / sb.bucket_size; sb.nr_in_set = 1; sb.first_bucket = (23 / sb.bucket_size) + 1;