]> git.neil.brown.name Git - LaFS.git/commitdiff
Add debug tracing to unlink.
authorNeilBrown <neilb@suse.de>
Fri, 25 Jun 2010 10:34:52 +0000 (20:34 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 27 Jun 2010 23:15:00 +0000 (09:15 +1000)
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 <neilb@suse.de>
dir.c

diff --git a/dir.c b/dir.c
index e492985c2000e77d15f410a1a026838470ace4a5..39f4d9115862fa580e1c2a0bd846ebd91397376a 100644 (file)
--- 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))