4) Data address translation file -- Maps virtual block numbers to usual
(DAT) block numbers. This file serves to
make on-disk blocks relocatable.
- 5) Sketch file (sketch) -- Keeps read-only data which can be
- associated with checkpoints (optional)
The following figure shows a typical organization of the logs:
return 0;
}
-static int nilfs_read_sketch_inode(struct inode *inode)
-{
- struct nilfs_sb_info *sbi = NILFS_SB(inode->i_sb);
- int err = 0;
-
- if (sbi->s_snapshot_cno) {
- struct the_nilfs *nilfs = sbi->s_nilfs;
- struct buffer_head *bh_cp;
- struct nilfs_checkpoint *raw_cp;
-
- err = nilfs_cpfile_get_checkpoint(
- nilfs->ns_cpfile, sbi->s_snapshot_cno, 0, &raw_cp,
- &bh_cp);
- if (likely(!err)) {
- if (!nilfs_checkpoint_sketch(raw_cp))
- inode->i_size = 0;
- nilfs_cpfile_put_checkpoint(
- nilfs->ns_cpfile, sbi->s_snapshot_cno, bh_cp);
- }
- inode->i_flags |= S_NOCMTIME;
- }
- return err;
-}
-
static int __nilfs_read_inode(struct super_block *sb, unsigned long ino,
struct inode *inode)
{
inode->i_op = &nilfs_file_inode_operations;
inode->i_fop = &nilfs_file_operations;
inode->i_mapping->a_ops = &nilfs_aops;
- if (unlikely(inode->i_ino == NILFS_SKETCH_INO)) {
- err = nilfs_read_sketch_inode(inode);
- if (unlikely(err))
- goto failed_unmap;
- }
} else if (S_ISDIR(inode->i_mode)) {
inode->i_op = &nilfs_dir_inode_operations;
inode->i_fop = &nilfs_dir_operations;
atomic_add(nr_dirty, &sbi->s_nilfs->ns_ndirtyblks);
- if (test_and_set_bit(NILFS_I_DIRTY, &ii->i_state) ||
- unlikely(inode->i_ino == NILFS_SKETCH_INO))
+ if (test_and_set_bit(NILFS_I_DIRTY, &ii->i_state))
return 0;
spin_lock(&sbi->s_inode_lock);
return;
}
nilfs_transaction_begin(inode->i_sb, &ti, 0);
- if (likely(inode->i_ino != NILFS_SKETCH_INO))
- nilfs_mark_inode_dirty(inode);
+ nilfs_mark_inode_dirty(inode);
nilfs_transaction_commit(inode->i_sb); /* never fails */
}
NILFS_ST_INIT = 0,
NILFS_ST_GC, /* Collecting dirty blocks for GC */
NILFS_ST_FILE,
- NILFS_ST_SKETCH,
NILFS_ST_IFILE,
NILFS_ST_CPFILE,
NILFS_ST_SUFILE,
cpu_to_le64(sci->sc_nblk_inc + sci->sc_nblk_this_inc);
raw_cp->cp_create = cpu_to_le64(sci->sc_seg_ctime);
raw_cp->cp_cno = cpu_to_le64(nilfs->ns_cno);
- if (sci->sc_sketch_inode && i_size_read(sci->sc_sketch_inode) > 0)
- nilfs_checkpoint_set_sketch(raw_cp);
+
nilfs_write_inode_common(sbi->s_ifile, &raw_cp->cp_ifile_inode, 1);
nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, nilfs->ns_cno, bh_cp);
return 0;
nilfs_fill_in_file_bmap(ifile, ii);
set_bit(NILFS_I_COLLECTED, &ii->i_state);
}
- if (sci->sc_sketch_inode) {
- ii = NILFS_I(sci->sc_sketch_inode);
- if (test_bit(NILFS_I_DIRTY, &ii->i_state))
- nilfs_fill_in_file_bmap(ifile, ii);
- }
}
/*
sci->sc_stage.scnt = NILFS_ST_DONE;
return 0;
}
- sci->sc_stage.scnt++; /* Fall through */
- case NILFS_ST_SKETCH:
- if (mode == SC_LSEG_SR && sci->sc_sketch_inode) {
- ii = NILFS_I(sci->sc_sketch_inode);
- if (test_bit(NILFS_I_DIRTY, &ii->i_state)) {
- sci->sc_sketch_inode->i_ctime.tv_sec
- = sci->sc_seg_ctime;
- sci->sc_sketch_inode->i_mtime.tv_sec
- = sci->sc_seg_ctime;
- err = nilfs_mark_inode_dirty(
- sci->sc_sketch_inode);
- if (unlikely(err))
- goto break_or_fail;
- }
- err = nilfs_segctor_scan_file(sci,
- sci->sc_sketch_inode,
- &nilfs_sc_file_ops);
- if (unlikely(err))
- goto break_or_fail;
- }
sci->sc_stage.scnt++;
sci->sc_stage.flags |= NILFS_CF_IFILE_STARTED;
/* Fall through */
} while (sci->sc_stage.scnt != NILFS_ST_DONE);
- /* Clearing sketch data */
- if (has_sr && sci->sc_sketch_inode) {
- if (i_size_read(sci->sc_sketch_inode) == 0)
- clear_bit(NILFS_I_DIRTY,
- &NILFS_I(sci->sc_sketch_inode)->i_state);
- i_size_write(sci->sc_sketch_inode, 0);
- }
out:
nilfs_segctor_destroy_segment_buffers(sci);
nilfs_segctor_check_out_files(sci, sbi);
struct nilfs_recovery_info *ri)
{
int err;
- struct inode *inode = nilfs_iget(sci->sc_super, NILFS_SKETCH_INO);
-
- sci->sc_sketch_inode = IS_ERR(inode) ? NULL : inode;
- if (sci->sc_sketch_inode)
- i_size_write(sci->sc_sketch_inode, 0);
sci->sc_seq_done = sci->sc_seq_request;
if (ri)
if (ri)
list_splice_init(&sci->sc_active_segments,
ri->ri_used_segments.prev);
- if (sci->sc_sketch_inode) {
- iput(sci->sc_sketch_inode);
- sci->sc_sketch_inode = NULL;
- }
}
return err;
}
WARN_ON(!list_empty(&sci->sc_segbufs));
- if (sci->sc_sketch_inode) {
- iput(sci->sc_sketch_inode);
- sci->sc_sketch_inode = NULL;
- }
down_write(&sbi->s_nilfs->ns_segctor_sem);
kfree(sci);
* @sc_nblk_this_inc: Number of blocks included in the current logical segment
* @sc_seg_ctime: Creation time
* @sc_flags: Internal flags
- * @sc_sketch_inode: Inode of the sketch file
* @sc_state_lock: spinlock for sc_state and so on
* @sc_state: Segctord state flags
* @sc_flush_request: inode bitmap of metadata files to be flushed
unsigned long sc_flags;
- /*
- * Pointer to an inode of the sketch.
- * This pointer is kept only while it contains data.
- * We protect it with a semaphore of the segment constructor.
- */
- struct inode *sc_sketch_inode;
-
spinlock_t sc_state_lock;
unsigned long sc_state;
unsigned long sc_flush_request;
NILFS_CHECKPOINT_FNS(SNAPSHOT, snapshot)
NILFS_CHECKPOINT_FNS(INVALID, invalid)
-NILFS_CHECKPOINT_FNS(SKETCH, sketch)
/**
* struct nilfs_cpinfo - checkpoint information
NILFS_CPINFO_FNS(SNAPSHOT, snapshot)
NILFS_CPINFO_FNS(INVALID, invalid)
-NILFS_CPINFO_FNS(SKETCH, sketch)
/**