From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 EB4E632ED4E for ; Tue, 6 Jan 2026 13:15:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767705307; cv=none; b=ecMseQBNBAtpCZLDvzD7TmbG+CgVf5m4MwG+6HCNuY3R11m4eAX5kMQ4a3VpLW7Nkvu/9qiniU0clhEgnUZ+64GMAqCRI28nhOJyAjIPIwqP/4n5wV9SD34dNv2KaOCAG5/0wnN6w+Ckvrd6axPxpCa28+bsM2NtZjs63mej2Qs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767705307; c=relaxed/simple; bh=oeQfbG3YXkVorqOxo5ToI8t7EzLqBrUOMDj1P0VzPpg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aVEhIIXrhjQ91wnCCz5149aY7uqDiWD0Ft9Vx7AwzoXN/j/bDeFdSvgZRbjusg1lEbixe1hGV/xENqKWDjDVQUB64AeuGfGGMChqZbg9bRnTMjhCC+jsH6BJpxCHXNZzKEJQ5wN8FS6qNcmwupeAqF2nrASk9bmk5USHrJLGMis= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NmVmCpgp; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NmVmCpgp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1767705304; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Fa8r7E52wSsWJY4CuomkcvnqW024CYAaKP2i8APhpbY=; b=NmVmCpgpk02+A3zIPBiA1ZQeLOdJg6wzscqz6RWJiIa7mCPwA7tH1l1EaTkmvaPcNINvtu YU6BWd0Chh5SGdVHKCYP3eJb7428ZMK9PrU3+LdtExx180cFVoYGT2rJ9y1431EdnCnmxQ GLuX4jYKBwxee6eOGLYnDClA7NYolPE= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-209-DVhyaenNPnmtWmYE-v-8yw-1; Tue, 06 Jan 2026 08:15:01 -0500 X-MC-Unique: DVhyaenNPnmtWmYE-v-8yw-1 X-Mimecast-MFC-AGG-ID: DVhyaenNPnmtWmYE-v-8yw_1767705300 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id DE2A4195FCDD; Tue, 6 Jan 2026 13:14:59 +0000 (UTC) Received: from fedora (unknown [10.72.116.130]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C8EEC19560B2; Tue, 6 Jan 2026 13:14:50 +0000 (UTC) Date: Tue, 6 Jan 2026 21:14:39 +0800 From: Ming Lei To: Caleb Sander Mateos Cc: Jens Axboe , Shuah Khan , linux-block@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Stanley Zhang , Uday Shankar , "Martin K . Petersen" Subject: Re: [PATCH v3 05/19] ublk: add ublk_copy_user_bvec() helper Message-ID: References: <20260106005752.3784925-1-csander@purestorage.com> <20260106005752.3784925-6-csander@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260106005752.3784925-6-csander@purestorage.com> X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 On Mon, Jan 05, 2026 at 05:57:37PM -0700, Caleb Sander Mateos wrote: > Factor a helper function ublk_copy_user_bvec() out of > ublk_copy_user_pages(). It will be used for copying integrity data too. > > Signed-off-by: Caleb Sander Mateos > --- > drivers/block/ublk_drv.c | 52 +++++++++++++++++++++++----------------- > 1 file changed, 30 insertions(+), 22 deletions(-) > > diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c > index 2b0a9720921d..2ce9afdecc15 100644 > --- a/drivers/block/ublk_drv.c > +++ b/drivers/block/ublk_drv.c > @@ -1000,10 +1000,39 @@ static const struct block_device_operations ub_fops = { > .open = ublk_open, > .free_disk = ublk_free_disk, > .report_zones = ublk_report_zones, > }; > > +static bool ublk_copy_user_bvec(const struct bio_vec *bv, unsigned *offset, > + struct iov_iter *uiter, int dir, size_t *done) > +{ > + unsigned len; > + void *bv_buf; > + size_t copied; > + > + if (*offset >= bv->bv_len) { > + *offset -= bv->bv_len; > + return true; > + } > + > + len = bv->bv_len - *offset; > + bv_buf = kmap_local_page(bv->bv_page) + bv->bv_offset + *offset; > + if (dir == ITER_DEST) > + copied = copy_to_iter(bv_buf, len, uiter); > + else > + copied = copy_from_iter(bv_buf, len, uiter); > + > + kunmap_local(bv_buf); > + > + *done += copied; > + if (copied < len) > + return false; > + > + *offset = 0; > + return true; > +} > + > /* > * 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, > @@ -1012,33 +1041,12 @@ static size_t ublk_copy_user_pages(const struct request *req, > struct req_iterator iter; > struct bio_vec bv; > size_t done = 0; > > rq_for_each_segment(bv, req, iter) { > - unsigned len; > - void *bv_buf; > - size_t copied; > - > - if (offset >= bv.bv_len) { > - offset -= bv.bv_len; > - continue; > - } > - > - len = bv.bv_len - offset; > - bv_buf = kmap_local_page(bv.bv_page) + bv.bv_offset + offset; > - if (dir == ITER_DEST) > - copied = copy_to_iter(bv_buf, len, uiter); > - else > - copied = copy_from_iter(bv_buf, len, uiter); > - > - kunmap_local(bv_buf); > - > - done += copied; > - if (copied < len) > + if (!ublk_copy_user_bvec(&bv, &offset, uiter, dir, &done)) > break; > - > - offset = 0; > } > return done; > } Reviewed-by: Ming Lei Thanks, Ming