]> git.neil.brown.name Git - LaFS.git/commitdiff
Don't set I_Trunc until pages are invalidated and trunc_next is set.
authorNeilBrown <neilb@suse.de>
Fri, 2 Jul 2010 23:38:55 +0000 (09:38 +1000)
committerNeilBrown <neilb@suse.de>
Sat, 3 Jul 2010 00:16:07 +0000 (10:16 +1000)
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 <neilb@suse.de>
inode.c

diff --git a/inode.c b/inode.c
index 80f44c89a7959ee70f74a8a8aeee4ffc868e755e..6a491c174f4493063c014ea9f30f2665286a70d8 100644 (file)
--- 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));
 }