Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6526703rwr; Tue, 9 May 2023 17:05:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ZMIzs2Ww8L78XFJJhL9jPTrxYq6N7DhSH6vyWDWWfCyU2dVW5mwNWfSKs+1RFCLlOq1OM X-Received: by 2002:a05:6a20:6a2a:b0:f4:d4a8:9c82 with SMTP id p42-20020a056a206a2a00b000f4d4a89c82mr18666326pzk.47.1683677132850; Tue, 09 May 2023 17:05:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683677132; cv=none; d=google.com; s=arc-20160816; b=gl4wMFqMGZnQ7xZFYEhRC0+hWzpIPdtgihHhpklZv+kbQm7SES3I06CzoOWeCaRhiz b4KlOZWULQy+wSqqRDzZsauRrdrSN33mXoIebqWhGONYk3WAkajpv8Zh88HbyziowRrK cWnDOCC+0yxCdkJnzwX0DGZcSS85d32zcKdfBgADRDHIcxIkGBfRPgqCw7cmU+YQCBs7 2VfhGawZsh0VtgrYlz45b4+FR1g1z+YMfqkMrCBp64KPcBY/VfAjd4NwVtY0r8uNsLUz c8wgvvGFjY32c+/d1awj0xstOZ4BIMxqXfSUkKJg9jWN7SoxsG7MDR0UELrg6diTKmiN t/dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=HhUCLQ7ZrV4DdwmSYqQPD67Er0hUj9pRQQE02cLTraE=; b=hMOhlX3ckO/r+8DngZdnCVHXE0Lu8LR07Tn6ZgHeCijfclfmcvO+CKk87smtt6xtMz 7hWh5+JcOkiel8mtPjYtQR3Rx2l1mSP3LNIfUvSFJKbB6d19nZJ4xcZi27vfrRDa1q8g 3tWvWcpq408QbI3p2PZgVkHNYsLmxIEEjU5gPXyOqBUdA4m/txDlpb+KUJCUCxqSBwtZ eNHUCzTIkeYjl2r5tPLrfxX4RbesmI2Ua1jUMsVweUF+4MrQm0eqjtSuwwrJy4oASAXf FRn2UnskctXEJ3vYb6dYnz+kNba4dLVGfmMz6jwdZfFNc+gy3MBXaXIka+u9vdQS6CCQ p7dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=HYlSoj8l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d21-20020a637355000000b005303c098a92si2841524pgn.346.2023.05.09.17.05.17; Tue, 09 May 2023 17:05:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=HYlSoj8l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233875AbjEIXrZ (ORCPT + 99 others); Tue, 9 May 2023 19:47:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjEIXrY (ORCPT ); Tue, 9 May 2023 19:47:24 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 225184EE8; Tue, 9 May 2023 16:47:23 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-24e4f674356so5985186a91.3; Tue, 09 May 2023 16:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683676042; x=1686268042; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:from:to:cc:subject:date:message-id :reply-to; bh=HhUCLQ7ZrV4DdwmSYqQPD67Er0hUj9pRQQE02cLTraE=; b=HYlSoj8lwXn3BKBpO43qLwd3E57tBWEEWoH3hpWLiodFlmVTEMmMK6MFJQzhqrBMpb r+8nDbjpBW+lcdbBcDbskrzit9BDCx73TQihePoy8Y0CMeuypXEyk//OwrfHPBlZS4E0 KgYUf+32y88Dg6gSFzQSvlaPwv3rxhpjSKI7ayRt6cDWe+1YCbiqWYW+2NHolgOBDHfl ilAEj4rwYiGpoe7FmOunUmDORouIjhQUGDH4hyB2q9qqVMB7m9awV3ucNfVbJOYl8FKj oQ30szT7yNmp0cdkv50oX5QMp2jIuJAimplVz7H6QkusaWUsEqq/eJxp00/uKXU3E4jV Kx0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683676042; x=1686268042; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:sender:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HhUCLQ7ZrV4DdwmSYqQPD67Er0hUj9pRQQE02cLTraE=; b=XaEYFGCcMRp385P1/8z7b8KWpNjlUZNG2uDqsFYOttwqvFPo5SVG4/y88LmhM58qte MHROzHXeJWbNJyQsa97YDLxFWZFhjSiFvoXu5o/PUgVgeGMAHZrVhtGEcjn9r5LB78p0 7vYX2C0acLEasChIKCR7DMGxUsy/MdmiuThRU4eNHtu8qKC4GIIWF2RIV3B8i7Zk2e5w 0KMrk1P+A7LVwDzm3OzR2n6O3R0IAMrEUbsmxsgfn3ArTxrmmqo/PBfe68uWzV8pFmk2 /75oxh1I9EYEpUrDbmQwi7H5kT9DimCJJ6NnK9yHaBq5Hwu77yuZGsilAtEfPd5pGbzl uHCw== X-Gm-Message-State: AC+VfDz/RVtaTIofZrdFEjD3krbKoiOg7BT6YEejxIuh8fFNCzYMiq/0 +KgJMkU2svZ6fkpfacfT/os= X-Received: by 2002:a17:90a:9c07:b0:250:1961:f6b0 with SMTP id h7-20020a17090a9c0700b002501961f6b0mr15837259pjp.32.1683676042217; Tue, 09 May 2023 16:47:22 -0700 (PDT) Received: from localhost (2603-800c-1a02-1bae-a7fa-157f-969a-4cde.res6.spectrum.com. [2603:800c:1a02:1bae:a7fa:157f:969a:4cde]) by smtp.gmail.com with ESMTPSA id y10-20020a17090a474a00b0025063e893c9sm5469929pjg.55.2023.05.09.16.47.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 May 2023 16:47:21 -0700 (PDT) Sender: Tejun Heo Date: Tue, 9 May 2023 13:47:20 -1000 From: Tejun Heo To: David Sterba Cc: jiangshanlai@gmail.com, linux-kernel@vger.kernel.org, kernel-team@meta.com, Wang Yugui , Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org Subject: Re: [PATCH 08/13] btrfs: Use alloc_ordered_workqueue() to create ordered workqueues Message-ID: References: <20230509015032.3768622-1-tj@kernel.org> <20230509015032.3768622-9-tj@kernel.org> <20230509145332.GA32559@twin.jikos.cz> <20230509233620.GN32559@twin.jikos.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230509233620.GN32559@twin.jikos.cz> X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, David. On Wed, May 10, 2023 at 01:36:20AM +0200, David Sterba wrote: ... > Yeah I think so but I'm not entierly sure. The ordering for all queues > that don't start with max_active > 1 should not be required, here the > parallelization and out of order processing is expected and serialized > or decided once the work is done. > > > > In btrfs_resize_thread_pool the workqueue_set_max_active is called > > > directly or indirectly so this can set the max_active to a user-defined > > > mount option. Could this be a problem or trigger a warning? This would > > > lead to max_active==1 + WQ_UNBOUND. > > > > That's not a problem. The only thing we need to make sure is that the > > workqueues which actually *must* be ordered use alloc_ordered_workqueue() as > > they won't be implicitly treated as ordered in the future. > > > > * The current patch converts two - fs_info->discard_ctl.discard_workers and > > scrub_workers when @is_dev_replace is set. Do they actually need to be > > ordered? > > > > * As you pointed out, fs_info->fixup_workers and > > fs_info->qgroup_rescan_workers are also currently implicitly ordered. Do > > they actually need to be ordered? > > I think all of them somehow implictly depend on the ordering. The > replace process sequentially goes over a block group and copies blocks. > > The fixup process is quite obscure and we should preserve the semantics > as much as possible. It has something to do with pages that get out of > sync with extent state without btrfs knowing and that there are more such > requests hapenning at the same time is low but once it happens it can > lead to corruptions. > > Quota rescan is in its nature also a sequential process but I think it > does not need to be ordered, it's started from higher level context like > enabling quotas or rescan but there are also calls at remount time so > this makes it less clear. > > In summary, if the ordered queue could be used then I'd recommend to do > it as the safe option. I see. It seems rather error-prone to make workqueues implicitly ordered from btrfs_alloc_workqueue(). I'll see if I can make it explicit and keep all workqueues which are currently guaranteed to be ordered ordered. Thanks. -- tejun