From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796006399; b=Bcvj8AS6MQDW13MaqH1p/vpFFBeuxzcJ/T2+gZx8rKPZkvRj1B53SvnoEPF0fC1GYMRZ zxRlvst/fGykeO28d8T6HDypxs0gLMh9Xf9uu6xc1yOa7y2SwG4RaxqUtz06A8RobM4gb t/ook/NOYQdFtdzRTt/njZteAvDeq2N4QzmobK+Gnhht9rRCrsF9aPHKMkcQqv8iPUtBy 7It8l/bNu/Ljp8WG+Xl4wPytyRgDWg5c7jKgCjmS3ZPRbptw7wQcmuSVz/9Zj5+QConnH GB5WxBLQ/NF53TD4pPm7lIesvnm8M9CIDey7chueU089K2MU8hjEs9Aq3GkLMRYLcow== 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=2XvFrvUvpu6jpH1CpJYIhozWNL21jpEi7JjIGXnp+UietfctwpTiLIReG7zPMdwTv4OC WMBHCXcNKskh2QKV7mpryUpFybeXBfm71UujTt/x0bbuWxfCgcVJK1c+NtdorZdmvxsJz okcziqfkWm5g97bmRZoLAocyELuGgJI4pIq2OdONYEH1eEbeS8ttsWO0fP71Wf6p+TENT R85L+KtwotwrvLeSjqpsEHHNdUiqiD0wcEoyCH9G1DMi4quGKcROQpQO5mwgPcbef8cxG 9qwDE4j0UDreiJIQ67GdZeu2teyqHvxThIHx93gaGlgOAkfqsnhmOmm55utKasUFK2Q== 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.53 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (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 1A293606A325 for ; Mon, 30 Nov 2026 02:39:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1A293606A325 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-f53.google.com with SMTP id 46e09a7af769-862df509d48so7445960a34.0 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=DsYGgSLVCDfk91bcEIYxtQqagvwmF8hB1+DJiNig9UigrvMGuR0wEkZ6bUQX2UREa2 jlbUo9Li0L+NEAi6V3ocspVK35iokyXCdnqy+cAHttzGAaIrGXtOmHpDn1giWv22bbK/ nn4XTIS03rgb5YZDELbtGQQhW3kgjege2Uj7cPJ94lVWFAOPLhAU+RLV+NG3+LZrgIUZ mNvxFo5w0wlLTvLmxZtCmWK7jO9YRoHqGl3kPQ+9fCJZVQsVeuPN52cvYOMGrvM2lIo9 YNB37iCTXFLN7pG2oPvALY3QIyM18eVhLynQ2J1DgvIDz9ZvQcgiwpq+D0GtHFa+r4c6 xRcA== X-Forwarded-Encrypted: i=1; AL+hErHfvxSFc2vglYHo9Ngvl4ZnlgjBi7hA2kOgQbysXhzexk1N07AUWdwb8Ip8UVMx+P00pG3H+zFm4SSXTw==@vger.kernel.org X-Gm-Message-State: APuU4Z8Y2gAGVoKQqqH0JLQQkOcbhhbDHq4kZv51XYch/rKfjK6lim0B O26TMrDrtdNQP7oDVcDUSEoXKOMYZxAQaM5djiVkD342i4UhXweCodZY X-Gm-Gg: AZFdTZeFMwHL/iURJLUBLJiwEr3sVnYGyZitw/IhVxS09qno+WBwxbZcFOLiitW4pbZ pU6oYoFnm8Uo/iMF3A8tKtC95OroYEw/7r3g2dSjlpUf4Xk/b+mzNm6CsNhZ9wb8zt9SIrbLS8E WRi0+FT2NzuSgnzpEx5gi+9cPCuTmMBoXmcjO5Q0JJGBTYEQRIKbOcFO/6deVkWcizHbuODd+9H TmO8+P1D56Qba55YyJt8yII11QpWVIswtDkNF/+XC4mmq5PE1mkBsVEUzXG5sWb9AQOsg/klgqZ uwwAROZbkWu7ST5m4pn3k/RqMbUsFf9duBctSB581kIqQGKy6rYTBoK314ck1f9YNT5iX3HpyX3 kzQ8cTI4Bms3x/JsEIn5EGHA6UsSlM+1qhUh4ZT/0If0hGkqtog63VoNq67yFQqHkohcGKxYiZ1 C2XspnnRB5bbymgjdv5gOG+3n5s31sYhHWAN9UqMeauMyWtf9afnhFE7taZ/xVGXgTSSdHFRSe2 /aG8PoV1yWbukTWWyu0Dw8g5r5rCKZ5MjProLy/QjqgNWxUP3LwYGDLiaMYbqmkAvDCiXVWb7xD kyp6UhYn5QuOTBrdsqcZsKDUFZNgoOXf7zG7GIR4NFG1TAZUpKLG89xvGo1f/u+yDz7tyrUmybG HCytjk2tb6u96NWzDoCeuQaFiJRg7+PEILoWPnaL+WwmpEel1rdJBO+LY8w== 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: linux-block@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