orphans);
list_move(&db->orphans, &done);
mx = orphan_mutex(db);
- if (!mx || !mutex_trylock(mx))
+ if (!mx && !test_bit(B_Claimed, &db->b.flags))
+ /* OK not to have a mutex */;
+ else if (!mx || !mutex_trylock(mx))
continue;
+ getdref(db, MKREF(run_orphans));
spin_unlock(&fs->lock);
- /* The 'orphan_list' reference cannot be dropped
- * while we own the mutex, so our reference to db is safe
- */
-
- switch(LAFSI(db->b.inode)->type) {
- case TypeInodeFile:
- lafs_inode_handle_orphan(db);
- break;
- case TypeDir:
- lafs_dir_handle_orphan(db);
- break;
+ if (!mx)
+ lafs_orphan_release(fs, db);
+ else {
+ switch(LAFSI(db->b.inode)->type) {
+ case TypeInodeFile:
+ lafs_inode_handle_orphan(db);
+ break;
+ case TypeDir:
+ lafs_dir_handle_orphan(db);
+ break;
+ }
+ mutex_unlock(mx);
}
- mutex_unlock(mx);
- /* The block has either been put, or is still on
- * 'done'.
- */
+ putdref(db, MKREF(run_orphans));
spin_lock(&fs->lock);
}
list_splice(&done, &fs->pending_orphans);