Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp2135844imc; Fri, 22 Feb 2019 19:11:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IaMoNMKnTzyd1F10BxDLLd8E8A899qDhz163N36mK/DvwHVmQWtaSdyYkDGvMYFydTXt99J X-Received: by 2002:a65:6651:: with SMTP id z17mr6681544pgv.95.1550891494044; Fri, 22 Feb 2019 19:11:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550891494; cv=none; d=google.com; s=arc-20160816; b=wcmZvIpZAOqCjZUa5HuWLmwwXyf7wl9/KvvSLKmk1ER0namneDsP25s7AMKcad8ZxY UFUtfWxVA1whPfuqXNTkrxF6brKT4kdbFscLxEJKkET1uDoKrUbLClvOwADYoVEx5d7o mmrle4k5xCcXOGQ2u56SlJD/bTUT5PDRW3K/GR71tEwKbGmuRty85wu08E0Mfgmnv24/ IJTLJmd0MWW4YNI4eMd92eQVy/diqS4DfU56OqZIzBYtFGsHryn0XdoJ33Z+JpisSxe9 dvCjwcJIPBlYeXkoQgo3GT4QUiP+dyTT8v/al7E8ilAlRxk3i44nUY53VW4yOyQaeaTp NvBA== 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 :in-reply-to:references:mime-version; bh=FVo2yvPkQcOfnCvpRVWOLfbTevOVnB/+yEXQwluhnxg=; b=ZaKLg8MRBXYx4yTGIwzY0nGuhaJBRd4y7qViyZH9JkSzMn6ghEMAuqx/lKEk78QkNR 6dvS1dxNe7tvlqJ1JnpABS0mVE/1GVa8AWwIF7qpvRipYx4qgw1yvIaj0Ov9xgYmSds1 63BJ50S0rzSqI20CSuMFlN0qu+9fPaxbTSKCvsNyI8SecWt5Pev0RCk2/3CqNc7WYEdC M8PBAB95fUA5/Z1dDjANx8ZrwinJbxrq0MNIFeuf6GkSut9zv0xn52vs+3dGV7GJ+1QZ Xh23KLDpkW23sNMb8mEz6BXF+9ysXjo6Mh9vDkOYCDh0gHw1afQiJ+8xrzkSj5XzqPBw XG6g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e65si3119863pfa.80.2019.02.22.19.11.18; Fri, 22 Feb 2019 19:11:34 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727560AbfBWDKw (ORCPT + 99 others); Fri, 22 Feb 2019 22:10:52 -0500 Received: from mail-qt1-f174.google.com ([209.85.160.174]:46163 "EHLO mail-qt1-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725936AbfBWDKw (ORCPT ); Fri, 22 Feb 2019 22:10:52 -0500 Received: by mail-qt1-f174.google.com with SMTP id z25so4806605qti.13 for ; Fri, 22 Feb 2019 19:10:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FVo2yvPkQcOfnCvpRVWOLfbTevOVnB/+yEXQwluhnxg=; b=TrExlnwxIHL6D6vpsHbzpO6SsNRIOgDw8CU0/iROfLtT23NEOJf+JACwAHm06AHdff cVmQ9jDQewwIu35eKJ0GCCSdqFweDrDCW4tlzg1rPgJLdWNuBW70g7iB/+Exd+Otxj9d h+rRLPTcQFviiFvQMv0Wu6JEt5kEs8pMHcBWBJG8dn4Z5llDYyroboEuXBistb4w2Znt 1hKcP1D/TGiFcG0x721nYngbSjc4il1CxCWS5vXckax9mHH962UQf2k6wKjAQcy1Ep55 L1kfkrIDeBgfcamVRQ3qtcCpRriWOscVGlrbkPKPJcJTgBc2m/OgukUqF/dABJVFDggn LUog== X-Gm-Message-State: AHQUAuZnhomdcemtvfcL0Lfml0/iDDjD40Fe0ShAvZXv2/w2giif/Tk7 Uck9Xb8Jw+Kwjp34e+CGcFn4Jj8k+4JDOBDH+bf26g== X-Received: by 2002:a0c:93ab:: with SMTP id f40mr5721776qvf.59.1550891451403; Fri, 22 Feb 2019 19:10:51 -0800 (PST) MIME-Version: 1.0 References: <70cda2a3-f246-d45b-f600-1f9d15ba22ff@gmail.com> <87eflmpqkb.fsf@notabene.neil.brown.name> <20190222211006.GA10987@redhat.com> <7f0aeb7b-fdaa-0625-f785-05c342047550@kernel.dk> <20190222235459.GA11726@redhat.com> <20190223024402.GA12407@redhat.com> In-Reply-To: <20190223024402.GA12407@redhat.com> From: John Dorminy Date: Fri, 22 Feb 2019 22:10:39 -0500 Message-ID: Subject: Re: block: be more careful about status in __bio_chain_endio To: Mike Snitzer Cc: Jens Axboe , NeilBrown , linux-block@vger.kernel.org, device-mapper development , Milan Broz , 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 I'm also worried about the other two versions, though: memory-barriers.txt#1724: 1724 (*) The compiler is within its rights to invent stores to a variable, i.e. the compiler is free to decide __bio_chain_endio looks like this: static struct bio *__bio_chain_endio(struct bio *bio) { struct bio *parent = bio->bi_private; blk_status_t tmp = parent->bi_status; parent->bi_status = bio->bi_status; if (!bio->bi_status) parent->bi_status = tmp; bio_put(bio); return parent; } In which case, the read and later store on the two different threads may overlap in such a way that bio_endio sometimes sees success, even if one child had an error. As a result, I believe the setting of parent->bi_status needs to be a WRITE_ONCE() and the later reading needs to be a READ_ONCE() [although, since the later reading happens in many different functions, perhaps some other barrier to make sure all readers get the correct value is in order.]