From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 282D93955F7 for ; Wed, 8 Jul 2026 10:13:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783505634; cv=none; b=s7BzAVrCFcwLt1mWD5+gd/ETWeE7MiZ3C7LEEM9Xtcde4HYCZUEjJFyIXG68F8L6Q3KqEvbzkpsShiHbsv4sV6h/YeSjHT4FMG3sBggu/oGtiEpgh1k/9isCZl9AI6fGbgBhUQ/9C0HuX1EKyYsf8YU687WqxtogvBO53kt1V5c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783505634; c=relaxed/simple; bh=mhSf1diO787IHvy/KgOdwRidnshdDQzhxOrYmB6YdGY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YrP3qUG4eJPCog/VcdlDdS9NEJfMa9CxyL+MSqRa+N8dzB6S/p6OF0rpPr2ECKBHkjjpPMFUVc4WfiAgfjnOJOHs+x2Yjma916ciIfXO7EyP3Ckb50MyWu89UgORmQNoxn1i0R0OSA/mI3C9PKlgCM+SCFibZrZvU6EotO7Z/8E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DpNsOR73; arc=none smtp.client-ip=209.85.221.45 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.b="DpNsOR73" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-47d6c634f45so353155f8f.3 for ; Wed, 08 Jul 2026 03:13:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783505631; x=1784110431; 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=GkymPx5dWsv7zXA1LsUKxw6gSalWwxADmMb2zMEOuyU=; b=DpNsOR73xva2gz0UFbAKZjwRmtT40Fkfp0hj09FSJ/+HeKb+LcN0Q/zyMkjRzy12JT DXnGeQL3kYR+FGAcq444iqYEqXgfujMzs3iUztFF593ZAjjW821fqfogzhCTHoF9qcEg eXWIs3/i/lRtwkTRf+QqFhJoRyiZoNXmaPJni426jywqJ9ryfQ4e8wF1XT/V0pe4SYd6 w875FMxsLB42Qcgqbu55TVWeWTe0zvJW+aVgCk1wzIr0gvfheOk4tgW6MEw0YUcvTW2h 4K73qPNEkGbi/zAW6oIsAtDjOCwrxFUQSOCdlf5U73zLeVdOGLjXLBs3Co8sluG+vbZt ADjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783505631; x=1784110431; 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=GkymPx5dWsv7zXA1LsUKxw6gSalWwxADmMb2zMEOuyU=; b=aOUKVXSNZ3uyMmpmB4QxllIWT9pAne3hsOl6sv1/x9HeeOP9fjSLK76CYsTL5oCR4x zth1NXemAJENWLVZ47vRouj1PjNoU9IyRIOcGEayRFzZ+FH+Huvb2xbPvGnPxUFmj5jE WpXRcAipmKy1PDBf5aiPcb4b6IZHXtguGCK0wX5aa9LQmDALHlF6o2Ya2ALC5J9RRN3R bWw593H/0C0qPCZQOPYOQUxGFlHSISrwhSzux/U4IMor5BjTVCHgHN1+pvoj4tzdwiFl EBhYrta/l3U1p55PBP7dU3qZdHG6jNf+eATw2ActoZDPJW2j2dv2OzoVYNZCpobb7DqJ xbfA== X-Forwarded-Encrypted: i=1; AHgh+Ro6nYfvndqyxkIo+cfIjwSEofSBvyEgCzMhTyC/rzPMxhWjbyNHrxfeJfXMUUPyPGmetDxet1V78hUWpy8=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7nt8OGkpdKPnBX+yuyCGt1GGuhLtlUZeC5bBYEENIAms7EQbO IwszZlIYFiIIK6lypR4LkKci5aKF70lIJFoglmdA5txN9kfOaAyiOub9 X-Gm-Gg: AfdE7ckAkdcowDXGHIHZNWQPafQ4iwzpL//LtYFEbTxLejLjELntvNPdHRA/6c1PLu1 jKQlDAo/ZWLpa02FuXWY5U+MS5MuOLWQ8VGFT4++X4sgqJNg4dKJa4njfr/VFWD5Wt3G430NDJA WInPdoiKWCKLbC44F/3eIJgno5dx/ppEiwd3DCU2QkdGfg2MI6zCQC2E0FGGqBDWoQ8KgiK3cY3 a1Xamjfrc8ePWl8YDAHHJeXM1JrTNhrq4IVbM7153C1e3Nxlte4c0l8GgD1UobOAooOAvaESvml LZu9L6YSrS5jFYDbsHyE6vh88kzwZqNwCWiiiQUZ5VJ+NvUD7xcKbe8I7lidt4+FL5814zpDDPU lbdv3xR01PZwmDwkZU3MU24DMg8p8zxrMEWxCIQ5WP83jAvTQtnXgCrzKJ0iBhuvszWA0i29KTX LDgZAZoC4I X-Received: by 2002:a05:600c:828a:b0:493:bc4a:fb51 with SMTP id 5b1f17b1804b1-493e68fe2b5mr17422695e9.39.1783505631397; Wed, 08 Jul 2026 03:13:51 -0700 (PDT) Received: from yocto.. ([195.72.110.74]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493e0faee30sm108987515e9.10.2026.07.08.03.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 03:13:50 -0700 (PDT) From: Abd-Alrhman Masalkhi To: song@kernel.org, yukuai@fygo.io, magiclinan@didiglobal.com, xiao@kernel.org, axboe@kernel.dk, vverma@digitalocean.com, john.g.garry@oracle.com, martin.petersen@oracle.com, abd.masalkhi@gatech.edu, linux-kernel@vger.kernel.org Cc: linux-raid@vger.kernel.org, Abd-Alrhman Masalkhi Subject: [PATCH v3 3/7] md/raid10: consistently fail atomic writes that require splitting Date: Wed, 8 Jul 2026 10:13:37 +0000 Message-ID: <20260708101341.473750-4-abd.masalkhi@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260708101341.473750-1-abd.masalkhi@gmail.com> References: <20260708101341.473750-1-abd.masalkhi@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit RAID10 currently handles one badblock path explicitly by failing atomic writes with EIO. However, another badblock path can also reduce the writable range and force the bio through bio_submit_split_bioset(), which implicitly completes the bio with EINVAL. Fix this by handling atomic writes in the common split check. If RAID10 determines that an atomic write would require splitting, complete the bio with EIO. Fixes: a1d9b4fd42d9 ("md/raid10: Atomic write support") Signed-off-by: Abd-Alrhman Masalkhi --- Changes in v3: - No changes. - Link to v2: https://lore.kernel.org/linux-raid/20260628142420.1051027-4-abd.masalkhi@gmail.com/ Changes in v2: - Drop the early atomic write split check from raid10_write_request() and rely on queue limits instead. - Link to v1: https://lore.kernel.org/linux-raid/20260623072456.333437-4-abd.masalkhi@gmail.com/ --- drivers/md/raid10.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index bd322eccdc3f..3480fc7907f0 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1356,6 +1356,7 @@ static bool raid10_write_request(struct mddev *mddev, struct bio *bio, int i, k; sector_t sectors; int max_sectors; + bool atomic = bio->bi_opf & REQ_ATOMIC; if ((mddev_is_clustered(mddev) && mddev->cluster_ops->area_resyncing(mddev, WRITE, @@ -1464,16 +1465,6 @@ static bool raid10_write_request(struct mddev *mddev, struct bio *bio, if (is_bad) { int good_sectors; - /* - * We cannot atomically write this, so just - * error in that case. It could be possible to - * atomically write other mirrors, but the - * complexity of supporting that is not worth - * the benefit. - */ - if (bio->bi_opf & REQ_ATOMIC) - goto err_handle; - good_sectors = first_bad - dev_sector; if (good_sectors < max_sectors) max_sectors = good_sectors; @@ -1493,6 +1484,9 @@ static bool raid10_write_request(struct mddev *mddev, struct bio *bio, r10_bio->sectors = max_sectors; if (r10_bio->sectors < bio_sectors(bio)) { + if (atomic) + goto err_handle; + allow_barrier(conf); bio = bio_submit_split_bioset(bio, r10_bio->sectors, &conf->bio_split); -- 2.43.0