From 9135e07221121806c3ad38f98ffaad69d85c7305 Mon Sep 17 00:00:00 2001 From: Olga Kornievskaia Date: Mon, 2 Apr 2012 18:41:37 -0400 Subject: [PATCH] only send setattr if attr changed for hidden, system, and archive, first check with our cached attributes and if the values are the same, ignore this setattr --- daemon/open.c | 2 +- daemon/setattr.c | 23 +++++++++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/daemon/open.c b/daemon/open.c index 7c772dd..2253b8f 100644 --- a/daemon/open.c +++ b/daemon/open.c @@ -584,7 +584,7 @@ static int handle_open(nfs41_upcall *upcall) args->mode = info.mode; args->changeattr = info.change; } else { - nfs41_file_info createattrs; + nfs41_file_info createattrs = { 0 }; uint32_t create = 0, createhowmode = 0, lookup_status = status; if (!lookup_status && (args->disposition == FILE_OVERWRITE || diff --git a/daemon/setattr.c b/daemon/setattr.c index ca655bd..7ab950f 100644 --- a/daemon/setattr.c +++ b/daemon/setattr.c @@ -61,16 +61,27 @@ static int handle_nfs41_setattr(setattr_upcall_args *args) nfs41_open_state *state = args->state; nfs41_superblock *superblock = state->file.fh.superblock; stateid_arg stateid; - nfs41_file_info info = { 0 }; - int status = NO_ERROR; + nfs41_file_info info = { 0 }, old_info = { 0 }; + int status = NO_ERROR, getattr_status; - /* hidden */ info.hidden = basic_info->FileAttributes & FILE_ATTRIBUTE_HIDDEN ? 1 : 0; info.system = basic_info->FileAttributes & FILE_ATTRIBUTE_SYSTEM ? 1 : 0; info.archive = basic_info->FileAttributes & FILE_ATTRIBUTE_ARCHIVE ? 1 : 0; - info.attrmask.arr[0] |= FATTR4_WORD0_HIDDEN | FATTR4_WORD0_ARCHIVE; - info.attrmask.arr[1] = FATTR4_WORD1_SYSTEM; - info.attrmask.count = 2; + getattr_status = nfs41_attr_cache_lookup(session_name_cache(state->session), + state->file.fh.fileid, &old_info); + + if (getattr_status || info.hidden != old_info.hidden) { + info.attrmask.arr[0] = FATTR4_WORD0_HIDDEN; + info.attrmask.count = 1; + } + if (getattr_status || info.archive != old_info.archive) { + info.attrmask.arr[0] |= FATTR4_WORD0_ARCHIVE; + info.attrmask.count = 1; + } + if (getattr_status || info.system != old_info.system) { + info.attrmask.arr[1] = FATTR4_WORD1_SYSTEM; + info.attrmask.count = 2; + } if (superblock->cansettime) { /* set the time_delta so xdr_settime4() can decide