nfs4: Use unstable writes and commit before close
This commit is contained in:
@@ -34,6 +34,8 @@ public:
|
|||||||
|
|
||||||
status_t GetChangeInfo(uint64* change);
|
status_t GetChangeInfo(uint64* change);
|
||||||
|
|
||||||
|
status_t Commit();
|
||||||
|
|
||||||
status_t LookUp(const char* name, ino_t* id);
|
status_t LookUp(const char* name, ino_t* id);
|
||||||
|
|
||||||
status_t CreateLink(const char* name, const char* path,
|
status_t CreateLink(const char* name, const char* path,
|
||||||
|
|||||||
@@ -456,3 +456,29 @@ Inode::Write(OpenFileCookie* cookie, off_t pos, const void* _buffer,
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Inode::Commit()
|
||||||
|
{
|
||||||
|
do {
|
||||||
|
RPC::Server* serv = fFileSystem->Server();
|
||||||
|
Request request(serv);
|
||||||
|
RequestBuilder& req = request.Builder();
|
||||||
|
|
||||||
|
req.PutFH(fInfo.fHandle);
|
||||||
|
req.Commit(0, 0);
|
||||||
|
|
||||||
|
status_t result = request.Send();
|
||||||
|
if (result != B_OK)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
ReplyInterpreter& reply = request.Reply();
|
||||||
|
|
||||||
|
if (_HandleErrors(reply.NFS4Error(), serv))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
reply.PutFH();
|
||||||
|
return reply.Commit();
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ enum Procedure {
|
|||||||
enum Opcode {
|
enum Opcode {
|
||||||
OpAccess = 3,
|
OpAccess = 3,
|
||||||
OpClose = 4,
|
OpClose = 4,
|
||||||
|
OpCommit = 5,
|
||||||
OpCreate = 6,
|
OpCreate = 6,
|
||||||
OpGetAttr = 9,
|
OpGetAttr = 9,
|
||||||
OpGetFH = 10,
|
OpGetFH = 10,
|
||||||
|
|||||||
@@ -125,6 +125,19 @@ ReplyInterpreter::Close()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
ReplyInterpreter::Commit()
|
||||||
|
{
|
||||||
|
status_t res = _OperationError(OpCommit);
|
||||||
|
if (res != B_OK)
|
||||||
|
return res;
|
||||||
|
|
||||||
|
fReply->Stream().GetOpaque(NULL);
|
||||||
|
|
||||||
|
return fReply->Stream().IsEOF() ? B_BAD_VALUE : B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
ReplyInterpreter::Create(uint64* before, uint64* after, bool& atomic)
|
ReplyInterpreter::Create(uint64* before, uint64* after, bool& atomic)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public:
|
|||||||
|
|
||||||
status_t Access(uint32* supported, uint32* allowed);
|
status_t Access(uint32* supported, uint32* allowed);
|
||||||
status_t Close();
|
status_t Close();
|
||||||
|
status_t Commit();
|
||||||
status_t Create(uint64* before, uint64* after, bool& atomic);
|
status_t Create(uint64* before, uint64* after, bool& atomic);
|
||||||
status_t GetAttr(AttrValue** attrs, uint32* count);
|
status_t GetAttr(AttrValue** attrs, uint32* count);
|
||||||
status_t GetFH(FileHandle* fh);
|
status_t GetFH(FileHandle* fh);
|
||||||
|
|||||||
@@ -89,6 +89,24 @@ RequestBuilder::Close(uint32 seq, const uint32* id, uint32 stateSeq)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
RequestBuilder::Commit(uint64 offset, uint32 count)
|
||||||
|
{
|
||||||
|
if (fProcedure != ProcCompound)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
if (fRequest == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
fRequest->Stream().AddUInt(OpCommit);
|
||||||
|
fRequest->Stream().AddUHyper(offset);
|
||||||
|
fRequest->Stream().AddUInt(count);
|
||||||
|
|
||||||
|
fOpCount++;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
RequestBuilder::Create(FileType type, const char* name, AttrValue* attr,
|
RequestBuilder::Create(FileType type, const char* name, AttrValue* attr,
|
||||||
uint32 count, const char* path)
|
uint32 count, const char* path)
|
||||||
@@ -729,7 +747,7 @@ RequestBuilder::Write(const uint32* id, uint32 stateSeq, const void* buffer,
|
|||||||
fRequest->Stream().AddUInt(id[1]);
|
fRequest->Stream().AddUInt(id[1]);
|
||||||
fRequest->Stream().AddUInt(id[2]);
|
fRequest->Stream().AddUInt(id[2]);
|
||||||
fRequest->Stream().AddUHyper(pos);
|
fRequest->Stream().AddUHyper(pos);
|
||||||
fRequest->Stream().AddInt(FILE_SYNC4);
|
fRequest->Stream().AddInt(UNSTABLE4);
|
||||||
fRequest->Stream().AddOpaque(buffer, len);
|
fRequest->Stream().AddOpaque(buffer, len);
|
||||||
|
|
||||||
fOpCount++;
|
fOpCount++;
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ public:
|
|||||||
status_t Access();
|
status_t Access();
|
||||||
status_t Close(uint32 seq, const uint32* id,
|
status_t Close(uint32 seq, const uint32* id,
|
||||||
uint32 stateSeq);
|
uint32 stateSeq);
|
||||||
|
status_t Commit(uint64 offset, uint32 count);
|
||||||
status_t Create(FileType type, const char* name,
|
status_t Create(FileType type, const char* name,
|
||||||
AttrValue* attr, uint32 count,
|
AttrValue* attr, uint32 count,
|
||||||
const char* path = NULL);
|
const char* path = NULL);
|
||||||
|
|||||||
@@ -472,6 +472,7 @@ nfs4_free_cookie(fs_volume* volume, fs_vnode* vnode, void* _cookie)
|
|||||||
|
|
||||||
OpenFileCookie* cookie = reinterpret_cast<OpenFileCookie*>(_cookie);
|
OpenFileCookie* cookie = reinterpret_cast<OpenFileCookie*>(_cookie);
|
||||||
file_cache_sync(inode->FileCache());
|
file_cache_sync(inode->FileCache());
|
||||||
|
inode->Commit();
|
||||||
inode->Close(cookie);
|
inode->Close(cookie);
|
||||||
delete cookie;
|
delete cookie;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user