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


/**********************************************************************

 fs_pm_gc.h

 Garbage collector.

 Copyright (c) 2003, 2004, 2005 by QUALCOMM Incorporated. All Rights Reserved.

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

                        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_pm_gc.h#2 $ $DateTime: 2005/06/09 09:56:13 $ $Author: davidb $

when          who     what, where, why
--------      ---     ------------------------------------------------------
2005-04-26    dlb     Add 2K page support.
2004-10-15    dlb     Update copyright line.
2004-10-07    dlb     Whitespace cleanup.
2003-03-07    dlb     Created file.
===========================================================================*/

#ifndef __FS_PM_GC_H__
#define __FS_PM_GC_H__

#include "customer.h"
#include "fs_device.h"
#include "fs_pm_super.h"
#include "fs_pm_log.h"

struct fs_gc_data;
typedef struct fs_gc_data *fs_gc_t;

/* Initialize the garbage collector.  The following fields in 'gc' should
 * already be filled in: ...
 *   min_page
 *   max_page - The bounds of the region (max_page is 1 past the end).
 */
void
fs_gc_init (
    fs_gc_t             gc,
    int                 fresh_start
    );

/* Called after initialization is finished. */
void fs_gc_init_finish (fs_gc_t gc);

/* Do any urgent GC.  Returns true if anything needed to be done. */
int fs_gc_do_urgent (fs_gc_t gc);

/* Allocate a single page with this gc. */
page_id fs_gc_alloc (fs_gc_t gc);

/* Visit a log node. */
void fs_gc_visit_node (fs_gc_t gc, fs_log_code_t code, uint32 *args);

enum fs_gc_state {
  FS_GC_HEAD, FS_GC_MOVING, FS_GC_ERASE
};

struct fs_gc_data {
  /* These fields must be set before calling fs_gc_init. */
  fs_device_t   dev;
  page_id       min_page;
  page_id       max_page;
  fs_super_t    super;
  fs_log_t      log;
  void         *priv;
  cluster_id (*get_reverse) (void *priv, page_id page);
  void (*set_reverse) (void *priv, page_id page, page_id state);
  int (*erase) (void *priv, block_id block);
  void (*mark_alloc) (void *priv, page_id page);
  void (*page_move) (void *priv, page_id state, page_id old_place,
      page_id new_place);

  page_id       alloc_next;
  page_id       gc_next;
  page_id       free_count;
  enum fs_gc_state state;

  uint8         realloc_buffer[EFS_PAGE_SIZE];
};

#endif /* not __FS_PM_GC_H__ */