Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp108749pxk; Sat, 29 Aug 2020 18:24:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVmWLKMwaM9o7QZWibH6yf0wW/CvLpZRtPVKsN0fhNHhhEAzkPgVSpC9wXsBYFXftKOQZp X-Received: by 2002:a17:906:bfcb:: with SMTP id us11mr5555992ejb.502.1598750675702; Sat, 29 Aug 2020 18:24:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598750675; cv=none; d=google.com; s=arc-20160816; b=KJUl31Y8uEH/EiE5PTXBEMZFtPpWoEakD1ljY+mMyRiP/OrE/l/3puWhERcm2+j3lx SbnbxKXUeEW3S8RKuYVdhi22eFeZpaSJYUirGuTQPRzJ3ZdGXJTeksi46zqXr7zSUqbV s80ZF+siSz8vduc7CNXy0A2uZtjsECUPMLD2RtoqwQqJeCagTM40PsPs1NTOnxJF2j+G T6w5Ds8yii+c3jSQfGhAFnMSKWxmldn7Q5YRtF9EsYXJGF2dOyQK8xCi7PovB5pNgd93 5EwNGr11fDlV/wcJy6b0kOQorpw6zc7NeH+V1dC5alKhGa5qI6sWqCCgemtL4OBj821o CFAw== 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=aiqIIVHmY3wPsZLF3CW081k8n4tXc4QrcWEWsn8FuuE=; b=KV6V2CcKcuE7Auso+mnDQhh3eYyEITS69Mu1iD6GBE6n9uxHvD9ivalO4b5mdPri0h IAw1kLjFA3S7KpPFoAz8mMToDDG0Np6WgZ/CKgJPD3LtZfGOvfN5GunmdC15PQP8pnO7 682VcyMsV5Ll4x6HGQOACmXWClOcenMFWpMTVXz8UXash+Bm/edvojfDdrw3us+WvOTr SPofPUBRYF6qcnh5TTckWZBNHGHNCN0T4M30DmspgyWNDJ9SyL7gTIpF+RiC6X0GZD02 jBD54iGQR+OPVmGh98N8kdJOoriXdL2D2hRLlTLd3vIOo3IOqk5rgVa8qwike5qMwDyI 0pOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=sPAlVSgZ; 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 m64si2485787ede.91.2020.08.29.18.23.57; Sat, 29 Aug 2020 18:24: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=fail header.i=@infradead.org header.s=casper.20170209 header.b=sPAlVSgZ; 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 S1728567AbgH3BWS (ORCPT + 99 others); Sat, 29 Aug 2020 21:22:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728246AbgH3BWR (ORCPT ); Sat, 29 Aug 2020 21:22:17 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E22B4C061573; Sat, 29 Aug 2020 18:21:55 -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-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=aiqIIVHmY3wPsZLF3CW081k8n4tXc4QrcWEWsn8FuuE=; b=sPAlVSgZookYSkFDWpVCPgmpfg cS07a3oX5FX+TbbXFEinQRq7cHwCBWSbNow0NMjH83vTr7ajEwNa97aO8qcqeoB4suuvxoq0VnWum njuvX3paolsMGgMxMo703BZLH0ZEd81HdxyCzpVMGQ4PVEFU8ES27rA1XzA3pFldSm5rzKSXE7j7s JUcSv38r7Hol/Cpjh/zTDnyQSqQoAuRnVsjPsmEzte+/yxQY1aKe5Rb72uQT+1TMCcjtkSOiPTYzI o8eyOHHNIkL4bx2GtwA7i4I8jm0aOC0+q3MC+jxqiJ/dGrMNXR1YLQ4D1AOFvStPRXhF3op2LbtZ8 eDNOlFUA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kCC2Z-0004nW-1w; Sun, 30 Aug 2020 01:21:51 +0000 Date: Sun, 30 Aug 2020 02:21:51 +0100 From: Matthew Wilcox To: OGAWA Hirofumi Cc: Andrew Morton , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] fat: Avoid oops when bdi->io_pages==0 Message-ID: <20200830012151.GW14765@casper.infradead.org> References: <87ft85osn6.fsf@mail.parknet.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87ft85osn6.fsf@mail.parknet.co.jp> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 30, 2020 at 09:59:41AM +0900, OGAWA Hirofumi wrote: > On one system, there was bdi->io_pages==0. This seems to be the bug of > a driver somewhere, and should fix it though. Anyway, it is better to > avoid the divide-by-zero Oops. > > So this check it. > > Signed-off-by: OGAWA Hirofumi > Cc: > --- > fs/fat/fatent.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c > index f7e3304..98a1c4f 100644 > --- a/fs/fat/fatent.c 2020-08-30 06:52:47.251564566 +0900 > +++ b/fs/fat/fatent.c 2020-08-30 06:54:05.838319213 +0900 > @@ -660,7 +660,7 @@ static void fat_ra_init(struct super_blo > if (fatent->entry >= ent_limit) > return; > > - if (ra_pages > sb->s_bdi->io_pages) > + if (sb->s_bdi->io_pages && ra_pages > sb->s_bdi->io_pages) > ra_pages = rounddown(ra_pages, sb->s_bdi->io_pages); Wait, rounddown? ->io_pages is supposed to be the maximum number of pages to readahead. Shouldn't this be max() instead of rounddown()?