Split fd.c into multiple source files

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Split fd.c into multiple source files
Date: 2026-07-05 17:33:08
Message-ID: a5c1dc64-16e9-484a-9659-58793c6ef7ea@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I'd like to split fd.c into multiple source files. It's currently a mix
of a few different things:

- the Virtual File Descriptor abstraction
- misc portability and utility functions, some of which have frontend
counterparts in common/file_utils.c
- temporary file management stuff

I think it'd be good for readability to split it up. But the reason I'm
thinking about this right now is that for multithreading, I think the
Virtual File Descriptor abstraction needs changes. Before starting to
mess with that, it'd be nice to isolate it from the rest of the stuff
that's in fd.c now.

Attached patch set splits fd.c into:

- fd.c, containing the Virtual File Descriptor abstraction, i.e.
functions that operate on 'File's
- file_utils.c, containing portability and utility functions like
pg_fsync() and durable_rename()
- datadir.c, containing functions for creating/deleting directories
(e.g. MakePGDirectory)
- tempfile.c, containing functions for creating temporary files, e.g.
PathNameCreateTemporaryFile and all the temp tablespace stuff.

Patch 0001 is a little different in that it doesn't just move code
around. It removes the check at end-of-xact to check that no xact-scoped
temporary files are still open. It's been merely a redundant debugging
cross-check since commit ab3148b712 in 2009, when we started to track
temporary files with ResourceOwners. Let's just rely on ResourceOwners
and remove that. There's no immediate need to do this right now, but
simpler is better, and I don't remember that cross-check ever finding
anything useful.

- Heikki

Attachment Content-Type Size
0001-Remove-backup-mechanism-to-delete-temp-files-at-end-.patch text/x-patch 5.2 KB
0002-Move-some-functions-from-fd.c-to-file_utils.c.patch text/x-patch 56.5 KB
0003-Split-off-functions-related-to-creating-deleting-dir.patch text/x-patch 35.6 KB
0004-Make-RegisterTemporaryFile-set-the-fdstate-field-and.patch text/x-patch 7.8 KB
0005-Move-functions-related-to-temporary-file-management-.patch text/x-patch 56.5 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-07-05 18:19:25 Re: Improving display of octal GUCs
Previous Message Heikki Linnakangas 2026-07-05 17:15:45 Re: GIN index fast list search may become un-interruptible for long time.