Annotation of parser3/src/sql/mysql/mySQL32/include/raid.h, revision 1.1

1.1     ! paf         1: /* Copyright (C) 1999 Monty Program KB
        !             2: 
        !             3:    This software is distributed with NO WARRANTY OF ANY KIND.  No author or
        !             4:    distributor accepts any responsibility for the consequences of using it, or
        !             5:    for whether it serves any particular purpose or works at all, unless he or
        !             6:    she says so in writing.  Refer to the Free Public License (the "License")
        !             7:    for full details.
        !             8: 
        !             9:    Every copy of this file must include a copy of the License, normally in a
        !            10:    plain ASCII text file named PUBLIC.  The License grants you the right to
        !            11:    copy, modify and redistribute this file, but only under certain conditions
        !            12:    described in the License.  Among other things, the License requires that
        !            13:    the copyright notice and this notice be preserved on all copies. */
        !            14: 
        !            15: 
        !            16: /* Parser needs these defines  always, even if USE_RAID is not defined */
        !            17: #define RAID_TYPE_0 1       // Striping
        !            18: #define RAID_TYPE_x 2       // Some new modes
        !            19: #define RAID_TYPE_y 3       // 
        !            20: 
        !            21: #define RAID_DEFAULT_CHUNKS 4
        !            22: #define RAID_DEFAULT_CHUNKSIZE 256*1024 /* 256kB */
        !            23: 
        !            24: extern const char *raid_type_string[];
        !            25: 
        !            26: #if defined(USE_RAID)
        !            27: 
        !            28: #ifdef __GNUC__
        !            29: #pragma interface                      /* gcc class implementation */
        !            30: #endif
        !            31: #include "my_dir.h"
        !            32: 
        !            33: /* Trap all occurences of my_...() in source and use our wrapper around this function */
        !            34: 
        !            35: #ifdef MAP_TO_USE_RAID
        !            36: #define my_read(A,B,C,D)     my_raid_read(A,B,C,D)
        !            37: #define my_write(A,B,C,D)    my_raid_write(A,B,C,D)
        !            38: #define my_pwrite(A,B,C,D,E) my_raid_pwrite(A,B,C,D,E)
        !            39: #define my_pread(A,B,C,D,E)  my_raid_pread(A,B,C,D,E)
        !            40: #define my_chsize(A,B,C)     my_raid_chsize(A,B,C)
        !            41: #define my_close(A,B)        my_raid_close(A,B)
        !            42: #define my_tell(A,B)         my_raid_tell(A,B)
        !            43: #define my_seek(A,B,C,D)     my_raid_seek(A,B,C,D)
        !            44: #define my_lock(A,B,C,D,E)     my_raid_lock(A,B,C,D,E)
        !            45: #define my_fstat(A,B,C)     my_raid_fstat(A,B,C)
        !            46: #endif /* MAP_TO_USE_RAID */
        !            47: 
        !            48: #ifdef __cplusplus
        !            49: extern "C" {
        !            50: #endif
        !            51: 
        !            52:   void init_raid(void);
        !            53:   void end_raid(void);
        !            54: 
        !            55:   bool is_raid(File fd);
        !            56:   File my_raid_create(const char *FileName, int CreateFlags, int access_flags,
        !            57:                      uint raid_type, uint raid_chunks, ulong raid_chunksize,
        !            58:                      myf MyFlags);
        !            59:   File my_raid_open(const char *FileName, int Flags,
        !            60:                    uint raid_type, uint raid_chunks, ulong raid_chunksize,
        !            61:                    myf MyFlags);
        !            62:   int my_raid_rename(const char *from, const char *to, uint raid_chunks,
        !            63:                     myf MyFlags);
        !            64:   int my_raid_delete(const char *from, uint raid_chunks, myf MyFlags);
        !            65:   int my_raid_redel(const char *old_name, const char *new_name,
        !            66:                    uint raid_chunks, myf MyFlags);
        !            67: 
        !            68:   my_off_t my_raid_seek(File fd, my_off_t pos, int whence, myf MyFlags);
        !            69:   my_off_t my_raid_tell(File fd, myf MyFlags);
        !            70: 
        !            71:   uint my_raid_write(File,const byte *Buffer, uint Count, myf MyFlags);
        !            72:   uint my_raid_read(File Filedes, byte *Buffer, uint Count, myf MyFlags);
        !            73: 
        !            74:   uint my_raid_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset,
        !            75:                     myf MyFlags);
        !            76:   uint my_raid_pwrite(int Filedes, const byte *Buffer, uint Count,
        !            77:                      my_off_t offset, myf MyFlags);
        !            78: 
        !            79:   int my_raid_lock(File,int locktype, my_off_t start, my_off_t length,
        !            80:                   myf MyFlags);
        !            81:   int my_raid_chsize(File fd, my_off_t newlength, myf MyFlags);
        !            82:   int my_raid_close(File, myf MyFlags);
        !            83:   int my_raid_fstat(int Filedes, struct stat *buf,  myf MyFlags);
        !            84: 
        !            85:   const char *my_raid_type(int raid_type);
        !            86: 
        !            87: #ifdef __cplusplus
        !            88: }
        !            89: 
        !            90: class RaidName {
        !            91:   public:
        !            92:     RaidName(const char *FileName);
        !            93:     ~RaidName();
        !            94:     bool IsRaid();
        !            95:     int Rename(const char * from, const char * to, myf MyFlags);
        !            96:   private:
        !            97:     uint _raid_type;       // RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5
        !            98:     uint _raid_chunks;     // 1..n
        !            99:     ulong _raid_chunksize; // 1..n in bytes
        !           100: };
        !           101: 
        !           102: class RaidFd {
        !           103:   public:
        !           104:     RaidFd(uint raid_type, uint raid_chunks , ulong raid_chunksize);
        !           105:     ~RaidFd();
        !           106:     File Create(const char *FileName, int CreateFlags, int access_flags,
        !           107:                myf MyFlags);
        !           108:     File Open(const char *FileName, int Flags, myf MyFlags);
        !           109:     my_off_t Seek(my_off_t pos,int whence,myf MyFlags);
        !           110:     my_off_t Tell(myf MyFlags);
        !           111:     int Write(const byte *Buffer, uint Count, myf MyFlags);
        !           112:     int Read(const byte *Buffer, uint Count, myf MyFlags);
        !           113:     int Lock(int locktype, my_off_t start, my_off_t length, myf MyFlags);
        !           114:     int Chsize(File fd, my_off_t newlength, myf MyFlags);
        !           115:     int Fstat(int fd, MY_STAT *stat_area, myf MyFlags );
        !           116:     int Close(myf MyFlags);
        !           117:     static bool IsRaid(File fd);
        !           118:     static DYNAMIC_ARRAY _raid_map;            /* Map of RaidFD* */
        !           119:   private:
        !           120: 
        !           121:     uint _raid_type;       // RAID_TYPE_0 or RAID_TYPE_1 or RAID_TYPE_5
        !           122:     uint _raid_chunks;     // 1..n
        !           123:     ulong _raid_chunksize; // 1..n in bytes
        !           124: 
        !           125:     ulong _total_block;    // We are operating with block no x (can be 0..many).
        !           126:     uint _this_block;      // can be 0.._raid_chunks
        !           127:     uint _remaining_bytes; // Maximum bytes that can be written in this block
        !           128: 
        !           129:     my_off_t _position;
        !           130:     my_off_t _size;        // Cached file size for faster seek(SEEK_END)
        !           131:     File _fd;
        !           132:     File *_fd_vector;          /* Array of File */
        !           133:     off_t *_seek_vector;       /* Array of cached seek positions */
        !           134: 
        !           135:     inline void Calculate()
        !           136:     {
        !           137:       DBUG_ENTER("RaidFd::_Calculate");
        !           138:       DBUG_PRINT("info",("_position: %lu _raid_chunksize: %d, _size: %lu",
        !           139:                         (ulong) _position, _raid_chunksize, (ulong) _size));
        !           140: 
        !           141:       _total_block = (ulong) (_position / _raid_chunksize);
        !           142:       _this_block = _total_block % _raid_chunks;    // can be 0.._raid_chunks
        !           143:       _remaining_bytes = (uint) (_raid_chunksize -
        !           144:                                 (_position - _total_block * _raid_chunksize));
        !           145:       DBUG_PRINT("info",
        !           146:                 ("_total_block: %d  this_block: %d  _remaining_bytes:%d",
        !           147:                  _total_block, _this_block, _remaining_bytes));
        !           148:       DBUG_VOID_RETURN;
        !           149:     }
        !           150: };
        !           151: 
        !           152: #endif /* __cplusplus */
        !           153: #endif /* USE_RAID */

E-mail: