persistentstorage/dbms/ustor/US_FILE.CPP
changeset 25 63532cdadd44
parent 0 08ec8eefde2f
child 29 cce6680bbf1c
--- a/persistentstorage/dbms/ustor/US_FILE.CPP	Thu May 27 14:29:47 2010 +0300
+++ b/persistentstorage/dbms/ustor/US_FILE.CPP	Fri Jun 11 15:29:22 2010 +0300
@@ -98,10 +98,12 @@
 	default:
 		__LEAVE(KErrNotSupported);
 	case TDbFormat::ECreate:
-		store=CPermanentFileStore::CreateL(iFs,aName,EFileRead|EFileWrite);
+//  When the file cache in file server is on, the order of file writing is not guaranteed which could cause data inconsistency in some circumstances, for example, when the power is lost in the middle of data transaction. Therefore, the file write cache is switched off here to maintain the file integrity .	    
+		store=CPermanentFileStore::CreateL(iFs,aName,EFileRead|EFileWrite/EFileWriteDirectIO);
 		break;
 	case TDbFormat::EReplace:
-		store=CPermanentFileStore::ReplaceL(iFs,aName,EFileRead|EFileWrite);
+//  When the file cache in file server is on, the order of file writing is not guaranteed which could cause data inconsistency in some circumstances, for example, when the power is lost in the middle of data transaction. Therefore, the file write cache is switched off here to maintain the file integrity .
+		store=CPermanentFileStore::ReplaceL(iFs,aName,EFileRead|EFileWrite/EFileWriteDirectIO);
 		break;
 		};
 	iStore=store;
@@ -143,7 +145,9 @@
 	__ASSERT(!iName);	// check construction phase
 //
 	iName=aName.AllocL();
-	const TUint mode=aMode==TDbFormat::EReadOnly ? EFileShareReadersOnly : EFileWrite;
+	TUint mode=aMode==TDbFormat::EReadOnly ? EFileShareReadersOnly : EFileWrite;
+//	When the file cache in file server is on, the order of file writing is not guaranteed which could cause data inconsistency in some circumstances, for example, when the power is lost in the middle of data transaction. Therefore, the file write cache is switched off here to maintain the file integrity .
+	mode = mode|EFileWriteDirectIO;
 	CFileStore* store=CPermanentFileStore::OpenL(iFs,*iName,mode);
 	iStore=store;
 	CDbStoreDatabase::RestoreL(DatabaseIdL(store->Root()));