From nobody Fri Dec 19 14:36:06 2025 Received: from mail-oa1-f104.google.com (mail-oa1-f104.google.com [209.85.160.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4871834E759 for ; Thu, 6 Nov 2025 17:17:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.104 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762449428; cv=none; b=suUC/MsZdEdCye629TGKc8MBMtENDlzEeZW49JWeKtRWuj/qsHGlG0hiv/tsj5Q4MxzKFO2lhYK9pxvLxzTKarbMHV6GL6eN+IpUEQZ/WQKxNUo48ZyhWi27X2j8CCH27p6soSw65O2N9Ho6voOykdboQHodClJXaQbqcLqpZP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762449428; c=relaxed/simple; bh=wBafmD1PayfZCiZJCkVQ0+F0gMQwd6p1jXlMnZn5YmQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=incCivFAmb741E+mSGqhVI9BE2VRnkVtytaC0gPDqkzzfkiijVTsJBf9HLi7hzr9tqwn8at4+onMjr+dFJr6PzNHmt2MNi5kI9APlGKU1IQ8v6Rfz0V39drDY1KlfjXoDCvJBc9dIuf0bnL0cHdnWNDdP0ARZGJlg5/ekII5kPc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=S5NW2k5B; arc=none smtp.client-ip=209.85.160.104 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="S5NW2k5B" Received: by mail-oa1-f104.google.com with SMTP id 586e51a60fabf-3c99d6ff0deso490894fac.1 for ; Thu, 06 Nov 2025 09:17:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1762449425; x=1763054225; 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=+oSFiObM7RAEo/WrdtTuQmJtpLuHs/NBmatOtwNMwHs=; b=S5NW2k5BQTXtxHm1P0qt78yiYHxfPO1VFgrTS06j3vOALzVYEMfm55BbCEqKfRG/qi eeeWMXNkcQbGVQ+/iETnRuEpOClWahB+eEvFfHwPW/hL6vZ936djU+OOPf9ns+9WTxfo 8p4Xi8yeesWtOFBCMqTZ7FDOV3twBpIBhoCaEeaBKqL8fPqhWVGKyTT4RZ8L//MG6W8k vhMG3gfzuf/uXzh+87kF6YvUiAGrSQjEhRoAxeAhssusUHnVhBWDb7lSL4xtIZ3blUlg ZaZR4R1B88Tkku2Awg1C5JmTyK9slAwdB7EaBkqJwxBa69hTRp8dZKkXJaWnkwBrytLG l2KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762449425; x=1763054225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+oSFiObM7RAEo/WrdtTuQmJtpLuHs/NBmatOtwNMwHs=; b=cifm1Jrzpf2mqhk3I2cMEXRqBvVndqXZ2oW4TTaE5mwcGB0LGil53QY5d/BG/GCJv2 pFkk5MTiwtyQ8ERKtFpOa+QhkDHZlPnNlQcHqjlwAazTiDF0RdnzIgtYfd6CpyiV0wUo YummQsYV+jytIMGUAY+o2ERIy6ezWMAh9C15RWpXthlLeDwL3qDf0j6XknogFL8GwsY6 lH9QkgOg7R+lVg0vOlxPIr0HYlZ6xUPLjh7e1TxqKeqbgjYfjwFMLZeYViqHNMa6b2aX tDzZZLUlLFM3F+L2zlfQLbw2QEJ6ZzBfwfsAeqnLVr8y53fxARUeeTL5gHbGmdDdaUNU byvQ== X-Forwarded-Encrypted: i=1; AJvYcCUDQXWFVjxEaRWH9uJbly8TynfOfn7eWfKm59cCHRdmLapSPvkdM/AZ5wij6J4jCDwthloOiX/1NgtqvNc=@vger.kernel.org X-Gm-Message-State: AOJu0YwsXhAD59RCgBnxVozhNToZ94X+4zX7pjao+I9NejpQgnOklwyn U+YsBZAPnAHEEPQVka4jKZbpzUlwFL8ksd/9IcyMsxbLDRQZokpjcEpf5huGRHauMe/hOl66XDu 1HesqgsXxt/9e16fC9wrdDpLfwbOV9L+NC/eY X-Gm-Gg: ASbGnctCH4KDDojWo51jJwH0MBwWLcqCJ7V9QbykInc4TWlB9+CSh3Kaa3OsYiJxzdF Lv+gPgfb1ued+Hr59GCHvbZP51cyHJEMB3NU8wowe5xGgodwc4lGVoMWSRKigZ4XCiK+8g1CX8E clD+DPjmPpbadeLtX370yErewSFC5XEA2cBWdOENzNM+bMZN48ijFv70LiDdvyYgGlsNTPfuQzm wsWeFja6fW+CE/Ms1ae+Io/1zpU2eMt2dU1aa39Y7HYVcsSXnSC/aj7H4gd63hwn9gVQhotCVr4 JAVzbXG7RU5leRPHIxZ5mlPEIpvsIm6RKLvVErx81WGRyT8/0V0T2Jcm0tJI1t16wQrWkca/+Az 1sYG6Q1qOLBgt5VIAWhQqYJEx+ZNxt68= X-Google-Smtp-Source: AGHT+IHVbMUymvX0FalFWXCotYOJ6nfVMyYq924TTcFbfvd6YhEKMWH5Rm8Y1TNKoPo+9ypajR5CPkvh41o+ X-Received: by 2002:a05:6830:924:b0:7c6:cf87:88ae with SMTP id 46e09a7af769-7c6efef3bd5mr164068a34.4.1762449425146; Thu, 06 Nov 2025 09:17:05 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.128]) by smtp-relay.gmail.com with ESMTPS id 46e09a7af769-7c6f0f0f226sm9389a34.2.2025.11.06.09.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Nov 2025 09:17:05 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.7.70.37]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 9C45D340410; Thu, 6 Nov 2025 10:17:04 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 9817DE401BC; Thu, 6 Nov 2025 10:17:04 -0700 (MST) From: Caleb Sander Mateos To: Ming Lei , Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH v3 1/2] ublk: use copy_{to,from}_iter() for user copy Date: Thu, 6 Nov 2025 10:16:46 -0700 Message-ID: <20251106171647.2590074-2-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20251106171647.2590074-1-csander@purestorage.com> References: <20251106171647.2590074-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ublk_copy_user_pages()/ublk_copy_io_pages() currently uses iov_iter_get_pages2() to extract the pages from the iov_iter and memcpy()s between the bvec_iter and the iov_iter's pages one at a time. Switch to using copy_to_iter()/copy_from_iter() instead. This avoids the user page reference count increments and decrements and needing to split the memcpy() at user page boundaries. It also simplifies the code considerably. Ming reports a 40% throughput improvement when issuing I/O to the selftests null ublk server with zero-copy disabled. Signed-off-by: Caleb Sander Mateos Reviewed-by: Ming Lei --- drivers/block/ublk_drv.c | 62 +++++++++------------------------------- 1 file changed, 14 insertions(+), 48 deletions(-) diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index 97cc4bc0a6ce..40eee3e15a4c 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -911,58 +911,47 @@ static const struct block_device_operations ub_fops = =3D { .open =3D ublk_open, .free_disk =3D ublk_free_disk, .report_zones =3D ublk_report_zones, }; =20 -#define UBLK_MAX_PIN_PAGES 32 - struct ublk_io_iter { - struct page *pages[UBLK_MAX_PIN_PAGES]; struct bio *bio; struct bvec_iter iter; }; =20 -/* return how many pages are copied */ -static void ublk_copy_io_pages(struct ublk_io_iter *data, - size_t total, size_t pg_off, int dir) +/* return how many bytes are copied */ +static size_t ublk_copy_io_pages(struct ublk_io_iter *data, + struct iov_iter *uiter, int dir) { - unsigned done =3D 0; - unsigned pg_idx =3D 0; + size_t done =3D 0; =20 - while (done < total) { + for (;;) { struct bio_vec bv =3D bio_iter_iovec(data->bio, data->iter); - unsigned int bytes =3D min3(bv.bv_len, (unsigned)total - done, - (unsigned)(PAGE_SIZE - pg_off)); void *bv_buf =3D bvec_kmap_local(&bv); - void *pg_buf =3D kmap_local_page(data->pages[pg_idx]); + size_t copied; =20 if (dir =3D=3D ITER_DEST) - memcpy(pg_buf + pg_off, bv_buf, bytes); + copied =3D copy_to_iter(bv_buf, bv.bv_len, uiter); else - memcpy(bv_buf, pg_buf + pg_off, bytes); + copied =3D copy_from_iter(bv_buf, bv.bv_len, uiter); =20 - kunmap_local(pg_buf); kunmap_local(bv_buf); =20 - /* advance page array */ - pg_off +=3D bytes; - if (pg_off =3D=3D PAGE_SIZE) { - pg_idx +=3D 1; - pg_off =3D 0; - } - - done +=3D bytes; + done +=3D copied; + if (copied < bv.bv_len) + break; =20 /* advance bio */ - bio_advance_iter_single(data->bio, &data->iter, bytes); + bio_advance_iter_single(data->bio, &data->iter, copied); if (!data->iter.bi_size) { data->bio =3D data->bio->bi_next; if (data->bio =3D=3D NULL) break; data->iter =3D data->bio->bi_iter; } } + return done; } =20 static bool ublk_advance_io_iter(const struct request *req, struct ublk_io_iter *iter, unsigned int offset) { @@ -986,38 +975,15 @@ static bool ublk_advance_io_iter(const struct request= *req, */ static size_t ublk_copy_user_pages(const struct request *req, unsigned offset, struct iov_iter *uiter, int dir) { struct ublk_io_iter iter; - size_t done =3D 0; =20 if (!ublk_advance_io_iter(req, &iter, offset)) return 0; =20 - while (iov_iter_count(uiter) && iter.bio) { - unsigned nr_pages; - ssize_t len; - size_t off; - int i; - - len =3D iov_iter_get_pages2(uiter, iter.pages, - iov_iter_count(uiter), - UBLK_MAX_PIN_PAGES, &off); - if (len <=3D 0) - return done; - - ublk_copy_io_pages(&iter, len, off, dir); - nr_pages =3D DIV_ROUND_UP(len + off, PAGE_SIZE); - for (i =3D 0; i < nr_pages; i++) { - if (dir =3D=3D ITER_DEST) - set_page_dirty(iter.pages[i]); - put_page(iter.pages[i]); - } - done +=3D len; - } - - return done; + return ublk_copy_io_pages(&iter, uiter, dir); } =20 static inline bool ublk_need_map_req(const struct request *req) { return ublk_rq_has_data(req) && req_op(req) =3D=3D REQ_OP_WRITE; --=20 2.45.2 From nobody Fri Dec 19 14:36:06 2025 Received: from mail-il1-f229.google.com (mail-il1-f229.google.com [209.85.166.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFEF034E771 for ; Thu, 6 Nov 2025 17:17:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.229 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762449428; cv=none; b=QbTFP7fR0nZ+cL3Axsea2IUJb3WJDJvxI0PzPIGJehC1XWTGuMTpbf8lhi2IFDGcInA5KjE/pWRBLlpOCoxNfsato5ETM1rind3OO9kB519bab2867s2j1HcerQq7/9hnDt79xGICsHs2aqsu4JZttEsCNhVH/cq/UmXEkaDAWc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762449428; c=relaxed/simple; bh=OBV5Wvf7Pf20YICHZs8rawC+9onihr9HjuRkLnqfYV4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RzMj2EhaJiPCR+bTetwDhwGo89pkNeWiw0pjl/RLpNsRkSYxfyIiYV5hQPglTZQCracAT3FR/Ri8mS73+yO3NYGOH6956ZVQDouGxm3S/35yoGzbFwWR62MhmGyy2qPGkvNfhQ9q+3RB0hhaYEaNGl1BJvY7FXyAr7LvEnG+dXY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=Goh0CI3z; arc=none smtp.client-ip=209.85.166.229 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="Goh0CI3z" Received: by mail-il1-f229.google.com with SMTP id e9e14a558f8ab-4334ebed4b7so480735ab.1 for ; Thu, 06 Nov 2025 09:17:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1762449425; x=1763054225; 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=IB1zx0ug02eNzGM3pa1SYRczl09y5Mp94LC3eOoPIeo=; b=Goh0CI3zkM4IOSL9nJI4JIR2jxS6Y9YB0kE/V3bp0/Hge2nAsu0oi7R6ObzSqgp7y9 uGuEfjvr5YGbjgKndGkW+yayIj9zVNBipblQf93xMh46pIZvCHX4LHfEx+OtAeg8lEWR 5wtMmPksr2gmmqqrsKDCuraDwu+Rp/HFroSyTSn5SwgVaqPlBGi6PuiJtIWgnaw/3T8N HYB9mEzZbHG3jUPtJBlj3sClEDpm4P7VI0J8Dkd1H2Jy+nKrhgEF93SKo92JrM82/syZ 7QDDY9oUGRq737Tj1vNL7LhWo65AgetWnXpEOySkQrKzj/+1SUjCkJ+12QRNMDmzaGQ6 8OJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762449425; x=1763054225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=IB1zx0ug02eNzGM3pa1SYRczl09y5Mp94LC3eOoPIeo=; b=wI1KRrejPUbfYNPFNE6bXycrcgyQYXGjFxq6Ys0ckxfaAeL+xPxf5jm6gZz32frbBF AnMahbqpBc80gwSqUP292woRB9H0/4DpWnuBfMmSz9t4dv6RvzxFO7FQukI87ovzhQQ5 v90ijpd6bVlw8FjC9SloQaexpLdFN3B+10T6bsrg1ABJsr/VqN2FHaamNDHAifNxkqNU EB6/ptAQ0zF+kptzpIGlqc/PXKAjsOVmr3YvbCDCd5JzOzXWTBBvFShyvWSkWD5ekzEB Qy1+FkCELDjGd2IA6vq0jHlkFtOoiGsjDNEYwt7qIGuJXNHzVrYaonDBJ0fHRA6usH9r TX3w== X-Forwarded-Encrypted: i=1; AJvYcCVJcYtCK78XxDUe9gmhcyhP4dyrAOMGW6L/fBelqnKrbbMgvz0jx5/6AKc5poBfKCDgge2HIzTZzErfidY=@vger.kernel.org X-Gm-Message-State: AOJu0YwIhOtq/hk8izKuak002ox5JYnDKqhzYBVf+xj5ad7XCgL5SPzZ 83BpWMVl20K3AZ4krrKi/f1nwd2lVFNMJ+N9Gx5pwrkp1Ewf/8DO+TyAyiVhwoQSNea2xYSPQiT 3dH3seiUS5g+j54skSvFWriJO3xjXdZy46tkE X-Gm-Gg: ASbGncvaIl2JxxskWPCUqnY34bUbl3aGzwCyTK1QyTJ18KUrJXm/T5VGG2TcWxF7Rye Imw0j4VwCkM2k7wf8eZg4jZE2rgvkbAbdJcF8xpPTUp+zG+lwPE9kKZoIkoa3AUyb+mWYYXpyG8 W/wsnXQpBfi+0yMjamp6g5XZZdIzJK6vRW0Dv4Do7bApqusZ86jHNXTOoHkObqvi8D/Y2nV7Wur MTMwohf12aJkAHthpmqXHj5VjW8K6+qyrqrgejdcvyixne2k1PP+XAoQ0gzFcAAkuD2qQa1ofhn NcXAgS3ywo1oJrv/pyRg4Jz78mgjPm3PxwNOxehG6Kow/U8tQqE9lFZwdJQ5AS6P9VJcdrFf7XS 1IlxDBoCgcMSGUCggjv5DL3Dx1rmS23k= X-Google-Smtp-Source: AGHT+IE3SOPR3RvvTYbgxmQWXBVVJ3yDbMy/iZny5RZkVIcJY2XztktIO9465VGyzSGLf0729xvn39bTVg5V X-Received: by 2002:a05:6e02:1d85:b0:433:5c6b:4b72 with SMTP id e9e14a558f8ab-4335f49a8c0mr835205ab.6.1762449425552; Thu, 06 Nov 2025 09:17:05 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.128]) by smtp-relay.gmail.com with ESMTPS id e9e14a558f8ab-4334f4b46basm2221115ab.19.2025.11.06.09.17.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Nov 2025 09:17:05 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.7.70.37]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 3C217340315; Thu, 6 Nov 2025 10:17:05 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 3922EE401BC; Thu, 6 Nov 2025 10:17:05 -0700 (MST) From: Caleb Sander Mateos To: Ming Lei , Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH v3 2/2] ublk: use rq_for_each_segment() for user copy Date: Thu, 6 Nov 2025 10:16:47 -0700 Message-ID: <20251106171647.2590074-3-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20251106171647.2590074-1-csander@purestorage.com> References: <20251106171647.2590074-1-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" ublk_advance_io_iter() and ublk_copy_io_pages() currently open-code the iteration over the request's bvecs. Switch to the rq_for_each_segment() macro provided by blk-mq to avoid reaching into the bio internals and simplify the code. Suggested-by: Ming Lei Signed-off-by: Caleb Sander Mateos Reviewed-by: Ming Lei --- drivers/block/ublk_drv.c | 70 +++++++++++----------------------------- 1 file changed, 19 insertions(+), 51 deletions(-) diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index 40eee3e15a4c..5cf288809226 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -911,26 +911,33 @@ static const struct block_device_operations ub_fops = =3D { .open =3D ublk_open, .free_disk =3D ublk_free_disk, .report_zones =3D ublk_report_zones, }; =20 -struct ublk_io_iter { - struct bio *bio; - struct bvec_iter iter; -}; - -/* return how many bytes are copied */ -static size_t ublk_copy_io_pages(struct ublk_io_iter *data, - struct iov_iter *uiter, int dir) +/* + * Copy data between request pages and io_iter, and 'offset' + * is the start point of linear offset of request. + */ +static size_t ublk_copy_user_pages(const struct request *req, + unsigned offset, struct iov_iter *uiter, int dir) { + struct req_iterator iter; + struct bio_vec bv; size_t done =3D 0; =20 - for (;;) { - struct bio_vec bv =3D bio_iter_iovec(data->bio, data->iter); - void *bv_buf =3D bvec_kmap_local(&bv); + rq_for_each_segment(bv, req, iter) { + void *bv_buf; size_t copied; =20 + if (offset >=3D bv.bv_len) { + offset -=3D bv.bv_len; + continue; + } + + bv.bv_offset +=3D offset; + bv.bv_len -=3D offset; + bv_buf =3D bvec_kmap_local(&bv); if (dir =3D=3D ITER_DEST) copied =3D copy_to_iter(bv_buf, bv.bv_len, uiter); else copied =3D copy_from_iter(bv_buf, bv.bv_len, uiter); =20 @@ -938,54 +945,15 @@ static size_t ublk_copy_io_pages(struct ublk_io_iter = *data, =20 done +=3D copied; if (copied < bv.bv_len) break; =20 - /* advance bio */ - bio_advance_iter_single(data->bio, &data->iter, copied); - if (!data->iter.bi_size) { - data->bio =3D data->bio->bi_next; - if (data->bio =3D=3D NULL) - break; - data->iter =3D data->bio->bi_iter; - } + offset =3D 0; } return done; } =20 -static bool ublk_advance_io_iter(const struct request *req, - struct ublk_io_iter *iter, unsigned int offset) -{ - struct bio *bio =3D req->bio; - - for_each_bio(bio) { - if (bio->bi_iter.bi_size > offset) { - iter->bio =3D bio; - iter->iter =3D bio->bi_iter; - bio_advance_iter(iter->bio, &iter->iter, offset); - return true; - } - offset -=3D bio->bi_iter.bi_size; - } - return false; -} - -/* - * Copy data between request pages and io_iter, and 'offset' - * is the start point of linear offset of request. - */ -static size_t ublk_copy_user_pages(const struct request *req, - unsigned offset, struct iov_iter *uiter, int dir) -{ - struct ublk_io_iter iter; - - if (!ublk_advance_io_iter(req, &iter, offset)) - return 0; - - return ublk_copy_io_pages(&iter, uiter, dir); -} - static inline bool ublk_need_map_req(const struct request *req) { return ublk_rq_has_data(req) && req_op(req) =3D=3D REQ_OP_WRITE; } =20 --=20 2.45.2