]> git.neil.brown.name Git - LaFS.git/commitdiff
Allow EmptyIndex blocks to be written
authorNeilBrown <neilb@suse.de>
Tue, 22 Jun 2010 05:42:49 +0000 (15:42 +1000)
committerNeilBrown <neilb@suse.de>
Wed, 23 Jun 2010 01:57:21 +0000 (11:57 +1000)
They are stored as phys address 0.

Signed-off-by: NeilBrown <neilb@suse.de>
cluster.c

index b83e8fea3b90448717aab7c534540c627560f07d..8f68e556445832ffeb159ef6d9b5dfc4644a895e 100644 (file)
--- a/cluster.c
+++ b/cluster.c
@@ -533,7 +533,16 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
        LAFS_BUG(!test_bit(B_Valid, &b->flags), b);
        LAFS_BUG(!fs->rolled, b);
        LAFS_BUG(lai->flags & File_nonlogged &&
-              !test_bit(B_Index, &b->flags), b);
+                !test_bit(B_Index, &b->flags), b);
+
+       /* We cannot change the physaddr of an uniblock in a
+        * different phase to the parent, else the parent will
+        * get the wrong address.
+        */
+       LAFS_BUG(test_bit(B_Index, &b->flags) &&
+                test_bit(B_Uninc, &b->flags) &&
+                !!test_bit(B_Phase1, &b->flags) !=
+                !!test_bit(B_Phase1, &b->parent->b.flags), b);
 
        size = i_size_read(b->inode);
        if (!test_bit(B_Index, &b->flags) &&          /* it is a datablock */
@@ -696,6 +705,13 @@ unsigned long long lafs_cluster_allocate(struct block *b, int cnum)
        if (test_and_set_bit(B_Writeback, &b->flags))
                LAFS_BUG(1, b);
        lafs_iounlock_block(b);
+
+       if (test_bit(B_EmptyIndex, &b->flags)) {
+               lafs_allocated_block(fs, b, 0);
+               lafs_writeback_done(b);
+               mutex_unlock(&wc->lock);
+               return wc->cluster_seq; /* FIXME is this really needed - or right */
+       }
        /* insert into list ensuring there is enough space
         * in cluster head
         */