Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3166686pxj; Mon, 7 Jun 2021 04:10:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJuOKmhJcegt4kQFyGsahptf+1OU7gJlecUT3tKQ6Nerw7IXTP/1iyKorHt4yIfjwMnScw X-Received: by 2002:a17:907:16ab:: with SMTP id hc43mr17397989ejc.539.1623064240073; Mon, 07 Jun 2021 04:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623064240; cv=none; d=google.com; s=arc-20160816; b=o5+5Mx5nVhi3F00n2Nkq+RL+s0vFKFhkhMYnJh8kkb49Swx9IG7A47IOH1LCttR89f hkAhw3E0glzQMjSN8ytM/1VIxbohNANjDrnBbV2x9l6DBfTZ55+bUoBFIyWtxmySb7tX 5U0Q1sFAM2xmo4a6r2xk5Y2AasTbfPMt9REFPYL0ePtAFlPhIl7eVajRmhc6O0tWuqhn RPXHGA/GFwkDh0kjTn6T0DPNkrRVbLXOD7fFoUrWXDTLmdBOiDo/mew+G6x4CvjJlVS9 LRMMUpbtckJTSlHTBQOAFolAxLFHrK+WRdTAlobm4l9WwgIEzxo+GL3DFU6LHdhPvld0 gGig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=MoppTrqvw/ldP2X9QMz+b5yFFFqg4FfCIIZQsEdGRhg=; b=vFF+U34W4aE8hMgcDRqqD74Ggj/J3nKYw/SI8uYJt7u4qqli7ooS0yd+pPTBs1ElVf jGT8/9c9XB25mEnAuFJ6StgmiJeA2R1p5plbKYKVTbEovDEOnsd7ylxkD5Dpayr8/PRS WwprGWBHlQ15KHeoA4mY2RLL+42M1G9qOjneqWIcCT5fAeAm3UTPTC3sUITGldh25qsn oQOm9+BPqA7i2V4Voo/ouFmXfPnj4gGd8QNd0J00Lwz6oSPq+ppF2nI0w9BdmW54Y6o5 Kq5gxbCQiChCYt3nSvrlmepUDlQdKIt4GZ1H6Y0pK229aBQthqd6ai3BJ25SFaozb5ez t4jg== ARC-Authentication-Results: i=1; mx.google.com; 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 g5si3557452edb.144.2021.06.07.04.10.16; Mon, 07 Jun 2021 04:10:40 -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; 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 S230215AbhFGLIy (ORCPT + 99 others); Mon, 7 Jun 2021 07:08:54 -0400 Received: from verein.lst.de ([213.95.11.211]:45696 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230131AbhFGLIw (ORCPT ); Mon, 7 Jun 2021 07:08:52 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 67A4867373; Mon, 7 Jun 2021 13:06:57 +0200 (CEST) Date: Mon, 7 Jun 2021 13:06:57 +0200 From: Christoph Hellwig To: Coly Li Cc: axboe@kernel.dk, linux-bcache@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Alexander Ullrich , Diego Ercolani , Jan Szubiak , Marco Rebhan , Matthias Ferdinand , Victor Westerhuis , Vojtech Pavlik , Rolf Fokkens , Thorsten Knabe , stable@vger.kernel.org, Christoph Hellwig , Kent Overstreet , Nix , Takashi Iwai Subject: Re: [PATCH v5 2/2] bcache: avoid oversized read request in cache missing code path Message-ID: <20210607110657.GB6729@lst.de> References: <20210607103539.12823-1-colyli@suse.de> <20210607103539.12823-3-colyli@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210607103539.12823-3-colyli@suse.de> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 07, 2021 at 06:35:39PM +0800, Coly Li wrote: > + /* Limitation for valid replace key size and cache_bio bvecs number */ > + size_limit = min_t(unsigned int, bio_max_segs(UINT_MAX) * PAGE_SECTORS, > + (1 << KEY_SIZE_BITS) - 1); bio_max_segs kaps the argument to BIO_MAX_VECS, so you might as well directly write BIO_MAX_VECS. Can you explain the PAGE_SECTORS here a bit more? Does this code path use discontiguous per-sector allocations? Preferably in a comment. > + s->insert_bio_sectors = min3(size_limit, sectors, bio_sectors(bio)); Also I don't really understand the units involved here. s->insert_bio_sectors, sectors, and bio_sectors is in unit of 512 byte sectors. > - miss = bio_next_split(bio, sectors, GFP_NOIO, &s->d->bio_split); > + miss = bio_next_split(bio, s->insert_bio_sectors, GFP_NOIO, &s->d->bio_split); Overly long line.