Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp1687117rwl; Mon, 26 Dec 2022 03:18:20 -0800 (PST) X-Google-Smtp-Source: AMrXdXsCGZ7skhw2UOI92jHxrPcU8NQEF3lS7iVFSbI1NlRzfWkgTgqzOEZF8n93wueHIpCMoaDS X-Received: by 2002:a17:906:6a1a:b0:7b9:ee36:6153 with SMTP id qw26-20020a1709066a1a00b007b9ee366153mr19815346ejc.2.1672053500642; Mon, 26 Dec 2022 03:18:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672053500; cv=none; d=google.com; s=arc-20160816; b=IK/ObJSy0BEikcvt7KyiBK1YEuQUrtdsEqs+2IO396eu0c+6L7nYfoeoUxL1RZVN81 xPTtlv0OBVTNnDGjmj7SsytAz53QuA5u92VoXFXdIqxMB4/yGa+598TsH3/AkdqkJa4y fcJ6bHdItykRr8hsMY2/IjqReLZKWDawkakGK3fsqJl77A2yd1EW/87oqvKXq0NAZxYX dE9TicrRWBogTPKmJ1a2KCDvaXWC23A077E1+veh4MQmiCS91n1zXS6WxJ6J14ng0QR4 Pg8+Jf6TEPe2Wa0I/73wiEA2kYwZb8FGEpL+isoocHWkUaDBA3oWlDYur3Wq9qzcGU0o o5ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/8iJERifRuDgkKMvQvGyxuwsw9IX1lKSaIBEuKbKFZc=; b=r7W5QmoxiMrY30h+ehoEtT+buRXm6gf1GEUgRIJB676ZMzZCxhNEtmQWB1j9vSPoo1 YvRT56Bw2y4rQfMapOdcBhZsebzKyAY+KHTb/Gpovy+vaGp614WLpUvf/sUZJS3qeACa SWy0jYIT2GxoH/1+c304jXiI9/qpaIR2l3KzflmkH2Nvl9n9QiBucmymI2iwnJLTWPPE h4z0CYnCoDWlP7f3iJ36g47mt+vQdRrT62FfAmL7cu0hO5s4vwNSl/Yzumgp01FrCbSd DswAxwlGB5YnvNPoC1J9+92TPYtaZ20lK7AGwf6VEofd63KN5ssJC90R0tQwpn/3foM0 ig0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j15-20020a05640211cf00b0046abe52aca7si9742017edw.486.2022.12.26.03.18.05; Mon, 26 Dec 2022 03:18:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231873AbiLZKd0 (ORCPT + 66 others); Mon, 26 Dec 2022 05:33:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbiLZKdX (ORCPT ); Mon, 26 Dec 2022 05:33:23 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B35586161 for ; Mon, 26 Dec 2022 02:33:21 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4NgYz03ZqSz4f3p0c for ; Mon, 26 Dec 2022 18:33:16 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP4 (Coremail) with SMTP id gCh0CgBH_rFreKlj6SMxAg--.54373S6; Mon, 26 Dec 2022 18:33:19 +0800 (CST) From: Hou Tao To: linux-cachefs@redhat.com Cc: David Howells , Jeff Layton , linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org, Jingbo Xu , houtao1@huawei.com Subject: [PATCH v2 2/2] fscache: Add the missing smp_mb__after_atomic() before wake_up_bit() Date: Mon, 26 Dec 2022 18:33:09 +0800 Message-Id: <20221226103309.953112-3-houtao@huaweicloud.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20221226103309.953112-1-houtao@huaweicloud.com> References: <20221226103309.953112-1-houtao@huaweicloud.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgBH_rFreKlj6SMxAg--.54373S6 X-Coremail-Antispam: 1UD129KBjvJXoW7tryxXF18tr4DCF48ZF47Arb_yoW8Gr18pr Z5WFySqay8X39rt3yDJw17u34SgrWUKanrGr10y3WUZF4FqrWFv3WSkas8u3W7C398Xry3 ZF15K3y3XF1UZr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUvGb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXw A2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMc Ij6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_ Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr 0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY 17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcV C0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY 6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa 73UjIFyTuYvjxU2GYLDUUUU X-CM-SenderInfo: xkrx3t3r6k3tpzhluzxrxghudrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hou Tao fscache_create_volume_work() uses wake_up_bit() to wake up the processes which are waiting for the completion of volume creation. According to comments in wake_up_bit() and waitqueue_active(), an extra smp_mb() is needed to guarantee the memory order between FSCACHE_VOLUME_CREATING flag and waitqueue_active() before invoking wake_up_bit(). Considering clear_bit_unlock() before wake_up_bit() is an atomic operation, use smp_mb__after_atomic() instead of smp_mb() to provide such guarantee. Signed-off-by: Hou Tao --- fs/fscache/volume.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/fscache/volume.c b/fs/fscache/volume.c index fc3dd3bc851d..734d17f404e7 100644 --- a/fs/fscache/volume.c +++ b/fs/fscache/volume.c @@ -281,6 +281,11 @@ static void fscache_create_volume_work(struct work_struct *work) fscache_access_acquire_volume_end); clear_bit_unlock(FSCACHE_VOLUME_CREATING, &volume->flags); + /* + * Paired with barrier in wait_on_bit(). Check wake_up_bit() and + * waitqueue_active() for details. + */ + smp_mb__after_atomic(); wake_up_bit(&volume->flags, FSCACHE_VOLUME_CREATING); fscache_put_volume(volume, fscache_volume_put_create_work); } -- 2.29.2