nfs4: Do not sync too often if delegation is held
This commit is contained in:
@@ -20,20 +20,16 @@ Delegation::Delegation(const OpenDelegationData& data, Inode* inode,
|
|||||||
fData(data),
|
fData(data),
|
||||||
fInode(inode)
|
fInode(inode)
|
||||||
{
|
{
|
||||||
rw_lock_init(&fLock, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Delegation::~Delegation()
|
|
||||||
{
|
|
||||||
rw_lock_destroy(&fLock);
|
|
||||||
}
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
Delegation::GiveUp(bool truncate)
|
Delegation::GiveUp(bool truncate)
|
||||||
{
|
{
|
||||||
if (!truncate) {
|
if (!truncate) {
|
||||||
// save buffers
|
fInode->SyncAndCommit(true);
|
||||||
|
|
||||||
|
// TODO: claim locks
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnDelegation();
|
ReturnDelegation();
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ class Delegation : public NFS4Object,
|
|||||||
public:
|
public:
|
||||||
Delegation(const OpenDelegationData& data, Inode* inode,
|
Delegation(const OpenDelegationData& data, Inode* inode,
|
||||||
uint64 clientID);
|
uint64 clientID);
|
||||||
~Delegation();
|
|
||||||
|
|
||||||
// TODO: locks
|
// TODO: locks
|
||||||
|
|
||||||
@@ -38,8 +37,6 @@ private:
|
|||||||
uint64 fClientID;
|
uint64 fClientID;
|
||||||
OpenDelegationData fData;
|
OpenDelegationData fData;
|
||||||
Inode* fInode;
|
Inode* fInode;
|
||||||
|
|
||||||
rw_lock fLock;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -648,8 +648,7 @@ Inode::AcquireLock(OpenFileCookie* cookie, const struct flock* lock,
|
|||||||
status_t
|
status_t
|
||||||
Inode::ReleaseLock(OpenFileCookie* cookie, const struct flock* lock)
|
Inode::ReleaseLock(OpenFileCookie* cookie, const struct flock* lock)
|
||||||
{
|
{
|
||||||
file_cache_sync(fFileCache);
|
SyncAndCommit();
|
||||||
Commit();
|
|
||||||
|
|
||||||
LockInfo* prev = NULL;
|
LockInfo* prev = NULL;
|
||||||
|
|
||||||
@@ -699,8 +698,7 @@ Inode::ReleaseLock(OpenFileCookie* cookie, const struct flock* lock)
|
|||||||
status_t
|
status_t
|
||||||
Inode::ReleaseAllLocks(OpenFileCookie* cookie)
|
Inode::ReleaseAllLocks(OpenFileCookie* cookie)
|
||||||
{
|
{
|
||||||
file_cache_sync(fFileCache);
|
SyncAndCommit();
|
||||||
Commit();
|
|
||||||
|
|
||||||
OpenState* state = cookie->fOpenState;
|
OpenState* state = cookie->fOpenState;
|
||||||
MutexLocker _(state->fLocksLock);
|
MutexLocker _(state->fLocksLock);
|
||||||
@@ -790,3 +788,14 @@ Inode::RecallDelegation(bool truncate)
|
|||||||
fDelegation = NULL;
|
fDelegation = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
Inode::SyncAndCommit(bool force)
|
||||||
|
{
|
||||||
|
if (!force && fDelegation != NULL)
|
||||||
|
return B_OK;
|
||||||
|
|
||||||
|
file_cache_sync(fFileCache);
|
||||||
|
return Commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ public:
|
|||||||
status_t Access(int mode);
|
status_t Access(int mode);
|
||||||
|
|
||||||
status_t Commit();
|
status_t Commit();
|
||||||
|
status_t SyncAndCommit(bool force = false);
|
||||||
|
|
||||||
status_t CreateObject(const char* name, const char* path,
|
status_t CreateObject(const char* name, const char* path,
|
||||||
int mode, FileType type);
|
int mode, FileType type);
|
||||||
|
|||||||
@@ -146,8 +146,7 @@ Inode::Open(int mode, OpenFileCookie* cookie)
|
|||||||
status_t
|
status_t
|
||||||
Inode::Close(OpenFileCookie* cookie)
|
Inode::Close(OpenFileCookie* cookie)
|
||||||
{
|
{
|
||||||
file_cache_sync(fFileCache);
|
SyncAndCommit();
|
||||||
Commit();
|
|
||||||
|
|
||||||
MutexLocker _(fStateLock);
|
MutexLocker _(fStateLock);
|
||||||
if (cookie->fOpenState != NULL) {
|
if (cookie->fOpenState != NULL) {
|
||||||
|
|||||||
@@ -308,11 +308,7 @@ static status_t
|
|||||||
nfs4_fsync(fs_volume* volume, fs_vnode* vnode)
|
nfs4_fsync(fs_volume* volume, fs_vnode* vnode)
|
||||||
{
|
{
|
||||||
Inode* inode = reinterpret_cast<Inode*>(vnode->private_node);
|
Inode* inode = reinterpret_cast<Inode*>(vnode->private_node);
|
||||||
status_t result = file_cache_sync(inode->FileCache());
|
return inode->SyncAndCommit();
|
||||||
if (result != B_OK)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
return inode->Commit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user