From 36b1cad4d881f6e88141d5b35d5a0e8c08bdfe65 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Fri, 25 Jun 2010 20:34:52 +1000 Subject: [PATCH] Add debug tracing to unlink. Have had strange code of unlink failing to find the target file. So add lots of tracing in the hope that it will happen again. It might be sensitive to the hash chosen. Signed-off-by: NeilBrown --- dir.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dir.c b/dir.c index e492985..39f4d91 100644 --- a/dir.c +++ b/dir.c @@ -48,12 +48,15 @@ dir_lookup_blk(struct inode *dir, const char *name, int nlen, nlen = strlen(name); hash = lafs_hash_name(seed, nlen, name); + dprintk("name= %s hash=%lu\n", name, (unsigned long)bn); while (1) { char *buf; bn = hash+1; + dprintk("bn=%lu\n", (unsigned long)bn); if (lafs_find_next(dir, &bn) == 0) bn = 0; + dprintk("now=%lu\n", (unsigned long)bn); err = -ENOMEM; b = lafs_get_block(dir, bn, NULL, GFP_KERNEL, REF); @@ -63,6 +66,10 @@ dir_lookup_blk(struct inode *dir, const char *name, int nlen, if (err) break; buf = map_dblock(b); + if (lafs_trace) { + void lafs_dir_print(char *buf, int psz); + lafs_dir_print(buf, bits); + } for ( ; hash < (bn ? bn : MaxDirHash) ; hash++) { u8 piece; struct dir_ent de; @@ -377,6 +384,15 @@ dir_delete_prepare(struct fs *fs, struct inode *dir, doh->dirent_block = dirblk = dir_lookup_blk(dir, name, nlen, &doh->index, 0, &doh->hash, MKREF(dir_blk)); + if (IS_ERR(dirblk) && PTR_ERR(dirblk) == -ENOENT) { + lafs_trace = 1; + dirblk = dir_lookup_blk(dir, name, nlen, &doh->index, + 0, &doh->hash, MKREF(dir_blk)); + if (!IS_ERR(dirblk)) + printk("Weird: %s\n", strblk(&dirblk->b)); + lafs_trace = 0; + } + if (IS_ERR(dirblk)) return PTR_ERR(dirblk); @@ -704,6 +720,7 @@ lafs_unlink(struct inode *dir, struct dentry *de) err = dir_delete_prepare(fs, dir, de->d_name.name, de->d_name.len, &doh); + BUG_ON(err == -ENOENT); err = dir_log_prepare(&uh, fs, &de->d_name) ?: err; inodb = lafs_inode_dblock(inode, SYNC, MKREF(inode_update)); if (IS_ERR(inodb)) -- 2.39.5