From 0c2148da5b613455c6ee762b03c9a1beb14cae5f Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 25 Feb 2011 11:44:41 -0800 Subject: [PATCH] pnfs: support for mdsthreshold attribute hacked up and tested against bluearc server Signed-off-by: Casey Bodley --- daemon/nfs41_types.h | 20 +++++++++++++++++ daemon/nfs41_xdr.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/daemon/nfs41_types.h b/daemon/nfs41_types.h index 50a3487..0072503 100644 --- a/daemon/nfs41_types.h +++ b/daemon/nfs41_types.h @@ -161,8 +161,28 @@ typedef struct __fs_locations4 { uint32_t location_count; } fs_locations4; +enum { + MDSTHRESH_READ = 0, + MDSTHRESH_WRITE, + MDSTHRESH_READ_IO, + MDSTHRESH_WRITE_IO, + + MAX_MDSTHRESH_HINTS +}; +typedef struct __threshold_item4 { + uint32_t type; + uint64_t hints[MAX_MDSTHRESH_HINTS]; +} threshold_item4; + +#define MAX_MDSTHRESHOLD_ITEMS 1 +typedef struct __mdsthreshold4 { + uint32_t count; + threshold_item4 items[MAX_MDSTHRESHOLD_ITEMS]; +} mdsthreshold4; + typedef struct __nfs41_file_info { nfs41_fsid fsid; + mdsthreshold4 mdsthreshold; nfstime4 time_access; nfstime4 time_create; nfstime4 time_modify; diff --git a/daemon/nfs41_xdr.c b/daemon/nfs41_xdr.c index 43bdb89..838b577 100644 --- a/daemon/nfs41_xdr.c +++ b/daemon/nfs41_xdr.c @@ -247,6 +247,52 @@ static bool_t xdr_layout_types( return TRUE; } +static bool_t xdr_threshold_item( + XDR *xdr, + threshold_item4 *item) +{ + bitmap4 bitmap; + + if (!xdr_u_int32_t(xdr, &item->type)) + return FALSE; + + if (!xdr_bitmap4(xdr, &bitmap)) + return FALSE; + + if (!xdr_u_int32_t(xdr, &bitmap.count)) + return FALSE; + + if (bitmap.count) { + if (bitmap.arr[0] & 0x1 && !xdr_u_hyper(xdr, &item->hints[0])) + return FALSE; + if (bitmap.arr[0] & 0x2 && !xdr_u_hyper(xdr, &item->hints[1])) + return FALSE; + if (bitmap.arr[0] & 0x4 && !xdr_u_hyper(xdr, &item->hints[2])) + return FALSE; + if (bitmap.arr[0] & 0x8 && !xdr_u_hyper(xdr, &item->hints[3])) + return FALSE; + } + return TRUE; +} + +static bool_t xdr_mdsthreshold( + XDR *xdr, + mdsthreshold4 *mdsthreshold) +{ + uint32_t i; + + if (!xdr_u_int32_t(xdr, &mdsthreshold->count)) + return FALSE; + + if (mdsthreshold->count > MAX_MDSTHRESHOLD_ITEMS) + return FALSE; + + for (i = 0; i < mdsthreshold->count; i++) + if (!xdr_threshold_item(xdr, &mdsthreshold->items[i])) + return FALSE; + return TRUE; +} + /* pathname4 * decode a variable array of components into a nfs41_abs_path */ static bool_t decode_pathname4( @@ -1652,6 +1698,12 @@ static bool_t decode_file_attrs( return FALSE; } } + if (attrs->attrmask.count >= 3) { + if (attrs->attrmask.arr[2] & FATTR4_WORD2_MDSTHRESHOLD) { + if (!xdr_mdsthreshold(xdr, &info->mdsthreshold)) + return FALSE; + } + } return TRUE; }