Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3764700pxk; Tue, 29 Sep 2020 05:50:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJWpcqyObgCWC6EDAVahJWSgKQ+toOADqU9/4B44Arwv26wrUYzprYwHAMXPgBXjUL9wUW X-Received: by 2002:aa7:dcd2:: with SMTP id w18mr3128609edu.288.1601383850633; Tue, 29 Sep 2020 05:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601383850; cv=none; d=google.com; s=arc-20160816; b=osqdNnyeLNsTOS/J5F9zWAqvjnmwX0x8KdmJ4F5dDAfNLZeBLRY/FggDIwCCgg9Cmt NHWwhY4jlP8CXI0aneU0MOvM6EnJlqJTNwmPRueBjOiy+Rq7hDfOSqgSxRa0FpUzA8rU NnG+0vbfpqhgcq8T5j0wnRtRoz8w3BL1lm7NGgFBXFDQSPVoR35hAa6V8F8JYrhVMcd6 3J1HlA1b5tgzno/6XJmWAyUDq783vJ+UEQRQuPeWqgm3uEX5Qbxz80CPXWTTfjUC0gKn xxE82K5z06zrZseJFZ9h0FUUCcurbiGXNclYltmR+/tkr2kF4gBjrVpKj868E8+codcc axMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7VMzLjySmlqOMm2+fWHh8rTJaE5S09FPfbh59RaqgkU=; b=IFBKEhRjkZAZYfyx1EqP26ppYe42skUCeJ7+K2LSHMYwQky60kaz2UdpsXPnw+bOFk S0sCud+Gdn0j0PXsvwc9dRQG5JflRH7KRerUYdKpubzvdn9MkFpu+m3gTtUGrbQ2OV6w 15/Re4Q6yfVS5M8bZ6iMO/QKCgr0X0JQJkXmuM5eqtu5UK9zOjPeA31yMjcPKKd8jPBE 8RXndx9LwrKD76W/JVMfUpDr61X2sUtd/ufJkL6/0fPHD9+ZttJTt/vpz60sOXN0KrXQ WAmQ12OAWh1gXtzG5zeL9F7sytawYkC8Dw6kknqmz0wI0+Rqv/1K4/5H8Kl1ZD1t+sPo MaRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IBj4qV2U; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d1si2954097edr.490.2020.09.29.05.50.27; Tue, 29 Sep 2020 05:50:50 -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=IBj4qV2U; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732771AbgI2Mrb (ORCPT + 99 others); Tue, 29 Sep 2020 08:47:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:40812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728605AbgI2LEi (ORCPT ); Tue, 29 Sep 2020 07:04:38 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 4DFDB21924; Tue, 29 Sep 2020 11:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601377476; bh=C169/HX/zDif2R0FRt3lQxZ7wq1l4U5sR/NacEP1e48=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IBj4qV2UsrajqPMx+lPMWTHrPQxfqz70nuew+A+HDu7avChOgg3nWmVOD48j4Yr20 iITVFE6lNrCGmZ2j2ma4mBVwsohtvaMd67Fy2vVN2mUjGLWdQmLNlZqvU1LTf7/p2f RkrfMTcKjsEQMGOil3K76KyfEbr88WqSZHOWasrw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xianting Tian , Andrew Morton , "Matthew Wilcox (Oracle)" , Jan Kara , yubin@h3c.com, Linus Torvalds , Sasha Levin Subject: [PATCH 4.4 49/85] mm/filemap.c: clear page error before actual read Date: Tue, 29 Sep 2020 13:00:16 +0200 Message-Id: <20200929105930.687626093@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105928.198942536@linuxfoundation.org> References: <20200929105928.198942536@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xianting Tian [ Upstream commit faffdfa04fa11ccf048cebdde73db41ede0679e0 ] Mount failure issue happens under the scenario: Application forked dozens of threads to mount the same number of cramfs images separately in docker, but several mounts failed with high probability. Mount failed due to the checking result of the page(read from the superblock of loop dev) is not uptodate after wait_on_page_locked(page) returned in function cramfs_read: wait_on_page_locked(page); if (!PageUptodate(page)) { ... } The reason of the checking result of the page not uptodate: systemd-udevd read the loopX dev before mount, because the status of loopX is Lo_unbound at this time, so loop_make_request directly trigger the calling of io_end handler end_buffer_async_read, which called SetPageError(page). So It caused the page can't be set to uptodate in function end_buffer_async_read: if(page_uptodate && !PageError(page)) { SetPageUptodate(page); } Then mount operation is performed, it used the same page which is just accessed by systemd-udevd above, Because this page is not uptodate, it will launch a actual read via submit_bh, then wait on this page by calling wait_on_page_locked(page). When the I/O of the page done, io_end handler end_buffer_async_read is called, because no one cleared the page error(during the whole read path of mount), which is caused by systemd-udevd reading, so this page is still in "PageError" status, which can't be set to uptodate in function end_buffer_async_read, then caused mount failure. But sometimes mount succeed even through systemd-udeved read loopX dev just before, The reason is systemd-udevd launched other loopX read just between step 3.1 and 3.2, the steps as below: 1, loopX dev default status is Lo_unbound; 2, systemd-udved read loopX dev (page is set to PageError); 3, mount operation 1) set loopX status to Lo_bound; ==>systemd-udevd read loopX dev<== 2) read loopX dev(page has no error) 3) mount succeed As the loopX dev status is set to Lo_bound after step 3.1, so the other loopX dev read by systemd-udevd will go through the whole I/O stack, part of the call trace as below: SYS_read vfs_read do_sync_read blkdev_aio_read generic_file_aio_read do_generic_file_read: ClearPageError(page); mapping->a_ops->readpage(filp, page); here, mapping->a_ops->readpage() is blkdev_readpage. In latest kernel, some function name changed, the call trace as below: blkdev_read_iter generic_file_read_iter generic_file_buffered_read: /* * A previous I/O error may have been due to temporary * failures, eg. mutipath errors. * Pg_error will be set again if readpage fails. */ ClearPageError(page); /* Start the actual read. The read will unlock the page*/ error=mapping->a_ops->readpage(flip, page); We can see ClearPageError(page) is called before the actual read, then the read in step 3.2 succeed. This patch is to add the calling of ClearPageError just before the actual read of read path of cramfs mount. Without the patch, the call trace as below when performing cramfs mount: do_mount cramfs_read cramfs_blkdev_read read_cache_page do_read_cache_page: filler(data, page); or mapping->a_ops->readpage(data, page); With the patch, the call trace as below when performing mount: do_mount cramfs_read cramfs_blkdev_read read_cache_page: do_read_cache_page: ClearPageError(page); <== new add filler(data, page); or mapping->a_ops->readpage(data, page); With the patch, mount operation trigger the calling of ClearPageError(page) before the actual read, the page has no error if no additional page error happen when I/O done. Signed-off-by: Xianting Tian Signed-off-by: Andrew Morton Reviewed-by: Matthew Wilcox (Oracle) Cc: Jan Kara Cc: Link: http://lkml.kernel.org/r/1583318844-22971-1-git-send-email-xianting_tian@126.com Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/filemap.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index f217120973ebe..3d0a0e409cbf5 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2313,6 +2313,14 @@ filler: unlock_page(page); goto out; } + + /* + * A previous I/O error may have been due to temporary + * failures. + * Clear page error before actual read, PG_error will be + * set again if read page fails. + */ + ClearPageError(page); goto filler; out: -- 2.25.1