Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qFPke-0005Ap-G9 for pgsql-hackers@arkaria.postgresql.org; Sat, 01 Jul 2023 01:50:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qFPkc-0001mo-Gh for pgsql-hackers@arkaria.postgresql.org; Sat, 01 Jul 2023 01:50:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qFPkc-0001mf-7Y for pgsql-hackers@lists.postgresql.org; Sat, 01 Jul 2023 01:50:14 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qFPkZ-001U1K-N3 for pgsql-hackers@postgresql.org; Sat, 01 Jul 2023 01:50:13 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 512875C0189; Fri, 30 Jun 2023 21:50:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 30 Jun 2023 21:50:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1688176209; x=1688262609; bh=Tq i/oanxGNqDoNMVs8z2qkx2YMKwnGkuvXy+KVd/v+c=; b=xVrV5p4H3lYWCpeALZ FktaFyXgEfZ39siafoae4MdcJE56nd0RoGDso05SHKCNsx4kY5eagl8sFyIpKlkn twMpjFiDWFL6PMjmXMIOoXnrac4T7dsJgzhPiicayIugnsGCbwECUPvlJ6u/gm5q /PQMhbBW+3aKXr14Ngb9D45J2eGAty0ySKtx0IHt2POTvP1qQM/zNJOpghTBNnUm os5++x0RFaebNi5JglIX96VlHxjhbHaJK8I6g5dsZ7aAnGylEuPK8AEK1t/cxnyy RAunzdEQU8uk9UdXo6Z/Mo0rXIq57pMBNwsp9Jw7tg53KFM2UFbX1IXfvTgBzeS5 cDHg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1688176209; x=1688262609; bh=Tqi/oanxGNqDo NMVs8z2qkx2YMKwnGkuvXy+KVd/v+c=; b=eRyfNtZmiPzKzg3fSoJD2695n7Jhi ETqixHRrCEL5lgRitMZihU3XABkbQ5QVxuCR8yMm3wD+7qalMt+r0AkkaKwL8dM3 N+Pw3oSKZJlSLnIzY0/OSr39d3BfDp9lavNueTxVdO10X5cjHvO94jvinYmU8C5k lAXh6eTlv+uV8s9BvFmHEY5TRHSGqmG5S71dfVJjtHOIS1ECpkOFD3YBhho31vg7 /cGHVSRS6HHHsvYxibwmeffovknv4ZkcSBG1ZwaFGyecZwLIhv4BlGtYJKJT4HY0 V2nTjZi8tgB+zjaqEHkw/4hPtHCDGg5DHbbfcJMGxVzA8lOGVrUtf2N/w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrtdejgdehudcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedvffefvefhteevffegieetfefhtddvffejvefhueetgeeludehteevudei tedtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 30 Jun 2023 21:50:08 -0400 (EDT) Date: Fri, 30 Jun 2023 18:50:07 -0700 From: Andres Freund To: Matthias van de Meent Cc: PostgreSQL Hackers Subject: Re: Extensible storage manager API - SMGR hook Redux Message-ID: <20230701015007.fu5nsjaxoird3ejx@awork3.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2023-06-30 14:26:44 +0200, Matthias van de Meent wrote: > diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c > index 4c49393fc5..8685b9fde6 100644 > --- a/src/backend/postmaster/postmaster.c > +++ b/src/backend/postmaster/postmaster.c > @@ -1002,6 +1002,11 @@ PostmasterMain(int argc, char *argv[]) > */ > ApplyLauncherRegister(); > > + /* > + * Register built-in managers that are not part of static arrays > + */ > + register_builtin_dynamic_managers(); > + > /* > * process any libraries that should be preloaded at postmaster start > */ That doesn't strike me as a good place to initialize this, we'll need it in multiple places that way. How about putting it into BaseInit()? > -static const f_smgr smgrsw[] = { > +static f_smgr *smgrsw; This adds another level of indirection. I would rather limit the number of registerable smgrs than do that. > +SMgrId > +smgr_register(const f_smgr *smgr, Size smgrrelation_size) > +{ > + MemoryContextSwitchTo(old); > + > + pg_compiler_barrier(); Huh, what's that about? > @@ -59,14 +63,8 @@ typedef struct SMgrRelationData > * Fields below here are intended to be private to smgr.c and its > * submodules. Do not touch them from elsewhere. > */ > - int smgr_which; /* storage manager selector */ > - > - /* > - * for md.c; per-fork arrays of the number of open segments > - * (md_num_open_segs) and the segments themselves (md_seg_fds). > - */ > - int md_num_open_segs[MAX_FORKNUM + 1]; > - struct _MdfdVec *md_seg_fds[MAX_FORKNUM + 1]; > + SMgrId smgr_which; /* storage manager selector */ > + int smgrrelation_size; /* size of this struct, incl. smgr-specific data */ It looked to me like you determined this globally - why do we need it in every entry then? Greetings, Andres Freund