2001-05-23 15:26:42 +02:00
|
|
|
/*
|
|
|
|
* PROGRAM: JRD Access Method
|
|
|
|
* MODULE: pio.h
|
|
|
|
* DESCRIPTION: File system interface definitions
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Interbase Public
|
|
|
|
* License Version 1.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy
|
|
|
|
* of the License at http://www.Inprise.com/IPL.html
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an
|
|
|
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
|
|
|
|
* or implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* The Original Code was created by Inprise Corporation
|
|
|
|
* and its predecessors. Portions created by Inprise Corporation are
|
|
|
|
* Copyright (C) Inprise Corporation.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
* Contributor(s): ______________________________________.
|
2002-10-30 07:40:58 +01:00
|
|
|
*
|
|
|
|
* 2002.10.29 Sean Leyne - Removed obsolete "Netware" port
|
|
|
|
*
|
2002-10-31 06:06:02 +01:00
|
|
|
* 2002.10.30 Sean Leyne - Removed support for obsolete "PC_PLATFORM" define
|
|
|
|
*
|
2001-05-23 15:26:42 +02:00
|
|
|
*/
|
|
|
|
|
2003-10-03 03:53:34 +02:00
|
|
|
#ifndef JRD_PIO_H
|
|
|
|
#define JRD_PIO_H
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2001-12-24 03:51:06 +01:00
|
|
|
#include "../include/fb_blk.h"
|
2007-09-25 13:47:39 +02:00
|
|
|
#include "../jrd/thread_proto.h"
|
2007-09-25 22:15:53 +02:00
|
|
|
#include "../common/classes/rwlock.h"
|
2008-02-28 14:34:50 +01:00
|
|
|
#include "../common/classes/array.h"
|
2001-12-24 03:51:06 +01:00
|
|
|
|
2004-03-20 15:57:40 +01:00
|
|
|
namespace Jrd {
|
|
|
|
|
2001-05-23 15:26:42 +02:00
|
|
|
#ifdef UNIX
|
|
|
|
|
2004-02-20 07:43:27 +01:00
|
|
|
class jrd_file : public pool_alloc_rpt<SCHAR, type_fil>
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
2008-05-10 05:44:57 +02:00
|
|
|
public:
|
2004-02-20 07:43:27 +01:00
|
|
|
jrd_file* fil_next; /* Next file in database */
|
2001-05-23 15:26:42 +02:00
|
|
|
ULONG fil_min_page; /* Minimum page number in file */
|
|
|
|
ULONG fil_max_page; /* Maximum page number in file */
|
|
|
|
USHORT fil_sequence; /* Sequence number of file */
|
|
|
|
USHORT fil_fudge; /* Fudge factor for page relocation */
|
|
|
|
int fil_desc;
|
2007-02-02 11:56:53 +01:00
|
|
|
//int *fil_trace; /* Trace file, if any */
|
2007-06-06 14:37:24 +02:00
|
|
|
Firebird::Mutex fil_mutex;
|
2003-02-06 20:47:07 +01:00
|
|
|
USHORT fil_flags;
|
2001-05-23 15:26:42 +02:00
|
|
|
SCHAR fil_string[1]; /* Expanded file name */
|
2001-12-24 03:51:06 +01:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef WIN_NT
|
|
|
|
#ifdef SUPERSERVER_V2
|
2004-05-12 02:02:37 +02:00
|
|
|
const int MAX_FILE_IO = 32; /* Maximum "allocated" overlapped I/O events */
|
2001-05-23 15:26:42 +02:00
|
|
|
#endif
|
|
|
|
|
2004-02-20 07:43:27 +01:00
|
|
|
class jrd_file : public pool_alloc_rpt<SCHAR, type_fil>
|
2001-12-24 03:51:06 +01:00
|
|
|
{
|
2008-05-10 05:44:57 +02:00
|
|
|
public:
|
2007-09-18 16:50:51 +02:00
|
|
|
|
2008-05-10 05:44:57 +02:00
|
|
|
~jrd_file()
|
|
|
|
{
|
2007-09-18 16:50:51 +02:00
|
|
|
delete fil_ext_lock;
|
|
|
|
}
|
|
|
|
|
2004-02-20 07:43:27 +01:00
|
|
|
jrd_file* fil_next; /* Next file in database */
|
2001-05-23 15:26:42 +02:00
|
|
|
ULONG fil_min_page; /* Minimum page number in file */
|
|
|
|
ULONG fil_max_page; /* Maximum page number in file */
|
|
|
|
USHORT fil_sequence; /* Sequence number of file */
|
|
|
|
USHORT fil_fudge; /* Fudge factor for page relocation */
|
2007-07-26 03:23:18 +02:00
|
|
|
HANDLE fil_desc; // File descriptor
|
2007-02-02 11:56:53 +01:00
|
|
|
//int *fil_trace; /* Trace file, if any */
|
2007-06-06 14:37:24 +02:00
|
|
|
Firebird::Mutex fil_mutex;
|
2007-09-25 22:15:53 +02:00
|
|
|
Firebird::RWLock* fil_ext_lock; // file extend lock
|
2001-05-23 15:26:42 +02:00
|
|
|
#ifdef SUPERSERVER_V2
|
2002-04-29 17:05:11 +02:00
|
|
|
void* fil_io_events[MAX_FILE_IO]; /* Overlapped I/O events */
|
2001-05-23 15:26:42 +02:00
|
|
|
#endif
|
|
|
|
USHORT fil_flags;
|
|
|
|
SCHAR fil_string[1]; /* Expanded file name */
|
2001-12-24 03:51:06 +01:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2004-05-12 02:02:37 +02:00
|
|
|
const USHORT FIL_force_write = 1;
|
2007-07-25 20:44:54 +02:00
|
|
|
const USHORT FIL_no_fs_cache = 2; // not using file system cache
|
|
|
|
const USHORT FIL_readonly = 4; // file opened in readonly mode
|
2001-05-23 15:26:42 +02:00
|
|
|
|
|
|
|
/* Physical IO trace events */
|
|
|
|
|
2004-05-12 02:02:37 +02:00
|
|
|
const SSHORT trace_create = 1;
|
|
|
|
const SSHORT trace_open = 2;
|
|
|
|
const SSHORT trace_page_size = 3;
|
|
|
|
const SSHORT trace_read = 4;
|
|
|
|
const SSHORT trace_write = 5;
|
|
|
|
const SSHORT trace_close = 6;
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-02-20 07:43:27 +01:00
|
|
|
// Physical I/O status block, used only in SS v2 for Win32
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2007-02-02 11:56:53 +01:00
|
|
|
#ifdef SUPERSERVER_V2
|
2008-05-10 05:44:57 +02:00
|
|
|
struct phys_io_blk
|
|
|
|
{
|
2004-02-20 07:43:27 +01:00
|
|
|
jrd_file* piob_file; /* File being read/written */
|
2001-05-23 15:26:42 +02:00
|
|
|
SLONG piob_desc; /* File descriptor */
|
|
|
|
SLONG piob_io_length; /* Requested I/O transfer length */
|
|
|
|
SLONG piob_actual_length; /* Actual I/O transfer length */
|
|
|
|
USHORT piob_wait; /* Async or synchronous wait */
|
|
|
|
UCHAR piob_flags;
|
|
|
|
SLONG piob_io_event[8]; /* Event to signal I/O completion */
|
2004-02-20 07:43:27 +01:00
|
|
|
};
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2004-05-12 02:02:37 +02:00
|
|
|
// piob_flags
|
|
|
|
const UCHAR PIOB_error = 1; /* I/O error occurred */
|
|
|
|
const UCHAR PIOB_success = 2; /* I/O successfully completed */
|
|
|
|
const UCHAR PIOB_pending = 4; /* Asynchronous I/O not yet completed */
|
2007-02-02 11:56:53 +01:00
|
|
|
#endif
|
2001-05-23 15:26:42 +02:00
|
|
|
|
2008-02-28 10:48:11 +01:00
|
|
|
static const int ZERO_BUF_SIZE = 1024 * 128;
|
|
|
|
|
|
|
|
class HugeStaticBuffer
|
|
|
|
{
|
|
|
|
public:
|
2008-03-10 09:16:57 +01:00
|
|
|
explicit HugeStaticBuffer(MemoryPool& p)
|
2008-02-28 10:48:11 +01:00
|
|
|
: zeroArray(p),
|
2008-03-01 19:24:06 +01:00
|
|
|
zeroBuff(zeroArray.getBuffer(ZERO_BUF_SIZE))
|
2008-02-28 10:48:11 +01:00
|
|
|
{
|
|
|
|
memset(zeroBuff, 0, ZERO_BUF_SIZE);
|
|
|
|
}
|
|
|
|
|
2008-05-10 05:44:57 +02:00
|
|
|
const char* get() const { return zeroBuff; }
|
2008-02-28 10:48:11 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Firebird::Array<char> zeroArray;
|
2008-03-02 09:45:41 +01:00
|
|
|
char* const zeroBuff;
|
2008-02-28 10:48:11 +01:00
|
|
|
};
|
|
|
|
|
2004-03-20 15:57:40 +01:00
|
|
|
} //namespace Jrd
|
|
|
|
|
2004-02-20 07:43:27 +01:00
|
|
|
#endif // JRD_PIO_H
|
|
|
|
|