Set the Swift max_file_size to 1/2 the loopback

Currently Devstack (and devstack gate) uses the default
max_file_size of for Swift (5GB). However the loopback file
is only 1 or 2 GB is size.

We are looking at setting a default FALLOCATE_RESERVE in swift
https://review.openstack.org/#/c/288011.
Because of this our max file size test fails due to the max_file_size
and devstacks loopback size being too small.

This patch sets this to a more sane size by default inside DevStack.
See the gerrit link above for more details.

Tempest uses a loopback of 6GB, so in this case the swift default of 5GB
should be fine.

Change-Id: If09eab7d16ae67bd252020e00e8812ff252f065b
diff --git a/lib/swift b/lib/swift
index b6c3ca4..8c5aa5e 100644
--- a/lib/swift
+++ b/lib/swift
@@ -71,17 +71,20 @@
     # only 1G we can not upload volume to image.
     # Increase Swift disk size up to 2G
     SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=2G
+    SWIFT_MAX_FILE_SIZE_DEFAULT=1073741824 # 1G
 else
     # DevStack will create a loop-back disk formatted as XFS to store the
     # swift data. Set ``SWIFT_LOOPBACK_DISK_SIZE`` to the disk size in
     # kilobytes.
     # Default is 1 gigabyte.
     SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=1G
+    SWIFT_MAX_FILE_SIZE_DEFAULT=536870912 # 512M
 fi
 
 # if tempest enabled the default size is 6 Gigabyte.
 if is_service_enabled tempest; then
     SWIFT_LOOPBACK_DISK_SIZE_DEFAULT=${SWIFT_LOOPBACK_DISK_SIZE:-6G}
+    SWIFT_MAX_FILE_SIZE_DEFAULT=5368709122 # Swift default 5G
 fi
 
 SWIFT_LOOPBACK_DISK_SIZE=${SWIFT_LOOPBACK_DISK_SIZE:-$SWIFT_LOOPBACK_DISK_SIZE_DEFAULT}
@@ -127,6 +130,10 @@
 # Swift API
 SWIFT_MAX_HEADER_SIZE=${SWIFT_MAX_HEADER_SIZE:-16384}
 
+# Set ``SWIFT_MAX_FILE_SIZE`` to configure the maximum file size in Swift API
+# Default 500MB because the loopback file used for swift could be 1 or 2 GB
+SWIFT_MAX_FILE_SIZE=${SWIFT_MAX_FILE_SIZE:-$SWIFT_MAX_FILE_SIZE_DEFAULT}
+
 # Set ``OBJECT_PORT_BASE``, ``CONTAINER_PORT_BASE``, ``ACCOUNT_PORT_BASE``
 # Port bases used in port number calculation for the service "nodes"
 # The specified port number will be used, the additional ports calculated by
@@ -462,6 +469,7 @@
     cp ${SWIFT_DIR}/etc/swift.conf-sample ${SWIFT_CONF_DIR}/swift.conf
     iniset ${SWIFT_CONF_DIR}/swift.conf swift-hash swift_hash_path_suffix ${SWIFT_HASH}
     iniset ${SWIFT_CONF_DIR}/swift.conf swift-constraints max_header_size ${SWIFT_MAX_HEADER_SIZE}
+    iniset ${SWIFT_CONF_DIR}/swift.conf swift-constraints max_file_size ${SWIFT_MAX_FILE_SIZE}
 
     local node_number
     for node_number in ${SWIFT_REPLICAS_SEQ}; do