Extensible storage manager API - smgr hooks - Mailing list pgsql-hackers

From Anastasia Lubennikova
Subject Extensible storage manager API - smgr hooks
Date
Msg-id CAP4vRV6JKXyFfEOf=n+v5RGsZywAQ3CTM8ESWvgq+S87Tmgx_g@mail.gmail.com
Whole thread Raw
Responses Re: Extensible storage manager API - smgr hooks
List pgsql-hackers
Hi, hackers!

Many recently discussed features can make use of an extensible storage manager API. Namely, storage level compression and encryption [1], [2], [3], disk quota feature [4], SLRU storage changes [5], and any other features that may want to substitute PostgreSQL storage layer with their implementation (i.e. lazy_restore [6]).

Attached is a proposal to change smgr API to make it extensible.  The idea is to add a hook for plugins to get control in smgr and define custom storage managers. The patch replaces smgrsw[] array and smgr_sw selector with smgr() function that loads f_smgr implementation.

As before it has only one implementation - smgr_md, which is wrapped into smgr_standard().

To create custom implementation, a developer needs to implement smgr API functions
    static const struct f_smgr smgr_custom =
    {
        .smgr_init = custominit,
        ...
    }

create a hook function
   const f_smgr * smgr_custom(BackendId backend, RelFileNode rnode)
  {
      //Here we can also add some logic and chose which smgr to use based on rnode and backend
      return &smgr_custom;
  }

and finally set the hook:
    smgr_hook = smgr_custom;



--
Best regards,
Lubennikova Anastasia
Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: WIP: Relaxing the constraints on numeric scale
Next
From: Simon Riggs
Date:
Subject: Fix PITR msg for Abort Prepared