From patchwork Sun Nov 8 13:22:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagi Grimberg X-Patchwork-Id: 7578261 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4AD6AC05C6 for ; Sun, 8 Nov 2015 13:22:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 691CA20603 for ; Sun, 8 Nov 2015 13:22:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 776C0205DD for ; Sun, 8 Nov 2015 13:22:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751488AbbKHNWR (ORCPT ); Sun, 8 Nov 2015 08:22:17 -0500 Received: from mail-wi0-f179.google.com ([209.85.212.179]:38300 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750887AbbKHNWQ (ORCPT ); Sun, 8 Nov 2015 08:22:16 -0500 Received: by wicli17 with SMTP id li17so1082358wic.1 for ; Sun, 08 Nov 2015 05:22:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev_mellanox_co_il.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=tYkzvPXRP0/Nim0JfEVfnG2ejbf/znOxcggV5yWXXhk=; b=175PGThODu8MUFhPEjXfP6jATv6coznFkaKPB9OZPtuwWvCNC7e2r9ZU6ikaPREyg+ KN/mSNj5w5foe2EQk1ucWGkNOsSrAg6kgZY6firpCm5JBgRPRUCLGgDZG4aHSaiMqPBE IAv23+xaEKAcB5IAyESxQpHIKRUQSbh/TFj5n3B4bi8dFnK6p7nHOY6vieMT8fWM1FI9 ivsE0eWlSvNMPpexzr/QCOFhW1sZFYV5WwjGU8PDLnxuBfBcdpXz6qsZUavsGT0uvhA6 w6DovitCiYREwnNPFchqB6pQ6XY0nwNnqfo30yMfdGSOFYNYka713bz0Xzx2eo/VVsZN 11UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=tYkzvPXRP0/Nim0JfEVfnG2ejbf/znOxcggV5yWXXhk=; b=TPagOSVPywsbAPRp3EUauve2+qvq3w+avWVLU/DYqc8kNqQgnrugcGuvyIntXRGKlD fQgWfY8/y2x0OGA5dwPAPhBNhAJHvMT59+2QDz/Xv41peBTA9Hmc3EZxIimj25mPNahz Cu2BVX8pHmC2KcyQHuWyQq0rlmwJLif0xbWxJJXuSquRYhubjtnRDaVAso1A58R960Xu LzEH8U1INl19W1QHQL5/3A1aE3Ilo/UWLFOOcqyrLyxA8qpra0HT9lu2BjRk1hioFDeM NFRGGyKx9uM6EbYymJ81JcgisHQDiSTkUKp0zW2loSK4N3aIo5mkRIj21wKkMNVbV9HH nxNQ== X-Gm-Message-State: ALoCoQmZO9o8X79+4B9aaugpP4q6uSSGJF4j9ux6ORvuO91PoVKhsRwCOg7/UtBGtCLq5TIOjZSh X-Received: by 10.194.172.1 with SMTP id ay1mr9004614wjc.82.1446988935115; Sun, 08 Nov 2015 05:22:15 -0800 (PST) Received: from [10.223.0.53] ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id an7sm9958594wjc.44.2015.11.08.05.22.13 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 08 Nov 2015 05:22:14 -0800 (PST) Subject: Re: [PATCH 8/8] nvme-loop: add a NVMe loopback device To: Christoph Hellwig , linux-nvme@lists.infradead.org References: <1446915643-21175-1-git-send-email-hch@lst.de> <1446915643-21175-9-git-send-email-hch@lst.de> <563F29D4.5030801@dev.mellanox.co.il> Cc: linux-block@vger.kernel.org From: Sagi Grimberg Message-ID: <563F4C83.5030709@dev.mellanox.co.il> Date: Sun, 8 Nov 2015 15:22:11 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <563F29D4.5030801@dev.mellanox.co.il> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 08/11/2015 12:54, Sagi Grimberg wrote: > >> +static void nvme_loop_free_ctrl(struct nvme_ctrl *nctrl) >> +{ >> + struct nvme_loop_ctrl *ctrl = to_loop_ctrl(nctrl); >> + >> + list_del(&ctrl->list); > > This should be list_del_init so that cleanup_module > list_empty() check will be correct. unloading nvme-loop > with active controllers is getting a list corruption. Actually this is wrong. Whats wrong here is that ctrl->list is being removed twice (once in nvme_loop_cleanup_module and then here). The following worked for me: --- -- -- To unsubscribe from this list: send the line "unsubscribe linux-block" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c index a0eac07..cf0f745 100644 --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c @@ -869,18 +869,11 @@ out: static void __exit nvme_loop_cleanup_module(void) { - struct nvme_loop_ctrl *ctrl; + struct nvme_loop_ctrl *ctrl, *tmp; mutex_lock(&nvme_loop_ctrl_mutex); - while (!list_empty(&nvme_loop_ctrl_list)) { - ctrl = list_entry(nvme_loop_ctrl_list.next, - struct nvme_loop_ctrl, list); - - if (!list_empty(&ctrl->list)) - list_del(&ctrl->list); - + list_for_each_entry_safe(ctrl, tmp, &nvme_loop_ctrl_list, list) __nvme_loop_remove_ctrl(ctrl); - } mutex_unlock(&nvme_loop_ctrl_mutex); device_destroy(nvme_loop_class, MKDEV(0, 0));