@@ -127,23 +127,17 @@ int dynamic_shared_memory_type;
127127 * map it.
128128 *
129129 * 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.
132130 *
133131 * DSM_OP_DETACH. Unmap the segment.
134132 *
135- * DSM_OP_RESIZE. Resize the segment to the given request_size and
136- * remap the segment at that new size.
137- *
138133 * DSM_OP_DESTROY. Unmap the segment, if it is mapped. Destroy the
139134 * segment.
140135 *
141136 * Arguments:
142137 * op: The operation to be performed.
143138 * handle: The handle of an existing object, or for DSM_OP_CREATE, the
144139 * 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.
147141 * impl_private: Private, implementation-specific data. Will be a pointer
148142 * to NULL for the first operation on a shared memory segment within this
149143 * 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,
165159 void * * impl_private , void * * mapped_address , Size * mapped_size ,
166160 int elevel )
167161{
168- Assert (op == DSM_OP_CREATE || op == DSM_OP_RESIZE || request_size == 0 );
162+ Assert (op == DSM_OP_CREATE || request_size == 0 );
169163 Assert ((op != DSM_OP_CREATE && op != DSM_OP_ATTACH ) ||
170164 (* mapped_address == NULL && * mapped_size == 0 ));
171165
@@ -198,31 +192,6 @@ dsm_impl_op(dsm_op op, dsm_handle handle, Size request_size,
198192 }
199193}
200194
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-
226195#ifdef USE_DSM_POSIX
227196/*
228197 * Operating system primitives to support POSIX shared memory.
@@ -296,7 +265,7 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, Size request_size,
296265
297266 /*
298267 * 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.
300269 */
301270 if (op == DSM_OP_ATTACH )
302271 {
@@ -319,16 +288,14 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, Size request_size,
319288 }
320289 request_size = st .st_size ;
321290 }
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 )
324292 {
325293 int save_errno ;
326294
327295 /* Back out what's already been done. */
328296 save_errno = errno ;
329297 close (fd );
330- if (op == DSM_OP_CREATE )
331- shm_unlink (name );
298+ shm_unlink (name );
332299 errno = save_errno ;
333300
334301 /*
@@ -346,35 +313,6 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, Size request_size,
346313 return false;
347314 }
348315
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-
378316 /* Map it. */
379317 address = mmap (NULL , request_size , PROT_READ | PROT_WRITE ,
380318 MAP_SHARED | MAP_HASSEMAPHORE | MAP_NOSYNC , fd , 0 );
@@ -457,10 +395,9 @@ dsm_impl_posix_resize(int fd, off_t size)
457395 * Operating system primitives to support System V shared memory.
458396 *
459397 * 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.
464401 */
465402static bool
466403dsm_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,
473410 char name [64 ];
474411 int * ident_cache ;
475412
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-
483413 /* Since resize isn't supported, reattach is a no-op. */
484414 if (op == DSM_OP_ATTACH && * mapped_address != NULL )
485415 return true;
@@ -670,13 +600,6 @@ dsm_impl_windows(dsm_op op, dsm_handle handle, Size request_size,
670600 char name [64 ];
671601 MEMORY_BASIC_INFORMATION info ;
672602
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-
680603 /* Since resize isn't supported, reattach is a no-op. */
681604 if (op == DSM_OP_ATTACH && * mapped_address != NULL )
682605 return true;
@@ -905,7 +828,7 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
905828
906829 /*
907830 * 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.
909832 */
910833 if (op == DSM_OP_ATTACH )
911834 {
@@ -928,24 +851,7 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
928851 }
929852 request_size = st .st_size ;
930853 }
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
949855 {
950856 /*
951857 * Allocate a buffer full of zeros.
@@ -985,8 +891,7 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
985891 /* Back out what's already been done. */
986892 save_errno = errno ;
987893 CloseTransientFile (fd );
988- if (op == DSM_OP_CREATE )
989- unlink (name );
894+ unlink (name );
990895 errno = save_errno ? save_errno : ENOSPC ;
991896
992897 ereport (elevel ,
@@ -997,35 +902,6 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
997902 }
998903 }
999904
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-
1029905 /* Map it. */
1030906 address = mmap (NULL , request_size , PROT_READ | PROT_WRITE ,
1031907 MAP_SHARED | MAP_HASSEMAPHORE | MAP_NOSYNC , fd , 0 );
0 commit comments