CODE SPORT

This month’s col­umn con­tin­ues the dis­cus­sion on data stor­age sys­tems, with the fo­cus on the meta­data struc­tures of file sys­tems.

OpenSource For You - - CODE SPORT - Sandya Man­nar­swamy

Last month we dis­cussed how er­rors can oc­cur in file sys­tems and stor­age stacks. We also cov­ered ‘fsck’ – the file sys­tem con­sis­tency check­ing tool. In this month’s col­umn, let’s dis­cuss how file sys­tem con­sis­tency is main­tained in case of ‘up­date in place’ file sys­tems.

The most crit­i­cal piece of in­for­ma­tion as­so­ci­ated with file sys­tems is file sys­tem meta­data. This rep­re­sents in­for­ma­tion about a file such as where its data blocks are lo­cated, the ac­cess rights, the cre­ator of the file, the time at which the file was mod­i­fied/ac­cessed, etc. The meta­data also in­cludes in­for­ma­tion like the root of the file sys­tem, its block size and mount point, etc. The ma­jor data struc­tures used to rep­re­sent file sys­tem meta­data in­for­ma­tion in­clude su­perblock, in­ode and den­try.

To re­call last month’s dis­cus­sion on the ‘Vir­tual File Sys­tem (VFS)’ in Linux, VFS pro­vides a generic file sys­tem ab­strac­tion layer over any low level file sys­tem layer. The generic file sys­tem op­er­a­tions like read, write, cre­ate, etc are mapped by VFS onto un­der­ly­ing op­er­a­tions of the spe­cific file sys­tem. The meta­data struc­tures at the VFS layer in­clude su­perblock, in­ode and den­try. Each of th­ese data struc­tures sup­ports a set of op­er­a­tions. For in­stance, su­perblock con­tains a set of su­perblock op­er­a­tions known as ‘su­per_­op­er­a­tions’. Th­ese op­er­a­tions are de­fined by the spe­cific file sys­tem layer cor­re­spond­ing to that su­per-block. And they rep­re­sent the func­tions/meth­ods which the Linux ker­nel in­vokes for each of th­ese spe­cific ob­jects, based on the un­der­ly­ing file sys­tem. This al­lows the ker­nel VFS layer to be trans­par­ent to the un­der­ly­ing file sys­tem in­ter­nals while sup­port­ing generic in­ter­faces.

When we dis­cuss file sys­tem in­ter­nal data struc­tures, one point to note is that since file sys­tem meta­data is main­tained on disk as part of the file sys­tem it­self, each of th­ese meta­data struc­tures has both a disk rep­re­sen­ta­tion and in-mem­ory rep­re­sen­ta­tion. The in-mem­ory rep­re­sen­ta­tion is con­structed from the on-disk rep­re­sen­ta­tion of the data struc­ture.

The su­perblock data struc­ture con­tains in­for­ma­tion about a spe­cific mounted file sys­tem. There is one su­perblock ob­ject for each file sys­tem mounted. There is an in-mem­ory rep­re­sen­ta­tion of the su­perblock as well as on-disk rep­re­sen­ta­tion. The on-disk su­perblock is typ­i­cally stored on a spe­cific po­si­tion on the disk as­so­ci­ated with that file sys­tem, which en­ables the ker­nel to ac­cess the disk su­perblock when the file sys­tem is mounted and to con­struct the in-mem­ory rep­re­sen­ta­tion of it. In the Linux ker­nel, the su­perblock ob­ject is rep­re­sented by ‘struct su­perblock’ and is de­fined in <linux/fs.h>.

A su­perblock ob­ject for a file sys­tem is cre­ated when the file sys­tem is mounted by the ker­nel. For the Linux ker­nel, this is done by means of the ‘al­loc_­su­per’ func­tion which is de­fined in fs/ su­per.c. ‘Struct su­perblock’ con­tains a struc­ture field mem­ber called ‘s_op’. This is a pointer to a struc­ture of type ‘struc­ture su­per_­op­er­a­tions’, which de­fines var­i­ous func­tions op­er­at­ing on the file sys­tem such as ‘put_­su­per’, ‘write_­su­per’, ‘sync_fs’ and var­i­ous in­ode re­lated op­er­a­tions such as ‘al­loc_in­ode’, ‘de­stroy_in­ode’, ‘dirty_in­ode’, etc.

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.