Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp484521ybl; Fri, 6 Dec 2019 00:57:53 -0800 (PST) X-Google-Smtp-Source: APXvYqwKDPxMx3a7u13wqCKU6Yu6n+AhDofyU5KCmZOAViF82J+0oMPivsK4he6657EjbMP1Ewgv X-Received: by 2002:a9d:7999:: with SMTP id h25mr10173309otm.347.1575622672954; Fri, 06 Dec 2019 00:57:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575622672; cv=none; d=google.com; s=arc-20160816; b=MlI7g5za51kV5qVMRgjVjy3xCsT92NsacsSOsOXM19iwcprhiLIK0FHxaUZ6T8dhBu gpNXQjAHwZc7OE38E2stEB0d0riT7Enl1BU+un3aUhiMyx7Xs1SnWxeUj2/lwuSGo1wu AEEqMUOMS4mQ6OhrmsNmKfWlD4p3/buYU5i3fwRRCVafcfSg2UM/ixehnHTjMMHkrNlO JbjIMDzmf++aok65NmVFq1MhdkvYzp+4Q55+zDejKkj/JEVXO8B8+vfJK8kcX61n40hx /VD442guijk9TBVMKdk7K3gEhXZ9/70wfJLft4qLMzV21tnmj3I+eeDxFgIcFXAZTuEy 6yWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=6Ss3QtZcDjjNjMVmzVt9+Rd5w/z8fKvAe110pSWx1O0=; b=oyK/pu7Qg3QUgZVR/MD8FUy0y+oMcOsUvg4/0YhakwkgunndiaMj+/joiMnSMURkil Zbm6GeXXpiWGHLnyKo18TONp10YfyPJh21XkvxlNaJ0Jdop5q+QcpAyZF2UnJiNdgu0L Vas13mQ7UQFenh3cCUyfOtN4gJHlAMHQcoj++d+2AK63vW1KevE0tqrKKxnMDN4TtKKx emBZw4xHSk5GSpzcpkCy/joJ3XHXlHozpu77fpU3L3mHkzNbyeYWGS7UVyi6nFgoC3+w BM9dEVmpTypQ8erhTaQV8LxmhP6Dm72EyTBBUW5WkXsJ8ZfGNeH2hhq1muZ3bOep05aI qJ+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ddjhbs4c; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p16si1980970oto.287.2019.12.06.00.57.40; Fri, 06 Dec 2019 00:57:52 -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=pass header.i=@gmail.com header.s=20161025 header.b=Ddjhbs4c; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726325AbfLFI4L (ORCPT + 99 others); Fri, 6 Dec 2019 03:56:11 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:34377 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726109AbfLFI4K (ORCPT ); Fri, 6 Dec 2019 03:56:10 -0500 Received: by mail-pj1-f68.google.com with SMTP id j11so1359372pjs.1; Fri, 06 Dec 2019 00:56:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6Ss3QtZcDjjNjMVmzVt9+Rd5w/z8fKvAe110pSWx1O0=; b=Ddjhbs4cE6GzBEGCP53g36/q3g1cVmZB38V4NB7LzOdUSLpJdcMJnNtlG8Q3RFJFrV /fveGj452sacVGAnUU4Kx+2VWvjtvVe8QEobBk+I0cng0I3Ls2DsOuId1+ezpE5aXTH+ xTZaEf3k2N02dwD5tFRQ1CgdskfFaoBOW4KlnkchukdNTpNUE0Gm1AT+Lfeu8lB6VF10 IUWHpDJGfRjSqTJK2KjhOX8fCliqT4s2i8RiQwzc0oftWHhhpsMFLefBqwwapDmJCXDW a2SfLTf7ov9pOncBHAZ2Byafrfk6D09x3M0fu7xtuvFocp4nrME6iIBx3R/H0kbwps8f 3VFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6Ss3QtZcDjjNjMVmzVt9+Rd5w/z8fKvAe110pSWx1O0=; b=qHVzSnfCHReYx+LCLsVdBZnVicO17v2Rfk5CYHQlhzXVHEhV6utFtyx7VXZ0tubYdc GF7He3tS7nhk40ekbehjsEBpxhTDdqqxgm9kcTwlCtYIt9yIfWKYM9llyufAx3fE9ZWw dRSmiIMf3iCzTnZ8xT6aDnPF6q75OcfCfw4kPFDdy1pybZXNvtH/blgb3B73iyHXb9ia tTjvhnF6Z27l0efCQM5SHdRvMaSQ0NpSWXgIVgmytpX15FYlusRw5psxUvyki1w3BblB pHnCJEofp/CVHHm5h+lQeVI4J1eU3vXdZpHHEKH+mswAwQZQB09guFPxa/ejCsYjkzJi 7seQ== X-Gm-Message-State: APjAAAVnq6yiWfO/U5snx1hvj/EstQTAS7T7j4JmfMEYJfF24XSQ4AxK RfBRgAuOKR84TDROqVYYguo= X-Received: by 2002:a17:90b:d85:: with SMTP id bg5mr13771030pjb.99.1575622570011; Fri, 06 Dec 2019 00:56:10 -0800 (PST) Received: from workstation.localdomain ([170.178.178.163]) by smtp.gmail.com with ESMTPSA id u18sm14520599pgi.44.2019.12.06.00.56.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Dec 2019 00:56:09 -0800 (PST) From: Liang Chen To: colyli@suse.de Cc: kent.overstreet@gmail.com, linux-kernel@vger.kernel.org, linux-bcache@vger.kernel.org, Liang Chen Subject: [PATCH 2/2] [PATCH] bcache: __write_super to handle page sizes other than 4k Date: Fri, 6 Dec 2019 16:55:43 +0800 Message-Id: <1575622543-22470-2-git-send-email-liangchen.linux@gmail.com> X-Mailer: git-send-email 2.7.5 In-Reply-To: <1575622543-22470-1-git-send-email-liangchen.linux@gmail.com> References: <1575622543-22470-1-git-send-email-liangchen.linux@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __write_super assumes super block data starts at offset 0 of the page read in with __bread from read_super, which is not true when page size is not 4k. We encountered the issue on system with 64K page size - commonly seen on aarch64 architecture. Instead of making any assumption on the offset of the data within the page, this patch calls __bread again to locate the data. That should not introduce an extra io since the page has been held when it's read in from read_super, and __write_super is not on performance critical code path. Signed-off-by: Liang Chen --- drivers/md/bcache/super.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index a573ce1d85aa..a39450c9bc34 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c @@ -207,15 +207,27 @@ static void write_bdev_super_endio(struct bio *bio) closure_put(&dc->sb_write); } -static void __write_super(struct cache_sb *sb, struct bio *bio) +static int __write_super(struct cache_sb *sb, struct bio *bio, + struct block_device *bdev) { - 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; bio->bi_iter.bi_sector = SB_SECTOR; bio->bi_iter.bi_size = SB_SIZE; bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_SYNC|REQ_META); - bch_bio_map(bio, NULL); + bch_bio_map(bio, bh->b_data); out->offset = cpu_to_le64(sb->offset); out->version = cpu_to_le64(sb->version); @@ -239,7 +251,14 @@ static void __write_super(struct cache_sb *sb, struct bio *bio) pr_debug("ver %llu, flags %llu, seq %llu", sb->version, sb->flags, sb->seq); + /* The page will still be held without this bh.*/ + put_bh(bh); submit_bio(bio); + return 0; + +out_bh: + pr_err("Couldn't read super block, __write_super failed"); + return -1; } static void bch_write_bdev_super_unlock(struct closure *cl) @@ -264,7 +283,8 @@ void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent) closure_get(cl); /* I/O request sent to backing device */ - __write_super(&dc->sb, bio); + if(__write_super(&dc->sb, bio, dc->bdev)) + closure_put(cl); closure_return_with_destructor(cl, bch_write_bdev_super_unlock); } @@ -312,7 +332,9 @@ void bcache_write_super(struct cache_set *c) bio->bi_private = ca; closure_get(cl); - __write_super(&ca->sb, bio); + if(__write_super(&ca->sb, bio, ca->bdev)) + closure_put(cl); + } closure_return_with_destructor(cl, bcache_write_super_unlock); -- 2.17.0