Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp630486yba; Thu, 18 Apr 2019 07:07:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxZ45++LUMmyWxI7ogG8LXlgcqOD7/8Mlb33Al/VDU2Haa0fii1ipKtSXiRxrsFXnrDNxlB X-Received: by 2002:a17:902:eb0f:: with SMTP id cw15mr6324609plb.314.1555596465447; Thu, 18 Apr 2019 07:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555596465; cv=none; d=google.com; s=arc-20160816; b=VOuxl6nAqMqFZxdpk3WAZjcSi0G6eFyHaG/dwbZCWTAMOIzUPhxAefh+ZrCZn6uweV MxVYhQpS2ioSsWSbPwWKj2y9q3qpcwitONA+Vx+2XKjoxBZKzcTmcQIWd0bQAx8bxJtN GDX7zxWjzbPi2LNE2xif6LxJtmPukmhQMM2SNTnPVvPMc/guJwe7xK6XE3uphe/KaQdV kWaZfU9020cm5bSNPXmzhQASClRw0sF+/ars2mI2wb1f0SGLxgtFgc355V+mEqy0+69s SRxU3erZd2AfUqkI6K7qVay8kO8juZ8r5pWJs1IaAUn1yp/WNYDAc9t8YZIoxH6JU/Jr i6aA== 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; bh=hjH/x7AambhthlZEZUgu50bmqOATeHH9YubU7+YNwbU=; b=JlXkb0Y0tJ4iVaDj5r1f41MCG/ZMNWYJRtWzLh0YhvcnD0dM+hWAN9osae3VI/gXOV k9KPUx/z70tZVUWCFbLObvwJ0EDG88UehQU4mJWu2oO4dUJIme8h8f2oR0tu060QT7yp P+CpuUcrIbos+3jCoECkTA2L0KyT9NbXVu9UgsJqiY3HPSN1P3B6z3pzGgPi5AiYDxo4 5Gdu5f2pp3x+8WNseK+u/vP3SKhmXb75BhbXu2dr77rqmArz9WKZsIAjtLCpujeH2L+B m5BXcjhjfhJihB48VnSJlRfmFAEdrBd3kcSKXIzoaoLvC+0XNsg5OSruigipMmB8AE2k xhgw== ARC-Authentication-Results: i=1; mx.google.com; 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 t7si2203847plo.163.2019.04.18.07.07.30; Thu, 18 Apr 2019 07:07:45 -0700 (PDT) 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; 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 S2389181AbfDROGJ (ORCPT + 99 others); Thu, 18 Apr 2019 10:06:09 -0400 Received: from mx2.suse.de ([195.135.220.15]:49434 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388392AbfDROGI (ORCPT ); Thu, 18 Apr 2019 10:06:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 96984AF1C; Thu, 18 Apr 2019 14:06:06 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 8DC201E15AE; Thu, 18 Apr 2019 16:06:03 +0200 (CEST) Date: Thu, 18 Apr 2019 16:06:03 +0200 From: Jan Kara To: Kanchan Joshi Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, prakash.v@samsung.com Subject: Re: [PATCH v4 4/7] block: introduce write-hint to stream-id conversion Message-ID: <20190418140603.GL28541@quack2.suse.cz> References: <1555523406-2380-1-git-send-email-joshi.k@samsung.com> <1555523406-2380-5-git-send-email-joshi.k@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1555523406-2380-5-git-send-email-joshi.k@samsung.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 17-04-19 23:20:03, Kanchan Joshi wrote: > This patch moves write-hint-to-stream-id conversion in block-layer. > Earlier this was done by driver (nvme). Current conversion is of the > form "streamid = write-hint - 1", for both user and kernel streams. > Conversion takes stream limit (maintained in request queue) into > account. Write-hints beyond the exposed limit turn to 0. > A new field 'streamid' has been added in request. While 'write-hint' > field continues to exist. It keeps original value passed from upper > layer, and used during merging checks. > > Signed-off-by: Kanchan Joshi > --- > block/blk-core.c | 20 ++++++++++++++++++++ > include/linux/blkdev.h | 1 + > 2 files changed, 21 insertions(+) > > diff --git a/block/blk-core.c b/block/blk-core.c > index a55389b..712e6b7 100644 > --- a/block/blk-core.c > +++ b/block/blk-core.c > @@ -730,6 +730,25 @@ bool blk_attempt_plug_merge(struct request_queue *q, struct bio *bio, > return false; > } > > +enum rw_hint blk_write_hint_to_streamid(struct request *req, > + struct bio *bio) > +{ > + enum rw_hint streamid, nr_streams; > + struct request_queue *q = req->q; > + nr_streams = q->limits.nr_streams; > + > + streamid = bio->bi_write_hint; > + if (!nr_streams || streamid == WRITE_LIFE_NOT_SET || > + streamid == WRITE_LIFE_NONE) > + streamid = 0; > + else { > + --streamid; > + if(streamid > nr_streams) > + streamid = 0; > + } > + return streamid; > +} > + Someone told me that stream ids are potentially persistent on the storage so it isn't great to change the id for the same thing e.g. if we add another user hint. So maybe we should allocate kernel hints from top as Dave Chinner suggested? I.e., something like the following mapping function: if (streamid <= BLK_MAX_USER_HINTS) { streamid--; if (streamid > nr_streams) streamid = 0; } else { /* Kernel hints get allocated from top */ streamid -= WRITE_LIFE_KERN_MIN; if (streamid > nr_streams - BLK_MAX_USER_HINTS) streamid = 0; else streamid = nr_streams - streamid - 1; } what do you think? Honza -- Jan Kara SUSE Labs, CR