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 EF15236B043 for ; Tue, 23 Jun 2026 10:06:12 +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=1782209174; cv=none; b=sx+XRfhyP6+vaLuwomyKW6Htwxu89HWzl8ynqtiEo9SkpQCbpXc23Sx5gjnTj7RNHKz6iMQMc68FNbl3vhDcuoiRqxFTgl28t91en9OuRFVbIo3orzd2Lm3jvy39Vyk8hwfzWixhX/d8Qcyd4wrBNENpE/yWtsR+adQMFgNUDgc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782209174; c=relaxed/simple; bh=IeCcvLfEXXfbac5s+Vn9SHrII3bh9+V9Maa+KrWFHm8=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=u25HMMVJOY9BARuwUOB/q/WWGwI6oB8n6mmGWdbwZHePCFtnuCTEmySgoarGN4YNcalxi2lyz8a5PaqsrlkVBPrYYjNJeuN+8ziwRs2q7nl52IgqvlhKMya97St/zpr4+mxyvHE6YXgAfwBGA3nwHE7VmX+8MTCNZG4Yia7qrE4= 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=rm7d5FoA; 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="rm7d5FoA" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-462cdb88d01so566793f8f.0 for ; Tue, 23 Jun 2026 03:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782209171; x=1782813971; darn=vger.kernel.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=8BFdELiiAWXtyV9jq5igUjkjNq2N/STvSc6HvxYwA4E=; b=rm7d5FoA9C3R1RWeMMzypWWZNkakjyo0VgyWu5NLWQaKXOTT41yJ4AfrLRZzjNXS2F y66wkI5P2j8w/ejBHZNhOu6xwz+j5t8eLpczoh/sGVH8c9IPVedfMvDQkr1g8ZfpZ5tP cXu92hAA/NNSAGxERaVGPQfyPuvNjyRObYwlsMEeOBM/RqaD/J+XRFKHnO7pc4MaILRF jZEkBpYlGnZYHH6tW4Rym4K+ciRH9DbI+iznFq82jSuldnSmoFQcUC9Y5wmGHXQtx29R Zs41yKW8HuwRF0gDu7muUb/r9Dmtv3HjUdefkfKxjQUzWvXYNhn85x7a7caTOgIWiATP d2NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782209171; x=1782813971; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8BFdELiiAWXtyV9jq5igUjkjNq2N/STvSc6HvxYwA4E=; b=rFGlOpUwEcNL2djyCO+RELfQ5+JN+6fdBVoJtRBd658hu42M84/AhJkeunjAQ4kAoM aM0FIB32ZYADvaYHYBgk77GKXOUoS0WbHUqcphZkHo6FgoxmW1jDyYf189SAu6a0ZLgI fJSO7Umvuw61iwsCOou8G2VI8gwpgNX81v4BkgeBh4D1BUXQ7rDHhHtsKQFMAyog1QK5 nDNJRyrZGk01PnIWULZVr+pCFq2QK1egQHTayz2Bxmuhf5GB0hDwz5PkGzzRZeoQkLfj zXTrxmBzfotq30sygYlrWFcnZ0hRn/Mh4bOH3hsA8excRzkfk7TvfAKV2T4T5ANC9Sw8 ctnQ== X-Forwarded-Encrypted: i=1; AHgh+Rojb0sXCxnfFvpt999K/Wm5FzKVBT/2aDNlhqFGO+kaBXZv3q9aft8h4ilPmjUGbQOfAB6Vc5fUgE5uyPc=@vger.kernel.org X-Gm-Message-State: AOJu0YwCtW5suzNQhDdJfh2F9dVDjopWJmHKZc5nzMJXhk4/76Eyeyoj vCONBg5ZI1USKDDrUEQIm5pPWHok/8PqEGhNDpFfkmaeBWXvbNja85sDB8+vkw== X-Gm-Gg: AfdE7cnk+AKDycM23qGl92EkGK6RswI6012vkE3NTtjkpKImgqUMdknV8sEu3d+Wo1p MoG9LAO74EsN7RQe2gIkssfJpFoYicfZWmDH05TOnMSPiHceljGqRA0QEk3HesNZkyk61EJCSfE s4G8nRHPTEfQKgxY0Wm3E47s8+WfTtNq/FZRCNf+cPMaWN5UqzyxOO1jgK0GcBn3G9WHq7hGbXP hGpk+JZRPG/waidI7QfuLfcj5dC6sNgJcpCKAk8o9uPZt/HgQCIb81805CJtnw0Pg/mxuL2R5Sx EQsUJufRmEebWWJ99IKTkNAnCyrQ2cl5Xjr/PQWfvnniVngZx6NMJP43ztjdeyc7jHJ27mF2xJY V/OKaGIB+fFrYFGVJiwyjFqDrBXADSrk1m27l0klDqB5vDUO5LBzMnmLCgpyifh/JeHrGdyPVyE znm5Zt3qV/hSbZIbXr9UHP6VRs+E413XKBxFQtN5ChE77Iosdesfd8kI0v X-Received: by 2002:a05:6000:250a:b0:463:3184:6310 with SMTP id ffacd0b85a97d-46a80f5c67amr4920142f8f.28.1782209171167; Tue, 23 Jun 2026 03:06:11 -0700 (PDT) Received: from Abds-MacBook-Air.local ([141.2.113.173]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-46666788226sm33996976f8f.23.2026.06.23.03.06.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jun 2026 03:06:10 -0700 (PDT) From: Abd-Alrhman Masalkhi To: John Garry , song@kernel.org, yukuai@fygo.io, magiclinan@didiglobal.com, xiao@kernel.org, axboe@kernel.dk, martin.petersen@oracle.com Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/7] md/raid1: handle atomic writes that require splitting In-Reply-To: <6130d0cb-4cf8-4042-843e-98a9d8aa00c5@oracle.com> References: <20260623072456.333437-1-abd.masalkhi@gmail.com> <20260623072456.333437-3-abd.masalkhi@gmail.com> <6130d0cb-4cf8-4042-843e-98a9d8aa00c5@oracle.com> Date: Tue, 23 Jun 2026 12:06:09 +0200 Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Tue, Jun 23, 2026 at 10:20 +0100, John Garry wrote: > On 23/06/2026 09:58, Abd-Alrhman Masalkhi wrote: >> On Tue, Jun 23, 2026 at 09:11 +0100, John Garry wrote: >>> On 23/06/2026 08:24, Abd-Alrhman Masalkhi wrote: >>>> If a request already requires splitting when entering >>>> raid1_write_request(), the current code allows it to proceed until it >>>> eventually reaches the split path. >>> >>> The block layer should catch invalid atomic writes in >>> submit_bio_noacct() -> blk_validate_atomic_write_op_size() before we >>> even get as far as the md atomic write handling. Having the check in >>> bio_submit_split_bioset() is really just a fail-safe for the block layer >>> not catching invalid atomic writes or the atomic writes queue limits not >>> being properly calculated. >> The request size itself satisfies the currently advertised atomic write >> limits, so blk_validate_atomic_write_op_size() allows it. The problem >> is that RAID1 may further restrict atomic writes to a single barrier >> unit via align_to_barrier_unit_end(). Therefore a request that crosses >> a barrier-unit boundary can still reach raid1_write_request() with >> max_sectors < bio_sectors(bio). >> >> If the barrier-unit restriction should instead be advertised through the >> atomic write queue limits, > > It should. Any restrictions should be advertised up front. For the user > to issue an atomic write which is valid according to limits, then it > should succeed. > I'll take a look at how best to expose that through the queue limits and rework this part accordingly. If there is already an existing mechanism you had in mind, I'd appreciate any pointers. >> then I agree the block layer could reject >> such requests earlier and the RAID1 entry check would become >> unnecessary. >> >> However, there are also cases where max_sectors is reduced later within >> raid1_write_request(), for example when bad blocks are present on some >> mirrors (or due to other RAID1-specific constraints such as write-behind >> limits). Those reductions depend on RAID1 runtime state and mirror >> health, so they are not readily visible to the block layer during atomic >> write validation. In those cases RAID1 still needs to detect that the >> atomic write can no longer be serviced as requested and fail it >> appropriately. > > Sure, and we do this. As I remember, we should return -EIO in this case. > Right, and that's the main motivation for this patch. The original atomic write support already returned -EIO for one bad-block path, but there are other cases where max_sectors can be reduced (e.g. the first_bad <= sector path and write-behind limits) After a4c55c902670, those cases can end up completing with EINVAL or NOTSUPP instead. This patch is intended to restore consistent -EIO. >> >>> >>>> Along the way, the bio may instead >>>> fail due to other conditions and return a different status, even though >>>> the request was invalid as an atomic write from the beginning. >>>> > -- Best Regards, Abd-Alrhman