All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH]nilfs2: Don't load/check invalid cno
@ 2009-07-27  9:25 Zhu Yanhai
       [not found] ` <4A6D7273.5010906-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Zhu Yanhai @ 2009-07-27  9:25 UTC (permalink / raw)
  To: NILFS Users mailing list
  Cc: qiang.z.zhang-ral2JQCrhuEAvxtiuMwx3w,
	yanhai.zhu-VuQAYsv1563Yd54FQh9/CA

nilfs2: Don't load/check cp block if specified cno is larger than the
largest exist one.
nilfs2 would load invalid cp block, and report random inconsistent error
message under this situation before.

Signed-off-by: Zhu Yanhai <zhu.yanhai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

---
 fs/nilfs2/cpfile.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/nilfs2/cpfile.c b/fs/nilfs2/cpfile.c
index aec942c..43978a9 100644
--- a/fs/nilfs2/cpfile.c
+++ b/fs/nilfs2/cpfile.c
@@ -814,9 +814,10 @@ int nilfs_cpfile_is_snapshot(struct inode *cpfile, __u64 cno)
 	struct nilfs_checkpoint *cp;
 	void *kaddr;
 	int ret;
-
-	if (cno == 0)
-		return -ENOENT; /* checkpoint number 0 is invalid */
+
+	/* return ENOENT if cno is invalid. */
+	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);
-- 
1.6.2.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-07-28  0:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-27  9:25 [PATCH]nilfs2: Don't load/check invalid cno Zhu Yanhai
     [not found] ` <4A6D7273.5010906-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-07-27  9:26   ` Zhu Yanhai
     [not found]     ` <977a2be20907270226s7c7037b5v38830e1ba68cefcb-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-07-27 17:40       ` Ryusuke Konishi
     [not found]         ` <20090728.024035.102951444.ryusuke-sG5X7nlA6pw@public.gmane.org>
2009-07-28  0:46           ` Zhu Yanhai

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.