39#define state_entry(pos) list_container(pos, pnfs_layout_state, entry)
40#define layout_entry(pos) list_container(pos, pnfs_layout, entry)
41#define file_layout_entry(pos) list_container(pos, pnfs_file_layout, layout.entry)
109 return diff ? diff :
memcmp(layout_fh->
fh, meta_fh->
fh, meta_fh->
len);
128 if (layouts ==
NULL) {
134 *layouts_out = layouts;
178 "returning new layout %p\n",
layout);
187 "returning existing layout %p\n", *layout_out);
231 if (
layout->layout.length == 0 ||
246 const uint32_t diff = rhs->count - lhs->count;
247 return diff ? diff :
memcmp(rhs->arr, lhs->arr,
263 if (to_max < from->
layout.offset || from_max < to->
layout.offset)
267 if (to->layout.iomode !=
from->layout.iomode ||
268 to->layout.type !=
from->layout.type ||
271 to->pattern_offset !=
from->pattern_offset ||
272 to->first_index !=
from->first_index ||
273 to->util !=
from->util)
276 dprintf(
FLLVL,
"merging layout range {%llu, %llu} with {%llu, %llu}\n",
277 to->layout.offset, to->layout.length,
278 from->layout.offset,
from->layout.length);
281 to->layout.offset =
min(to->layout.offset,
from->layout.offset);
282 to->layout.length =
max(to_max, from_max) - to->layout.offset;
380 if (
state->stateid.seqid == 0) {
383 }
else if (
memcmp(&
state->stateid.other, stateid->other,
386 state->stateid.seqid = stateid->seqid;
402 eprintf(
"LAYOUTGET didn't return any file layouts\n");
408 eprintf(
"LAYOUTGET returned a new stateid when we already had one\n");
412 if (!
state->return_on_close)
413 state->return_on_close = layoutget_res->return_on_close;
469 dprintf(
FLLVL,
"<-- file_layout_fetch() returning %s\n",
491 if (
layout->iomode >= iomode &&
492 layout->offset <= position &&
500 *offset_missing = position;
524 while (
state->pending)
529 if (
state->stateid.seqid) {
532 stateid = &layout_stateid;
557 OUT unsigned char *deviceid)
577 IN const unsigned char *deviceid,
599 IN unsigned char *deviceid)
645 *layout_out =
state->layout;
648 "cached layout %p\n", *layout_out);
687 dprintf(
FLLVL,
"pnfs_layout_state_open() caching layout %p "
688 "(%u opens)\n",
state->layout, open_count);
700 dprintf(
FLLVL,
"<-- pnfs_layout_state_open() returning %s\n",
787 while (
state->pending)
795 memcpy(&stateid, &
state->stateid,
sizeof(stateid));
804 eprintf(
"pnfs_rpc_layoutreturn() failed with %s\n",
825 dprintf(
FLLVL,
"<-- file_layout_return() returning %s\n",
849 return_layout =
layout->return_on_close && (open_count <= 0);
855 eprintf(
"file_layout_return() failed with %s\n",
872#define recall_entry(pos) list_container(pos, struct layout_recall, layout.entry)
878 return layout->type == recall->type
879 &&
layout->offset <= (recall->offset + recall->length)
882 layout->iomode == recall->iomode);
905 memcpy(
layout->filehandles.arr, existing->filehandles.arr,
928 if (recall->offset >
layout->layout.offset) {
930 layout->layout.length = recall->offset -
layout->layout.offset;
932 if (layout_end > recall->offset + recall->length) {
940 layout->layout.offset = recall->offset + recall->length;
941 layout->layout.length = layout_end -
layout->layout.offset;
947 if (layout_end <= recall->
offset + recall->length) {
953 layout->layout.offset = recall->offset + recall->length;
954 layout->layout.length = layout_end -
layout->layout.offset;
981 lrc->layout.offset = recall->recall.args.file.offset;
982 lrc->layout.length = recall->recall.args.file.length;
984 lrc->layout.offset = 0;
987 lrc->layout.iomode = recall->iomode;
989 lrc->changed = recall->changed;
1013 dprintf(
FLLVL,
"merging recalled range {%llu, %llu} with {%llu, %llu}\n",
1036 const stateid4 *stateid = &recall->recall.args.file.stateid;
1042 if (
state->stateid.seqid == 0) {
1050 if (stateid->
seqid >
state->stateid.seqid + 1) {
1062 if (
state->io_count) {
1102 dprintf(
FLLVL,
"<-- file_layout_recall_file() returning %s\n",
1111 return lhs->major == rhs->major && lhs->minor == rhs->minor;
1123 dprintf(
FLLVL,
"--> file_layout_recall_fsid(%llu, %llu)\n",
1124 recall->recall.args.fsid.major, recall->recall.args.fsid.minor);
1132 fh = &
state->meta_fh;
1142 dprintf(
FLLVL,
"<-- file_layout_recall_fsid() returning %s\n",
1166 dprintf(
FLLVL,
"<-- file_layout_recall_all() returning %s\n",
1177 dprintf(
FLLVL,
"--> pnfs_file_layout_recall(%u, %s, %u)\n",
1188 switch (recall->recall.type) {
1200 dprintf(
FLLVL,
"invalid return type %u!\n", recall->recall);
1205 dprintf(
FLLVL,
"<-- pnfs_file_layout_recall() returning %s\n",
1263 dprintf(
FLLVL,
"pnfs_layout_io_start(): count -> %u\n",
1274 dprintf(
FLLVL,
"pnfs_layout_io_finished() count -> %u\n",
1277 if (
state->io_count > 0)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
#define InterlockedIncrement
#define InterlockedDecrement
static void list_remove(struct list_entry *entry)
#define list_for_each(entry, head)
#define list_for_each_tmp(entry, tmp, head)
static int list_empty(struct list_entry *head)
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
static void list_add_head(struct list_entry *head, struct list_entry *entry)
static void list_add(struct list_entry *entry, struct list_entry *prev, struct list_entry *next)
static struct list_entry * list_search(const struct list_entry *head, const void *value, list_compare_fn compare)
static void list_init(struct list_entry *head)
void fh_copy(OUT nfs41_fh *dst, IN const nfs41_fh *src)
void eprintf(LPCSTR format,...)
const char * nfs_error_string(int status)
const char * pnfs_iomode_string(enum pnfs_iomode iomode)
void dprint_layout(int level, const struct __pnfs_file_layout *layout)
const char * pnfs_layout_type_string(enum pnfs_layout_type type)
const char * pnfs_error_string(enum pnfs_status status)
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
VOID WINAPI InitializeSRWLock(PSRWLOCK Lock)
BOOL WINAPI SleepConditionVariableSRW(PCONDITION_VARIABLE ConditionVariable, PSRWLOCK Lock, DWORD Timeout, ULONG Flags)
VOID WINAPI InitializeConditionVariable(PCONDITION_VARIABLE ConditionVariable)
VOID WINAPI WakeConditionVariable(PCONDITION_VARIABLE ConditionVariable)
GLuint GLuint GLsizei GLenum type
GLuint GLsizei GLsizei * length
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
double __cdecl remainder(double, double)
#define memcpy(s1, s2, n)
#define NFS4_STATEID_OTHER
@ NFS4ERR_UNKNOWN_LAYOUTTYPE
@ NFS4ERR_LAYOUTUNAVAILABLE
enum nfsstat4 pnfs_rpc_layoutget(IN nfs41_session *session, IN nfs41_path_fh *file, IN stateid_arg *stateid, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t minlength, IN uint64_t length, OUT pnfs_layoutget_res_ok *layoutget_res_ok)
enum nfsstat4 pnfs_rpc_layoutreturn(IN nfs41_session *session, IN nfs41_path_fh *file, IN enum pnfs_layout_type type, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t length, IN stateid4 *stateid, OUT pnfs_layoutreturn_res *layoutreturn_res)
@ EXCHGID4_FLAG_USE_PNFS_MDS
static const uint64_t NFS4_UINT64_MAX
__inline uint32_t layout_unit_size(IN const pnfs_file_layout *layout)
enum pnfs_status pnfs_file_device_get(IN struct __nfs41_session *session, IN struct pnfs_file_device_list *devices, IN unsigned char *deviceid, OUT pnfs_file_device **device_out)
#define PNFS_DEVICEID_SIZE
@ PNFSERR_LAYOUT_RECALLED
void pnfs_file_device_put(IN pnfs_file_device *device)
@ PNFS_LAYOUT_UNAVAILABLE
void pnfs_file_device_list_invalidate(IN struct pnfs_file_device_list *devices)
static enum pnfs_status layout_update(IN OUT pnfs_layout_state *state, IN const pnfs_layoutget_res_ok *layoutget_res)
void pnfs_layout_io_finished(IN pnfs_layout_state *state)
enum pnfs_status pnfs_layout_state_prepare(IN pnfs_layout_state *state, IN nfs41_session *session, IN nfs41_path_fh *meta_file, IN stateid_arg *stateid, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t length)
static void device_assign(IN pnfs_layout_state *state, IN const unsigned char *deviceid, IN pnfs_file_device *device)
static enum pnfs_status layout_state_find_or_create(IN struct pnfs_layout_list *layouts, IN const nfs41_fh *meta_fh, OUT pnfs_layout_state **layout_out)
static void layout_recall_range(IN pnfs_layout_state *state, IN const pnfs_layout *recall)
static enum pnfs_status file_layout_fetch(IN OUT pnfs_layout_state *state, IN nfs41_session *session, IN nfs41_path_fh *meta_file, IN stateid_arg *stateid, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t minlength, IN uint64_t length)
static enum pnfs_status device_status(IN pnfs_layout_state *state, IN uint64_t offset, IN uint64_t length, OUT unsigned char *deviceid)
void pnfs_layout_io_start(IN pnfs_layout_state *state)
static enum pnfs_status file_layout_recall_file(IN nfs41_client *client, IN const struct cb_layoutrecall_args *recall)
static enum pnfs_status client_supports_pnfs(IN nfs41_client *client)
static pnfs_file_layout * layout_allocate_copy(IN const pnfs_file_layout *existing)
enum pnfs_status pnfs_layout_list_create(OUT struct pnfs_layout_list **layouts_out)
static void layout_state_free(IN pnfs_layout_state *state)
static uint64_t range_max(IN const pnfs_layout *layout)
static void layout_recall_entry_init(OUT struct layout_recall *lrc, IN const struct cb_layoutrecall_args *recall)
static enum pnfs_status layout_update_range(IN OUT pnfs_layout_state *state, IN const struct list_entry *layouts)
static enum pnfs_status layout_update_stateid(IN OUT pnfs_layout_state *state, IN const stateid4 *stateid)
static enum pnfs_status layout_recall_merge(IN struct list_entry *list, IN pnfs_layout *from)
void pnfs_layout_recall_fenced(IN pnfs_layout_state *state, IN const pnfs_layout *layout)
static bool_t layout_sanity_check(IN pnfs_file_layout *layout)
static enum pnfs_status file_layout_return(IN nfs41_session *session, IN nfs41_path_fh *file, IN pnfs_layout_state *state)
static bool_t fsid_matches(IN const nfs41_fsid *lhs, IN const nfs41_fsid *rhs)
#define layout_entry(pos)
void pnfs_layout_state_close(IN nfs41_session *session, IN nfs41_open_state *state, IN bool_t remove)
void pnfs_layout_list_free(IN struct pnfs_layout_list *layouts)
static enum pnfs_status layout_state_merge(IN pnfs_layout_state *state, IN pnfs_file_layout *from)
static enum pnfs_status layout_return_status(IN const pnfs_layout_state *state)
static enum pnfs_status layout_entry_find(IN struct pnfs_layout_list *layouts, IN const nfs41_fh *meta_fh, OUT struct list_entry **entry_out)
static enum pnfs_status layout_coverage_status(IN pnfs_layout_state *state, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t length, OUT uint64_t *offset_missing)
static void layout_ordered_insert(IN pnfs_layout_state *state, IN pnfs_layout *layout)
static void layout_state_free_layouts(IN pnfs_layout_state *state)
static int layout_entry_compare(IN const struct list_entry *entry, IN const void *value)
static enum pnfs_status file_layout_recall_all(IN nfs41_client *client, IN const struct cb_layoutrecall_args *recall)
static void file_layout_free(IN pnfs_file_layout *layout)
static void layout_state_free_recalls(IN pnfs_layout_state *state)
static enum pnfs_status open_state_layout_cached(IN nfs41_open_state *state, OUT pnfs_layout_state **layout_out)
static bool_t layout_recall_compatible(IN const pnfs_layout *layout, IN const pnfs_layout *recall)
static enum pnfs_status layout_fetch(IN pnfs_layout_state *state, IN nfs41_session *session, IN nfs41_path_fh *meta_file, IN stateid_arg *stateid, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t length)
static enum pnfs_status file_layout_recall(IN pnfs_layout_state *state, IN const struct cb_layoutrecall_args *recall)
enum pnfs_status pnfs_file_layout_recall(IN nfs41_client *client, IN const struct cb_layoutrecall_args *recall)
static enum pnfs_status device_fetch(IN pnfs_layout_state *state, IN nfs41_session *session, IN unsigned char *deviceid)
#define file_layout_entry(pos)
enum pnfs_status pnfs_layout_recall_status(IN const pnfs_layout_state *state, IN const pnfs_layout *layout)
static enum pnfs_status file_layout_recall_fsid(IN nfs41_client *client, IN const struct cb_layoutrecall_args *recall)
static enum pnfs_status layout_state_create(IN const nfs41_fh *meta_fh, OUT pnfs_layout_state **layout_out)
enum pnfs_status pnfs_layout_state_open(IN nfs41_open_state *state, OUT pnfs_layout_state **layout_out)
static bool_t layout_merge_segments(IN pnfs_file_layout *to, IN pnfs_file_layout *from)
static enum pnfs_status fs_supports_layout(IN const nfs41_superblock *superblock, IN enum pnfs_layout_type type)
static int layout_filehandles_cmp(IN const pnfs_file_layout_handles *lhs, IN const pnfs_file_layout_handles *rhs)
#define recall_entry(pos)
static enum pnfs_status layout_state_find_and_delete(IN struct pnfs_layout_list *layouts, IN const nfs41_fh *meta_fh)
static void layout_state_deferred_recalls(IN pnfs_layout_state *state)
struct __nfs41_superblock * superblock
unsigned char fh[NFS4_FHSIZE]
enum pnfs_layout_type type
struct list_entry layouts
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)