Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1965366pxv; Sat, 24 Jul 2021 00:43:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6gIE/Myv/fgJBiclqjD8NJTOs5KXE0RArqJZc0IzYWwuTvwNbNBr8Ur5VTDQo6USws8UI X-Received: by 2002:a17:907:62a1:: with SMTP id nd33mr8099270ejc.303.1627112610045; Sat, 24 Jul 2021 00:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627112610; cv=none; d=google.com; s=arc-20160816; b=zPXrqK0a5rklQ4gqcjaF4lNMK1xF5BTaFY4xvhLDi/Ov60ZHP9/0lY+lR5Lgb24N1f EZZ7rdRCE/fXHXWX73Nuy2cWs3+T39Y7NvSQrnmjtHNGYGb0DXX1OU7E1l93sg7ZdXD3 hNS8ngouApstlqocfe4bH8tj4hpKS3dAXUIshdZ22PUdu7QPzonMPRJZ1oFgJSRCVcDx 2XSUWgp2inQOV9mvWjG1sWW/LA+JBahkEWbmvT2UTFzzTf3PJt5008PIgud/yAsAxIoz c8IJ8n8W8sRGb7cUxLXRl9qaO4pCfFGyItUocfGXRRbM9RBNIB89QH1UI19E9seqGexm MYHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=twUaPKjfnsTbPfe/CmNFMyhlSHASSr5iLxR8bOidA5A=; b=kDuXlMNCjz40IQ5kinIY7fR9LPMHfTa47uNSIfUXcWKeHr1ZPPLku/UMiRuFyaNAWX XE9HZgj4x6BgmjgsOqETbWZOUg0MrEoBIvsdarzDSlKA6jPMPoGdzViIfPV38BMIpBNN ynt790lcKYF/axV+0u6tB8RhLKuqJQj6aO0rXi97TNHvO4Qwo/eFhP1h4k/Zrn5mnyPS 0j1O5WMSsagV4TlMaxsPDhfxVBf9NEDVTPMrw6qhxzDKX+vTurDapsKk1yd6l2hAj1sk 2rQBWwnF53NyTYH6l1tsFnxteUkBnosvt/QwDZuwXDRiWyRubJlO5dJSqmfxJzv7Uun0 Cr0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o7mQ8POD; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b24si14399035ejg.403.2021.07.24.00.43.00; Sat, 24 Jul 2021 00:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o7mQ8POD; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234266AbhGXHCX (ORCPT + 99 others); Sat, 24 Jul 2021 03:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234105AbhGXHCX (ORCPT ); Sat, 24 Jul 2021 03:02:23 -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 E25F5C061575; Sat, 24 Jul 2021 00:42:55 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id m2-20020a17090a71c2b0290175cf22899cso6864364pjs.2; Sat, 24 Jul 2021 00:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=twUaPKjfnsTbPfe/CmNFMyhlSHASSr5iLxR8bOidA5A=; b=o7mQ8POD3B3LbIiiTNfgjfHjEJJogE3MNiEH8WwLDkynOD/iMguWhoOIUu5m3ClKor PbdSuui+Pb/CWwk6K29Q13d4AszKVMVxk+lFEZmRKM1mT7NyPG9S4UsNsuTZiWOvQhf3 QvXtnUo8GndHhzG7HwaJ9KHQ0zWQ0gHEtHTNMB6ekDc4OGYKjzdth0bXLWItSgJMJj4z PsrQG+moazZ0lrQZDNGnpWJTGoECvT2kGyGv6JNcDx+MFtKqdO4Q2lu0GkuE9zgNOemk O+kozV8fmoCB75z4IMG1NRK1+1DeqMEh4ZSiCLna5JM+2+MlMjjwhH7YNYDpdlSd0IW8 4i8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=twUaPKjfnsTbPfe/CmNFMyhlSHASSr5iLxR8bOidA5A=; b=jW7i3uvXZJBU3rQx2kZghprFVDiZUJsW0gRKbGFKtpNk3Jp4xlgLSkiSOxhzhUbX+Z hgJVzwqecQB3OHFmlIj/wyh9zkQxBVPPXaT0VVblqMzkb+6npVf7XkgP+UgrLs7+yZlh 702W2LRXBeUG129gpV7HvsDlSfDGPiGcUaVToPQT52jVdysEm5C+yJWRCW5WP8g2Dh5k lwqMcX36SF4xu0THxoF/01KQOEt4Gbxuy5jkzNohhe0uLyQFQgf8qQ4JjHtHf4a1QC/L m25BxKP0rflGJBp2WxW4INjKp8TUMxxNnXZQ59NUUiI/xj5RPd5DoqdX7ao3ouqMyGao aWJA== X-Gm-Message-State: AOAM530copv/+7LLoGs5vp0CZmvtfsNbpFgvyWNxoUtA25nGBUSzfb2Z RVHzZZcoPq1y6lEQLVhs0oTW4tC/h/XdMg== X-Received: by 2002:a63:5903:: with SMTP id n3mr8506382pgb.104.1627112575474; Sat, 24 Jul 2021 00:42:55 -0700 (PDT) Received: from localhost.localdomain ([154.86.159.244]) by smtp.gmail.com with ESMTPSA id v31sm33002342pgl.49.2021.07.24.00.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 00:42:55 -0700 (PDT) From: Wang Jianchao To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Cc: tytso@mit.edu, adilger.kernel@dilger.ca Subject: [PATCH V3 0/5] ext4: get discard out of jbd2 commit context Date: Sat, 24 Jul 2021 15:41:19 +0800 Message-Id: <20210724074124.25731-1-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hi all This is the version 3 patch set that attempts to get discard out of the jbd2 commit kthread. When the user delete a lot data and cause discard flooding, the jbd2 commit kthread can be blocked for very long time and then all of the metadata operations are blocked due to no journal space. The xfstest with following parameters, MODULAR=0 TEST_DIR=/mnt/test TEST_DEV=/dev/nbd37p1 SCRATCH_MNT=/mnt/scratch SCRATCH_DEV=/dev/nbd37p2 MOUNT_OPTIONS="-o discard" has passed. The result is consistent w/ or w/o this patch set. There are 5 patches, Patch 1 ~ 3, there are no functional changes in them, but just some preparation for following patches Patch 4 introduces a async kworker to do discard in fstrim fation which implements the core idea of this patch set. Patch 5 let the fallocate retry when err is ENOSPC. This fix the generic/371 Any comments are welcome ;) V2 -> V3 - Get rid of the per block group rb tree which carries freed entry. It is not neccesary because we have done aggregation when wait for journal commit. Just use a list to carry the free entries. V1 -> V2 - free the blocks back to mb buddy after commit and then do ftrim fashion discard fs/ext4/ext4.h | 2 + fs/ext4/extents.c | 6 ++- fs/ext4/mballoc.c | 223 ++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------- 3 files changed, 151 insertions(+), 80 deletions(-)