Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fs(5) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chfstore

inode

chfstore

store



FS(5,F)                     AIX Technical Reference                     FS(5,F)



-------------------------------------------------------------------------------
fs



PURPOSE

Contains the format of a file system volume.

SYNOPSIS

#include <sys/types.h>
#include <sys/filsys.h>

DESCRIPTION

Every file system storage volume has a common format for certain vital
information.  Every such volume is divided into a certain number of 4096-byte
sectors.  Sector 0 is unused and is available to contain a bootstrap program,
pack label, or other information.

Sector 1 is the super block.  The super block describes the layout of the file
system.  The sectors immediately following the super block contain the inodes
(see "inode").  Each allocated inode describes a file in the file system.  The
remaining sectors of the file system are a pool of blocks from which the data
blocks of files are allocated.

A file system volume may be designated as being one of several replicated
copies of a file system.  When this is done, each copy (also called a pack) of
the file system is given the same global file system number, and each copy,
when mounted, must be mounted on separate sites and at the same place in the
network-wide directory hierarchy (see "mount").  All copies of a replicated
file system must agree on the read-only status with which they are mounted.

Each copy of a replicated file system must have the same number of inodes, thus
allowing each copy to have the potential of storing any of the files in the
file system.  However, each copy of the file system need not actually store the
data for all of the files in the file system.  Because of this, the copies of a
file system need not be the same size.  Certain copies may have a smaller pool
of blocks from which to allocate data blocks for files.

One copy of a replicated file system is designated the primary copy.  This copy
must be mounted on one of the sites in the network (called the primary site for
this file system) in order for any user or process to make a change to any file
in the file system.  When a change is made to a file, it is made first to the
primary copy, and after the change has been committed (see "fsync, fcommit"),
the other sites which store this file are updated.  If a copy of the file
system is not mounted, is on a site which is down, or is on a site which is not
in communication with the primary site, the propagation of the changed file to
this copy is done automatically at a later time.  If none of the currently
mounted copies of a replicated file system is the primary copy, the files in
the file system are treated as read-only.



Processed November 7, 1990          FS(5,F)                                   1





FS(5,F)                     AIX Technical Reference                     FS(5,F)




A copy other than the primary copy of a file system may be designated as
storing all of the files in the file system.  Such a copy is called a backbone
copy of the file system, and the site on which it is mounted is called a
backbone site.

The remaining copies of the file system, those not designated as the primary
copy or as a backbone copy, selectively store files according to the fstore
attribute of each file (see "chfstore").  The interpretation of a file's fstore
attribute is different for file systems designated as system-replicated than
for file systems designated as user-replicated.

In a system-replicated file system, the data pages of a file are stored in a
non-primary, non-backbone copy if the logical AND of the file's fstore value
and the super block's fstore value is nonzero.  The program chfstore or the
system call chfstore is used to change a file's fstore value if the file is in
a system-replicated file system.

In a user-replicated file system, the data pages of a file are stored in a
nonprimary, non-backbone copy which has pack number packno if the packno bit of
the file's fstore value is set.  The low order bit (0x1) of the fstore value
represents pack number 1, while the high order bit (0x80000000) represents pack
number 32.  The program store or the system call chfstore is used to change a
file's fstore value if the file is in a user-replicated file system.

The layout of the super block as defined by the include file <sys/filsys.h> is:

  #define NICFREE    600
  #define NICINOD    325
  #define NCMTLST    200
  #define NGENLST    25

  /* number of freeblock pointers in the super block */
  /* for replicated file systems                     */
  #define NICSFREE   NICFREE \
                     - (NGENLST * sizeof(fsgen_t) \
                     + NCMTLST * sizeof(commitcnt_t)) / sizeof(daddr_t)


















Processed November 7, 1990          FS(5,F)                                   2





FS(5,F)                     AIX Technical Reference                     FS(5,F)



  /*
   * Structure of the super block
   */
  struct  filsys
  {
      long           s_magic;     /* identifies this as a TCF file system */
                                  /* defined as a constant below */
      gfs_t          s_gfs;       /* global file system number */
      daddr_t        s_fsize;     /* size in blocks of entire volume */
      commitcnt_t    s_lwm;       /* all prior commits propagated */
      commitcnt_t    s_hwm;       /* highest commit propagated */
      /* oldest committed version in the list.
       * llst mod NCMTLST is the offset of commit #llst in the list,
       * which wraps around from there.
       */
      commitcnt_t    s_llst;
      fstore_t       s_fstore;    /* file system storage bit mask; if the
                                     filsys is replicated and this is not a
                                     primary or backbone copy, this bit mask
                                     determines which files are stored */

      time_t         s_time;      /* last super block update */
      daddr_t        s_tfree;     /* total free blocks*/

      ino_t          s_isize;     /* size in blocks of i-list */
      short          s_nfree;     /* number of addresses in s_free */
      unsigned short s_flags;     /* filsys flags, defined below */

  #define s_ronly s_flags
      ino_t          s_tinode;    /* total free inodes */
      ino_t          s_lasti;     /* start place for circular search */
      ino_t          s_nbehind;   /* est # free inodes before s_lasti */
      pckno_t        s_gfspack;   /* global file system pack number */
      short          s_ninode;    /* number of inodes in s_inode */
      short          s_dinfo[4];  /* interleave stuff */
  #define s_m     s_dinfo[0]
  #define s_skip  s_dinfo[0]
  #define s_n     s_dinfo[1]
  #define s_cyl   s_dinfo[1]
      char           s_flock;     /* lock during free list manipulation */
      char           s_ilock;     /* lock during i-list manipulation */
      char           s_fmod;      /* super block modified flag */
      char           s_version;   /* version of the data format in fs. */
      char           s_fsmnt[32]; /* name of this file system */
      char           s_fpack[8];  /*name of this physical vol.*/










Processed November 7, 1990          FS(5,F)                                   3





FS(5,F)                     AIX Technical Reference                     FS(5,F)



  #define s_fname s_fsmnt                /* for backwards compatibility */
      ino_t          s_inode[NICINOD];   /* free inode list */
      union {   /* union of replicated and non-replicated filsystem types */
          daddr_t su_free[NICFREE];      /* free block list
                                           for non-replicated filsys */
          struct {
              daddr_t     su_sfree[NICSFREE]; /* free block list
                                                 for replicated filsys */
              ino_t       su_cmtlst[NCMTLST]; /* list of recent*/
                                              /* commits         */
              commitcnt_t su_mntcnt;          /* prim site mounts */
              fsgen_t     su_fsgens[NGENLST]; /* filsys generations */
          } su_st;
      } s_un;
  #define s_free     s_un.su_free
  #define s_cmtlst   s_un.su_st.su_cmtlst
  #define s_fsgens   s_un.su_st.su_fsgens
  #define s_mntcnt   s_un.su_st.su_mntcnt
      char           s_byteorder;      /* byte order of integers */

  };

          /* Current magic number */
  #define SB_MAGIC        0xffeeddcd   /* word unlikely to be found in non-fs*/

s_magic contains the value SB_MAGIC and identifies this storage medium as a
valid AIX file system.

s_version is a version number for the format of the file system.  It is changed
whenever the structure of the super block or inodes change in an incompatible
way.

The global file system number, s_gfs, is the unique name for this file system.
Each file system has a distinct s_gfs number.  Each copy of a replicated file
system has the same s_gfs number, but has a distinct s_gfspack number.  To
uniquely identify a file in AIX, the pair gfs,inumber is used.  To uniquely
identify a copy of a replicated file, the triple gfs, gfspack, inumber is used.

s_isize is the address of the first block after the i-list, which starts just
after the super block, block 2.  Thus the i-list is s_isize-2 blocks long.
s_fsize is the address of the first block not potentially available for
allocation to a file.  These numbers are used by the system to check for bad
block addresses; if an "impossible" block address is allocated from the free
list or is freed, a diagnostic message is written on the on-line console.
Moreover, the free array is cleared, so as to prevent further allocation from a
presumably corrupted free list.

The free list for each volume is maintained as follows.  The s_free array
contains, in s_free [1], ... , s_free [s_nfree-1], up to NICFREE free block
numbers.  s_free [0] is the block address of the head of a chain of blocks
constituting the free list.  In a replicated file system, the number of free
block numbers is only NICSFREE.



Processed November 7, 1990          FS(5,F)                                   4





FS(5,F)                     AIX Technical Reference                     FS(5,F)




The layout of each block of the free chain as defined in the include file
<sys/fblk.h> is:

   struct fblk
   {
       long  df_nfree;
       daddr_t df_free[NICFREE];
   };

The fields df_nfree and df_free in a free block are used exactly like s_nfree
and s_free in the super block.  To allocate a block: decrement s_nfree, and the
new block number is s_free [s_nfree].  If the new block address is 0, there are
no blocks left, so give an error.  If s_nfree became 0, read the new block into
s_nfree and s_free.  To free a block, check if s_nfree is NICFREE; if so, copy
s_nfree and the s_free array into it, write it out, and set s_nfree to 0.  In
any event set s_free [s_nfree] to the freed block's address and increment
s_nfree.

s_cmtlst is a list of the last NCMTLST changed files.  s_llst (module NCMTLST)
is the index of the oldest entry in the list.  s_hwm (module NCMTLST) is the
index of the newest entry in the list; that is, the high water mark of commits
seen.  If s_lwm is within NCMTLST of s_hwm, s_lwm (module NCMTLST) is the index
of the most recent entry in the list up to which every entry has been processed
and the local file brought up to date; that is, the low water mark of commits
propagated.  These three indices always follow the relationship that "s_llst <=
s_lwm <= s_hwm".  In the primary copy of the file system, s_lwm and s_hwm are
always equal.

s_ninode is the number of free i-numbers in the s_inode array.  To allocate an
inode: if s_ninode is greater than 0, decrement it and return s_inode
[s_ninode].  If it was 0, read the i-list and place the numbers of all free
inodes (up to NICINOD) into the s_inode array, then try again.  To free an
inode, provided s_ninode is less than NICINODE, place its number into s_inode
[s_ninode] and increment s_ninode.  If s_ninode is already NICINODE, don't
bother to enter the freed inode into any table.  This list of inodes is only to
speed up the allocation process; the information as to whether the inode is
really free or not is maintained in the inode itself.

The fields s_lasti and s_nbehind are used to avoid searching the inode list
from the beginning each time the system runs out of inodes.  s_lasti gives the
base of the block of inodes last searched on the file system when inodes ran
out, and s_nbehind gives the number of inodes, whose numbers were less than
s_lasti when they were freed with s_ninode already NICINODE.  Thus s_nbehind is
the number of free inodes before s_lasti.  The system will search forward for
free inodes from s_lasti for more inodes unless s_nbehind is sufficiently
large, in which case it will search the file system inode list from the
beginning.  This mechanism serves to avoid n**2 behavior in allocating inodes.

s_flock and s_ilock are flags maintained in main memory while the file system
is mounted and their values on disk are immaterial.  The value of s_fmod on
disk is likewise immaterial; it is used as a flag to indicate that the super



Processed November 7, 1990          FS(5,F)                                   5





FS(5,F)                     AIX Technical Reference                     FS(5,F)



block has changed and should be copied to the disk during the next periodic
update of file system information.

s_flags is a set of flag bits whose values are defined as follows:

   /* Flags used in s_flags */
   #define SB_RDONLY   0x1  /* no writes allowed on file system         */
   #define SB_CLEAN    0x2  /* file system was unmounted cleanly        */
   #define SB_DIRTY    0x4  /* file system was mounted without clean bit set */
   #define SB_PRIMPACK 0x10 /* This is primary pack of the file system  */
   #define SB_REPLTYPE 0x20 /* This is a replicated type of file system */
   #define SB_USER     0x40 /* This is a user-replicated file system    */
   #define SB_BACKBONE 0x80 /* This is a backbone copy of file system   */

The SB_RDONLY flag is used only in main memory to indicate that the file system
is mounted read only.  The SB_CLEAN flag is used to indicate that a file system
has been unmounted cleanly or that file system checks have been successfully
run.  This indicates that file system checks are not necessary when the file
system is next mounted.  The SB_DIRTY flag is to guard against the SB_CLEAN
flag being turned on when an unchecked file system is mounted and then
unmounted.

The SB_REPLTYPE flag indicates that this is a replicated file system.  If it is
a replicated file system, the SB_PRIMPACK flag identifies the primary copy --
the only copy of the replicated file system that can be modified.  The
SB_BACKBONE flag indicates a site which will store a complete copy of the file
system.  SB_PRIMPACK and SB_BACKBONE should not both be set.  The SB_USER flag
identifies a replicated file system as being a user-replicated file system, as
opposed to a system-replicated file system.  All copies of a file system should
agree on whether the file system is user-replicated or system-replicated.  As
described above, the system interprets the file storage value (fstore) of a
file in a user-replicated and system-replicated file system differently.  In
user-replicated file systems, the fstore bits refer to file system pack
numbers; while in system-replicated file systems, the fstore bits of a file are
compared to the s_fstore field in the super block.  The s_fstore field is only
relevant if neither SB_BACKBONE nor SB_PRIMPACK is set.  System-replicated and
user-replicated file systems also differ in the way symbolic links are deleted.
The system call rmslink must be used to remove a symbolic link from a
system-replicated file system.  This restriction is to prevent symbolic links
in the replicated root file system from being deleted inadvertently.

s_time is the last time the super block of the file system was changed.

The total number of unallocated blocks in a file system is maintained in the
field s_tfree.  In a replicated file system, this number may be different in
the individual copies of the file system.  The total number of unallocated
inodes in a file system is maintained in the field s_tinode.  In a replicated
file system, this number is only maintained at the primary site.  The value of
s_tinode stored in the super block of other copies is undefined.

The fields s_fpack and s_byteorder are not currently maintained.




Processed November 7, 1990          FS(5,F)                                   6





FS(5,F)                     AIX Technical Reference                     FS(5,F)



FILES

/usr/include/sys/filsys.h
/usr/include/sys/stat.h

RELATED INFORMATION

In this book:  "chfstore" and "inode."

The chfstore and store commands in AIX Operating System Commands Reference.













































Processed November 7, 1990          FS(5,F)                                   7



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026