Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp1022212ybm; Fri, 29 May 2020 18:57:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8J/PvaY3f3NGybHF3/1bIT8giUS3iyTvzUUGHG+xs3IDg1DyczhiCeO6UaqKodGFyV2cZ X-Received: by 2002:a17:906:cede:: with SMTP id si30mr5365201ejb.315.1590803855275; Fri, 29 May 2020 18:57:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590803855; cv=none; d=google.com; s=arc-20160816; b=tZ5tbzpVSXw7A0rD8a5TzMVwLI77k/l02lZyU2ybNqOQEAAng5uOcBt7Jex9VvGXHt aV3moiU+57JT8JGdKBmjbF81B7RZ0AMrqrgwjcLXCKQZJ/zAS/jYRq/lKK1hpXT2TAen qX8F5R4eqiFpikv5M71FYg/8qH5cKCl38wCFxalzG0hO9iDIi0cqDwSBQsWxEwFMqe9O w+zWAGbbgpDKLq7I/U069I+Nc3UEw5QnmH2qrWKOdbvIhryjZvV1WwSy6AKKW5JEvLOz 4TNCt9lrVx871O+wKxsW2NLrMqaIGaNd7kTCaLoSYX7XjclAAARmQIZCFkYyUAKW7HTT +tMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=88jCXc3EuAexCY4iksBBEbK1cBktwp12ShhYzkJhUoU=; b=0vpiuLrIZ+QzR4tLY04oQkNFZ1L7kP0O9RRu9gHVAvSyYo0rGqH7soEzzGX79VXi5K 1hFGLD2pS2OfclBujzG1hPn72Hr+aM360gvWvgPY3XYoCkrxOs95nqrzu46sMf+FQYBD A4VQmi+Ab/xR1wiRbgHEYDDfaIPfbeo4MFqJ/aMamWgpWLqw8vhtyiQvKDY2FIJX3de9 F26TNpR66yDNkrx6S81ZwAACeD/s9eUIv09Z7UWLFhZ7DBsEDeJNYTJ+gMa2rW3wbkRA nb3cb/KoTA6yRzxZ2+y6E1pPzYt8JXy8/cAdGQSxnh79vgb49xgnAbtb/pFAVmoqXQNP HbbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZgFhjOA2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m4si831648ejx.217.2020.05.29.18.57.00; Fri, 29 May 2020 18:57:35 -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; dkim=pass header.i=@kernel.org header.s=default header.b=ZgFhjOA2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728680AbgE3Bt1 (ORCPT + 99 others); Fri, 29 May 2020 21:49:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:48576 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728406AbgE3Bt1 (ORCPT ); Fri, 29 May 2020 21:49:27 -0400 Received: from localhost (unknown [104.132.1.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 34DBE2075A; Sat, 30 May 2020 01:49:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590803367; bh=BIqHsLS0l8dGN8SLFgIgF41GvrgmvFj89GJ0W/GH6AY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZgFhjOA2Tg/cDAaLjTfNaZqzCG2tESxAefx1PLDVuEm3NQSd5SWvnA7gwlEPA4J9E 6u8M83SyAx6okIHexmh9qmllwAUBM37YDlX/Ag5b5b9WHN7vB+equLefOWuCQeYZkr 76YCSaWzFbP/Oeb7WML8UZHghJnGO5pgS3mb6uGo= Date: Fri, 29 May 2020 18:49:26 -0700 From: Jaegeuk Kim To: Chao Yu Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, chao@kernel.org Subject: Re: [PATCH] Revert "f2fs: fix quota_sync failure due to f2fs_lock_op" Message-ID: <20200530014926.GA39950@google.com> References: <20200529092947.7890-1-yuchao0@huawei.com> <20200529223426.GA249109@google.com> <96ba756e-a354-1ee8-689e-211f63c294e6@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <96ba756e-a354-1ee8-689e-211f63c294e6@huawei.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, 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) -- 2.27.0.rc0.183.gde8f92d652-goog