From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.161.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796118732; b=RMls13EgrxF2xeUgnKUUXggLmUYN+S4I05+9lp4GhmgY53K/umz0Ov1d8X5zE5+ApfFZ kLrJccxMGQu/dZJsv4J1LNZzOBAHFcUktMz1t1ofQ6wWv2vMMlpqp5t9D5DOLUVHa/LtY wbz+X5F8Hlj5UltHJiiM2WxT3zL4A7hQ5lCioU1OQpsSuBLUhjVJk79NbWhRUPd/btW2A IubKcP+QvdG5aEULxmwBPxueOB8nRJJAj3wPSbY4DH/4n9m36/xPv92iG16IqE5RSh9Aw h0PmiB5AsOgm+WHMiT51v1VWJoFRV26RWi4rn8UKV9xnEbQhuKadTvr/WbKmwyK45WA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796118732; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=x9bOGAN9hb0ZlKeB5wxL2+u8dP7XbW3Jwu8BcVySc4E=; b=sgVlD7mwxqLB9uwIGCUrTSVxla72bYgtE8eOISmkrtaL3LTNmUYv9Xvt1wP+ZzBrwMAT WlhGaOWjSfgckzimfa183Zix5NBpaUGL0SiH/wCXElJXTBKWzTK/I8CbmJG5sx64mCEWe SapjYFki3dPtDm0ppaf64AtCDhV8bHhW6noWGk/Xl7ETZ18CS90UL/XAEOdlSHfZYG4Bc yQM8M2PuJr60uadvbkjBx0dUB0Yo3fDcu/XrUFn96txBa0/aTxDpmw5J+BDQa4myavJx0 xUHwTqseFoxEH3GSwcM+EZqHPfzTu1RBdYYb1vdaapOAd+rAqwp6D3s32Mm/lA7nCwQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=JIz8OFHF; arc=none smtp.remote-ip=209.85.161.45 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEF02606A680 for ; Tue, 1 Dec 2026 09:52:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CEF02606A680 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=JIz8OFHF Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-703be215729so5082138eaf.1 for ; Tue, 01 Dec 2026 01:52:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796118731; x=1796723531; 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:content-type; bh=x9bOGAN9hb0ZlKeB5wxL2+u8dP7XbW3Jwu8BcVySc4E=; b=JIz8OFHFj7EJ0DZt3EbHwVPioGZ6yjf1up19zyHJ/s8/hr9kNEggYG86OWuAzprrcq upxH5zIGnIjpbjirBr0jOqEEiweMJ22bHrx/X+nUoKJXLZ4pYcPc/53Az6Xeu+mZes+T phfRy0ikK/xWPRivRZP6DCtElLFy6YCx9lW8rm/y4hGXPIuXZlTBeFkzevdcoOoSmvwq 5NSBwx214BH5AhoDc77qg0JSg4MhJ/vLRFtv3aiPPY1DAxwbntJk42XqGxi967uAtcvD xIt1Hra810V2/yZea3t10zih8X6XdFhODZrsVH6EPChcQv31IkpIQvA0O5pUMNPHSPYP a6qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796118731; x=1796723531; 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:content-type; bh=x9bOGAN9hb0ZlKeB5wxL2+u8dP7XbW3Jwu8BcVySc4E=; b=A/hayNJ/OiJNAdBukm6UiJ7NZigoLlDh5NrNOxpITdUiudC7KfRMC/b383b8e7ephZ 7ezFOMcxzhx90Oga+tfNK8s2WhP5m0LOk8VP0XzS7pPtD9gKIW277yISPBkKE3RC+ehK g4kthcA9OpWnI4POgqSaJDIYqImD4TCGhWjUjlDEXMZJrmZtNU3tjRQxSxzqxNg0w+CR dQ/qFKdxLQFzQ6TOG8i7CCRXW+bcWZfObczqZHs/R4Bjir5umPIxTZnsKQYKg5RcN8wU IBlzIqxhiyhkT3AV5+ib7ILTou0YQqIA/dfMwvz9TPSHLBeiLXcdfnNp4NTsz7vAd18t 1kcQ== X-Forwarded-Encrypted: i=1; AL+hErH+Wq/rdhlqNBehTU2NCB16NO9rprogQNc5Qa18dd4lOQeo/g4lM/ERVFbWcAWAMgm3raXyktb5nbeKeRXb3hk=@vger.kernel.org X-Gm-Message-State: APuU4Z+p5zG66nmbKCIsOrSzFmVZUVyeNBJvnc5Ly/CbMcEjxDC2HiM0 GNivwQABp9yN20S6Jyt+XLXkUhGeImwdQeJlWa62/+HgAohFr0dOevdM X-Gm-Gg: AZFdTZdMNI5jybiRVfKQUET1mi9fv4/e/n31eUfnVsDsKPoHTKMW4TN7VHc4531M/wg rF3ROF4vXhUSu5XP6AlpmDtcXbGOrykIQhCIoEguiRCphl21mgzUOtba2h9ukJMNS1tyt3bpV5R nz9meO7q8SG0yW0s5DjDtMcnH/8/63xNtZ2Ioy1V0jAGNU2sQGYbl9pYYuHTk7sDEVShu59K1jY bH8jsdcM76qgRvA7UF+oxRYbjcSFndgasttI7T4VkgFfGSjBFQQQmVuxesY9Mmi6nL7EpYfSh7e jsO3YxVCHEnwpgYdFJMxA5GYjLAQI8vkPveVSfsCA0Pe4o6keNGylpvZ2qCtcZTUeC07MLa1nE5 ATcQQ2hLtd+qAOxpuaadivzP8jk2dsKaPYqn87w1X5bZ2j5ZiF73QonuPDCIQvL5U9ohtPAbKzP aSu+RTRNejTemgkfaMv+arzNyiIa3F1QeLuhIgP+Uvt7b8JJ0UFahLcda7OrPjGNWki9YRTN9zz pW0CfBVNNEMezzUwAvs+1KzOHgBaLKBGeyKxOZQztFf+SxDrSjeLV90pK5hGlE71gHgoWhLWUQB 7tNT2GHX39i2iYsJHceBs84wg+gOYyqkaWH3PYYopxS3Xr5qjHHkhG4vIiNDgPQCrb3bLjXM/Yb O8WVgQBBkOzmYp0OMMi72Q2LjxAV520htfZWbQfulifJBaIx8WMpjWNnE5pCLhLjmOL59Hnajgz W2Aww= X-Received: by 2002:a05:6820:1501:b0:71a:e4a8:bed0 with SMTP id 006d021491bc7-71b395c0ce0mr28696331eaf.90.1796118730767; Tue, 01 Dec 2026 01:52:10 -0800 (PST) Received: from fedora-laptop.tail348456.ts.net ([172.245.82.59]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-71b380b6f82sm22698287eaf.10.2026.12.01.01.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 01:52:10 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-block@vger.kernel.org Cc: Ming Lei , Caleb Sander Mateos , Shuah Khan , linux-kselftest@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2 3/5] ublk: don't complete a short request in full Date: Tue, 1 Dec 2026 03:51:49 -0600 Message-ID: <20261201095153.1012606-4-tom.leiming@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201095153.1012606-1-tom.leiming@gmail.com> References: <20261201095153.1012606-1-tom.leiming@gmail.com> X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Since commit a8a79eba22dc ("ublk: lift checks out of ublk_{,un}map_io()"), __ublk_complete_rq() ends the request in full and ignores io->res when there is nothing to copy back: every WRITE, and every request on a user copy, zero copy or auto buffer registration device. A short write or read from the server is reported as complete. Shmem zero copy requests have had the same problem since commit 4d4a512a1f87 ("ublk: add PFN-based buffer matching in I/O path"). Skip only the copy step, and complete READ and WRITE by io->res through blk_update_request() again, requeueing the rest. Other requests are still ended directly, including report zones, whose reply can be short. Fixes: a8a79eba22dc ("ublk: lift checks out of ublk_{,un}map_io()") Fixes: 4d4a512a1f87 ("ublk: add PFN-based buffer matching in I/O path") Cc: stable@vger.kernel.org Signed-off-by: Ming Lei --- drivers/block/ublk_drv.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c index 1a0cbaf5690a..5cffd8c4e0a3 100644 --- a/drivers/block/ublk_drv.c +++ b/drivers/block/ublk_drv.c @@ -1569,7 +1569,6 @@ static void ublk_end_request(struct request *req, blk_status_t error) local_bh_enable(); } -/* todo: handle partial completion */ static inline void __ublk_complete_rq(struct request *req, struct ublk_io *io, bool need_map, struct io_comp_batch *iob) { @@ -1594,10 +1593,24 @@ static inline void __ublk_complete_rq(struct request *req, struct ublk_io *io, goto exit; } - /* shmem zero copy: no data to unmap, pages already shared */ + /* + * FLUSH, DISCARD, WRITE_ZEROES and zone management requests usually + * don't return a byte count, so end them directly. So is report zones + * (DRV_IN): its reply can be shorter than the buffer, and a requeued + * rest would rerun the report. So is zone append: a requeued rest would + * be appended again at a moved write pointer. + */ + if (req_op(req) != REQ_OP_READ && req_op(req) != REQ_OP_WRITE) + goto exit; + + /* + * Nothing to copy for WRITE, user copy, zero copy, auto buffer + * registration or shmem zero copy, but io->res still tells how many + * bytes are done. + */ if (!need_map || !ublk_need_unmap_req(req) || ublk_iod_is_shmem_zc(req->mq_hctx->driver_data, req->tag)) - goto exit; + goto update; /* for READ request, writing data in iod->addr to rq buffers */ unmapped_bytes = ublk_unmap_io(req, io); @@ -1618,6 +1631,7 @@ static inline void __ublk_complete_rq(struct request *req, struct ublk_io *io, io->res = unmapped_bytes; } +update: /* * Run bio->bi_end_io() with softirqs disabled. If the final fput * happens off this path, then that will prevent ublk's blkdev_release() -- 2.56.1