From nobody Fri Dec 19 14:44:44 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22BA3C4167B for ; Mon, 11 Dec 2023 09:01:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234211AbjLKJAx (ORCPT ); Mon, 11 Dec 2023 04:00:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234112AbjLKJAq (ORCPT ); Mon, 11 Dec 2023 04:00:46 -0500 Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94C56F1; Mon, 11 Dec 2023 01:00:52 -0800 (PST) Received: by mail-il1-x12f.google.com with SMTP id e9e14a558f8ab-35d64ad4188so19751165ab.3; Mon, 11 Dec 2023 01:00:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702285252; x=1702890052; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3C4XGNOSQh2qdBXT10pq8W1umCRdPJt9fc3zqaA6RvE=; b=B6c/+Ac/eaHHn0JXTnLGcIauJsiztidAQEh8Tdy4VdUC/YbImwy2siiuUAy1XPCqW4 THVpUlsTpP2kZMpYAy0gKa3bwWyHcKs4gMjQp2C52OJJEg5tHV+MWQXOEujAu/d6VPgP vhd5vea1DjBeiUzSbuPZsa92HZBZWZ8GaRrh9pbLiGqTe8ntyai9mpBunKYcFqD5EaBy 4BeKQuM6yqRva33M4+Ciy9wavuIt2tVtG6Zng6i8J0xGtuRH+FimBVyJmFximuONlIrG LdQTUtaF8/naear6uGxK6PYhrQYI0/XOCFz+66aNOWXku7smLRqkzbXBtpBaHMOJ+FYB o9RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702285252; x=1702890052; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3C4XGNOSQh2qdBXT10pq8W1umCRdPJt9fc3zqaA6RvE=; b=QFpgV36xUCGg7e9LiQPtShow5QVrliqJxt1FTSfmW32UY6yoeNYDM6LL++z0cU3Ehz CjXU/i1dft3YejAhz8tQxVLbt28/2hAgSQ007JixmzlLrElQKkKRDIVbXYXa8cJFe3ub x7pdDDVKBiIOoT3HmC6rM6C6MspwPXXfjjG8wj1lUMagWEjY7EAEwoOEaMmeF7mcmhq4 lhckP7osEP59eVNNfgKtXkUESM9EwikZSsHEKVXp5PUGgfF1heKXskUeDfINjuiRDVId MNSoy2mBBV41azjkTY7PrRxLBo3F0h0I1SO+txZ9HMMu8K6kayfKI1uTDV/3jEbNjyYk GqjA== X-Gm-Message-State: AOJu0YxCm1FYz/y5DKpyC/2pPp43rGrx5g0FyrfaOEF62l6UK8q76hxL 7wSQCS8a0Bu2qPF4id+3m/8= X-Google-Smtp-Source: AGHT+IEyCY3ErGWmI8LoIrEOhonz6hBK3ptUyoziGLGE/0Z406ge/Sd7ExzYhLFDiYo6/zx9zBAXTw== X-Received: by 2002:a92:d150:0:b0:35d:6220:ac8b with SMTP id t16-20020a92d150000000b0035d6220ac8bmr5172666ilg.58.1702285251875; Mon, 11 Dec 2023 01:00:51 -0800 (PST) Received: from ubuntu.. ([117.18.48.102]) by smtp.gmail.com with ESMTPSA id f14-20020a056e020b4e00b0035b0b05189bsm2211216ilu.38.2023.12.11.01.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 01:00:51 -0800 (PST) From: Hongyu Jin To: agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, axboe@kernel.dk, ebiggers@kernel.org Cc: zhiguo.niu@unisoc.com, ke.wang@unisoc.com, yibin.ding@unisoc.com, hongyu.jin@unisoc.com, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-block@vger.kernel.org Subject: [PATCH v3 2/5] dm: Support I/O priority for dm_io() Date: Mon, 11 Dec 2023 16:59:57 +0800 Message-Id: <20231211090000.9578-3-hongyu.jin.cn@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231211090000.9578-1-hongyu.jin.cn@gmail.com> References: <20231211090000.9578-1-hongyu.jin.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hongyu Jin Add ioprio field in struct dm_io_region, by this field specific I/O priority when call dm_io(). Co-developed-by: Yibin Ding Signed-off-by: Yibin Ding Signed-off-by: Hongyu Jin --- drivers/md/dm-bufio.c | 3 +++ drivers/md/dm-integrity.c | 5 +++++ drivers/md/dm-io.c | 1 + drivers/md/dm-log.c | 1 + drivers/md/dm-raid1.c | 2 ++ drivers/md/dm-snap-persistent.c | 1 + drivers/md/dm-writecache.c | 4 ++++ include/linux/dm-io.h | 2 ++ 8 files changed, 19 insertions(+) diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c index 62eb27639c9b..7f82262aed54 100644 --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -1269,6 +1269,7 @@ static void use_dmio(struct dm_buffer *b, enum req_op= op, sector_t sector, .bdev =3D b->c->bdev, .sector =3D sector, .count =3D n_sectors, + .ioprio =3D IOPRIO_DEFAULT, }; =20 if (b->data_mode !=3D DATA_MODE_VMALLOC) { @@ -2125,6 +2126,7 @@ int dm_bufio_issue_flush(struct dm_bufio_client *c) .bdev =3D c->bdev, .sector =3D 0, .count =3D 0, + .ioprio =3D IOPRIO_DEFAULT, }; =20 if (WARN_ON_ONCE(dm_bufio_in_request())) @@ -2149,6 +2151,7 @@ int dm_bufio_issue_discard(struct dm_bufio_client *c,= sector_t block, sector_t c .bdev =3D c->bdev, .sector =3D block_to_sector(c, block), .count =3D block_to_sector(c, count), + .ioprio =3D IOPRIO_DEFAULT, }; =20 if (WARN_ON_ONCE(dm_bufio_in_request())) diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index e85c688fd91e..7cba183abdce 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -543,6 +543,7 @@ static int sync_rw_sb(struct dm_integrity_c *ic, blk_op= f_t opf) io_loc.bdev =3D ic->meta_dev ? ic->meta_dev->bdev : ic->dev->bdev; io_loc.sector =3D ic->start; io_loc.count =3D SB_SECTORS; + io_loc.ioprio =3D IOPRIO_DEFAULT; =20 if (op =3D=3D REQ_OP_WRITE) { sb_set_version(ic); @@ -1070,6 +1071,7 @@ static void rw_journal_sectors(struct dm_integrity_c = *ic, blk_opf_t opf, io_loc.bdev =3D ic->meta_dev ? ic->meta_dev->bdev : ic->dev->bdev; io_loc.sector =3D ic->start + SB_SECTORS + sector; io_loc.count =3D n_sectors; + io_loc.ioprio =3D IOPRIO_DEFAULT; =20 r =3D dm_io(&io_req, 1, &io_loc, NULL); if (unlikely(r)) { @@ -1187,6 +1189,7 @@ static void copy_from_journal(struct dm_integrity_c *= ic, unsigned int section, u io_loc.bdev =3D ic->dev->bdev; io_loc.sector =3D target; io_loc.count =3D n_sectors; + io_loc.ioprio =3D IOPRIO_DEFAULT; =20 r =3D dm_io(&io_req, 1, &io_loc, NULL); if (unlikely(r)) { @@ -1515,6 +1518,7 @@ static void dm_integrity_flush_buffers(struct dm_inte= grity_c *ic, bool flush_dat fr.io_reg.bdev =3D ic->dev->bdev, fr.io_reg.sector =3D 0, fr.io_reg.count =3D 0, + fr.io_reg.ioprio =3D IOPRIO_DEFAULT, fr.ic =3D ic; init_completion(&fr.comp); r =3D dm_io(&fr.io_req, 1, &fr.io_reg, NULL); @@ -2738,6 +2742,7 @@ static void integrity_recalc(struct work_struct *w) io_loc.bdev =3D ic->dev->bdev; io_loc.sector =3D get_data_sector(ic, area, offset); io_loc.count =3D n_sectors; + io_loc.ioprio =3D IOPRIO_DEFAULT; =20 r =3D dm_io(&io_req, 1, &io_loc, NULL); if (unlikely(r)) { diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c index f053ce245814..b40f0a432981 100644 --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c @@ -354,6 +354,7 @@ static void do_region(const blk_opf_t opf, unsigned int= region, &io->client->bios); bio->bi_iter.bi_sector =3D where->sector + (where->count - remaining); bio->bi_end_io =3D endio; + bio->bi_ioprio =3D where->ioprio; store_io_and_region_in_bio(bio, io, region); =20 if (op =3D=3D REQ_OP_DISCARD || op =3D=3D REQ_OP_WRITE_ZEROES) { diff --git a/drivers/md/dm-log.c b/drivers/md/dm-log.c index f9f84236dfcd..e0dacdcd94f1 100644 --- a/drivers/md/dm-log.c +++ b/drivers/md/dm-log.c @@ -309,6 +309,7 @@ static int flush_header(struct log_c *lc) .bdev =3D lc->header_location.bdev, .sector =3D 0, .count =3D 0, + .ioprio =3D IOPRIO_DEFAULT, }; =20 lc->io_req.bi_opf =3D REQ_OP_WRITE | REQ_PREFLUSH; diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index ddcb2bc4a617..2de9b1377de3 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c @@ -275,6 +275,7 @@ static int mirror_flush(struct dm_target *ti) io[i].bdev =3D m->dev->bdev; io[i].sector =3D 0; io[i].count =3D 0; + io[i].ioprio =3D IOPRIO_DEFAULT; } =20 error_bits =3D -1; @@ -475,6 +476,7 @@ static void map_region(struct dm_io_region *io, struct = mirror *m, io->bdev =3D m->dev->bdev; io->sector =3D map_sector(m, bio); io->count =3D bio_sectors(bio); + io->ioprio =3D bio_prio(bio); } =20 static void hold_bio(struct mirror_set *ms, struct bio *bio) diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persisten= t.c index 15649921f2a9..4aa70b71f1da 100644 --- a/drivers/md/dm-snap-persistent.c +++ b/drivers/md/dm-snap-persistent.c @@ -236,6 +236,7 @@ static int chunk_io(struct pstore *ps, void *area, chun= k_t chunk, blk_opf_t opf, .bdev =3D dm_snap_cow(ps->store->snap)->bdev, .sector =3D ps->store->chunk_size * chunk, .count =3D ps->store->chunk_size, + .ioprio =3D IOPRIO_DEFAULT, }; struct dm_io_request io_req =3D { .bi_opf =3D opf, diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c index 074cb785eafc..135d1268246f 100644 --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -515,6 +515,7 @@ static void ssd_commit_flushed(struct dm_writecache *wc= , bool wait_for_ios) region.bdev =3D wc->ssd_dev->bdev; region.sector =3D (sector_t)i * (BITMAP_GRANULARITY >> SECTOR_SHIFT); region.count =3D (sector_t)(j - i) * (BITMAP_GRANULARITY >> SECTOR_SHIFT= ); + region.ioprio =3D IOPRIO_DEFAULT; =20 if (unlikely(region.sector >=3D wc->metadata_sectors)) break; @@ -555,6 +556,7 @@ static void ssd_commit_superblock(struct dm_writecache = *wc) region.bdev =3D wc->ssd_dev->bdev; region.sector =3D 0; region.count =3D max(4096U, wc->block_size) >> SECTOR_SHIFT; + region.ioprio =3D IOPRIO_DEFAULT; =20 if (unlikely(region.sector + region.count > wc->metadata_sectors)) region.count =3D wc->metadata_sectors - region.sector; @@ -590,6 +592,7 @@ static void writecache_disk_flush(struct dm_writecache = *wc, struct dm_dev *dev) region.bdev =3D dev->bdev; region.sector =3D 0; region.count =3D 0; + region.ioprio =3D IOPRIO_DEFAULT; req.bi_opf =3D REQ_OP_WRITE | REQ_PREFLUSH; req.mem.type =3D DM_IO_KMEM; req.mem.ptr.addr =3D NULL; @@ -984,6 +987,7 @@ static int writecache_read_metadata(struct dm_writecach= e *wc, sector_t n_sectors region.bdev =3D wc->ssd_dev->bdev; region.sector =3D wc->start_sector; region.count =3D n_sectors; + region.ioprio =3D IOPRIO_DEFAULT; req.bi_opf =3D REQ_OP_READ | REQ_SYNC; req.mem.type =3D DM_IO_VMA; req.mem.ptr.vma =3D (char *)wc->memory_map; diff --git a/include/linux/dm-io.h b/include/linux/dm-io.h index 7595142f3fc5..227ee6d77c70 100644 --- a/include/linux/dm-io.h +++ b/include/linux/dm-io.h @@ -20,6 +20,8 @@ struct dm_io_region { struct block_device *bdev; sector_t sector; sector_t count; /* If this is zero the region is ignored. */ + /* Set it to IOPRIO_DEFAULT if you don't know what value to set */ + unsigned short ioprio; }; =20 struct page_list { --=20 2.34.1