From patchwork Thu Jan 11 06:49:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hou Tao X-Patchwork-Id: 10157261 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 1EE77605F8 for ; Thu, 11 Jan 2018 06:42:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13E53286A9 for ; Thu, 11 Jan 2018 06:42:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08CE2286DA; Thu, 11 Jan 2018 06:42:23 +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 A2F2D286A9 for ; Thu, 11 Jan 2018 06:42:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753997AbeAKGmV (ORCPT ); Thu, 11 Jan 2018 01:42:21 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:4162 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753916AbeAKGmU (ORCPT ); Thu, 11 Jan 2018 01:42:20 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 6E916E669A2F9; Thu, 11 Jan 2018 14:42:04 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.361.1; Thu, 11 Jan 2018 14:42:05 +0800 From: Hou Tao To: CC: , , , Subject: [PATCH v4 1/4] dmflakey: support multiple dm targets for a dm-flakey device Date: Thu, 11 Jan 2018 14:49:30 +0800 Message-ID: <20180111064933.12088-2-houtao1@huawei.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180111064933.12088-1-houtao1@huawei.com> References: <20180111064933.12088-1-houtao1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP dm-flakey can be used to emulate IO write error, however, when we also need to prevent the IO error for a specific range of the block device (eg., the log region of a XFS), we need to specify multiple dm targets for the dm device. Option --table can not accommodate the multiple dm targets case, so let dmsetup get the possible-multiple-targets table from standard input. Signed-off-by: Hou Tao --- v4: add comments for reading dm target table from standard input --- common/dmflakey | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/dmflakey b/common/dmflakey index 4434307..e34fce8 100644 --- a/common/dmflakey +++ b/common/dmflakey @@ -77,11 +77,14 @@ _load_flakey_table() $DMSETUP_PROG suspend $suspend_opt flakey-test [ $? -ne 0 ] && _fatal "failed to suspend flakey-test" - $DMSETUP_PROG load flakey-test --table "$table" + # There may be multiple dm targets in the table, and these dm targets + # will be joined by the newline ("\n"). Option --table can not cope with + # the multiple-targets case, so get them by reading from standard input. + echo -e "$table" | $DMSETUP_PROG load flakey-test [ $? -ne 0 ] && _fatal "failed to load table into flakey-test" $DMSETUP_PROG resume flakey-test - [ $? -ne 0 ] && _fatal "failed to resumeflakey-test" + [ $? -ne 0 ] && _fatal "failed to resume flakey-test" } # Silently drop all writes and unmount/remount to simulate a crash/power