|
|||||||||||
|
[patch 7/8] WL4081 Allow use of direct IO (O_DIRECT) with azio
From: <stewart(at)mysql.com>
Date: Thu Oct 11 2007 - 04:45:48 EDT
This enables O_DIRECT usage with azio if aligned buffers are allocated (by default, the azio allocation - posix_memalign - does this). Index: telco-6.2/storage/ndb/include/util/azlib.h
-
int z_err; /* error code for last stream operation */ int z_eof; /* set if end of input file */ File file; /* .gz file */ - Byte inbuf[AZ_BUFSIZE_READ]; /* input buffer */ - Byte outbuf[AZ_BUFSIZE_WRITE]; /* output buffer */ + Byte *inbuf; /* input buffer */ + Byte *outbuf; /* output buffer */ uLong crc; /* crc32 of uncompressed data */ char *msg; /* error message */ int transparent; /* 1 if input file is not a .gz file */ char mode; /* 'w' or 'r' */ + char bufalloced; /* true if azio allocated buffers */ my_off_t start; /* start of compressed data in file (header skipped) */ my_off_t in; /* bytes into deflate or inflate */ my_off_t out; /* bytes out of deflate or inflate */ @@ -233,7 +233,6 @@ typedef struct azio_stream { } azio_stream;
/* basic functions */
-
extern int azopen(azio_stream *s, const char *path, int Flags); /* Opens a gzip (.gz) file for reading or writing. The mode parameter Index: telco-6.2/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.cpp
+ azfBufferUnaligned= (Byte*)ndbd_malloc((AZ_BUFSIZE_READ+AZ_BUFSIZE_WRITE) + +NDB_O_DIRECT_WRITE_ALIGNMENT-1); + + azf.inbuf= (Byte*)(((UintPtr)azfBufferUnaligned + + NDB_O_DIRECT_WRITE_ALIGNMENT - 1) & + ~(UintPtr)(NDB_O_DIRECT_WRITE_ALIGNMENT - 1)); + + azf.outbuf= azf.inbuf + AZ_BUFSIZE_READ; +
NdbMutex_Unlock(theStartMutexPtr);
@@ -1024,7 +1033,13 @@ AsyncFile::closeReq(Request * request)
else
+ Byte *a,*b; + a= azf.inbuf; + b= azf.outbuf; memset(&azf,0,sizeof(azf)); + azf.inbuf= a; + azf.outbuf= b; +
if (-1 == r) {
if (theFd == -1) {
// Thread is ended with return
+ + if (azfBufferUnaligned) + ndbd_free(azfBufferUnaligned, (AZ_BUFSIZE_READ*AZ_BUFSIZE_WRITE) + +NDB_O_DIRECT_WRITE_ALIGNMENT-1);} Index: telco-6.2/storage/ndb/src/kernel/blocks/ndbfs/AsyncFile.hpp
size_t m_write_wo_sync; // Writes wo/ sync size_t m_auto_sync_freq; // Auto sync freq in bytes Index: telco-6.2/storage/ndb/src/common/util/azio.c =================================================================== --- telco-6.2.orig/storage/ndb/src/common/util/azio.c 2007-10-11 17:01:35.313731711 +1000 +++ telco-6.2/storage/ndb/src/common/util/azio.c 2007-10-11 17:01:42.798098794 +1000 @@ -15,6 +15,7 @@ #include
static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
static int const az_magic[3] = {0xfe, 0x03, 0x01}; /* az magic header */
s->stream.zalloc = (alloc_func)0;
s->stream.zfree = (free_func)0;
s->stream.opaque = (voidpf)0;
+ s->bufalloced = 0;
+ if(!s->inbuf)
+ {
+ err= posix_memalign(&(s->inbuf),512,AZ_BUFSIZE_READ);
+ if(err)
+ return err;
+ err= posix_memalign(&(s->outbuf),512,AZ_BUFSIZE_WRITE);
+ if(err)
+ return err;
+ s->bufalloced = 1; + }
memset(s->inbuf, 0, AZ_BUFSIZE_READ);
memset(s->outbuf, 0, AZ_BUFSIZE_WRITE);
s->stream.next_in = s->inbuf;
if (s->z_err < 0) err = s->z_err;
+ if(s->bufalloced)
+ {
+ free(s->inbuf);
+ free(s->outbuf);
+ }
+
return err;
-- Stewart Smith -- MySQL Code Commits Mailing List For list archives: http://lists.mysql.com/commits To unsubscribe: http://lists.mysql.com/commits?unsub=lists@pantek.comReceived on Thu Oct 11 09:22:29 2007 This archive was generated by hypermail 2.1.8 : Thu Jul 03 2008 - 09:43:35 EDT |
||||||||||
|
|||||||||||