nfs4: Do not sync too often if delegation is held

This commit is contained in:
Pawel Dziepak
2012-08-06 03:25:02 +02:00
parent bfa20379a3
commit e2e5f06d6e
6 changed files with 19 additions and 21 deletions
@@ -20,20 +20,16 @@ Delegation::Delegation(const OpenDelegationData& data, Inode* inode,
fData(data),
fInode(inode)
{
rw_lock_init(&fLock, NULL);
}
Delegation::~Delegation()
{
rw_lock_destroy(&fLock);
}
status_t
Delegation::GiveUp(bool truncate)
{
if (!truncate) {
// save buffers
fInode->SyncAndCommit(true);
// TODO: claim locks
}
ReturnDelegation();
@@ -22,7 +22,6 @@ class Delegation : public NFS4Object,
public:
Delegation(const OpenDelegationData& data, Inode* inode,
uint64 clientID);
~Delegation();
// TODO: locks
@@ -38,8 +37,6 @@ private:
uint64 fClientID;
OpenDelegationData fData;
Inode* fInode;
rw_lock fLock;
};
+13 -4
View File
@@ -648,8 +648,7 @@ Inode::AcquireLock(OpenFileCookie* cookie, const struct flock* lock,
status_t
Inode::ReleaseLock(OpenFileCookie* cookie, const struct flock* lock)
{
file_cache_sync(fFileCache);
Commit();
SyncAndCommit();
LockInfo* prev = NULL;
@@ -699,8 +698,7 @@ Inode::ReleaseLock(OpenFileCookie* cookie, const struct flock* lock)
status_t
Inode::ReleaseAllLocks(OpenFileCookie* cookie)
{
file_cache_sync(fFileCache);
Commit();
SyncAndCommit();
OpenState* state = cookie->fOpenState;
MutexLocker _(state->fLocksLock);
@@ -790,3 +788,14 @@ Inode::RecallDelegation(bool truncate)
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 Commit();
status_t SyncAndCommit(bool force = false);
status_t CreateObject(const char* name, const char* path,
int mode, FileType type);
@@ -146,8 +146,7 @@ Inode::Open(int mode, OpenFileCookie* cookie)
status_t
Inode::Close(OpenFileCookie* cookie)
{
file_cache_sync(fFileCache);
Commit();
SyncAndCommit();
MutexLocker _(fStateLock);
if (cookie->fOpenState != NULL) {
@@ -308,11 +308,7 @@ static status_t
nfs4_fsync(fs_volume* volume, fs_vnode* vnode)
{
Inode* inode = reinterpret_cast<Inode*>(vnode->private_node);
status_t result = file_cache_sync(inode->FileCache());
if (result != B_OK)
return result;
return inode->Commit();
return inode->SyncAndCommit();
}