Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1025923ybm; Fri, 29 May 2020 19:05:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzolkvtAnhPHqnMA1cA12k9wi2lF4NLus9c2P+5bvTFl6UgK5OZuMiFIk6iG3UdvSqSS+ZV X-Received: by 2002:a50:af85:: with SMTP id h5mr4413866edd.86.1590804308881; Fri, 29 May 2020 19:05:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590804308; cv=none; d=google.com; s=arc-20160816; b=x030jsjmKtCGbR+2XTZXHWuloVrwW8zsL/w+RvmVN27vFf/XYOQlVlZ78RSngB/HMX RSlBwHSae2QjGFXpHrYada/RqHUhfxuTgV9kUFcv35UQClqYVI0S8t7aTmAv5OmgotDm rrO281QfFnsyPychlaDluDGU8KgMGtmvQziyP0bevjZMUdrjyhcQOhF884X6hsOty/Dn r5o19MhSAzxD3sYoLSfg4NicFH3LRjwtXKsQlDmg0Ehf0vtgZyxp7itY/5GoLueK+9xE E38//Bs9QDBwP5v6uvhYusmpxziE9NXnxbeO8OuHdY33SqKqb6FXmwDdO5hIw5SomH1R 5pqw== 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=jg8933ZJx2S2t8HhVmBnRlKj4EapNgzBWg+lfvCJbLY=; b=IpQeW5G72hgkeAqo28YSPPy/BKm0p6jlkTbfmIYiwdevy026LMluDXYGMF6dKRVdDq Z2wnlpgDKFxGRZhhJ8Sju9KLh0iU+hfS17OYqZoFCGsRp2Ht4WIYpEx75rjdtXZXhZAp iQv7ZH0ORwwW7vInnaZ25YDRWTQaIUCwRqj23lveDU4jQhlXPxeFgf0v2omnhYhI+CBo 4nZxHHo79gjbXBp1WQGQ5zjG0mf5qkol5SWVzPXmTNPHbKBawlW1spd4+CF6ZIw1xVrp o1IJnqop11W1Psuxeh9tmBhjDeVLVI5arH88VcgvtMAymc5mp2QxFGmGeSBK2oFMzej4 T+IQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 w24si6572329edv.588.2020.05.29.19.04.44; Fri, 29 May 2020 19:05:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728542AbgE3CDF (ORCPT + 99 others); Fri, 29 May 2020 22:03:05 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:44044 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727876AbgE3CDE (ORCPT ); Fri, 29 May 2020 22:03:04 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 402E1D1A17C9C56793B8; Sat, 30 May 2020 10:03:02 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.203) with Microsoft SMTP Server (TLS) id 14.3.487.0; Sat, 30 May 2020 10:02:59 +0800 Subject: Re: [PATCH] Revert "f2fs: fix quota_sync failure due to f2fs_lock_op" To: Jaegeuk Kim CC: , , References: <20200529092947.7890-1-yuchao0@huawei.com> <20200529223426.GA249109@google.com> <96ba756e-a354-1ee8-689e-211f63c294e6@huawei.com> <20200530014926.GA39950@google.com> From: Chao Yu Message-ID: Date: Sat, 30 May 2020 10:02:57 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200530014926.GA39950@google.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/5/30 9:49, Jaegeuk Kim wrote: > On 05/30, Chao Yu wrote: >> On 2020/5/30 6:34, Jaegeuk Kim wrote: >>> On 05/29, Chao Yu wrote: >>>> Under heavy fsstress, we may triggle panic while issuing discard, >>>> because __check_sit_bitmap() detects that discard command may earse >>>> valid data blocks, the root cause is as below race stack described, >>>> since we removed lock when flushing quota data, quota data writeback >>>> may race with write_checkpoint(), so that it causes inconsistency in >>>> between cached discard entry and segment bitmap. >>>> >>>> - f2fs_write_checkpoint >>>> - block_operations >>>> - set_sbi_flag(sbi, SBI_QUOTA_SKIP_FLUSH) >>>> - f2fs_flush_sit_entries >>>> - add_discard_addrs >>>> - __set_bit_le(i, (void *)de->discard_map); >>>> - f2fs_write_data_pages >>>> - f2fs_write_single_data_page >>>> : inode is quota one, cp_rwsem won't be locked >>>> - f2fs_do_write_data_page >>>> - f2fs_allocate_data_block >>>> - f2fs_wait_discard_bio >>>> : discard entry has not been added yet. >>>> - update_sit_entry >>>> - f2fs_clear_prefree_segments >>>> - f2fs_issue_discard >>>> : add discard entry >>>> >>>> This patch fixes this issue by reverting 435cbab95e39 ("f2fs: fix quota_sync >>>> failure due to f2fs_lock_op"). >>>> >>>> Fixes: 435cbab95e39 ("f2fs: fix quota_sync failure due to f2fs_lock_op") >>> >>> The previous patch fixes quota_sync gets EAGAIN all the time. >>> How about this? It seems this works for fsstress test. >>> > > Then this? > > --- > fs/f2fs/segment.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index ebbadde6cbced..ed11dcf2d69ed 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -3107,6 +3107,14 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, > type = CURSEG_COLD_DATA; > } > > + /* > + * We need to wait for node_write to avoid block allocation during > + * checkpoint. This can only happen to quota writes which can cause > + * the below discard race condition. > + */ > + if (IS_DATASEG(type)) > + down_write(&sbi->node_write); > + > down_read(&SM_I(sbi)->curseg_lock); > > mutex_lock(&curseg->curseg_mutex); > @@ -3174,6 +3182,9 @@ void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page, Minor thing: unlock order. if (IS_DATASEG(type)) up_write(&sbi->node_write); Could you merge the diff into this patch? > > if (put_pin_sem) > up_read(&sbi->pin_sem); > + > + if (IS_DATASEG(type)) > + up_write(&sbi->node_write); > } > > static void update_device_state(struct f2fs_io_info *fio) >