@@ -127,23 +127,17 @@ int dynamic_shared_memory_type;
127
127
* map it.
128
128
*
129
129
* DSM_OP_ATTACH. Map the segment, whose size must be the request_size.
130
- * The segment may already be mapped; any existing mapping should be removed
131
- * before creating a new one.
132
130
*
133
131
* DSM_OP_DETACH. Unmap the segment.
134
132
*
135
- * DSM_OP_RESIZE. Resize the segment to the given request_size and
136
- * remap the segment at that new size.
137
- *
138
133
* DSM_OP_DESTROY. Unmap the segment, if it is mapped. Destroy the
139
134
* segment.
140
135
*
141
136
* Arguments:
142
137
* op: The operation to be performed.
143
138
* handle: The handle of an existing object, or for DSM_OP_CREATE, the
144
139
* a new handle the caller wants created.
145
- * request_size: For DSM_OP_CREATE, the requested size. For DSM_OP_RESIZE,
146
- * the new size. Otherwise, 0.
140
+ * request_size: For DSM_OP_CREATE, the requested size. Otherwise, 0.
147
141
* impl_private: Private, implementation-specific data. Will be a pointer
148
142
* to NULL for the first operation on a shared memory segment within this
149
143
* backend; thereafter, it will point to the value to which it was set
@@ -165,7 +159,7 @@ dsm_impl_op(dsm_op op, dsm_handle handle, Size request_size,
165
159
void * * impl_private , void * * mapped_address , Size * mapped_size ,
166
160
int elevel )
167
161
{
168
- Assert (op == DSM_OP_CREATE || op == DSM_OP_RESIZE || request_size == 0 );
162
+ Assert (op == DSM_OP_CREATE || request_size == 0 );
169
163
Assert ((op != DSM_OP_CREATE && op != DSM_OP_ATTACH ) ||
170
164
(* mapped_address == NULL && * mapped_size == 0 ));
171
165
@@ -198,31 +192,6 @@ dsm_impl_op(dsm_op op, dsm_handle handle, Size request_size,
198
192
}
199
193
}
200
194
201
- /*
202
- * Does the current dynamic shared memory implementation support resizing
203
- * segments? (The answer here could be platform-dependent in the future,
204
- * since AIX allows shmctl(shmid, SHM_RESIZE, &buffer), though you apparently
205
- * can't resize segments to anything larger than 256MB that way. For now,
206
- * we keep it simple.)
207
- */
208
- bool
209
- dsm_impl_can_resize (void )
210
- {
211
- switch (dynamic_shared_memory_type )
212
- {
213
- case DSM_IMPL_POSIX :
214
- return true;
215
- case DSM_IMPL_SYSV :
216
- return false;
217
- case DSM_IMPL_WINDOWS :
218
- return false;
219
- case DSM_IMPL_MMAP :
220
- return true;
221
- default :
222
- return false; /* should not happen */
223
- }
224
- }
225
-
226
195
#ifdef USE_DSM_POSIX
227
196
/*
228
197
* Operating system primitives to support POSIX shared memory.
@@ -296,7 +265,7 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, Size request_size,
296
265
297
266
/*
298
267
* If we're attaching the segment, determine the current size; if we are
299
- * creating or resizing the segment, set the size to the requested value.
268
+ * creating the segment, set the size to the requested value.
300
269
*/
301
270
if (op == DSM_OP_ATTACH )
302
271
{
@@ -319,16 +288,14 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, Size request_size,
319
288
}
320
289
request_size = st .st_size ;
321
290
}
322
- else if (* mapped_size != request_size &&
323
- dsm_impl_posix_resize (fd , request_size ) != 0 )
291
+ else if (dsm_impl_posix_resize (fd , request_size ) != 0 )
324
292
{
325
293
int save_errno ;
326
294
327
295
/* Back out what's already been done. */
328
296
save_errno = errno ;
329
297
close (fd );
330
- if (op == DSM_OP_CREATE )
331
- shm_unlink (name );
298
+ shm_unlink (name );
332
299
errno = save_errno ;
333
300
334
301
/*
@@ -346,35 +313,6 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, Size request_size,
346
313
return false;
347
314
}
348
315
349
- /*
350
- * If we're reattaching or resizing, we must remove any existing mapping,
351
- * unless we've already got the right thing mapped.
352
- */
353
- if (* mapped_address != NULL )
354
- {
355
- if (* mapped_size == request_size )
356
- return true;
357
- if (munmap (* mapped_address , * mapped_size ) != 0 )
358
- {
359
- int save_errno ;
360
-
361
- /* Back out what's already been done. */
362
- save_errno = errno ;
363
- close (fd );
364
- if (op == DSM_OP_CREATE )
365
- shm_unlink (name );
366
- errno = save_errno ;
367
-
368
- ereport (elevel ,
369
- (errcode_for_dynamic_shared_memory (),
370
- errmsg ("could not unmap shared memory segment \"%s\": %m" ,
371
- name )));
372
- return false;
373
- }
374
- * mapped_address = NULL ;
375
- * mapped_size = 0 ;
376
- }
377
-
378
316
/* Map it. */
379
317
address = mmap (NULL , request_size , PROT_READ | PROT_WRITE ,
380
318
MAP_SHARED | MAP_HASSEMAPHORE | MAP_NOSYNC , fd , 0 );
@@ -457,10 +395,9 @@ dsm_impl_posix_resize(int fd, off_t size)
457
395
* Operating system primitives to support System V shared memory.
458
396
*
459
397
* System V shared memory segments are manipulated using shmget(), shmat(),
460
- * shmdt(), and shmctl(). There's no portable way to resize such
461
- * segments. As the default allocation limits for System V shared memory
462
- * are usually quite low, the POSIX facilities may be preferable; but
463
- * those are not supported everywhere.
398
+ * shmdt(), and shmctl(). As the default allocation limits for System V
399
+ * shared memory are usually quite low, the POSIX facilities may be
400
+ * preferable; but those are not supported everywhere.
464
401
*/
465
402
static bool
466
403
dsm_impl_sysv (dsm_op op , dsm_handle handle , Size request_size ,
@@ -473,13 +410,6 @@ dsm_impl_sysv(dsm_op op, dsm_handle handle, Size request_size,
473
410
char name [64 ];
474
411
int * ident_cache ;
475
412
476
- /* Resize is not supported for System V shared memory. */
477
- if (op == DSM_OP_RESIZE )
478
- {
479
- elog (elevel , "System V shared memory segments cannot be resized" );
480
- return false;
481
- }
482
-
483
413
/* Since resize isn't supported, reattach is a no-op. */
484
414
if (op == DSM_OP_ATTACH && * mapped_address != NULL )
485
415
return true;
@@ -670,13 +600,6 @@ dsm_impl_windows(dsm_op op, dsm_handle handle, Size request_size,
670
600
char name [64 ];
671
601
MEMORY_BASIC_INFORMATION info ;
672
602
673
- /* Resize is not supported for Windows shared memory. */
674
- if (op == DSM_OP_RESIZE )
675
- {
676
- elog (elevel , "Windows shared memory segments cannot be resized" );
677
- return false;
678
- }
679
-
680
603
/* Since resize isn't supported, reattach is a no-op. */
681
604
if (op == DSM_OP_ATTACH && * mapped_address != NULL )
682
605
return true;
@@ -905,7 +828,7 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
905
828
906
829
/*
907
830
* If we're attaching the segment, determine the current size; if we are
908
- * creating or resizing the segment, set the size to the requested value.
831
+ * creating the segment, set the size to the requested value.
909
832
*/
910
833
if (op == DSM_OP_ATTACH )
911
834
{
@@ -928,24 +851,7 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
928
851
}
929
852
request_size = st .st_size ;
930
853
}
931
- else if (* mapped_size > request_size && ftruncate (fd , request_size ))
932
- {
933
- int save_errno ;
934
-
935
- /* Back out what's already been done. */
936
- save_errno = errno ;
937
- CloseTransientFile (fd );
938
- if (op == DSM_OP_CREATE )
939
- unlink (name );
940
- errno = save_errno ;
941
-
942
- ereport (elevel ,
943
- (errcode_for_dynamic_shared_memory (),
944
- errmsg ("could not resize shared memory segment \"%s\" to %zu bytes: %m" ,
945
- name , request_size )));
946
- return false;
947
- }
948
- else if (* mapped_size < request_size )
854
+ else
949
855
{
950
856
/*
951
857
* Allocate a buffer full of zeros.
@@ -985,8 +891,7 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
985
891
/* Back out what's already been done. */
986
892
save_errno = errno ;
987
893
CloseTransientFile (fd );
988
- if (op == DSM_OP_CREATE )
989
- unlink (name );
894
+ unlink (name );
990
895
errno = save_errno ? save_errno : ENOSPC ;
991
896
992
897
ereport (elevel ,
@@ -997,35 +902,6 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
997
902
}
998
903
}
999
904
1000
- /*
1001
- * If we're reattaching or resizing, we must remove any existing mapping,
1002
- * unless we've already got the right thing mapped.
1003
- */
1004
- if (* mapped_address != NULL )
1005
- {
1006
- if (* mapped_size == request_size )
1007
- return true;
1008
- if (munmap (* mapped_address , * mapped_size ) != 0 )
1009
- {
1010
- int save_errno ;
1011
-
1012
- /* Back out what's already been done. */
1013
- save_errno = errno ;
1014
- CloseTransientFile (fd );
1015
- if (op == DSM_OP_CREATE )
1016
- unlink (name );
1017
- errno = save_errno ;
1018
-
1019
- ereport (elevel ,
1020
- (errcode_for_dynamic_shared_memory (),
1021
- errmsg ("could not unmap shared memory segment \"%s\": %m" ,
1022
- name )));
1023
- return false;
1024
- }
1025
- * mapped_address = NULL ;
1026
- * mapped_size = 0 ;
1027
- }
1028
-
1029
905
/* Map it. */
1030
906
address = mmap (NULL , request_size , PROT_READ | PROT_WRITE ,
1031
907
MAP_SHARED | MAP_HASSEMAPHORE | MAP_NOSYNC , fd , 0 );
0 commit comments