HAMMER 42/Many: Cleanup.
authorMatthew Dillon <dillon@dragonflybsd.org>
Fri, 9 May 2008 07:26:51 +0000 (07:26 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Fri, 9 May 2008 07:26:51 +0000 (07:26 +0000)
* Finish up the general code to associate an inode with a cursor.

sys/vfs/hammer/hammer.h
sys/vfs/hammer/hammer_inode.c
sys/vfs/hammer/hammer_object.c
sys/vfs/hammer/hammer_vnops.c

index 2ae0e2f..46d9869 100644 (file)
@@ -31,7 +31,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $DragonFly: src/sys/vfs/hammer/hammer.h,v 1.62 2008/05/06 00:21:07 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer.h,v 1.63 2008/05/09 07:26:51 dillon Exp $
  */
 /*
  * This header file contains structures used internally by the HAMMERFS
@@ -625,7 +625,7 @@ int hammer_unload_volume(hammer_volume_t volume, void *data __unused);
 int    hammer_unload_buffer(hammer_buffer_t buffer, void *data __unused);
 int    hammer_install_volume(hammer_mount_t hmp, const char *volname);
 
-int    hammer_ip_lookup(hammer_cursor_t cursor, hammer_inode_t ip);
+int    hammer_ip_lookup(hammer_cursor_t cursor);
 int    hammer_ip_first(hammer_cursor_t cursor);
 int    hammer_ip_next(hammer_cursor_t cursor);
 int    hammer_ip_resolve_record_and_data(hammer_cursor_t cursor);
index 94d6305..4d9098a 100644 (file)
@@ -31,7 +31,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $DragonFly: src/sys/vfs/hammer/hammer_inode.c,v 1.53 2008/05/06 00:21:08 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer_inode.c,v 1.54 2008/05/09 07:26:51 dillon Exp $
  */
 
 #include "hammer.h"
@@ -673,6 +673,7 @@ hammer_unload_inode(struct hammer_inode *ip)
        KKASSERT(ip->vp == NULL);
        KKASSERT(ip->flush_state == HAMMER_FST_IDLE);
        KKASSERT(ip->cursor_ip_refs == 0);
+       KKASSERT(ip->lock.lockcount == 0);
        KKASSERT((ip->flags & HAMMER_INODE_MODMASK) == 0);
 
        KKASSERT(RB_EMPTY(&ip->rec_tree));
index c94570d..393aaf3 100644 (file)
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $DragonFly: src/sys/vfs/hammer/hammer_object.c,v 1.55 2008/05/05 20:34:48 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer_object.c,v 1.56 2008/05/09 07:26:51 dillon Exp $
  */
 
 #include "hammer.h"
 
 static int hammer_mem_add(hammer_transaction_t trans, hammer_record_t record);
-static int hammer_mem_lookup(hammer_cursor_t cursor, hammer_inode_t ip);
+static int hammer_mem_lookup(hammer_cursor_t cursor);
 static int hammer_mem_first(hammer_cursor_t cursor);
 
 /*
@@ -379,32 +379,16 @@ hammer_rec_scan_callback(hammer_record_t rec, void *data)
  */
 static
 int
-hammer_mem_lookup(hammer_cursor_t cursor, hammer_inode_t ip)
+hammer_mem_lookup(hammer_cursor_t cursor)
 {
        int error;
 
+       KKASSERT(cursor->ip);
        if (cursor->iprec) {
                hammer_rel_mem_record(cursor->iprec);
                cursor->iprec = NULL;
        }
-       if (cursor->ip) {
-               KKASSERT(cursor->ip->cursor_ip_refs > 0);
-               --cursor->ip->cursor_ip_refs;
-#if 0
-               hammer_rec_rb_tree_scan_info_done(&cursor->scan,
-                                                 &cursor->ip->rec_tree);
-#endif
-       }
-       cursor->ip = ip;
-#if 0
-       hammer_rec_rb_tree_scan_info_link(&cursor->scan, &ip->rec_tree);
-#endif
-       ++ip->cursor_ip_refs;
-
-#if 0
-       cursor->scan.node = NULL;
-#endif
-       hammer_rec_rb_tree_RB_SCAN(&ip->rec_tree, hammer_rec_find_cmp,
+       hammer_rec_rb_tree_RB_SCAN(&cursor->ip->rec_tree, hammer_rec_find_cmp,
                                   hammer_rec_scan_callback, cursor);
 
        if (cursor->iprec == NULL)
@@ -792,8 +776,11 @@ hammer_ip_sync_record(hammer_transaction_t trans, hammer_record_t record)
        do {
                error = hammer_init_cursor(trans, &cursor,
                                           &record->ip->cache[0], record->ip);
-               if (error)
+               if (error) {
+                       KKASSERT(0);
+                       hammer_done_cursor(&cursor);
                        return(error);
+               }
                error = hammer_ip_sync_record_cursor(&cursor, record);
                hammer_done_cursor(&cursor);
        } while (error == EDEADLK);
@@ -1076,7 +1063,7 @@ hammer_mem_add(struct hammer_transaction *trans, hammer_record_t record)
  * NOT be called to iterate results.
  */
 int
-hammer_ip_lookup(hammer_cursor_t cursor, struct hammer_inode *ip)
+hammer_ip_lookup(hammer_cursor_t cursor)
 {
        int error;
 
@@ -1084,7 +1071,8 @@ hammer_ip_lookup(hammer_cursor_t cursor, struct hammer_inode *ip)
         * If the element is in-memory return it without searching the
         * on-disk B-Tree
         */
-       error = hammer_mem_lookup(cursor, ip);
+       KKASSERT(cursor->ip);
+       error = hammer_mem_lookup(cursor);
        if (error == 0) {
                cursor->record = &cursor->iprec->rec;
                return(error);
@@ -1095,7 +1083,7 @@ hammer_ip_lookup(hammer_cursor_t cursor, struct hammer_inode *ip)
        /*
         * If the inode has on-disk components search the on-disk B-Tree.
         */
-       if ((ip->flags & (HAMMER_INODE_ONDISK|HAMMER_INODE_DONDISK)) == 0)
+       if ((cursor->ip->flags & (HAMMER_INODE_ONDISK|HAMMER_INODE_DONDISK)) == 0)
                return(error);
        error = hammer_btree_lookup(cursor);
        if (error == 0)
index f2dcefd..86a0058 100644 (file)
@@ -31,7 +31,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $DragonFly: src/sys/vfs/hammer/hammer_vnops.c,v 1.49 2008/05/06 00:21:08 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer_vnops.c,v 1.50 2008/05/09 07:26:51 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -1156,7 +1156,7 @@ hammer_vop_readlink(struct vop_readlink_args *ap)
        cursor.asof = ip->obj_asof;
        cursor.flags |= HAMMER_CURSOR_ASOF;
 
-       error = hammer_ip_lookup(&cursor, ip);
+       error = hammer_ip_lookup(&cursor);
        if (error == 0) {
                error = hammer_ip_resolve_data(&cursor);
                if (error == 0) {