From nobody Sun Nov 24 17:39:16 2024 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 5C14E16DC28; Mon, 4 Nov 2024 01:45:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730684701; cv=none; b=ojR8/hwf3bZzcnGXrHFZkHl67ZttnPwKfaTburHDw8X05NUTBFOOG4Fk52Nw2c2fJ1REdE0o5Lns+VpXJmhsi894VMl97Nj0mwPZiigh9SN5WiUJ1cilu1bCk+1vWsdevYulfHjZGvxth0W7557gxpCtPGd5C2vB6zqVueLOTe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730684701; c=relaxed/simple; bh=7Pp4PBJBD5yxLLgDe9EQ5hpOhYXqkT1Cf7NgbTbHuUw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G4FUhemO33ENQpXyHP+CpeySmBoKIHcDOrvFbAfEIDbJ7Q1SlVtQx/ectaN7Vnadi6xaL15yf1rSi2GwEUJ5dywdAkSvG/P+dHdsM+t8n7siDfLKiGa7nquqDxjxT2lV2UALYQTkasv2KoOCcH1HQ/MDuqwrzeWJxQVyZWzSt60= 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=hAmRCPOL; arc=none smtp.client-ip=209.85.215.178 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="hAmRCPOL" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-7f12ba78072so495037a12.2; Sun, 03 Nov 2024 17:45:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730684699; x=1731289499; 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; bh=M+88D/OjH70vfTg2OXZg5JI8QMPXka3iA132tE3YHvA=; b=hAmRCPOLL53kHK8+nV4eT3yn7pbsNdh0kE1DBG/rbzZMj5HBVkqGirzEKfuNPJu3Ud YDT1OVi8Myei/y9m1Y02EpRqYIp2NeVV4J9pw01zGAslDKSvBM2DCDBcLRKkJ7TMntRj FPKHUG6SvtHrTblyTwXRwhuckS3jFuzNAjOaqAVfS6bRxWHFS8UCjqxHaZwBI+onNZ4U 151f7eb9agpbN2Qy1BuHgGNxuFUEVnFNrV6nen/V2hd6HQK9Msv4bGOiSgjeZv7FXXnL VrohkmGVCqwZjiDuDxmlm95/USuoNZIjPCebM0UhZKkDDATTybZbbi3neTnXF9N0Fa2I 4XDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730684699; x=1731289499; 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=M+88D/OjH70vfTg2OXZg5JI8QMPXka3iA132tE3YHvA=; b=PazIIH0gVo19Jgjy6vG8W4tHjq502YkZNOKIIgi8K7ou1wYeYrZYpUHqAywm4VxNav LhN3cMvzXQUFA3POdpDMncyP9wkuJI/NOBR0PMmQl5YmInA6aGFQIDTYLJtDe8nUZXzR Yv9OJW+xZ5vcPlWIpGmZv25CQCpDw8gfK2cPrrugGdfcZ1d1/zZBkGk4x4+LuxuYqgzC NYQmeOyR6XmHYSTKzbj7YvssH3GMmzu//KGOwD9OBye1VKoWr06Klx+7pm9GGbUQTPAc o3q8tOTdNL44zXwCXKIA0YaepAd/CTpuF9rhYvG+aTayLRDgEg4sV6561god6KZsW4IJ k2eg== X-Forwarded-Encrypted: i=1; AJvYcCXlK/eNhY0esKIwqkaDZFu1DUy7JBUrzkOgBgAxwh3GVZv71ZsIZK+8P5T/BT5Enr5EwnfdH+qhgg2WoDQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yy68RVpwHAuhhYhPXz+XbE1GYwIAtnSmfTSpaK2guQYlSHH7YPV VUZwE0r/5wyVZXFFV4Kaap7HzzobaUZ73Honwq4hyn/Sh7xG6C78 X-Google-Smtp-Source: AGHT+IHa2yJ/bn3FSL0jPq2uBClDUUfxkR7tGn7zwp7n7ppK6tYZdpha2KzG/KTpdGWbtpWMzsQ+ww== X-Received: by 2002:a05:6a21:388a:b0:1d7:3d:6008 with SMTP id adf61e73a8af0-1d9a83cac42mr39743282637.13.1730684699536; Sun, 03 Nov 2024 17:44:59 -0800 (PST) Received: from localhost.localdomain ([2607:f130:0:105:216:3cff:fef7:9bc7]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-720bc1eb3a7sm6360030b3a.81.2024.11.03.17.44.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 17:44:59 -0800 (PST) From: zhangshida X-Google-Original-From: zhangshida To: djwong@kernel.org, dchinner@redhat.com, leo.lilong@huawei.com, wozizhi@huawei.com, osandov@fb.com, xiang@kernel.org, zhangjiachen.jaycee@bytedance.com Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, zhangshida@kylinos.cn, starzhangzsd@gmail.com Subject: [PATCH 1/5] xfs: add two wrappers for iterating ags in a AF Date: Mon, 4 Nov 2024 09:44:35 +0800 Message-Id: <20241104014439.3786609-2-zhangshida@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104014439.3786609-1-zhangshida@kylinos.cn> References: <20241104014439.3786609-1-zhangshida@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Shida Zhang As indicated by the diagram: |<--------+ af 0 +--------->| |---------------------------- | ag 0 | ag 1 | ag 2 | ag 3 | +-------------------------------- |----------2-->|----1--->| | curr_af start next_af-1 next_af 1.First iterate over [start, next_af). 2.Then [restart, start). Signed-off-by: Shida Zhang --- fs/xfs/libxfs/xfs_ag.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h index 9edfe0e96439..0c6b7fe5194f 100644 --- a/fs/xfs/libxfs/xfs_ag.h +++ b/fs/xfs/libxfs/xfs_ag.h @@ -311,6 +311,23 @@ xfs_perag_next_wrap( for_each_perag_wrap_at((mp), (start_agno), (mp)->m_sb.sb_agcount, \ (agno), (pag)) =20 +/* + * Iterate all AGs from start_agno through wrap_agno, then curr_af through + * (start_agno - 1). + */ +#define for_each_perag_af_wrap_at(mp, start_agno, wrap_agno, agno, pag, cu= rr_af) \ + for_each_perag_wrap_range((mp), (start_agno), (curr_af), (wrap_agno), (ag= no), \ + (pag)) + +/* + * Iterate all AGs from start_agno through to the end of the AF, then curr= _af + * through (start_agno - 1). + */ +#define for_each_perag_af_wrap(mp, start_agno, agno, pag, curr_af, next_af= ) \ + for_each_perag_af_wrap_at((mp), (start_agno), (next_af), (agno), (pag), \ + (curr_af)) + + =20 struct aghdr_init_data { /* per ag data */ --=20 2.33.0 From nobody Sun Nov 24 17:39:16 2024 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 1355817DFE0; Mon, 4 Nov 2024 01:45:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730684708; cv=none; b=h2aXuV13mGPzkle/sIEjESWo5bdPde+nkAW5G8fBKrXq3iDoDMz/NYjFZcadPGEz4XVxx1Wxhc5tFKE/XuzzPwkLTToj7icFAXixMOTPG4SP6xeyo2Y/xopIztAUnRe6SHiNxXsWfntWHZobuRvVbbBHEQPw8QoTP2Lha7YqyO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730684708; c=relaxed/simple; bh=arn1OCDxZaEgplRAT40oLAkueks9sPLIJ/HqWldOUNU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UxAv20pAC2QvptNaC9QfhngPQPx0hImErXBaMLl/PUw8Jc9VQUJSnwaEQkRrs2PzvMXQeAW7ZOsx6dbhRhwAo9TFl8vdPTGoVqvAVM41NXnaOiCUN8dd3ZirllUwOXBChR0y8i/IFnyd/8noWlQG2CF7bH40wlB7bfG6qnDL+L4= 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=M0a8enp1; arc=none smtp.client-ip=209.85.210.171 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="M0a8enp1" Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-720c2db824eso3356068b3a.0; Sun, 03 Nov 2024 17:45:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730684706; x=1731289506; 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; bh=fbk9rhQrosmAxwMrd6YDiXdQG9wegdoaNo70H/pX0VM=; b=M0a8enp1Jdh27FUwPssytq4iTENGPqitKsTwOeT3yfmBw5d+OyUgi5CnsRIn6q7J7G 5UljHZj4+wet47kbEdeN8FPLM38fFe3ued7/0VCCMauRjabuFCtA6pBgxTzujcSEMbHy OFm0ywyol4wBsRzin4lNDTopvKDwcx/xrLbO1D+5AFYivqOusCvAnsartAJBGX+MOxoE k/vo6SUuIe9NcJqE8rQZJyFGz7azqafUa7SeN5k1kmP96GCUf7DwVQxUVfBFR7njlnQY GsFbbf8LJTONYBat1MT+90rgqpy/JntxF6JjlgVPs2Z6AeaiE6qxuJw8zHo/esh2giMx lqMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730684706; x=1731289506; 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=fbk9rhQrosmAxwMrd6YDiXdQG9wegdoaNo70H/pX0VM=; b=GEZiAHuk8wLKaLItp5MAtRqxcMfqTAt7JjROMdxYAN03mHji8W8/jGo1I4q7Eqdyss EcSePtSlbyK8Sq0oiJP2LZ9k/1XsOWkF+ZbEdN4FtRLa1Bw4xZI8q8jcEnyFzyV8f+Ns 5DpnL6Rg2ElJSl0Y91CcE2Nblj57tuTQd7KrLE9wgSatq7nfe3ws+8ImijU2KZrrrvIU gmmXGtvnDV0ozvHQYKi1GZN+0jQFyZMWZF99kLe1NPpejqYQTfGs1mk722CxZ833hfVe bYXmRDTZbZkb+Xts5LdSykcd7FvTGJMqhB1HEepsW8ZXQfBUz8OuIJ98gXGNM0f+3a0S PvvA== X-Forwarded-Encrypted: i=1; AJvYcCVSo1G0wJV/cta+OgKuk2QP1I967JlJnqIkRCsftPDC0K9XkK5FygpbxfmYpiy2qfTTN2LOUEiBG+OOlE4=@vger.kernel.org X-Gm-Message-State: AOJu0YzzZt++h53MlUJ/8mLJnalBKFGMoMRm1FSWP/z7SpThnT5UbFRo EQ5dE9m9MutUWXu0+YG0fOj6NdxIawhVjddAUJDD6shIW1JRO0aa X-Google-Smtp-Source: AGHT+IEsZPdU8GM1kum7/zaUzEVw6XvTIJrad8b4SerZbO73UnRoT/b4kMshT+eS7mAR2Kt1EenPhA== X-Received: by 2002:a05:6a00:4616:b0:71e:41b3:a57a with SMTP id d2e1a72fcca58-72063093466mr40197264b3a.24.1730684706294; Sun, 03 Nov 2024 17:45:06 -0800 (PST) Received: from localhost.localdomain ([2607:f130:0:105:216:3cff:fef7:9bc7]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-720bc1eb3a7sm6360030b3a.81.2024.11.03.17.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 17:45:05 -0800 (PST) From: zhangshida X-Google-Original-From: zhangshida To: djwong@kernel.org, dchinner@redhat.com, leo.lilong@huawei.com, wozizhi@huawei.com, osandov@fb.com, xiang@kernel.org, zhangjiachen.jaycee@bytedance.com Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, zhangshida@kylinos.cn, starzhangzsd@gmail.com Subject: [PATCH 2/5] xfs: add two mp member to record the alloction field layout Date: Mon, 4 Nov 2024 09:44:36 +0800 Message-Id: <20241104014439.3786609-3-zhangshida@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104014439.3786609-1-zhangshida@kylinos.cn> References: <20241104014439.3786609-1-zhangshida@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Shida Zhang Add two member to support the AF(alloction field) for each *mp*, which means now we can have 3 AFs at most: [ 0, AF[0] ) [ AF[0], AF[1] ) [ AF[1], m_sb.agcount ) where AF[N], start agno of the AF[N] =3D mp->m_sb.agcount - mp->m_af[N] On default, [ 0, m_sb.agcount) [ m_sb.agcount, m_sb.agcount ) [ m_sb.agcount, m_sb.agcount ) That means the entire filesystem can be deemed as a AF 0 extending from 0 to m_sb.agcount. Signed-off-by: Shida Zhang --- fs/xfs/xfs_mount.h | 3 +++ fs/xfs/xfs_super.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index 96496f39f551..38dff08b467d 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -260,6 +260,9 @@ typedef struct xfs_mount { =20 /* Hook to feed dirent updates to an active online repair. */ struct xfs_hooks m_dir_update_hooks; + + /* Relative start agno of the AFs */ + xfs_agnumber_t m_af[2]; } xfs_mount_t; =20 #define M_IGEO(mp) (&(mp)->m_ino_geo) diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index fbb3a1594c0d..0975ad55557e 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -2040,6 +2040,8 @@ static int xfs_init_fs_context( mp->m_logbufs =3D -1; mp->m_logbsize =3D -1; mp->m_allocsize_log =3D 16; /* 64k */ + mp->m_af[0] =3D 0; + mp->m_af[1] =3D 0; =20 xfs_hooks_init(&mp->m_dir_update_hooks); =20 --=20 2.33.0 From nobody Sun Nov 24 17:39:16 2024 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 E8E5918732B; Mon, 4 Nov 2024 01:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730684715; cv=none; b=Nup6PKD5Ko1IIqajs82cM5sLCf8bSu9vnXjoxLDbYt6RYCWhKJjjU0QxV+EzALfU51UNB9JdCsujYYRYoYcePqXCNz4gZeYEnRYE1BN9ImX4wL8ojxmcPrzEFhD99oPUTz3RjT2pxmCRpzBNoW9T3aWi0FM7SfhKR/2dJ/TGQJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730684715; c=relaxed/simple; bh=4HN9YTUUVd5m+kQvD8mswBgKP6nmdptFwI0vtuu5NSg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XEHIwjCUlwUqIfaKeEcvyPkfHw+dOcf5BpWCkB3V+KuLmqwgpdhLUDYNLiKh4VzHZIyg5DwXWYGTCl+rmKFV/yjJUcFjVbydFePdtNZCCxJGMz7HLYE4g/zOBWFJYG8FqMOn9b/E7l9Jy74GS58aMFa6RkMcvQztSK7zLUf023k= 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=Azr0JTsj; arc=none smtp.client-ip=209.85.210.172 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="Azr0JTsj" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-720be27db74so2283338b3a.1; Sun, 03 Nov 2024 17:45:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730684713; x=1731289513; 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; bh=1rDXLhuXjk2jLJN5NRJ96tHaE2wkNSlsldVHym5Q/eo=; b=Azr0JTsjTx1RXwOD4c+xhOKq/nc+osCNN2r0OUgIlTsnosdAtCvrR810MMU+wFzk4q DGtF/sgN13wFL+IXYpTEU9JoI7tbdf0rVnP+0H8iHUr8GqjSBNj78lUXo9SSYvTFXTwZ fkmzkegxw0KepAAjcCRMgur521IdjjUgtBK8o72Fep8AxRWGX8mDFKsrsfzBeAEFEC5J A2EzErUGm9F+JHKN4zICP0YaoJsqYTIFHEAvZ9Te2ThCC6olxCqDUjCtXHA+pgFiiloo o3CPeVH3HiEyPFEDAGvd5AmF73uFp5QOP/E0O9o3kTpP1jHi2zcMQOjoDsuuC4sa9Chg D6YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730684713; x=1731289513; 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=1rDXLhuXjk2jLJN5NRJ96tHaE2wkNSlsldVHym5Q/eo=; b=snK9DVhSfw8o9knygvPwXcU0LowXjkQYNamxJuN+ZYjvV95mz+un6muL+ghzmh0yP2 BEQnv+aSNq+BVMTO+48ihA0rMSRvylSJzHtXPK1mt5XdBLiPMn+JPBAqFjMzqH/kHE8X 069bWxy9a2g1C5Ue4OICA9fNX77G43f7jSraQUz/2jI65vXmvCdRDu9JeieTOObpf3Vb JPI2Syd6x1S6Tk4YHkZMIljYgmFHsvzCcjKzHkIKEXjDCJEnqL8Q9cxRgRBasB7x0gGn rERUDEc+FDCmHQzQJoPMl2XPNkyT8iK6dFxA9azIV1/RQQ7EUOAix73NKHssTYeoaRRx Z/7Q== X-Forwarded-Encrypted: i=1; AJvYcCVm8ue0EI0/DcCIPWCbLKjMYZMOIcbw1CWQD4HKY7C94CMi6gPt9kKUxcTj7IYxU8lZWBA/aSkdNf0mA80=@vger.kernel.org X-Gm-Message-State: AOJu0YzGbA3Tq5Eej1yWLGID0+NfvHkhQKirYNBd4IsnH965OgIabJ/N vgdFrIMCdTxUXX2gTQDBaO+V2CJRPbI0b62zEDNIDoy9qGHDUe3XUX2cgowvgaE= X-Google-Smtp-Source: AGHT+IFposWJFsNCfOvvnQK72vOWX6qOEnNRu3Qw1p2EcyFypfIgeTWSrCxQDtjQGZoLJrAj3J6H6Q== X-Received: by 2002:a05:6a00:4615:b0:71e:5573:8dcd with SMTP id d2e1a72fcca58-720bcaf1e8emr19062503b3a.2.1730684712999; Sun, 03 Nov 2024 17:45:12 -0800 (PST) Received: from localhost.localdomain ([2607:f130:0:105:216:3cff:fef7:9bc7]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-720bc1eb3a7sm6360030b3a.81.2024.11.03.17.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 17:45:12 -0800 (PST) From: zhangshida X-Google-Original-From: zhangshida To: djwong@kernel.org, dchinner@redhat.com, leo.lilong@huawei.com, wozizhi@huawei.com, osandov@fb.com, xiang@kernel.org, zhangjiachen.jaycee@bytedance.com Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, zhangshida@kylinos.cn, starzhangzsd@gmail.com Subject: [PATCH 3/5] xfs: add mount options as a way to change the AF layout Date: Mon, 4 Nov 2024 09:44:37 +0800 Message-Id: <20241104014439.3786609-4-zhangshida@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104014439.3786609-1-zhangshida@kylinos.cn> References: <20241104014439.3786609-1-zhangshida@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Shida Zhang Except for mount options, maybe there are other ways like ioctl() to pass the layout from user to the filesystem. Signed-off-by: Shida Zhang --- fs/xfs/xfs_super.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 0975ad55557e..09dc44480d16 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -105,7 +105,7 @@ enum { Opt_filestreams, Opt_quota, Opt_noquota, Opt_usrquota, Opt_grpquota, Opt_prjquota, Opt_uquota, Opt_gquota, Opt_pquota, Opt_uqnoenforce, Opt_gqnoenforce, Opt_pqnoenforce, Opt_qnoenforce, - Opt_discard, Opt_nodiscard, Opt_dax, Opt_dax_enum, + Opt_discard, Opt_nodiscard, Opt_dax, Opt_dax_enum, Opt_af1, Opt_af2, }; =20 static const struct fs_parameter_spec xfs_fs_parameters[] =3D { @@ -150,6 +150,8 @@ static const struct fs_parameter_spec xfs_fs_parameters= [] =3D { fsparam_flag("nodiscard", Opt_nodiscard), fsparam_flag("dax", Opt_dax), fsparam_enum("dax", Opt_dax_enum, dax_param_enums), + fsparam_u32("af1", Opt_af1), + fsparam_u32("af2", Opt_af2), {} }; =20 @@ -1396,6 +1398,12 @@ xfs_fs_parse_param( xfs_fs_warn_deprecated(fc, param, XFS_FEAT_NOATTR2, true); parsing_mp->m_features |=3D XFS_FEAT_NOATTR2; return 0; + case Opt_af1: + parsing_mp->m_af[0] =3D result.uint_32; + return 0; + case Opt_af2: + parsing_mp->m_af[1] =3D result.uint_32; + return 0; default: xfs_warn(parsing_mp, "unknown mount option [%s].", param->key); return -EINVAL; --=20 2.33.0 From nobody Sun Nov 24 17:39:16 2024 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) (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 EF6D918732B; Mon, 4 Nov 2024 01:45:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730684722; cv=none; b=Z0YACUYrffM9FWvC+aIiXMaoJaaVjC6D6LVyeiLAGhCNFEfEq4My9ysEws/7HbV7KQ+IMACFghccAD6Ueu/S/Mraxys0+GEtms+vro5/3uopl9sLN2Aak7cGjDPrjAnXFLNeE2Br+6cQT33DoicPhB1STxqYynixVsLvYqF6cO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730684722; c=relaxed/simple; bh=sD9QONmCZspB9Zc6QOAK0N4fAfgLhVox8koPW9vJLSk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XpIg+vDyzGcTxkQKkdidlURlalLLndjA4QfKC92ybkzmCnp5WJEU7SpwRWd0Q50s2Ifw2WDExNbCvZxtUjEBJnToRNCOBlQlTwzIBV6NLTFtX07OF2G0dcmD1UPJuLVTolIf3Erl18S7S7br8hfxq1NycIjJ+D9t9x6qapwJVZM= 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=jhugICGo; arc=none smtp.client-ip=209.85.210.169 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="jhugICGo" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-720d01caa66so1949651b3a.2; Sun, 03 Nov 2024 17:45:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730684720; x=1731289520; 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; bh=xitybgapCtabUaUYpxoDtyGnJUvnyr68olN5vz5Y+nM=; b=jhugICGoipY3hkV6u6xVyNuvlvl1S7nvZR7IcScy5gQWkddFl/+NiBjMVkTDAw7bk4 Ltim0rNexZqifmsWIT5MdUm+CQ+AftzJZ1MQQ2+WoDSugaUM0P9FvbX7zuoZlLrz1VrR EjGLDxtTY2/25d87aReUSEpDw/kdKeVOfPoIqLK4Qm2LDiJAzuXuKY/VQK3tTSd64TiN /eehLbCNYG0fMP2oR4tCMtJ9FE+Wa8T7Cggx8yL8Ys1HapeuUQugRYjar6Phah4X4nat d2HitVHliUXGoa1hBKl6lsG1p5kEiMucM9foZ42u45qTaxtKjmoj9MezTG/+4zfDE8OW qhmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730684720; x=1731289520; 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=xitybgapCtabUaUYpxoDtyGnJUvnyr68olN5vz5Y+nM=; b=G3xIx6Yl14O6OIV6WyhOg4l4EV3gZJ0vrV2qpAHXgJvMsCnGsiXJkW4Ia8Z+JcBZhz FNILuE2KkGZ2Vj+HhXG3URlBZollaLFaq62Cs/BMPNEofHiuNmDo5krWBe1qTK1ufyPo ka3lMJPSX8eZo1V6EyG7grN+EhGUCNAlIocLpuYbbFHZt8h22k77xRXV6d1de7LepqZE aAKi98GssRj+ut463YYnJOBG/VIhP/xI1z2/l+uHxHrnCUtekQjTPPM/I2LM0WRRcXQi 39+1g13I7npIdKronjVKoY6VnMwRX8OzTev00wJ7YttYY7exqWt8hGm0RC0ksieg3MJ2 nh1Q== X-Forwarded-Encrypted: i=1; AJvYcCVy98Sil6Z4/1CZyBvxFOk5XZL5sncb+Ea/OUuoF6KsOSBQLcCU3hbxWPalnFJiyfK6McKnc8rfDPS4NkM=@vger.kernel.org X-Gm-Message-State: AOJu0YziLD5kJth6RkDvRVRQftdMxJzg3PcoND3mFyhDs4ulUtYGr0Th macPqORTyF6OjE9BP9oOGp0S2Uwe9cB3FrKOQS1cyCWN5D8UDGfE X-Google-Smtp-Source: AGHT+IE94FTfuYMU8CLRKkMfIDeifsIHOg9D7ohYmLWVOOGohhqq6PY9e2GbXBjD1t363PnwjrvGgg== X-Received: by 2002:a05:6a00:4653:b0:71e:77e7:d60 with SMTP id d2e1a72fcca58-720b9ddb788mr20889511b3a.23.1730684720150; Sun, 03 Nov 2024 17:45:20 -0800 (PST) Received: from localhost.localdomain ([2607:f130:0:105:216:3cff:fef7:9bc7]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-720bc1eb3a7sm6360030b3a.81.2024.11.03.17.45.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 17:45:19 -0800 (PST) From: zhangshida X-Google-Original-From: zhangshida To: djwong@kernel.org, dchinner@redhat.com, leo.lilong@huawei.com, wozizhi@huawei.com, osandov@fb.com, xiang@kernel.org, zhangjiachen.jaycee@bytedance.com Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, zhangshida@kylinos.cn, starzhangzsd@gmail.com Subject: [PATCH 4/5] xfs: add infrastructure to support AF allocation algorithm Date: Mon, 4 Nov 2024 09:44:38 +0800 Message-Id: <20241104014439.3786609-5-zhangshida@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104014439.3786609-1-zhangshida@kylinos.cn> References: <20241104014439.3786609-1-zhangshida@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Shida Zhang Add a function to search through all the AFs in a alloction. Add two members in *args* to trace the current AF. And properly initialize these members so as to keeping the behavior exacly the same with the original code logic. And for those bmbt alloction, we can slightly break the roles imposed by AF, since it's allocating one block at a time. Remember our goal to propose the concept of AF is to avoid a badly fragmented filesystem to consume all the continuous free space. So just initialize it in a way like this alloctions are in a AF ranging from [0, ag_count). Signed-off-by: Shida Zhang --- fs/xfs/libxfs/xfs_alloc.h | 2 ++ fs/xfs/libxfs/xfs_bmap.c | 34 ++++++++++++++++++++++++++++++++++ fs/xfs/libxfs/xfs_bmap_btree.c | 2 ++ 3 files changed, 38 insertions(+) diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h index 0165452e7cd0..ab34aceecc72 100644 --- a/fs/xfs/libxfs/xfs_alloc.h +++ b/fs/xfs/libxfs/xfs_alloc.h @@ -56,6 +56,8 @@ typedef struct xfs_alloc_arg { bool alloc_minlen_only; /* allocate exact minlen extent */ struct xfs_owner_info oinfo; /* owner of blocks being allocated */ enum xfs_ag_resv_type resv; /* block reservation to use */ + xfs_agnumber_t curr_af; /* start agno of the allocation field */ + xfs_agnumber_t next_af; /* next point of the allocation field */ } xfs_alloc_arg_t; =20 /* diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 36dd08d13293..b55b8670730c 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -683,6 +683,8 @@ xfs_bmap_extents_to_btree( args.minlen =3D args.maxlen =3D args.prod =3D 1; args.wasdel =3D wasdel; *logflagsp =3D 0; + args.curr_af =3D 0; + args.next_af =3D mp->m_sb.sb_agcount; error =3D xfs_alloc_vextent_start_ag(&args, XFS_INO_TO_FSB(mp, ip->i_ino)); if (error) @@ -830,6 +832,8 @@ xfs_bmap_local_to_extents( */ args.total =3D total; args.minlen =3D args.maxlen =3D args.prod =3D 1; + args.curr_af =3D 0; + args.next_af =3D args.mp->m_sb.sb_agcount; error =3D xfs_alloc_vextent_start_ag(&args, XFS_INO_TO_FSB(args.mp, ip->i_ino)); if (error) @@ -3630,6 +3634,8 @@ xfs_bmap_btalloc_low_space( =20 if (args->minlen > ap->minlen) { args->minlen =3D ap->minlen; + args->curr_af =3D 0; + args->next_af =3D args->mp->m_sb.sb_agcount; error =3D xfs_alloc_vextent_start_ag(args, ap->blkno); if (error || args->fsbno !=3D NULLFSBLOCK) return error; @@ -3735,6 +3741,32 @@ xfs_bmap_btalloc_best_length( return xfs_bmap_btalloc_low_space(ap, args); } =20 +static int +xfs_bmap_btalloc_best_length_iterate_afs( + struct xfs_bmalloca *ap, + struct xfs_alloc_arg *args, + int stripe_align) +{ + struct xfs_mount *mp =3D ap->ip->i_mount; + int error; + unsigned int i; + + args->curr_af =3D 0; + + for (i =3D 0; args->curr_af < mp->m_sb.sb_agcount; i++) { + args->next_af =3D mp->m_sb.sb_agcount - mp->m_af[i]; + error =3D xfs_bmap_btalloc_best_length(ap, args, stripe_align); + if (error || args->fsbno !=3D NULLFSBLOCK) + break; + + args->curr_af =3D args->next_af; + /* Exit LOWMODE when going to the next AF. */ + ap->tp->t_flags &=3D ~XFS_TRANS_LOWMODE; + } + + return error; +} + static int xfs_bmap_btalloc( struct xfs_bmalloca *ap) @@ -3751,6 +3783,8 @@ xfs_bmap_btalloc( .datatype =3D ap->datatype, .alignment =3D 1, .minalignslop =3D 0, + .curr_af =3D 0, + .next_af =3D mp->m_sb.sb_agcount, }; xfs_fileoff_t orig_offset; xfs_extlen_t orig_length; diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c index 3464be771f95..4e57b6f897e8 100644 --- a/fs/xfs/libxfs/xfs_bmap_btree.c +++ b/fs/xfs/libxfs/xfs_bmap_btree.c @@ -234,6 +234,8 @@ xfs_bmbt_alloc_block( args.minleft =3D xfs_bmapi_minleft(cur->bc_tp, cur->bc_ino.ip, cur->bc_ino.whichfork); =20 + args.curr_af =3D 0; + args.next_af =3D args.mp->m_sb.sb_agcount; error =3D xfs_alloc_vextent_start_ag(&args, be64_to_cpu(start->l)); if (error) return error; --=20 2.33.0 From nobody Sun Nov 24 17:39:16 2024 Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 9EA64166310; Mon, 4 Nov 2024 01:45:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730684730; cv=none; b=bN5atV5gpb6/1Lam6BAttRmYILlIomv+dQaCky/elSKhT5QmcjnXBDmUTgp9CuPlRCCm90g2UuDOyudXwXbdiyIYMjZ2LwUYQu0TZOAJwHxXAZ77oo8Vze2tfRv+7Mz8gB0LFvACiXefnNQu02H0iCsuXONsgCqOqjGS5WN9XPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730684730; c=relaxed/simple; bh=v7M4rAfw0syNlkg6nlA1/MAlQXSJDeKSY6G4D/mkxRE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LO7XDZBnPMUCNHujbiggltLPNiAH/dnz3TDjmH+zeq4Elqz+IvktHc7fp+olrE6Ombdox+mSumP4vdEqjmf7Yt20sXvmpLMbgZJf9fH5yIz4Vivn9Lim03Db0aU0q5ihDX0segWM4nT9FiUjlUeSQe0oshPH1751A1EcPpV5Exs= 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=hUK+RsC4; arc=none smtp.client-ip=209.85.210.180 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="hUK+RsC4" Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-720d5ada03cso2339292b3a.1; Sun, 03 Nov 2024 17:45:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730684727; x=1731289527; 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; bh=+fYSOcf5BwbqG/V0bjEjjkcwk/JSzZFYqZyDOf0lnd4=; b=hUK+RsC4kMd7ISy30tkozr4L+yEnwrCsu2Ab1mqghLjAkQ5202w8ArJBWKSPtNtXW2 16ojpIu7l9zHVBh7weqlSjyuKoudB9mvSQCuVO89mDVPAo/D+buPxb0snHY4x1JSdqKQ cWkSWjNaqxsPh0QyeDp18RiKJZPkV/PB0NUCEQVHnCRiFpAPUa+5UcqPEKFeGTo76xlT iizAgtZY6/zvbV6xKIOSeKmI4AFFTrvvcyPSeEwfI3luEV7EAoJSuxss9FLpldjAyFen 5r+p5R7QCa3aIGy6czqowh+Wjn7YPgNpvCAUsJDZJai4ug5eKqlvkA2ruX97P4IaYuRz ZDYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730684727; x=1731289527; 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=+fYSOcf5BwbqG/V0bjEjjkcwk/JSzZFYqZyDOf0lnd4=; b=kRap482dzNuMyxZx6Q0dMsmVBQKg/JH4yL3pPjJVzT1XPH+s2/LVvorsxI67KrF4iN mkkswamvOqA25YPAPW2GJWJXpgwG3rk4UQ+fyZw5LNW3pA9e/MbiUMGoUrcSJvWjanTi WvFTX5lICIVHfBWG3i3CBaJUoArgRbX5JuPqi0QH2JFQM9HO5+d43zsXi2pqWs5A4D6P SQY7R8pbNp54GOfTuQMC7MC5JxnFWGYnlqfrpoh6SMYf/Djejslh/BMm9mQe4930xyjG ZtxD46aAdzt4e573aEo7UAVdaFXHORjMcbqOEJCa0phzK0xhl1lDQGLK/pEH79g9EE90 +k6w== X-Forwarded-Encrypted: i=1; AJvYcCWcskjFFAYDlqVfFZz17W3xw/4w9FbBxiAXAQKZr2YPMn7SOwhLsFREqy6iXR9tD9XpsEnpjC3t5C5FDt8=@vger.kernel.org X-Gm-Message-State: AOJu0YzmkhHEyb5W4HTTMqQTMBA3DCWhtqY7Rr1SGEZ+VrXpaw0bVBh9 xYYRjxH5ZoGuFPK0XXzwptorgLCRmQBa5NsvFbdSAVYqO21P/sIo X-Google-Smtp-Source: AGHT+IFqqG3AVIwR2dvdYVWcOll8SFyzb+cFp7t3eJHk6OOIVzIApobg17OnJsaXXd1cvm1AaGX/Sw== X-Received: by 2002:a05:6a21:2d8b:b0:1d9:28f8:f27d with SMTP id adf61e73a8af0-1db91e533camr21757137637.38.1730684726824; Sun, 03 Nov 2024 17:45:26 -0800 (PST) Received: from localhost.localdomain ([2607:f130:0:105:216:3cff:fef7:9bc7]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-720bc1eb3a7sm6360030b3a.81.2024.11.03.17.45.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 17:45:26 -0800 (PST) From: zhangshida X-Google-Original-From: zhangshida To: djwong@kernel.org, dchinner@redhat.com, leo.lilong@huawei.com, wozizhi@huawei.com, osandov@fb.com, xiang@kernel.org, zhangjiachen.jaycee@bytedance.com Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, zhangshida@kylinos.cn, starzhangzsd@gmail.com Subject: [PATCH 5/5] xfs: modify the logic to comply with AF rules Date: Mon, 4 Nov 2024 09:44:39 +0800 Message-Id: <20241104014439.3786609-6-zhangshida@kylinos.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241104014439.3786609-1-zhangshida@kylinos.cn> References: <20241104014439.3786609-1-zhangshida@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Shida Zhang AF rules: Lower AF will never go to higher AF for its alloction if they have other choices. So unlike previous iterating over the entire [0, agcount), now iterate one AF, i.e. [curr_af, next_af), at a time. Signed-off-by: Shida Zhang --- fs/xfs/libxfs/xfs_alloc.c | 20 +++++++++++++++++++- fs/xfs/libxfs/xfs_bmap.c | 13 +++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index 04f64cf9777e..c3321f24a4f9 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c @@ -3707,12 +3707,30 @@ xfs_alloc_vextent_iterate_ags( xfs_agnumber_t restart_agno =3D minimum_agno; xfs_agnumber_t agno; int error =3D 0; + xfs_agnumber_t start_af =3D args->curr_af; + xfs_agnumber_t end_af =3D args->next_af - 1; + =20 if (alloc_flags & XFS_ALLOC_FLAG_TRYLOCK) restart_agno =3D 0; restart: + /* if start_agno is not in current AF range, make it be. */ + if ((start_agno < start_af) || (start_agno > end_af)) + start_agno =3D start_af; + + /* Only iterate the cross region between current allocation field and + * [restart_agno, start_agno]. + */ + restart_agno =3D max(start_af, restart_agno); + start_agno =3D min(end_af, start_agno); + + WARN_ON_ONCE((args->next_af <=3D 0) || (args->next_af > mp->m_sb.sb_agcou= nt)); + WARN_ON_ONCE((args->curr_af < 0) || (args->curr_af >=3D mp->m_sb.sb_agcou= nt)); + WARN_ON_ONCE(restart_agno > start_agno); + WARN_ON_ONCE(restart_agno < start_af); + WARN_ON_ONCE(start_agno > end_af); for_each_perag_wrap_range(mp, start_agno, restart_agno, - mp->m_sb.sb_agcount, agno, args->pag) { + args->next_af, agno, args->pag) { args->agno =3D agno; error =3D xfs_alloc_vextent_prepare_ag(args, alloc_flags); if (error) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index b55b8670730c..799cd75cd150 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3326,6 +3326,8 @@ xfs_bmap_btalloc_select_lengths( struct xfs_perag *pag; xfs_agnumber_t agno, startag; int error =3D 0; + xfs_agnumber_t start_af =3D args->curr_af; + xfs_agnumber_t end_af =3D args->next_af - 1; =20 if (ap->tp->t_flags & XFS_TRANS_LOWMODE) { args->total =3D ap->minlen; @@ -3338,8 +3340,14 @@ xfs_bmap_btalloc_select_lengths( if (startag =3D=3D NULLAGNUMBER) startag =3D 0; =20 + /* if startag is not in current AF range, make it be. */ + if ((startag < start_af) || (startag > end_af)) + startag =3D start_af; + *blen =3D 0; - for_each_perag_wrap(mp, startag, agno, pag) { + WARN_ON_ONCE((args->next_af <=3D 0) || (args->next_af > mp->m_sb.sb_agcou= nt)); + WARN_ON_ONCE((args->curr_af < 0) || (args->curr_af >=3D mp->m_sb.sb_agcou= nt)); + for_each_perag_af_wrap(mp, startag, agno, pag, start_af, args->next_af) { error =3D xfs_bmap_longest_free_extent(pag, args->tp, blen); if (error && error !=3D -EAGAIN) break; @@ -3807,7 +3815,8 @@ xfs_bmap_btalloc( xfs_inode_is_filestream(ap->ip)) error =3D xfs_bmap_btalloc_filestreams(ap, &args, stripe_align); else - error =3D xfs_bmap_btalloc_best_length(ap, &args, stripe_align); + error =3D xfs_bmap_btalloc_best_length_iterate_afs(ap, &args, + stripe_align); if (error) return error; =20 --=20 2.33.0