From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.49 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796006399; b=L3GhZlQcXpkvwDP9eiQKP9UOs7Ppj9ANn0sD0AMgszMuphOcwN2DPZqZPO2v/wORW4Of I+px5y89Wj29v3xtu8zvifVXYQfXl3m0iOeDIig8BIH4wFJAsbwQgvUC3+Js0yIz59kKg HerNE0Q1pn6N37Est3H7RY2wS5gGTJYDMXZvMn+UFukXzWj3vu1uJauwHh/HDU3Hj0XX4 ZHAaALmkrGUVp86Aix3U0Nbq161TuMAPZdfL7tkvVFt6C06JnErtPR3aVOqZsHTWhmSU4 S/yZo483AQH0PtzoOTrmekbFzQcUH2P347FiqRD4S4tXJHPUra+LIvCInmqEHOXhB5A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796006399; 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=jAFYQc8pRp2sxyuO59HLb7ve2aR9KNXmkPqInV1zdXk=; b=kPrQDikJimw7WVs750B8GEKThN3QycQxdSArTxD+93dGhjrKESu9W8GpmxHW8HdhlOU6 TaEubBCwIybAyo9O2RiEOGkSFY2VYwN/u0A+77cGbjQr1FZYRpPJfDw9D9mgPHfQmRcKm o1cFvvMUaq1WF0UaeR26vD0EWxRweHWmQ8G99Ao7H2cCOg/RZhAUjmuCE7vnxRLneFair eEDWkkt5VkrrzmC8zi31M6CDSFHWB76AVqJ1x+c+187uLmCM30t413M7n/IR1+L6cji7c jRENzSSM2zF/CoAAKw6a/sLb8mmj2cCIRpciAmoCWbnWfbO0zgUoLm8z0lWGMGHhEMg== 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=TRE951S6; arc=none smtp.remote-ip=209.85.210.49 Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (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 257CA606A327 for ; Mon, 30 Nov 2026 02:39:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 257CA606A327 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=TRE951S6 Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-86288992de5so7240691a34.1 for ; Sun, 29 Nov 2026 18:39:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796006398; x=1796611198; 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=jAFYQc8pRp2sxyuO59HLb7ve2aR9KNXmkPqInV1zdXk=; b=TRE951S6fR2WrU3+OIzxGNN8gGoeSRhcpTf0SArJMBcchlFCGFWiiuV63GFp/dojIj QjPtUHY19qVA83EWDc6Tj1JRTqsDQrtv2+IawL5QWm52Z/ODnobUJm9XVE1OV0g4PbW/ lIGxD3tRlIvj2K4By7SuQNrbyuAgXXnxxkN6a2/4l3zRLfJyaXsyVKI/YFHV4k5wxGiG dyqDSXv1mkKChrbwcgAkXdSyv0DweEcym6R+FT6CaCE/0mbXS2XO20pJdldTW3Ulv0cO mtZv6XENRSSzjVH9LPLQprFmzR2zqrKC2X7Io93/EL7Ny5LUP1WLLcBEDUeM0grKXUm2 S8Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796006398; x=1796611198; 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=jAFYQc8pRp2sxyuO59HLb7ve2aR9KNXmkPqInV1zdXk=; b=WLxw2lu4mzIIlctqnjfro3XT6S6Q/EzHOeiSo4wULODScKZCCW4GRi1dORyn9NLKvl mAWsUrCvBAGrv+bY+LnUkrU5Phc71G7SrNo3nNEZUYSkh3kNMOqasBu4ZJcdVmdd5Ge5 FDb4NImUG+Mul4lCy/0TlH24HMZ/6+Bx9ndace0nHlwEeiDztZZWjSZHU6rNBPNX180q wyOQx9TNdtm3VfRQE3EQ2M70BHucSwh6So/Lu3G8DipZnloVxX+mSHZblEvNCrcjFyTe T57+IyR3DOA1b9sT3xygby8IO8D3THNvuM/TzEfzUsz1EP7ApNnnbnbqm0sFtLmNEQr4 8C6Q== X-Forwarded-Encrypted: i=1; AL+hErHMiyassR1nL/lerDyGDp+IJ1xh14Ds1tWB3B9LR4EdDZu3idfaKju/tk8fsK6MykHGzp/qtAc=@vger.kernel.org X-Gm-Message-State: APuU4Z+SPhnkyz58XjcST9BWngYoLvhEZOidbFF/Sc1kog0xkhpotkuw ZHhzii+yFnv4IlptDKYYieX0JJCrcAmcoa3ZbfqWGd1r3eKBGR/9HTYo X-Gm-Gg: AZFdTZeZTVjEJodxcgeSU8CzSloS/RJKfqLZSQIcyj9ULw5GBvTaa/tYQjmaK+W1CR8 +EcFLCnKw61MYgGWaSceKnIgipWeYvqsSGGA9l4EVFCxU5pr0eiXiDfvMfzjqbDKWVzQ2TYQ0VR 4B8mAxH1upaat9uZdyK2MXmC4cCzX//jmhFO3gSsuA9MNE8DokF/MDagJ/e4n+t+ZjWplbRbALy NMkOlrA1wilzM/M0V2cVw4BiEAz0mWXUGLzBL/kzXn5Gb94H/AVP40LDiy5VnaG/WhSRl2QOt8Q 70KvF2uP5gIYVro0b3HrTky3VJC/MCAlMgcKaNcok6pie7fTiEODKA/eo/IsC7bH4h/tm1Itnfa GeVWLZ6e1AvAoVPMg88e1Lftsm0Dh27nfao3MrJHxNSytXQxxTinpdwltYsG6PUxaAXFvnPR9kw t98ZxMDS2ZgBcLZ0ha1fnMxPSXgAuoptEqOQL0y9pPJlLQlBUYQsR5Afro4oFJ9pVNhlDXOley2 e+q39BC7e5VRzEKocAvTVR20E/KfvB1zzS5i7IvWZ+9O6UPa36Je7O9EeSszZD+hWouMV3JB4t6 YISccWmxxgmIyBCGwYW5rtdjMAp4Ce0m5B63r2o9oifudwy6vKH/2zCGTEq5ziAau+eANRHwBbE oacMISUel3DKKBolFOLS7Zq3K59zssw2q4G9YkEAvWu1KxzwTHrLi5bwaXA== X-Received: by 2002:a05:6830:2e01:b0:862:ca3f:37f8 with SMTP id 46e09a7af769-8630927fc7emr25421640a34.26.1796006398051; Sun, 29 Nov 2026 18:39:58 -0800 (PST) Received: from fedora-laptop.tail348456.ts.net ([172.245.82.59]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-86322db2d1asm21254554a34.4.2026.11.29.18.39.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 18:39:57 -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 3/5] ublk: don't complete a short request in full Date: Sun, 29 Nov 2026 20:39:28 -0600 Message-ID: <20261130023937.606428-4-tom.leiming@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261130023937.606428-1-tom.leiming@gmail.com> References: <20261130023937.606428-1-tom.leiming@gmail.com> X-Mailing-List: stable@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 db1b049b7ac0..69778b34ffd0 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