From 7de5ef56bb17c44b1e903dd75f01c396ad9f6ac9 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sat, 2 Oct 2010 10:59:32 +1000 Subject: [PATCH] Add proper locking to inode_handle_orphan When walking the indexblock looking for things to purge we need to hold the inode private_lock. Signed-off-by: NeilBrown --- inode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inode.c b/inode.c index 88c76d1..c70a934 100644 --- a/inode.c +++ b/inode.c @@ -860,10 +860,7 @@ int lafs_inode_handle_orphan(struct datablock *b) err = -EBUSY; /* Try again after the checkpoint */ goto out2; } - /* FIXME I need some sort of lock to safely walk - * down this list */ - ib2 = ib; lastaddr = (i_size_read(ino) + fs->blocksize - 1) >> fs->blocksize_bits; @@ -874,7 +871,8 @@ int lafs_inode_handle_orphan(struct datablock *b) * If there are none, descend the last block that * is not after EOF and look at its children. */ - next = ib; + ib2 = next = ib; + spin_lock(&ib->b.inode->i_data.private_lock); while (next) { ib2 = next; next = NULL; @@ -889,6 +887,7 @@ int lafs_inode_handle_orphan(struct datablock *b) } if (ib2->b.fileaddr < lastaddr) { /* Must be all done */ + spin_unlock(&ib->b.inode->i_data.private_lock); clear_bit(I_Trunc, &LAFSI(ino)->iflags); if (!test_bit(I_Deleting, &LAFSI(ino)->iflags)) iput(ino); @@ -897,6 +896,7 @@ int lafs_inode_handle_orphan(struct datablock *b) goto out2; } getiref(ib2, MKREF(inode_handle_orphan2)); + spin_unlock(&ib->b.inode->i_data.private_lock); /* ib2 is an index block beyond EOF with no * Pinned children. -- 2.39.5