@@ -1948,6 +1948,36 @@ void ext4_remove_pending(struct inode *inode, ext4_lblk_t lblk)
write_unlock(&ei->i_es_lock);
}
+void ext4_check_inode_pending(struct inode *inode)
+{
+ struct ext4_inode_info *ei = EXT4_I(inode);
+ struct pending_reservation *pr;
+ struct ext4_pending_tree *tree;
+ struct rb_node *node;
+ int count = 0;
+
+ write_lock(&ei->i_es_lock);
+ tree = &EXT4_I(inode)->i_pending_tree;
+ node = rb_first(&tree->root);
+ while (node) {
+ pr = rb_entry(node, struct pending_reservation, rb_node);
+ node = rb_next(node);
+ rb_erase(&pr->rb_node, &tree->root);
+ kmem_cache_free(ext4_pending_cachep, pr);
+ count++;
+ }
+ write_unlock(&ei->i_es_lock);
+
+ if (!count)
+ return;
+
+ ext4_warning(inode->i_sb, "Inode %lu: pending tree has %d not cleared!",
+ inode->i_ino, count);
+ WARN_ON(1);
+
+ return;
+}
+
/*
* ext4_is_pending - determine whether a cluster has a pending reservation
* on it
@@ -248,6 +248,7 @@ extern int __init ext4_init_pending(void);
extern void ext4_exit_pending(void);
extern void ext4_init_pending_tree(struct ext4_pending_tree *tree);
extern void ext4_remove_pending(struct inode *inode, ext4_lblk_t lblk);
+extern void ext4_check_inode_pending(struct inode *inode);
extern bool ext4_is_pending(struct inode *inode, ext4_lblk_t lblk);
extern int ext4_es_insert_delayed_block(struct inode *inode, ext4_lblk_t lblk,
bool allocated);
@@ -1393,6 +1393,9 @@ static void ext4_destroy_inode(struct inode *inode)
WARN_ON(1);
}
+
+ if (EXT4_SB(inode->i_sb)->s_cluster_ratio != 1)
+ ext4_check_inode_pending(inode);
}
static void init_once(void *foo)