Skip to content

Commit

Permalink
Merge pull request #849 from schakrava/687_qgroup_import_fs
Browse files Browse the repository at this point in the history
enable quota on imported pools. set qgroup on imported shares. Fixes …
  • Loading branch information
schakrava committed Sep 1, 2015
2 parents e4fa461 + 4126222 commit 546cb1b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
9 changes: 3 additions & 6 deletions src/rockstor/storageadmin/views/disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,15 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

from contextlib import contextmanager
from storageadmin.exceptions import RockStorAPIException

"""
Disk view, for anything at the disk level
"""

from rest_framework.response import Response
from django.db import transaction
from storageadmin.models import (Disk, Pool, Share)
from fs.btrfs import (scan_disks, wipe_disk, blink_disk, enable_quota,
btrfs_uuid, pool_usage, mount_root, get_pool_info,
pool_raid)
pool_raid, enable_quota)
from storageadmin.serializers import DiskInfoSerializer
from storageadmin.util import handle_exception
from share_helpers import (import_shares, import_snapshots)
Expand Down Expand Up @@ -201,6 +197,7 @@ def _btrfs_disk_import(self, dname, request):
po.raid = pool_raid('%s%s' % (settings.MNT_PT, po.name))['data']
po.size = pool_usage('%s%s' % (settings.MNT_PT, po.name))[0]
po.save()
enable_quota(po)
import_shares(po)
for share in Share.objects.filter(pool=po):
import_snapshots(share)
Expand Down
2 changes: 1 addition & 1 deletion src/rockstor/storageadmin/views/share.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def post(self, request):

#Before creating a new Share, we create the qgroup for it. And during
#it's creation, we assign this qgroup to it. During it's creation a 0/x
#qgroup will automatically be created, but it will be come the child of
#qgroup will automatically be created, but it will become the child of
#our explicitly-created qgroup(2015/x).

#We will set the qgroup limit on our qgroup and it will enforce the
Expand Down
9 changes: 6 additions & 3 deletions src/rockstor/storageadmin/views/share_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
from storageadmin.models import (Share, Disk, Snapshot, SFTP)
from smart_manager.models import ShareUsage
from fs.btrfs import (mount_share, mount_snap, is_share_mounted, is_mounted,
umount_root, shares_info, share_usage, snaps_info)
umount_root, shares_info, share_usage, snaps_info,
qgroup_create, update_quota)
from storageadmin.util import handle_exception

import logging
Expand Down Expand Up @@ -120,8 +121,10 @@ def import_shares(pool):
cshare.rusage, cshare.eusage = share_usage(pool, cshare.qgroup)
cshare.save()
except Share.DoesNotExist:
nso = Share(pool=pool, qgroup=shares_d[s], name=s, size=pool.size,
subvol_name=s)
pqid = qgroup_create(pool)
update_quota(pool, pqid, pool.size * 1024)
nso = Share(pool=pool, qgroup=shares_d[s], pqgroup=pqid, name=s,
size=pool.size, subvol_name=s)
nso.save()
mount_share(nso, '%s%s' % (settings.MNT_PT, s))

Expand Down

0 comments on commit 546cb1b

Please sign in to comment.