www.pudn.com > efs.rar > fs_efs2.h


/***********************************************************************
 * fs_efs2.h
 *
 * Filesystem Mountpoint handler. EFS2
 * Copyright (C) 2002--2006, Qualcomm, Inc.
 *
 * Mountpoint handler for EFS2 flash file system.
 *
 ***********************************************************************/

/*===========================================================================

                        EDIT HISTORY FOR MODULE

  This section contains comments describing changes made to the module.
  Notice that changes are listed in reverse chronological order.

  $Header: //depot/asic/MSMSHARED/services/efs/MSM_EFS.01.02/fs_efs2.h#9 $ $DateTime: 2006/11/13 09:22:31 $ $Author: davidb $

when          who     what, where, why
--------      ---     ------------------------------------------------------
2006-11-06    dlb     Delete recovery support.
2006-10-10    dlb     Partial transaction flush support.
2006-09-29    dlb     Support info block upgrades.
2006-04-13    dlb     Add support for very long filenames.
2006-03-02    sh      Removed FS_FIELD_LIMIT_DIFF
2005-10-30    sh      Lint cleanup.
2005-12-06    sh      Added FS_PARANOIA_CHECKS to detect memory corruption.
2005-07-13    dlb     Mountpoint cleanup.
2005-04-26    dlb     Add 2K page support.
2005-01-27    dlb     Allow standalone builds.
2004-10-15    dlb     Update copyright line.
2003-08-20    dlb     Remove delayed truncate code.
2003-08-20    dlb     Use direct inode addresses.
2003-04-22    cr      Added delayed truncation restart implementation.
2003-04-15    cr      Added delayed truncation implementation to fix CR#28410.
2002-10-08    dlb     Rename to fs_efs2.h.
2002-08-08    drh     Created by gr.  Added history header.

===========================================================================*/

#ifndef __FS_EFS2_H__
#define __FS_EFS2_H__

#include "comdef.h"
#include "fs_mount.h"
#include "fs_inode.h"

#include "fs_efs2_names.h"

/* Macros for locking and releasing access to the EFS2 public functions
 */

#ifdef FS_STANDALONE
  #define FS_GLOBAL_LOCK_INIT()
  #define FS_GLOBAL_LOCK()
  #define FS_GLOBAL_UNLOCK()
#else
  #include "rex.h"
  extern rex_crit_sect_type fs_crit_sect;
  #define FS_GLOBAL_LOCK_INIT() rex_init_crit_sect (&fs_crit_sect)
  #ifdef FS_PARANOIA_CHECKS
    void fs_global_lock (void);
    void fs_global_unlock (void);

    #define FS_GLOBAL_LOCK()   do { rex_enter_crit_sect (&fs_crit_sect); \
                                    fs_global_lock(); \
                                  } while (0)
    #define FS_GLOBAL_UNLOCK() do { fs_global_unlock(); \
                                    rex_leave_crit_sect (&fs_crit_sect); \
                                  } while (0)
  #else
    #define FS_GLOBAL_LOCK() rex_enter_crit_sect (&fs_crit_sect)
    #define FS_GLOBAL_UNLOCK() rex_leave_crit_sect (&fs_crit_sect)
  #endif
#endif

/* Inode tables. */
#define FS_MOUNT_INODE_TREE_DEPTH       3

struct efs_info_data {
  /* Magic number, and version. */
  uint32        magic;
  uint32        version;

  /* Description of the inode location table.  The table is a tree, with
   * the bottom level consisting of clusters with inodes as contents.  The
   * levels above this are lists of clusters defining where to look for an
   * inode. */
  cluster_id    inode_top;

  /* Inode freelist management.  Freed inodes are chainged through the
   * data[0] cluster into the inode_free field.  When a new cluster is
   * allocated to hold inodes, inode_next points to the next available
   * inode in that cluster.  When there is no cluster available, then it is
   * set to FS_INVALID_INODE. */
  fs_inode_t    inode_next;
  fs_inode_t    inode_free;

  fs_inode_t    root;

  /******************************/
  /* First field of version supporting partial delete. */

  /* Indicates that a delete was in progress, and recovery needs to finish
   * this operation.  Zero indicates that there is no partial delete in
   * process.  Larger numbers indicate the leaf level that is currently
   * being deallocated.
   * 'partial_delete_mid' indicates that the current level was only
   * partially completed.  Counts have been adjusted, but all of the nodes
   * haven't been marked in the freemap.
   * 'partial_delete_data' contains the indirect block pointers.  Element
   * '0' is for 1 level of indirection, and so on. */
  uint8         partial_delete;
  uint8         partial_delete_mid;
  fs_gid_t      partial_delete_gid;
  cluster_id    partial_delete_data
                  [FS_DIRECTION_LEVELS - 1];
};

/* Private mountpoint data. */
struct fs_mount_efs {
  struct fs_mount       parent;
  fs_dev_t      dev;
  struct fs_vnode *root_dir;
  fsb_t         buf;
  fs_db_t       db;
  unsigned int  cluster_size;
  int           cluster_shift;

  /* How deep are our transactions. */
  int           transaction_depth;

  cluster_id    info_cluster;

  /* A cached copy of the info data. */
  struct efs_info_data  info;

  /* Dirty flag for the above. */
  int           info_dirty;

  /* A temporary inode used by the allocator. */
  struct efs_inode_struct  tmp_inode;

  /* Shift and mask for converting fixed inode addresses into
   * cluster/offset pairs. */
  int           inode_shift;
  uint32        inode_low_mask;

  /* The database itself. */
  struct fs_db_data database;
};

/* Initialize the mountpoint. */
void fs_efs2_init (void);

#endif /* not __FS_EFS2_H__ */