From patchwork Fri Feb 23 16:12:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13569416 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55084823C5; Fri, 23 Feb 2024 16:13:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704785; cv=none; b=llV7vsrpmCVPO060d66vqhk6cTkVa+icwB3qxUOiuSZCYHlvQHDbvJyVH7WcIxf9icMqSCYPp5Bh2y47DcVqLcKHnUM3Fpb52UbtnBV/JtP1OR2wDue2SBPOeCP9PDiYy7lEUBWWb34yGBXY1a2spBAZaNoLXl632gslZTS2aEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708704785; c=relaxed/simple; bh=tqUc+Z9d2VAdWNLtusCOHo8Eoophn2R0QknoDx92pJ0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GebKVpkllYEM7bIOfE+ZbQOYYMTfAvWWPsZIsti0Hupxf2aRL7GZNLhx03zLPzia4uZzNuTl9fcMqXUiOzqdIDo/tNlzvK7LSSd8/vr3d6QxqRKaXHvw0e5aVZUvlbn/yxJfz2vhuJtUgkAQOx4hH05eExuAQjfSxCZpQutY9Xs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=SdwUH+ZS; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SdwUH+ZS" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=OMaKAmrOGVexeWclRWo7mbRBrld0WSyZffyo91301/M=; b=SdwUH+ZSlxRUjNTV6VjxMwvkcD hV1OSOFLEmyVBDUNPjZlfm9bpLXqcQt2UZg2LUNn+4nfyYCKOQRNxJGJ2rYF00CDuzGESUWu0f6Xk MBbPA7oWXJ9rqXDJ8upjJqayFqFxcVhq8SJqyoLC1qSI2efdFp9nGX7MmmBPcUBztL7Oew02Zr6Ve +PXwJ8uE1LcoesvOygbzjGh4mTnjEMGmmbPQat2PsN13Ght4oQvKNngkBpETZ6PyvZklsLSfaojFo TBu8oUNxE2YKQyb3zCTCr1LT2rFDpJRR7y7VOF2GbrUx2NXVLNLKJRxHyFjW7J0FEoi4Ggt2dwkTK 7YPbZWTA==; Received: from [2001:4bb8:19a:62b2:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdYAT-0000000AAgf-1Zo2; Fri, 23 Feb 2024 16:13:03 +0000 From: Christoph Hellwig To: Jens Axboe , Mike Snitzer , Mikulas Patocka , Song Liu , Yu Kuai Cc: dm-devel@lists.linux.dev, linux-block@vger.kernel.org, linux-raid@vger.kernel.org Subject: [PATCH 2/9] block: add a queue_limits_stack_bdev helper Date: Fri, 23 Feb 2024 17:12:40 +0100 Message-Id: <20240223161247.3998821-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223161247.3998821-1-hch@lst.de> References: <20240223161247.3998821-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Add a small wrapper around blk_stack_limits that allows passing a bdev for the bottom device and prints an error in case of misaligned device. The name fits into the new queue limits API and the intent is to eventually replace disk_stack_limits. Signed-off-by: Christoph Hellwig --- block/blk-settings.c | 24 ++++++++++++++++++++++++ include/linux/blkdev.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/block/blk-settings.c b/block/blk-settings.c index 1989a177be201b..f14d3a18f9e2f0 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -891,6 +891,30 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, } EXPORT_SYMBOL(blk_stack_limits); +/** + * queue_limits_stack_bdev - adjust queue_limits for stacked devices + * @t: the stacking driver limits (top device) + * @bdev: the underlying block device (bottom) + * @offset: offset to beginning of data within component device + * + * Description: + * This function is used by stacking drivers like MD and DM to ensure + * that all component devices have compatible block sizes and + * alignments. The stacking driver must provide a queue_limits + * struct (top) and then iteratively call the stacking function for + * all component (bottom) devices. The stacking function will + * attempt to combine the values and ensure proper alignment. + */ +void queue_limits_stack_bdev(struct queue_limits *t, struct block_device *bdev, + sector_t offset, const char *pfx) +{ + if (blk_stack_limits(t, &bdev_get_queue(bdev)->limits, + get_start_sect(bdev) + offset)) + pr_notice("%s: Warning: Device %pg is misaligned\n", + pfx, bdev); +} +EXPORT_SYMBOL_GPL(queue_limits_stack_bdev); + /** * disk_stack_limits - adjust queue limits for stacked drivers * @disk: MD/DM gendisk (top) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index dd510ad7ce4b45..285e82723d641f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -924,6 +924,8 @@ extern void blk_set_queue_depth(struct request_queue *q, unsigned int depth); extern void blk_set_stacking_limits(struct queue_limits *lim); extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, sector_t offset); +void queue_limits_stack_bdev(struct queue_limits *t, struct block_device *bdev, + sector_t offset, const char *pfx); extern void disk_stack_limits(struct gendisk *disk, struct block_device *bdev, sector_t offset); extern void blk_queue_update_dma_pad(struct request_queue *, unsigned int);