From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F385AC2D0E2 for ; Tue, 22 Sep 2020 09:13:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DA7D20715 for ; Tue, 22 Sep 2020 09:13:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726576AbgIVJNR (ORCPT ); Tue, 22 Sep 2020 05:13:17 -0400 Received: from mx2.suse.de ([195.135.220.15]:58278 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726341AbgIVJNR (ORCPT ); Tue, 22 Sep 2020 05:13:17 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 3198DAEEF; Tue, 22 Sep 2020 09:13:51 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 1C2AD1E12E3; Tue, 22 Sep 2020 11:13:14 +0200 (CEST) Date: Tue, 22 Sep 2020 11:13:14 +0200 From: Jan Kara To: Christoph Hellwig Cc: Jens Axboe , Song Liu , Hans de Goede , Coly Li , Richard Weinberger , Minchan Kim , Johannes Thumshirn , Justin Sanders , linux-mtd@lists.infradead.org, dm-devel@redhat.com, linux-block@vger.kernel.org, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, drbd-dev@lists.linbit.com, linux-raid@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, cgroups@vger.kernel.org Subject: Re: [PATCH 07/13] block: lift setting the readahead size into the block layer Message-ID: <20200922091314.GD16464@quack2.suse.cz> References: <20200921080734.452759-1-hch@lst.de> <20200921080734.452759-8-hch@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200921080734.452759-8-hch@lst.de> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-bcache@vger.kernel.org On Mon 21-09-20 10:07:28, Christoph Hellwig wrote: > Drivers shouldn't really mess with the readahead size, as that is a VM > concept. Instead set it based on the optimal I/O size by lifting the > algorithm from the md driver when registering the disk. Also set > bdi->io_pages there as well by applying the same scheme based on > max_sectors. > > Signed-off-by: Christoph Hellwig > Reviewed-by: Johannes Thumshirn ... > diff --git a/block/blk-settings.c b/block/blk-settings.c > index 76a7e03bcd6cac..01049e9b998f1d 100644 > --- a/block/blk-settings.c > +++ b/block/blk-settings.c > @@ -452,6 +452,8 @@ EXPORT_SYMBOL(blk_limits_io_opt); > void blk_queue_io_opt(struct request_queue *q, unsigned int opt) > { > blk_limits_io_opt(&q->limits, opt); > + q->backing_dev_info->ra_pages = > + max(queue_io_opt(q) * 2 / PAGE_SIZE, VM_READAHEAD_PAGES); > } > EXPORT_SYMBOL(blk_queue_io_opt); > > @@ -628,9 +630,6 @@ void disk_stack_limits(struct gendisk *disk, struct block_device *bdev, > printk(KERN_NOTICE "%s: Warning: Device %s is misaligned\n", > top, bottom); > } > - > - t->backing_dev_info->io_pages = > - t->limits.max_sectors >> (PAGE_SHIFT - 9); > } > EXPORT_SYMBOL(disk_stack_limits); One thing I've noticed is that blk_stack_limits() does not use blk_queue_io_opt() to set new optimal limit. That means that ra_pages won't be updated for the new queue. E.g. your DRDB change below will result in ra_pages not being properly updated AFAICT. Similarly it isn't clear to me how io_pages would get updated after blk_stack_limits() updates max_hw_sectors... Otherwise the patch looks good. Honza > diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c > index aaff5bde391506..f8fb1c9b1bb6c1 100644 > --- a/drivers/block/drbd/drbd_nl.c > +++ b/drivers/block/drbd/drbd_nl.c > @@ -1360,18 +1360,8 @@ static void drbd_setup_queue_param(struct drbd_device *device, struct drbd_backi > decide_on_discard_support(device, q, b, discard_zeroes_if_aligned); > decide_on_write_same_support(device, q, b, o, disable_write_same); > > - if (b) { > + if (b) > blk_stack_limits(&q->limits, &b->limits, 0); > - > - if (q->backing_dev_info->ra_pages != > - b->backing_dev_info->ra_pages) { > - drbd_info(device, "Adjusting my ra_pages to backing device's (%lu -> %lu)\n", > - q->backing_dev_info->ra_pages, > - b->backing_dev_info->ra_pages); > - q->backing_dev_info->ra_pages = > - b->backing_dev_info->ra_pages; > - } > - } > fixup_discard_if_not_supported(q); > fixup_write_zeroes(device, q); > } -- Jan Kara SUSE Labs, CR