Btrfs clone WIP patch - Mailing list pgsql-hackers

From Jonathan Rogers
Subject Btrfs clone WIP patch
Date
Msg-id 511B5D11.4040507@socialserve.com
Whole thread Raw
Responses Re: Btrfs clone WIP patch  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
This patch against PostgreSQL 9.1.8 takes advantage of efficient file
cloning on Linux Btrfs file systems to make CREATE DATABASE operations
extremely fast regardless of the size of the database used as a
template. On my system, I can create a database from a multi-gibibyte
template in a second or less. This is very useful for automated testing
as well in a development environment where reverting to a baseline
database is frequently required. As an added bonus, newly created
databases require very little additional disk storage until they diverge
from the template.

The efficient cloning is accomplished by a Btrfs-specific ioctl() call.
On non-Linux systems or if the ioctl() call fails, file contents are
copied in the conventional way so no configuration is needed. This has
been tested on a Linux system on both Btrfs and XFS file systems as well
as an OSX system.

The clone_file() function was originally copied from GNU coreutils which
is under GPL v3. The function is currently only about ten lines long and
contains little essential information beyond the magic values needed for
the ioctl() call so I'm not sure if license is a problem.
--
Jonathan Ross Rogers

Attachment

pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: 9.2.3 crashes during archive recovery
Next
From: Heikki Linnakangas
Date:
Subject: Re: Fractal tree indexing