Received: by 10.223.185.116 with SMTP id b49csp7479781wrg; Thu, 1 Mar 2018 06:16:11 -0800 (PST) X-Google-Smtp-Source: AG47ELsXPWGRv4UDQWDB5E40jSNiHKa8RCAVr4f14KPpjT4wxC/uhythYnPf47YmuLGxO4YAB2i8 X-Received: by 2002:a17:902:518d:: with SMTP id y13-v6mr2092051plh.121.1519913771019; Thu, 01 Mar 2018 06:16:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519913770; cv=none; d=google.com; s=arc-20160816; b=WPiFVKn/D1MHix8VIl1N/z0LiQAzT9WxfD4xXjafSse1HYxRyioWf44bjJEDJWjiC5 uU6kmQ7olib2C56S649+t2R+bfrxhHaq3jD9N12V2NqeELy8aw/9DPpYe9V1p2fWYHxA edApX2H6ViDrC3oOgwOlFiHRocE2ycciFQkWSBrleci2bjElaienFyi8w+CLnNnI8C+V ix85XFnCFn9hPWgu1z5vfGxKX4572qTP7LvqRNNC8iPwKgvQfoFSig0s85xFFjpn6XiS 1c7vXTaPMwvKoevzpssESc6M5pkrIum4Fe3gOKCVpiVNadV89V+ztvKOl5Tm5/WdcxVi OKsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=/FvcWAXZOfHteBqqlpYLzGBE86oorXXEwYbhyHNW/MI=; b=LlvXLEC8+tsz2H7kHcGrv3NEsgRleUeL+F9z2f9ZAJaI4ryDI5/PjDHBR8TSfLdohq 5fuLq1QyX/20KuQlfDewThoYQUcHJ/PFL2GiufgO4NuiEwEXUWsQKaZ7EOFIW2wA324T HT9Iq4U7WP5PTOYXR1r99lqCbZLA0+frxj36Lsq4G9eM+mkszdr4DbSmacrGbh5NIOta yw/GpiuhlJ9rcPnzg5GnS4x9SgKRupDusNtuNGjs4sxdnMh/I9HqSP8XGM77ErAbIsLD IZn2LzZnE10jPiD3Q5UESZbVhhYpwPI3c8YKbzWn7jcSL/2KxdLcO35grVdbTeW6ZG/I OUQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uKtJTl6b; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a80si3039478pfa.315.2018.03.01.06.15.55; Thu, 01 Mar 2018 06:16:10 -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=@gmail.com header.s=20161025 header.b=uKtJTl6b; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031214AbeCAOO7 (ORCPT + 99 others); Thu, 1 Mar 2018 09:14:59 -0500 Received: from mail-qk0-f177.google.com ([209.85.220.177]:33271 "EHLO mail-qk0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031174AbeCAOO5 (ORCPT ); Thu, 1 Mar 2018 09:14:57 -0500 Received: by mail-qk0-f177.google.com with SMTP id f25so7687238qkm.0; Thu, 01 Mar 2018 06:14:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=/FvcWAXZOfHteBqqlpYLzGBE86oorXXEwYbhyHNW/MI=; b=uKtJTl6b7e5smw/eJZ33OQyyXIZwjbuN4x7UIa2vkynf6bf0wA6XQAwCzJ8PRwLKip 9k/F9nm0MGN/yt7+7GKihO/2mcpukgWv81DaJR8HcI1+Uxs4/j5VjNlNPgRoq63G428J CZ5kfGN0658c2JVGUmr3pXKYumDmSZyGv/qa3y3U8fl3DjjslkBOaJbk/JtUYioisTN7 VbmYKrXLgtsr22uty4ryPfCl8T1jWBi/KuRLhxGeP6VnnV1uAtPk89E9l+pZFWYepeZC 9t8akJ1RCw3KRnL1Y6WNcxnuDLBuws8N6araSgcSNDKv6s22A0xr7O2St93bpT7kgIE3 q8eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=/FvcWAXZOfHteBqqlpYLzGBE86oorXXEwYbhyHNW/MI=; b=MJIn/7SQUcGyl70G4HL7TI3dNZR42fy4B+8X+WS5VzHiGTxzOBSGSVssv8mqLOy/HW it7fvbrAHgHkyFKWZuiLFb2MCC48cpaBJQSQhaPpNNVxD4Y81MC9JZwy2Bgtz1c7piWp NKgtdLgQV4aTI+xLGOmKG1iotMOSjOvCuzxMHMEXNc3PSOp9U9+AjN63gwnzozh0r2QE 1AEWwBGMQfLMQe/wMCxXcUf53kGSuj/k4x3av+lAZ3JJxpBWtAI4GBxiw9m6Hzg5dmUi MEUUjjySJIr/WBSVF7ecS6L/LMfzuaWbhmjHAdAJgciU6V+8edoH5MqPUT/nPt+6oZn2 AzFA== X-Gm-Message-State: AElRT7H2h9VuqZ71aUz5/uzws2ZGR0flvpdiqbHfiakcwpys4MVuJ6QM geZ5vxoZjRAY/0m37U/24+jJ5ndXXgJi6aqy89s= X-Received: by 10.55.126.69 with SMTP id z66mr2858938qkc.218.1519913696533; Thu, 01 Mar 2018 06:14:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.195.80 with HTTP; Thu, 1 Mar 2018 06:14:55 -0800 (PST) In-Reply-To: <01000161e1e448a5-d54e05d2-58f2-4480-b05b-67185d4ffae7-000000@email.amazonses.com> References: <01000161e1e448a5-d54e05d2-58f2-4480-b05b-67185d4ffae7-000000@email.amazonses.com> From: Andy Shevchenko Date: Thu, 1 Mar 2018 16:14:55 +0200 Message-ID: Subject: Re: [PATCH] scsi: sd: Keep disk read-only when re-reading partition To: Jeremy Cline Cc: "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 1, 2018 at 4:08 PM, Jeremy Cline wrote: > If the read-only flag is true on a SCSI disk, re-reading the partition > table sets the flag back to false. > > To observe this bug, you can run: > > 1. blockdev --setro /dev/sda > 2. blockdev --rereadpt /dev/sda > 3. blockdev --getro /dev/sda > > This commit reads the disk's old state and combines it with the device > disk-reported state rather than unconditionally marking it as RW. > - sdkp->write_prot = ((data.device_specific & 0x80) != 0); > + sdkp->write_prot = ((data.device_specific & 0x80) != 0) || > + disk_ro; Perhaps sdkp->write_prot = (data.device_specific & 0x80) || disk_ro; will save a line. -- With Best Regards, Andy Shevchenko