* [PATCH] nilfs2: add more check routines in mount process
@ 2009-08-12 6:17 Zhu Yanhai
[not found] ` <4A825E97.10605-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Zhu Yanhai @ 2009-08-12 6:17 UTC (permalink / raw)
To: NILFS Users mailing list; +Cc: Zhang Qiang, Zhu Yanhai
nilfs2: Add more safeguard routines and protections in mount process,
which also makes nilsf2 report consistency error messages when checkpoint
number is invalid.
Signed-off-by: Zhu Yanhai <zhu.yanhai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
fs/nilfs2/cpfile.c | 11 ++++++++---
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 aec942c..1c6cfb5 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)
void *kaddr;
int ret;
- if (cno == 0)
- return -ENOENT; /* checkpoint number 0 is invalid */
+ /* CP number is invalid if it's zero or larger than the
+ largest exist one.*/
+ if (cno == 0 || cno >= nilfs_mdt_cno(cpfile))
+ return -ENOENT;
down_read(&NILFS_MDT(cpfile)->mi_sem);
ret = nilfs_cpfile_get_checkpoint_block(cpfile, cno, 0, &bh);
@@ -824,7 +826,10 @@ int nilfs_cpfile_is_snapshot(struct inode *cpfile, __u64 cno)
goto out;
kaddr = kmap_atomic(bh->b_page, KM_USER0);
cp = nilfs_cpfile_block_get_checkpoint(cpfile, cno, bh, kaddr);
- ret = nilfs_checkpoint_snapshot(cp);
+ if (nilfs_checkpoint_invalid(cp))
+ ret = -ENOENT;
+ else
+ ret = nilfs_checkpoint_snapshot(cp);
kunmap_atomic(kaddr, KM_USER0);
brelse(bh);
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 8e2ec43..b2ad589 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -814,10 +814,15 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent,
if (sb->s_flags & MS_RDONLY) {
if (nilfs_test_opt(sbi, SNAPSHOT)) {
+ down_read(&nilfs->ns_segctor_sem);
err = nilfs_cpfile_is_snapshot(nilfs->ns_cpfile,
sbi->s_snapshot_cno);
- if (err < 0)
+ up_read(&nilfs->ns_segctor_sem);
+ if (err < 0) {
+ if (err == -ENOENT)
+ err = -EINVAL;
goto failed_sbi;
+ }
if (!err) {
printk(KERN_ERR
"NILFS: The specified checkpoint is "
--
1.6.2.2
^ permalink raw reply related [flat|nested] 2+ messages in thread[parent not found: <4A825E97.10605-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH] nilfs2: add more check routines in mount process [not found] ` <4A825E97.10605-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2009-08-12 11:58 ` Ryusuke Konishi 0 siblings, 0 replies; 2+ messages in thread From: Ryusuke Konishi @ 2009-08-12 11:58 UTC (permalink / raw) To: users-JrjvKiOkagjYtjvyW6yDsg, zhu.yanhai-Re5JQEeQqe8AvxtiuMwx3w Cc: qiang.z.zhang-ral2JQCrhuEAvxtiuMwx3w, yanhai.zhu-VuQAYsv1563Yd54FQh9/CA On Wed, 12 Aug 2009 14:17:59 +0800, Zhu Yanhai wrote: > nilfs2: Add more safeguard routines and protections in mount process, > which also makes nilsf2 report consistency error messages when checkpoint > number is invalid. > > Signed-off-by: Zhu Yanhai <zhu.yanhai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > --- > fs/nilfs2/cpfile.c | 11 ++++++++--- > 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 aec942c..1c6cfb5 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) > void *kaddr; > int ret; > > - if (cno == 0) > - return -ENOENT; /* checkpoint number 0 is invalid */ > + /* CP number is invalid if it's zero or larger than the > + largest exist one.*/ > + if (cno == 0 || cno >= nilfs_mdt_cno(cpfile)) > + return -ENOENT; > down_read(&NILFS_MDT(cpfile)->mi_sem); > > ret = nilfs_cpfile_get_checkpoint_block(cpfile, cno, 0, &bh); > @@ -824,7 +826,10 @@ int nilfs_cpfile_is_snapshot(struct inode *cpfile, __u64 cno) > goto out; > kaddr = kmap_atomic(bh->b_page, KM_USER0); > cp = nilfs_cpfile_block_get_checkpoint(cpfile, cno, bh, kaddr); > - ret = nilfs_checkpoint_snapshot(cp); > + if (nilfs_checkpoint_invalid(cp)) > + ret = -ENOENT; > + else > + ret = nilfs_checkpoint_snapshot(cp); > kunmap_atomic(kaddr, KM_USER0); > brelse(bh); > > diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c > index 8e2ec43..b2ad589 100644 > --- a/fs/nilfs2/super.c > +++ b/fs/nilfs2/super.c > @@ -814,10 +814,15 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent, > > if (sb->s_flags & MS_RDONLY) { > if (nilfs_test_opt(sbi, SNAPSHOT)) { > + down_read(&nilfs->ns_segctor_sem); > err = nilfs_cpfile_is_snapshot(nilfs->ns_cpfile, > sbi->s_snapshot_cno); > - if (err < 0) > + up_read(&nilfs->ns_segctor_sem); > + if (err < 0) { > + if (err == -ENOENT) > + err = -EINVAL; > goto failed_sbi; > + } > if (!err) { > printk(KERN_ERR > "NILFS: The specified checkpoint is " > -- > 1.6.2.2 Applied. Thank you! Ryusuke Konishi ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-08-12 11:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-12 6:17 [PATCH] nilfs2: add more check routines in mount process Zhu Yanhai
[not found] ` <4A825E97.10605-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-08-12 11:58 ` Ryusuke Konishi
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.