From: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
To: Vegard Nossum <vegard.nossum@gmail.com>
Cc: jfs-discussion@lists.sourceforge.net,
Johannes Weiner <hannes@saeurebad.de>,
linux-kernel@vger.kernel.org
Subject: Re: latest -git: BUG at fs/jfs/namei.c:512 assert(ip->i_nlink)
Date: Thu, 17 Jul 2008 18:09:24 -0500 [thread overview]
Message-ID: <1216336164.32175.3.camel@norville.austin.ibm.com> (raw)
In-Reply-To: <19f34abd0807171135m4a3b39e6v4065ed676720ae46@mail.gmail.com>
On Thu, 2008-07-17 at 20:35 +0200, Vegard Nossum wrote:
> Hi,
>
> I got this on latest -git with an intentionally corrupted filesystem image:
>
> BUG at fs/jfs/namei.c:512 assert(ip->i_nlink)
This assert shouldn't be here. It would be better to handle this with
jfs_error(), which will mark the superblock dirty, and take appropriate
action.
> Full log at http://folk.uio.no/vegardno/linux/log-1216318656.txt, but
> I think the preceding messages are just left-overs from previous
> mount/remount attempts. I can test patches.
How about this one? So far, compile tested only.
JFS: The kernel shouldn't trap when deleting a file with nlink == 0.
Signed-off-by: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 2aba823..10340be 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -508,33 +508,35 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry)
IWRITE_UNLOCK(ip);
goto out1;
}
-
- ASSERT(ip->i_nlink);
-
ip->i_ctime = dip->i_ctime = dip->i_mtime = CURRENT_TIME;
mark_inode_dirty(dip);
- /* update target's inode */
- inode_dec_link_count(ip);
+ if (ip->i_nlink == 0)
+ jfs_error(dip->i_sb, "jfs_unlink: i_nlink already zero");
+ else {
+ /* update target's inode */
+ inode_dec_link_count(ip);
- /*
- * commit zero link count object
- */
- if (ip->i_nlink == 0) {
- assert(!test_cflag(COMMIT_Nolink, ip));
- /* free block resources */
- if ((new_size = commitZeroLink(tid, ip)) < 0) {
- txAbort(tid, 1); /* Marks FS Dirty */
- txEnd(tid);
- mutex_unlock(&JFS_IP(ip)->commit_mutex);
- mutex_unlock(&JFS_IP(dip)->commit_mutex);
- IWRITE_UNLOCK(ip);
- rc = new_size;
- goto out1;
+ /*
+ * commit zero link count object
+ */
+ if (ip->i_nlink == 0) {
+ assert(!test_cflag(COMMIT_Nolink, ip));
+ /* free block resources */
+ new_size = commitZeroLink(tid, ip);
+ if (new_size < 0) {
+ txAbort(tid, 1); /* Marks FS Dirty */
+ txEnd(tid);
+ mutex_unlock(&JFS_IP(ip)->commit_mutex);
+ mutex_unlock(&JFS_IP(dip)->commit_mutex);
+ IWRITE_UNLOCK(ip);
+ rc = new_size;
+ goto out1;
+ }
+ tblk = tid_to_tblock(tid);
+ tblk->xflag |= COMMIT_DELETE;
+ tblk->u.ip = ip;
}
- tblk = tid_to_tblock(tid);
- tblk->xflag |= COMMIT_DELETE;
- tblk->u.ip = ip;
}
/*
--
David Kleikamp
IBM Linux Technology Center
next prev parent reply other threads:[~2008-07-17 23:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-17 18:35 Vegard Nossum
2008-07-17 23:09 ` Dave Kleikamp [this message]
2008-07-18 8:10 ` Vegard Nossum
2008-07-18 8:29 ` Vegard Nossum
2008-07-18 8:43 ` Vegard Nossum
2008-07-18 17:29 ` Dave Kleikamp
2008-07-18 18:08 ` Vegard Nossum
2008-07-18 21:58 ` Dave Kleikamp
2008-07-22 16:30 ` Vegard Nossum
2008-07-18 17:15 ` Dave Kleikamp
2008-07-18 17:17 ` Vegard Nossum
2008-07-18 17:25 ` [Jfs-discussion] " Dave Kleikamp
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=1216336164.32175.3.camel@norville.austin.ibm.com \
--to=shaggy@linux.vnet.ibm.com \
--cc=hannes@saeurebad.de \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=vegard.nossum@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®