All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhu Yanhai <zhu.yanhai-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: NILFS Users mailing list <users-JrjvKiOkagjYtjvyW6yDsg@public.gmane.org>
Cc: qiang.z.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	yanhai.zhu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org
Subject: [PATCH]nilfs2: Don't load/check invalid cno
Date: Mon, 27 Jul 2009 17:25:07 +0800	[thread overview]
Message-ID: <4A6D7273.5010906@gmail.com> (raw)

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

             reply	other threads:[~2009-07-27  9:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-27  9:25 Zhu Yanhai [this message]
     [not found] ` <4A6D7273.5010906-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-07-27  9:26   ` [PATCH]nilfs2: Don't load/check invalid cno 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A6D7273.5010906@gmail.com \
    --to=zhu.yanhai-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=qiang.z.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=users-JrjvKiOkagjYtjvyW6yDsg@public.gmane.org \
    --cc=yanhai.zhu-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.