Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp500971ybt; Wed, 17 Jun 2020 06:45:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmnj9CM2nmruUAlZxczSj8xjAF7IBnq0zG/n9NSzdjORiMbeRsf+S3mdctSUT0NSl+BCt/ X-Received: by 2002:a17:906:73d5:: with SMTP id n21mr8024567ejl.24.1592401543884; Wed, 17 Jun 2020 06:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592401543; cv=none; d=google.com; s=arc-20160816; b=vjrtZN7N1+3kW293UYkaedHnRk/Dv/jQ/5afInyvZNFKI4B2D7LB6cJ2eHnMNSEW+a fvMpDk8dveih30j34yN9f1VydKXl+XFRd2cXD4fLU1Yb7nAoK4lxixq4luF+FZPvyy5x WvVviaA7/X7pqz1rer3MjUelCCKGBc4bEeZs3w5CKK7yu1M+1Jc3zCfmfmdSvRAdrYNY OpJfP+qb+EkRObScT92M/o5oo2ULp4d2Yu/RIiwQYRJYxB5LYZ0+4wx8BPZVoSoXaPGF qR6kLumuVXeOHPJaY9Xbn8iHIdabDGt+bjfnFelWQUB9OU93nT5ZZBv1zU5etce7J2sg Vtuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=wEYrUdBfzxp5mN1Y7MljXKfcU8qZUs8mLwuS0Q/9fLg=; b=wkJosplyUPiD+GiFwqt3i7sjvwxImfHgGxOxBHezqBGD3cbQa3rhSMjbAiI+rcjJzC 03i3tR9ZA1A2m575Egn5OUQ24qhmyTtyVHOOPFVhHX09UZh/IkR87MsJNi7M8hMR2tqQ hsHs1WvaMuTxJQ9mOd8WKqqjZg6toI8yJKDeVHSkgEb4BlWdDlgttSYzJqjeJncCnISM uXAO45JkOblBxpYwBW9IbGrgYHxKZO2D367ght6bueOrT1KN524d1TWEpRojbLPMUUsf Zv2K0d23iSMDQ08ZoCgvXvan+3QMT8EnkHnVspL+vfvPQE2x7Sm5W4Moju0rzFJ/LmCo 7q7Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dk14si4219edb.0.2020.06.17.06.45.18; Wed, 17 Jun 2020 06:45:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726848AbgFQNor (ORCPT + 99 others); Wed, 17 Jun 2020 09:44:47 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:35046 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726331AbgFQNor (ORCPT ); Wed, 17 Jun 2020 09:44:47 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id A893EA6112A76EA029FA; Wed, 17 Jun 2020 21:44:45 +0800 (CST) Received: from [127.0.0.1] (10.166.215.198) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Wed, 17 Jun 2020 21:44:36 +0800 Subject: Re: [PATCH v2 3/5] ext4: detect metadata async write error when getting journal's write access To: Jan Kara CC: , , , , References: <20200617115947.836221-1-yi.zhang@huawei.com> <20200617115947.836221-4-yi.zhang@huawei.com> <20200617124157.GB29763@quack2.suse.cz> From: "zhangyi (F)" Message-ID: <8caf9fe1-b7ce-655f-1f4d-3e0e90e211dc@huawei.com> Date: Wed, 17 Jun 2020 21:44:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <20200617124157.GB29763@quack2.suse.cz> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.166.215.198] X-CFilter-Loop: Reflected Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On 2020/6/17 20:41, Jan Kara wrote: > On Wed 17-06-20 19:59:45, zhangyi (F) wrote: >> Although we have already introduce s_bdev_wb_err_work to detect and >> handle async write metadata buffer error as soon as possible, there is >> still a potential race that could lead to filesystem inconsistency, >> which is the buffer may reading and re-writing out to journal before >> s_bdev_wb_err_work run. So this patch detect bdev mapping->wb_err when >> getting journal's write access and also mark the filesystem error if >> something bad happened. >> >> Signed-off-by: zhangyi (F) > > So instead of all this, cannot we just do: > > if (work_pending(sbi->s_bdev_wb_err_work)) > flush_work(sbi->s_bdev_wb_err_work); > > ? And so we are sure the filesystem is aborted if the abort was pending? > Thanks for this suggestion. Yeah, we could do this, it depends on the second patch, if we check and flush the pending work here, we could not use the end_buffer_async_write() in ext4_end_buffer_async_write(), we need to open coding ext4_end_buffer_async_write() and queue the error work before the buffer is unlocked, or else the race is still there. Do you agree ? Thanks, Yi.