From: NeilBrown Date: Fri, 2 Jul 2010 23:38:55 +0000 (+1000) Subject: Don't set I_Trunc until pages are invalidated and trunc_next is set. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=6e1f204d4b828ce353d54a6228ced7f7511dd664;p=LaFS.git Don't set I_Trunc until pages are invalidated and trunc_next is set. The block could already be subject to orphan handling, as unlink sets that up before truncation happens. So make sure not to set I_Trunc until we a really ready for the orphan-inode truncation handling to happen. Without this truncation can race with the cleaner and weird thinks can happen. Signed-off-by: NeilBrown --- diff --git a/inode.c b/inode.c index 80f44c8..6a491c1 100644 --- a/inode.c +++ b/inode.c @@ -498,9 +498,9 @@ void lafs_delete_inode(struct inode *ino) spin_unlock(&ino->i_data.private_lock); i_size_write(ino, 0); - set_bit(I_Trunc, &LAFSI(ino)->iflags); truncate_inode_pages(&ino->i_data, 0); LAFSI(ino)->trunc_next = 0; + set_bit(I_Trunc, &LAFSI(ino)->iflags); set_bit(I_Deleting, &LAFSI(ino)->iflags); set_bit(B_Claimed, &b->b.flags); @@ -1448,10 +1448,10 @@ void lafs_truncate(struct inode *ino) /* FIXME there is nothing I can do with an error here */ lafs_make_orphan(fs, db); - set_bit(I_Trunc, &LAFSI(ino)->iflags); LAFSI(ino)->trunc_next = (i_size_read(ino) + ino->i_sb->s_blocksize - 1) >> ino->i_sb->s_blocksize_bits; + set_bit(I_Trunc, &LAFSI(ino)->iflags); putdref(db, MKREF(trunc)); }