nilfs2: delete unnecessary condition in load_segment_summary
[safe/jmp/linux-2.6] / fs / nilfs2 / gcinode.c
index 0013952..e16a666 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * gcinode.c - NILFS memory inode for GC
+ * gcinode.c - dummy inodes to buffer blocks for garbage collection
  *
  * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
  *
  * Revised by Ryusuke Konishi <ryusuke@osrg.net>.
  *
  */
+/*
+ * This file adds the cache of on-disk blocks to be moved in garbage
+ * collection.  The disk blocks are held with dummy inodes (called
+ * gcinodes), and this file provides lookup function of the dummy
+ * inodes and their buffer read function.
+ *
+ * Since NILFS2 keeps up multiple checkpoints/snapshots accross GC, it
+ * has to treat blocks that belong to a same file but have different
+ * checkpoint numbers.  To avoid interference among generations, dummy
+ * inodes are managed separatly from actual inodes, and their lookup
+ * function (nilfs_gc_iget) is designed to be specified with a
+ * checkpoint number argument as well as an inode number.
+ *
+ * Buffers and pages held by the dummy inodes will be released each
+ * time after they are copied to a new log.  Dirty blocks made on the
+ * current generation and the blocks to be moved by GC never overlap
+ * because the dirty blocks make a new generation; they rather must be
+ * written individually.
+ */
 
 #include <linux/buffer_head.h>
 #include <linux/mpage.h>
@@ -33,8 +52,9 @@
 #include "dat.h"
 #include "ifile.h"
 
-static struct address_space_operations def_gcinode_aops = {};
-/* XXX need def_gcinode_iops/fops? */
+static const struct address_space_operations def_gcinode_aops = {
+       .sync_page              = block_sync_page,
+};
 
 /*
  * nilfs_gccache_submit_read_data() - add data buffer and submit read request
@@ -129,7 +149,7 @@ int nilfs_gccache_submit_read_node(struct inode *inode, sector_t pbn,
                                   __u64 vbn, struct buffer_head **out_bh)
 {
        int ret = nilfs_btnode_submit_block(&NILFS_I(inode)->i_btnode_cache,
-                                           vbn ? : pbn, pbn, out_bh, 0);
+                                           vbn ? : pbn, pbn, out_bh);
        if (ret == -EEXIST) /* internal code (cache hit) */
                ret = 0;
        return ret;
@@ -192,9 +212,10 @@ void nilfs_destroy_gccache(struct the_nilfs *nilfs)
 static struct inode *alloc_gcinode(struct the_nilfs *nilfs, ino_t ino,
                                   __u64 cno)
 {
-       struct inode *inode = nilfs_mdt_new_common(nilfs, NULL, ino, GFP_NOFS);
+       struct inode *inode;
        struct nilfs_inode_info *ii;
 
+       inode = nilfs_mdt_new_common(nilfs, NULL, ino, GFP_NOFS, 0);
        if (!inode)
                return NULL;
 
@@ -207,7 +228,6 @@ static struct inode *alloc_gcinode(struct the_nilfs *nilfs, ino_t ino,
        ii->i_flags = 0;
        ii->i_state = 1 << NILFS_I_GCINODE;
        ii->i_bh = NULL;
-       ii->i_dtime = 0;
        nilfs_bmap_init_gc(ii->i_bmap);
 
        return inode;
@@ -246,7 +266,6 @@ struct inode *nilfs_gc_iget(struct the_nilfs *nilfs, ino_t ino, __u64 cno)
  */
 void nilfs_clear_gcinode(struct inode *inode)
 {
-       nilfs_mdt_clear(inode);
        nilfs_mdt_destroy(inode);
 }