volume: cache volume attributes on mount

struct NFS41_V_NET_ROOT_EXTENSION now stores only the FILE_FS_ATTRIBUTE_INFORMATION (without the extra buffer space for a name).  on QueryVolumeInfo() for FileFsAttributeInformation on the root directory, the FILE_FS_ATTRIBUTE_INFORMATION is copied into the output buffer, and the name is added there.  QueryVolumeInfo() only makes upcalls when FileFsAttributeInformation queries are not for the root directory

new function is_root_directory() uses the logic from Set/GetReparsePoint() to determine whether it's operating on the root directory

moved logic from volume.c:handle_volume_attributes() to superblock.c:nfs41_superblock_fs_attributes().  the mount downcall copies the FILE_FS_ATTRIBUTE_INFORMATION buffer down to the driver.  the driver reads this buffer directly into VNetRootContext->FsAttrs

Signed-off-by: Casey Bodley <cbodley@citi.umich.edu>
This commit is contained in:
Casey Bodley 2012-04-10 12:05:43 -04:00 committed by unknown
parent 4c8c263b49
commit 2baeeb855b
6 changed files with 94 additions and 78 deletions

View file

@ -61,6 +61,7 @@ static int handle_mount(nfs41_upcall *upcall)
multi_addr4 addrs;
nfs41_root *root;
nfs41_client *client;
nfs41_path_fh file;
// resolve hostname,port
status = nfs41_server_resolve(args->hostname, 2049, &addrs);
@ -95,13 +96,15 @@ static int handle_mount(nfs41_upcall *upcall)
// look up the mount path, and fail if it doesn't exist
status = nfs41_lookup(root, client->session,
&path, NULL, NULL, NULL, NULL);
&path, NULL, &file, NULL, NULL);
if (status) {
eprintf("nfs41_lookup('%s') failed with %d\n", path.path, status);
status = ERROR_BAD_NETPATH;
goto out_err;
}
nfs41_superblock_fs_attributes(file.fh.superblock, &args->FsAttrs);
upcall->root_ref = root;
nfs41_root_ref(upcall->root_ref);
args->lease_time = client->session->lease_time;
@ -124,6 +127,8 @@ static int marshall_mount(unsigned char *buffer, uint32_t *length, nfs41_upcall
status = safe_write(&buffer, length, &NFS41D_VERSION, sizeof(DWORD));
if (status) goto out;
status = safe_write(&buffer, length, &args->lease_time, sizeof(DWORD));
if (status) goto out;
status = safe_write(&buffer, length, &args->FsAttrs, sizeof(args->FsAttrs));
out:
return status;
}

View file

@ -443,6 +443,11 @@ static __inline void nfs41_superblock_supported_attrs_exclcreat(
bitmap_intersect(attrs, &superblock->suppattr_exclcreat);
}
struct _FILE_FS_ATTRIBUTE_INFORMATION;
void nfs41_superblock_fs_attributes(
IN const nfs41_superblock *superblock,
OUT struct _FILE_FS_ATTRIBUTE_INFORMATION *FsAttrs);
void nfs41_superblock_space_changed(
IN nfs41_superblock *superblock);

View file

@ -25,6 +25,7 @@
#include "daemon_debug.h"
#include "nfs41.h"
#include "nfs41_ops.h"
#include "from_kernel.h"
#include "util.h"
@ -160,6 +161,35 @@ out:
return status;
}
void nfs41_superblock_fs_attributes(
IN const nfs41_superblock *superblock,
OUT PFILE_FS_ATTRIBUTE_INFORMATION FsAttrs)
{
FsAttrs->FileSystemAttributes = FILE_SUPPORTS_REMOTE_STORAGE;
if (superblock->link_support)
FsAttrs->FileSystemAttributes |= FILE_SUPPORTS_HARD_LINKS;
if (superblock->symlink_support)
FsAttrs->FileSystemAttributes |= FILE_SUPPORTS_REPARSE_POINTS;
if (superblock->ea_support)
FsAttrs->FileSystemAttributes |= FILE_SUPPORTS_EXTENDED_ATTRIBUTES;
if (superblock->case_preserving)
FsAttrs->FileSystemAttributes |= FILE_CASE_PRESERVED_NAMES;
if (!superblock->case_insensitive)
FsAttrs->FileSystemAttributes |= FILE_CASE_SENSITIVE_SEARCH;
if (superblock->aclsupport)
FsAttrs->FileSystemAttributes |= FILE_PERSISTENT_ACLS;
FsAttrs->MaximumComponentNameLength = NFS41_MAX_COMPONENT_LEN;
/* let the driver fill in FileSystemName */
FsAttrs->FileSystemNameLength = 0;
dprintf(SBLVL, "FileFsAttributeInformation: case_preserving %u, "
"case_insensitive %u, max component %u\n",
superblock->case_preserving, superblock->case_insensitive,
FsAttrs->MaximumComponentNameLength);
}
/* nfs41_superblock_list */
#define superblock_entry(pos) list_container(pos, nfs41_superblock, entry)

View file

@ -35,6 +35,7 @@ typedef struct __mount_upcall_args {
DWORD rsize;
DWORD wsize;
DWORD lease_time;
FILE_FS_ATTRIBUTE_INFORMATION FsAttrs;
} mount_upcall_args;
typedef struct __open_upcall_args {

View file

@ -112,39 +112,6 @@ out:
return status;
}
static void handle_volume_attributes(
IN volume_upcall_args *args,
IN nfs41_open_state *state)
{
PFILE_FS_ATTRIBUTE_INFORMATION attr = &args->info.attribute;
const nfs41_superblock *superblock = state->file.fh.superblock;
attr->FileSystemAttributes = FILE_SUPPORTS_REMOTE_STORAGE;
if (superblock->link_support)
attr->FileSystemAttributes |= FILE_SUPPORTS_HARD_LINKS;
if (superblock->symlink_support)
attr->FileSystemAttributes |= FILE_SUPPORTS_REPARSE_POINTS;
if (superblock->ea_support)
attr->FileSystemAttributes |= FILE_SUPPORTS_EXTENDED_ATTRIBUTES;
if (superblock->case_preserving)
attr->FileSystemAttributes |= FILE_CASE_PRESERVED_NAMES;
if (!superblock->case_insensitive)
attr->FileSystemAttributes |= FILE_CASE_SENSITIVE_SEARCH;
if (superblock->aclsupport)
attr->FileSystemAttributes |= FILE_PERSISTENT_ACLS;
attr->MaximumComponentNameLength = NFS41_MAX_COMPONENT_LEN;
/* let the driver fill in FileSystemName/Len */
args->len = sizeof(args->info.attribute);
dprintf(2, "FileFsAttributeInformation: case_preserving %u, "
"case_insensitive %u, max component %u\n",
superblock->case_preserving, superblock->case_insensitive,
attr->MaximumComponentNameLength);
}
static int handle_volume(nfs41_upcall *upcall)
{
volume_upcall_args *args = &upcall->args.volume;
@ -176,7 +143,8 @@ static int handle_volume(nfs41_upcall *upcall)
break;
case FileFsAttributeInformation:
handle_volume_attributes(args, upcall->state_ref);
nfs41_superblock_fs_attributes(upcall->state_ref->file.fh.superblock,
&args->info.attribute);
break;
default: