32#define file_layout_entry(pos) list_container(pos, pnfs_file_layout, layout.entry)
88 if (filehandle_count == server_count) {
90 *file_out = &
layout->filehandles.arr[serverid];
91 }
else if (filehandle_count == 1) {
92 *file_out = &
layout->filehandles.arr[0];
93 }
else if (filehandle_count == 0) {
94 *file_out = meta_file;
96 eprintf(
"invalid sparse layout! has %u file handles "
97 "and %u servers\n", filehandle_count, server_count);
115 if (filehandle_count == stripe_count) {
116 *file_out = &
layout->filehandles.arr[stripeid];
118 eprintf(
"invalid dense layout! has %u file handles "
119 "and %u stripes\n", filehandle_count, stripe_count);
130 return layout->iomode >= iomode
131 &&
layout->offset <= position
153 position =
layout->layout.offset +
layout->layout.length;
194 for (
s = 0;
s <
layout->device->stripes.count;
s++) {
211 position =
layout->layout.offset +
layout->layout.length;
250 pattern->meta_file = meta_file;
256 pattern->default_lease = default_lease;
306 if (
io->offset < *position)
307 io->offset = *position;
309 *position =
io->offset;
312 if (
io->length > offset_end)
313 io->length = offset_end;
315 if (
io->offset >=
io->length)
318 io->length -=
io->offset;
362 if (serverid >=
device->servers.count)
365 *server_out = &
device->servers.arr[serverid];
452 lowest_offset =
min(lowest_offset,
pattern->threads[
i].offset);
453 if (stable) *stable =
min(*stable,
pattern->threads[
i].stable);
455 return lowest_offset -
pattern->offset_start;
495 uint32_t maxreadsize, bytes_read, total_read;
505 eprintf(
"thread_data_server() failed with %s\n",
513 eprintf(
"pnfs_data_server_client() failed with %s\n",
524 if (
io.length > maxreadsize)
525 io.length = maxreadsize;
530 eprintf(
"nfs41_read() failed with %s\n",
536 total_read += bytes_read;
537 thread->offset += bytes_read;
540 dprintf(
IOLVL,
"read thread %u reached eof: offset %llu\n",
547 dprintf(
IOLVL,
"<-- file_layout_read_thread(%u) returning %s\n",
562 uint32_t maxwritesize, bytes_written, total_written;
571 eprintf(
"thread_data_server() failed with %s\n",
579 eprintf(
"pnfs_data_server_client() failed with %s\n",
590 thread->offset = offset_start;
597 if (
io.length > maxwritesize)
598 io.length = maxwritesize;
604 eprintf(
"nfs41_write() failed with %s\n",
612 total_written += bytes_written;
613 thread->offset += bytes_written;
616 if (commit_min >
io.offset)
617 commit_min =
io.offset;
618 if (commit_max <
io.offset +
io.length)
619 commit_max =
io.offset +
io.length;
623 if (commit_max <= commit_min)
635 dprintf(1,
"sending COMMIT to data server for offset=%lld len=%lld\n",
636 commit_min, commit_max - commit_min);
653 dprintf(
IOLVL,
"<-- file_layout_write_thread(%u) returning %s\n",
666 OUT unsigned char *buffer_out,
689 state->session->lease_time);
691 eprintf(
"pattern_init() failed with %s\n",
702 goto out_free_pattern;
729 eprintf(
"nfs41_commit() to mds failed with %s\n",
748 eprintf(
"mds commit: failed to commit to data server\n");
753 eprintf(
"mds commit verifier doesn't match ds write verifiers\n");
778 if (
state->pnfs_last_offset < last_offset ||
779 (
state->pnfs_last_offset == 0 && last_offset == 0)) {
780 state->pnfs_last_offset = last_offset;
781 new_last_offset = &last_offset;
786 memcpy(&layout_stateid, &
layout->stateid,
sizeof(layout_stateid));
789 dprintf(1,
"LAYOUTCOMMIT for offset=%lld len=%lld new_last_offset=%u\n",
794 dprintf(
IOLVL,
"pnfs_rpc_layoutcommit() failed with %s\n",
833 state->session->lease_time);
835 eprintf(
"pattern_init() failed with %s\n",
847 goto out_free_pattern;
851 goto out_free_pattern;
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
#define list_for_each(entry, head)
uint32_t max_read_size(IN const nfs41_session *session, IN const nfs41_fh *fh)
bool_t verify_write(IN nfs41_write_verf *verf, IN OUT enum stable_how4 *stable)
bool_t verify_commit(IN nfs41_write_verf *verf)
uint32_t max_write_size(IN const nfs41_session *session, IN const nfs41_fh *fh)
void eprintf(LPCSTR format,...)
const char * nfs_error_string(int status)
const char * pnfs_error_string(enum pnfs_status status)
BOOL WINAPI GetExitCodeThread(IN HANDLE hThread, OUT LPDWORD lpExitCode)
VOID WINAPI ReleaseSRWLockShared(PSRWLOCK Lock)
VOID WINAPI AcquireSRWLockExclusive(PSRWLOCK Lock)
VOID WINAPI AcquireSRWLockShared(PSRWLOCK Lock)
VOID WINAPI ReleaseSRWLockExclusive(PSRWLOCK Lock)
GLuint GLuint GLsizei count
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 const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
double __cdecl remainder(double, double)
#define memcpy(s1, s2, n)
static HANDLE ULONG_PTR DWORD threads
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
static __inline void nfs41_superblock_getattr_mask(IN const nfs41_superblock *superblock, OUT bitmap4 *attrs)
#define NFS4_VERIFIER_SIZE
int nfs41_read(IN nfs41_session *session, IN nfs41_path_fh *file, IN stateid_arg *stateid, IN uint64_t offset, IN uint32_t count, OUT unsigned char *data_out, OUT uint32_t *data_len_out, OUT bool_t *eof_out)
enum nfsstat4 pnfs_rpc_layoutcommit(IN nfs41_session *session, IN nfs41_path_fh *file, IN stateid4 *stateid, IN uint64_t offset, IN uint64_t length, IN OPTIONAL uint64_t *new_last_offset, IN OPTIONAL nfstime4 *new_time_modify, OUT nfs41_file_info *info)
int nfs41_getattr(IN nfs41_session *session, IN OPTIONAL nfs41_path_fh *file, IN bitmap4 *attr_request, OUT nfs41_file_info *info)
int nfs41_write(IN nfs41_session *session, IN nfs41_path_fh *file, IN stateid_arg *stateid, IN unsigned char *data, IN uint32_t data_len, IN uint64_t offset, IN enum stable_how4 stable, OUT uint32_t *bytes_written, OUT nfs41_write_verf *verf, OUT nfs41_file_info *cinfo)
int nfs41_commit(IN nfs41_session *session, IN nfs41_path_fh *file, IN uint64_t offset, IN uint32_t count, IN bool_t do_getattr, OUT nfs41_write_verf *verf, OUT nfs41_file_info *cinfo)
static const uint64_t NFS4_UINT64_MAX
__inline uint32_t stripe_index(IN const pnfs_file_layout *layout, IN uint64_t sui, IN uint32_t stripe_count)
void pnfs_layout_io_finished(IN pnfs_layout_state *state)
__inline uint32_t layout_unit_size(IN const pnfs_file_layout *layout)
__inline uint32_t data_server_index(IN const pnfs_file_device *device, IN uint32_t stripeid)
void pnfs_layout_io_start(IN pnfs_layout_state *state)
__inline int is_dense(IN const pnfs_file_layout *layout)
__inline uint64_t stripe_unit_offset(IN const pnfs_file_layout *layout, IN uint64_t sui, IN uint32_t unit_size)
void pnfs_layout_recall_fenced(IN pnfs_layout_state *state, IN const pnfs_layout *layout)
__inline uint64_t stripe_unit_number(IN const pnfs_file_layout *layout, IN uint64_t offset, IN uint32_t unit_size)
@ PNFSERR_INVALID_FH_LIST
@ PNFSERR_INVALID_DS_INDEX
@ PNFSERR_LAYOUT_RECALLED
__inline int should_commit_to_mds(IN const pnfs_file_layout *layout)
enum pnfs_status pnfs_data_server_client(IN struct __nfs41_root *root, IN pnfs_data_server *server, IN uint32_t default_lease, OUT struct __nfs41_client **client_out)
enum pnfs_status pnfs_layout_state_prepare(IN pnfs_layout_state *state, IN struct __nfs41_session *session, IN nfs41_path_fh *meta_file, IN struct __stateid_arg *stateid, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t length)
enum pnfs_status pnfs_layout_recall_status(IN const pnfs_layout_state *state, IN const pnfs_layout *layout)
static enum pnfs_status thread_next_unit(IN pnfs_io_thread *thread, OUT pnfs_io_unit *io)
static enum pnfs_status layout_commit(IN nfs41_open_state *state, IN pnfs_layout_state *layout, IN uint64_t offset, IN uint64_t length, OUT nfs41_file_info *info)
static enum pnfs_status pattern_threads_init(IN pnfs_io_pattern *pattern, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t length)
enum pnfs_status pnfs_read(IN nfs41_root *root, IN nfs41_open_state *state, IN stateid_arg *stateid, IN pnfs_layout_state *layout, IN uint64_t offset, IN uint64_t length, OUT unsigned char *buffer_out, OUT ULONG *len_out)
static enum pnfs_status get_sparse_fh(IN pnfs_file_layout *layout, IN nfs41_path_fh *meta_file, IN uint32_t stripeid, OUT nfs41_path_fh **file_out)
static enum pnfs_status get_dense_fh(IN pnfs_file_layout *layout, IN uint32_t stripeid, OUT nfs41_path_fh **file_out)
enum pnfs_status pnfs_write(IN nfs41_root *root, IN nfs41_open_state *state, IN stateid_arg *stateid, IN pnfs_layout_state *layout, IN uint64_t offset, IN uint64_t length, IN unsigned char *buffer, OUT ULONG *len_out, OUT nfs41_file_info *info)
static uint32_t thread_count(IN pnfs_layout_state *state, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t length)
static __inline uint64_t positive_remainder(IN uint64_t dividend, IN uint32_t divisor)
static enum pnfs_status pattern_init(IN pnfs_io_pattern *pattern, IN nfs41_root *root, IN nfs41_path_fh *meta_file, IN const stateid_arg *stateid, IN pnfs_layout_state *state, IN unsigned char *buffer, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t length, IN uint32_t default_lease)
struct __pnfs_io_pattern pnfs_io_pattern
static uint64_t pattern_bytes_transferred(IN pnfs_io_pattern *pattern, OUT OPTIONAL enum stable_how4 *stable)
static void pattern_free(IN pnfs_io_pattern *pattern)
static enum pnfs_status pattern_fork(IN pnfs_io_pattern *pattern, IN pnfs_io_thread_fn thread_fn)
static enum pnfs_status thread_data_server(IN pnfs_io_thread *thread, OUT pnfs_data_server **server_out)
static enum pnfs_status thread_init(IN pnfs_io_pattern *pattern, IN pnfs_io_thread *thread, IN pnfs_file_layout *layout, IN uint32_t stripeid, IN uint64_t offset)
struct __pnfs_io_unit pnfs_io_unit
static __inline bool_t layout_compatible(IN const pnfs_layout *layout, IN enum pnfs_iomode iomode, IN uint64_t position)
static uint32_t WINAPI file_layout_read_thread(void *args)
#define file_layout_entry(pos)
static enum pnfs_status stripe_next_unit(IN const pnfs_file_layout *layout, IN uint32_t stripeid, IN uint64_t *position, IN uint64_t offset_end, OUT pnfs_io_unit *io)
struct __pnfs_io_thread pnfs_io_thread
uint32_t(WINAPI * pnfs_io_thread_fn)(void *)
static enum pnfs_status map_ds_error(IN enum nfsstat4 nfsstat, IN pnfs_layout_state *state, IN const pnfs_file_layout *layout)
static enum pnfs_status mds_commit(IN nfs41_open_state *state, IN uint64_t offset, IN uint32_t length, IN const pnfs_io_pattern *pattern, OUT nfs41_file_info *info)
static uint32_t WINAPI file_layout_write_thread(void *args)
static enum pnfs_status pattern_join(IN HANDLE *threads, IN DWORD count)
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
PULONG MinorVersion OPTIONAL
unsigned char verf[NFS4_VERIFIER_SIZE]
const stateid_arg * stateid
nfs41_path_fh * meta_file
pnfs_layout_state * state
struct __pnfs_io_thread * threads
pnfs_io_pattern * pattern
pnfs_file_layout * layout
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
static rfbScreenInfoPtr server
DWORD WINAPI GetLastError(void)
#define MAXIMUM_WAIT_OBJECTS