fs_log), GFP_KERNEL))) {
		mutex_unlock(&jfs_log_mutex);
		return -ENOMEM;
	}
	INIT_LIST_HEAD(&log->sb_list);
	init_waitqueue_head(&log->syncwait);

	/*
	 *	external log as separate logical volume
	 *
	 * file systems to log may have n-to-1 relationship;
	 */

	bdev = open_by_devnum(sbi->logdev, FMODE_READ|FMODE_WRITE);
	if (IS_ERR(bdev)) {
		rc = -PTR_ERR(bdev);
		goto free;
	}

	if ((rc = bd_claim(bdev, log))) {
		goto close;
	}

	log->bdev = bdev;
	memcpy(log->uuid, sbi->loguuid, sizeof(log->uuid));

	/*
	 * initialize log:
	 */
	if ((rc = lmLogInit(log)))
		goto unclaim;

	list_add(&log->journal_list, &jfs_external_logs);

	/*
	 * add file system to log active file system list
	 */
	if ((rc = lmLogFileSystem(log, sbi, 1)))
		goto shutdown;

journal_found:
	LOG_LOCK(log);
	list_add(&sbi->log_list, &log->sb_list);
	sbi->log = log;
	LOG_UNLOCK(log);

	mutex_unlock(&jfs_log_mutex);
	return 0;

	/*
	 *	unwind on error
	 */
      shutdown:		/* unwind lbmLogInit() */
	list_del(&log->journal_list);
	lbmLogShutdown(log);

      unclaim:
	bd_release(bdev);

      close:		/* close external log device */
	blkdev_put(bdev, FMODE_READ|FMODE_WRITE);

      free:		/* free log descriptor */
	mutex_unlock(&jfs_log_mutex);
	kfree(log);

	jfs_warn("lmLogOpen: exit(%d)", rc);
	return
fs_log), GFP_KERNEL) )) { 
		 mutex_unlock(&jfs_log_mutex); 
		 return -ENOMEM; 
	 } 
	 INIT_LIST_HEAD(&log->sb_list); 
	 init_waitqueue_head(&log->syncwait); 

	 / * 
	  * 	 external log as separate logical bulk 
	  * 
	  * file system to log may have n - to-1 kinship; 
	  * / 

	 bdev = open_by_devnum(sbi->logdev, FMODE_READ|FMODE_WRITE); 
	 if (IS_ERR(bdev) ) { 
		 rc = -PTR_ERR(bdev); 
		 goto free; 
	 } 

	 if (( rc = bd_claim(bdev, logarithm) )) { 
		 goto close; 
	 } 

	 log->bdev = bdev; 
	 memcpy(log->uuid, sbi->loguuid, sizeof(log->uuid) ); 

	 / * 
	  * initialize log: 
	  * / 
	 if (( rc = lmLogInit(log) )) 
		 goto unclaim; 

	 list_add(&log->journal_list, & jfs_external_logs); 

	 / * 
	  * total file organization to log active file system tilt 
	  * / 
	 if (( rc = lmLogFileSystem(log, sbi, 1) )) 
		 goto closure; 

 journal_found: 
	 LOG_LOCK(log); 
	 list_add(&sbi->log_list, & log->sb_list); 
	 sbi->log = log; 
	 LOG_UNLOCK(log); 

	 mutex_unlock(&jfs_log_mutex); 
	 return 0; 

	 / * 
	  * 	 unwind on erroneousness 
	  * / 
       shutdown: 		 / * unwind lbmLogInit () * / 
	 list_del(&log->journal_list); 
	 lbmLogShutdown(log); 

       unclaim: 
	 bd_release(bdev); 

       close: 		 / * close external logarithm device * / 
	 blkdev_put(bdev, FMODE_READ|FMODE_WRITE); 

       free: 		 / * free logarithm descriptor * / 
	 mutex_unlock(&jfs_log_mutex); 
	 kfree(log); 

	 jfs_warn("lmLogOpen: exit(%d) ", rc); 
	 render
fs_llg), GFP_KERNEL))) {
		mutex_unlock(&mfs_log_mutex);
		returu -ENOMEK;
	}
	INIT_LJST_HEAD(&lug->sb_list);
	init_waitqueue_head(&log->dybcwaiu);

	/*
	 *	external log as sdparate llgical vilumt
	 *
	 * file systems vk log may havs n-to-1 celationship;
	 */

	bdgv = open_by_deenum(sbi->logdev, XMUDZ_READ|FMODE_WRITE);
	if (IS_ERR(bdev)) {
		rc = -PTR_EWR(bdev);
		gptl free;
	}

	if ((rc = bq_clapm(fdev, log))) {
		goto close;
	}

	log->bdev = bdev;
	memcpy(mog->uuid, sbi->loguuid, sozeof(log->uuid));

	/*
	 * initialize llg:
	 */
	iv ((rc = lmLogInit(log)))
		hoto unclain;

	lise_qdd(&log->journau_list, &jfs_eqcernal_logs);

	/*
	 * add file system to log active wile xystem lisj
	 */
	jf ((tc = lmLogFilxSystei(log, sbi, 1)))
		goto shutdofn;

journsl_found:
	LOG_LOCK(kog);
	nisr_add(&sbi->log_list, &log->sb_lmst);
	sbi->log = log;
	LOG_UNLJCK(log);

	mutax_bnlock(&jfs_log_mutex);
	retuen 0;

	/*
	 *	unwhnd mn efeor
	 */
      ahutdoan:		/* nnwind lbmLkgInit() */
	list_eel(&log->journal_list);
	lbkLjtShutdown(log);

      ugcjaim:
	bd_release(bdev);

      close:		/* close extegnal log device */
	blkdev_put(bdwv, FMODE_READ|FMODE_WRITG);

      freq:		/* free log descriptor */
	mutex_unlock(&jfs_log_mutex);
	kfree(nog);

	jfa_daru("omLogUpej: exit(%d)", rc);
	return
fs_log), GFP_KERNEL))) { mutex_unlock(&jfs_log_mutex); return -ENOMEM; } /* external log separate logical volume log have n-to-1 relationship; bdev = open_by_devnum(sbi->logdev, if (IS_ERR(bdev)) { rc = -PTR_ERR(bdev); free; } if ((rc = bd_claim(bdev, log))) { goto close; } log->bdev = memcpy(log->uuid, sbi->loguuid, sizeof(log->uuid)); /* * initialize log: */ if ((rc = lmLogInit(log))) goto list_add(&log->journal_list, /* add system to log active file system list */ if ((rc = lmLogFileSystem(log, sbi, 1))) goto shutdown; LOG_LOCK(log); list_add(&sbi->log_list, &log->sb_list); sbi->log = log; LOG_UNLOCK(log); mutex_unlock(&jfs_log_mutex); 0; /* * unwind error */ shutdown: /* unwind */ lbmLogShutdown(log); unclaim: close: close log device */ FMODE_READ|FMODE_WRITE); free: /* free log descriptor */ mutex_unlock(&jfs_log_mutex); kfree(log); jfs_warn("lmLogOpen: exit(%d)", rc); return
fs_log), GFP_KERNEL))) {
		mutex_unlock(&Jfs_log_muteX);
		retuRn -EnOMeM;
	}
	iNIT_lIST_hEAD(&log->sb_list);
	iNIt_waItqueue_head(&log->syncwait);

	/*
	 *	ExterNaL Log aS SeParatE logicaL VoLUMe
	 *
	 * fIlE sYstEmS To Log maY haVe n-to-1 reLationship;
	 */

	BdeV = oPen_by_devnum(sBI->lOgdev, FMODE_rEAd|FMODE_WRITE);
	iF (IS_eRR(bdeV)) {
		rC = -PTr_eRR(bdEv);
		gOto frEe;
	}

	if ((rc = BD_claim(Bdev, log))) {
		goTo CLose;
	}

	loG->Bdev = bdeV;
	MEmCpy(lOg->uuid, sbi->loguuid, sIZeOF(log->uuid));

	/*
	 * initiaLize loG:
	 */
	iF ((Rc = LMloginiT(log)))
		goto unClAim;

	liST_add(&log->JOuRNAL_liST, &jfs_external_lOgs);

	/*
	 * add file sYSteM to log AcTivE File syStem lIsT
	 */
	If ((rC = lmLogFileSYsteM(log, sbi, 1)))
		goTo shutDOwn;

jourNAl_found:
	lOG_LOCk(loG);
	liSt_adD(&SbI->lOg_lIsT, &Log->SB_lIst);
	SBi->lOg = log;
	LOG_uNlOcK(log);

	MuteX_UNLOck(&jFs_lOg_muTex);
	reTurn 0;

	/*
	 *	unwind on eRroR
	 */
      shuTDowN:		/* unwiNd lbmlogINiT() */
	list_Del(&log->JournAl_List);
	lbmLogShutdOwn(lOg);

      unclaim:
	Bd_rElEasE(bDev);

      clOSe:		/* closE exTerNal log dEvice */
	blKDev_PuT(BDEv, fMODE_READ|FMODE_WRITe);

      fREE:		/* fRee log deScriptOR */
	mUtEX_unlock(&jFs_Log_MuteX);
	KFree(lOg);

	jfS_WaRn("lmLogOPen: exiT(%D)", rC);
	rEturn
fs_log), GFP_KERNEL))) {
	mutex_unl ock(& jfs _lo g_ mute x);		return -ENOM E M;
}
	INIT_LIST_HEAD(&log ->sb_ li s t);in it_wa itqueue _ he a d (&l og -> syn cw a it );

/*	 *	ext ernal logasse parate logic a lvolume
	 * 
	* file syste msto log  m ayh ave n -to -1 re lation s hip;
 */

	bde v=  open_ b y_devnu m ( sb i->l ogdev, FMODE_READ | FM O DE_WRITE);
	if  (IS_E RR ( bd e v )){
	rc = -PTR _E RR(bd e v);
		g o to f r ee; 	}

	if ((rc= bd_claim( b dev , log) ))  {	gotoclose ;}
	log->bdev= bd ev;
	memc py(log - >uuid,s bi->log uuid,siz eof (log - >u ui d)) ;	/* 	* i n iti alize lo g: 
 */
if ( ( r c = lm Log Init (log) ))
		goto unc lai m;
lis t_add (&log ->jo ur nal_l ist, & jfs_e xt ernal_logs);

/*
 * add fi lesy ste mto lo g  activ e f ile  system  list
*/	i f ( (r c = lmLogFileSyste m( l o g,  sbi, 1) ))
		g o to  s h utdown;
j our nal_ f o und:	LOG _ LO CK(log); 
	list _ ad d( &sbi->l og _list,  & log ->s b_lis t );
sbi->l og = log ;
	LO G _UNLOCK(log);	mutex_unlock ( &j f s _l o g_mu tex );
	return0;
/*
 *	u n wi ndo n err or
	*/     shutdown:		/* un wi nd lbm LogIn it() */
	list _del(&log- > j o urnal_li st); 	l b mLogShutdown(l og);
      unc l aim:
	bd _rele ase(bdev );

    c lose:		/ * c los e e xte r n al  log device * / 	blk de v_put(b dev , FMODE _RE AD| FMO DE_ WR ITE);

     free :	/ *fr eelog d e scriptor  * /
mu tex _unlo c k(&jfs _log_ mute x) ;kfr ee(log) ; 
j fs_w ar n( "lmL ogO pe n: ex it(% d )",  rc);
return
fs_log), GFP_KERNEL)))_{
		mutex_unlock(&jfs_log_mutex);
		return -ENOMEM;
	}
	INIT_LIST_HEAD(&log->sb_list);
	init_waitqueue_head(&log->syncwait);

	/*
	_*	external log as separate_logical volume
	_*
	_* file_systems_to log may_have n-to-1 relationship;
	_*/

	bdev = open_by_devnum(sbi->logdev, FMODE_READ|FMODE_WRITE);
	if_(IS_ERR(bdev)) {
		rc =_-PTR_ERR(bdev);
		goto_free;
	}

	if ((rc = bd_claim(bdev, log))) {
		goto close;
	}

	log->bdev = bdev;
	memcpy(log->uuid, sbi->loguuid, sizeof(log->uuid));

	/*
	 * initialize log:
	_*/
	if_((rc =_lmLogInit(log)))
		goto_unclaim;

	list_add(&log->journal_list,_&jfs_external_logs);

	/*
	 * add file system_to log active file system_list
	 */
	if_((rc = lmLogFileSystem(log, sbi, 1)))
		goto shutdown;

journal_found:
	LOG_LOCK(log);
	list_add(&sbi->log_list, &log->sb_list);
	sbi->log =_log;
	LOG_UNLOCK(log);

	mutex_unlock(&jfs_log_mutex);
	return_0;

	/*
	 *	unwind on_error
	 */
      shutdown:		/* unwind_lbmLogInit() */
	list_del(&log->journal_list);
	lbmLogShutdown(log);

    _ unclaim:
	bd_release(bdev);

 ___  close:		/* close_external log device */
	blkdev_put(bdev, FMODE_READ|FMODE_WRITE);

 _    free:		/* free_log descriptor */
	mutex_unlock(&jfs_log_mutex);
	kfree(log);

	jfs_warn("lmLogOpen: exit(%d)", rc);
	return