]> git.neil.brown.name Git - LaFS.git/commitdiff
lafs_refile: only use ->inode pointer when we know it is valid.
authorNeilBrown <neilb@suse.de>
Sun, 9 Aug 2009 06:11:08 +0000 (16:11 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 9 Aug 2009 06:11:08 +0000 (16:11 +1000)
->inode may be invalid if block is not pinned, or at least
has a parent.  So don't try to find 'fs' from it until we know
we will need it.

index.c

diff --git a/index.c b/index.c
index 3d4da4cfbcb1f92b8d967f52fa7e4ec7ccc882c7..055398b2861d012de152217483a7f7a5a7ee1025 100644 (file)
--- a/index.c
+++ b/index.c
@@ -643,13 +643,12 @@ void lafs_phase_flip(struct fs *fs, struct block *b)
 void lafs_refile(struct block *b, int dec)
 {
        struct block *next = NULL, *next_parent = NULL;
-       struct fs *fs;
+       struct fs *fs = NULL;
        struct inode *in;
        u64 physref = 0;
 
        if (!b)
                return;
-       fs = fs_from_inode(b->inode);
 
 /* sanity tests.
  * 1/ make sure pincnt is right
@@ -761,6 +760,7 @@ void lafs_refile(struct block *b, int dec)
                       || test_bit(B_Realloc, &LAFSI(b->inode)->dblock->b.flags))
                            )) {
                        /* Don't need to be Pinned any more */
+                       fs = fs_from_inode(b->inode);
                        lafs_checkpoint_lock(fs);
                        if (test_and_clear_bit(B_Pinned, &b->flags)) {
                                if (onlru) {
@@ -801,6 +801,7 @@ void lafs_refile(struct block *b, int dec)
                                /* unlock */
                                /* FIXME was that ref counted?? */
                        }
+                       fs = fs_from_inode(b->inode);
                        spin_lock(&fs->lock);
                        if (list_empty(&b->lru)) {
                                if (test_bit(B_Realloc, &b->flags))
@@ -828,6 +829,7 @@ void lafs_refile(struct block *b, int dec)
                                      (1<<B_Dirty)))
                                ) {
                                int credits;
+                               fs = fs_from_inode(b->inode);
                                /* Don't need ->parent any more */
                                if (next_parent == &b->parent->b) {
                                        if (atomic_dec_and_test(&next_parent