From: Matthew Dillon Date: Sat, 3 May 2008 07:59:06 +0000 (+0000) Subject: HAMMER 40E/Many: Inode/link-count sequencer cleanup pass. X-Git-Tag: v2.0.1~721 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/3bf2d80af5516e1e71cb4cae3c73b5d3a39cceaf HAMMER 40E/Many: Inode/link-count sequencer cleanup pass. * An inode can go inactive before it is deleted, add an unload check in hammer_ip_del_directory to catch the nlinks == 0 case on an inactive inode. Otherwise the inode would not be deleted on-media until umount. * Add a missing resignaling case. * Clean out a few more of the debug kprintf()'s --- diff --git a/sys/vfs/hammer/hammer.h b/sys/vfs/hammer/hammer.h index 6cb7ec7deb..5271ab6bdb 100644 --- a/sys/vfs/hammer/hammer.h +++ b/sys/vfs/hammer/hammer.h @@ -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.57 2008/05/03 05:28:55 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer.h,v 1.58 2008/05/03 07:59:06 dillon Exp $ */ /* * This header file contains structures used internally by the HAMMERFS @@ -765,6 +765,7 @@ int hammer_create_inode(struct hammer_transaction *trans, struct vattr *vap, void hammer_rel_inode(hammer_inode_t ip, int flush); int hammer_sync_inode(hammer_inode_t ip); void hammer_test_inode(hammer_inode_t ip); +void hammer_inode_unloadable_check(hammer_inode_t ip); int hammer_ip_add_directory(struct hammer_transaction *trans, hammer_inode_t dip, struct namecache *ncp, diff --git a/sys/vfs/hammer/hammer_inode.c b/sys/vfs/hammer/hammer_inode.c index a26d9889af..502f6ec4b7 100644 --- a/sys/vfs/hammer/hammer_inode.c +++ b/sys/vfs/hammer/hammer_inode.c @@ -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.47 2008/05/03 05:28:55 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_inode.c,v 1.48 2008/05/03 07:59:06 dillon Exp $ */ #include "hammer.h" @@ -42,7 +42,6 @@ static int hammer_unload_inode(struct hammer_inode *ip); static void hammer_flush_inode_core(hammer_inode_t ip, int flags); static int hammer_setup_child_callback(hammer_record_t rec, void *data); -static void hammer_inode_unloadable_check(hammer_inode_t ip); static int hammer_setup_parent_inodes(hammer_record_t record); /* @@ -1591,7 +1590,7 @@ done: * At this point if the inode's nlinks count is zero we want to destroy * it, which may mean destroying it on-media too. */ -static void +void hammer_inode_unloadable_check(hammer_inode_t ip) { /* @@ -1610,13 +1609,22 @@ hammer_inode_unloadable_check(hammer_inode_t ip) } } +/* + * Re-test an inode when a dependancy had gone away to see if we + * can chain flush it. + */ void hammer_test_inode(hammer_inode_t ip) { if (ip->flags & HAMMER_INODE_REFLUSH) { ip->flags &= ~HAMMER_INODE_REFLUSH; hammer_ref(&ip->lock); - hammer_flush_inode(ip, HAMMER_FLUSH_SIGNAL); + if (ip->flags & HAMMER_INODE_RESIGNAL) { + ip->flags &= ~HAMMER_INODE_RESIGNAL; + hammer_flush_inode(ip, HAMMER_FLUSH_SIGNAL); + } else { + hammer_flush_inode(ip, 0); + } hammer_rel_inode(ip, 0); } } diff --git a/sys/vfs/hammer/hammer_object.c b/sys/vfs/hammer/hammer_object.c index 840cd360cb..e237f318b5 100644 --- a/sys/vfs/hammer/hammer_object.c +++ b/sys/vfs/hammer/hammer_object.c @@ -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_object.c,v 1.51 2008/05/03 05:28:55 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_object.c,v 1.52 2008/05/03 07:59:06 dillon Exp $ */ #include "hammer.h" @@ -584,16 +584,16 @@ hammer_ip_del_directory(struct hammer_transaction *trans, /* * One less link. The file may still be open in the OS even after - * all links have gone away so we only try to sync if the OS has - * no references and nlinks falls to 0. + * all links have gone away. * * We have to terminate the cursor before syncing the inode to - * avoid deadlocking against ourselves. + * avoid deadlocking against ourselves. XXX this may no longer + * be true. * - * XXX we can't sync the inode here because the encompassing - * transaction might be a rename and might update the inode - * again with a new link. That would force the delete_tid to be - * the same as the create_tid and cause a panic. + * If nlinks drops to zero and the vnode is inactive (or there is + * no vnode), call hammer_inode_unloadable_check() to zonk the + * inode. If we don't do this here the inode will not be destroyed + * on-media until we unmount. */ if (error == 0) { --ip->ino_rec.ino_nlinks; @@ -601,6 +601,8 @@ hammer_ip_del_directory(struct hammer_transaction *trans, if (ip->ino_rec.ino_nlinks == 0 && (ip->vp == NULL || (ip->vp->v_flag & VINACTIVE))) { hammer_done_cursor(cursor); + hammer_inode_unloadable_check(ip); + hammer_flush_inode(ip, 0); } } @@ -1716,19 +1718,6 @@ hammer_ip_check_directory_empty(hammer_transaction_t trans, struct hammer_cursor cursor; int error; -#if 0 - /* - * Check flush connectivity - */ - if (ip->flush_state != HAMMER_FST_IDLE) { - kprintf("FWAIT\n"); - hammer_done_cursor(parent_cursor); - hammer_flush_inode(ip, HAMMER_FLUSH_SIGNAL); - hammer_wait_inode(ip); - return (EDEADLK); - } -#endif - /* * Check directory empty */ diff --git a/sys/vfs/hammer/hammer_recover.c b/sys/vfs/hammer/hammer_recover.c index f0e198f745..6cab2d46d2 100644 --- a/sys/vfs/hammer/hammer_recover.c +++ b/sys/vfs/hammer/hammer_recover.c @@ -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_recover.c,v 1.13 2008/04/29 01:10:37 dillon Exp $ + * $DragonFly: src/sys/vfs/hammer/hammer_recover.c,v 1.14 2008/05/03 07:59:06 dillon Exp $ */ #include "hammer.h" @@ -97,7 +97,8 @@ hammer_recover(hammer_mount_t hmp, hammer_volume_t root_volume) } while ((int64_t)bytes > 0) { - kprintf("scan_offset %016llx\n", scan_offset); + if (hammer_debug_general & 0x0080) + kprintf("scan_offset %016llx\n", scan_offset); if (scan_offset == HAMMER_ZONE_ENCODE(HAMMER_ZONE_UNDO_INDEX, 0)) { scan_offset = rootmap->alloc_offset; continue; @@ -316,7 +317,9 @@ static void hammer_recover_copy_undo(hammer_off_t undo_offset, char *src, char *dst, int bytes) { - kprintf("UNDO %016llx: %d\n", undo_offset, bytes); + kprintf("U"); + if (hammer_debug_general & 0x0080) + kprintf("NDO %016llx: %d\n", undo_offset, bytes); #if 0 kprintf("UNDO %016llx:", undo_offset); hammer_recover_debug_dump(22, dst, bytes);