]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/nilfs2/the_nilfs.h
nilfs2: introduce secondary super block
[linux-2.6-omap-h63xx.git] / fs / nilfs2 / the_nilfs.h
index 75da37306964c9c845b8e9f907b8f053b9f7ac47..30fe58778d05a6a8ca335a0848e3a8467827d0ff 100644 (file)
@@ -49,9 +49,10 @@ enum {
  * @ns_sem: semaphore for shared states
  * @ns_writer_mutex: mutex protecting ns_writer attach/detach
  * @ns_writer_refcount: number of referrers on ns_writer
- * @ns_sbh: buffer head of the on-disk super block
- * @ns_sbp: pointer to the super block data
- * @ns_used_segments: list of full segments in volatile active state
+ * @ns_sbh: buffer heads of on-disk super blocks
+ * @ns_sbp: pointers to super block data
+ * @ns_sbwtime: previous write time of super blocks
+ * @ns_sbsize: size of valid data in super block
  * @ns_supers: list of nilfs super block structs
  * @ns_seg_seq: segment sequence counter
  * @ns_segnum: index number of the latest full segment.
@@ -65,6 +66,7 @@ enum {
  * @ns_last_pseg: start block number of the latest segment
  * @ns_last_seq: sequence value of the latest segment
  * @ns_last_cno: checkpoint number of the latest segment
+ * @ns_prot_seq: least sequence number of segments which must not be reclaimed
  * @ns_free_segments_count: counter of free segments
  * @ns_segctor_sem: segment constructor semaphore
  * @ns_dat: DAT file inode
@@ -101,9 +103,10 @@ struct the_nilfs {
         * - protecting s_dirt in the super_block struct
         *   (see nilfs_write_super) and the following fields.
         */
-       struct buffer_head     *ns_sbh;
-       struct nilfs_super_block *ns_sbp;
-       struct list_head        ns_used_segments;
+       struct buffer_head     *ns_sbh[2];
+       struct nilfs_super_block *ns_sbp[2];
+       time_t                  ns_sbwtime[2];
+       unsigned                ns_sbsize;
        unsigned                ns_mount_state;
        struct list_head        ns_supers;
 
@@ -132,6 +135,7 @@ struct the_nilfs {
        sector_t                ns_last_pseg;
        u64                     ns_last_seq;
        __u64                   ns_last_cno;
+       u64                     ns_prot_seq;
        unsigned long           ns_free_segments_count;
 
        struct rw_semaphore     ns_segctor_sem;
@@ -182,15 +186,20 @@ THE_NILFS_FNS(INIT, init)
 THE_NILFS_FNS(LOADED, loaded)
 THE_NILFS_FNS(DISCONTINUED, discontinued)
 
+/* Minimum interval of periodical update of superblocks (in seconds) */
+#define NILFS_SB_FREQ          10
+#define NILFS_ALTSB_FREQ       60  /* spare superblock */
+
 void nilfs_set_last_segment(struct the_nilfs *, sector_t, u64, __u64);
 struct the_nilfs *alloc_nilfs(struct block_device *);
 void put_nilfs(struct the_nilfs *);
 int init_nilfs(struct the_nilfs *, struct nilfs_sb_info *, char *);
 int load_nilfs(struct the_nilfs *, struct nilfs_sb_info *);
 int nilfs_count_free_blocks(struct the_nilfs *, sector_t *);
-void nilfs_dispose_used_segments(struct the_nilfs *);
 int nilfs_checkpoint_is_mounted(struct the_nilfs *, __u64, int);
 int nilfs_near_disk_full(struct the_nilfs *);
+void nilfs_fall_back_super_block(struct the_nilfs *);
+void nilfs_swap_super_block(struct the_nilfs *);
 
 
 static inline void get_nilfs(struct the_nilfs *nilfs)
@@ -281,4 +290,9 @@ static inline __u64 nilfs_last_cno(struct the_nilfs *nilfs)
        return cno;
 }
 
+static inline int nilfs_segment_is_active(struct the_nilfs *nilfs, __u64 n)
+{
+       return n == nilfs->ns_segnum || n == nilfs->ns_nextnum;
+}
+
 #endif /* _THE_NILFS_H */