Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp962430imj; Thu, 7 Feb 2019 14:58:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IYzssR9iMNiXtGeOlGOrWywynUhn7NEbAqBDLBgqfEI0HpfG6w307wINTifrCvnomPFZQ3u X-Received: by 2002:a17:902:8643:: with SMTP id y3mr6460654plt.80.1549580331488; Thu, 07 Feb 2019 14:58:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549580331; cv=none; d=google.com; s=arc-20160816; b=CmSVP1VPkT+fl/60Ny/dhxecWSm+vu+ut5WcrXhN9wXNr6WDt610D3N3aDFNPz3I0V BDoCvkYgXq295LgzPEgmh7bi+TuWlYMmCkEioHa4TJNUNWAOkeOLhnV6B9akTZxDhRhg uCBEYfv1YjvRdfkfkcM92bdghYCbvSxH5lPYXnpKl6Tn9DbuGPEvS/7J7RNejnkZmn0k CM6ahxWfWCOLZeqowKGLFlFVPee5EVWZxObxgw6aNRQRRh2YdzeXlc+Vv7RovLyxCAdZ BiIAIFcI14hdLRYFirZPIsRuxjxOfBUFZi4MVfNmg+d1LnYvn53CN4ZH3XtXxPj3MsiH nDsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-filter :dkim-signature; bh=rtVb3ivpOblZf8WHdo5sutGCTv0TgBQL/UA1qMhZ9xY=; b=nZfv6xo5u46b7emslnm6aFfPYWJYlFVxYRPxOptfhE8sv5JRCcQ84cAr7eAVsSCGos /bqM+dWOe3P4o+L/s6EzDftTkvopedHNhce3GZxa9dgkJ3fBKVmP0RhWtUPNH38au03c V9T5u/fDdq9maKLOzJ5O+GJYrsqeQ43yQh6V+ChjQC5iGmIkS/dL/lqyGuV4uTgcRffD WkFPivw3uEhfcbmBOZMwzlDt2QTyfNm//KKq2IVAwwlLv1Sy2x0Gqcw+QryHAY+ZjQz3 u5qS6GKEkYcJEXiCF94kPQzL3WbOKR2KrPKszQpBcKAaoKfpBAWYqSUkJUlXRwIlApwS n9gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fjfi.cvut.cz header.s=20151024 header.b=tSn87r6Y; 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 x74si319413pfe.23.2019.02.07.14.58.35; Thu, 07 Feb 2019 14:58:51 -0800 (PST) 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; dkim=pass header.i=@fjfi.cvut.cz header.s=20151024 header.b=tSn87r6Y; 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 S1726974AbfBGW44 (ORCPT + 99 others); Thu, 7 Feb 2019 17:56:56 -0500 Received: from mailgw1.fjfi.cvut.cz ([147.32.9.3]:43946 "EHLO mailgw1.fjfi.cvut.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726622AbfBGW4z (ORCPT ); Thu, 7 Feb 2019 17:56:55 -0500 Received: from localhost (localhost [127.0.0.1]) by mailgw1.fjfi.cvut.cz (Postfix) with ESMTP id 8CB44AE33D; Thu, 7 Feb 2019 23:56:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fjfi.cvut.cz; s=20151024; t=1549580212; i=@fjfi.cvut.cz; bh=rtVb3ivpOblZf8WHdo5sutGCTv0TgBQL/UA1qMhZ9xY=; h=Date:From:To:cc:Subject:In-Reply-To:References; b=tSn87r6YCtPVfkZ7AOH8a6y+vuSM6D/yfEl/4dnrCo3edcGH3CMUWIE/sVejP+wpB SK17M15O7oErm64CndBMfwRISbaqBUyh7MuG4iUDXdr1VStf+8JwXiIcs7s/AI5Kmo 66HWW8NDMPZYDXAwKaVLFR0rl490kKiv3M9DU8tk= X-CTU-FNSPE-Virus-Scanned: amavisd-new at fjfi.cvut.cz Received: from mailgw1.fjfi.cvut.cz ([127.0.0.1]) by localhost (mailgw1.fjfi.cvut.cz [127.0.0.1]) (amavisd-new, port 10022) with ESMTP id Xa472l_5-7j3; Thu, 7 Feb 2019 23:56:49 +0100 (CET) Received: from linux.fjfi.cvut.cz (linux.fjfi.cvut.cz [147.32.5.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mailgw1.fjfi.cvut.cz (Postfix) with ESMTPS id B5960AE33C; Thu, 7 Feb 2019 23:56:48 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 mailgw1.fjfi.cvut.cz B5960AE33C Received: by linux.fjfi.cvut.cz (Postfix, from userid 1001) id 6167C6004E; Thu, 7 Feb 2019 23:56:48 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by linux.fjfi.cvut.cz (Postfix) with ESMTP id 5532C6004D; Thu, 7 Feb 2019 23:56:48 +0100 (CET) Date: Thu, 7 Feb 2019 23:56:48 +0100 (CET) From: David Kozub To: Christoph Hellwig cc: Jens Axboe , Jonathan Derrick , Scott Bauer , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Jonas Rabenstein Subject: Re: [PATCH v4 10/16] block: sed-opal: add ioctl for done-mark of shadow mbr In-Reply-To: <20190204145244.GJ31132@infradead.org> Message-ID: References: <1549054223-12220-1-git-send-email-zub@linux.fjfi.cvut.cz> <1549054223-12220-11-git-send-email-zub@linux.fjfi.cvut.cz> <20190204145244.GJ31132@infradead.org> User-Agent: Alpine 2.21 (LRH 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 4 Feb 2019, Christoph Hellwig wrote: > On Fri, Feb 01, 2019 at 09:50:17PM +0100, David Kozub wrote: >> From: Jonas Rabenstein >> >> 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 >> Reviewed-by: Scott Bauer >> --- >> block/sed-opal.c | 33 +++++++++++++++++++++++++++++++-- >> include/linux/sed-opal.h | 1 + >> include/uapi/linux/sed-opal.h | 1 + >> 3 files changed, 33 insertions(+), 2 deletions(-) >> >> diff --git a/block/sed-opal.c b/block/sed-opal.c >> index 4b0a63b9d7c9..e03838cfd31b 100644 >> --- a/block/sed-opal.c >> +++ b/block/sed-opal.c >> @@ -1996,13 +1996,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, } > > This seems to be a change of what we pass to set_mbr_done / > set_mbr_enable_disable and not really related to the new functionality > here, so it should be split into a separate patch. > > That being said if we really care about this translation between > the two sets of constants, why not do it inside > set_mbr_done and set_mbr_enable_disable? Hi Christoph, I agree, this should be split. Furthermore I think I found an issue here: OPAL_MBR_ENABLE and OPAL_MBR_DISABLE are defined as follows: enum opal_mbr { OPAL_MBR_ENABLE = 0x0, OPAL_MBR_DISABLE = 0x01, }; ... while OPAL_TRUE and OPAL_FALSE tokens are: OPAL_TRUE = 0x01, OPAL_FALSE = 0x00, so in the current code in kernel, when the IOCTL input is directly passed in place of the TRUE/FALSE tokens (in opal_enable_disable_shadow_mbr), passing OPAL_MBR_ENABLE (0) to IOC_OPAL_ENABLE_DISABLE_MBR ends up being interpreted as OPAL_FALSE (0) and passing OPAL_MBR_DISABLE (1) ended up being interpreted as OPAL_TRUE (1). So the behavior is: OPAL_MBR_ENABLE: set MBR enable to OPAL_FALSE and done to OPAL_FALSE OPAL_MBR_DISABLE: set MBR enable to OPAL_TRUE and done to OPAL_TRUE Am I missing something here? This seems wrong to me. And I think this patch actually changes it by introducing: + u8 token = opal_mbr->enable_disable == OPAL_MBR_ENABLE + ? OPAL_TRUE : OPAL_FALSE; which is essentially a negation (map 0 to 1 and 1 to 0). I had a strange feeling of IOC_OPAL_ENABLE_DISABLE_MBR behaving incorrectly when I first tried it. But when I checked later I was not able to reproduce it - probably originally I tested without this patch. With regard to the new IOC_OPAL_MBR_STATUS: I find the usage of OPAL_MBR_ENABLE/DISABLE for this confusing: what should passing OPAL_MBR_ENABLE do? Should it enable the shadow MBR? Or should it enable the MBR-done flag? I think the implementation in this patch interprets OPAL_MBR_ENABLE as 'set the "done" flag to true', thus hiding the shadow MBR. But this is not obvious looking at the IOCTL name. What if I introduced two new constants for this? OPAL_MBR_DONE and OPAL_MBR_NOT_DONE? Maybe the IOCTL could be renamed too - IOC_OPAL_MBR_DONE? Or is it only me who finds this confusing? Best regards, David