From patchwork Thu Mar 30 18:53:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 9654937 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 CF5C160113 for ; Thu, 30 Mar 2017 18:53:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C4CA628497 for ; Thu, 30 Mar 2017 18:53:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9A87285C5; Thu, 30 Mar 2017 18:53:14 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 5D9CC28497 for ; Thu, 30 Mar 2017 18:53:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934394AbdC3SxO (ORCPT ); Thu, 30 Mar 2017 14:53:14 -0400 Received: from mail-it0-f54.google.com ([209.85.214.54]:38360 "EHLO mail-it0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933891AbdC3SxN (ORCPT ); Thu, 30 Mar 2017 14:53:13 -0400 Received: by mail-it0-f54.google.com with SMTP id y18so82198294itc.1 for ; Thu, 30 Mar 2017 11:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=uJVQAJeC1DyitPnZTy9GXKE8vuY2vMPNj3hOOKk66wg=; b=qsQ/lusXfenCUPplo3bTeJ8Z3Mi/6AXd1lnp4ao+M1hX/b3EBMUcyfFCWeU96345JO 60SRLhAbPuQzKMBtFoaaDwe7pcWDwmDUuUdXKsK6ue4cU90uC2e3/oWIvQA/bWbLJPXC Y7qoL/aQ391THQOeVWSHe1poAwavTCxRKHymuCdMpBtREDV4ZhvNghGuL8oReY5upChm aSTN0QDZ16epwdI7n1fD/NFNdl3R+xXNfJ6hdr9mp79ZKGw/bOaUyKSyNDaVYt+fLxj+ nM9DXB8vedDzWVzIqte9yLCAgHeJ3b/mHE4swtY97HvDSa+igDJa2jrIiV2LHTlY+lZS fw+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=uJVQAJeC1DyitPnZTy9GXKE8vuY2vMPNj3hOOKk66wg=; b=gVhCwrqJhjVO+O95zyUWpC+OgaJUhZn7FlOeiUeuxR48iabSv15eAoDkhfBVBJ2dxr UrH1DKtdRFapHyZ2PnR6K1JKaF+cHzrSH3OXxBXpOAb0hRwrnZjtvBYLxVOEdFAnF5d+ +ET44d8B+U0xWG8PUgYaKLza+gnjtqMouQaiW8ElUnQDwVYxSDXPziPe9x6hqiBiLhz9 xLaU/PFcQZERgR32aTYMltktOV1A2zLRITzUa9rRmORmOgcZRRDIVGopyD26Wj4+Ecd9 JMl39u+ieN/pHkkHVNjVD5+U/wKSwnxuEz8uqxPKKFiQX8asTs+U4WxxHPWmmgb+OeYM M8zw== X-Gm-Message-State: AFeK/H0PJkFRe0DMTwFv3NU8c95e1Z2ayR3LrUSOkhf49OUjwLf+93S8F5PlxQDjleahhA== X-Received: by 10.36.147.71 with SMTP id y68mr2273694itd.85.1490899992285; Thu, 30 Mar 2017 11:53:12 -0700 (PDT) Received: from [192.168.1.154] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id l188sm1838504ioa.35.2017.03.30.11.53.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Mar 2017 11:53:11 -0700 (PDT) To: "linux-block@vger.kernel.org" Cc: Christoph Hellwig From: Jens Axboe Subject: null_blk: add blocking mode Message-ID: <9a2b8d7e-1b04-4c94-2c79-c16fa8134f9d@kernel.dk> Date: Thu, 30 Mar 2017 12:53:05 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 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 This adds a new module parameter to null_blk, blocking. If set, null_blk will set the BLK_MQ_F_BLOCKING flag, indicating that it sometimes/always needs to block in its ->queue_rq() function. The intent is to help find regressions in blocking drivers, since not many of them exist. If null_blk is loaded with submit_queues > 1 and blocking=1, this shows the regression recently fixed by bf4907c05e61. Signed-off-by: Jens Axboe Reviewed-by: Bart Van Assche diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 6f2e565..d95635f 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -117,6 +117,10 @@ static bool use_lightnvm; module_param(use_lightnvm, bool, S_IRUGO); MODULE_PARM_DESC(use_lightnvm, "Register as a LightNVM device"); +static bool blocking; +module_param(blocking, bool, S_IRUGO); +MODULE_PARM_DESC(blocking, "Register as a blocking blk-mq driver device"); + static int irqmode = NULL_IRQ_SOFTIRQ; static int null_set_irqmode(const char *str, const struct kernel_param *kp) @@ -357,6 +361,8 @@ static int null_queue_rq(struct blk_mq_hw_ctx *hctx, { struct nullb_cmd *cmd = blk_mq_rq_to_pdu(bd->rq); + might_sleep_if(hctx->flags & BLK_MQ_F_BLOCKING); + if (irqmode == NULL_IRQ_TIMER) { hrtimer_init(&cmd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); cmd->timer.function = null_cmd_timer_expired; @@ -724,6 +730,9 @@ static int null_add_dev(void) nullb->tag_set.flags = BLK_MQ_F_SHOULD_MERGE; nullb->tag_set.driver_data = nullb; + if (blocking) + nullb->tag_set.flags |= BLK_MQ_F_BLOCKING; + rv = blk_mq_alloc_tag_set(&nullb->tag_set); if (rv) goto out_cleanup_queues;