Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp667304iob; Wed, 18 May 2022 10:11:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxINkizdvXQB90Qb42pxdogpA3DOWhtUBYpIYmD6JnXwsns1BgO+BvqHCeHM1aqKmovuPJ X-Received: by 2002:a63:231d:0:b0:3f2:4af2:1ff0 with SMTP id j29-20020a63231d000000b003f24af21ff0mr384363pgj.510.1652893894004; Wed, 18 May 2022 10:11:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652893893; cv=none; d=google.com; s=arc-20160816; b=N9lomyHD9S1xzJ3clodjjUBLEBFUWbzTqa7k1nHQc2WpiaR1RZRNRDoF54PCJLVt62 0otYShDPids4DuuwR3KqJNItKXPRo+NzjR1khrsVcOZTnjGcIsqojEExIH+OUu17Bgxf b41cOuUk+uI4H6MyI6C5NoZqm06x9cnolDscvyY7lSrbGkMy86WyoZfKjn5YbImxE0m8 mZT8x6/l4IUZtGjrA5ahhQGWLHLP4kRauEPSQbl7KbwKACKOn9eJ2SSewrZQiWEAZviL J6+uWRvrclsxeO7gzy7xWPVPuJy4cn5P27TJmbnZnRpJi38/JS8OnbOldlt/aBU3Zl1i 3RQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CjTJ3p6aCRmVinOxweum1QDs81Fl9FfzslrIAeweBkM=; b=mdL54GcXekYERHGFgZzIOeQV3HykrgQXko0DW0nSy7h0ynzwwWG4ieDtlz0bxB8KqY o40wzO9uiFk5uZqFNRqbHhfr1rWlAS6R863//VQablU25pjXfZ3ljUdWNuyLqpZJD32P 4A1lvk2IuemXI5IFJIuaKBvf4+LZxE8QK2gneO3EKPFm83Cap7BbSLtApfLMP6lm+usl D7OfzaJfVvmK/qI36phONa9Xoq1I6W9sr8sZ4OVoe8QWU5QSCFdYJ0tLnFTCaO56Ao5C fZZpwMc/ieNM+gfanjgYRK8nbBeDRreV7nodc0iiIvPfvGdSGfoEm7Dn3qWfVuyF5lb+ IyUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d8M7V9cw; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k20-20020a17090aaa1400b001bf691f3264si2908165pjq.19.2022.05.18.10.11.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 10:11:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=d8M7V9cw; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 50C9937A37; Wed, 18 May 2022 10:06:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240721AbiERRG0 (ORCPT + 99 others); Wed, 18 May 2022 13:06:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240753AbiERRGZ (ORCPT ); Wed, 18 May 2022 13:06:25 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B86A637A0D for ; Wed, 18 May 2022 10:06:23 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id c14so2732345pfn.2 for ; Wed, 18 May 2022 10:06:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CjTJ3p6aCRmVinOxweum1QDs81Fl9FfzslrIAeweBkM=; b=d8M7V9cwiXEtE3YHN0uzALLtO4e1UZ0wvHi72ZhwoC0v3xkvp8tUokEpkbQmTJcnue hZgBtuVd25W6kYZOfNseqpSqG7ae6O3eoMiQFqWwQRpWvJ6kHTO5halCTEScQpHEsqtP t/AkHfVVd6M1xaOE2sD8O7wqj5mNmM7Asrrh0ssQD4p43wD49nKXBV48Aa4AkkoQxatA ykGShPYTY83ECMtVMoNNak1EnhaNBUxXZ5u4sOpqpu34+iUdd2ndtRkkdHC3t4Byffjx jWNrq8fOFXSRo/r3J6E0uohgfGHxQnqvrsWOJaeW7XltH6RaXAwFvB9a58y1uCsvQY9x 0Bqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CjTJ3p6aCRmVinOxweum1QDs81Fl9FfzslrIAeweBkM=; b=YVnwSq4e2Gq+Tqb7MGCPaul4a4ueNWHoMK8PZF+CBvoXESxalQEKeaXLteQ8z8XtPA YND4RbRXCSxtLsN/EmUbQsKNMiJgfGgBjoKL06GzatU65ghhoMVCQxrspxuyvH6s/GDI tozFPI9oqtaFDJImFt9rZz9CpyKrXYjDulGMeIRAMFZBlKTKUBn/l0IdXcVolSci9cXa OYo1AFt25DRcDCnmghd+QoRCy2r01ZsH/lm7FrY5RQAMmfEgeRpo3g2D4F9AJoxy+bi9 toM7IpMGq0Ot8372apIvX2XYMTcDl+1NwDi8yQPt8zpigICuohZE2I9G1LAuPEXFcipS rC/w== X-Gm-Message-State: AOAM5314eXalQZYpzek0Wa1zA2VAax9GAEpfuU0uB556vEQjK/RZg91f r8dRMTcl0pIKMIrKpkQXq6O2BtzFLxs= X-Received: by 2002:a63:5a5a:0:b0:3c2:8205:17a6 with SMTP id k26-20020a635a5a000000b003c2820517a6mr321741pgm.609.1652893583273; Wed, 18 May 2022 10:06:23 -0700 (PDT) Received: from localhost ([2406:7400:63:532d:aa10:b33a:cf83:4737]) by smtp.gmail.com with ESMTPSA id k3-20020a17090ad08300b001d75aabe050sm1817406pju.34.2022.05.18.10.06.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 10:06:22 -0700 (PDT) Date: Wed, 18 May 2022 22:36:17 +0530 From: Ritesh Harjani To: Zhang Yi , Jan Kara Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, adilger.kernel@dilger.ca, jack@suse.cz, yukuai3@huawei.com Subject: Re: [PATCH] ext4: fix warning when submitting superblock in ext4_commit_super() Message-ID: <20220518170617.vooz4ycfe73xsszx@riteshh-domain> References: <20220518141020.2432652-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220518141020.2432652-1-yi.zhang@huawei.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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-ext4@vger.kernel.org On 22/05/18 10:10PM, Zhang Yi wrote: > We have already check the io_error and uptodate flag before submitting > the superblock buffer, and re-set the uptodate flag if it has been > failed to write out. But it was lockless and could be raced by another > ext4_commit_super(), and finally trigger '!uptodate' WARNING when > marking buffer dirty. Fix it by submit buffer directly. I agree that there could be a race with multiple processes trying to call ext4_commit_super(). Do you have a easy reproducer for this issue? Also do you think something like below should fix the problem too? So if you lock the buffer from checking until marking the buffer dirty, that should avoid the race too that you are reporting. Thoughts? diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 6900da973ce2..3447841fe654 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -6007,6 +6007,7 @@ static int ext4_commit_super(struct super_block *sb) ext4_update_super(sb); + lock_buffer(sbh); if (buffer_write_io_error(sbh) || !buffer_uptodate(sbh)) { /* * Oh, dear. A previous attempt to write the @@ -6023,6 +6024,7 @@ static int ext4_commit_super(struct super_block *sb) } BUFFER_TRACE(sbh, "marking dirty"); mark_buffer_dirty(sbh); + unlock_buffer(sbh); error = __sync_dirty_buffer(sbh, REQ_SYNC | (test_opt(sb, BARRIER) ? REQ_FUA : 0)); if (buffer_write_io_error(sbh)) {