diff options
author | Zhu Yanhai <zhu.yanhai@gmail.com> | 2009-08-12 02:17:59 -0400 |
---|---|---|
committer | Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> | 2009-09-14 05:27:14 -0400 |
commit | 43be0ec0387a5ccce2e064cb78502e7b2b4dd590 (patch) | |
tree | e412246fce3f999b46b960ef416f1f10653ca895 /fs/nilfs2 | |
parent | a4f0b9c5b4ae83636dafde8f3a0e04b5e411a0f3 (diff) |
nilfs2: add more check routines in mount process
nilfs2: Add more safeguard routines and protections in mount process,
which also makes nilfs2 report consistency error messages when
checkpoint number is invalid.
Signed-off-by: Zhu Yanhai <zhu.yanhai@gmail.com>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Diffstat (limited to 'fs/nilfs2')
-rw-r--r-- | fs/nilfs2/cpfile.c | 11 | ||||
-rw-r--r-- | fs/nilfs2/super.c | 7 |
2 files changed, 14 insertions, 4 deletions
diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c index aec942cf79e3..1c6cfb59128d 100644 --- a/fs/nilfs2/cpfile.c +++ b/fs/nilfs2/cpfile.c | |||
@@ -815,8 +815,10 @@ int nilfs_cpfile_is_snapshot(struct inode *cpfile, __u64 cno) | |||
815 | void *kaddr; | 815 | void *kaddr; |
816 | int ret; | 816 | int ret; |
817 | 817 | ||
818 | if (cno == 0) | 818 | /* CP number is invalid if it's zero or larger than the |
819 | return -ENOENT; /* checkpoint number 0 is invalid */ | 819 | largest exist one.*/ |
820 | if (cno == 0 || cno >= nilfs_mdt_cno(cpfile)) | ||
821 | return -ENOENT; | ||
820 | down_read(&NILFS_MDT(cpfile)->mi_sem); | 822 | down_read(&NILFS_MDT(cpfile)->mi_sem); |
821 | 823 | ||
822 | ret = nilfs_cpfile_get_checkpoint_block(cpfile, cno, 0, &bh); | 824 | ret = nilfs_cpfile_get_checkpoint_block(cpfile, cno, 0, &bh); |
@@ -824,7 +826,10 @@ int nilfs_cpfile_is_snapshot(struct inode *cpfile, __u64 cno) | |||
824 | goto out; | 826 | goto out; |
825 | kaddr = kmap_atomic(bh->b_page, KM_USER0); | 827 | kaddr = kmap_atomic(bh->b_page, KM_USER0); |
826 | cp = nilfs_cpfile_block_get_checkpoint(cpfile, cno, bh, kaddr); | 828 | cp = nilfs_cpfile_block_get_checkpoint(cpfile, cno, bh, kaddr); |
827 | ret = nilfs_checkpoint_snapshot(cp); | 829 | if (nilfs_checkpoint_invalid(cp)) |
830 | ret = -ENOENT; | ||
831 | else | ||
832 | ret = nilfs_checkpoint_snapshot(cp); | ||
828 | kunmap_atomic(kaddr, KM_USER0); | 833 | kunmap_atomic(kaddr, KM_USER0); |
829 | brelse(bh); | 834 | brelse(bh); |
830 | 835 | ||
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c index 019752f7d2da..50284add7880 100644 --- a/fs/nilfs2/super.c +++ b/fs/nilfs2/super.c | |||
@@ -792,10 +792,15 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent, | |||
792 | 792 | ||
793 | if (sb->s_flags & MS_RDONLY) { | 793 | if (sb->s_flags & MS_RDONLY) { |
794 | if (nilfs_test_opt(sbi, SNAPSHOT)) { | 794 | if (nilfs_test_opt(sbi, SNAPSHOT)) { |
795 | down_read(&nilfs->ns_segctor_sem); | ||
795 | err = nilfs_cpfile_is_snapshot(nilfs->ns_cpfile, | 796 | err = nilfs_cpfile_is_snapshot(nilfs->ns_cpfile, |
796 | sbi->s_snapshot_cno); | 797 | sbi->s_snapshot_cno); |
797 | if (err < 0) | 798 | up_read(&nilfs->ns_segctor_sem); |
799 | if (err < 0) { | ||
800 | if (err == -ENOENT) | ||
801 | err = -EINVAL; | ||
798 | goto failed_sbi; | 802 | goto failed_sbi; |
803 | } | ||
799 | if (!err) { | 804 | if (!err) { |
800 | printk(KERN_ERR | 805 | printk(KERN_ERR |
801 | "NILFS: The specified checkpoint is " | 806 | "NILFS: The specified checkpoint is " |