Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3206751pxj; Mon, 7 Jun 2021 05:12:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzItlZ7uEa65zsoBhxKR86iBCgUCuXKJBvV8G9kSyEJGkmqaxjrQ4I8nLnGW2UxPiyDGRfQ X-Received: by 2002:a17:906:19d6:: with SMTP id h22mr17967310ejd.156.1623067941726; Mon, 07 Jun 2021 05:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623067941; cv=none; d=google.com; s=arc-20160816; b=an9mYPMYeBsTLVpM1M8yDwIYA/QeVgCIsOQB+wxyEeR9ypQe2GX39WgyF0GxsM/aTD fmwcDY4UfOunBaj7AQMKmAz7xarI5aRnBbfy10EOE/rQhWzpIMBGZ2dj755e1l8uZ5gu AhrePCR7dOMsSrJ3KAl39kC5SYOeOflIqB1c1r5Dcx16Cop4Slf9EJ3HRCQYWBBKqliT vATGhAXQZW6VIL9LfvQNYx6XbkPCWLSmdwnhe/aKycA9gzytxR1E/s60k77On6dodErM s/EaiD4udLuILSohpzgpVhPEJO0zU3SJvcYjb6twWDhQSkFiGQ7hXxwR7jNt/N1k/exF 46yg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=IGjlUROWa63tC+4X9rjkubiGWJVX5LdmH/3yF4fEU3o=; b=ov+fEwuDlwA4kuNC4dspSrg69k+CF+e3HglsBdZOp7pmUmDOckrzkqZ/xkV3svXYE9 UdPXsqKjMLVTY8YeoUVldXafXuj/Vk5noD+GqTWMrwMSy+QHW5otmzC9CinJEevhchZ7 2KkAbPZtEEcdNfi54q88QYcK6reilbIpXy4lvf97OPfBUf9wBdVhd/f2mjlvvOuPjRiR lNzPkQkUzJI0yjCh+F2IkbdixNGgHVzbzEigLFkzr7P6AQodl99jbndIbSfGhOxvS45h O2s+umKSnOe5UlwPrAOzbwdFgNJwk8E5gDoi8i3pcu9SP6XkHPajK9Q6Yk/q0QiK7KNh ZuzA== 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 f6si12678040edf.38.2021.06.07.05.11.59; Mon, 07 Jun 2021 05:12:21 -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 S230322AbhFGMKR (ORCPT + 99 others); Mon, 7 Jun 2021 08:10:17 -0400 Received: from verein.lst.de ([213.95.11.211]:45916 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230286AbhFGMKR (ORCPT ); Mon, 7 Jun 2021 08:10:17 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 4CCDE67373; Mon, 7 Jun 2021 14:08:22 +0200 (CEST) Date: Mon, 7 Jun 2021 14:08:22 +0200 From: Christoph Hellwig To: Coly Li Cc: Christoph Hellwig , 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, Kent Overstreet , Nix , Takashi Iwai Subject: Re: [PATCH v5 2/2] bcache: avoid oversized read request in cache missing code path Message-ID: <20210607120822.GA11665@lst.de> References: <20210607103539.12823-1-colyli@suse.de> <20210607103539.12823-3-colyli@suse.de> <20210607110657.GB6729@lst.de> <6d08d23b-b778-4e5f-a5f3-7106a42e26a1@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6d08d23b-b778-4e5f-a5f3-7106a42e26a1@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 07:55:22PM +0800, Coly Li wrote: > On 6/7/21 7:06 PM, Christoph Hellwig wrote: > > 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 > > It was suggested to not directly access BIO_MAX_VECS by you, maybe I > misunderstood you. Yes, drivers really should not care about it. But hiding that behind a tiny wrapper doesn't help either. > > 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. > > > It is just because bch_bio_map() assume the maximum bio size is 1MB. It > was not true since the multiple pages bvecs > was merged in mainline kernel. > ? > The PAGE_SECTORS part is legacy for 1MB maximum size bio (256*4KB), it > should be fixed/improved later to > use multiple pages for bio size > 1MB and replace bch_bio_map(). bch_bio_map and bch_bio_alloc_pages that poke directly into the bio are the root cause of a lot of these problems. I had a series fixing some of that but Kent did not like it. Drivers must not diretly access bi_vcnt or directly build bios. > Not any more. Now the line limit is 100 characters. Though I still > prefer 80 characters, place 86 characters in single line > makes the change more obvious. It makes it really hard to read in a normal terminal.