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 8BFD5C04AA5 for ; Thu, 25 Aug 2022 11:32:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 15CC06B0074; Thu, 25 Aug 2022 07:32:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 10D64940007; Thu, 25 Aug 2022 07:32:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F3D956B0078; Thu, 25 Aug 2022 07:32:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E52906B0074 for ; Thu, 25 Aug 2022 07:32:18 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B21B6121BEC for ; Thu, 25 Aug 2022 11:32:18 +0000 (UTC) X-FDA: 79837901556.15.89B1A70 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf17.hostedemail.com (Postfix) with ESMTP id 0251C40003 for ; Thu, 25 Aug 2022 11:32:15 +0000 (UTC) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MD11z0rY3zlWJs; Thu, 25 Aug 2022 19:28:55 +0800 (CST) Received: from kwepemm600013.china.huawei.com (7.193.23.68) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 25 Aug 2022 19:32:10 +0800 Received: from [10.174.178.46] (10.174.178.46) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 25 Aug 2022 19:32:09 +0800 Subject: Re: [PATCH] mm: migrate: buffer_migrate_folio_norefs() fallback migrate not uptodate pages To: Jan Kara CC: , , , , , , References: <20220825080146.2021641-1-chengzhihao1@huawei.com> <20220825105704.e46hz6dp6opawsjk@quack3> From: Zhihao Cheng Message-ID: <6db0b93a-76d8-e936-c57e-17cb192224f2@huawei.com> Date: Thu, 25 Aug 2022 19:32:09 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20220825105704.e46hz6dp6opawsjk@quack3> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.46] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600013.china.huawei.com (7.193.23.68) X-CFilter-Loop: Reflected ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of chengzhihao1@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=chengzhihao1@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1661427138; a=rsa-sha256; cv=none; b=XGQTFb4945K1J6SRqJR2kI69J52kEpMT0fKXBCfD4n0q/E4OzFDrOiKdVdsGNc1qPLpHoI C/z7jeQvYtotDDdIRxKFfqYrRpkaJSqBJrpplMNtR7LSzKmX0csnBX/1CQT+T+EEYCGVLB 6fMI4T4LoaCcmfQWi5rNrHVjPx193Gs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1661427138; 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; bh=UkM7GwqmhmZGDz8/52Pi/lk8BpKlYgbiCaJ/hOfer70=; b=d5x1FOES0M+dxy8086cLC0wyUKX4uI+7EMa5uzK0gJxWk9s44F+Jis7K0hyF3aWPuYNO77 ROgXoW4yEAPjiyHqHwf4Uvfk2cdHOB4mLYJLBHWvrTjfalt5y1C0FPVxz5GmD6U3c9M5cD 7rzI004U8n7+aSRf1q9KzJNgn+Thl58= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 0251C40003 X-Rspam-User: X-Stat-Signature: 1pye876ozyioqptcriuarbdmyewh4smn Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.hostedemail.com: domain of chengzhihao1@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=chengzhihao1@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-HE-Tag: 1661427135-429896 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: ÔÚ 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.