HAMMER VFS - Fix HAMMER_INODE_XDIRTY flags / state assertion
authorMatthew Dillon <dillon@apollo.backplane.com>
Sun, 28 Nov 2010 06:40:13 +0000 (22:40 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 28 Nov 2010 17:32:53 +0000 (09:32 -0800)
* The HAMMER_INODE_XDIRTY flag was not being immediately synchronized
  with the state of ip->rec_tree in one case and the delay could create
  a window of opportunity where an assertion would get hit.

* Remove the window of opportunity, the assertion no longer gets hit.

Reported-by: YONETANI Tomokazu <qhwt.dfly@les.ath.cx>
sys/vfs/hammer/hammer_object.c

index 7ccbb88..368acf0 100644 (file)
@@ -415,6 +415,12 @@ hammer_rel_mem_record(struct hammer_record *record)
                                          record);
                                record->flags &= ~HAMMER_RECF_ONRBTREE;
                                KKASSERT(ip->rsv_recs > 0);
+                               if (RB_EMPTY(&record->ip->rec_tree)) {
+                                       record->ip->flags &=
+                                                       ~HAMMER_INODE_XDIRTY;
+                                       record->ip->sync_flags &=
+                                                       ~HAMMER_INODE_XDIRTY;
+                               }
                                diddrop = 1;
                        } else {
                                diddrop = 0;
@@ -439,11 +445,8 @@ hammer_rel_mem_record(struct hammer_record *record)
                                --ip->rsv_recs;
                                hmp->rsv_databytes -= record->leaf.data_len;
 
-                               if (RB_EMPTY(&record->ip->rec_tree)) {
-                                       record->ip->flags &= ~HAMMER_INODE_XDIRTY;
-                                       record->ip->sync_flags &= ~HAMMER_INODE_XDIRTY;
+                               if (RB_EMPTY(&record->ip->rec_tree))
                                        hammer_test_inode(record->ip);
-                               }
                                if (ip->rsv_recs == hammer_limit_inode_recs - 1)
                                        wakeup(&ip->rsv_recs);
                        }