Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1977612pxb; Thu, 7 Oct 2021 20:34:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7JUaf1Sw3HMlygVklXug4tShDYnL2HNRVQOnwBF0y7BLH947E8ReE/nTbuV+XG3CzMMJz X-Received: by 2002:a17:906:4f13:: with SMTP id t19mr1084342eju.53.1633664081859; Thu, 07 Oct 2021 20:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633664081; cv=none; d=google.com; s=arc-20160816; b=EknV9rw+ztjecL/XPV8Pk/MrjMO6EnhN85Fgoqg4jdQoGRZ/Hu3PAsiHzL3GrcTPEU WcUVKvyz5ILTsbP20a4dpQLZ/R3M0ZtT4lrDiKGk94zJXfmM2FOo2ncE20/y/RMG2qsF 84CNkLCRIW5EHmRTsP5Ofu123HIqVaKUvq4dec/I3jJIinfBLj3J72xcn/8ds0A2+5P5 r97Ijre2cktog2Y6EBs5UEV0RvgumMr4BdmTca3CLTDuNftKsrYzFIE0KbGTOiseZHng 7VgiQAeMVS4PqIlVJ6v0g/OG9uOrxQIADkn+7fjpYFoiIGI9xMiZSagj4VQTI0S9xXmT wyYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=VSeLCmemXSSseFE6GWGfLbL5+eucGh3/N220YyPpMd0=; b=oRqc4EQkmIceO3gduLDDUiXMDlmKr4iSj6NTq215Kqc3T6qtb/OwLAv4B2cjn0tUOB VLxFPyafK3rPqlB7LpP7LKiQboTlzLRFDQQgkwFtx8+jziO1LK1chPvMOVlug2LuAKD/ VIpTLkkFc48U6ggO+PUJ7WxkQLik5O/Gz74+rx+AER6S9ygtCr8uj9GkM9f4RF4n0goQ Ewdbt//yP0ysZ/UFDUvxTaHq8Uu4kFDc4NPQifR17AgIBY/xC8GLvE48ieHdkmkNVS8R evnnVZGRTwxriI9myjAM2aSoAZC82ZDC1E306FUAdzimBZGvhXgYbcurycqqt1hvX3Oa hhvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=sOdirM9A; 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 ne17si2206973ejc.518.2021.10.07.20.34.18; Thu, 07 Oct 2021 20:34:41 -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=@infradead.org header.s=casper.20170209 header.b=sOdirM9A; 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 S240523AbhJHDeA (ORCPT + 99 others); Thu, 7 Oct 2021 23:34:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238708AbhJHDd7 (ORCPT ); Thu, 7 Oct 2021 23:33:59 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77DA7C061714; Thu, 7 Oct 2021 20:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=VSeLCmemXSSseFE6GWGfLbL5+eucGh3/N220YyPpMd0=; b=sOdirM9AOuaWTrkR2EPQPI1Sqy uC1Ttna+a3wXn0EF9uQrPYtq+MjJ65W0IjFFDdcmUjt3rDuGr2c6N4OhZue2zntvo8BzPJ+VcbSGM v4yy7sFOb0DXXNcLfuoeU8+Z/Jrfa8MiR8VCIzbGOUeTz62KFb4Nbp45I4THHDxm3r6N5Yr6N3gNV oBZwIVPwzRWbUg5i91zsInHQM5GRgB4r6E3YqNEMcKEPecTCsEs2XT/fbGRPIZc+PJwC0RrVBHjo+ RMiihpEF2vOFTTiN0NYwpPuPYx6mDKHJoi9UX12arZC5wXtUZXfqs7pbOGFxEoaJu7ZAFkAlkTec+ IKOYw9Ww==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mYgbC-002kMQ-B6; Fri, 08 Oct 2021 03:31:20 +0000 Date: Fri, 8 Oct 2021 04:31:06 +0100 From: Matthew Wilcox To: Hao Sun Cc: Jens Axboe , Linux Kernel Mailing List , viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, Yang Shi Subject: Re: kernel BUG in block_invalidatepage Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 08, 2021 at 11:02:14AM +0800, Hao Sun wrote: > Matthew Wilcox 于2021年10月7日周四 下午10:20写道: > > > > On Thu, Oct 07, 2021 at 02:40:29PM +0800, Hao Sun wrote: > > > Hello, > > > > > > This crash can still be triggered repeatedly on the latest kernel. > > > > I asked you three days ago to try a patch and report the results: > > > > https://lore.kernel.org/linux-mm/YVtWhVNFhLbA9+Tl@casper.infradead.org/ > > Sorry, I missed that. > > Here are the results. > Used reproducer: https://paste.ubuntu.com/p/yrYsn4zpcn/ > Kernel log *before* applying the patch: https://paste.ubuntu.com/p/WtkFKB6Vy9/ > Kernel log *after* applying the patch: https://paste.ubuntu.com/p/S2VrtDdggp/ > Symbolized log: https://paste.ubuntu.com/p/RwXjCXDxB8/ OK, so that's ioctl(fd, BLKRRPART). That reproducer is a beast, and I can't help but think it could be minimised. I think I see what's going on here though. We open a block device, mount some stuff on it. khugepaged comes through and decides to create a THP for some of the pages on it. Nobody has it open for write, so why not? But then the filesystem on top of it dirties something -- it doesn't need to go through an open file descriptor because it's a filesystem. So when we call BLKRRPART, it tries to write the dirty things back (which it should) and things go wrong because the writeback path is not equipped to handle compound pages. So, yeah, let's do what Yang Shi suggested and tell khugepaged to never try to work on block devices. I can't think how any of this could happen except to a block device, so there's no more insight to be gained here.