Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3795590ybl; Sun, 8 Dec 2019 23:40:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzeB/Q9/+HYPFR+7N+XESO3G20xjzbiXOjoZP8pYHgojG2WxV2Ryd9NXUXKMIEEr2wJ0cRn X-Received: by 2002:a9d:3425:: with SMTP id v34mr11310348otb.142.1575877212657; Sun, 08 Dec 2019 23:40:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575877212; cv=none; d=google.com; s=arc-20160816; b=wvRrgHJcQMaVp3xvSxPkCahKT2hm3zAB2JY1TKljrHi6RvSp7NPmFORuM7sLGlkO8T qWR06Ukp2fbHJD3NcaIj4bCNw6Pb7aIi8Zoa/nebOhqx0wpXszzDinVqWrH8Y7iRNk3+ VXmKFj15W2bZeVSKYDyp3t2+imTEx9nml8aXzAKgbFbIWJGFW1U9Ubl7suNPXa1t5GJk UxdqTDQgOEJ9n5PFpNgTOR+f9hmO4cSxAR9w089qoSeyAzqie3eq1pZf8jldQBIXlJUi 4x0gbKGq1NwD7jCau0yWtM+fsOJGHuuMgY5nF4B5xfi5OLWVqbrKiHNXr3nFGKG3lc7L 94IQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=RBzUEPx4oHsspEth4FQtF7CsBt3Lu0e/H3Pg/iH6hJA=; b=Gdn5J66S8M1b1XQ7TptD/MYrpiHB28N4EsrtDe790ZQLjKRE8R3Gdl/oCBO52GmSzg NQMTKKzJOjUrI+cCyt35F5TzSuODSchvm6z/vvrcZliurotk+FVrhMht2tXL5kX7MppM iDY4DBXWX1ts2BwdtVS50oosHUrLnS3xYiFW9EenjE7FUlR7jeubXG6Llc7gS+U28JlB uLeDoB/xZHLJyyANYN2+Bdw3w+hjfWd9Q1LWyKFD1p8Gkz5LZQ+lkWHTvK4M70xFx+cL 8Xm0ROJfVQdPj7uShJgyO3yGKJyX5yiB0OgeYOIqmz7PfJI68jRJxLGsPU8Rhdbp3QKs +ddA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IGqHHbWb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z18si11289967otq.121.2019.12.08.23.40.00; Sun, 08 Dec 2019 23:40:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=IGqHHbWb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727154AbfLIHhq (ORCPT + 99 others); Mon, 9 Dec 2019 02:37:46 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:42576 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbfLIHhq (ORCPT ); Mon, 9 Dec 2019 02:37:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=RBzUEPx4oHsspEth4FQtF7CsBt3Lu0e/H3Pg/iH6hJA=; b=IGqHHbWb3mAXUulXMcdRbUS0Y 0zuhaNwPeJqLrq5SOvMTdIlQfa7tYyzBGq4p6i5bM6XJr7iZr5LeSq7ni2JP4fsnxQSSkMffIrmt2 hAJpORxNtU9o/oaAw6HBatFY/9NuoUUfDFS3WI2w5iu3hiFZNl95Nd9q6vFeHEpBoOm4ObPpPBWLd 3BCV52x8PtkjMoqdYJ+1kaXdtoJQtC1TIa197o7P1F7kEnMN0ePuZRBrGjBiUWZXQyanw3Zm9dgTT P49cBbdz6rZWnUAUEukYcK73haKis+uFlqyYgmh061DaBwW0+1slKZiDdsDykO8BU4XRlsj383Gmm kfwiajV9g==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1ieDc0-0002fa-Rd; Mon, 09 Dec 2019 07:37:44 +0000 Date: Sun, 8 Dec 2019 23:37:44 -0800 From: Christoph Hellwig To: Coly Li Cc: Liang Chen , kent.overstreet@gmail.com, linux-kernel@vger.kernel.org, linux-bcache@vger.kernel.org Subject: Re: [PATCH 2/2] [PATCH] bcache: __write_super to handle page sizes other than 4k Message-ID: <20191209073744.GB3852@infradead.org> References: <1575622543-22470-1-git-send-email-liangchen.linux@gmail.com> <1575622543-22470-2-git-send-email-liangchen.linux@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 06, 2019 at 05:44:38PM +0800, Coly Li wrote: > > { > > - struct cache_sb *out = page_address(bio_first_page_all(bio)); > > + struct cache_sb *out; > > unsigned int i; > > + struct buffer_head *bh; > > + > > + /* > > + * The page is held since read_super, this __bread * should not > > + * cause an extra io read. > > + */ > > + bh = __bread(bdev, 1, SB_SIZE); > > + if (!bh) > > + goto out_bh; > > + > > + out = (struct cache_sb *) bh->b_data; > > This is quite tricky here. Could you please to move this code piece into > an inline function and add code comments to explain why a read is > necessary for a write. A read is not nessecary. He only added it because he was too fearful of calculating the data offset directly. But calculating it directly is almost trivial and should just be done here. Alternatively if that is still to hard just keep a pointer to the cache_sb around, which is how most file systems do it.