Below is the list of changes that have just been committed into a local
5.1 repository of jonas. When jonas does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-08-10 16:12:54+02:00, jonas@stripped +1 -0
ndb - bug#21172
Handle also open && !OM_INIT wrt non function O_DIRECT
storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp@stripped, 2006-08-10 16:12:52+02:00, jonas@stripped +50 -14
Fix open wrt O_DIRECT
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: jonas
# Host: perch.ndb.mysql.com
# Root: /home/jonas/src/51-work
--- 1.33/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp 2006-08-10 16:12:58 +02:00
+++ 1.34/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp 2006-08-10 16:12:58 +02:00
@@ -259,7 +259,7 @@ void AsyncFile::openReq(Request* request
DWORD dwDesiredAccess = 0;
DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
DWORD dwFlagsAndAttributes = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS | FILE_FLAG_NO_BUFFERING;
- const Uint32 flags = request->par.open.flags;
+ Uint32 flags = request->par.open.flags;
// Convert file open flags from Solaris to Windows
if ((flags & FsOpenReq::OM_CREATE) && (flags & FsOpenReq::OM_TRUNCATE)){
@@ -312,7 +312,7 @@ void AsyncFile::openReq(Request* request
return;
}
#else
- const Uint32 flags = request->par.open.flags;
+ Uint32 flags = request->par.open.flags;
Uint32 new_flags = 0;
// Convert file open flags from Solaris to Liux
@@ -339,22 +339,24 @@ void AsyncFile::openReq(Request* request
new_flags |= O_APPEND;
}
- if ((flags & FsOpenReq::OM_SYNC) && ! (flags & FsOpenReq::OM_INIT))
- {
-#ifdef O_SYNC
- new_flags |= O_SYNC;
-#endif
- }
-
-//#ifndef NDB_NO_O_DIRECT /* to allow tmpfs */
-#ifdef O_DIRECT
if (flags & FsOpenReq::OM_DIRECT)
+#ifdef O_DIRECT
{
new_flags |= O_DIRECT;
}
+#elif defined O_SYNC
+ {
+ flags |= OM_SYNC;
+ }
#endif
-//#endif
+ if ((flags & FsOpenReq::OM_SYNC) && ! (flags & FsOpenReq::OM_INIT))
+ {
+#ifdef O_SYNC
+ new_flags |= O_SYNC;
+#endif
+ }
+
switch(flags & 0x3){
case FsOpenReq::OM_READONLY:
new_flags |= O_RDONLY;
@@ -403,6 +405,11 @@ no_odirect:
if (new_flags & O_DIRECT)
{
new_flags &= ~O_DIRECT;
+ flags |= FsOpenReq::OM_SYNC;
+#ifdef O_SYNC
+ if (! (flags & FsOpenReq::OM_INIT))
+ new_flags |= O_SYNC;
+#endif
goto no_odirect;
}
#endif
@@ -415,6 +422,11 @@ no_odirect:
else if (new_flags & O_DIRECT)
{
new_flags &= ~O_DIRECT;
+ flags |= FsOpenReq::OM_SYNC;
+#ifdef O_SYNC
+ if (! (flags & FsOpenReq::OM_INIT))
+ new_flags |= O_SYNC;
+#endif
goto no_odirect;
}
#endif
@@ -489,6 +501,7 @@ no_odirect:
{
ndbout_c("error on first write(%d), disable O_DIRECT", err);
new_flags &= ~O_DIRECT;
+ flags |= FsOpenReq::OM_SYNC;
close(theFd);
theFd = ::open(theFileName.c_str(), new_flags, mode);
if (theFd != -1)
@@ -505,18 +518,41 @@ no_odirect:
if(lseek(theFd, 0, SEEK_SET) != 0)
request->error = errno;
}
+ else if (flags & FsOpenReq::OM_DIRECT)
+ {
+#ifdef O_DIRECT
+ do {
+ int ret;
+ char buf[2*GLOBAL_PAGE_SIZE -1];
+ char * bufptr = (char*)((UintPtr(buf)+(GLOBAL_PAGE_SIZE - 1)) & ~(GLOBAL_PAGE_SIZE - 1));
+ while (((ret = ::read(theFd, bufptr, GLOBAL_PAGE_SIZE)) == -1) && (errno == EINTR));
+ if (ret == -1)
+ {
+ ndbout_c("%s Failed to read using O_DIRECT, disabling", theFileName.c_str());
+ flags |= FsOpenReq::OM_SYNC;
+ flags |= FsOpenReq::OM_INIT;
+ break;
+ }
+ if(lseek(theFd, 0, SEEK_SET) != 0)
+ {
+ request->error = errno;
+ return;
+ }
+ } while (0);
+#endif
+ }
if ((flags & FsOpenReq::OM_SYNC) && (flags & FsOpenReq::OM_INIT))
{
+#ifdef O_SYNC
/**
* reopen file with O_SYNC
*/
close(theFd);
new_flags &= ~(O_CREAT | O_TRUNC);
-#ifdef O_SYNC
new_flags |= O_SYNC;
-#endif
theFd = ::open(theFileName.c_str(), new_flags, mode);
+#endif
}
#endif
}
| Thread |
|---|
| • bk commit into 5.1 tree (jonas:1.2265) BUG#21172 | jonas | 10 Aug |