~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/src/kernel/blocks/ndbfs/VoidFs.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include <limits.h>
 
17
#include <errno.h>
 
18
 
 
19
#include "Ndbfs.hpp"
 
20
#include "AsyncFile.hpp"
 
21
#include "Filename.hpp"
 
22
 
 
23
#include <signaldata/FsOpenReq.hpp>
 
24
#include <signaldata/FsCloseReq.hpp>
 
25
#include <signaldata/FsReadWriteReq.hpp>
 
26
#include <signaldata/FsAppendReq.hpp>
 
27
#include <signaldata/FsRemoveReq.hpp>
 
28
#include <signaldata/FsConf.hpp>
 
29
#include <signaldata/FsRef.hpp>
 
30
#include <signaldata/NdbfsContinueB.hpp>
 
31
#include <signaldata/DumpStateOrd.hpp>
 
32
 
 
33
#include <RefConvert.hpp>
 
34
#include <NdbSleep.h>
 
35
#include <NdbOut.hpp>
 
36
#include <Configuration.hpp>
 
37
 
 
38
#define DEBUG(x) { ndbout << "FS::" << x << endl; }
 
39
 
 
40
VoidFs::VoidFs(Block_context & ctx) :
 
41
  SimulatedBlock(NDBFS, ctx)
 
42
{
 
43
  BLOCK_CONSTRUCTOR(VoidFs);
 
44
  
 
45
  // Set received signals
 
46
  addRecSignal(GSN_READ_CONFIG_REQ, &VoidFs::execREAD_CONFIG_REQ);
 
47
  addRecSignal(GSN_DUMP_STATE_ORD,  &VoidFs::execDUMP_STATE_ORD);
 
48
  addRecSignal(GSN_STTOR,  &VoidFs::execSTTOR);
 
49
  addRecSignal(GSN_FSOPENREQ, &VoidFs::execFSOPENREQ);
 
50
  addRecSignal(GSN_FSCLOSEREQ, &VoidFs::execFSCLOSEREQ);
 
51
  addRecSignal(GSN_FSWRITEREQ, &VoidFs::execFSWRITEREQ);
 
52
  addRecSignal(GSN_FSREADREQ, &VoidFs::execFSREADREQ);
 
53
  addRecSignal(GSN_FSSYNCREQ, &VoidFs::execFSSYNCREQ);
 
54
  addRecSignal(GSN_FSAPPENDREQ, &VoidFs::execFSAPPENDREQ);
 
55
  addRecSignal(GSN_FSREMOVEREQ, &VoidFs::execFSREMOVEREQ);
 
56
   // Set send signals
 
57
}
 
58
 
 
59
VoidFs::~VoidFs()
 
60
{
 
61
}
 
62
 
 
63
void 
 
64
VoidFs::execREAD_CONFIG_REQ(Signal* signal)
 
65
{
 
66
  const ReadConfigReq * req = (ReadConfigReq*)signal->getDataPtr();
 
67
 
 
68
  Uint32 ref = req->senderRef;
 
69
  Uint32 senderData = req->senderData;
 
70
 
 
71
  ReadConfigConf * conf = (ReadConfigConf*)signal->getDataPtrSend();
 
72
  conf->senderRef = reference();
 
73
  conf->senderData = senderData;
 
74
  sendSignal(ref, GSN_READ_CONFIG_CONF, signal, 
 
75
             ReadConfigConf::SignalLength, JBB);
 
76
}
 
77
 
 
78
void
 
79
VoidFs::execSTTOR(Signal* signal)
 
80
{
 
81
  jamEntry();
 
82
  
 
83
  if(signal->theData[1] == 0){ // StartPhase 0
 
84
    jam();
 
85
    signal->theData[3] = 255;
 
86
    sendSignal(NDBCNTR_REF, GSN_STTORRY, signal, 4, JBB);
 
87
    return;
 
88
  }
 
89
  ndbrequire(0);
 
90
}
 
91
 
 
92
void 
 
93
VoidFs::execFSOPENREQ(Signal* signal)
 
94
{
 
95
  jamEntry();
 
96
  const FsOpenReq * const fsOpenReq = (FsOpenReq *)&signal->theData[0];
 
97
  const BlockReference userRef = fsOpenReq->userReference;
 
98
  const Uint32 userPointer = fsOpenReq->userPointer;
 
99
 
 
100
  Uint32 flags = fsOpenReq->fileFlags;
 
101
  if(flags == FsOpenReq::OM_READONLY){
 
102
    // Initialise FsRef signal
 
103
    FsRef * const fsRef = (FsRef *)&signal->theData[0];
 
104
    fsRef->userPointer = userPointer;
 
105
    fsRef->errorCode = FsRef::fsErrFileDoesNotExist;
 
106
    fsRef->osErrorCode = ~0; 
 
107
    sendSignal(userRef, GSN_FSOPENREF, signal, 3, JBB);
 
108
    return;
 
109
  }
 
110
 
 
111
  if(flags & FsOpenReq::OM_WRITEONLY || flags & FsOpenReq::OM_READWRITE){
 
112
    signal->theData[0] = userPointer;
 
113
    signal->theData[1] = c_maxFileNo++;
 
114
    sendSignal(userRef, GSN_FSOPENCONF, signal, 2, JBB);
 
115
  }
 
116
}
 
117
 
 
118
void 
 
119
VoidFs::execFSREMOVEREQ(Signal* signal)
 
120
{
 
121
  jamEntry();
 
122
  const FsRemoveReq * const req = (FsRemoveReq *)signal->getDataPtr();
 
123
  const Uint32 userRef = req->userReference;
 
124
  const Uint32 userPointer = req->userPointer;
 
125
 
 
126
  signal->theData[0] = userPointer;
 
127
  sendSignal(userRef, GSN_FSREMOVECONF, signal, 1, JBB);
 
128
}
 
129
 
 
130
/*
 
131
 * PR0: File Pointer DR0: User reference DR1: User Pointer DR2: Flag bit 0= 1
 
132
 * remove file
 
133
 */
 
134
void 
 
135
VoidFs::execFSCLOSEREQ(Signal * signal)
 
136
{
 
137
  jamEntry();
 
138
  
 
139
  const FsCloseReq * const req = (FsCloseReq *)signal->getDataPtr();
 
140
  const Uint32 userRef = req->userReference;
 
141
  const Uint32 userPointer = req->userPointer;
 
142
  
 
143
  signal->theData[0] = userPointer;
 
144
  sendSignal(userRef, GSN_FSCLOSECONF, signal, 1, JBB);
 
145
}
 
146
 
 
147
void 
 
148
VoidFs::execFSWRITEREQ(Signal* signal)
 
149
{
 
150
  jamEntry();
 
151
  const FsReadWriteReq * const req = (FsReadWriteReq *)signal->getDataPtr();
 
152
  const Uint32 userRef = req->userReference;
 
153
  const Uint32 userPointer = req->userPointer;
 
154
 
 
155
  signal->theData[0] = userPointer;
 
156
  sendSignal(userRef, GSN_FSWRITECONF, signal, 1, JBB);
 
157
}
 
158
 
 
159
void 
 
160
VoidFs::execFSREADREQ(Signal* signal)
 
161
{
 
162
  jamEntry();
 
163
 
 
164
  const FsReadWriteReq * const req = (FsReadWriteReq *)signal->getDataPtr();
 
165
  const Uint32 userRef = req->userReference;
 
166
  const Uint32 userPointer = req->userPointer;
 
167
 
 
168
  signal->theData[0] = userPointer;
 
169
  sendSignal(userRef, GSN_FSREADCONF, signal, 1, JBB);
 
170
#if 0
 
171
  FsRef * const fsRef = (FsRef *)&signal->theData[0];
 
172
  fsRef->userPointer = userPointer;
 
173
  fsRef->errorCode = FsRef::fsErrEnvironmentError;
 
174
  fsRef->osErrorCode = ~0; // Indicate local error
 
175
  sendSignal(userRef, GSN_FSREADREF, signal, 3, JBB);
 
176
#endif
 
177
}
 
178
 
 
179
void
 
180
VoidFs::execFSSYNCREQ(Signal * signal)
 
181
{
 
182
  jamEntry();
 
183
 
 
184
  BlockReference userRef = signal->theData[1];
 
185
  const UintR userPointer = signal->theData[2]; 
 
186
 
 
187
  signal->theData[0] = userPointer;
 
188
  sendSignal(userRef, GSN_FSSYNCCONF, signal, 1, JBB);
 
189
 
 
190
  return;
 
191
}
 
192
 
 
193
void 
 
194
VoidFs::execFSAPPENDREQ(Signal * signal)
 
195
{
 
196
  const FsAppendReq * const fsReq = (FsAppendReq *)&signal->theData[0];
 
197
  const UintR userPointer = fsReq->userPointer; 
 
198
  const BlockReference userRef = fsReq->userReference;
 
199
  const Uint32 size = fsReq->size;
 
200
  
 
201
  signal->theData[0] = userPointer;
 
202
  signal->theData[1] = size << 2;
 
203
  sendSignal(userRef, GSN_FSAPPENDCONF, signal, 2, JBB);
 
204
}
 
205
 
 
206
void
 
207
VoidFs::execDUMP_STATE_ORD(Signal* signal)
 
208
{
 
209
}//VoidFs::execDUMP_STATE_ORD()
 
210
 
 
211
 
 
212
 
 
213
BLOCK_FUNCTIONS(VoidFs)
 
214