From nobody Sat Sep 26 22:55:47 2026 Received: from mx0a-00364e01.pphosted.com (mx0a-00364e01.pphosted.com [148.163.135.74]) (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 8E8B646C85B for ; Fri, 28 Aug 2026 13:50:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925023; cv=none; b=ay7xqJH8Jdc4tPnE1sLhW1Y9eBN5VnyfPul3j5gTMVbxory6sAv00pkx74Y/uu4sOF+HmWxE6EmnjMr1jLXQG3gzHF+Rn/xnVwv6v76dHQpBwlvVCOSPUFZmIQkJZ3Qru/NOSShIR+LdNQO3X1VWXkkXe5rjJmokyWEj4i/GkCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925023; c=relaxed/simple; bh=cvjM2bWwCeJz7HnW+o4BiE6Cy5HEK+ZgZMvk4q0+/sI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PDE/+0D3K1cwHM+qWzWpHBWdMAR8pHUztiYUsn/ftZGCjYrUQZ334g1FAGEDWNTOygo/oUx61Btr27F7ORwgwy9gWjzxpR2OTsL/DJ9IdfaUS+T21bxLgidgCOhDQz0blt2BrQ/YjBdWuPwcaFClcDwUdAyG/mEuBfFLTfB3S4w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu; spf=pass smtp.mailfrom=columbia.edu; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=M3kgtPwo; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=ASg5Kab5; arc=none smtp.client-ip=148.163.135.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=columbia.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="M3kgtPwo"; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="ASg5Kab5" Received: from pps.filterd (m0167070.ppops.net [127.0.0.1]) by mx0a-00364e01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67SCY80t1703507 for ; Fri, 28 Aug 2026 09:50:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pps01; bh=3vNQ +LNoQmUCg3VgcL1mBrxpYQC65W9r0CI37CzqFVA=; b=M3kgtPwoQ93zAYhvaleR kUktSiCzGBXI7k2zR3+L5GiCRipIlReUOtTWyTC63BK8gtPbmAQvgW2Zps0ogDiO Mmd5rKNSgXGbRotTd8+cgVc81s2NvM2UPBthobsO9+TSlRGh87qIbRACzxA0oTjo kpFWGzjH9DXjdsfQBDBNfxoJlKk5fwfUBz8tsMOaC1IDBTfZawsZ5c0Uw5k4U6cL +LGnVK1fHarbLAvAxY/uQaWZMgLJ+Wocw4dN1COAE/W/gokSTozRsIFq+YcFeVC7 SIEueuBe5FmtyslfRSDMCji7vjpkqYgKTwMKfoJQrSLBCyeoqWVV6Zxdfp6pI/ty oA== Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by mx0a-00364e01.pphosted.com (PPS) with ESMTPS id 4gatc1d4k2-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 28 Aug 2026 09:50:14 -0400 (EDT) Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-90a91f4c6f1so9281096d6.3 for ; Fri, 28 Aug 2026 06:50:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; s=lionmail; t=1787925014; x=1788529814; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3vNQ+LNoQmUCg3VgcL1mBrxpYQC65W9r0CI37CzqFVA=; b=ASg5Kab5z0k7T5P2L1qRUg+PH3VzcHRpml40bZAjImqXnhLAj/Sw+Rw3J9S16XamRJ mW1Tpe3jTL2njXBJ8mzt6PlclR+t0CpUYa4XbQTSd61SIGam4AHV9ykmMJZXS5k/jQ5M fyqJWCiXwJoKeaD+V/KC6hQ6OnYEyIl9GDi0yCu6+ZLtFzN2/ykIZb4ymijJP/LvhU/X QdMN9NCxGrXgTqGbRXeaaWQYQ4gYG5kILtw3bTXbJP9gfHdHndjg+jekK7qCHFpHgtku /Pzh1WjHYmmOi9by3JiwZthXeUYzmTx5NaCGMFuVNB0/0CIsyFZSKSekICvHptyiZ/uh 0jjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787925014; x=1788529814; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=3vNQ+LNoQmUCg3VgcL1mBrxpYQC65W9r0CI37CzqFVA=; b=rtEzijAtjmBsactOdVhHA/ePBXiSk7AR3VFHZYRxNpIYlfXjlgLr2sncswlQIJ7n6F K83kf6ll30iipA/XmH82n5kOLLjllARrOP2MYVonhLiA/217luDm8CSTKB62slq4MQok J3c7An02hqpwI/N1exwOpFJBDIsT+Fo6tD7mV4pU8vNv/o0ILDi38INlFxgB/NEQKDZN PaquKdU0qLYiCQfT8Jfwd1lRG8dCFZZtWaVO6mVO8Z4T74l1EQTN5pEH2aQpFG/901JA FkK5OAUFE6Vl2aGrDgrWMIpqmmEwPEhlObW9+m6LhArbZ6hEcW3op5jfFnWTdJ5WZNdY EC8Q== X-Forwarded-Encrypted: i=1; AHgh+RqkNk3cawa/HHHUN+KR6yBrTwedY3UBNWrC4H8y+w+BiO3SOkOF66whX7stURgtMZgxRXCokW9qwYyggJs=@vger.kernel.org X-Gm-Message-State: AFuF++mkmH9y3tXcOsn7f+JTtsR/M9LiLOKBs9iTAUEJxFGTo5UiOL4E pKFpWfXJGF8t5MjVvNp7NYuj9tzmmgp3WT+SueArm5MYbYFE/2kEo4xDpCDM0OcH7nzYEKa71DA //QeOcJ0TfSEZ953VbjAJhc5WNs9gC7xu08Wny6MhdA4dZfstJpxFQszPXlwM7vR09q2a0v4ayn g= X-Gm-Gg: AR+sD102XQlx+zsuUk8sdoRHu1VIKlobhcPBgERaZsKT+wm/VKl4qN4nCYhs3fMYSAJ 6ZuDD0g/J2URphfmsC+c77TP7rgDH9vSBieIYQfc3gL1QcwrahnhfcLk27oqN+gDL866yGuhVAk VUBYJeejE7rIBNuoFJv1MF70XgsY6OogfLqDgvP6g1mVNTTSc19t/qb3Lb7Xc/4Ly1u97vcG+XM MvBbHbZroI0m4emBx7z09nV4MKt6qg+dv8IGSZFegkRXlhn5HYYGDZAQt5UzyLIUhdj7iv1oIL8 F0Apo5IeDU8HqxAi3w91SzgrxYIk1qVrOvPT+/ZlW104nM2Xk2U+/bDQ3kKSi+idmsHx7bfUkln 2wor8+Ych X-Received: by 2002:a05:6214:2aa8:b0:90c:de81:6e76 with SMTP id 6a1803df08f44-90ce0bdea13mr82677216d6.6.1787925013350; Fri, 28 Aug 2026 06:50:13 -0700 (PDT) X-Received: by 2002:a05:6214:2aa8:b0:90c:de81:6e76 with SMTP id 6a1803df08f44-90ce0bdea13mr82676576d6.6.1787925012771; Fri, 28 Aug 2026 06:50:12 -0700 (PDT) Received: from [127.0.1.1] ([45.130.83.151]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-90ce4534ebesm15645116d6.48.2026.08.28.06.50.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 06:50:12 -0700 (PDT) From: Tal Zussman Date: Fri, 28 Aug 2026 09:49:50 -0400 Subject: [PATCH v2 1/7] block: use iomap_dirty_folio for block devices 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260828-blkdev-fixes-v2-1-32f3f40cebed@columbia.edu> References: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> In-Reply-To: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> To: Jens Axboe , Christoph Hellwig , Johannes Thumshirn , Luis Chamberlain , Hannes Reinecke , "Matthew Wilcox (Oracle)" , John Garry , Christian Brauner , "Darrick J. Wong" , Keith Busch , "Martin K. Petersen" Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Sashiko , Tal Zussman X-Mailer: b4 0.14.3-dev-d7477 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787925005; l=2080; i=tz2294@columbia.edu; s=20250528; h=from:subject:message-id; bh=cvjM2bWwCeJz7HnW+o4BiE6Cy5HEK+ZgZMvk4q0+/sI=; b=i8zsqlqEzBYmHrJwB1M3D8XEh+23kDrso9VTCckZEfshQvH5f8/F9Pzew2miCa10YzGSqCg9j uvM9QwyZrWOD0K8kb2ZlIvPguvMz82e7tPysKEcIuBpfgJvx5VF2Z/e X-Developer-Key: i=tz2294@columbia.edu; a=ed25519; pk=BIj5KdACscEOyAC0oIkeZqLB3L94fzBnDccEooxeM5Y= X-Authority-Analysis: v=2.4 cv=JKYLdcKb c=1 sm=1 tr=0 ts=6a919216 cx=c_pps a=UgVkIMxJMSkC9lv97toC5g==:117 a=xDWFIMX55ayQNp92vt0S/Q==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=x7bEGLp0ZPQA:10 a=A0y_DWxS2BwA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Da8U98TiO7q1upZEImrf:22 a=svvvyxlR1OQQkelhaPoB:22 a=NEAV23lmAAAA:8 a=c92rfblmAAAA:8 a=VwQbUJbxAAAA:8 a=lHyHCDWJ2e6pF_oXpYUA:9 a=QEXdDO2ut3YA:10 a=1HOtulTD9v-eNWfpl4qZ:22 a=GvGzcOZaWPEFPQC_NcjD:22 X-Proofpoint-ORIG-GUID: MS_VR6QA41kfpuGgi6jer5lgebjehVmX X-Proofpoint-Spam-Info: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfX2oq5F3AK14rO gD7csNSqW6PXen9CzZXXJ2gC5dMrInclKpikR7e7OGwnrO9Exs36ZgwSu8jToezDBaYfq+npOLv l3DxVHEbDtjmU3D8B68M03JVzjMb98cxo5agkSEer4y5RktMtwdd X-Proofpoint-GUID: MS_VR6QA41kfpuGgi6jer5lgebjehVmX X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfX6Tk4vPo+nS9Z SGFLX7HbvBQbF+EEtKhIHLzmoXE5lX4BMwEIAuqUC8fY3zXGiE+6cENUJ1x0ouBybaxM0ViKxwO uNZHGnWED36Cw4aSIsCnJx/0D3hUWGIX4ggS/pVjtG3Bd9K6R6wxAILpkNEkDaLEG6fwCLhi0Sm ZJKvTs6dzWkaTXoa0RkDoaantcL2oUp8Z7JdGxQYG1CTaoJBPzAA8PoP4A6p4gaG2uVbk4kSIcz EnY1qacGs6EczchKKjdy7qBTBcIBfhey8YpBkJI32jCRPdn/QZ+op4Fs2tSph9AZFlLi7i4ZMT7 qdOTpueV49FI3cjSouYoHSGbWKQRoBjfZQTP0oS9ohZPuZMPrbcHoXMVEExa4kIbfBm9SkYg0ft cG85i6bjrlcQzzHKlkc9mrqs0AaRWuCkc8E0TbWuA/mcxvYXduawXRoVvKRT4Qjn4jQ1vVP5LLJ weq+8r4xE/IH90Ewbnw== X-Proofpoint-Virus-Version: vendor=nai engine=6900 definitions=11888 signatures=596817 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 spamscore=0 bulkscore=10 adultscore=0 impostorscore=10 lowpriorityscore=10 priorityscore=1501 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608280119 With CONFIG_BUFFER_HEAD=3Dn, block devices are written back through iomap, but def_blk_aops uses filemap_dirty_folio, which only sets PG_dirty. It does not set the per-block dirty bits in the folio's iomap_folio_state, so iomap_writeback_folio() finds no dirty range, submits no I/O and clears PG_dirty, resulting in data loss. Other iomap users set .dirty_folio to iomap_dirty_folio, which marks the folio's blocks dirty before calling filemap_dirty_folio(). This is only observable with block size < folio size. With a single block there is no iomap_folio_state to get out of sync and iomap_writeback_folio() marks the whole folio dirty itself. For a page-aligned device, this may require using the BLKBSZSET ioctl to set the block size, which requires CAP_SYS_ADMIN. A device whose size is not page aligned already gets a sub-page block size from set_init_blocksize(), so no ioctl and no privilege is needed. To reproduce, on a device with a sub-page block size, write a known pattern with O_DIRECT, mmap the same range, store to it, msync() and fsync(), then read it back with O_DIRECT. A reproducer is available at [1]. [1] https://gist.github.com/tzussman/18ab05cba4b3fdc79cce0a69d1fd05b4 Fixes: 925c86a19bac ("fs: add CONFIG_BUFFER_HEAD") Reported-by: Sashiko Link: https://sashiko.dev/#/patchset/20260730-blk-dontcache-v7-0-3e8e685006= 8d%40columbia.edu?part=3D5 Reviewed-by: Christoph Hellwig Signed-off-by: Tal Zussman Reviewed-by: Hannes Reinecke --- block/fops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/fops.c b/block/fops.c index 2ce7c6c4714e..c57784773fe1 100644 --- a/block/fops.c +++ b/block/fops.c @@ -560,7 +560,7 @@ static int blkdev_writepages(struct address_space *mapp= ing, } =20 const struct address_space_operations def_blk_aops =3D { - .dirty_folio =3D filemap_dirty_folio, + .dirty_folio =3D iomap_dirty_folio, .release_folio =3D iomap_release_folio, .invalidate_folio =3D iomap_invalidate_folio, .read_folio =3D blkdev_read_folio, --=20 2.39.5 From nobody Sat Sep 26 22:55:47 2026 Received: from mx0a-00364e01.pphosted.com (mx0a-00364e01.pphosted.com [148.163.135.74]) (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 EB6DB46C825 for ; Fri, 28 Aug 2026 13:50:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925022; cv=none; b=TjEXNk3FBz94QQuZoV/oVeKCfK45xxvp5HNYlN78PyQsU3MJcfE97isPACA35RSVGL4XcvFG/Cdg733ZM9mhvAAJqBJukkphUAOd87k6C3EbS+eIqNRTe3gdrqcVTpxHUVYdHWvdD4v7rxKmsPAPUNsQDuBZyaTiHzITq4KDEkQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925022; c=relaxed/simple; bh=lztChwPH+1ASZjAYgppa5ZtHfkdeAZyT/dwRUUUH+CA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RDapLY2a6qmaTcov98Ks2EGC2K54T+KAZJ1iszDhqSoztojzn8Gw5rrzc63ZDNUdVKEd3Pb27cji0iWiukqTdYUFb1alQLSOG55AsDPyQUVdPwBIIbuRG2NWLunXNPCYoIQvQFblHkZiJo86xYfWzjGUwe9X1khOL0TP8ID1HdY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu; spf=pass smtp.mailfrom=columbia.edu; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=CxbpKt0C; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=J1P6XMDP; arc=none smtp.client-ip=148.163.135.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=columbia.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="CxbpKt0C"; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="J1P6XMDP" Received: from pps.filterd (m0167071.ppops.net [127.0.0.1]) by mx0a-00364e01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67SCY62x3231909 for ; Fri, 28 Aug 2026 09:50:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pps01; bh=mWgk pzSag0jbNM57A5E7I+GWepk+yurbjd4WqPTkFrg=; b=CxbpKt0CBGPLv8Qhth8c Tp39sID6F2XgwhRPuoazV3jrI6lBtv8rMRWrGxDDpJCT6+MRGKiwYafKDuvvHVXi PBD2DifF5bd2xrlrIDH63AiS/Vci450USPcXOsEmUqic8bPUrCOJ3frx7OVlTtG5 kV0UZ4WiYfkfRYPFKVCFII50NCm1SIGJRMenHOcajX/ki28qcR1xuaZ95x6Ndf8u uVa+p4lqS2V2s+aZbtnQiW/HovhdsJfJ8CP7idUXZA6Od9zw3TgzrqPqax7/HdML Tf7ibN/YnvGdX0deFtAYnRB0Jq9vLRgvMpa8kCdDx//wSz1yLMdF0iUW0LaJarVU 0A== Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by mx0a-00364e01.pphosted.com (PPS) with ESMTPS id 4gaufkvgcc-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 28 Aug 2026 09:50:20 -0400 (EDT) Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-8f1e4e0eac1so6288826d6.1 for ; Fri, 28 Aug 2026 06:50:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; s=lionmail; t=1787925019; x=1788529819; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=mWgkpzSag0jbNM57A5E7I+GWepk+yurbjd4WqPTkFrg=; b=J1P6XMDP6Fw5jTlMA2d5Xf6Xj4nop7nQVMl8lGFFzhWvODAzw3CYG+WJfdvuAIdNGZ eAQsea9/XO/A+sv6AIVYZnKscQMr8ped0NITyhV6ZiLlIeHVL4l7RvTnSqnVm+qZTJNy Yp+l2MwBvjlggMP1wzrINVXJEBdAdFzOoSf37I+swgh4EZv6GGM7Fs4Uhegqi8FhiB3M Sm3Xpnlo28zZ1OlsL4s76/JFYZUSQ654HcFC/dmSoNFPoIi0eZSxjSSbe80xc3l8Ifaj nw9rVm4VrvPJZXybTR4nEmc8bha666emgsv6dkhsk4yiPej4egF/P9NZAX+7p5opl/FD 2Nkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787925019; x=1788529819; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=mWgkpzSag0jbNM57A5E7I+GWepk+yurbjd4WqPTkFrg=; b=qD67g2WwuLN3KtMsCywQnZj/9ntomdLnhXjf6JRIvWmm44dZ3lBteB9zgTGwWWy/lz G3CJfD3+2rQvqaZodnwakn9SjivAE2rQwSqVoEtfMT+tY9rN2XaKKccxdFm0HYat6GJi 2EZzXiGGb1fj8SG6cJvr4rp2FS58DBFZsLu9OPSjduM8NNnLtGcu5WfHEdMg4Y7CCLcm o54jI9AAy4g8qGhVYp/ujJdnwjYuzvKkzQvIg9uDGdo9nEDIG92oW5lyxCM/yfHAQaKb oITZX7EZ06NRYiSTDAVSe9aZ8TOdqmLkvhQT/1o1U4x9GCjntrFG9a2wUslk7w+uaz1o XzyQ== X-Forwarded-Encrypted: i=1; AHgh+RokGZqKVfyyzPWi0+UmWsEiCOSRRWm/pghcPPYCMqzl+4l9dxk48miFGDDCaFHH+1iiKkyDACcqhULRY2c=@vger.kernel.org X-Gm-Message-State: AFuF++kY1oEBcg1JI0pp1RpDj6hjagrFjbfxNfKH4UCY8bSFcI8kAgrC LFvBBDqaW5Gxkrt8lAHAR1UYuObjcc1biNurjYQwBJM+gscXT/O1DsNiIA/ppQmKhMA+dBtxokK 0rHq9r7XOHWL/pkZPTIJZRTlPKdgYnsLRS4OgwHVICX6PB1hwLdHL2d2KQLfTzQ== X-Gm-Gg: AR+sD13xnCMrCbDy5b2wIfseoVD9d9UXPC1JTTVcLWYv2JEngFr0e2lU2VN5hh3IczR Vf+LLEXEEKCkG8Vh8rPJA7HlmDeSYhCyAX3xB3vqdBGY++cWMUGHydry7gGLmTUfCXw4x8JaCfG pqxRfr+uVo4mUOuhFgvL5qToybrryOuw4TR7INRGQySvAY49V+y3hxWGplhGE1wECMUc5xYwtqJ Jn7MzKYphsDtrElKES+zPzuVh5JaTRVqZWhb4gvLm5ywOKcIfdndVdfAFj/MLMkvMYnGXEOPW/j F4zXungNJ6EP4P22Jy/K+lZwqpkYFk4o0fycW3EMi6eTNtPGf5m7ivyUxjbQz4tvKnE+H9rt6ty kNI0/BBBH X-Received: by 2002:a05:6214:5a06:b0:90c:5947:7e64 with SMTP id 6a1803df08f44-90ce0bf74f1mr109799996d6.3.1787925018884; Fri, 28 Aug 2026 06:50:18 -0700 (PDT) X-Received: by 2002:a05:6214:5a06:b0:90c:5947:7e64 with SMTP id 6a1803df08f44-90ce0bf74f1mr109798766d6.3.1787925018305; Fri, 28 Aug 2026 06:50:18 -0700 (PDT) Received: from [127.0.1.1] ([45.130.83.151]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-90ce4534ebesm15645116d6.48.2026.08.28.06.50.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 06:50:17 -0700 (PDT) From: Tal Zussman Date: Fri, 28 Aug 2026 09:49:51 -0400 Subject: [PATCH v2 2/7] block: take i_rwsem for the direct I/O write fallback 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260828-blkdev-fixes-v2-2-32f3f40cebed@columbia.edu> References: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> In-Reply-To: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> To: Jens Axboe , Christoph Hellwig , Johannes Thumshirn , Luis Chamberlain , Hannes Reinecke , "Matthew Wilcox (Oracle)" , John Garry , Christian Brauner , "Darrick J. Wong" , Keith Busch , "Martin K. Petersen" Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Sashiko , Tal Zussman X-Mailer: b4 0.14.3-dev-d7477 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787925005; l=4610; i=tz2294@columbia.edu; s=20250528; h=from:subject:message-id; bh=lztChwPH+1ASZjAYgppa5ZtHfkdeAZyT/dwRUUUH+CA=; b=L1XVFubg3p6Sql6VAoc7sXpVFgPRPKovliasY3MQR+iWjp8SbRO697dnbZTB5gvYrUzhCuJ/Z 6qBsLZCcKZDCZpMRpq2kKzRICvyP03CM/5ml/onLLIaR1THBPoW6YVW X-Developer-Key: i=tz2294@columbia.edu; a=ed25519; pk=BIj5KdACscEOyAC0oIkeZqLB3L94fzBnDccEooxeM5Y= X-Authority-Analysis: v=2.4 cv=daOwG3Xe c=1 sm=1 tr=0 ts=6a91921c cx=c_pps a=oc9J++0uMp73DTRD5QyR2A==:117 a=xDWFIMX55ayQNp92vt0S/Q==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=x7bEGLp0ZPQA:10 a=A0y_DWxS2BwA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Da8U98TiO7q1upZEImrf:22 a=79PYxaXUQd1wl-QFWJnA:22 a=NEAV23lmAAAA:8 a=c92rfblmAAAA:8 a=VwQbUJbxAAAA:8 a=HaKTZzbUtGO3MgJEFeMA:9 a=QEXdDO2ut3YA:10 a=iYH6xdkBrDN1Jqds4HTS:22 a=GvGzcOZaWPEFPQC_NcjD:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfXwEQ0caT/z2gi oLOklqBaj6LOZMhuPiRDfrU+PRK7uVRfAiGUOptCbKw1rv4i5W7YAHr0rY4h+mzukIKKR4G1SlX x7ipS2iPwQM6p6/O9Rib4WKKyQjyR1uBtTNpkdzwP/tF+PNU9xlMYstasiT2gaRhYZsNporgU+l m8X+Ppsca7WiDgIMJIBhoOrllQOuf3hswykW8zOZ6AqGyKPk0DKgqvChcDtcKEcKnN1dXlvwyfT A3YfRI+Kuo4LgcAj+v6stsJAFOG/RDh/hS0lF2mMYV7h0JuxI0mp+x/lNKKTQisw+GBsGNk8Jfa F7Yay4alB+y+HcXqoTXBworT3Dj2ouQ8fzN39ZzJ3i4p4JaQbY+VGt7UnFz5W5mrqwyJenHrXKy 12gC7/BzlHg7tG2bVnxebhhIzbtO2v0B1bZfFlykcFLbfHfMJb85+9b9fcA5DrZdEXQDc3uN1rF WcwDkwRAsXqXnNrjTmw== X-Proofpoint-ORIG-GUID: fpnsPOdy2UGtNhMwtyl3wJC8VpMwFWBX X-Proofpoint-GUID: fpnsPOdy2UGtNhMwtyl3wJC8VpMwFWBX X-Proofpoint-Spam-Info: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfX5bVE0X/o5wp8 udNomt5S3QG1KkBI2XONHiJ7892mM1dxg92ZLYLJFKqnD7epsB8jsbuX/vQFGnPeptJOFIXRFvw PXT5flanD+YSsdj/7cSuewSS6LxlPzxJSqEfRjjxhBrg1m0IWGmo X-Proofpoint-Virus-Version: vendor=nai engine=6900 definitions=11888 signatures=596817 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=10 lowpriorityscore=10 impostorscore=10 spamscore=0 clxscore=1015 priorityscore=1501 adultscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608280119 Commit c0e473a0d226 ("block: fix race between set_blocksize and read paths") closed a race between set_blocksize() and block device I/O: with large sector size support, set_blocksize() can change i_blkbits and the mapping's minimum folio order while a concurrent reader still holds a folio of the old, smaller order, leading to crashes. In particular, it made blkdev_write_iter() wrap buffered writes in inode_lock_shared(). However, the direct I/O fallback path was missed in that conversion. blkdev_write_iter() passes blkdev_buffered_write() as an argument to direct_write_fallback() with no lock held. A direct write that completes only partially then finishes as a buffered write with no protection. This can cause a BUG by racing partial direct writes against ioctl(BLKBSZSET). Writer threads issue O_DIRECT pwritev() with a two-segment iovec whose second segment is an unreadable PROT_NONE mapping. The direct path then writes the first segment, fails to pin the second, and returns short, entering the fallback. A second thread keeps toggling the second segment's protection so that some fallbacks get past fault_in_iov_iter_readable() and reach the page cache, a third thread populates the page cache with folios of the current block size via pread() and readahead(), and a fourth thread toggles the block size between 512 bytes and 64K with BLKBSZSET. The minimum folio order only moves with block sizes above PAGE_SIZE, i.e. with CONFIG_TRANSPARENT_HUGEPAGE raising BLK_MAX_BLOCK_SIZE to 64K. On a CONFIG_DEBUG_VM kernel this yields the following BUG: page dumped because: VM_BUG_ON_FOLIO(folio_order(folio) < mapping_min_fol= io_order(mapping)) kernel BUG at mm/filemap.c:858! Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI RIP: 0010:__filemap_add_folio+0x860/0x8d0 Call Trace: filemap_add_folio+0xc9/0x1f0 __filemap_get_folio_mpol+0x240/0x660 iomap_write_begin+0xa87/0xd70 iomap_file_buffered_write+0x304/0x6a0 blkdev_write_iter+0x255/0x510 do_iter_readv_writev+0x23d/0x3c0 vfs_writev+0x211/0x7d0 do_pwritev+0x121/0x190 do_syscall_64+0x121/0x630 entry_SYSCALL_64_after_hwframe+0x77/0x7f The same workload also trips WARN_ON_ONCE(pos >=3D folio_pos(folio) + fsize) in iomap_trim_folio_range(). Fix this by calling blkdev_buffered_write() in the fallback path under inode_lock_shared(), matching the plain buffered-write branch. With the fix the same workload runs clean. A short IOCB_NOWAIT direct write reaches the same fallback. Taking i_rwsem there can now block behind set_blocksize(), and the fallback already blocks on writeback of the data it copied in direct_write_fallback(). blkdev_write_iter() already rejects a purely buffered IOCB_NOWAIT write with -EOPNOTSUPP, so do not enter the fallback for IOCB_NOWAIT at all: return the bytes the direct path already wrote, or -EAGAIN if none, and let the caller retry. The reproducer used was written by an LLM, and is available at [1]. [1] https://gist.github.com/tzussman/69d06bc57d42a42989eb038b1b5aeb74 Fixes: 3c20917120ce ("block/bdev: enable large folio support for large logi= cal block sizes") Reported-by: Sashiko Link: https://sashiko.dev/#/patchset/20260730-blk-dontcache-v7-0-3e8e685006= 8d%40columbia.edu?part=3D5 Assisted-by: Claude:claude-fable-5 Signed-off-by: Tal Zussman Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/fops.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/block/fops.c b/block/fops.c index c57784773fe1..d5f569333f46 100644 --- a/block/fops.c +++ b/block/fops.c @@ -765,9 +765,26 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, s= truct iov_iter *from) =20 if (iocb->ki_flags & IOCB_DIRECT) { ret =3D blkdev_direct_write(iocb, from); - if (ret >=3D 0 && iov_iter_count(from)) - ret =3D direct_write_fallback(iocb, from, ret, - blkdev_buffered_write(iocb, from)); + if (ret >=3D 0 && iov_iter_count(from)) { + if (iocb->ki_flags & IOCB_NOWAIT) { + /* + * The buffered fallback blocks on i_rwsem and + * on writeback of the data it copied: return + * the short direct write instead and let the + * caller retry. + */ + if (!ret) + ret =3D -EAGAIN; + } else { + ssize_t ret2; + + inode_lock_shared(bd_inode); + ret2 =3D blkdev_buffered_write(iocb, from); + inode_unlock_shared(bd_inode); + ret =3D direct_write_fallback(iocb, from, ret, + ret2); + } + } } else { /* * Take i_rwsem and invalidate_lock to avoid racing with --=20 2.39.5 From nobody Sat Sep 26 22:55:47 2026 Received: from mx0a-00364e01.pphosted.com (mx0a-00364e01.pphosted.com [148.163.135.74]) (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 6C19A46D550 for ; Fri, 28 Aug 2026 13:50:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925027; cv=none; b=dwUIMGB39aA4oum24bcw4zKqTocSqKiRrDgFNJEeiljadQd1NcauKKJXY1HCUjAwpmRvYnCHWDyusIutVyuOnxOS1SgXFDDvNRzYWfsZjem9obPT87YBFu5FTBrGRiih55wiOJQ39LqVB7XJWeq6RdF2oDu+4FvrKaQ2lPGEIzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925027; c=relaxed/simple; bh=nGU4ZTBzn3aF/jEzn6TEW4RsPtGSLYpYxrHIRAT6WO4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ICD22yrrfVBcVp8TEI120i/iNkVgDq/0IoNEjv1LehAD3plLWTmDY0Jy+ws3lDWLU3kvvL4Tn7KzP0tTiCcO4WTcyd73597ULxmK9f8AyyKRmkr5Chv4PY8nX+xglBbMWXsb+JrbVtd86j1z917vlI/besNFMlGa+n8xwPb0Anw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu; spf=pass smtp.mailfrom=columbia.edu; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=TC65GV9a; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=bGY/GjW/; arc=none smtp.client-ip=148.163.135.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=columbia.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="TC65GV9a"; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="bGY/GjW/" Received: from pps.filterd (m0167071.ppops.net [127.0.0.1]) by mx0a-00364e01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67SCYC0m3231995 for ; Fri, 28 Aug 2026 09:50:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pps01; bh=PmAd iHxzSpepwE7sbIhm/WAFwGYto5pQ5mrP6+6odVs=; b=TC65GV9amv0ybweYpxjY csgQTIoXkTZnpuqh4eT0cub/2HuHY1pO4Jl+kjN4F3PDrkM+omsW3NGTB1DZWfro z4/glTqx8M2mLSQnaMOcRm4uCwn+IARNq9yZRUBfBa3irNoB2XSezklKFGFsItGc irOr/IRuamOhpwp1Id1hgwEjVypAPPEvy3UD/2UTdSlhgH6fnLhuX8kw4zHj3DPO g/mAqJPnYUVEo7T5UOvls/oZLDFqvitMsZjJrvsO4qHgZwidtsE7GPhy69QuxowW PD7x/KkJc0oFzMXMyU2OWKADs1GlK3C3/e+fILkIYgC1+Sv/Cml8m1+hEgDZN7dJ zQ== Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by mx0a-00364e01.pphosted.com (PPS) with ESMTPS id 4gaufkvgct-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 28 Aug 2026 09:50:24 -0400 (EDT) Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-90cc2b97f8fso18986746d6.0 for ; Fri, 28 Aug 2026 06:50:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; s=lionmail; t=1787925023; x=1788529823; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PmAdiHxzSpepwE7sbIhm/WAFwGYto5pQ5mrP6+6odVs=; b=bGY/GjW/sM7i42PpEM6mDY0AsVUrm8w1GBzQdOY9CNF7P4nTCL52n0zknMcSp9XJ5s Ungt1Kh93I1QnyJoPk7hPoSr9tJxyEIbh2zR8OxkH4N5vFQmyFbeOtQcMhBYebb1Djc4 V+MP0cRBLKJRCe2xhs1CIe0z7Xa+OJApIRzeo+EXwfm5moezAIBXV7Esn/v96gkZWUPI OSz3AlvdlCr1Uibugy/udo2vQn7Jag7wda0AsZX9uCDEVj+SWfOru0yEsXTyeAoVKAvr pXUTFAiSxI5B+3wq+l9vCM2sYqeVExurK828KinHDrMjMH99EPbgaKUdWkd23i8Bs3DK UpDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787925023; x=1788529823; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=PmAdiHxzSpepwE7sbIhm/WAFwGYto5pQ5mrP6+6odVs=; b=FPfdtaW5JodzdyQGN7apiQ9KfInh4rQc9T+z/h6mMIhOgJgMZOCpnrQLqCNWDgHyqz n8+B4iGONzGXAdAMtDSe/op8gffQnD/lSHDS6RyE69giQUfTro/TSwIr4tJ9Okj7nVWX Y0Q9fcQn8E8fepvXK+6nic9CAFlrO3ndzunwz0HImq1Dz6C3DNGIvtzLZFRbvjFGzMiv nnNpH7xTlV4/UOR0EzJ52lAcgoobwiohfKwVO/1TWzAinVKeMPiaaYmSlHD+JaDaAA+R l6EYiN8yCHmagea9hF/T/ZMNUTfdUb7tU/AeMGDBico3n/wBhFgu0rMXcUPHWaNR6boL 49Tw== X-Forwarded-Encrypted: i=1; AHgh+RpClZRuvO35hK09PlmDdrPGuws8W9wS7Jal6wUnR/gzN51GAY6Ii6MvxdDp9EyusMgUwJ57zYSheTtEKdg=@vger.kernel.org X-Gm-Message-State: AFuF++lxHq/QR87ZknjYb7ASKSQzKhlUcxS8awVJRSQAflRYW7dgJJ2L INuup63VJ1ylaw935dU5B6qFP4xsCwQd+y6zP6uxLH/POZwn/pdNfOI3xHZnskJVlH1q8ObzPAz F1YospFiwYC5oCMd7xuI9hAtYI0I8+B66wq2V/XIkBqzMqVmH0CoRChutO/1ghA== X-Gm-Gg: AR+sD11KZ8w6moOUH4/iscnPeiHoz3hnoyNOyyGoYfMCp5m6jSmWcRyhd+68FLkFPPh wcbs1+oZgv+S4bGYfnlvDHaqMGcSQQ1Xmr3DaedSc0zuuS9xRl4j9l7gepmRp6wvvhKolEZzt8F TH2B5+tm5SIayT3gS+01znzabDueuWeHvzxPcyNfSY64zKuLoZq1y5QcNvBEZTGuUS4b0rvl1cB r2UXtkg8CXEy7ZGGSa2qW5Q9Rgi6lq992dybuUI39ltZTlFtaHgj8trXHy+muHpCKB2VYAnjZ8k JBS8VXwVW3DT+3owOv9TUxqJEAxChTzmTn9gpp33IENdwEnnUkuwyJWM4W/M9FXpUp6x8oVuBhz HZ0Riq1eZ X-Received: by 2002:a05:6214:ac9:b0:8e0:7d6a:480d with SMTP id 6a1803df08f44-90ce0ef6619mr87721636d6.20.1787925023180; Fri, 28 Aug 2026 06:50:23 -0700 (PDT) X-Received: by 2002:a05:6214:ac9:b0:8e0:7d6a:480d with SMTP id 6a1803df08f44-90ce0ef6619mr87720466d6.20.1787925022388; Fri, 28 Aug 2026 06:50:22 -0700 (PDT) Received: from [127.0.1.1] ([45.130.83.151]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-90ce4534ebesm15645116d6.48.2026.08.28.06.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 06:50:21 -0700 (PDT) From: Tal Zussman Date: Fri, 28 Aug 2026 09:49:52 -0400 Subject: [PATCH v2 3/7] block: take i_rwsem for the splice read path 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260828-blkdev-fixes-v2-3-32f3f40cebed@columbia.edu> References: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> In-Reply-To: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> To: Jens Axboe , Christoph Hellwig , Johannes Thumshirn , Luis Chamberlain , Hannes Reinecke , "Matthew Wilcox (Oracle)" , John Garry , Christian Brauner , "Darrick J. Wong" , Keith Busch , "Martin K. Petersen" Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Tal Zussman X-Mailer: b4 0.14.3-dev-d7477 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787925005; l=2730; i=tz2294@columbia.edu; s=20250528; h=from:subject:message-id; bh=nGU4ZTBzn3aF/jEzn6TEW4RsPtGSLYpYxrHIRAT6WO4=; b=/8snr6j3GY8v39lMzgXuQ/x7S18viJt+QLVqsA+fl4DCUganenyyqqCmmqwEjPNMi2Rk+EqXQ ESt8PK45Y6BA2Zv81gfq9v91cHD9J2xm3At2MJuNXIkxnwhdtd/8yAE X-Developer-Key: i=tz2294@columbia.edu; a=ed25519; pk=BIj5KdACscEOyAC0oIkeZqLB3L94fzBnDccEooxeM5Y= X-Authority-Analysis: v=2.4 cv=daOwG3Xe c=1 sm=1 tr=0 ts=6a919220 cx=c_pps a=UgVkIMxJMSkC9lv97toC5g==:117 a=xDWFIMX55ayQNp92vt0S/Q==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=x7bEGLp0ZPQA:10 a=A0y_DWxS2BwA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Da8U98TiO7q1upZEImrf:22 a=79PYxaXUQd1wl-QFWJnA:22 a=kXXCQoMOyz17bj_MZH4A:9 a=QEXdDO2ut3YA:10 a=1HOtulTD9v-eNWfpl4qZ:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfX21dsbbBbjRHh ZQbXryBsZqd0ewhKuDsi7BgW9zbttj4In0C44es+qZQUyx/0/rN5A0dfQv29n2JXmTOaH1gGgnP 2dSbi8J5Lq+Lu6aV+M8MCUsbzt6QL6T+KPMbqr5Oe2fY8LLEcdmG6c48GPXRM8u6CzE8fEYrD/u V2DpFfRZm0aS3RA7lY04JMkkjTbsheBP3WgPdcYFqoAfmpCZQdNxuL/zRwppmC4myQ3xYhHnaxK MbO2dHR25PA/VUbSXVcJ/Foe11rpnpWcK502YMbrXwEfbKkZFpPVwMNHRLFu63ZTVz5btbAHkGr vyatNa4jRhIRrbFwCpFUnHwrnRsx/LY2T9WybMznFtHQhUwkKjxynvHQCHZUlwnBWVc5fpMD2UN sq6tthiQFNLWyS98CeTyePWZpvTOQxKXyqe2bfD38Siy27NfjBmOG82xzbx+QpC+OCp5AOlvT29 HuW2wO8TeE12qhSgTTw== X-Proofpoint-ORIG-GUID: zBT7Evu93-ZEzilivr-BrihYqQv5Otn0 X-Proofpoint-GUID: zBT7Evu93-ZEzilivr-BrihYqQv5Otn0 X-Proofpoint-Spam-Info: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfX1kO7p79OoWdW EA+2AIFXILwK6/xW3CE1KrJ80QjURpZ348Gd8BdR0+uPBtttQI75b+h6M28tnLiX+2iYAWkAD3M m43l+wX7xhdgEZzJw4oxQ3WEchaNAghoNEdDlUpmH40oyE0bKmOB X-Proofpoint-Virus-Version: vendor=nai engine=6900 definitions=11888 signatures=596817 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=10 lowpriorityscore=10 impostorscore=10 spamscore=0 clxscore=1015 priorityscore=1501 adultscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608280119 def_blk_fops wires ->splice_read directly to filemap_splice_read(), which allocates folios based on mapping_min_folio_order() without any lock against set_blocksize(). A splice from a block device can race set_blocksize() raising the minimum folio order and insert a folio that is too small for the mapping. blkdev_read_iter() wraps filemap_read() in inode_lock_shared() for this reason, but the splice path was missed. Splicing from a block device while toggling the block size between 512 bytes and 64K with BLKBSZSET hits this within seconds on a CONFIG_DEBUG_VM kernel: page dumped because: VM_BUG_ON_FOLIO(folio_order(folio) < mapping_min_fol= io_order(mapping)) kernel BUG at mm/filemap.c:858! Oops: invalid opcode: 0000 [#1] SMP NOPTI RIP: 0010:__filemap_add_folio+0x51c/0x570 Call Trace: filemap_add_folio+0x64/0x140 page_cache_ra_order+0x1dd/0x3d0 filemap_get_pages+0x153/0x760 filemap_splice_read+0x13f/0x300 splice_file_to_pipe+0xc0/0xd0 do_splice+0x6a8/0x890 __do_splice+0xb0/0x210 __x64_sys_splice+0x80/0x100 do_syscall_64+0x10e/0x520 entry_SYSCALL_64_after_hwframe+0x77/0x7f Take inode_lock_shared() around filemap_splice_read(), like the read path does. Fixes: 3c20917120ce ("block/bdev: enable large folio support for large logi= cal block sizes") Assisted-by: Claude:claude-fable-5 Signed-off-by: Tal Zussman Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/fops.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/block/fops.c b/block/fops.c index d5f569333f46..a51814821100 100644 --- a/block/fops.c +++ b/block/fops.c @@ -855,6 +855,22 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, st= ruct iov_iter *to) return ret; } =20 +/* + * Take i_rwsem to avoid racing with set_blocksize changing i_blkbits/folio + * order and punching out the pagecache. + */ +static ssize_t blkdev_splice_read(struct file *in, loff_t *ppos, + struct pipe_inode_info *pipe, size_t len, unsigned int flags) +{ + struct inode *bd_inode =3D bdev_file_inode(in); + ssize_t ret; + + inode_lock_shared(bd_inode); + ret =3D filemap_splice_read(in, ppos, pipe, len, flags); + inode_unlock_shared(bd_inode); + return ret; +} + #define BLKDEV_FALLOC_FL_SUPPORTED \ (FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE | \ FALLOC_FL_ZERO_RANGE | FALLOC_FL_WRITE_ZEROES) @@ -956,7 +972,7 @@ const struct file_operations def_blk_fops =3D { #ifdef CONFIG_COMPAT .compat_ioctl =3D compat_blkdev_ioctl, #endif - .splice_read =3D filemap_splice_read, + .splice_read =3D blkdev_splice_read, .splice_write =3D iter_file_splice_write, .fallocate =3D blkdev_fallocate, .uring_cmd =3D blkdev_uring_cmd, --=20 2.39.5 From nobody Sat Sep 26 22:55:47 2026 Received: from mx0a-00364e01.pphosted.com (mx0a-00364e01.pphosted.com [148.163.135.74]) (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 26AE946D09F for ; Fri, 28 Aug 2026 13:50:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925030; cv=none; b=dji8CAO+1VAOQS1ijBSImslW+ZtPjE74qzowDjoU7VFVssIA73WLl0T7F4QM2FIG0ZPcXgyCV/KWjuctF8R0eT5JOHiRhlcc+XasHsk3O1bwdHF0CqLr9E6SwGj0b+yRZsu+Hbfd6/qgZT8zlcp9aVdI4FS+EHTrGw8De6aQOpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925030; c=relaxed/simple; bh=dVg+Kna1OS1/t+OMJgLb0pIoDRWpFDUIK/hgTycNT2o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uS2ZixwCbhOMG/gOCVKlO2SaeiMRK46SQmsiMxvetxBkpXcjI0JN21bQHXiyApcpPayAsE0bAl+59DKAdGhFLMy8z6NuxRIE8jlIPmtvUo/mrm7QUrMI1RHmKNjMU4HoC2jTaPic+8ERgP32+dMQOfmT7dWhW6mJuvoRdHXdiJE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu; spf=pass smtp.mailfrom=columbia.edu; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=kEzFvb4I; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=Mfg8Q9xK; arc=none smtp.client-ip=148.163.135.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=columbia.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="kEzFvb4I"; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="Mfg8Q9xK" Received: from pps.filterd (m0167071.ppops.net [127.0.0.1]) by mx0a-00364e01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67SCY2bV3231789 for ; Fri, 28 Aug 2026 09:50:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pps01; bh=YQ2v 5WPLuMyVBiCPn6/ythOOcdRgTs4YGXxw08VQDF0=; b=kEzFvb4Ii/COh0VNXWbg jGFLHoxKadM8kbCQitKcBnzHqsnMYyg2tGuYvZA/JwUEozzytJRFLGbYuBE9cSqO D36bVlbGBD0tIkgbyFSCTDHvtsOmEn9uoiA7DoJLdFD7l764X/sOm39bnqGY2/te cEK8Mso2PvZQm2yfNKji3prn3pkOXoFOmBS7Au8oFI+CCEDh0vlpHtzR/afg6i5j zkPKdtSeP332G5P+pVWxI3AXx3Y2P2OKSjMOgz5puTsAAkGcxluqVpwf/WuSugU8 AkGTrgdsgOJm2GxOtddoWnOYvtDeACjv22baN0HOizFDe6z4REvWKFU4YnzFZ9mQ 4A== Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by mx0a-00364e01.pphosted.com (PPS) with ESMTPS id 4gaufkvgdg-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 28 Aug 2026 09:50:28 -0400 (EDT) Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-90a602a4e6fso25489266d6.1 for ; Fri, 28 Aug 2026 06:50:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; s=lionmail; t=1787925027; x=1788529827; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YQ2v5WPLuMyVBiCPn6/ythOOcdRgTs4YGXxw08VQDF0=; b=Mfg8Q9xKe8cIpccpSISXftGDjO+Sa2X488by+o81ZkWDkR1nhrWXTmbDeAXsWnd1Mv SYfbKx/69iHDYwrKo24RVF+LnDCXE4cOjurTaYWY0Qb3a6QXb1e5a5+OTqMtjUuRoPgq AJTQXX+V17HB+u5/pG3e/9aR25GfOUwXEMjxtd4VJWWjJ5Kd4Q492ZACQ/Y/8r96kSzt XUstf7XMPCw5JpZyDEDyOAPCI8yYhhsLK53qfQ1LKuLuEnKYFs3wiOWJlwx1ZYV0xyCu oW3AQsU2xqtaeqfyCtelOP8rryFe4sZNshK+MXogLfEmYYYmDcmUD7+9ieWQ90yH32pm Ru5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787925027; x=1788529827; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=YQ2v5WPLuMyVBiCPn6/ythOOcdRgTs4YGXxw08VQDF0=; b=HJd6sPOz7L1s1ClqfMeOs4t66rz+0ae1VClb3ndk80J7Z60omr//rUIC2iU+hG7cqW 5OIyXl3DLfy1p3c+NI9cA3PWemkmLrA7DsNKJ9MDTk9kk/qLC8+tTK2JWK3b0dkC6LSl dyFABaFSw11oQ47WPWdlPGIK8wERxarQOHaX/tfQRUpTLua0MVVvRW+/hmOdRJ6k7Bpb Z5IbyXJWtct2/iL6Ql9Yl0Y+jCvs8K/V6GoqSCUAdGQM0wcTtwKSEgdCDvNkP2Wzx4SW TVJy8JgcQ7P6d+Ex42zXggVQIYTbBw+rnlYCJnoubGgysnP4dVhakt5H6zI4zEWUeK6l SIag== X-Forwarded-Encrypted: i=1; AHgh+RqlPqlE0UAcsD9k8gGfeLG633xkWLT98yhDjCV4/kryWD5BPTdpNo989T4V/8bAPwXp1KfAkXbTHKjFdws=@vger.kernel.org X-Gm-Message-State: AFuF++nDRa2IWyFiKg6YYlbKVYq7HKUlBMleQ8Scv9wSFaPiBKoh+JEq bP7A1X8LjmqQqL/B6L5AnoFtqjb3siVuDC4BXa2KVUZ7T3Ci/82YBSCz1Cc/fOhpwBNEDrRKieB M6uV0Mw137qdfV++mB5HUDLCTXXS4TtCKN7CjCocWUqS609nV6kFbZbonRotATQ== X-Gm-Gg: AR+sD10smN0dUI3XpJ0L8KPWqPwmIoBIQQgcnVQaea5i358t2M0+5xc6kOX1zh8Duks 1rtDao6XQSZLhQGqQo1zytDjPzDWgzgS0SKxHbL3GvmvcIMgPYI+6HwteSpkV8XXOXr2EfAqqgu YVRJZ664cM9E09byofD8lhkz28t680ARnpDiTSa2RlIZ1rT07uO85d3OZodc2zjMGkPUvA/wBvz SiirgSF7GYtiDJZrLmDL9XbnGo/KrXGo+HoQKBvJqMBGfTiJhbg1kvbtRXqFWSYlg1UdXFrbEd3 5aiXn4BG3Mu3d+stuqeV86o27sZtvvLkEVn/sSGUUwXNr10iZgaxNVnMins0FqtMO3R4k2iVqjn gBkRhLtlx X-Received: by 2002:a05:6214:460a:b0:907:bfc0:781e with SMTP id 6a1803df08f44-90ce0f1c9b3mr99273346d6.30.1787925027018; Fri, 28 Aug 2026 06:50:27 -0700 (PDT) X-Received: by 2002:a05:6214:460a:b0:907:bfc0:781e with SMTP id 6a1803df08f44-90ce0f1c9b3mr99271956d6.30.1787925026237; Fri, 28 Aug 2026 06:50:26 -0700 (PDT) Received: from [127.0.1.1] ([45.130.83.151]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-90ce4534ebesm15645116d6.48.2026.08.28.06.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 06:50:25 -0700 (PDT) From: Tal Zussman Date: Fri, 28 Aug 2026 09:49:53 -0400 Subject: [PATCH v2 4/7] block: honor IOCB_NOWAIT in the block device buffered read path 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260828-blkdev-fixes-v2-4-32f3f40cebed@columbia.edu> References: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> In-Reply-To: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> To: Jens Axboe , Christoph Hellwig , Johannes Thumshirn , Luis Chamberlain , Hannes Reinecke , "Matthew Wilcox (Oracle)" , John Garry , Christian Brauner , "Darrick J. Wong" , Keith Busch , "Martin K. Petersen" Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Sashiko , Tal Zussman X-Mailer: b4 0.14.3-dev-d7477 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787925005; l=1776; i=tz2294@columbia.edu; s=20250528; h=from:subject:message-id; bh=dVg+Kna1OS1/t+OMJgLb0pIoDRWpFDUIK/hgTycNT2o=; b=+LKbEJTPkxRdLSw389VbqFoK/GHLhz/RdywtxJgd9bmpKS+r3dMK94MXnS3zwzZfPjp1ib1jr LtdsVtapnE+Dwxgqd4SRQg4Jyz0zg84y2pw5wmLu536svMsqr6ZIElC X-Developer-Key: i=tz2294@columbia.edu; a=ed25519; pk=BIj5KdACscEOyAC0oIkeZqLB3L94fzBnDccEooxeM5Y= X-Authority-Analysis: v=2.4 cv=daOwG3Xe c=1 sm=1 tr=0 ts=6a919224 cx=c_pps a=oc9J++0uMp73DTRD5QyR2A==:117 a=xDWFIMX55ayQNp92vt0S/Q==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=x7bEGLp0ZPQA:10 a=A0y_DWxS2BwA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Da8U98TiO7q1upZEImrf:22 a=79PYxaXUQd1wl-QFWJnA:22 a=c92rfblmAAAA:8 a=VwQbUJbxAAAA:8 a=s8mzj7eOnaliLhoSWqYA:9 a=QEXdDO2ut3YA:10 a=iYH6xdkBrDN1Jqds4HTS:22 a=GvGzcOZaWPEFPQC_NcjD:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfX3sg/sj9Jf+jM 3CplvpNBFw8VnA80JagG+72w6t3QkCxQ622u2k/AITcwSxGJ0BTPJ6+OeLL0sxI1vDJ2pn8TZdR fNcl1rtwfLLeGVTcAHj6m0TyGHS4ZmJGF0WHMKYVlfcrxaZAW9cszatMvwPHM3GwAK/amNaKVAb W8dyEGazX0imGrKG6wPXWCg/bcLgQHMnLzxtQ5n2yiWpyJAOP5JIlN1GqhePr99YCKIATiRPd8y +LJ/1gone9hbZN7j36So7n8+gutoqKFWqW3BOYfwiTxBxlr0Yvjjw7YfkWtfTUH7JRNDRr118TW pnWRmF3kPRehxRTl1ebGa9Cc8rbSwpDBdHkedvP6fTOf2NWvgqSTcevNf3wG6YXSOm9CWkQEjeM z8Dh5qGVFpbGgmtM03zxzYq5shd8JLyQ4njthy7/dtQINlZRbk1lLHlNunvk4uuD3vjU8J1D7NM /YNa5USlcty4RsP8Uhw== X-Proofpoint-ORIG-GUID: 8kUZOpP8N7pU7UCaPpvsUBS2NUpcsCV4 X-Proofpoint-GUID: 8kUZOpP8N7pU7UCaPpvsUBS2NUpcsCV4 X-Proofpoint-Spam-Info: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfX3G+ag1QJFkYv Zzsu0yFs4kk9gFpeSeRlYjpzyisy2RX4DGj1mJ6DyS6v7WINJ3XBI+XcSQqUXrrnvLJE1Smeq3G Qf5RXsIjqtJw+9ELiQbFepBTTk4eZw5edscamg4iBh+hNw1GtgQd X-Proofpoint-Virus-Version: vendor=nai engine=6900 definitions=11888 signatures=596817 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=10 lowpriorityscore=10 impostorscore=10 spamscore=0 clxscore=1015 priorityscore=1501 adultscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608280119 blkdev_read_iter() takes inode_lock_shared() unconditionally around filemap_read(). Unlike blkdev_write_iter(), it does not reject IOCB_NOWAIT for buffered I/O, so a non-blocking read, or the buffered tail of a short IOCB_NOWAIT direct read, blocks behind set_blocksize() holding i_rwsem across sync_blockdev(). A preadv2(RWF_NOWAIT) issued while another thread changes the block size with a dirty page cache blocks for as long as sync_blockdev() takes, 4 to 6 seconds on a scsi_debug device with delay=3D5. Use inode_trylock_shared() for IOCB_NOWAIT and return the bytes the direct path already read, or -EAGAIN if none, when the lock is contended, preserving NOWAIT semantics. Fixes: c0e473a0d226 ("block: fix race between set_blocksize and read paths") Reported-by: Sashiko Link: https://sashiko.dev/#/patchset/20260802-blkdev-fixes-v1-0-a82fc549fd7= 4%40columbia.edu?part=3D2 Assisted-by: Claude:claude-fable-5 Signed-off-by: Tal Zussman Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/fops.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block/fops.c b/block/fops.c index a51814821100..a3a709697b40 100644 --- a/block/fops.c +++ b/block/fops.c @@ -845,7 +845,15 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, st= ruct iov_iter *to) * Take i_rwsem and invalidate_lock to avoid racing with set_blocksize * changing i_blkbits/folio order and punching out the pagecache. */ - inode_lock_shared(bd_inode); + if (iocb->ki_flags & IOCB_NOWAIT) { + if (!inode_trylock_shared(bd_inode)) { + if (!ret) + ret =3D -EAGAIN; + goto reexpand; + } + } else { + inode_lock_shared(bd_inode); + } ret =3D filemap_read(iocb, to, ret); inode_unlock_shared(bd_inode); =20 --=20 2.39.5 From nobody Sat Sep 26 22:55:47 2026 Received: from mx0a-00364e01.pphosted.com (mx0a-00364e01.pphosted.com [148.163.135.74]) (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 772BA46D550 for ; Fri, 28 Aug 2026 13:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925033; cv=none; b=bGziFihjNcO+tCHtKnK1moyTo3aZR5TcX0va1Uj/WFmsw3vvk1w332MuoRmDsk1P95wMBfI3K//LDezHCeOy6LlmTFfue8C7WRdlOFS7ZaUJUkrIX82qU4nDCYvN1v2nJYSknPrXLWXcgJ4wnLmg1efW2c1+BOxspi/EONKAoBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925033; c=relaxed/simple; bh=572OiES/CjhuxPL8vR1LJOvecWmry6un5glgns5urC0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iBmsGjm1KtD598GPZ1hZTOtjV0lhv6mCbH2yJGxIFDcHeA3Sph8pZmUaWr8xKwVHoCEik8AR/QqCMcDsuyOS5ifKZ1t1KBB9g6W99BDt3Th3mDN8qbItQRmksIqCKQp+h9KNHTlN26s8Gcf7ft5YjUBQuFZE2E/IrUhMJtNgYK0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu; spf=pass smtp.mailfrom=columbia.edu; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=LxA6bp3H; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=x0QUTq7l; arc=none smtp.client-ip=148.163.135.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=columbia.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="LxA6bp3H"; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="x0QUTq7l" Received: from pps.filterd (m0167070.ppops.net [127.0.0.1]) by mx0a-00364e01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67SCYLFD1704071 for ; Fri, 28 Aug 2026 09:50:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pps01; bh=pOJo XJGTDCmNM/Ad6tqs2TZFZdczxvGzOD6wQaDYgcs=; b=LxA6bp3HGYx/oXH+P0It 5FDs1OO/GU5787H/eqhKdbiXeOobZAF2gnQaMXXA2/pEN0oFpyOkAUMpPexDv7hf dVSY8lb/PFYYlxd/4CD5zjZnZZEpn/S07kBC3f8Czwy2stgreHuWldRgjY+5GzZ9 ozGACjQS97GlYjlT9eN1N1Tf2HXhqprQbgLcPGDrRc3FzUmcePiZE1RtlndtIimH qUcvDNzqOZOJ7j0waoFU86zAhm0smvcwWyj02s+Fmd0tJVoc0nynvuMr6EYWXTee ZGOZqu3RbObv+EDSbUlfiWfIR9W5UPEDcHSIWJYv/3R1lOjVm+gx1Xd+IcJgPSmG LA== Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by mx0a-00364e01.pphosted.com (PPS) with ESMTPS id 4gatc1d4mx-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 28 Aug 2026 09:50:31 -0400 (EDT) Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-90c8cb9f37eso11806546d6.0 for ; Fri, 28 Aug 2026 06:50:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; s=lionmail; t=1787925031; x=1788529831; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=pOJoXJGTDCmNM/Ad6tqs2TZFZdczxvGzOD6wQaDYgcs=; b=x0QUTq7lrL6IxKOlgC9uzjG3xREt+ylTfePpUdyZzFh88H5cEk4JSG0C6O+g5G+LHS /S+Ibuu183aQ91icdDPmL46Cfu291VeI30n+EH2DNW3GFYCTfKz8y3zy0vE16p4wsplS LyCRBSgo9e34YTTkshIInlQl5rQXJn8WxZx9tmBoMjkekJ9X5R61BmtgHnUo+c6K/Kf1 IT+Bd8SLZZaB5CuJNgLsRQg3ZFkcncZwjLyvCfst2IuXKloXdEllHDyGxXfu29Cg6ot6 z8g5bXxVgm9B6TVKPSRByyfI/iSAphLUCoEfdWXhh/Aq1yqmkSIw0vbtLskorY7moQbm K6kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787925031; x=1788529831; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pOJoXJGTDCmNM/Ad6tqs2TZFZdczxvGzOD6wQaDYgcs=; b=NOxOMxedydM0jIXPcItH8GRM1NF4yMgHEdWOrtnD6K5e/1MBDwxpGeEttUvEpuP7CK +WviNaWeVjybHNY5014iw17OvqaYWi5KpsQp6wdKJoCxB2hN5r71Rh6qs1Jfhr311Qpn aY5IhxKRXb5z0zMXXvtjSNxvrkFU6HdCagyUoDk1ogiGru3O6gDgodbM2dbermG+Jh/T 7v+BIRZQtA7t/NQFqKI1m7lMtN+KXHBjxOVEIOOoZURQ9K6/4mR3jU/aXqgX4EpoEsnQ 38cWRXTUTBQRwh61qs6Km970YsDXmvnOMjanr0X+ecVF1C2ltDCtmHUAP4syomtT//Z4 NZzw== X-Forwarded-Encrypted: i=1; AHgh+RqzZj+S6M1GsiW6zMxp224MaJc+Gi2R8iP1bhTZO5W8qKCQ5dJjBjuYXAEh/4VIhk/hYvNAdzSbwK4s8ow=@vger.kernel.org X-Gm-Message-State: AFuF++m5UtZEyhq27y71sOSnM8ItwP32wywYlsdry2tCPur0qHUbUzo8 0P1TWrnfUAJGCqvihTJ4v5YHsrNtZZarQGEwl/ZIoHtWTCGxl3RkOLI2lRbBxcsbhtuRZmmCVoh OLPW/vjkvzfoYTeaeg4trmg/GNSloViiEL25GbjvwOFE3OgcN7NgZJ0Ni9qId7g== X-Gm-Gg: AR+sD12xDPZotaZYuWdDuVxQCNSZNSdqJd1L7oax9CVRxFw/Ccx9cqeM6QJQpgdnQC8 vAIl91e9u/9EvlLy0QJFqsHTlJXOI7nKHmVyLnaC3jVJza0YN+xKbUjk6B43eYz/PVBo3FhOchO S8ONxeePeqbIm9qJW1SjNdueihp58pOKlzqfe/Lvo9iCrhSmXmn9MCNzMwXPqdcUPU0579dvQ/2 gH2hMXV1UdO5MVE/H5Nxk2aQoXJkTSUG7Gzq/Dqn6ngIRSYWAAOx8RxLCEaecxW11Uqt8VbtHiU scVifYdsuxQpsfWOsbPWV6HpW5pj4LrWv5py+3YU2GPmbj3GYFpIKL7apC7r5qP6BRoEQdEryWF rPpzHGMV1 X-Received: by 2002:a05:6214:27e1:b0:907:44ac:7d12 with SMTP id 6a1803df08f44-90ce0b467a0mr87795986d6.0.1787925030451; Fri, 28 Aug 2026 06:50:30 -0700 (PDT) X-Received: by 2002:a05:6214:27e1:b0:907:44ac:7d12 with SMTP id 6a1803df08f44-90ce0b467a0mr87795146d6.0.1787925029825; Fri, 28 Aug 2026 06:50:29 -0700 (PDT) Received: from [127.0.1.1] ([45.130.83.151]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-90ce4534ebesm15645116d6.48.2026.08.28.06.50.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 06:50:29 -0700 (PDT) From: Tal Zussman Date: Fri, 28 Aug 2026 09:49:54 -0400 Subject: [PATCH v2 5/7] block: fail atomic writes instead of falling back to buffered I/O 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260828-blkdev-fixes-v2-5-32f3f40cebed@columbia.edu> References: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> In-Reply-To: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> To: Jens Axboe , Christoph Hellwig , Johannes Thumshirn , Luis Chamberlain , Hannes Reinecke , "Matthew Wilcox (Oracle)" , John Garry , Christian Brauner , "Darrick J. Wong" , Keith Busch , "Martin K. Petersen" Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Sashiko , Tal Zussman X-Mailer: b4 0.14.3-dev-d7477 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787925005; l=3243; i=tz2294@columbia.edu; s=20250528; h=from:subject:message-id; bh=572OiES/CjhuxPL8vR1LJOvecWmry6un5glgns5urC0=; b=ctdPaig/TPcLwkd135uOHim6leQoiv3dyzVAv5IWWPpvmjaeShsahmLX+O7aFEDrItQ5mSZ+s Heg3BLVKSv7DKG2Duzq3/crPLfU9p6h48t4FD+QtOTPKCvHLdVQwKwx X-Developer-Key: i=tz2294@columbia.edu; a=ed25519; pk=BIj5KdACscEOyAC0oIkeZqLB3L94fzBnDccEooxeM5Y= X-Authority-Analysis: v=2.4 cv=JKYLdcKb c=1 sm=1 tr=0 ts=6a919227 cx=c_pps a=7E5Bxpl4vBhpaufnMqZlrw==:117 a=xDWFIMX55ayQNp92vt0S/Q==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=x7bEGLp0ZPQA:10 a=A0y_DWxS2BwA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Da8U98TiO7q1upZEImrf:22 a=svvvyxlR1OQQkelhaPoB:22 a=c92rfblmAAAA:8 a=VwQbUJbxAAAA:8 a=bwvcz7OWzcURP5mN1j0A:9 a=QEXdDO2ut3YA:10 a=pJ04lnu7RYOZP9TFuWaZ:22 a=GvGzcOZaWPEFPQC_NcjD:22 X-Proofpoint-ORIG-GUID: UlcYG-grvimxytbcPQvcw77NQ1X8gA_j X-Proofpoint-Spam-Info: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfX4GuC63OiHdfB IWt4w4zQBMYpZUzyy7CSdLFPzneq2eJ74FlnOQJX/Vl1mpLp6wb8BSwinQFdZ2T+0DKoI/e0wKG HWgXpsVG3a25jwQLBZFFao57cHOXgq3udQEuNzrIfHzQ8T5qXdCl X-Proofpoint-GUID: UlcYG-grvimxytbcPQvcw77NQ1X8gA_j X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfXwyPllryN4yET agHWsPXRixUR7uOl0rm5jl2I73/ZXuUFucGZw25E63y4dNtr5tD7eMOV/uXjgQwVQEK7bxnDq2K VsIw3qWwAOf1GHsOBeEYL1smTHOi8YXEXdssri15Ijcmn7OLq+A96EjyZwDnj2dAtbgecJYeman 2r0ml8QMJF4dGPbaYUlSjyyWV1Rftm6fE/IczI+tE+YwPSij6hN4noD3e1PqHLuIt9GZ/6RGosc AJEfiG6eoR3Q0HDPGC0xayBPMURkuEqGLABaFdI6BcNhgxuwbvknq50vvzMNRz+mmsOMPwJn92R G4iP/4e6dPFw4CfJhDWmoeuogvN/qEzBiHKQFDXampxGdMVbK2qPshZcmX3szL670RSLDRaSQ2j IAfqpYXDtw5FflzOadjGBItfIpZE16U4czpRoelFMePs9fI6zRju2gtm2Q1i+JBGXxNSE3qBYex VHS2vuHVKQ07HjVaY/A== X-Proofpoint-Virus-Version: vendor=nai engine=6900 definitions=11888 signatures=596817 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 spamscore=0 bulkscore=10 adultscore=0 impostorscore=10 lowpriorityscore=10 priorityscore=1501 suspectscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608280119 An IOCB_ATOMIC direct write to a block device can silently lose its torn-write guarantee in two ways: 1. blkdev_direct_write() turns an -EBUSY from page cache invalidation into a 0 return, so the whole write is retried through blkdev_buffered_write(), with no atomicity guarantee. 2. On a partial page pin, __blkdev_direct_IO_simple() and __blkdev_direct_IO_async() submit what was pinned with REQ_ATOMIC set and leave the rest to the buffered fallback. The second case can be triggered deterministically. A 16K pwritev2(RWF_ATOMIC) whose last page is PROT_NONE, on a scsi_debug device with atomic_wr=3D1, completes short with only three of the four pages written, violating RWF_ATOMIC semantics. Fail the I/O instead. Return -EAGAIN when page cache invalidation fails for IOCB_ATOMIC rather than retrying through the page cache, matching __iomap_dio_rw(), which treats the failure as transient and lets the caller retry. Release a short atomic pin and return -EFAULT before submission, which is what a direct write already returns when none of the buffer can be pinned. A sync atomic write can then never return short with a remainder, so the buffered fallback is never reached. ext4 has the same fallback and only warns in it. For block devices both ways in can be detected before any I/O is submitted, so fail early instead. Fixes: caf336f81b3a ("block: Add fops atomic write support") Reported-by: Sashiko Link: https://sashiko.dev/#/patchset/20260802-blkdev-fixes-v1-0-a82fc549fd7= 4%40columbia.edu?part=3D2 Assisted-by: Claude:claude-fable-5 Signed-off-by: Tal Zussman Reviewed-by: Christoph Hellwig Reviewed-by: Hannes Reinecke --- block/fops.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/block/fops.c b/block/fops.c index a3a709697b40..8769bb13df1c 100644 --- a/block/fops.c +++ b/block/fops.c @@ -87,6 +87,12 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *i= ocb, ret =3D blkdev_iov_iter_get_pages(&bio, iter, bdev); if (unlikely(ret)) goto out; + if ((iocb->ki_flags & IOCB_ATOMIC) && iov_iter_count(iter)) { + /* a short atomic write would be torn by definition */ + bio_release_pages(&bio, false); + ret =3D -EFAULT; + goto out; + } ret =3D bio.bi_iter.bi_size; =20 if (iov_iter_rw(iter) =3D=3D WRITE) @@ -352,6 +358,12 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *= iocb, ret =3D blkdev_iov_iter_get_pages(bio, iter, bdev); if (unlikely(ret)) goto out_bio_put; + if ((iocb->ki_flags & IOCB_ATOMIC) && iov_iter_count(iter)) { + /* a short atomic write would be torn by definition */ + bio_release_pages(bio, false); + ret =3D -EFAULT; + goto out_bio_put; + } } dio->size =3D bio->bi_iter.bi_size; =20 @@ -691,8 +703,15 @@ blkdev_direct_write(struct kiocb *iocb, struct iov_ite= r *from) =20 written =3D kiocb_invalidate_pages(iocb, count); if (written) { - if (written =3D=3D -EBUSY) + /* + * The buffered write fallback cannot provide torn-write + * protection, so atomic writes must fail instead. + */ + if (written =3D=3D -EBUSY) { + if (iocb->ki_flags & IOCB_ATOMIC) + return -EAGAIN; return 0; + } return written; } =20 --=20 2.39.5 From nobody Sat Sep 26 22:55:47 2026 Received: from mx0a-00364e01.pphosted.com (mx0a-00364e01.pphosted.com [148.163.135.74]) (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 E6B4746EC91 for ; Fri, 28 Aug 2026 13:50:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925039; cv=none; b=lKGcttr7a3W96tUmbAW6RodUsZAJr/VFV/bVcuQyK7B//2H5D87A+5iKfG3jnpaTeXCoo5moD51zQdRzoIWb1DtPKfCLrk2q6qIta7rTebDfLh41zpyRtWlFwAYYer5edx9O7+WQecrM1bwMy9+IMO+DhZZVpXvYZWRa0vA5Yso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925039; c=relaxed/simple; bh=7uQC8VotJR36OCAn8vP8AVuyOk19WhdnG7o564CLv+s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=paGH2VHfsvj2ywRB8+50pJPegCw9Hvm4RXNQVI0KzhMNNVIdzdm8QS0godCIpYxMaLfiNPC6IwByJ4llYQDtmztBVK4wTlcnPhSH/t56rlQyBxTgMAyUFJXNAZSeMyC5j9g/KnBY+hBfZumfGZljaH9EMg6HmMvD2+puniGmfDw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu; spf=pass smtp.mailfrom=columbia.edu; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=m8oEO6sy; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=BENa23yS; arc=none smtp.client-ip=148.163.135.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=columbia.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="m8oEO6sy"; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="BENa23yS" Received: from pps.filterd (m0167068.ppops.net [127.0.0.1]) by mx0a-00364e01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67SCcW8x2291333 for ; Fri, 28 Aug 2026 09:50:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pps01; bh=yBG7 kFfJ+sRlQ+D9LSOXUuMG2++9TcA/Tr58AwqFz9o=; b=m8oEO6syDU/lforqWQoV FfMK75uf5kECsQx97X3vcOFcvCeZmSi4E07VeHFNEO4OFtjWPb9hXySL1+LC5o9j n/aP1gJy8HSx8VfzEYPAkpdLqQEMxns2fqtMTdb5gaja5n1CoCjXPCDLfPFtvtKr jdKdQIkbj0lyGlOfT2VqD/gDE7Zn0JId6wfyNCGze+rM1KFGo9Jk5vcrymFOGBmb eDSn4bwCmGK5orr2PUsJP7PiCQD+0c2nhUv0km7gwKdNs7wEHlmNifSHlgNNMTAy DjahGojPPIPVRS25w5XWdMADm/HhH9jgGz5uLQFLkFBcuGDUEWB/mdjWFIlj2APU HA== Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by mx0a-00364e01.pphosted.com (PPS) with ESMTPS id 4gauffvj2u-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 28 Aug 2026 09:50:36 -0400 (EDT) Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-90c8da50f8dso21152586d6.2 for ; Fri, 28 Aug 2026 06:50:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; s=lionmail; t=1787925036; x=1788529836; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yBG7kFfJ+sRlQ+D9LSOXUuMG2++9TcA/Tr58AwqFz9o=; b=BENa23yS1MiqNzuDDuRX3HH6GJfiS1ykrbqD+eAZNLKB6hZOABgxIZK07loLFfEvVj RRnkgDWpIUEYgtpWcSH1lamZ4eyDa8w/hhAh+HsLqspZW/hgDEIvjdeCFKbtHS1hQRoF wRjwcs86wX/Q5dNslzlQrORx01VOrWEX1RnC63jA4UR9jY2K/gE8LBSk+31chTvuM0on qBHJPimstvBibjw44Sn8w3m7ifHSJly1aHCZWR2GIhiMc2qmGqZ6MnWTqmrPW/9HiBhL iRziVCMg8OX3/v66+wfqE6myP0/AMQs+X6cBjM/8zlklMhVJ2xtWOFj9zhojXEpy+p/D h10A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787925036; x=1788529836; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yBG7kFfJ+sRlQ+D9LSOXUuMG2++9TcA/Tr58AwqFz9o=; b=J53GCSNbTyWdpifeV7tw5FHiqOXo9s7FamZpbDtDKXSTxpbRnCWpoQyz9Dw0azINrj jcAnSFrqZ54atQOHNXuQLwzLmCaj7CtAkazn8puxxxN+rzIMOvBo7ZU3xIQSVt4z2bc5 dSc7uYn/M5iiZzPHMsi0w6GMdvm/oF/IMTX6Pa3w3aW/rxgsIwtY2f5yTMh4qx/305ZG rwFVAll5iJM1Tij8T1oimaI4giDeJ9D0NBcRIhkMkCPMmQt3RWo3CsP7sqqqqwXE5mco TQoaAFbI5Cmk/hPeGEbTRdNXswN99zJUJHMb7DQ0fv9+THtgkMNXmeBlBQjcA8MjAd2L dgtA== X-Forwarded-Encrypted: i=1; AHgh+Rqk8S7+voLr2w+MAlfdC0t4jzs8mPGzEU591lAycOrHqaIOaEN4p267kJ/tX2x/Fnt/9r5mBkTm3XOw87Q=@vger.kernel.org X-Gm-Message-State: AFuF++kqOh3AlBPMvsWDpQELr/Y+ZvLCT0W+d8fbTFwrI3UPuzsAHGnc 3Q0tJZB4RpbMtvZCE4oHFWShHVJDOvmSy6zFFkNdIlEEfLg14Pvqhy13rP3oJV2ykfpreGr5hN0 ipTc2gS3fhhGImrtnwnTRWD06yUcU3TG3jUb54+jNn+Gn9oM6JHansRTAsFxdBQ== X-Gm-Gg: AR+sD11bf6lnPW9LXoA8YqLZ9CTvezOPzlF47/nS3p1g+BrOxy/4kKq6HAbrUi2JDx1 3C6/A3kCkET2Mi5SAvyNJz/61OsA17v1QZV79Oo9JQJZiEVCblFgPcrQ9E0v0N+nfUApS0aaJ++ o8X0fw6dGWjJCGN3YdR5k++jV4L9P/g1SSWMZnnWsbeQXV4qWNH2oqUcMdi+jOu3pFhPN23K9/z kHqOCVQcyCxyBwiC7T8OYWTGN7j1eWzACjGj/Gg5bFSqZFUSCe3kMRj3Nx7AZepDzrmmFMkn4IR Zwn1iUmoyBF/Ccw5Md3vvrZt2HdrsTFmb5WJF0XGP9g2Egp92qOkLeNDR4zRkWNcS5qbHRteXfC WvipnGq0R X-Received: by 2002:a05:6214:2584:b0:90c:b415:cb32 with SMTP id 6a1803df08f44-90ce0c1d3ddmr88417846d6.6.1787925035717; Fri, 28 Aug 2026 06:50:35 -0700 (PDT) X-Received: by 2002:a05:6214:2584:b0:90c:b415:cb32 with SMTP id 6a1803df08f44-90ce0c1d3ddmr88417176d6.6.1787925035204; Fri, 28 Aug 2026 06:50:35 -0700 (PDT) Received: from [127.0.1.1] ([45.130.83.151]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-90ce4534ebesm15645116d6.48.2026.08.28.06.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 06:50:33 -0700 (PDT) From: Tal Zussman Date: Fri, 28 Aug 2026 09:49:55 -0400 Subject: [PATCH v2 6/7] block: unpin all pages of a bvec in bio_iov_iter_align_down() 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260828-blkdev-fixes-v2-6-32f3f40cebed@columbia.edu> References: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> In-Reply-To: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> To: Jens Axboe , Christoph Hellwig , Johannes Thumshirn , Luis Chamberlain , Hannes Reinecke , "Matthew Wilcox (Oracle)" , John Garry , Christian Brauner , "Darrick J. Wong" , Keith Busch , "Martin K. Petersen" Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Tal Zussman X-Mailer: b4 0.14.3-dev-d7477 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787925005; l=2734; i=tz2294@columbia.edu; s=20250528; h=from:subject:message-id; bh=7uQC8VotJR36OCAn8vP8AVuyOk19WhdnG7o564CLv+s=; b=dBdBQvsT1Eg2cEiskP/UEXYohc+3xoyjw8hNuV50R2Fc+vM1s6pMZ+Qjh/H/ndLhjWk++quGn LMLcwhnLW1dDi2Hoe024qu4r6t1A5HEq1zLzEa8HkQGinX/x5GKMKRk X-Developer-Key: i=tz2294@columbia.edu; a=ed25519; pk=BIj5KdACscEOyAC0oIkeZqLB3L94fzBnDccEooxeM5Y= X-Proofpoint-GUID: XkT7rQ9ykZu0S_cDchTQKIkE4jB3Z0CN X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfX24dEXtux8jQo 6QITEg4bULcun93yoglAItDoYYypZgFD25DLbfJodjrPblz9QphhydqM5PMilyUbPTqhuBAKus/ xzvXeJguBhf8mljOeHyXw7d7EIWx0d/m5AvWTrC78wyt2fqWokExzqor1zbUsNKo5CYExf9NbZ5 a2mXg0OWVgNPBes62LFmtG46a+nacM/PTF+nBjVcAb+f0vcjME7TcfERenipnfUNvHH6gyN/ShM ibczRC7V8IxhyhqPT6M579VHdxXE9ezIvvknJI1xFuKOyrUXEV4sNrLbbdsZGUT15e87/GGJYxq +Owl9s73GTZj2bC+M/cVOHUvdecljxPvwJo5+Q4VHYcC41BeEwaNZShtjqRR++YBD/EZIJP70Xk 4g+eyJtv3qDAtKMgZ6Ayqe/qZKQSt7HZX/jkNr4RQ3RpT0hnDx5mZ93Y1qqqq8Bf1KSd0SLoBtk s7Y8dH6EiCB4chmDymQ== X-Proofpoint-ORIG-GUID: XkT7rQ9ykZu0S_cDchTQKIkE4jB3Z0CN X-Authority-Analysis: v=2.4 cv=Y9LIdBeN c=1 sm=1 tr=0 ts=6a91922c cx=c_pps a=wEM5vcRIz55oU/E2lInRtA==:117 a=xDWFIMX55ayQNp92vt0S/Q==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=x7bEGLp0ZPQA:10 a=A0y_DWxS2BwA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Da8U98TiO7q1upZEImrf:22 a=usPcmh10W0ubT8QP8_c3:22 a=35irZU1t4opwmMTl3MoA:9 a=QEXdDO2ut3YA:10 a=OIgjcC2v60KrkQgK7BGD:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfXyoZtOqdM+w4o lPp7wdjCElUHcEhnzQo1RL3R15bBmywW+oEXmAooaVUCVgQ9mF+1QaqIlkJ+4xD6iKFw7pytei4 3KLK0s3OEAmvEr1uxvei3Nf3RBXOWEqDK9dObSOv8Li/YYZvqNje X-Proofpoint-Virus-Version: vendor=nai engine=6900 definitions=11888 signatures=596817 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 bulkscore=10 lowpriorityscore=10 spamscore=0 impostorscore=10 adultscore=0 suspectscore=0 priorityscore=1501 malwarescore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608280119 bio_iov_iter_align_down() drops trailing bvecs with unpin_user_page(), but a bvec built by iov_iter_extract_bvecs() can span several pages of one folio, each with its own pin. All but the first pin leak. The partially trimmed bvec has the same problem. Shrinking bv_len does not release the pins for the pages cut off by the trim, and __bio_release_pages() only unpins the pages bv_len still covers at completion. Both issues occur only with a logical block size above PAGE_SIZE and a large folio backing the user buffer. On a device with a 64K logical block size, an O_DIRECT pwritev() from a hugetlb mapping that ends 16K past a block boundary leaks one huge page per call, whether the remainder is its own bvec or the tail of a larger one. Unpin all pages of a dropped bvec with unpin_user_folio(), as __bio_release_pages() does, and unpin the pages trimmed off the last bvec as well. Fixes: 20a0e6276edb ("block: align the bio after building it") Assisted-by: Claude:claude-fable-5 Signed-off-by: Tal Zussman Reviewed-by: Hannes Reinecke --- block/bio.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index 898b2f5ef8c8..48fa6b9a6dba 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1196,6 +1196,11 @@ bool bio_iov_iter_set(struct bio *bio, const struct = iov_iter *iter) return true; } =20 +static unsigned int bvec_nr_pages(const struct bio_vec *bv) +{ + return DIV_ROUND_UP(bv->bv_offset + bv->bv_len, PAGE_SIZE); +} + /* * Aligns the bio size to the len_align_mask, releasing excessive bio vecs= that * __bio_iov_iter_get_pages may have inserted, and reverts the trimmed len= gth @@ -1205,6 +1210,7 @@ static int bio_iov_iter_align_down(struct bio *bio, s= truct iov_iter *iter, struct bio_vec *bv, unsigned len_align_mask) { size_t nbytes =3D bio->bi_iter.bi_size & len_align_mask; + unsigned int npages; =20 if (!nbytes) return 0; @@ -1213,14 +1219,24 @@ static int bio_iov_iter_align_down(struct bio *bio,= struct iov_iter *iter, bio->bi_iter.bi_size -=3D nbytes; while (nbytes >=3D bv->bv_len) { if (bio_flagged(bio, BIO_PAGE_PINNED)) - unpin_user_page(bv->bv_page); + unpin_user_folio(bvec_folio(bv), + bvec_nr_pages(bv)); =20 if (!--bio->bi_vcnt) return -EFAULT; nbytes -=3D bv->bv_len; bv--; } + + /* + * __bio_release_pages() only unpins the pages still covered by + * bv_len, so drop the pins for the pages trimmed off here. + */ + npages =3D bvec_nr_pages(bv); bv->bv_len -=3D nbytes; + npages -=3D bvec_nr_pages(bv); + if (npages && bio_flagged(bio, BIO_PAGE_PINNED)) + unpin_user_folio(bvec_folio(bv), npages); return 0; } =20 --=20 2.39.5 From nobody Sat Sep 26 22:55:47 2026 Received: from mx0a-00364e01.pphosted.com (mx0a-00364e01.pphosted.com [148.163.135.74]) (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 7302C469834 for ; Fri, 28 Aug 2026 13:50:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.135.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925045; cv=none; b=E9bpggTRVxzpwjpKEht5XRg5yk1MEGmE98wpR544R8kLGHJEGYjW/h1PhTX3J8YFCb6sVSZChxJxZyNi2idZ+psRQCi21Wyxzxy46+qfKpSO9NlNdW3L1D6rguVhbxksi/hgU51oNk/0WkxqVMg/C9NHML9fSCIHfb0iOxuujnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787925045; c=relaxed/simple; bh=CLBEYcKpWyuhrcgiMUWFD60aO3Fph2vHxszmT1moq34=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CFbsMZLSbwqcfJXmggXSOIgABpqh5owWy8Bz4MVWnj1Inrba8k+9I2u1tY0tzUuPXrgEdZvk/KJ35AA6JovK+VzsUqtgz+nJZ7zZex8+XxbDFvuqieIpQN8sDuRlhwJBn6BWjAq82dJAqCOYB59JttFyMhUnimfSUJ3on/hTCTE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu; spf=pass smtp.mailfrom=columbia.edu; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=lXpIiGs1; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b=2ZJ6UdCc; arc=none smtp.client-ip=148.163.135.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=columbia.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=columbia.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="lXpIiGs1"; dkim=pass (2048-bit key) header.d=columbia.edu header.i=@columbia.edu header.b="2ZJ6UdCc" Received: from pps.filterd (m0167069.ppops.net [127.0.0.1]) by mx0a-00364e01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67SCYS8Q3930717 for ; Fri, 28 Aug 2026 09:50:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pps01; bh=Bgm9 Lli18Fm8IY/j8xR8FpbXhUGGdPwb42mwnsGVJrE=; b=lXpIiGs1yvcVkoXZ+BRp aah3VZmrUyPV6mFS+VhqketrNQ2RqfVXqEBYRnBkUUe0o1wV1AYa0MGOKHwFgFWr vyu9F5LMzBI43aWEGi9OqL6qIbtzM1HYbbMBdh5tceTRAk5+1jvHcNYqnGUFA23b jSGjI+NBOaTwoTlsW16joScTiICVC0oDIRd9BpfITfAPkKVItUWKreTrVu/0ra7D I6ywj55ZQa8Fy8Pd9cpSS5TmaFHUBJH2kt3Nhys/EKQERzQjFv7sXmNJUUhXAcnl ymXEWf6xv76Ppn8D1ed/iS5bUJwevRDN9KYSm53uiU78uxa3QNNkj1SZfj9Atb4w vg== Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by mx0a-00364e01.pphosted.com (PPS) with ESMTPS id 4gb9q70sk5-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 28 Aug 2026 09:50:40 -0400 (EDT) Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-90cea0b5522so3536886d6.1 for ; Fri, 28 Aug 2026 06:50:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=columbia.edu; s=lionmail; t=1787925039; x=1788529839; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Bgm9Lli18Fm8IY/j8xR8FpbXhUGGdPwb42mwnsGVJrE=; b=2ZJ6UdCcyrJinjZQ/lBFbR+QmLb48TYCes6ouy9jqUHD6V5wnZ5XI7QluGc5R/6/Jx udiJp8rnvMJjANjcFUeG05V95CKvxeONXBCb99+gIwIHKQyE1+QkVpZD7O5WdVfBcq5G Z3NxsqMoFmUypGX/aLAZy9kBSX3NsW61kPQbCZU4N3wt3Nl1K3hcBl8tjVAaBWnNZKCk RLPwsYxbqocI4TZVCF2SXvB8tNoJJGnkripSQu5bpHmniaI87jxNvmlI1w/HGfQ9BwLj RCi1sCBrCNDxYJ6kMgaAPlAT1K1CDLW4d3SxHtEzMim829c+2ds1i4zGGLPfRK3YUML5 mb4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787925039; x=1788529839; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Bgm9Lli18Fm8IY/j8xR8FpbXhUGGdPwb42mwnsGVJrE=; b=pciHxrdlD3zy6wCJJxx7yOCi46mTOSBN92JYGttXeEky1V+UBcjOV7h3GA4ZWW01E5 rObA7pyz66j1D5smUcpx1Gzld0J8cLeN5VxyH+OVes5r6ZsM3ngW2y3Vg1gsLEelEV/W 1HBmXKTGhvmW1IcgC95D/nMsXd+XqC2VnW61zgR5j58jxIAllCwjaThDKj155VliUVJc RKvdmqOGirNniKUY3Y5XclClqG22l7/UgpGvgcqZcRfAu87SQ0CfjjlD24qkkv4yPqqA VqNIhfSdUvnmP+7cphqXNgZPLfQrxlVeg1L2rtYkjk/6VkjbPV7vypt4oSLcGqtCkk8m U9YQ== X-Forwarded-Encrypted: i=1; AHgh+RrC4v/fkukAolPLdJ/2OVZBE2ZG3cWaB96x7Ii8o1HcNjnMbIwTtu4a5x4CLEm5s41jGK+Cn+fqwQXJaH4=@vger.kernel.org X-Gm-Message-State: AFuF++lDFf3fy+MsNKcK7Zz2IalEw6zFZhMI/g+4A5YUnu2RxAxmfV/t 4Dd4oZU12579FlU/dZCj4Nt89/2hRmzNhWdn5VDyez3uDnf+DYAViDtx9V5eA7uDHmKR+2SGnC1 yRV+N3K46HB/dEjM7yzowsxBGjEhsk9kmEWH3rVnGaPFdICp5L2TbvTYlLRxVvQ== X-Gm-Gg: AR+sD13gs4b2EUZcprqp/K/KumeVA2PgYNXABYLeNri/hpZAUHPXf9bbcoL1eIM32sV hvsKFFf+A+aumsvLSVbl+7CWSF1VflCfWKAhwEHTGk6YCuwA1LDpkF9HexCQo1rAAr6ZdxnHLRp CMdX0lpwTCNCNtA+NhGXuFDou5edhoDSU/iED8E5ep1m1o03/x42u/JqoNyPNfDfGwg76dtGhJc UYHiL2IhbxbNwHYub5gV3VEPdoFVYUGwDDeBxpQlakjR9rj2OUyWOu78GPhXE0lCRrwZU0MWjv3 YZLYI2WzccO6MF+aJtlG3A6B6hgX0i1Bscep1C9zbHxkpd7gfgIno1l3oq4KKd6H/XDjom4ldC8 QZmgymVhG X-Received: by 2002:a05:6214:234e:b0:8cc:ea2c:f2b3 with SMTP id 6a1803df08f44-90ce0f0a733mr76345896d6.21.1787925038958; Fri, 28 Aug 2026 06:50:38 -0700 (PDT) X-Received: by 2002:a05:6214:234e:b0:8cc:ea2c:f2b3 with SMTP id 6a1803df08f44-90ce0f0a733mr76345216d6.21.1787925038479; Fri, 28 Aug 2026 06:50:38 -0700 (PDT) Received: from [127.0.1.1] ([45.130.83.151]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-90ce4534ebesm15645116d6.48.2026.08.28.06.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Aug 2026 06:50:37 -0700 (PDT) From: Tal Zussman Date: Fri, 28 Aug 2026 09:49:56 -0400 Subject: [PATCH v2 7/7] block: remove dead metadata handling from the async direct I/O path 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260828-blkdev-fixes-v2-7-32f3f40cebed@columbia.edu> References: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> In-Reply-To: <20260828-blkdev-fixes-v2-0-32f3f40cebed@columbia.edu> To: Jens Axboe , Christoph Hellwig , Johannes Thumshirn , Luis Chamberlain , Hannes Reinecke , "Matthew Wilcox (Oracle)" , John Garry , Christian Brauner , "Darrick J. Wong" , Keith Busch , "Martin K. Petersen" Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Tal Zussman X-Mailer: b4 0.14.3-dev-d7477 X-Developer-Signature: v=1; a=ed25519-sha256; t=1787925005; l=1284; i=tz2294@columbia.edu; s=20250528; h=from:subject:message-id; bh=CLBEYcKpWyuhrcgiMUWFD60aO3Fph2vHxszmT1moq34=; b=5WvKxt3K2LYokFDzH4WeJTFTA7gEIVIWCTmbVlba+tySOCaeA5kMtbAcp9DpKL341If1ztIEY xh3MbLbTCOAAGoQ8NrQGpjPrFv+GQRpn8+uJLIHNzo8rEQPhfBCqT+R X-Developer-Key: i=tz2294@columbia.edu; a=ed25519; pk=BIj5KdACscEOyAC0oIkeZqLB3L94fzBnDccEooxeM5Y= X-Proofpoint-GUID: ie8cwU4hyLueUWo71A-SoGgdwn6XZ_k5 X-Authority-Analysis: v=2.4 cv=IKUyzAvG c=1 sm=1 tr=0 ts=6a919230 cx=c_pps a=wEM5vcRIz55oU/E2lInRtA==:117 a=xDWFIMX55ayQNp92vt0S/Q==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=x7bEGLp0ZPQA:10 a=A0y_DWxS2BwA:10 a=VkNPw1HP01LnGYTKEx00:22 a=Da8U98TiO7q1upZEImrf:22 a=JR4YdQiviy7OQf72WyZ1:22 a=YZNyPf5b8iN1AD22L6QA:9 a=QEXdDO2ut3YA:10 a=OIgjcC2v60KrkQgK7BGD:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfXwGH/ppGaWPYe 8WVgFifbPR4Mkgiae+y/5CfYcpIu83mZ5w1bV9qCemD/4IzA08P1WhnskjjaUlwTeSlhEvLK0bI Lt4N5slwT+EQV8CtOEOKX085Bektu5y//9+QQKLBW/sPiSTLhr2g X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODI4MDExOSBTYWx0ZWRfX4qy9wpJNAK53 Mr3qQl8cB7i46tuqqL3EmWF8+yr/yM8OEtghvR9e8U1LjvBNB9CjaS0tKl4IQYi6sZwt/cC1SMl eC7N98RWk3gWjdICpm4tX4XpigqteJK9ZAGLl7aSNNia1605dyE2a6f++RSNSdTrsuGkfxf5apY RflcbGOiHt3KFhW7ZICUnwr2yVufviVcG2lbhxIG9PKiAjxCBhTVPW4aEWsCjO8kq2nq9jr3Swq daY1XGQ3jeTno7qUWgxBINHt1VGiYc7Cq1lSPRLvJJo/HJOg+BR7OU63XuHJfBGRCHZhlJzqzix Gt3UeSLRo48Qgn8kSITsogALYFRtIVToQW1CcLVK+arCthlu4VS6CejQzX5o8CtyzarI2/uwHX3 vz6v4Fr5LWyMfIl5CmBMvwWWgPm8KE7wN82QoJWXADY0PyQ8qKoGB/m85/fqMusWg9K6YLXIGa+ eiGoM3EHU4Zss6JK1EA== X-Proofpoint-ORIG-GUID: ie8cwU4hyLueUWo71A-SoGgdwn6XZ_k5 X-Proofpoint-Virus-Version: vendor=nai engine=6900 definitions=11888 signatures=596817 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 priorityscore=1501 malwarescore=0 phishscore=0 impostorscore=10 bulkscore=10 suspectscore=0 adultscore=0 spamscore=0 lowpriorityscore=10 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608280119 Since commit 2729a60bbfb9 ("block: don't silently ignore metadata for sync read/write"), blkdev_direct_IO() sends every IOCB_HAS_METADATA request to __blkdev_direct_IO(). Remove the now unreachable metadata mapping in __blkdev_direct_IO_async() and the unmap in its completion handler. No functional change. Assisted-by: Claude:claude-fable-5 Signed-off-by: Tal Zussman Reviewed-by: Christoph Hellwig --- block/fops.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/block/fops.c b/block/fops.c index 8769bb13df1c..1964cb113842 100644 --- a/block/fops.c +++ b/block/fops.c @@ -312,9 +312,6 @@ static void blkdev_bio_end_io_async(struct bio *bio) ret =3D blk_status_to_errno(bio->bi_status); } =20 - if (bio_integrity(bio)) - bio_integrity_unmap_user(bio); - iocb->ki_complete(iocb, ret); =20 if (dio->flags & DIO_SHOULD_DIRTY) { @@ -376,13 +373,6 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *= iocb, task_io_account_write(bio->bi_iter.bi_size); } =20 - if (iocb->ki_flags & IOCB_HAS_METADATA) { - ret =3D bio_integrity_map_iter(bio, iocb->private); - WRITE_ONCE(iocb->private, NULL); - if (unlikely(ret)) - goto out_bio_put; - } - if (iocb->ki_flags & IOCB_ATOMIC) bio->bi_opf |=3D REQ_ATOMIC; =20 --=20 2.39.5