From patchwork Wed Jun 19 08:03:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 11006025 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9A1D1986 for ; Thu, 20 Jun 2019 07:21:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 944962852A for ; Thu, 20 Jun 2019 07:21:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8900428541; Thu, 20 Jun 2019 07:21:49 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E745C2852B for ; Thu, 20 Jun 2019 07:21:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 81930619FB; Thu, 20 Jun 2019 07:21:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5511B60156; Thu, 20 Jun 2019 07:21:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B114C1806B0F; Thu, 20 Jun 2019 07:21:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5J83h1s006746 for ; Wed, 19 Jun 2019 04:03:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8242F60FDE; Wed, 19 Jun 2019 08:03:43 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 762E05C2E8 for ; Wed, 19 Jun 2019 08:03:41 +0000 (UTC) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F27B83086213 for ; Wed, 19 Jun 2019 08:03:26 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id A2BEAAF68; Wed, 19 Jun 2019 08:03:25 +0000 (UTC) From: Qu Wenruo To: dm-devel@redhat.com Date: Wed, 19 Jun 2019 16:03:12 +0800 Message-Id: <20190619080312.11549-3-wqu@suse.com> In-Reply-To: <20190619080312.11549-1-wqu@suse.com> References: <20190619080312.11549-1-wqu@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 19 Jun 2019 08:03:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 19 Jun 2019 08:03:29 +0000 (UTC) for IP:'195.135.220.15' DOMAIN:'mx2.suse.de' HELO:'mx1.suse.de' FROM:'wqu@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.299 (RCVD_IN_DNSWL_MED, SPF_NONE) 195.135.220.15 mx2.suse.de 195.135.220.15 mx2.suse.de X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Thu, 20 Jun 2019 03:21:43 -0400 Cc: linux-btrfs@vger.kernel.org Subject: [dm-devel] [PATCH 2/2] dm log writes: Introduce dump_type= message type to change dump_type on the fly X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk 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 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 20 Jun 2019 07:21:47 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP The new message format is: dump_type= The parameter of dump_type= follows the same one of constructor. This allows us to change dump_type on the fly, making the following use case possible: # dmsetup create log --table 0 10485760 log-writes \ /dev/tests/dest /dev/test/log dump_type=ALL # mkfs.btrfs -f /dev/mapper/log # dmsetup suspend log # dmsetup message log dm_dump_type=METADATA|FLUSH|FUA|DISCARD|MARK # mount /dev/mapper/log # # umount /dev/mapper/log The log device will record the full mkfs bios (as user space write can't generate bios with METADATA flag), then switch to only log METADATA FUA FLUSH DISCARD writes. Signed-off-by: Qu Wenruo --- drivers/md/dm-log-writes.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c index 9edf0bdcae39..80e872c7dcd3 100644 --- a/drivers/md/dm-log-writes.c +++ b/drivers/md/dm-log-writes.c @@ -980,7 +980,8 @@ static int log_writes_iterate_devices(struct dm_target *ti, /* * Messages supported: - * mark - specify the marked data. + * mark - specify the marked data. + * dump_type= - change dump type on the fly, suspend recommended */ static int log_writes_message(struct dm_target *ti, unsigned argc, char **argv, char *result, unsigned maxlen) @@ -988,15 +989,35 @@ static int log_writes_message(struct dm_target *ti, unsigned argc, char **argv, int r = -EINVAL; struct log_writes_c *lc = ti->private; - if (argc != 2) { - DMWARN("Invalid log-writes message arguments, expect 2 arguments, got %d", argc); + if (argc < 1) { + DMWARN( +"Invalid log-writes message arguments, expect at least one argument, got %d", + argc); return r; } - if (!strcasecmp(argv[0], "mark")) + if (!strcasecmp(argv[0], "mark")) { + if (argc != 2) { + DMWARN( +"Invalid log-writes message arguments, expect 2 arguments for mark, got %d", + argc); + return r; + } r = log_mark(lc, argv[1]); - else + } else if (!strncasecmp(argv[0], "dump_type=", strlen("dump_type="))) { + if (argc != 1) { + DMWARN( +"Invalid log-writes message arguments, expect 1 argument for dump_type, got %d", + argc); + return r; + } + r = parse_dump_types(lc, argv[0] + strlen("dump_type=")); + if (r < 0) { + ti->error = "Bad dump type"; + } + } else { DMWARN("Unrecognised log writes target message received: %s", argv[0]); + } return r; }