Skip to content

Commit 59e0438

Browse files
authored
Merge pull request #755 from CamStan/main
Merge dev into main for release 1.0.1
2 parents 6bbb03b + 6a11ec4 commit 59e0438

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2813
-858
lines changed

.github/workflows/build-and-test.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
os: [ ubuntu-latest ]
27+
os: [ ubuntu-20.04 ]
2828
compiler: [ gcc ]
2929
gcc: [ 7, 8, 9, 10, 11 ]
3030

@@ -37,7 +37,15 @@ jobs:
3737
CXX: g++-${{ matrix.gcc }}
3838

3939
steps:
40-
- uses: actions/checkout@v2
40+
- name: Push checkout
41+
if: github.event_name == 'push'
42+
uses: actions/checkout@v2
43+
44+
- name: PR checkout
45+
if: github.event_name == 'pull_request'
46+
uses: actions/checkout@v2
47+
with:
48+
ref: ${{ github.event.pull_request.head.sha }}
4149

4250
- name: Set up GCC
4351
uses: egor-tensin/setup-gcc@v1

Makefile.am

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ CONFIG = ordered
55
ACLOCAL_AMFLAGS = -I m4
66

77
pkgconfigdir = @pkgconfigdir@
8-
pkgconfig_DATA = client/unifyfs.pc \
9-
client/unifyfs-api.pc
8+
pkgconfig_DATA = \
9+
client/unifyfs.pc \
10+
client/unifyfs-api.pc \
11+
client/unifyfs-static.pc
1012

1113
CLEANFILES =
1214

client/src/Makefile.am

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ if USE_PMPI_WRAPPERS
1313
lib_LTLIBRARIES += libunifyfs_mpi_gotcha.la
1414
endif #USE_PMPI_WRAPPERS
1515

16+
if ENABLE_LD_PRELOAD
17+
lib_LTLIBRARIES += libunifyfs_preload_gotcha.la
18+
endif #ENABLE_LD_PRELOAD
19+
1620
if HAVE_FORTRAN
1721
lib_LTLIBRARIES += libunifyfsf.la
1822
endif #HAVE_FORTRAN
@@ -40,15 +44,13 @@ CLIENT_COMMON_CPPFLAGS = \
4044

4145
CLIENT_COMMON_CFLAGS = \
4246
$(AM_CFLAGS) \
43-
$(UNIFYFS_COMMON_FLAGS) \
44-
$(MPI_CFLAGS)
47+
$(UNIFYFS_COMMON_FLAGS)
4548

4649
CLIENT_COMMON_LDFLAGS = \
4750
-version-info $(LIBUNIFYFS_LT_VERSION)
4851

4952
CLIENT_COMMON_LIBADD = \
5053
$(UNIFYFS_COMMON_LIBS) \
51-
$(MPI_CLDFLAGS) \
5254
-lm -lrt -lcrypto -lpthread
5355

5456
if HAVE_SPATH
@@ -96,6 +98,8 @@ PMPI_SRC_FILES = \
9698
pmpi_wrappers.c \
9799
pmpi_wrappers.h
98100

101+
PRELOAD_SRC_FILES = \
102+
preload.c
99103

100104
# Per-target flags begin here
101105

@@ -118,8 +122,8 @@ libunifyfs_la_SOURCES = \
118122

119123
if USE_PMPI_WRAPPERS
120124
libunifyfs_mpi_la_CPPFLAGS = $(CLIENT_COMMON_CPPFLAGS)
121-
libunifyfs_mpi_la_CFLAGS = $(CLIENT_COMMON_CFLAGS)
122-
libunifyfs_mpi_la_LDFLAGS = $(CLIENT_COMMON_LDFLAGS)
125+
libunifyfs_mpi_la_CFLAGS = $(CLIENT_COMMON_CFLAGS) $(MPI_CFLAGS)
126+
libunifyfs_mpi_la_LDFLAGS = $(CLIENT_COMMON_LDFLAGS) $(MPI_CLDFLAGS)
123127
libunifyfs_mpi_la_LIBADD = libunifyfs.la
124128
libunifyfs_mpi_la_SOURCES = $(PMPI_SRC_FILES)
125129
endif #USE_PMPI_WRAPPERS
@@ -137,10 +141,18 @@ libunifyfs_gotcha_la_SOURCES = \
137141
$(POSIX_CLIENT_SRC_FILES) \
138142
gotcha_map_unifyfs_list.c
139143

144+
if ENABLE_LD_PRELOAD
145+
libunifyfs_preload_gotcha_la_CPPFLAGS = $(CLIENT_COMMON_CPPFLAGS)
146+
libunifyfs_preload_gotcha_la_CFLAGS = $(CLIENT_COMMON_CFLAGS)
147+
libunifyfs_preload_gotcha_la_LDFLAGS = $(CLIENT_COMMON_LDFLAGS)
148+
libunifyfs_preload_gotcha_la_LIBADD = libunifyfs_gotcha.la
149+
libunifyfs_preload_gotcha_la_SOURCES = $(PRELOAD_SRC_FILES)
150+
endif #ENABLE_LD_PRELOAD
151+
140152
if USE_PMPI_WRAPPERS
141153
libunifyfs_mpi_gotcha_la_CPPFLAGS = $(CLIENT_COMMON_CPPFLAGS)
142-
libunifyfs_mpi_gotcha_la_CFLAGS = $(CLIENT_COMMON_CFLAGS)
143-
libunifyfs_mpi_gotcha_la_LDFLAGS = $(CLIENT_COMMON_LDFLAGS)
154+
libunifyfs_mpi_gotcha_la_CFLAGS = $(CLIENT_COMMON_CFLAGS) $(MPI_CFLAGS)
155+
libunifyfs_mpi_gotcha_la_LDFLAGS = $(CLIENT_COMMON_LDFLAGS) $(MPI_CLDFLAGS)
144156
libunifyfs_mpi_gotcha_la_LIBADD = libunifyfs_gotcha.la
145157
libunifyfs_mpi_gotcha_la_SOURCES = $(PMPI_SRC_FILES)
146158
endif #USE_PMPI_WRAPPERS

client/src/client_read.c

Lines changed: 103 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -419,17 +419,41 @@ void service_local_reqs(
419419
/* copy data from local write log into user buffer */
420420
off_t log_offset = ext_log_pos + ext_byte_offset;
421421
size_t nread = 0;
422-
int rc = unifyfs_logio_read(client->state.logio_ctx, log_offset,
423-
cover_length, req_ptr, &nread);
424-
if (rc == UNIFYFS_SUCCESS) {
425-
/* update bytes we have filled in the request buffer */
426-
update_read_req_coverage(req, req_byte_offset, nread);
422+
/* we need to use the logio_ctx from correct client */
423+
logio_context* logio_ctx = NULL;
424+
if (next->client_id == client->state.client_id) {
425+
logio_ctx = client->state.logio_ctx;
426+
} else if (client->logio_ctx_ptrs[next->client_id] != NULL) {
427+
logio_ctx = client->logio_ctx_ptrs[next->client_id];
427428
} else {
428-
LOGERR("local log read failed for offset=%zu size=%zu",
429-
(size_t)log_offset, cover_length);
430-
req->errcode = rc;
429+
size_t shmem_size = 0;
430+
if (client->state.logio_ctx->shmem != NULL) {
431+
shmem_size = client->state.logio_ctx->shmem->size;
432+
}
433+
char* spill_dir = NULL;
434+
if (client->state.logio_ctx->spill_sz > 0) {
435+
spill_dir = client->cfg.logio_spill_dir;
436+
}
437+
unifyfs_logio_init(client->state.app_id,
438+
next->client_id,
439+
shmem_size,
440+
client->state.logio_ctx->spill_sz,
441+
spill_dir,
442+
&client->logio_ctx_ptrs[next->client_id]);
443+
logio_ctx = client->logio_ctx_ptrs[next->client_id];
444+
}
445+
if (NULL != logio_ctx) {
446+
int rc = unifyfs_logio_read(logio_ctx, log_offset,
447+
cover_length, req_ptr, &nread);
448+
if (rc == UNIFYFS_SUCCESS) {
449+
/* update bytes we have filled in the request buffer */
450+
update_read_req_coverage(req, req_byte_offset, nread);
451+
} else {
452+
LOGERR("local log read failed for offset=%zu size=%zu",
453+
(size_t) log_offset, cover_length);
454+
req->errcode = rc;
455+
}
431456
}
432-
433457
/* get the next element in the tree */
434458
next = seg_tree_iter(extents, next);
435459
}
@@ -560,7 +584,7 @@ static void update_read_req_result(unifyfs_client* client,
560584
*/
561585
int process_gfid_reads(unifyfs_client* client,
562586
read_req_t* in_reqs,
563-
int in_count)
587+
size_t in_count)
564588
{
565589
if (0 == in_count) {
566590
return UNIFYFS_SUCCESS;
@@ -597,9 +621,76 @@ int process_gfid_reads(unifyfs_client* client,
597621
/* this records the pointer to the temp request array if
598622
* we allocate one, we should free this later if not NULL */
599623
read_req_t* reqs = NULL;
624+
if (client->use_node_local_extents) {
625+
extents_list_t* list = calloc(1, sizeof(struct extents_list));
626+
struct extents_list* cur = list;
627+
int num_request_selected = 0;
628+
for (int i = 0; i < in_count; ++i) {
629+
int fid = unifyfs_fid_from_gfid(client, in_reqs[i].gfid);
630+
/* get meta for this file id */
631+
unifyfs_filemeta_t* meta = unifyfs_get_meta_from_fid(client, fid);
632+
if (meta != NULL) {
633+
if (!meta->attrs.is_laminated || !meta->needs_reads_sync) {
634+
/* do not proceed for this request as
635+
* it is not a laminated file or has already been synced.*/
636+
continue;
637+
}
638+
num_request_selected++;
639+
off_t filesize_offt = unifyfs_gfid_filesize(client,
640+
in_reqs[i].gfid);
641+
cur->value.file_pos = 0;
642+
cur->value.length = filesize_offt - 1;
643+
cur->value.gfid = in_reqs[i].gfid;
644+
if (i < in_count - 1) {
645+
cur->next = calloc(1, sizeof(struct extents_list));
646+
cur->next->next = NULL;
647+
cur = cur->next;
648+
} else {
649+
cur->next = NULL;
650+
}
651+
meta->needs_reads_sync = 0;
652+
}
653+
}
654+
if (num_request_selected > 0) {
655+
/* There are files which are laminated and
656+
* require sync of extents */
657+
size_t extent_count = 0;
658+
unifyfs_client_index_t* extents = NULL;
659+
int rc =
660+
invoke_client_node_local_extents_get_rpc(client,
661+
num_request_selected,
662+
list,
663+
&extent_count,
664+
&extents);
665+
if (rc == UNIFYFS_SUCCESS && extent_count != 0) {
666+
for (int j = 0; j < extent_count; ++j) {
667+
if (extents[j].log_app_id ==
668+
client->state.app_id) {
669+
int fid = unifyfs_fid_from_gfid(client,
670+
extents[j].gfid);
671+
/* get meta for this file id */
672+
unifyfs_filemeta_t* meta = unifyfs_get_meta_from_fid(
673+
client,
674+
fid);
675+
if (meta != NULL) {
676+
seg_tree_add(&meta->extents,
677+
extents[j].file_pos,
678+
extents[j].file_pos +
679+
extents[j].length - 1,
680+
extents[j].log_pos,
681+
extents[j].log_client_id);
682+
}
683+
}
684+
}
685+
}
686+
if (extents != NULL) {
687+
free(extents);
688+
}
689+
}
690+
}
600691

601692
/* attempt to complete requests locally if enabled */
602-
if (client->use_local_extents) {
693+
if (client->use_local_extents || client->use_node_local_extents) {
603694
/* allocate space to make local and server copies of the requests,
604695
* each list will be at most in_count long */
605696
size_t reqs_size = 2 * in_count;
@@ -743,7 +834,7 @@ int process_gfid_reads(unifyfs_client* client,
743834
/* if we attempted to service requests from our local extent map,
744835
* then we need to copy the resulting read requests from the local
745836
* and server arrays back into the user's original array */
746-
if (client->use_local_extents) {
837+
if (client->use_local_extents || client->use_node_local_extents) {
747838
/* TODO: would be nice to copy these back into the same order
748839
* in which we received them. */
749840

client/src/client_read.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,6 @@ void update_read_req_coverage(read_req_t* req,
111111
/* process a set of client read requests */
112112
int process_gfid_reads(unifyfs_client* client,
113113
read_req_t* in_reqs,
114-
int in_count);
114+
size_t in_count);
115115

116116
#endif // UNIFYFS_CLIENT_READ_H

client/src/gotcha_map_unifyfs_list.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ UNIFYFS_DEF(unlink, int,
6161
UNIFYFS_DEF(remove, int,
6262
(const char* path),
6363
(path))
64+
UNIFYFS_DEF(utimensat, int,
65+
(int dirfd, const char* pathname, const struct timespec times[2],
66+
int flags),
67+
(dirfd, pathname, times, flags))
68+
UNIFYFS_DEF(futimens, int,
69+
(int fd, const struct timespec times[2]),
70+
(fd, times))
6471

6572
UNIFYFS_DEF(stat, int,
6673
(const char* path, struct stat* buf),
@@ -144,6 +151,12 @@ UNIFYFS_DEF(pwrite64, ssize_t,
144151
UNIFYFS_DEF(close, int,
145152
(int fd),
146153
(fd))
154+
UNIFYFS_DEF(dup, int,
155+
(int fd),
156+
(fd))
157+
UNIFYFS_DEF(dup2, int,
158+
(int fd, int desired_fd),
159+
(fd, desired_fd))
147160
UNIFYFS_DEF(fchdir, int,
148161
(int fd),
149162
(fd))
@@ -349,6 +362,8 @@ struct gotcha_binding_t unifyfs_wrappers[] = {
349362
{ "truncate", UNIFYFS_WRAP(truncate), &wrappee_handle_truncate },
350363
{ "unlink", UNIFYFS_WRAP(unlink), &wrappee_handle_unlink },
351364
{ "remove", UNIFYFS_WRAP(remove), &wrappee_handle_remove },
365+
{ "utimensat", UNIFYFS_WRAP(utimensat), &wrappee_handle_utimensat },
366+
{ "futimens", UNIFYFS_WRAP(futimens), &wrappee_handle_futimens },
352367
{ "stat", UNIFYFS_WRAP(stat), &wrappee_handle_stat },
353368
{ "fstat", UNIFYFS_WRAP(fstat), &wrappee_handle_fstat },
354369
{ "__xstat", UNIFYFS_WRAP(__xstat), &wrappee_handle___xstat },
@@ -386,6 +401,8 @@ struct gotcha_binding_t unifyfs_wrappers[] = {
386401
{ "munmap", UNIFYFS_WRAP(munmap), &wrappee_handle_munmap },
387402
{ "mmap64", UNIFYFS_WRAP(mmap64), &wrappee_handle_mmap64 },
388403
{ "close", UNIFYFS_WRAP(close), &wrappee_handle_close },
404+
{ "dup", UNIFYFS_WRAP(dup), &wrappee_handle_dup },
405+
{ "dup2", UNIFYFS_WRAP(dup2), &wrappee_handle_dup2 },
389406
{ "opendir", UNIFYFS_WRAP(opendir), &wrappee_handle_opendir },
390407
{ "fdopendir", UNIFYFS_WRAP(fdopendir), &wrappee_handle_fdopendir },
391408
{ "closedir", UNIFYFS_WRAP(closedir), &wrappee_handle_closedir },

0 commit comments

Comments
 (0)