Skip to content

Commit

Permalink
Add option for ZSTD compression
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenBrown2 committed Jul 12, 2023
1 parent 9fdeff3 commit 3a1705a
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/rockstor/fs/btrfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2333,7 +2333,7 @@ def get_property(mnt_pt, prop_name=None):
properties. But if called with a single property then the value and type
appropriate for that property ie:
string for label (in presented in properties),
string for compression ie: lzo, zlib (if presented in properties),
string for compression ie: lzo, zlib (if presented in properties), zstd,
and Boolean for prop_name='ro'
If prop_name specified but not found then None is returned.
N.B. compression property for subvol only, vol/pool uses mount option.
Expand Down
2 changes: 1 addition & 1 deletion src/rockstor/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@

CONFROOT = '{}/conf'.format(BASE_DIR)
CERTDIR = '{}/certs'.format(BASE_DIR)
COMPRESSION_TYPES = ('lzo', 'zlib', 'no',)
COMPRESSION_TYPES = ('lzo', 'zlib', 'zstd', 'no',)

SNAP_TS_FORMAT = '%Y%m%d%H%M'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<option value="no">Don't enable compression</option>
<option value="zlib">zlib</option>
<option value="lzo">lzo</option>
<option value="zstd">zstd</option>
</select>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
{{pool.compression}}
{{else}}
<strong>
<a href="#" id="comprOptn" data-type="select"
data-title="Pool compression algorithm.<br><strong>zlib: </strong>
slower than lzo but higher compression ratio.<br><strong>lzo: </strong>faster than zlib but lower compression ratio.<br>
Pool level compression applies to all it's Shares.<br>Alternatively: consider Share level compression.
<br>Unchanged data remains at prior setting until balanced."
>{{pool.compression}}
<a href="#" id="comprOptn" data-type="select" data-title="Pool compression algorithm.<br>
<strong>zlib: </strong>slower than LZO but higher compression ratio.<br>
<strong>lzo:</strong>faster compression and decompression than ZLIB, worse compression ratio, designed to be fast.<br>
<strong>zstd: </strong>compression comparable to ZLIB with higher compression/decompression speeds and different ratio.<br>
Pool level compression applies to all it's Shares.<br>
Alternatively: consider Share level compression.<br>
Unchanged data remains at prior setting until balanced.">
{{pool.compression}}
</a>
</strong>
{{/if}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@
{{this.compression}}
{{else}}
<strong><a href="#" class="cmpOptns" data-name="cmpOptns" data-type="select" data-mntoptn="{{this.mnt_options}}"
data-value="{{this.compression}}" data-pid="{{this.id}}" data-title="Pool compression algorithm.
<br><strong>zlib: </strong>slower than lzo but higher compression ratio.<br><strong>lzo: </strong>
faster than zlib but lower compression ratio.<br>Pool level compression applies to all it's Shares.
<br>Alternatively: consider Share level compression.<br>Unchanged data remains at prior setting
until balanced.">
data-value="{{this.compression}}" data-pid="{{this.id}}" data-title="Pool compression algorithm.<br>
<strong>zlib: </strong>slower than LZO but higher compression ratio.<br>
<strong>lzo:</strong>faster compression and decompression than ZLIB, worse compression ratio, designed to be fast.<br>
<strong>zstd: </strong>compression comparable to ZLIB with higher compression/decompression speeds and different ratio.<br>
Pool level compression applies to all it's Shares.<br>
Alternatively: consider Share level compression.<br>
Unchanged data remains at prior setting until balanced.">
{{this.compression}}</a></strong>
{{/if}}
</td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<option value="no">Inherit from pool wide configuration</option>
<option value="zlib">zlib</option>
<option value="lzo">lzo</option>
<option value="zstd">zstd</option>
</select>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ AddPoolView = Backbone.View.extend({
this.$('#compression').tooltip({
html: true,
placement: 'right',
title: 'Choose a Pool compression algorithm.<br><strong>zlib: </strong>slower than lzo but higher compression ratio.<br><strong>lzo: </strong>faster than zlib but lower compression ratio.<br>Pool level compression applies to all it\'s Shares.<br>Alternatively: consider Share level compression.<br>This setting can be changed at any time.'
title: 'Choose a Pool compression algorithm.<br><strong>zlib: </strong>slower than LZO but higher compression ratio.<br><strong>lzo:</strong>faster compression and decompression than ZLIB, worse compression ratio, designed to be fast.<br><strong>zstd: </strong>compression comparable to ZLIB with higher compression/decompression speeds and different ratio.<br>Pool level compression applies to all its Shares.<br>Alternatively: consider Share level compression.<br>This setting can be changed at any time.'
});

$('#add-pool-form').validate({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ AddShareView = Backbone.View.extend({
_this.$('#compression').tooltip({
html: true,
placement: 'right',
title: 'Choose a compression algorithm for this Share. By default, parent pool\'s compression algorithm is applied.<br> If you like to set pool wide compression, don\'t choose anything here. If you want finer control of this particular Share\'s compression algorithm, you can set it here.<br><strong>zlib: </strong>slower than lzo but higher compression ratio.<br><strong>lzo: </strong>faster than zlib but lower compression ratio.'
title: 'Choose a compression algorithm for this Share. By default, parent pool\'s compression algorithm is applied.<br> If you like to set pool wide compression, don\'t choose anything here. If you want finer control of this particular Share\'s compression algorithm, you can set it here.<br><strong>zlib: </strong>slower than LZO but higher compression ratio.<br><strong>lzo:</strong>faster compression and decompression than ZLIB, worse compression ratio, designed to be fast.<br><strong>zstd: </strong>compression comparable to ZLIB with higher compression/decompression speeds and different ratio.'
});

$('#add-share-form').validate({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ PoolDetailsLayoutView = RockstorLayoutView.extend({
this.cOpts = {
'no': 'Dont enable compression',
'zlib': 'zlib',
'zstd': 'zstd',
'lzo': 'lzo'
};
this.initHandlebarHelpers();
Expand Down Expand Up @@ -155,6 +156,7 @@ PoolDetailsLayoutView = RockstorLayoutView.extend({
source: [
{value: 'no', text: 'no'},
{value: 'zlib', text: 'zlib'},
{value: 'zstd', text: 'zstd'},
{value: 'lzo', text: 'lzo'}
],
success: function(response, newCompr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ PoolsView = RockstorLayoutView.extend({
source: [
{value: 'no', text: 'no'},
{value: 'zlib', text: 'zlib'},
{value: 'zstd', text: 'zstd'},
{value: 'lzo', text: 'lzo'}
],
success: function(response, newCompr){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ ShareDetailsLayoutView = RockstorLayoutView.extend({
this.cOpts = {
'no': 'Dont enable compression',
'zlib': 'zlib',
'zstd': 'zstd',
'lzo': 'lzo'
};
this.cView = this.options.cView;
Expand Down Expand Up @@ -348,7 +349,7 @@ ShareDetailsLayoutView = RockstorLayoutView.extend({
this.$('#ph-compression-info #compression').tooltip({
html: true,
placement: 'top',
title: 'Choose a compression algorithm for this Share. By default, parent pool\'s compression algorithm is applied.<br> If you like to set pool wide compression, don\'t choose anything here. If you want finer control of this particular Share\'s compression algorithm, you can set it here.<br><strong>zlib: </strong>slower than lzo but higher compression ratio.<br><strong>lzo: </strong>faster than zlib but lower compression ratio.'
title: 'Choose a compression algorithm for this Share. By default, parent pool\'s compression algorithm is applied.<br> If you like to set pool wide compression, don\'t choose anything here. If you want finer control of this particular Share\'s compression algorithm, you can set it here.<br><strong>zlib: </strong>slower than LZO but higher compression ratio.<br><strong>lzo:</strong>faster compression and decompression than ZLIB, worse compression ratio, designed to be fast.<br><strong>zstd: </strong>compression comparable to ZLIB with higher compression/decompression speeds and different ratio.'
});
},

Expand Down
12 changes: 11 additions & 1 deletion src/rockstor/storageadmin/tests/test_pools.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def test_compression(self):
- enable zlib
- disable lzo - compression-test-pool
- enable lzo
- change compression from lzo to zstd - compression-test-pool
"""

# create pool with invalid compression
Expand All @@ -453,7 +454,7 @@ def test_compression(self):
}
e_msg = (
"Unsupported compression algorithm (derp). "
"Use one of ('lzo', 'zlib', 'no')."
"Use one of ('lzo', 'zlib', 'zstd', 'no')."
)
response = self.client.post(self.BASE_URL, data=data)
self.assertEqual(
Expand Down Expand Up @@ -542,6 +543,15 @@ def test_compression(self):
self.assertEqual(response.status_code, status.HTTP_200_OK, msg=response.data)
self.assertEqual(response.data["compression"], "lzo")

# change compression from lzo to zstd on compression-test-pool
comp_zstd = {"compression": "zstd"}
# call remount pool command with new compression setting request (put)
response = self.client.put(
"{}/{}/remount".format(self.BASE_URL, pId), data=comp_zstd
)
self.assertEqual(response.status_code, status.HTTP_200_OK, msg=response.data)
self.assertEqual(response.data["compression"], "zstd")

def test_mount_options(self):
"""
Mount options are agnostic to other parameters such as compression.
Expand Down
11 changes: 10 additions & 1 deletion src/rockstor/storageadmin/tests/test_shares.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ def test_compression(self):
- enable zlib
- disable lzo
- enable lzo
- change compression from lzo to zstd
"""

# create share with invalid compression
Expand All @@ -457,7 +458,7 @@ def test_compression(self):
}
e_msg = (
"Unsupported compression algorithm (derp). "
"Use one of ('lzo', 'zlib', 'no')."
"Use one of ('lzo', 'zlib', 'zstd', 'no')."
)
response = self.client.post(self.BASE_URL, data=compression_test_share)
self.assertEqual(
Expand Down Expand Up @@ -531,6 +532,14 @@ def test_compression(self):
self.assertEqual(response8.status_code, status.HTTP_200_OK, msg=response8.data)
self.assertEqual(response8.data["compression_algo"], "lzo")

# change compression from lzo to zstd
compression_zstd = {"compression": "zstd"}
response9 = self.client.put(
"{}/{}".format(self.BASE_URL, sId), data=compression_zstd
)
self.assertEqual(response9.status_code, status.HTTP_200_OK, msg=response.data)
self.assertEqual(response9.data["compression_algo"], "zstd")

def test_delete_exported_replicated(self):
"""
Test DELETE request on share
Expand Down

0 comments on commit 3a1705a

Please sign in to comment.