From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 533ADC64990 for ; Thu, 25 Aug 2022 14:11:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B83F36B0073; Thu, 25 Aug 2022 10:11:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B331F6B0074; Thu, 25 Aug 2022 10:11:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FB40940007; Thu, 25 Aug 2022 10:11:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 91A646B0073 for ; Thu, 25 Aug 2022 10:11:10 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 417641C6347 for ; Thu, 25 Aug 2022 14:11:10 +0000 (UTC) X-FDA: 79838301900.16.527E0A1 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf30.hostedemail.com (Postfix) with ESMTP id AE60C80024 for ; Thu, 25 Aug 2022 14:11:09 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5C38633BC8; Thu, 25 Aug 2022 14:11:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1661436668; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tl5mr7Orfciz8580Kvvafn34WntciMWhPUTK5y7gOSE=; b=haq1wmc25epJ/iMb1dVs9tLxYMS9sY750TcXzlFNLYPze+yYVeLqdR4DajyfAXdd2vUeiK Y4KubJVnTPjaFNHZqc/QyOYjMbLd8Z0kp7a0fYzdNBWw6JDRwhvcM85mypsaCZf4xq7zSa aUd+/NsR9sVb6siomWFO/CnHZKslwYs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1661436668; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Tl5mr7Orfciz8580Kvvafn34WntciMWhPUTK5y7gOSE=; b=f6y/Gxq94eKvWk0UYr80AFUcw7lsiHfeKsr5qQw9NfiLCm/yUwDebA1qpn7x1COaoJnGu2 OoRRSRFXQ0ctGrDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4925713517; Thu, 25 Aug 2022 14:11:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id apTOEfyCB2O7RAAAMHmgww (envelope-from ); Thu, 25 Aug 2022 14:11:08 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id D0CACA0679; Thu, 25 Aug 2022 16:11:07 +0200 (CEST) Date: Thu, 25 Aug 2022 16:11:07 +0200 From: Jan Kara To: Zhihao Cheng Cc: Jan Kara , linux-ext4@vger.kernel.org, akpm@linux-foundation.org, mgorman@suse.de, linux-mm@kvack.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yi.zhang@huawei.com Subject: Re: [PATCH] mm: migrate: buffer_migrate_folio_norefs() fallback migrate not uptodate pages Message-ID: <20220825141107.f2ntf77pekeepfty@quack3> References: <20220825080146.2021641-1-chengzhihao1@huawei.com> <20220825105704.e46hz6dp6opawsjk@quack3> <6db0b93a-76d8-e936-c57e-17cb192224f2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6db0b93a-76d8-e936-c57e-17cb192224f2@huawei.com> ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=haq1wmc2; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="f6y/Gxq9"; dmarc=none; spf=pass (imf30.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661436669; a=rsa-sha256; cv=none; b=NgWOANHdhD8KecD0Co8rWQSYXdIrD6RUWzboyO2FledrxiCR/E3/XM2Slu0+bbyWuPbgks ovh41DniCivFQhBAhiN5e716iCAwfepFWF8+o4WOw6dJa4VghbUNR+BvbqL/Vqq1/PTlEe rIy/t9zESiKOv+UzXaotylvQhmWp04g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661436669; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Tl5mr7Orfciz8580Kvvafn34WntciMWhPUTK5y7gOSE=; b=aJocUViqvtybyDdHJReMY1QwczlTws8WxkD+S8K0gQ6h7LftjVNHEg+nHTzXEjS5dV5tpY o4fnyq0XCcYAox4ZqWtbBD8RATFFQ1FH9DgDZJIhK/WWhgnQyFWnsU+iiWA5guvAE1Agee W4KDNqFNtMrRQMtbPF2sWnaTozaM+4Q= X-Stat-Signature: 7k4sg9trfmfncshztrccqwhe16qh66bz Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=haq1wmc2; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="f6y/Gxq9"; dmarc=none; spf=pass (imf30.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: AE60C80024 X-Rspam-User: X-HE-Tag: 1661436669-853625 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu 25-08-22 19:32:09, Zhihao Cheng wrote: > 在 2022/8/25 18:57, Jan Kara 写道: > > On Thu 25-08-22 16:01:46, Zhihao Cheng wrote: > > > From: Zhang Yi > > > > > > Recently we notice that ext4 filesystem occasionally fail to read > > > metadata from disk and report error message, but the disk and block > > > layer looks fine. After analyse, we lockon commit 88dbcbb3a484 > > > ("blkdev: avoid migration stalls for blkdev pages"). It provide a > > > migration method for the bdev, we could move page that has buffers > > > without extra users now, but it will lock the buffers on the page, which > > > breaks a lot of current filesystem's fragile metadata read operations, > > > like ll_rw_block() for common usage and ext4_read_bh_lock() for ext4, > > > these helpers just trylock the buffer and skip submit IO if it lock > > > failed, many callers just wait_on_buffer() and conclude IO error if the > > > buffer is not uptodate after buffer unlocked. > > > > > > This issue could be easily reproduced by add some delay just after > > > buffer_migrate_lock_buffers() in __buffer_migrate_folio() and do > > > fsstress on ext4 filesystem. > > > > > > EXT4-fs error (device pmem1): __ext4_find_entry:1658: inode #73193: > > > comm fsstress: reading directory lblock 0 > > > EXT4-fs error (device pmem1): __ext4_find_entry:1658: inode #75334: > > > comm fsstress: reading directory lblock 0 > > > > > > Something like ll_rw_block() should be used carefully and seems could > > > only be safely used for the readahead case. So the best way is to fix > > > the read operations in filesystem in the long run, but now let us avoid > > > this issue first. This patch avoid this issue by fallback to migrate > > > pages that are not uotodate like fallback_migrate_folio(), those pages > > > that has buffers may probably do read operation soon. > > > > > > Fixes: 88dbcbb3a484 ("blkdev: avoid migration stalls for blkdev pages") > > > Signed-off-by: Zhang Yi > > > Signed-off-by: Zhihao Cheng > > > > Thanks for the analysis and the fix! As you noted above this is actually a > > bug in the filesystems that they assume that locked buffer means it is > > under IO. Usually that is the case but there are other places that lock > > the buffer without doing IO. Page migration is one of them, jbd2 machinery > > another one, there may be others. > > > > So I think this really ought to be fixed in filesystems instead of papering > > over the bug in the migration code. I agree this is more work but we will > > reduce the technical debt, not increase it :). Honestly, ll_rw_block() > > should just die. It is actively dangerous to use. Instead we should have > > one call for readahead of bhs and the rest should be converted to > > submit_bh() or similar calls. There are like 25 callers remaining so it > > won't be even that hard. > > > > And then we have the same buggy code as in ll_rw_block() copied to > > ext4_bread_batch() (ext4_read_bh_lock() in particular) so that needs to be > > fixed as well... > > > > Honza > > You are right, Jan. I totally agree with you. It seems that I shouldn't have > been lazy. If you face any issues with this, feel free to email me. I'll be happy to help :). Honza -- Jan Kara SUSE Labs, CR