-
Notifications
You must be signed in to change notification settings - Fork 747
/
Copy pathOSCachemmap.cpp
1791 lines (1575 loc) · 61.9 KB
/
OSCachemmap.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* Copyright IBM Corp. and others 2001
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] https://openjdk.org/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
*******************************************************************************/
/**
* @file
* @ingroup Shared_Common
*/
#include <string.h>
#include "j2sever.h"
#include "j9cfg.h"
#include "j9port.h"
#include "pool_api.h"
#include "ut_j9shr.h"
#include "j9shrnls.h"
#include "util_api.h"
#include "OSCachemmap.hpp"
#include "CompositeCacheImpl.hpp"
#include "UnitTest.hpp"
#include "CacheMap.hpp"
#define MMAP_CACHEDATASIZE(size) (size - MMAP_CACHEHEADERSIZE)
#define RETRY_OBTAIN_WRITE_LOCK_SLEEP_NS 100000
#define RETRY_OBTAIN_WRITE_LOCK_MAX_MS 160
#define NANOSECS_PER_MILLISEC (I_64)1000000
/**
* Multi-argument constructor
*
* Constructs and initializes a SH_OSCachemmap object and calls startup to open/create
* a shared classes cache.
* This c'tor is currently used during unit testing only. Therefore we pass J9SH_DIRPERM_ABSENT as cacheDirPerm to startup().
*
* @param [in] portLibrary The Port library
* @param [in] cacheName The name of the cache to be opened/created
* @param [in] piconfig Pointer to a configuration structure
* @param [in] numLocks The number of locks to be initialized
* @param [in] createFlag Indicates whether cache is to be opened or created.
* \args J9SH_OSCACHE_CREATE Create the cache if it does not exists, otherwise open existing cache
* \args J9SH_OSCACHE_OPEXIST Open an existing cache only, failed if it doesn't exist.
* @param [in] verboseFlags Verbose flags
* @param [in] openMode Mode to open the cache in. Any of the following flags:
* \args J9OSCACHE_OPEN_MODE_DO_READONLY - open the cache readonly
* \args J9OSCACHE_OPEN_MODE_TRY_READONLY_ON_FAIL - if the cache could not be opened read/write - try readonly
* \args J9OSCACHE_OPEN_MODE_GROUPACCESS - creates a cache with group access. Only applies when a cache is created
* \args J9OSCACHE_OPEN_MODE_CHECK_NETWORK_CACHE - checks whether we are attempting to connect to a networked cache
* @param [in] versionData Version data of the cache to connect to
* @param [in] initializer Pointer to an initializer to be used to initialize the data
* area of a new cache
*/
SH_OSCachemmap::SH_OSCachemmap(J9PortLibrary* portLibrary, J9JavaVM* vm, const char* cacheDirName, const char* cacheName, J9SharedClassPreinitConfig* piconfig,
IDATA numLocks, UDATA createFlag, UDATA verboseFlags, U_64 runtimeFlags, I_32 openMode, J9PortShcVersion* versionData, SH_OSCacheInitializer* initializer)
{
Trc_SHR_OSC_Mmap_Constructor_Entry(cacheName, piconfig->sharedClassCacheSize, numLocks, createFlag, verboseFlags);
initialize(portLibrary, NULL, OSCACHE_CURRENT_CACHE_GEN, OSCACHE_CURRENT_LAYER_LAYER);
startup(vm, cacheDirName, J9SH_DIRPERM_ABSENT, cacheName, piconfig, numLocks, createFlag, verboseFlags, runtimeFlags, openMode, 0, versionData, initializer, SHR_STARTUP_REASON_NORMAL);
Trc_SHR_OSC_Mmap_Constructor_Exit();
}
/**
* Method to initialize object variables. This is outside the constructor for
* consistency with SH_OSCachesysv
* Note: This method is public as it is called by the factory method newInstance in SH_OSCache
*
* @param [in] portLibraryArg The Port library
* @param [in] memForConstructorArg Pointer to the memory to build the OSCachemmap into
* @param [in] generation The generation of this cache
* @param [in] layer The layer number of this cache
*/
void
SH_OSCachemmap::initialize(J9PortLibrary* portLibrary, char* memForConstructor, UDATA generation, I_8 layer)
{
Trc_SHR_OSC_Mmap_initialize_Entry(portLibrary, memForConstructor);
commonInit(portLibrary, generation, layer);
_fileHandle = -1;
_actualFileLength = 0;
_finalised = 0;
_mapFileHandle = NULL;
for (UDATA i = 0; i < J9SH_OSCACHE_MMAP_LOCK_COUNT; i++) {
_lockMutex[i] = NULL;
}
_corruptionCode = NO_CORRUPTION;
_corruptValue = NO_CORRUPTION;
_cacheFileAccess = J9SH_CACHE_FILE_ACCESS_ALLOWED;
Trc_SHR_OSC_Mmap_initialize_Exit();
}
/**
* Method to free resources and re-initialize variables when
* cache is no longer required
*/
void
SH_OSCachemmap::finalise()
{
Trc_SHR_OSC_Mmap_finalise_Entry();
commonCleanup();
_fileHandle = -1;
_actualFileLength = 0;
_finalised = 1;
_mapFileHandle = NULL;
for (UDATA i = 0; i < J9SH_OSCACHE_MMAP_LOCK_COUNT; i++) {
if(NULL != _lockMutex[i]) {
omrthread_monitor_destroy(_lockMutex[i]);
}
}
Trc_SHR_OSC_Mmap_finalise_Exit();
}
/**
* Method to create or open a persistent shared classes cache
* Should be able to successfully start up a cache on any version or generation
*
* @param [in] portLibrary The Port library
* @param [in] cacheName The name of the cache to be opened/created
* @param [in] cacheDirName The directory for the cache file
* @param [in] piconfig Pointer to a configuration structure
* @param [in] numLocks The number of locks to be initialized
* @param [in] createFlag Indicates whether cache is to be opened or created.
* Included for consistency with SH_OSCachesysv, but need to open or create is
* determined by logic within this class
* @param [in] verboseFlags Verbose flags
* @param [in] openMode Mode to open the cache in. Any of the following flags:
* \args J9OSCACHE_OPEN_MODE_DO_READONLY - open the cache readonly
* \args J9OSCACHE_OPEN_MODE_TRY_READONLY_ON_FAIL - if the cache could not be opened read/write - try readonly
* \args J9OSCACHE_OPEN_MODE_GROUPACCESS - creates a cache with group access. Only applies when a cache is created
* \args J9OSCACHE_OPEN_MODE_CHECK_NETWORK_CACHE - checks whether we are attempting to connect to a networked cache
* \args J9OSCACHE_OPEN_MODE_JITSERVER_AOT_LAYER - immediately unlink the underlying cache file after it is created
* @param [in] versionData Version data of the cache to connect to
* @param [in] initializer Pointer to an initializer to be used to initialize the data
* area of a new cache
* @param [in] reason Reason for starting up the cache. Used only when startup is called during destroy
*
* @return true on success, false on failure
*/
bool
SH_OSCachemmap::startup(J9JavaVM* vm, const char* ctrlDirName, UDATA cacheDirPerm, const char* cacheName, J9SharedClassPreinitConfig* piconfig, IDATA numLocks,
UDATA createFlag, UDATA verboseFlags, U_64 runtimeFlags, I_32 openMode, UDATA storageKeyTesting, J9PortShcVersion* versionData, SH_OSCacheInitializer* initializer, UDATA reason)
{
I_32 mmapCapabilities;
IDATA retryCntr;
bool creatingNewCache = false;
struct J9FileStat statBuf;
IDATA errorCode = J9SH_OSCACHE_FAILURE;
LastErrorInfo lastErrorInfo;
UDATA defaultCacheSize = J9_SHARED_CLASS_CACHE_DEFAULT_SIZE;
#if defined(J9VM_ENV_DATA64)
#if defined(OPENJ9_BUILD)
defaultCacheSize = J9_SHARED_CLASS_CACHE_DEFAULT_SIZE_64BIT_PLATFORM;
#else /* OPENJ9_BUILD */
if (J2SE_VERSION(vm) >= J2SE_V11) {
defaultCacheSize = J9_SHARED_CLASS_CACHE_DEFAULT_SIZE_64BIT_PLATFORM;
}
#endif /* OPENJ9_BUILD */
#endif /* J9VM_ENV_DATA64 */
PORT_ACCESS_FROM_PORT(_portLibrary);
Trc_SHR_OSC_Mmap_startup_Entry(cacheName, ctrlDirName,
(piconfig!= NULL)? piconfig->sharedClassCacheSize : defaultCacheSize,
numLocks, createFlag, verboseFlags, openMode);
versionData->cacheType = J9PORT_SHR_CACHE_TYPE_PERSISTENT;
mmapCapabilities = j9mmap_capabilities();
if (J9_ARE_NO_BITS_SET(mmapCapabilities, J9PORT_MMAP_CAPABILITY_WRITE | J9PORT_MMAP_CAPABILITY_MSYNC)) {
Trc_SHR_OSC_Mmap_startup_nommap(mmapCapabilities);
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_MMAPCAP, NULL);
goto _errorPreFileOpen;
}
if (commonStartup(vm, ctrlDirName, cacheDirPerm, cacheName, piconfig, createFlag, verboseFlags, runtimeFlags, openMode, versionData) != 0) {
Trc_SHR_OSC_Mmap_startup_commonStartupFailure();
goto _errorPreFileOpen;
}
Trc_SHR_OSC_Mmap_startup_commonStartupSuccess();
/* Detect remote filesystem */
if (openMode & J9OSCACHE_OPEN_MODE_CHECK_NETWORK_CACHE) {
if (0 == j9file_stat(_cacheDirName, 0, &statBuf)) {
if (statBuf.isRemote) {
Trc_SHR_OSC_Mmap_startup_detectedNetworkCache();
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_NETWORK_CACHE, NULL);
goto _errorPreFileOpen;
}
}
}
/* Open the file */
if (!openCacheFile(_createFlags & J9SH_OSCACHE_CREATE, &lastErrorInfo)) {
Trc_SHR_OSC_Mmap_startup_badfileopen(_cachePathName);
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_FILEOPEN_ERROR, &lastErrorInfo); /* TODO: ADD FILE NAME */
goto _errorPostFileOpen;
}
Trc_SHR_OSC_Mmap_startup_goodfileopen(_cachePathName, _fileHandle);
#if defined(J9VM_OPT_JITSERVER)
if (J9_ARE_ALL_BITS_SET(openMode, J9OSCACHE_OPEN_MODE_JITSERVER_AOT_LAYER)) {
if (deleteCacheFile(&lastErrorInfo)) {
Trc_SHR_OSC_Mmap_startup_jitserverlayergooddelete(_cachePathName, _fileHandle);
} else {
Trc_SHR_OSC_Mmap_startup_jitserverlayerbaddelete(_cachePathName, _fileHandle);
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_JITSERVER_LAYER_FILE_DELETE_ERROR, &lastErrorInfo);
}
}
#endif /* defined(J9VM_OPT_JITSERVER) */
/* Avoid any checks for cache file access if
* - user has specified a cache directory, or
* - destroying an existing cache (if SHR_STARTUP_REASON_DESTROY or SHR_STARTUP_REASON_EXPIRE or J9SH_OSCACHE_OPEXIST_DESTROY is set)
*/
if (!_isUserSpecifiedCacheDir
&& (J9_ARE_NO_BITS_SET(_createFlags, J9SH_OSCACHE_OPEXIST_DESTROY))
&& (SHR_STARTUP_REASON_DESTROY != reason)
&& (SHR_STARTUP_REASON_EXPIRE != reason)
) {
_cacheFileAccess = checkCacheFileAccess(_portLibrary, _fileHandle, _openMode, &lastErrorInfo);
if (J9_ARE_ALL_BITS_SET(_createFlags, J9SH_OSCACHE_OPEXIST_STATS)
|| (J9SH_CACHE_FILE_ACCESS_ALLOWED == _cacheFileAccess)
) {
Trc_SHR_OSC_Mmap_startup_fileaccessallowed(_cachePathName);
} else {
switch (_cacheFileAccess) {
case J9SH_CACHE_FILE_ACCESS_GROUP_ACCESS_REQUIRED:
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_GROUPACCESS_REQUIRED, NULL);
goto _errorPostFileOpen;
break;
case J9SH_CACHE_FILE_ACCESS_OTHERS_NOT_ALLOWED:
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_OTHERS_ACCESS_NOT_ALLOWED, NULL);
goto _errorPostFileOpen;
break;
case J9SH_CACHE_FILE_ACCESS_CANNOT_BE_DETERMINED:
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_INTERNAL_ERROR_CHECKING_CACHEFILE_ACCESS, &lastErrorInfo);
goto _errorPostFileOpen;
break;
default:
Trc_SHR_Assert_ShouldNeverHappen();
}
}
}
/* CMVC 177634: When destroying the cache, it is sufficient to open it.
* We should avoid doing any processing that can detect cache as corrupt.
*/
if (SHR_STARTUP_REASON_DESTROY == reason) {
Trc_SHR_OSC_Mmap_startup_openCacheForDestroy(_cachePathName);
goto _exitForDestroy;
}
for (UDATA i = 0; i < J9SH_OSCACHE_MMAP_LOCK_COUNT; i++) {
if (omrthread_monitor_init_with_name(&_lockMutex[i], 0, "Persistent shared classes lock mutex")) {
Trc_SHR_OSC_Mmap_startup_failed_mutex_init(i);
goto _errorPostFileOpen;
}
}
Trc_SHR_OSC_Mmap_startup_initialized_mutexes();
/* Get cache header write lock */
if (-1 == acquireHeaderWriteLock(_activeGeneration, &lastErrorInfo)) {
Trc_SHR_OSC_Mmap_startup_badAcquireHeaderWriteLock();
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_ACQUIREHEADERWRITELOCK_ERROR, &lastErrorInfo);
errorCode = J9SH_OSCACHE_CORRUPT;
OSC_ERR_TRACE1(J9NLS_SHRC_OSCACHE_CORRUPT_ACQUIRE_HEADER_WRITE_LOCK_FAILED, lastErrorInfo.lastErrorCode);
setCorruptionContext(ACQUIRE_HEADER_WRITE_LOCK_FAILED, (UDATA)lastErrorInfo.lastErrorCode);
goto _errorPostHeaderLock;
}
Trc_SHR_OSC_Mmap_startup_goodAcquireHeaderWriteLock();
/* Check the length of the file */
#if defined(WIN32) || defined(WIN64)
if ((_cacheSize = (U_32)j9file_blockingasync_flength(_fileHandle)) > 0) {
#else
if ((_cacheSize = (U_32)j9file_flength(_fileHandle)) > 0) {
#endif
IDATA rc;
/* We are opening an existing cache */
Trc_SHR_OSC_Mmap_startup_fileOpened();
if (_cacheSize <= sizeof(OSCachemmap_header_version_current)) {
Trc_SHR_OSC_Mmap_startup_cacheTooSmall();
errorCode = J9SH_OSCACHE_CORRUPT;
OSC_ERR_TRACE1(J9NLS_SHRC_CC_STARTUP_CORRUPT_CACHE_SIZE_INVALID, _cacheSize);
setCorruptionContext(CACHE_SIZE_INVALID, (UDATA)_cacheSize);
goto _errorPostHeaderLock;
}
/* At this point, don't check the cache version - we need to attach to older versions in order to destroy */
rc = internalAttach(false, _activeGeneration);
if (0 != rc) {
errorCode = rc;
Trc_SHR_OSC_Mmap_startup_badAttach();
goto _errorPostAttach;
}
if (_runningReadOnly) {
retryCntr = 0;
U_32* initCompleteAddr = (U_32*)getMmapHeaderFieldAddressForGen(_headerStart, _activeGeneration, OSCACHE_HEADER_FIELD_CACHE_INIT_COMPLETE);
/* In readonly, we can't get a header lock, so if the cache is mid-init, give it a chance to complete initialization */
while ((!*initCompleteAddr) && (retryCntr < J9SH_OSCACHE_READONLY_RETRY_COUNT)) {
omrthread_sleep(J9SH_OSCACHE_READONLY_RETRY_SLEEP_MILLIS);
++retryCntr;
}
if (!*initCompleteAddr) {
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_ERROR_READONLY_CACHE_NOTINITIALIZED, NULL);
Trc_SHR_OSC_Mmap_startup_cacheNotInitialized();
goto _errorPostAttach;
}
}
if (_verboseFlags & J9SHR_VERBOSEFLAG_ENABLE_VERBOSE) {
if (_runningReadOnly) {
OSC_TRACE1(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_OPENED_READONLY, _cacheName);
} else {
OSC_TRACE1(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_OPENED, _cacheName);
}
}
} else {
OSCachemmap_header_version_current *cacheHeader;
IDATA rc;
creatingNewCache = true;
/* File is wrong length, so we are creating the cache */
Trc_SHR_OSC_Mmap_startup_fileCreated();
/* We can't create the cache when we're running read-only */
if (_runningReadOnly) {
Trc_SHR_OSC_Mmap_startup_runningReadOnlyAndWrongLength();
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_ERROR_OPENING_CACHE_READONLY, NULL);
goto _errorPostHeaderLock;
}
/* Set cache to the correct length */
if (!setCacheLength((U_32)piconfig->sharedClassCacheSize, &lastErrorInfo)) {
Trc_SHR_OSC_Mmap_startup_badSetCacheLength(piconfig->sharedClassCacheSize);
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_ERROR_SETTING_CACHE_LENGTH, &lastErrorInfo);
goto _errorPostHeaderLock;
}
Trc_SHR_OSC_Mmap_startup_goodSetCacheLength(piconfig->sharedClassCacheSize);
/* Verify if the group access has been set */
if (J9_ARE_ALL_BITS_SET(_openMode, J9OSCACHE_OPEN_MODE_GROUPACCESS)) {
I_32 groupAccessRc = verifyCacheFileGroupAccess(_portLibrary, _fileHandle, &lastErrorInfo);
if (0 == groupAccessRc) {
Trc_SHR_OSC_Mmap_startup_setGroupAccessFailed(_cachePathName);
OSC_WARNING_TRACE(J9NLS_SHRC_OSCACHE_MMAP_SET_GROUPACCESS_FAILED);
} else if (-1 == groupAccessRc) {
/* Failed to get stats of the cache file */
Trc_SHR_OSC_Mmap_startup_badFileStat(_cachePathName);
errorHandler(J9NLS_SHRC_OSCACHE_ERROR_FILE_STAT, &lastErrorInfo);
goto _errorPostHeaderLock;
}
}
rc = internalAttach(true, _activeGeneration);
if (0 != rc) {
errorCode = rc;
Trc_SHR_OSC_Mmap_startup_badAttach();
goto _errorPostAttach;
}
cacheHeader = (OSCachemmap_header_version_current *)_headerStart;
/* Create the cache header */
if (!createCacheHeader(cacheHeader, versionData)) {
Trc_SHR_OSC_Mmap_startup_badCreateCacheHeader();
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_ERROR_CREATING_CACHE_HEADER, NULL);
goto _errorPostAttach;
}
Trc_SHR_OSC_Mmap_startup_goodCreateCacheHeader();
if (initializer) {
if (!initializeDataHeader(initializer)) {
Trc_SHR_OSC_Mmap_startup_badInitializeDataHeader();
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_ERROR_INITIALISING_DATA_HEADER, NULL);
goto _errorPostAttach;
}
Trc_SHR_OSC_Mmap_startup_goodInitializeDataHeader();
}
if (_verboseFlags & J9SHR_VERBOSEFLAG_ENABLE_VERBOSE) {
OSC_TRACE1(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_CREATED, _cacheName);
}
}
if (creatingNewCache) {
OSCachemmap_header_version_current *cacheHeader = (OSCachemmap_header_version_current *)_headerStart;
cacheHeader->oscHdr.cacheInitComplete = 1;
}
/* Detach the memory-mapped area */
internalDetach(_activeGeneration);
/* Release cache header write lock */
if (0 != releaseHeaderWriteLock(_activeGeneration, &lastErrorInfo)) {
Trc_SHR_OSC_Mmap_startup_badReleaseHeaderWriteLock();
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_ERROR_RELEASING_HEADER_WRITE_LOCK, &lastErrorInfo);
goto _errorPostFileOpen;
}
Trc_SHR_OSC_Mmap_startup_goodReleaseHeaderWriteLock();
_exitForDestroy:
_finalised = 0;
_startupCompleted = true;
Trc_SHR_OSC_Mmap_startup_Exit();
return true;
_errorPostAttach :
internalDetach(_activeGeneration);
_errorPostHeaderLock :
releaseHeaderWriteLock(_activeGeneration, NULL);
_errorPostFileOpen :
closeCacheFile();
if (creatingNewCache) {
deleteCacheFile(NULL);
}
_errorPreFileOpen :
setError(errorCode);
return false;
}
/**
* Returns if the cache is accessible by current user or not
*
* @return enum SH_CacheAccess
*/
SH_CacheAccess
SH_OSCachemmap::isCacheAccessible(void) const
{
if (J9SH_CACHE_FILE_ACCESS_ALLOWED == _cacheFileAccess) {
return J9SH_CACHE_ACCESS_ALLOWED;
} else if (J9SH_CACHE_FILE_ACCESS_GROUP_ACCESS_REQUIRED == _cacheFileAccess) {
return J9SH_CACHE_ACCESS_ALLOWED_WITH_GROUPACCESS;
} else {
return J9SH_CACHE_ACCESS_NOT_ALLOWED;
}
}
/**
* Advise the OS to release resources used by a section of the shared classes cache
*/
void
SH_OSCachemmap::dontNeedMetadata(J9VMThread* currentThread, const void* startAddress, size_t length) {
/* AIX does not allow memory to be disclaimed for memory mapped files */
#if !defined(AIXPPC)
PORT_ACCESS_FROM_VMC(currentThread);
j9mmap_dont_need(startAddress, length);
#endif
}
/**
* Destroy a persistent shared classes cache
*
* @param[in] suppressVerbose suppresses verbose output
* @param[in] isReset True if reset option is being used, false otherwise.
*
* This method detaches from the cache, checks whether it is in use by any other
* processes and if not, deletes it from the filesystem
*
* @return 0 for success and -1 for failure
*/
IDATA
SH_OSCachemmap::destroy(bool suppressVerbose, bool isReset)
{
PORT_ACCESS_FROM_PORT(_portLibrary);
UDATA origVerboseFlags = _verboseFlags;
IDATA returnVal = -1; /* Assume failure */
LastErrorInfo lastErrorInfo;
Trc_SHR_OSC_Mmap_destroy_Entry();
if (suppressVerbose) {
_verboseFlags = 0;
}
if (_headerStart != NULL) {
detach();
}
if (!closeCacheFile()) {
Trc_SHR_OSC_Mmap_destroy_closefilefailed();
goto _done;
}
_mapFileHandle = 0;
_actualFileLength = 0;
Trc_SHR_OSC_Mmap_destroy_deletingfile(_cachePathName);
if (!deleteCacheFile(&lastErrorInfo)) {
Trc_SHR_OSC_Mmap_destroy_badunlink();
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_DESTROY_ERROR_DELETING_FILE, &lastErrorInfo);
goto _done;
}
Trc_SHR_OSC_Mmap_destroy_goodunlink();
if (_verboseFlags) {
if (isReset) {
OSC_TRACE1(J9NLS_SHRC_OSCACHE_MMAP_DESTROY_SUCCESS, _cacheName);
} else {
J9PortShcVersion versionData;
memset(&versionData, 0, sizeof(J9PortShcVersion));
/* Do not care about the getValuesFromShcFilePrefix() return value */
getValuesFromShcFilePrefix(PORTLIB, _cacheNameWithVGen, &versionData);
if (J9SH_FEATURE_COMPRESSED_POINTERS == versionData.feature) {
OSC_TRACE1(J9NLS_SHRC_OSCACHE_MMAP_DESTROY_SUCCESS_CR, _cacheName);
} else if (J9SH_FEATURE_NON_COMPRESSED_POINTERS == versionData.feature) {
OSC_TRACE1(J9NLS_SHRC_OSCACHE_MMAP_DESTROY_SUCCESS_NONCR, _cacheName);
} else {
OSC_TRACE1(J9NLS_SHRC_OSCACHE_MMAP_DESTROY_SUCCESS, _cacheName);
}
}
}
Trc_SHR_OSC_Mmap_destroy_finalising();
finalise();
returnVal = 0;
Trc_SHR_OSC_Mmap_destroy_Exit();
_done :
if (suppressVerbose) {
_verboseFlags = origVerboseFlags;
}
return returnVal;
}
/**
* Method to update the cache's last detached time, detach it from the
* process and clean up the object's resources. It is called when the
* cache is no longer required by the JVM.
*/
void
SH_OSCachemmap::cleanup()
{
Trc_SHR_OSC_Mmap_cleanup_Entry();
if (_finalised) {
Trc_SHR_OSC_Mmap_cleanup_alreadyfinalised();
return;
}
if (_headerStart) {
if (acquireHeaderWriteLock(_activeGeneration, NULL) != -1) {
if (updateLastDetachedTime()) {
Trc_SHR_OSC_Mmap_cleanup_goodUpdateLastDetachedTime();
} else {
Trc_SHR_OSC_Mmap_cleanup_badUpdateLastDetachedTime();
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_CLEANUP_ERROR_UPDATING_LAST_DETACHED_TIME, NULL);
}
if (releaseHeaderWriteLock(_activeGeneration, NULL) == -1) {
PORT_ACCESS_FROM_PORT(_portLibrary);
I_32 myerror = j9error_last_error_number();
Trc_SHR_OSC_Mmap_cleanup_releaseHeaderWriteLock_Failed(myerror);
Trc_SHR_Assert_ShouldNeverHappen();
}
} else {
PORT_ACCESS_FROM_PORT(_portLibrary);
I_32 myerror = j9error_last_error_number();
Trc_SHR_OSC_Mmap_cleanup_acquireHeaderWriteLock_Failed(myerror);
Trc_SHR_Assert_ShouldNeverHappen();
}
}
if (_headerStart) {
detach();
}
if (_fileHandle != -1) {
closeCacheFile();
}
finalise();
Trc_SHR_OSC_Mmap_cleanup_Exit();
return;
}
/*
* TODO:
* There follows a series methods for acquiring/releasing various read/write
* locks on the cache. These all contain very similar code and while they
* do not present a problem in their current form, it would probably be better
* to reduce them to a few basic methods and have them operate on an array of
* lock words.
*/
/**
* Get an ID for a write area lock
*
* @return a non-negative lockID on success
*/
IDATA SH_OSCachemmap::getWriteLockID()
{
return J9SH_OSCACHE_MMAP_LOCKID_WRITELOCK;
}
/**
* Get an ID for a readwrite area lock
*
* @return a non-negative lockID on success
*/
IDATA SH_OSCachemmap::getReadWriteLockID()
{
return J9SH_OSCACHE_MMAP_LOCKID_READWRITELOCK;
}
/**
* Method to acquire the write lock on the cache data region
*
* @return 0 on success, -1 on failure
*/
IDATA
SH_OSCachemmap::acquireWriteLock(UDATA lockID)
{
PORT_ACCESS_FROM_PORT(_portLibrary);
I_32 lockFlags = J9PORT_FILE_WRITE_LOCK | J9PORT_FILE_WAIT_FOR_LOCK;
U_64 lockOffset, lockLength;
I_32 rc = 0;
I_64 startLoopTime = 0;
I_64 endLoopTime = 0;
UDATA loopCount = 0;
Trc_SHR_OSC_Mmap_acquireWriteLock_Entry(lockID);
if ((lockID != J9SH_OSCACHE_MMAP_LOCKID_WRITELOCK) && (lockID != J9SH_OSCACHE_MMAP_LOCKID_READWRITELOCK)) {
Trc_SHR_OSC_Mmap_acquireWriteLock_BadLockID(lockID);
return -1;
}
lockOffset = offsetof(OSCachemmap_header_version_current, dataLocks) + (lockID * sizeof(I_32));
lockLength = sizeof(((OSCachemmap_header_version_current *)NULL)->dataLocks[0]);
/* We enter a local mutex before acquiring the file lock. This is because file
* locks only work between processes, whereas we need to lock between processes
* AND THREADS. So we use a local mutex to lock between threads of the same JVM,
* then a file lock for locking between different JVMs
*/
Trc_SHR_OSC_Mmap_acquireWriteLock_entering_monitor(lockID);
if (omrthread_monitor_enter(_lockMutex[lockID]) != 0) {
Trc_SHR_OSC_Mmap_acquireWriteLock_failed_monitor_enter(lockID);
return -1;
}
Trc_SHR_OSC_Mmap_acquireWriteLock_gettingLock(_fileHandle, lockFlags, lockOffset, lockLength);
#if defined(WIN32) || defined(WIN64)
rc = j9file_blockingasync_lock_bytes(_fileHandle, lockFlags, lockOffset, lockLength);
#else
rc = j9file_lock_bytes(_fileHandle, lockFlags, lockOffset, lockLength);
#endif
while ((rc == -1) && (j9error_last_error_number() == J9PORT_ERROR_FILE_LOCK_EDEADLK)) {
if (++loopCount > 1) {
/* We time the loop so it doesn't loop forever. Try the lock algorithm below
* once before starting the timer. */
if (startLoopTime == 0) {
startLoopTime = j9time_nano_time();
} else if (loopCount > 2) {
/* Loop at least twice */
endLoopTime = j9time_nano_time();
if ((endLoopTime - startLoopTime) > ((I_64)RETRY_OBTAIN_WRITE_LOCK_MAX_MS * NANOSECS_PER_MILLISEC)) {
break;
}
}
omrthread_nanosleep(RETRY_OBTAIN_WRITE_LOCK_SLEEP_NS);
}
/* CMVC 153095: there are only three states our locks may be in if EDEADLK is detected.
* We can recover from cases 2 & 3 (see comments inline below). For case 1 our only option
* is to exit and let the caller retry.
*/
if (lockID == J9SH_OSCACHE_MMAP_LOCKID_READWRITELOCK && omrthread_monitor_owned_by_self(_lockMutex[J9SH_OSCACHE_MMAP_LOCKID_WRITELOCK]) == 1) {
/* CMVC 153095: Case 1
* Current thread:
* - Owns W monitor, W lock, RW monitor, and gets EDADLK on RW lock
*
* Notes:
* - This means other JVMs caused EDEADLK because they are holding RW, and
* waiting on W in a sequence that gives fcntl the impression of deadlock
* - If current thread owns the W monitor, it must also own the W lock
* if the call stack ended up here.
*
* Recovery:
* - In this case we can't do anything but retry RW, because EDEADLK is caused by other JVMs.
*/
Trc_SHR_OSC_Mmap_acquireWriteLockDeadlockMsg("Case 1: Current thread owns W lock & monitor, and RW monitor, but EDEADLK'd on RW lock");
#if defined(WIN32) || defined(WIN64)
rc = j9file_blockingasync_lock_bytes(_fileHandle, lockFlags, lockOffset, lockLength);
#else
rc = j9file_lock_bytes(_fileHandle, lockFlags, lockOffset, lockLength);
#endif
} else if (lockID == J9SH_OSCACHE_MMAP_LOCKID_READWRITELOCK) {
/* CMVC 153095: Case 2
* Another thread:
* - Owns the W monitor, and is waiting on (or owns) the W lock
*
* Current thread:
* - Current thread owns the RW monitor, and gets EDEADLK on RW lock
*
* Note:
* - Deadlock might caused by the order in which threads have taken locks, when compared to another JVM.
* - In the recovery code below the first release of the RW Monitor is to ensure SCStoreTransactions
* can complete.
*
* Recovery
* - Recover by trying to take the W monitor, then RW monitor and lock. This will
* resolve any EDEADLK caused by this JVM, because it ensures no thread in this JVM will hold
* the W lock.
*/
Trc_SHR_OSC_Mmap_acquireWriteLockDeadlockMsg("Case 2: Current thread owns RW mon, but EDEADLK'd on RW lock");
omrthread_monitor_exit(_lockMutex[J9SH_OSCACHE_MMAP_LOCKID_READWRITELOCK]);
if (omrthread_monitor_enter(_lockMutex[J9SH_OSCACHE_MMAP_LOCKID_WRITELOCK]) != 0) {
Trc_SHR_OSC_Mmap_acquireWriteLock_errorTakingWriteMonitor();
return -1;
}
if (omrthread_monitor_enter(_lockMutex[J9SH_OSCACHE_MMAP_LOCKID_READWRITELOCK]) != 0) {
Trc_SHR_OSC_Mmap_acquireWriteLock_errorTakingWriteMonitor();
omrthread_monitor_exit(_lockMutex[J9SH_OSCACHE_MMAP_LOCKID_WRITELOCK]);
return -1;
}
#if defined(WIN32) || defined(WIN64)
rc = j9file_blockingasync_lock_bytes(_fileHandle, lockFlags, lockOffset, lockLength);
#else
rc = j9file_lock_bytes(_fileHandle, lockFlags, lockOffset, lockLength);
#endif
omrthread_monitor_exit(_lockMutex[J9SH_OSCACHE_MMAP_LOCKID_WRITELOCK]);
} else if (lockID == J9SH_OSCACHE_MMAP_LOCKID_WRITELOCK) {
/* CMVC 153095: Case 3
* Another thread:
* - Owns RW monitor, and is waiting on (or owns) the RW lock.
*
* Current thread:
* - Owns W monitor, and gets EDEADLK on W lock.
*
* Note:
* - If the 'call stack' ends up here then it is known the current thread
* does not own the ReadWrite lock. The shared classes code always
* takes the W lock, then RW lock, OR just the RW lock.
*
* Recovery:
* - In this case we recover by waiting on the RW monitor before taking the W lock. This will
* resolve any EDEADLK caused by this JVM, because it ensures no thread in this JVM will hold
* the RW lock.
*/
Trc_SHR_OSC_Mmap_acquireWriteLockDeadlockMsg("Case 3: Current thread owns W mon, but EDEADLK'd on W lock");
if (omrthread_monitor_enter(_lockMutex[J9SH_OSCACHE_MMAP_LOCKID_READWRITELOCK]) != 0) {
Trc_SHR_OSC_Mmap_acquireWriteLock_errorTakingReadWriteMonitor();
break;
}
#if defined(WIN32) || defined(WIN64)
rc = j9file_blockingasync_lock_bytes(_fileHandle, lockFlags, lockOffset, lockLength);
#else
rc = j9file_lock_bytes(_fileHandle, lockFlags, lockOffset, lockLength);
#endif
omrthread_monitor_exit(_lockMutex[J9SH_OSCACHE_MMAP_LOCKID_READWRITELOCK]);
} else {
Trc_SHR_Assert_ShouldNeverHappen();
}
}
if (rc == -1) {
Trc_SHR_OSC_Mmap_acquireWriteLock_badLock();
omrthread_monitor_exit(_lockMutex[lockID]);
} else {
Trc_SHR_OSC_Mmap_acquireWriteLock_goodLock();
}
Trc_SHR_OSC_Mmap_acquireWriteLock_Exit(rc);
return rc;
}
/**
* Method to release the write lock on the cache data region
*
* @return 0 on success, -1 on failure
*/
IDATA
SH_OSCachemmap::releaseWriteLock(UDATA lockID)
{
PORT_ACCESS_FROM_PORT(_portLibrary);
U_64 lockOffset, lockLength;
I_32 rc = 0;
Trc_SHR_OSC_Mmap_releaseWriteLock_Entry(lockID);
if (lockID >= J9SH_OSCACHE_MMAP_LOCK_COUNT) {
Trc_SHR_OSC_Mmap_releaseWriteLock_BadLockID(lockID);
return -1;
}
lockOffset = offsetof(OSCachemmap_header_version_current, dataLocks) + (lockID * sizeof(I_32));
lockLength = sizeof(((OSCachemmap_header_version_current *)NULL)->dataLocks[0]);
Trc_SHR_OSC_Mmap_releaseWriteLock_gettingLock(_fileHandle, lockOffset, lockLength);
#if defined(WIN32) || defined(WIN64)
rc = j9file_blockingasync_unlock_bytes(_fileHandle, lockOffset, lockLength);
#else
rc = j9file_unlock_bytes(_fileHandle, lockOffset, lockLength);
#endif
if (-1 == rc) {
Trc_SHR_OSC_Mmap_releaseWriteLock_badLock();
} else {
Trc_SHR_OSC_Mmap_releaseWriteLock_goodLock();
}
Trc_SHR_OSC_Mmap_releaseWriteLock_exiting_monitor(lockID);
if (omrthread_monitor_exit(_lockMutex[lockID]) != 0) {
Trc_SHR_OSC_Mmap_releaseWriteLock_bad_monitor_exit(lockID);
rc = -1;
}
Trc_SHR_OSC_Mmap_releaseWriteLock_Exit(rc);
return rc;
}
/**
* Get the createTime from the OSCache_header2
*
* @return the createTime
*/
U_64
SH_OSCachemmap::getCreateTime()
{
OSCachemmap_header_version_current *cacheHeader = (OSCachemmap_header_version_current *)_headerStart;
return cacheHeader->oscHdr.createTime;
}
/**
* Method to acquire the read lock on the cache attach region
*
* Needs to be able to work with all generations
*
* @param [in] generation The generation of the cache header to use when calculating the lock offset
*
* @return 0 on success, -1 on failure
*/
IDATA
SH_OSCachemmap::acquireAttachReadLock(UDATA generation, LastErrorInfo *lastErrorInfo)
{
PORT_ACCESS_FROM_PORT(_portLibrary);
I_32 lockFlags = J9PORT_FILE_READ_LOCK | J9PORT_FILE_WAIT_FOR_LOCK;
U_64 lockOffset, lockLength;
I_32 rc = 0;
Trc_SHR_OSC_Mmap_acquireAttachReadLock_Entry();
if (NULL != lastErrorInfo) {
lastErrorInfo->lastErrorCode = 0;
}
lockOffset = (U_64)getMmapHeaderFieldOffsetForGen(generation, OSCACHEMMAP_HEADER_FIELD_ATTACH_LOCK);
lockLength = sizeof(((OSCachemmap_header_version_current *)NULL)->attachLock);
Trc_SHR_OSC_Mmap_acquireAttachReadLock_gettingLock(_fileHandle, lockFlags, lockOffset, lockLength);
#if defined(WIN32) || defined(WIN64)
rc = j9file_blockingasync_lock_bytes(_fileHandle, lockFlags, lockOffset, lockLength);
#else
rc = j9file_lock_bytes(_fileHandle, lockFlags, lockOffset, lockLength);
#endif
if (-1 == rc) {
if (NULL != lastErrorInfo) {
lastErrorInfo->lastErrorCode = j9error_last_error_number();
lastErrorInfo->lastErrorMsg = j9error_last_error_message();
}
Trc_SHR_OSC_Mmap_acquireAttachReadLock_badLock();
} else {
Trc_SHR_OSC_Mmap_acquireAttachReadLock_goodLock();
}
Trc_SHR_OSC_Mmap_acquireAttachReadLock_Exit(rc);
return rc;
}
/**
* Method to release the read lock on the cache attach region
*
* Needs to be able to work with all generations
*
* @param [in] generation The generation of the cache header to use when calculating the lock offset
*
* @return 0 on success, -1 on failure
*/
IDATA
SH_OSCachemmap::releaseAttachReadLock(UDATA generation)
{
PORT_ACCESS_FROM_PORT(_portLibrary);
U_64 lockOffset, lockLength;
I_32 rc = 0;
Trc_SHR_OSC_Mmap_releaseAttachReadLock_Entry();
lockOffset = (U_64)getMmapHeaderFieldOffsetForGen(generation, OSCACHEMMAP_HEADER_FIELD_ATTACH_LOCK);
lockLength = sizeof(((OSCachemmap_header_version_current *)NULL)->attachLock);
Trc_SHR_OSC_Mmap_releaseAttachReadLock_gettingLock(_fileHandle, lockOffset, lockLength);
#if defined(WIN32) || defined(WIN64)
rc = j9file_blockingasync_unlock_bytes(_fileHandle, lockOffset, lockLength);
#else
rc = j9file_unlock_bytes(_fileHandle, lockOffset, lockLength);
#endif
if (-1 == rc) {
Trc_SHR_OSC_Mmap_releaseAttachReadLock_badLock();
} else {
Trc_SHR_OSC_Mmap_releaseAttachReadLock_goodLock();
}
Trc_SHR_OSC_Mmap_releaseAttachReadLock_Exit(rc);
return rc;
}
/*
* This function performs enough of an attach to start the cache, but nothing more
* The internalDetach function is the equivalent for detach
* isNewCache should be true if we're attaching to a completely uninitialized cache, false otherwise
* THREADING: Pre-req caller holds the cache header write lock
*
* Needs to be able to work with all generations
*
* @param [in] isNewCache true if the cache is new and we should calculate cache size using the file size;
* false if the cache is pre-existing and we can read the size fields from the cache header
* @param [in] generation The generation of the cache header to use when calculating the lock offset
*
* @return 0 on success, J9SH_OSCACHE_FAILURE on failure, J9SH_OSCACHE_CORRUPT for corrupt cache
*/
IDATA
SH_OSCachemmap::internalAttach(bool isNewCache, UDATA generation)
{
PORT_ACCESS_FROM_PORT(_portLibrary);
U_32 accessFlags = _runningReadOnly ? J9PORT_MMAP_FLAG_READ : J9PORT_MMAP_FLAG_WRITE;
LastErrorInfo lastErrorInfo;
IDATA rc = J9SH_OSCACHE_FAILURE;
Trc_SHR_OSC_Mmap_internalAttach_Entry();
/* Get current length of file */
accessFlags |= J9PORT_MMAP_FLAG_SHARED;
_actualFileLength = _cacheSize;
Trc_SHR_Assert_True(_actualFileLength > 0);
if (0 != acquireAttachReadLock(generation, &lastErrorInfo)) {
Trc_SHR_OSC_Mmap_internalAttach_badAcquireAttachedReadLock();
errorHandler(J9NLS_SHRC_OSCACHE_MMAP_STARTUP_ERROR_ACQUIRING_ATTACH_READ_LOCK, &lastErrorInfo);
rc = J9SH_OSCACHE_FAILURE;
goto error;
}
Trc_SHR_OSC_Mmap_internalAttach_goodAcquireAttachReadLock();
#ifndef WIN32
/* if the cache is read-only and not being written, no free disk space is required */
if (!_runningReadOnly && J9_ARE_NO_BITS_SET(_runtimeFlags, J9SHR_RUNTIMEFLAG_NO_PERSISTENT_DISK_SPACE_CHECK)) {
J9FileStatFilesystem fileStatFilesystem;
/* check for free disk space */
rc = j9file_stat_filesystem(_cachePathName, 0, &fileStatFilesystem);
if (0 == rc) {
if (fileStatFilesystem.freeSizeBytes < (U_64)_actualFileLength) {
OSC_ERR_TRACE2(J9NLS_SHRC_OSCACHE_MMAP_DISK_FULL, (U_64)fileStatFilesystem.freeSizeBytes, (U_64)_actualFileLength);
rc = J9SH_OSCACHE_FAILURE;
goto error;
}
}
}
#endif
#if defined(J9ZOS39064)