From patchwork Sun Jul 9 10:29:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueshi Hu X-Patchwork-Id: 13305799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A12DC001B0 for ; Sun, 9 Jul 2023 10:30:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbjGIKaK (ORCPT ); Sun, 9 Jul 2023 06:30:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbjGIKaJ (ORCPT ); Sun, 9 Jul 2023 06:30:09 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 463F7F4 for ; Sun, 9 Jul 2023 03:30:08 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1b852785a65so22342785ad.0 for ; Sun, 09 Jul 2023 03:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20221208.gappssmtp.com; s=20221208; t=1688898607; x=1691490607; 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; bh=Gs/McJuB6h4mc7keVidPugoMclhLpdnhZvr1zie07xI=; b=Gemao1RHEYh1BL47dzs4ObslG4pm02SpOAmLDNurZLVFFiKUS8qDVgqTIlL6sntWoo /8E6tJ7h8eRJm2Fv2gX2E5xIggJ8JdmG325kWTLHaOe+GyrWmlkTKHm0JaFZ+fSMqomE l2BgkRyBUNv46DpBCTM3HAWuIzlvMgS5+8PCJvP/RW+vcI7xbVOTy4w20S5PiwA/y6iz SthRMq4t7K/07Yq9z505aAV3uG5iBpJKZHAoQUqD+aupk+zBWokkho+VpAwf1miK+zSz DIpwqACDzO0nJnv2et0soTLZd4S+64duT274AgZoqqSXVTIB+TuPxawByia9bqHnW68E x6jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688898607; x=1691490607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gs/McJuB6h4mc7keVidPugoMclhLpdnhZvr1zie07xI=; b=YBCZuJNxSDo5DsiAmggaKXYkUrnnXDZA8nYPpbqM9lCkv/cypK3MwlGOgtLs5w2sm+ qqMHHJivse53dsqIkrDHzWVZjt/dP4FnS3gUTNsCp70MSr3ik16tPKde/ic9HwPXeUIn k8nZ7ogOXgIc99QvE1j5/trVlWqg3lR2s2kLdFMXtsZAnwxtHPHh62OVh2VCiCzy2J3l TbWtaEVzpSYniTgTX9tD+CcO1Na5UevOqV7cfFeLrhInrzRwj8XUcKyNeHgLE0ej/kBi uk8n5qW2q7cWDzi+jyFtlDE7UCjnQYtXMNqBMtLt4jRm0enVZRPpIB9DEgpWNFp7gGdq MxMA== X-Gm-Message-State: ABy/qLZZCsZ4ePy+/cANXENe24GvmdsWPBI35hPVE4G3C65RiFd/DgEw uiJYiyPIklmBR5htT9PYyNkIumLXlnY3hamZRO0ZbmvyLMZZZQ== X-Google-Smtp-Source: APBJJlFJMdK68NBuGx+ZKJDoGqi8wII4rEOmMKEkEW9Scd29R2zxcO1tRj3B5zfHDjTDZxnCOVxodA== X-Received: by 2002:a17:902:d2c1:b0:1b8:6245:1235 with SMTP id n1-20020a170902d2c100b001b862451235mr20467917plc.13.1688898607529; Sun, 09 Jul 2023 03:30:07 -0700 (PDT) Received: from localhost.localdomain ([47.75.78.161]) by smtp.googlemail.com with ESMTPSA id i19-20020a170902eb5300b001b9be2e2b3esm4479140pli.277.2023.07.09.03.30.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 03:30:07 -0700 (PDT) From: Xueshi Hu X-Google-Original-From: Xueshi Hu To: song@kernel.org Cc: linux-raid@vger.kernel.org, Xueshi Hu Subject: [PATCH v2 1/3] md/raid1: gave up reshape in case there's queued io Date: Sun, 9 Jul 2023 18:29:54 +0800 Message-Id: <20230709102956.1716708-2-hubachelar@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230709102956.1716708-1-hubachelar@gmail.com> References: <20230709102956.1716708-1-hubachelar@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-raid@vger.kernel.org From: Xueshi Hu When an IO error happens, reschedule_retry() will increase r1conf::nr_queued, which makes freeze_array() unblocked. However, before all r1bio in the memory pool are released, the memory pool should not be modified. Signed-off-by: Xueshi Hu --- drivers/md/raid1.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index dd25832eb045..ce48cb3af301 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -3298,6 +3298,13 @@ static int raid1_reshape(struct mddev *mddev) freeze_array(conf, 0); + if (unlikely(atomic_read(conf->nr_queued))) { + kfree(newpoolinfo); + mempool_exit(&newpool); + unfreeze_array(conf); + return -EBUSY; + } + /* ok, everything is stopped */ oldpool = conf->r1bio_pool; conf->r1bio_pool = newpool; From patchwork Sun Jul 9 10:29:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueshi Hu X-Patchwork-Id: 13305800 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB598EB64DC for ; Sun, 9 Jul 2023 10:30:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230350AbjGIKaO (ORCPT ); Sun, 9 Jul 2023 06:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbjGIKaL (ORCPT ); Sun, 9 Jul 2023 06:30:11 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0D38F4 for ; Sun, 9 Jul 2023 03:30:10 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id d9443c01a7336-1b8b4749013so26103835ad.2 for ; Sun, 09 Jul 2023 03:30:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20221208.gappssmtp.com; s=20221208; t=1688898610; x=1691490610; 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; bh=7Ccj+V99OsZYt0ldTU5RVfYP8EjPvEfZb6DbZd35Eoc=; b=ybBVPdV7Vc52gtsxPFrU/VJ2oQlDH5V4bRY/bGlIBprZq8PaKIwLeP8gxAKbu1hJFn eOQ6BRUgN/YNeUbdqYN/byob1iB8s7KC/Bsav56k8ZBy4ApkzIQUuWsOgsaKEdNb7iZ3 F+7Y1blC68iM0XgE4ftq64BJhEufnD6IuP/0BxFqpFkpyIq/q3RWR1qinhryG8xS7jyj pfo9YlVPnL0m5yFLCKoZ+owfB/fLAITDfO9TjC+QKbyxmNSNbZmegkmwVDcsF+gpi7g+ Bo7FYxHQzS4PQnYDpH1mK0hY6FdIwrVGiNhBZbcS56tPHClyR+u187bezJ1C9hLjWNvX cdFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688898610; x=1691490610; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7Ccj+V99OsZYt0ldTU5RVfYP8EjPvEfZb6DbZd35Eoc=; b=c6heKSLEJQOt8mOObwenM2FdPY6Ed+oRIUzkwkF3Ls+u0t5Fnh10gysGbCl441UJhf 0C0IOMmSFteS6dwT08s3TiGKM4Od0ZiAvvP+wPXUTh0uso3DY+nFzdkUZ3SF3a0hL0Qt PX5+R7VMt/owYqe2r0QwAfblKYqJS18OWDQ084HdS7ghyq8SZoe42RR0BSKJr2FogZZq DsisiLBs/jo9tTHM8U1zCkrBVmBnvM/3t+lx69DGZd6wT8b5M3fB3aiiDi/N/QF2NFKc KR9R3dCGq3bkL8SdS3hopJkIYkzDg0iyl4nGX7Q9dYWS43Cfz4djX2SijsHL4heACO8j Pr/Q== X-Gm-Message-State: ABy/qLauSHiKfKm+irZJxUQYeUB8p5eo9EhIw+xbLVIzUTz0FgoHIeU2 p6Yi30noq8rUdxCUW1LM1brU0g== X-Google-Smtp-Source: APBJJlEe0M0R0jtmZBN7ZkhyQlNkIz/U587kbkF41VG4wdE4gAeCwIsO1rfNv4sgso3A8oVXZRX2Lg== X-Received: by 2002:a17:902:d3c6:b0:1b8:90bd:d157 with SMTP id w6-20020a170902d3c600b001b890bdd157mr9195703plb.26.1688898610446; Sun, 09 Jul 2023 03:30:10 -0700 (PDT) Received: from localhost.localdomain ([47.75.78.161]) by smtp.googlemail.com with ESMTPSA id i19-20020a170902eb5300b001b9be2e2b3esm4479140pli.277.2023.07.09.03.30.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 03:30:10 -0700 (PDT) From: Xueshi Hu X-Google-Original-From: Xueshi Hu To: song@kernel.org Cc: linux-raid@vger.kernel.org, Xueshi Hu Subject: [PATCH v2 2/3] md/raid1: free old r1bio before retry write Date: Sun, 9 Jul 2023 18:29:55 +0800 Message-Id: <20230709102956.1716708-3-hubachelar@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230709102956.1716708-1-hubachelar@gmail.com> References: <20230709102956.1716708-1-hubachelar@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-raid@vger.kernel.org From: Xueshi Hu allow_barrier() make reshape possible. Raid reshape changes the r1conf::raid_disks and mempool, so free the old r1bio and alloc a new one when retry write. Signed-off-by: Xueshi Hu Reviewed-by: Yu Kuai --- drivers/md/raid1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index ce48cb3af301..6c54786067b4 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1373,6 +1373,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, return; } + retry_write: r1_bio = alloc_r1bio(mddev, bio); r1_bio->sectors = max_write_sectors; @@ -1388,7 +1389,6 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, */ disks = conf->raid_disks * 2; - retry_write: blocked_rdev = NULL; rcu_read_lock(); max_sectors = r1_bio->sectors; @@ -1468,7 +1468,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, for (j = 0; j < i; j++) if (r1_bio->bios[j]) rdev_dec_pending(conf->mirrors[j].rdev, mddev); - r1_bio->state = 0; + free_r1bio(r1_bio); allow_barrier(conf, bio->bi_iter.bi_sector); if (bio->bi_opf & REQ_NOWAIT) { From patchwork Sun Jul 9 10:29:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueshi Hu X-Patchwork-Id: 13305801 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F8BCEB64DC for ; Sun, 9 Jul 2023 10:30:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230354AbjGIKaS (ORCPT ); Sun, 9 Jul 2023 06:30:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230351AbjGIKaO (ORCPT ); Sun, 9 Jul 2023 06:30:14 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0FA2F4 for ; Sun, 9 Jul 2023 03:30:13 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id d9443c01a7336-1b7e6512973so21804555ad.3 for ; Sun, 09 Jul 2023 03:30:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20221208.gappssmtp.com; s=20221208; t=1688898613; x=1691490613; 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; bh=6TNN9QkcmsO3KPgQ0QUmXwgC+bPcPHbUo8MbhwOskXA=; b=U2Z5xK6Gd4yg15x3O3BkvRhUyi/0KlDT3nXifbyDMaO1ymSr7R3QXn6ggAwNKGvkeq dFgJDhdZT3xUJEruULDOBcqoH0+4j+B/D0kigDdJNQ6x5mVYxDLOtCB8l4bVkwhKl8sQ ADL4+qy5bDaaWA+lsJCiHroQ6bJMVl4A7A2bL8SkXkb/5KT75dLIFXHDSrYHyRZdhN4V HU4ol4Am53sSGg4la2usEIevnPh7sqMbsNNLeK2KnB34vcZg5wph4eVSr0h7guIE1PHJ zI/KgkPx/P6LiZvZSyISR33hUN3pAGajTd9LFy1OtHms+P1XL+arhum9u2pZQfOm+liH /MmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688898613; x=1691490613; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6TNN9QkcmsO3KPgQ0QUmXwgC+bPcPHbUo8MbhwOskXA=; b=QJqgKzo7/9thahavDvm3zIMmpGLz7Ta1lTLRoq4c003xJ8h/bHq8a+xgfkJcvBMI3d mi6mCQnSdGVTYM0RzXDMFuxm1vhscGnMaPy8O26crbVxN5TBDK2X/77xrDhn5hKZdP92 ugLlBr6G/JFR8ThU+lz0N9B8weMHkOFfu09B+Py8QoXNW+DG5PWPvwErv2MSyGTgt+87 Gza0pt3flNgjfVZE1HdCuA7qJTT2kNMZjpZz3Dfr5d69NPyEGEFjJrc+pq9jnNy7BGTf TJFHCdCs6euJ0qEYuTGmH00G6jqbmfbYG4Tg4XHVgL6Uk3mmnXCdG7tWqozH88wd3eOW hWwQ== X-Gm-Message-State: ABy/qLaYLcQ7VJhSIt7lxoVRMIFRPK5LpRVJRVKOM8BBfgLX6OZ8Hzba Hb90a/OgCNnA/rA7GhTj1uk6b6ZAKpY3hxlSEj9UYAKDCnwgTYXn X-Google-Smtp-Source: APBJJlGD5F7LVnxIKEo1rFVhnZq8DCXM1TeLnpbZZaCyWB3juvOL3V0pm0BpHkWIeQvCFopqlpiVsw== X-Received: by 2002:a17:902:edca:b0:1b6:ab53:c7a5 with SMTP id q10-20020a170902edca00b001b6ab53c7a5mr7432716plk.46.1688898613162; Sun, 09 Jul 2023 03:30:13 -0700 (PDT) Received: from localhost.localdomain ([47.75.78.161]) by smtp.googlemail.com with ESMTPSA id i19-20020a170902eb5300b001b9be2e2b3esm4479140pli.277.2023.07.09.03.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jul 2023 03:30:12 -0700 (PDT) From: Xueshi Hu X-Google-Original-From: Xueshi Hu To: song@kernel.org Cc: linux-raid@vger.kernel.org, Xueshi Hu Subject: [PATCH v2 3/3] md/raid1: keep holding the barrier in handle_read_error() Date: Sun, 9 Jul 2023 18:29:56 +0800 Message-Id: <20230709102956.1716708-4-hubachelar@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230709102956.1716708-1-hubachelar@gmail.com> References: <20230709102956.1716708-1-hubachelar@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-raid@vger.kernel.org From: Xueshi Hu Raid reshape changes the r1conf::raid_disks and mempool. Keep holding the barrier in handle_read_error() to avoid raid reshape. Signed-off-by: Xueshi Hu --- drivers/md/raid1.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 6c54786067b4..43a9c095f94d 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1240,20 +1240,20 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio, rcu_read_unlock(); } - /* - * Still need barrier for READ in case that whole - * array is frozen. - */ - if (!wait_read_barrier(conf, bio->bi_iter.bi_sector, - bio->bi_opf & REQ_NOWAIT)) { - bio_wouldblock_error(bio); - return; - } - - if (!r1_bio) + if (!r1_bio) { + /* + * Still need barrier for READ in case that whole + * array is frozen. + */ + if (!wait_read_barrier(conf, bio->bi_iter.bi_sector, + bio->bi_opf & REQ_NOWAIT)) { + bio_wouldblock_error(bio); + return; + } r1_bio = alloc_r1bio(mddev, bio); - else + } else init_r1bio(r1_bio, mddev, bio); + r1_bio->sectors = max_read_sectors; /* @@ -2527,7 +2527,6 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio) } rdev_dec_pending(rdev, conf->mddev); - allow_barrier(conf, r1_bio->sector); bio = r1_bio->master_bio; /* Reuse the old r1_bio so that the IO_BLOCKED settings are preserved */