Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t0fDn-00CZRX-J3 for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Oct 2024 10:56:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t0fDk-005qpo-Ds for pgsql-hackers@arkaria.postgresql.org; Tue, 15 Oct 2024 10:56:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t0fDk-005qpg-23 for pgsql-hackers@lists.postgresql.org; Tue, 15 Oct 2024 10:56:08 +0000 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t0fDh-000zVv-L6 for pgsql-hackers@lists.postgresql.org; Tue, 15 Oct 2024 10:56:07 +0000 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2fb4ec17f5cso16921051fa.3 for ; Tue, 15 Oct 2024 03:56:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728989763; x=1729594563; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=R3nnDafnGadMdgHCCQadI2RzwjOX4TnkhomH8GmASXY=; b=eq5ozG+eOQ6ETxJ8azsIqjRqUcOyuLaiEz9aZd3cg0fqooK23zUZYYnB6Al2q91MIZ 6kSMtUcjI/W/rFkNMrfQhHaqGf2lAWnOmpuRHl+/03zokkiPJAiT7dWwR/vm7ywRwrf2 pmG+M7khbE/oresJyCJojO9q0g+Lwm8ZfwUDru/8CywqJ8lQBavrViY+FcIpPHaA93i2 g4Gd7wzUn0vIlHurjr6BJh0fSTCl6LK57LsuU4qabxFiN0KSsOXM5swcq9nOjdk1ibzX ZXEgECDSbmz1Ejpkp8X4N5mxVGGXdTYD9XKWrBWmdDtz3vUTtcTpKH8qrh9nftqaf4PJ obdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728989763; x=1729594563; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R3nnDafnGadMdgHCCQadI2RzwjOX4TnkhomH8GmASXY=; b=J/feB0yci4e4NQ4MNiPRhe3X8zDsctlsjs1CmTr3m2QbWAD7dLTXPaf4kzUyHDONM9 oQlvkgRqAjtC/IDlla8wGYXatSLLDr8HL1gZ242CYn94uPzUesdUbKtVkezronhz/59H HiY5HFHmaaV6+kfSZk9i8nFHVAPkrw6zD8hc0U21i6JRg1ODQvfGJDt84JjeyD1U8w3Y TCGDWbDi36sGhfdk6LdTU32Sezp06C6GmcmS5am5pg0QMp3IxfK6MS8LnygSY6eKdic5 XUz2rXqecG0bCUQ5FwKyywqyn928xpKGj+LbLOBph+1vLhyvUv5C7FAP/skASbOC8hdK LpEg== X-Forwarded-Encrypted: i=1; AJvYcCW6bDMWrAafWkGDN9OAdgzv972mqiYkOQnbDsFtiLfHeFUq+kvJqSNP5qT63MbyfFB0gAOHOB4eWGw1lbhG@lists.postgresql.org X-Gm-Message-State: AOJu0YyL4s6MxK/EFGabp8qkBtYgR3mmSlKJ4YCdlwwFp6cFe1tYWZ54 1nUBvCRiQLx9uTT0rrW3aX7n9zYkXBkOn7i3/o0/2ndXXeUX7XniZEaAAJ/i2MO5bCBOA4e3e+9 TXZR4QSQIXuBArEZNVuNsv1WZxes= X-Google-Smtp-Source: AGHT+IGMT+5pwugnBbvuscOmtBL+KZYFQzAOL2HWO4rVD8N0L1zLCCgKvBHenOtAy5+fOn1kHrOTrYl8Qt01546ZeTg= X-Received: by 2002:a2e:4e01:0:b0:2fb:5035:11e6 with SMTP id 38308e7fff4ca-2fb50351533mr26594681fa.36.1728989762918; Tue, 15 Oct 2024 03:56:02 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Junwang Zhao Date: Tue, 15 Oct 2024 18:55:50 +0800 Message-ID: Subject: Re: Use function smgrclose() to replace the loop To: Ilia Evdokimov Cc: Steven Niu , pgsql-hackers@lists.postgresql.org, Kirill Reshke Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Oct 14, 2024 at 6:30=E2=80=AFPM Ilia Evdokimov wrote: > > > On 14.08.2024 09:32, Steven Niu wrote: > > Hi, Kirill, Junwang, > > > > I made this patch to address the refactor issue in our previous email > > discussion. > > https://www.postgresql.org/message-id/flat/CABBtG=3DcDTCBDCBK7McSy6bJR3= s5xUTOg0vSFfuW8oLdUYyCscA@mail.gmail.com > > > > > > That is, the for loop in function smgrdestroy() and smgrdounlinkall > > can be replaced with smgrclose(). > > > > for (forknum =3D 0; forknum <=3D MAX_FORKNUM; forknum++) > > smgrsw[reln->smgr_which].smgr_close(reln, forknum); > > --> > > smgrclose(rels[i]); > > > > Please let me know if you have any questions. > > > > Best Regards, > > Steven from Highgo.com > > Hello, > > Are you sure we can refactor loop by 'smgrclose()'? I see it is not > quite the same. smgrclose does more by setting smgr_cached_nblocks[] and smgr_targblock to InvalidBlockNumber, I see no harm with the replacement, not 100% sure though. > > Regards, > Ilia Evdokimov, > Tantor Labs LLC. > --=20 Regards Junwang Zhao