void net_ctx_reset( net_ctx_t *ctx ) { journal_t *journal; if( ! ctx ) return; ctx->used = 0; ctx->ssrc = 0; ctx->send_ssrc = 0; ctx->initiator = 0; ctx->seq = 0x0000; FREENULL( (void **)&(ctx->ip_address) ); journal_destroy( &(ctx->journal) ); journal_init( &journal ); ctx->journal = journal; }
void net_ctx_destroy( void ) { uint8_t i; for( i = 0 ; i < _max_ctx ; i++ ) { if( ctx[ i ] ) { net_ctx_reset( ctx[i] ); journal_destroy( & (ctx[i]->journal) ); free( ctx[i] ); ctx[i] = NULL; } } free( ctx ); ctx = NULL; }
INT Ext2RecoverJournal( PEXT2_IRP_CONTEXT IrpContext, PEXT2_VCB Vcb ) { INT rc = 0; ULONG jNo = 0; PEXT2_MCB jcb = NULL; struct block_device * bd = &Vcb->bd; #ifndef __REACTOS__ struct super_block * sb = &Vcb->sb; #endif struct inode * ji = NULL; journal_t * journal = NULL; struct ext3_super_block *esb; /* check journal inode number */ if (!Ext2CheckJournal(Vcb, &jNo)) { return -1; } /* allocate journal Mcb */ jcb = Ext2LoadInternalJournal(Vcb, jNo); if (!jcb) { rc = -6; goto errorout; } /* allocate journal inode */ ji = &jcb->Inode; /* initialize journal file from inode */ journal = journal_init_inode(ji); /* initialzation succeeds ? */ if (!journal) { iput(ji); rc = -8; goto errorout; } /* start journal recovery */ rc = journal_load(journal); if (0 != rc) { rc = -9; DbgPrint("Ext2Fsd: recover_journal: failed " "to recover journal data.\n"); } /* reload super_block and group_description */ Ext2RefreshSuper(IrpContext, Vcb); Ext2RefreshGroup(IrpContext, Vcb); /* wipe journal data and clear recover flag in sb */ if (rc == 0) { journal_wipe_recovery(journal); ClearLongFlag( Vcb->SuperBlock->s_feature_incompat, EXT3_FEATURE_INCOMPAT_RECOVER ); Ext2SaveSuper(IrpContext, Vcb); sync_blockdev(bd); ClearLongFlag(Vcb->Flags, VCB_JOURNAL_RECOVER); } errorout: /* destroy journal structure */ if (journal) { journal_destroy(journal); } /* destory journal Mcb */ if (jcb) { Ext2FreeMcb(Vcb, jcb); } return rc; }
/* * If the journal has been kmalloc'd it needs to be freed after this * call. */ void ocfs2_journal_shutdown(struct ocfs2_super *osb) { struct ocfs2_journal *journal = NULL; int status = 0; struct inode *inode = NULL; int num_running_trans = 0; mlog_entry_void(); BUG_ON(!osb); journal = osb->journal; if (!journal) goto done; inode = journal->j_inode; if (journal->j_state != OCFS2_JOURNAL_LOADED) goto done; /* need to inc inode use count as journal_destroy will iput. */ if (!igrab(inode)) BUG(); num_running_trans = atomic_read(&(osb->journal->j_num_trans)); if (num_running_trans > 0) mlog(0, "Shutting down journal: must wait on %d " "running transactions!\n", num_running_trans); /* Do a commit_cache here. It will flush our journal, *and* * release any locks that are still held. * set the SHUTDOWN flag and release the trans lock. * the commit thread will take the trans lock for us below. */ journal->j_state = OCFS2_JOURNAL_IN_SHUTDOWN; /* The OCFS2_JOURNAL_IN_SHUTDOWN will signal to commit_cache to not * drop the trans_lock (which we want to hold until we * completely destroy the journal. */ if (osb->commit_task) { /* Wait for the commit thread */ mlog(0, "Waiting for ocfs2commit to exit....\n"); kthread_stop(osb->commit_task); osb->commit_task = NULL; } BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0); if (ocfs2_mount_local(osb)) { journal_lock_updates(journal->j_journal); status = journal_flush(journal->j_journal); journal_unlock_updates(journal->j_journal); if (status < 0) mlog_errno(status); } if (status == 0) { /* * Do not toggle if flush was unsuccessful otherwise * will leave dirty metadata in a "clean" journal */ status = ocfs2_journal_toggle_dirty(osb, 0); if (status < 0) mlog_errno(status); } /* Shutdown the kernel journal system */ journal_destroy(journal->j_journal); OCFS2_I(inode)->ip_open_count--; /* unlock our journal */ ocfs2_inode_unlock(inode, 1); brelse(journal->j_bh); journal->j_bh = NULL; journal->j_state = OCFS2_JOURNAL_FREE; // up_write(&journal->j_trans_barrier); done: if (inode) iput(inode); mlog_exit_void(); }