Skip to content

Commit c96fa46

Browse files
konistorvalds
authored andcommitted
nilfs2: mark minor flag for checkpoint created by internal operation
Nilfs creates checkpoints even for garbage collection or metadata updates such as checkpoint mode change. So, user often sees checkpoints created only by such internal operations. This is inconvenient in some situations. For example, application that monitors checkpoints and changes them to snapshots, will fall into an infinite loop because it cannot distinguish internally created checkpoints. This patch solves this sort of problem by adding a flag to checkpoint for identification. Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 458c5b0 commit c96fa46

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎fs/nilfs2/segment.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,9 @@ static void nilfs_segctor_begin_finfo(struct nilfs_sc_info *sci,
462462
sci->sc_binfo_ptr = sci->sc_finfo_ptr;
463463
nilfs_segctor_map_segsum_entry(
464464
sci, &sci->sc_binfo_ptr, sizeof(struct nilfs_finfo));
465+
466+
if (inode->i_sb && !test_bit(NILFS_SC_HAVE_DELTA, &sci->sc_flags))
467+
set_bit(NILFS_SC_HAVE_DELTA, &sci->sc_flags);
465468
/* skip finfo */
466469
}
467470

@@ -887,6 +890,11 @@ static int nilfs_segctor_fill_in_checkpoint(struct nilfs_sc_info *sci)
887890
raw_cp->cp_create = cpu_to_le64(sci->sc_seg_ctime);
888891
raw_cp->cp_cno = cpu_to_le64(nilfs->ns_cno);
889892

893+
if (test_bit(NILFS_SC_HAVE_DELTA, &sci->sc_flags))
894+
nilfs_checkpoint_clear_minor(raw_cp);
895+
else
896+
nilfs_checkpoint_set_minor(raw_cp);
897+
890898
nilfs_write_inode_common(sbi->s_ifile, &raw_cp->cp_ifile_inode, 1);
891899
nilfs_cpfile_put_checkpoint(nilfs->ns_cpfile, nilfs->ns_cno, bh_cp);
892900
return 0;
@@ -2091,6 +2099,7 @@ static void nilfs_segctor_complete_write(struct nilfs_sc_info *sci)
20912099
nilfs_set_last_segment(nilfs, segbuf->sb_pseg_start,
20922100
segbuf->sb_sum.seg_seq, nilfs->ns_cno);
20932101

2102+
clear_bit(NILFS_SC_HAVE_DELTA, &sci->sc_flags);
20942103
clear_bit(NILFS_SC_DIRTY, &sci->sc_flags);
20952104
set_bit(NILFS_SC_SUPER_ROOT, &sci->sc_flags);
20962105
} else

‎fs/nilfs2/segment.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ enum {
185185
NILFS_SC_SUPER_ROOT, /* The latest segment has a super root */
186186
NILFS_SC_PRIOR_FLUSH, /* Requesting immediate flush without making a
187187
checkpoint */
188+
NILFS_SC_HAVE_DELTA, /* Next checkpoint will have update of files
189+
other than DAT, cpfile, sufile, or files
190+
moved by GC */
188191
};
189192

190193
/* sc_state */

‎include/linux/nilfs2_fs.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ enum {
470470
NILFS_CHECKPOINT_SNAPSHOT,
471471
NILFS_CHECKPOINT_INVALID,
472472
NILFS_CHECKPOINT_SKETCH,
473+
NILFS_CHECKPOINT_MINOR,
473474
};
474475

475476
#define NILFS_CHECKPOINT_FNS(flag, name) \
@@ -494,6 +495,7 @@ nilfs_checkpoint_##name(const struct nilfs_checkpoint *cp) \
494495

495496
NILFS_CHECKPOINT_FNS(SNAPSHOT, snapshot)
496497
NILFS_CHECKPOINT_FNS(INVALID, invalid)
498+
NILFS_CHECKPOINT_FNS(MINOR, minor)
497499

498500
/**
499501
* struct nilfs_cpinfo - checkpoint information
@@ -526,6 +528,7 @@ nilfs_cpinfo_##name(const struct nilfs_cpinfo *cpinfo) \
526528

527529
NILFS_CPINFO_FNS(SNAPSHOT, snapshot)
528530
NILFS_CPINFO_FNS(INVALID, invalid)
531+
NILFS_CPINFO_FNS(MINOR, minor)
529532

530533

531534
/**

0 commit comments

Comments
 (0)