Received: by 10.213.65.68 with SMTP id h4csp36982imn; Mon, 19 Mar 2018 18:44:55 -0700 (PDT) X-Google-Smtp-Source: AG47ELuYnpsrWGuw1DotuOl1d+nEUkiQDAED6QxQlIq0suECvHphFOV8Ce/XeHEg3lqzU1i7Yh7p X-Received: by 2002:a17:902:51ee:: with SMTP id y101-v6mr14842148plh.359.1521510295921; Mon, 19 Mar 2018 18:44:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521510295; cv=none; d=google.com; s=arc-20160816; b=Ym9KaOfCuymsokzysZ9bq4Y84nyivfBP63T2H4Mt/3zbXnXUVHgHXnyT/PBVFKA3t1 VWg8CuAXFY/Bgb7qiEmc3uKFX1QpFKw4IdFxkofEhI8At0x6PgMcXyWbTuJ142sYIJjF 4+D3OWA4GTUYLjKDsbhmLjZiKluP7lazPngVi3uPSH/HEWhKY9h5ro2RmeEFlcNDC72a 7aIFIVKhQW7xj1JIPpU2RNNnfCwJFeFizF9w76WE6D1lA7wABJ0vQFlcHJ8fFYgK5MtA OWYWoE+yEtBt5hTNBrBELm0UnxSkbfhoN8t+cX1S54hMqJn43YUg9IkuLItL23oZVenP acjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=06oDbzMILYcRjubxec3CPxMGDR3l0Kio+iJXj1dXcww=; b=n0Af1dmLckmkIfraf/63uJW1Qi09oexdERmeN8EuYWliGzI221atf7M8/RMs/gL/vB mJI+U5LHUk+YT2WzB6On6/Gvw498O36NxC1Dgsh4YsieEZiGc4BzjitlAXfQzsZw9Zkd SyvgMaqptuGhpI9iWfVmU4SZImZx9f29OikcIKVWv8oyozFVvp/g0GmdSFCwXt/mY6yS yic9cVFSIUs6XjiIozVkpUWmlmfIOz37ObZ4a46hz8EdJWu7X3qZg6ehv1EfiQxKD9OL xA36nBMW6+XFV4OBLu8s8qM4S7ribEhHfr/Loym0BI54efQ4YL+2IF4JURl5Xfy42Yld sKGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v27si426853pfa.387.2018.03.19.18.44.42; Mon, 19 Mar 2018 18:44:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S970380AbeCSSja (ORCPT + 99 others); Mon, 19 Mar 2018 14:39:30 -0400 Received: from mx-rz-2.rrze.uni-erlangen.de ([131.188.11.21]:54750 "EHLO mx-rz-2.rrze.uni-erlangen.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S970295AbeCSSiE (ORCPT ); Mon, 19 Mar 2018 14:38:04 -0400 Received: from mx-rz-2.rrze.uni-erlangen.de (mx-rz-2.rrze.uni-erlangen.de [IPv6:2001:638:a000:1025::15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx-rz-2.rrze.uni-erlangen.de (Postfix) with ESMTPS id 404lDn5FwfzPkDb; Mon, 19 Mar 2018 19:38:01 +0100 (CET) Authentication-Results: mx-rz-2.rrze.uni-erlangen.de; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Quarantine-ID: X-Virus-Scanned: amavisd-new at boeck2.rrze.uni-erlangen.de (RRZE) X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" X-RRZE-Flag: Not-Spam X-RRZE-Submit-IP: 2003:d5:3db:1800:60b5:55d8:d757:229 Received: from fau.de (p200300D503DB180060B555D8D7570229.dip0.t-ipconnect.de [IPv6:2003:d5:3db:1800:60b5:55d8:d757:229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: U2FsdGVkX183bBLjvw0FrapF2+J2vriTG7pUHGpEjeo=) by smtp-auth.uni-erlangen.de (Postfix) with ESMTPSA id 404lDk2y0bzPk6B; Mon, 19 Mar 2018 19:37:58 +0100 (CET) From: Jonas Rabenstein To: Jonas Rabenstein , Scott Bauer , Jonathan Derrick , Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Christoph Hellwig Subject: [PATCH v2 07/11] block: sed-opal: add ioctl for done-mark of shadow mbr Date: Mon, 19 Mar 2018 19:36:49 +0100 Message-Id: X-Mailer: git-send-email 2.16.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enable users to mark the shadow mbr as done without completely deactivating the shadow mbr feature. This may be useful on reboots, when the power to the disk is not disconnected in between and the shadow mbr stores the required boot files. Of course, this saves also the (few) commands required to enable the feature if it is already enabled and one only wants to mark the shadow mbr as done. Signed-off-by: Jonas Rabenstein diff --git a/block/sed-opal.c b/block/sed-opal.c index fc10f81d4892..2c8baff8bf67 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -1988,13 +1988,39 @@ static int opal_erase_locking_range(struct opal_dev *dev, static int opal_enable_disable_shadow_mbr(struct opal_dev *dev, struct opal_mbr_data *opal_mbr) { + u8 token = opal_mbr->enable_disable == OPAL_MBR_ENABLE + ? OPAL_TRUE : OPAL_FALSE; const struct opal_step mbr_steps[] = { { opal_discovery0, }, { start_admin1LSP_opal_session, &opal_mbr->key }, - { set_mbr_done, &opal_mbr->enable_disable }, + { set_mbr_done, &token }, { end_opal_session, }, { start_admin1LSP_opal_session, &opal_mbr->key }, - { set_mbr_enable_disable, &opal_mbr->enable_disable }, + { set_mbr_enable_disable, &token }, + { end_opal_session, }, + { NULL, } + }; + int ret; + + if (opal_mbr->enable_disable != OPAL_MBR_ENABLE && + opal_mbr->enable_disable != OPAL_MBR_DISABLE) + return -EINVAL; + + mutex_lock(&dev->dev_lock); + setup_opal_dev(dev, mbr_steps); + ret = next(dev); + mutex_unlock(&dev->dev_lock); + return ret; +} + +static int opal_mbr_status(struct opal_dev *dev, struct opal_mbr_data *opal_mbr) +{ + u8 token = opal_mbr->enable_disable == OPAL_MBR_ENABLE + ? OPAL_TRUE : OPAL_FALSE; + const struct opal_step mbr_steps[] = { + { opal_discovery0, }, + { start_admin1LSP_opal_session, &opal_mbr->key }, + { set_mbr_done, &token }, { end_opal_session, }, { NULL, } }; @@ -2340,6 +2366,9 @@ int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *arg) case IOC_OPAL_ENABLE_DISABLE_MBR: ret = opal_enable_disable_shadow_mbr(dev, p); break; + case IOC_OPAL_MBR_STATUS: + ret = opal_mbr_status(dev, p); + break; case IOC_OPAL_ERASE_LR: ret = opal_erase_locking_range(dev, p); break; diff --git a/include/linux/sed-opal.h b/include/linux/sed-opal.h index 04b124fca51e..b38dc602cae3 100644 --- a/include/linux/sed-opal.h +++ b/include/linux/sed-opal.h @@ -47,6 +47,7 @@ static inline bool is_sed_ioctl(unsigned int cmd) case IOC_OPAL_ENABLE_DISABLE_MBR: case IOC_OPAL_ERASE_LR: case IOC_OPAL_SECURE_ERASE_LR: + case IOC_OPAL_MBR_STATUS: return true; } return false; diff --git a/include/uapi/linux/sed-opal.h b/include/uapi/linux/sed-opal.h index 627624d35030..0cb9890cdc04 100644 --- a/include/uapi/linux/sed-opal.h +++ b/include/uapi/linux/sed-opal.h @@ -116,5 +116,6 @@ struct opal_mbr_data { #define IOC_OPAL_ENABLE_DISABLE_MBR _IOW('p', 229, struct opal_mbr_data) #define IOC_OPAL_ERASE_LR _IOW('p', 230, struct opal_session_info) #define IOC_OPAL_SECURE_ERASE_LR _IOW('p', 231, struct opal_session_info) +#define IOC_OPAL_MBR_STATUS _IOW('p', 232, struct opal_mbr_data) #endif /* _UAPI_SED_OPAL_H */ -- 2.16.1