]> git.neil.brown.name Git - LaFS.git/commitdiff
leaf_find: make sure returned block is IOLocked.
authorNeilBrown <neilb@suse.de>
Tue, 25 Aug 2009 07:09:52 +0000 (17:09 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 25 Aug 2009 07:09:52 +0000 (17:09 +1000)
If we had to return a sibling of the found block, we weren't
getting an IOLock on it, which is bad.

index.c

diff --git a/index.c b/index.c
index a371b4f4237d7755824b58a5f7493222db997ddf..c6e4a8133f979d2814ecae95f90192e4f097a5a9 100644 (file)
--- a/index.c
+++ b/index.c
@@ -1318,6 +1318,11 @@ lafs_leaf_find(struct inode *inode, u32 addr, int adopt, u32 *next,
                ib2 = iblock_get(inode, iaddr, ib->depth-1, iphys, REF);
 
                if (!ib2) {
+                       /* if iphys==0, then we were expecting to find a
+                        * cached index block.  If we didn't, something is
+                        * wrong.
+                        */
+                       BUG_ON(iphys==0);
                        err = -ENOMEM;
                        lafs_iounlock_block(&ib->b);
                        goto err;
@@ -1372,6 +1377,8 @@ lafs_leaf_find(struct inode *inode, u32 addr, int adopt, u32 *next,
                        }
                        getref_locked(nxt, REF);
                        spin_unlock(&inode->i_data.private_lock);
+                       lafs_iolock_block(nxt);
+                       lafs_iounlock_block(&ib2->b);
                        putiref(ib2, REF);
                        ib2 = iblk(nxt);
                        spin_lock(&inode->i_data.private_lock);