Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
258 changes: 161 additions & 97 deletions src/rockstor/fs/btrfs.py

Large diffs are not rendered by default.

26 changes: 15 additions & 11 deletions src/rockstor/storageadmin/models/pool.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (c) 2012-2013 RockStor, Inc. <http://rockstor.com>
Copyright (c) 2012-2016 RockStor, Inc. <http://rockstor.com>
This file is part of RockStor.

RockStor is free software; you can redistribute it and/or modify
Expand All @@ -19,7 +19,8 @@
from django.db import models
from django.conf import settings
from smart_manager.models import PoolUsage
from fs.btrfs import pool_usage
from fs.btrfs import pool_usage, usage_bound


class Pool(models.Model):
"""Name of the pool"""
Expand All @@ -37,19 +38,22 @@ class Pool(models.Model):

@property
def free(self, *args, **kwargs):
#why do we compute pool usage on the fly like this and not like
#share usage as part of state refresh? This is a lot simpler and
#less code. For share usage, this type of logic could slow things
#down quite a bit because there can be 100's of Shares, but number
#of Pools even on a large instance is usually no more than a few.
try:
return pool_usage('%s%s' % (settings.MNT_PT, self.name))[2]
except:
return self.size
# Why do we compute pool usage on the fly like this and not like
# share usage as part of state refresh? This is a lot simpler and
# less code. For share usage, this type of logic could slow things
# down quite a bit because there can be 100's of Shares, but number
# of Pools even on a large instance is usually no more than a few.
return self.size - pool_usage('%s%s' % (settings.MNT_PT, self.name))

@property
def reclaimable(self, *args, **kwargs):
return 0

def usage_bound(self):
disk_sizes = [int(size) for size in self.disk_set
.values_list('size', flat=True)
.order_by('-size')]
return usage_bound(disk_sizes, len(disk_sizes), self.raid)

class Meta:
app_label = 'storageadmin'
Original file line number Diff line number Diff line change
@@ -1,105 +1,109 @@
<script>
/*
* Copyright (c) 2012-2013 RockStor, Inc. <http://rockstor.com>
* This file is part of RockStor.
*
* RockStor is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* RockStor is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
* Copyright (c) 2012-2016 RockStor, Inc. <http://rockstor.com>
* This file is part of RockStor.
*
* RockStor is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* RockStor is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
</script>

<div class="row">
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading">Create Pool</div>
<div class="panel-heading">Create Pool</div>

<div class="panel-body">
<form class="form-horizontal" name="add-pool-form" id="add-pool-form" >
<div class="messages"></div>
<div class="form-group">
<label class="col-sm-4 control-label" for="pool_name">Name<span class="required"> *</span></label>
<div class="col-sm-6">
<input class="form-control" type="text" name="pool_name" id="pool_name" title="Following characters are allowed: letter(a-z or A-Z), digit(0-9), hyphen(-), underscore(_) or a period(.). ">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="raid_level">Raid configuration<span class="required"> *</span></label>
<div class="col-sm-6">
<select class="form-control" id="raid_level" name="raid_level">
<option value="single">Single</option>
<option value="raid0">Raid0</option>
<option value="raid1">Raid1</option>
<option value="raid10">Raid10</option>
<option value="raid5">Raid5</option>
<option value="raid6">Raid6</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="compression">Compression</label>
<div class="col-sm-6">
<select class="form-control" id="compression" name="compression">
<option value="no">Dont enable compression</option>
<option value="zlib">zlib</option>
<option value="lzo">lzo</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="mnt_options">Mount options</label>
<div class="col-sm-6">
<input class="form-control" type="text" name="mnt_options" id="mnt_options" data-html="true" title="This is for <strong>Advanced users</strong> to provide specific BTRFS mount options.<br>Type them as a commma separated string of options without any spaces.<br> Allowed options are <strong>alloc_start, autodefrag, clear_cache, commit, compress-force, discard, fatal_errors, inode_cache, max_inline, metadata_ratio, noacl, noatime, nodatacow, nodatasum, nospace_cache, space_cache, ssd, nossd, ssd_spread, thread_pool</strong>">
</div>
</div>
<div id="SelectedDisksTable"> </div>
<div id="testTab"> </div>
<div class="form-group">
<label class="col-sm-4 control-label" for="disks">Select disks<span class="required"> *</span></label>
<div class="col-sm-6">
<div class="poolDiskTableScroll">
<table id="disks-table" class="table table-condensed table-bordered share-table tablesorter" summary="List of disks">
<thead>
<tr>
<th>No.</th>
<th>Disk Name</th>
<th>Capacity</th>
<th>Select all <input type="checkbox" id="checkAll"/></th>
</tr>
</thead>
<tbody>
{{#each disks}}
<tr>
<td>{{mathHelper @index}}</td>
<td>{{this.name}}</td>
<td>{{humanReadableSize this.size}}</td>
<td>
<input type="checkbox" class="disk" name="{{this.name}}" id="{{this.id}}" value="{{this.name}}" />
</td>
</tr>
{{/each}}
</tbody>
</table>
</div><!--poolDiskTableScroll-->
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<a id="js-cancel" class="btn btn-default" href="#">Cancel</a>
<input type="Submit" id="create_pool" class="btn btn-primary" value="Submit"></input>
</div>
</div>
</form>
<form class="form-horizontal" name="add-pool-form" id="add-pool-form" >
<div class="messages"></div>
<div class="form-group">
<label class="col-sm-4 control-label" for="pool_name">Name<span class="required"> *</span></label>
<div class="col-sm-6">
<input class="form-control" type="text" name="pool_name" id="pool_name" title="Following characters are allowed: letter(a-z or A-Z), digit(0-9), hyphen(-), underscore(_) or a period(.). ">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="raid_level">Raid configuration<span class="required"> *</span></label>
<div class="col-sm-6">
<select class="form-control" id="raid_level" name="raid_level">
<option value="single">Single</option>
<option value="raid0">Raid0</option>
<option value="raid1">Raid1</option>
<option value="raid10">Raid10</option>
<option value="raid5">Raid5</option>
<option value="raid6">Raid6</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="compression">Compression</label>
<div class="col-sm-6">
<select class="form-control" id="compression" name="compression">
<option value="no">Don't enable compression</option>
<option value="zlib">zlib</option>
<option value="lzo">lzo</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="mnt_options">Mount options</label>
<div class="col-sm-6">
<input class="form-control" type="text" name="mnt_options" id="mnt_options" data-html="true" title="This is for <strong>Advanced users</strong> to provide specific BTRFS mount options.<br>Type them as a commma separated string of options without any spaces.<br> Allowed options are <strong>alloc_start, autodefrag, clear_cache, commit, compress-force, discard, fatal_errors, inode_cache, max_inline, metadata_ratio, noacl, noatime, nodatacow, nodatasum, nospace_cache, space_cache, ssd, nossd, ssd_spread, thread_pool</strong>">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="disks">Select disks<span class="required"> *</span></label>
<div class="col-sm-6">
<div class="poolDiskTableScroll">
<table id="disks-table" class="table table-condensed table-bordered share-table tablesorter" summary="List of disks">
<thead>
<tr>
<th>No.</th>
<th>Disk Name</th>
<th>Capacity</th>
<th>Select all <input type="checkbox" id="checkAll"/></th>
</tr>
</thead>
<tbody>
{{#each disks}}
<tr>
<td>{{mathHelper @index}}</td>
<td>{{this.name}}</td>
<td>{{humanReadableSize this.size}}</td>
<td>
<input type="checkbox" class="disk" name="{{this.name}}" id="{{this.id}}" value="{{this.name}}" />
</td>
</tr>
{{/each}}
</tbody>
</table>
</div><!--poolDiskTableScroll-->
</div>
</div>
<div class=form-group>
<label class="col-sm-4 control-label">Selected disks summary</label>
<div class="col-sm-6">
<table id="selected-disks-table" class= "table table-condensed table-bordered share-table tablesorter"></table>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-8">
<a id="js-cancel" class="btn btn-default" href="#">Cancel</a>
<input type="Submit" id="create_pool" class="btn btn-primary" value="Submit"></input>
</div>
</div>
</form>
</div> <!-- panel-body -->
</div><!--panel-default-->
</div><!--col-md-8-->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{!<script>
/*
* Copyright (c) 2016 RockStor, Inc. <http://rockstor.com>
* This file is part of RockStor.
*
* RockStor is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License,
* or (at your option) any later version.
*
* RockStor is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
</script>}}

<tbody>
{{#if data}}
{{#each data}}
<tr>
<td>{{count}} x {{size}}</td>
<td>{{sum}}</td>
</tr>
{{/each}}
<tr>
<td><b>Total Raw Capacity</b></td>
<td style="color:#EB6841;"><b>{{total}}</b></td>
</tr>
<tr>
<td><b>Total Usable Capacity</b></td>
<td id="usable"><b>Retrieving...</b></td>
</tr>
{{else}}
<td>No disks selected.</td>
{{/if}}
</tbody>
Loading