deleg: support for CB_GETATTR

on CB_GETATTR, search for a delegation with the given filehandle.  if found, use its fileid to get its cached attributes.  when encoding the response, only include change and size attributes

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2011-08-30 12:53:26 -04:00 committed by unknown
parent 0184804498
commit 5880a8bb1d
6 changed files with 116 additions and 8 deletions

View file

@ -26,6 +26,7 @@
#include "delegation.h"
#include "nfs41_ops.h"
#include "name_cache.h"
#include "util.h"
#include "daemon_debug.h"
@ -725,6 +726,49 @@ out_deleg:
}
int nfs41_delegation_getattr(
IN nfs41_client *client,
IN const nfs41_fh *fh,
IN const bitmap4 *attr_request,
OUT nfs41_file_info *info)
{
nfs41_delegation_state *deleg;
uint64_t fileid;
int status;
dprintf(2, "--> nfs41_delegation_getattr()\n");
/* search for a delegation on this file handle */
status = delegation_find(client, fh, deleg_fh_cmp, &deleg);
if (status)
goto out;
AcquireSRWLockShared(&deleg->lock);
fileid = deleg->file.fh.fileid;
if (deleg->status != DELEGATION_GRANTED ||
deleg->state.type != OPEN_DELEGATE_WRITE) {
status = NFS4ERR_BADHANDLE;
}
ReleaseSRWLockShared(&deleg->lock);
if (status)
goto out;
ZeroMemory(&info, sizeof(nfs41_file_info));
/* find attributes for the given fileid */
status = nfs41_attr_cache_lookup(
client_name_cache(client), fileid, info);
if (status) {
status = NFS4ERR_BADHANDLE;
goto out;
}
out:
dprintf(DGLVL, "<-- nfs41_delegation_getattr() returning %s\n",
nfs_error_string(status));
return status;
}
void nfs41_client_delegation_free(
IN nfs41_client *client)
{