From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 339FA70603 for ; Thu, 24 Jun 2021 12:18:56 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 299E79CA5 for ; Thu, 24 Jun 2021 12:18:26 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 07FE69C9A for ; Thu, 24 Jun 2021 12:18:25 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id C907E46780 for ; Thu, 24 Jun 2021 12:18:24 +0200 (CEST) Date: Thu, 24 Jun 2021 12:18:16 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20210624100142.108334-1-w.bumiller@proxmox.com> In-Reply-To: <20210624100142.108334-1-w.bumiller@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1624529704.8e85r1vrn7.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.377 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URI_NOVOWEL 0.5 URI hostname has long non-vowel sequence Subject: Re: [pve-devel] [PATCH v3 storage 1/3] btrfs: support quota-based subvols optionally X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Jun 2021 10:18:56 -0000 On June 24, 2021 12:01 pm, Wolfgang Bumiller wrote: > Signed-off-by: Wolfgang Bumiller > --- > Difference to the main btrfs series v2: > * removed double-eval to catch errors when setting limits in > alloc_image > Note that the issue that subvols are created with size zero was an > issue in pve-container. > Volume resizing is fixed in patch 3 >=20 > PVE/Storage/BTRFSPlugin.pm | 93 +++++++++++++++++++++++--------------- > 1 file changed, 57 insertions(+), 36 deletions(-) >=20 > diff --git a/PVE/Storage/BTRFSPlugin.pm b/PVE/Storage/BTRFSPlugin.pm > index 5360dca..179186b 100644 > --- a/PVE/Storage/BTRFSPlugin.pm > +++ b/PVE/Storage/BTRFSPlugin.pm > @@ -57,6 +57,14 @@ sub properties { > type =3D> 'boolean', > default =3D> 0, > }, > + quotas =3D> { > + description =3D> "If enabled, containers will use subvolumes direct= ly, using quotas" > + . " for space accounting, instead of using ext4 formatted images files= ." > + . " While this removes a file system layer for containers, there is a = risk of" > + . " performance degrading over time.", > + type =3D> 'boolean', > + default =3D> 0, > + }, > }; > } > =20 > @@ -71,6 +79,7 @@ sub options { > format =3D> { optional =3D> 1 }, > is_mountpoint =3D> { optional =3D> 1 }, > nocow =3D> { optional =3D> 1 }, > + quotas =3D> { optional =3D> 1 }, > # TODO: The new variant of mkdir with `populate` vs `create`... > }; > } > @@ -336,27 +345,20 @@ sub alloc_image { > $path =3D "$subvol/disk.raw"; > } > =20 > - if ($fmt eq 'subvol' && !!$size) { > + if ($fmt eq 'subvol' && !!$size && !$scfg->{quotas}) { > # NOTE: `btrfs send/recv` actually drops quota information so supportin= g subvolumes with > # quotas doesn't play nice with send/recv. > - die "btrfs quotas are currently not supported, use an unsized subvolume= or a raw file\n"; > + die "btrfs quotas are currently disabled, use an unsized subvolume or a= raw file\n"; > } > =20 > $class->btrfs_cmd(['subvolume', 'create', '--', $subvol]); > =20 > eval { > if ($fmt eq 'subvol') { > - # Nothing to do for now... > - > - # This is how we *would* do it: > - # # Use the subvol's default 0/$id qgroup > - # eval { > - # # This call should happen at storage creation instead and the= refore governed by a > - # # configuration option! > - # # $class->btrfs_cmd(['quota', 'enable', $subvol]); > - # my $id =3D $class->btrfs_get_subvol_id($subvol); > - # $class->btrfs_cmd(['qgroup', 'limit', "${size}k", "0/$id", $s= ubvol]); > - # }; > + if (!!$size) { > + my $id =3D $class->btrfs_get_subvol_id($subvol); > + $class->btrfs_cmd(['qgroup', 'limit', "${size}k", "0/$id", $subvol]); > + } > } elsif ($fmt eq 'raw') { > sysopen my $fh, $path, O_WRONLY | O_CREAT | O_EXCL > or die "failed to create raw file '$path' - $!\n"; > @@ -434,27 +436,26 @@ sub free_image { > return undef; > } > =20 > -# Currently not used because quotas clash with send/recv. > -# my sub btrfs_subvol_quota { > -# my ($class, $path) =3D @_; > -# my $id =3D '0/' . $class->btrfs_get_subvol_id($path); > -# my $search =3D qr/^\Q$id\E\s+(\d)+\s+\d+\s+(\d+)\s*$/; > -# my ($used, $size); > -# $class->btrfs_cmd(['qgroup', 'show', '--raw', '-rf', '--', $path],= sub { > -# return if defined($size); > -# if ($_[0] =3D~ $search) { > -# ($used, $size) =3D ($1, $2); > -# } > -# }); > -# if (!defined($size)) { > -# # syslog should include more information: > -# syslog('err', "failed to get subvolume size for: $path (id $id)"); > -# # UI should only see the last path component: > -# $path =3D~ s|^.*/||; > -# die "failed to get subvolume size for $path\n"; > -# } > -# return wantarray ? ($used, $size) : $size; > -# } > +my sub btrfs_subvol_quota { > + my ($class, $path) =3D @_; > + my $id =3D '0/' . $class->btrfs_get_subvol_id($path); > + my $search =3D qr/^\Q$id\E\s+(\d)+\s+\d+\s+(\d+)\s*$/; > + my ($used, $size); > + $class->btrfs_cmd(['qgroup', 'show', '--raw', '-rf', '--', $path], s= ub { > + return if defined($size); > + if ($_[0] =3D~ $search) { > + ($used, $size) =3D ($1, $2); > + } > + }); > + if (!defined($size)) { > + # syslog should include more information: > + syslog('err', "failed to get subvolume size for: $path (id $id)"); this is still missing the use statement.. > + # UI should only see the last path component: > + $path =3D~ s|^.*/||; > + die "failed to get subvolume size for $path\n"; > + } > + return wantarray ? ($used, $size) : $size; > +} > =20 > sub volume_size_info { > my ($class, $scfg, $storeid, $volname, $timeout) =3D @_; > @@ -466,7 +467,9 @@ sub volume_size_info { > if ($format eq 'subvol') { > my $ctime =3D (stat($path))[10]; > my ($used, $size) =3D (0, 0); > - #my ($used, $size) =3D btrfs_subvol_quota($class, $path); # uses wantar= ray > + if ($scfg->{quotas}) { > + ($used, $size) =3D btrfs_subvol_quota($class, $path); > + } > return wantarray ? ($size, 'subvol', $used, undef, $ctime) : 1; > } > =20 > @@ -478,6 +481,9 @@ sub volume_resize { > =20 > my $format =3D ($class->parse_volname($volname))[6]; > if ($format eq 'subvol') { > + die "subvolumes can only be resized with quotas enabled\n" > + if !$scfg->{quotas}; > + > my $path =3D $class->filesystem_path($scfg, $volname); > my $id =3D '0/' . $class->btrfs_get_subvol_id($path); > $class->btrfs_cmd(['qgroup', 'limit', '--', "${size}k", "0/$id", $path]= ); > @@ -638,7 +644,9 @@ sub list_images { > ($size, $format, $used, $parent, $ctime) =3D PVE::Storage::Plugin::= file_size_info("$fn/disk.raw"); > } elsif ($ext eq 'subvol') { > ($used, $size) =3D (0, 0); > - #($used, $size) =3D btrfs_subvol_quota($class, $fn); > + if ($scfg->{quotas}) { > + ($used, $size) =3D btrfs_subvol_quota($class, $fn); > + } > $format =3D 'subvol'; > } else { > ($size, $format, $used, $parent, $ctime) =3D PVE::Storage::Plugin::= file_size_info($fn); > @@ -680,6 +688,9 @@ sub volume_export_formats { > my $format =3D ($class->parse_volname($volname))[6]; > return @result if $format ne 'raw' && $format ne 'subvol'; > =20 > + # Currently we don't allow using btrfs-send/recv with quotas on subv= olumes. > + return @result if $scfg->{quotas} && $format eq 'subvol'; > + > return ('btrfs', @result); > } > =20 > @@ -726,6 +737,11 @@ sub volume_export { > die "btrfs-sending volumes of type $volume_format ('$volname') is no= t supported\n" > if $volume_format ne 'raw' && $volume_format ne 'subvol'; > =20 > + if ($scfg->{quotas} && $format eq 'subvol') { > + die "btrfs-sending volumes of type $volume_format ('$volname') with quo= tas enabled is" > + . " currently not supported\n"; > + } > + > my $path =3D $class->path($scfg, $volname, $storeid); > =20 > if ($volume_format eq 'raw') { > @@ -782,6 +798,11 @@ sub volume_import { > die "btrfs-receiving volumes of type $volume_format ('$volname') is = not supported\n" > if $volume_format ne 'raw' && $volume_format ne 'subvol'; > =20 > + if ($scfg->{quotas} && $format eq 'subvol') { > + die "btrfs-receiving volumes of type $volume_format ('$volname') with q= uotas enabled is" > + . " currently not supported\n"; > + } > + > if (defined($base_snapshot)) { > my $path =3D $class->path($scfg, $volname, $storeid, $base_snapshot); > die "base snapshot '$base_snapshot' not found - no such directory '$pat= h'\n" > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20