List:Commits« Previous MessageNext Message »
From:stewart Date:October 11 2007 8:45am
Subject:[patch 6/8] WL4081: Add support to AsyncFile for reading zlib compressed files.
View as plain text  
Add OM_GZ flag to restore block (allowing restore of compressed LCPs)

Current issues:
- doesn't work with O_DIRECT
- doesn't do anything aligned

Likely issues for LockPages and lots of memory used... but
good for smaller places i hope.

Index: ndb-work/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp
===================================================================
--- ndb-work.orig/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp	2007-09-27
08:53:00.545217976 +1000
+++ ndb-work/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp	2007-10-03
15:37:39.712124476 +1000
@@ -50,7 +50,7 @@
 #endif
 
 // Use this define if you want printouts from AsyncFile class
-//#define DEBUG_ASYNCFILE
+#define DEBUG_ASYNCFILE
 
 #ifdef DEBUG_ASYNCFILE
 #include <NdbOut.hpp>
@@ -98,6 +98,7 @@ AsyncFile::AsyncFile(SimulatedBlock& fs)
   theMemoryChannelPtr(NULL),
   m_fs(fs)
 {
+  memset(&azf,0,sizeof(azf));
   m_page_ptr.setNull();
   m_current_request= m_last_request= 0;
   m_open_flags = 0;
@@ -477,6 +478,7 @@ no_odirect:
   theFd = ::open(theFileName.c_str(), new_flags, mode);
   if (-1 == theFd)
   {
+    ndbout_c("1 ERROR opening %s",theFileName.c_str());
     PRINT_ERRORANDFLAGS(new_flags);
     if ((errno == ENOENT) && (new_flags & O_CREAT)) 
     {
@@ -491,6 +493,7 @@ no_odirect:
 	  goto no_odirect;
 	}
 #endif
+        ndbout_c("2 ERROR opening %s",theFileName.c_str());
         PRINT_ERRORANDFLAGS(new_flags);
         request->error = errno;
 	return;
@@ -653,7 +656,7 @@ no_odirect:
   }
 #endif
   if(use_gz)
-    if(!azdopen(&azf, theFd, O_CREAT|O_RDWR|O_BINARY))
+    if(!azdopen(&azf, theFd, new_flags))
     {
       ndbout_c("Stewart's brain broke");
       abort();
@@ -671,14 +674,29 @@ AsyncFile::readBuffer(Request* req, char
   }
 #elif ! defined(HAVE_PREAD)
   off_t seek_val;
-  while((seek_val= lseek(theFd, offset, SEEK_SET)) == (off_t)-1 
-	&& errno == EINTR);
-  if(seek_val == (off_t)-1)
+  if(!use_gz)
   {
-    return errno;
+    while((seek_val= lseek(theFd, offset, SEEK_SET)) == (off_t)-1
+          && errno == EINTR);
+    if(seek_val == (off_t)-1)
+    {
+      return errno;
+    }
   }
 #endif
-    
+  off_t seek_val;
+  if(use_gz)
+  {
+    while((seek_val= azseek(&azf, offset, SEEK_SET)) == (off_t)-1
+          && errno == EINTR);
+    if(seek_val == (off_t)-1)
+    {
+      return errno;
+    }
+  }
+
+  int error;
+
   while (size > 0) {
     size_t bytes_read = 0;
     
@@ -694,9 +712,15 @@ AsyncFile::readBuffer(Request* req, char
     } 
     bytes_read = dwBytesRead;
 #elif  ! defined(HAVE_PREAD)
-    return_value = ::read(theFd, buf, size);
+    if(use_gz)
+      return_value = azread(&azf, buf, size, &error);
+    else
+      return_value = ::read(theFd, buf, size);
 #else // UNIX
-    return_value = ::pread(theFd, buf, size, offset);
+    if(!use_gz)
+      return_value = ::pread(theFd, buf, size, offset);
+    else
+      return_value = azread(&azf, buf, size, &error);
 #endif
 #ifndef NDB_WIN32
     if (return_value == -1 && errno == EINTR) {
@@ -1000,6 +1024,7 @@ AsyncFile::closeReq(Request * request)
   else
     ::close(theFd);
   use_gz= 0;
+  memset(&azf,0,sizeof(azf));
   if (-1 == r) {
 #ifndef DBUG_OFF
     if (theFd == -1) {
Index: ndb-work/storage/ndb/src/kernel/blocks/restore.cpp
===================================================================
--- ndb-work.orig/storage/ndb/src/kernel/blocks/restore.cpp	2007-09-25 23:56:12.668879000
+1000
+++ ndb-work/storage/ndb/src/kernel/blocks/restore.cpp	2007-10-03 15:37:39.816129577 +1000
@@ -359,7 +359,7 @@ Restore::open_file(Signal* signal, FileP
 {
   FsOpenReq * req = (FsOpenReq *)signal->getDataPtrSend();
   req->userReference = reference();
-  req->fileFlags = FsOpenReq::OM_READONLY ;
+  req->fileFlags = FsOpenReq::OM_READONLY | FsOpenReq::OM_GZ;
   req->userPointer = file_ptr.i;
   
   FsOpenReq::setVersion(req->fileNumber, 5);
Index: ndb-work/storage/ndb/src/common/util/azio.c
===================================================================
--- ndb-work.orig/storage/ndb/src/common/util/azio.c	2007-10-03 14:04:22.653607786 +1000
+++ ndb-work/storage/ndb/src/common/util/azio.c	2007-10-03 15:37:39.824129970 +1000
@@ -78,7 +78,7 @@ int az_open (azio_stream *s, const char 
   DBUG_ASSERT(Flags | O_APPEND);
   DBUG_ASSERT(Flags | O_WRONLY);
 
-  if (Flags & O_RDWR) 
+  if (Flags & O_RDWR || Flags & O_WRONLY)
     s->mode = 'w';
 
   if (s->mode == 'w') 

--
Stewart Smith
Thread
[patch 0/8] WL4081 NDB Compressed LCP and Backupstewart11 Oct
  • [patch 4/8] WL4081: read compressed backup filesstewart11 Oct
  • [patch 3/8] WL4081: Add compressed file support to AsyncFile (azio) and support compressed backups.stewart11 Oct
  • [patch 1/8] WL4081: Copy azio for NDBstewart11 Oct
  • [patch 6/8] WL4081: Add support to AsyncFile for reading zlib compressed files.stewart11 Oct
  • [patch 5/8] WL4081: add support for *storing* compressed LCPstewart11 Oct
  • [patch 8/8] WL4081 Futz with mtr ndb config to enable compressed lcp, backup and O_DIRECTstewart11 Oct
  • [patch 7/8] WL4081 Allow use of direct IO (O_DIRECT) with aziostewart11 Oct
  • [patch 2/8] WL4081: Make azio build for NDBstewart11 Oct
  • Re: [patch 0/8] WL4081 NDB Compressed LCP and BackupStewart Smith11 Oct