From patchwork Mon Jul 8 01:38:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauricio Faria de Oliveira X-Patchwork-Id: 1128802 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45hp6B4FDhz9sN4; Mon, 8 Jul 2019 11:39:45 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1hkId1-0005B8-FA; Mon, 08 Jul 2019 01:39:39 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1hkIcz-0005Az-Um for kernel-team@lists.ubuntu.com; Mon, 08 Jul 2019 01:39:37 +0000 Received: from mail-qk1-f199.google.com ([209.85.222.199]) by youngberry.canonical.com with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1hkIcz-0008NF-G2 for kernel-team@lists.ubuntu.com; Mon, 08 Jul 2019 01:39:37 +0000 Received: by mail-qk1-f199.google.com with SMTP id 5so15242376qki.2 for ; Sun, 07 Jul 2019 18:39:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=cD/U7WkanysKkuAxWl8cVONrmF34O5Z0cEolFTb38GY=; b=Dw2Tv8XnqlyhEiH8YmYtbf5ujtB2vzzm5cjw5UfrTYx0JZ0Xr0nogQeG9Hs+u6uvOp aleaNjSFjgbrrL5CERE7ybokd+79eN37Z435ATTqJL+UONbXGsIM+Bn8OPoyWVAzVYI4 AIWPkPI3pe3b8bxR3ALPNH/Ocu0HYbZ0gSaD8RBLV58zOQM/vZ0/aRCE1N97lkthaxuw 7S+h6TpgOoEZoPV8Z1YoZanqj70EHfRJoR7urMtM6in/R+L84R4n2nkhVLo83/rigiTV ePGqSwOuM4QxlvRl6CfQ4v42WKdR5HTW39Zc07lj+JgEuVYyXliWGsTUCMmP0KbOpkfY 0VrQ== X-Gm-Message-State: APjAAAWwdopZeZWheztsG5EWOrDHT+MXcdX8RFmDvR2eTVylo6dGROkZ 8vxT8Ac8dTsB4hvd1730PFpXVujPWv4DshBhwhJGak+hToaqN5LVkqmqUQSXgCQ1Y7IcSV2dJOO FRn3O7PCj2yn04J00sal2KL2gTIqvQE+w/eMpzDkWUA== X-Received: by 2002:ac8:6a17:: with SMTP id t23mr11783354qtr.183.1562549976552; Sun, 07 Jul 2019 18:39:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzldsIkir99INwf0BiUXNjjNJ7S4JEh6OkDDJBPNYVGBHPVt68OPMBmcPntK9qiVoq1UBIQvQ== X-Received: by 2002:ac8:6a17:: with SMTP id t23mr11783348qtr.183.1562549976366; Sun, 07 Jul 2019 18:39:36 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:4e7:1017:3da7:3d04:ea25:3a0]) by smtp.gmail.com with ESMTPSA id o71sm6644972qke.18.2019.07.07.18.39.35 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 07 Jul 2019 18:39:36 -0700 (PDT) From: Mauricio Faria de Oliveira To: kernel-team@lists.ubuntu.com Subject: [C][PATCH 1/2] bcache: fix ioctl in flash device Date: Sun, 7 Jul 2019 22:38:50 -0300 Message-Id: <20190708013851.14751-2-mfo@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708013851.14751-1-mfo@canonical.com> References: <20190708013851.14751-1-mfo@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Tang Junhui BugLink: https://bugs.launchpad.net/bugs/1829563 When doing ioctl in flash device, it will call ioctl_dev() in super.c, then we should not to get cached device since flash only device has no backend device. This patch just move the jugement dc->io_disable to cached_dev_ioctl() to make ioctl in flash device correctly. Fixes: 0f0709e6bfc3c ("bcache: stop bcache device when backing device is offline") Signed-off-by: Tang Junhui Cc: stable@vger.kernel.org Signed-off-by: Coly Li Signed-off-by: Jens Axboe (backported from commit dd0c91793b7c2658ea32c6b3a2247a8ceca45dc0) [mfo: backport: request.c/hunk 1: insert blank line, refresh one context line.] Signed-off-by: Mauricio Faria de Oliveira --- drivers/md/bcache/request.c | 4 ++++ drivers/md/bcache/super.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c index 9d2fa1359029..d451f2df150b 100644 --- a/drivers/md/bcache/request.c +++ b/drivers/md/bcache/request.c @@ -1156,6 +1156,10 @@ static int cached_dev_ioctl(struct bcache_device *d, fmode_t mode, unsigned int cmd, unsigned long arg) { struct cached_dev *dc = container_of(d, struct cached_dev, disk); + + if (dc->io_disable) + return -EIO; + return __blkdev_driver_ioctl(dc->bdev, mode, cmd, arg); } diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index 27c27c00c052..f09bf4a430fb 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -636,10 +636,6 @@ static int ioctl_dev(struct block_device *b, fmode_t mode, unsigned int cmd, unsigned long arg) { struct bcache_device *d = b->bd_disk->private_data; - struct cached_dev *dc = container_of(d, struct cached_dev, disk); - - if (dc->io_disable) - return -EIO; return d->ioctl(d, mode, cmd, arg); }