*: reflow comments to 80 characters
This reformats the entire Metropolis codebase to have comments no longer
than 80 characters, implementing CR/66.
This has been done half manually, as we don't have a good integration
between commentwrap/Bazel, but that can be implemented if we decide to
go for this tool/limit.
Change-Id: If1fff0b093ef806f5dc00551c11506e8290379d0
diff --git a/metropolis/pkg/fsquota/fsinfo.go b/metropolis/pkg/fsquota/fsinfo.go
index f885d51..ecbaecf 100644
--- a/metropolis/pkg/fsquota/fsinfo.go
+++ b/metropolis/pkg/fsquota/fsinfo.go
@@ -24,9 +24,9 @@
"golang.org/x/sys/unix"
)
-// This requires fsinfo() support, which is not yet in any stable kernel.
-// Our kernel has that syscall backported. This would otherwise be an extremely expensive
-// operation and also involve lots of logic from our side.
+// This requires fsinfo() support, which is not yet in any stable kernel. Our
+// kernel has that syscall backported. This would otherwise be an extremely
+// expensive operation and also involve lots of logic from our side.
// From syscall_64.tbl
const sys_fsinfo = 441
diff --git a/metropolis/pkg/fsquota/fsquota.go b/metropolis/pkg/fsquota/fsquota.go
index 3c0c578..263dd48 100644
--- a/metropolis/pkg/fsquota/fsquota.go
+++ b/metropolis/pkg/fsquota/fsquota.go
@@ -14,11 +14,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-// Package fsquota provides a simplified interface to interact with Linux's filesystem qouta API.
-// It only supports setting quotas on directories, not groups or users.
-// Quotas need to be already enabled on the filesystem to be able to use them using this package.
-// See the quotactl package if you intend to use this on a filesystem where quotas need to be
-// enabled manually.
+// Package fsquota provides a simplified interface to interact with Linux's
+// filesystem qouta API. It only supports setting quotas on directories, not
+// groups or users. Quotas need to be already enabled on the filesystem to be
+// able to use them using this package. See the quotactl package if you intend
+// to use this on a filesystem where quotas need to be enabled manually.
package fsquota
import (
@@ -32,10 +32,11 @@
"source.monogon.dev/metropolis/pkg/fsquota/quotactl"
)
-// SetQuota sets the quota of bytes and/or inodes in a given path. To not set a limit, set the
-// corresponding argument to zero. Setting both arguments to zero removes the quota entirely.
-// This function can only be called on an empty directory. It can't be used to create a quota
-// below a directory which already has a quota since Linux doesn't offer hierarchical quotas.
+// SetQuota sets the quota of bytes and/or inodes in a given path. To not set a
+// limit, set the corresponding argument to zero. Setting both arguments to
+// zero removes the quota entirely. This function can only be called on an
+// empty directory. It can't be used to create a quota below a directory which
+// already has a quota since Linux doesn't offer hierarchical quotas.
func SetQuota(path string, maxBytes uint64, maxInodes uint64) error {
dir, err := os.Open(path)
if err != nil {
@@ -61,10 +62,12 @@
var lastID uint32 = attrs.ProjectID
if lastID == 0 {
- // No project/quota exists for this directory, assign a new project quota
- // TODO(lorenz): This is racy, but the kernel does not support atomically assigning
- // quotas. So this needs to be added to the kernels setquota interface. Due to the short
- // time window and infrequent calls this should not be an immediate issue.
+ // No project/quota exists for this directory, assign a new project
+ // quota.
+ // TODO(lorenz): This is racy, but the kernel does not support
+ // atomically assigning quotas. So this needs to be added to the
+ // kernels setquota interface. Due to the short time window and
+ // infrequent calls this should not be an immediate issue.
for {
quota, err := quotactl.GetNextQuota(source, quotactl.QuotaTypeProject, lastID)
if err == unix.ENOENT || err == unix.ESRCH {
@@ -115,7 +118,8 @@
InodesUsed uint64
}
-// GetQuota returns the current active quota and its utilization at the given path
+// GetQuota returns the current active quota and its utilization at the given
+// path
func GetQuota(path string) (*Quota, error) {
dir, err := os.Open(path)
if err != nil {
diff --git a/metropolis/pkg/fsquota/fsquota_test.go b/metropolis/pkg/fsquota/fsquota_test.go
index 4729dac..392a0e9 100644
--- a/metropolis/pkg/fsquota/fsquota_test.go
+++ b/metropolis/pkg/fsquota/fsquota_test.go
@@ -29,9 +29,9 @@
"golang.org/x/sys/unix"
)
-// withinTolerance is a helper for asserting that a value is within a certain percentage of the
-// expected value. The tolerance is specified as a float between 0 (exact match)
-// and 1 (between 0 and twice the expected value).
+// withinTolerance is a helper for asserting that a value is within a certain
+// percentage of the expected value. The tolerance is specified as a float
+// between 0 (exact match) and 1 (between 0 and twice the expected value).
func withinTolerance(t *testing.T, expected uint64, actual uint64, tolerance float64, name string) {
t.Helper()
delta := uint64(math.Round(float64(expected) * tolerance))
@@ -131,8 +131,9 @@
require.Equal(t, uint64(bytesQuota), quotaUtil.Bytes, "bytes quota readback incorrect")
require.Equal(t, uint64(inodesQuota), quotaUtil.Inodes, "inodes quota readback incorrect")
- // Give 10% tolerance for quota used values to account for metadata overhead and internal
- // structures that are also in there. If it's out by more than that it's an issue anyways.
+ // Give 10% tolerance for quota used values to account for metadata
+ // overhead and internal structures that are also in there. If it's out
+ // by more than that it's an issue anyways.
withinTolerance(t, uint64(len(sizeFileData)), quotaUtil.BytesUsed, 0.1, "BytesUsed")
// Write 50 inodes for a total of 51 (with the 512K file)
diff --git a/metropolis/pkg/fsquota/quotactl/quotactl.go b/metropolis/pkg/fsquota/quotactl/quotactl.go
index a2edfa7..337daaa 100644
--- a/metropolis/pkg/fsquota/quotactl/quotactl.go
+++ b/metropolis/pkg/fsquota/quotactl/quotactl.go
@@ -14,9 +14,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-// Package quotactl implements a low-level wrapper around the modern portion of Linux's
-// quotactl() syscall. See the fsquota package for a nicer interface to the most common part
-// of this API.
+// Package quotactl implements a low-level wrapper around the modern portion of
+// Linux's quotactl() syscall. See the fsquota package for a nicer interface to
+// the most common part of this API.
package quotactl
import (
@@ -212,7 +212,8 @@
return nil
}
-// Sync syncs disk copy of filesystems quotas. If device is empty it syncs all filesystems.
+// Sync syncs disk copy of filesystems quotas. If device is empty it syncs all
+// filesystems.
func Sync(device string) error {
if device != "" {
devArg, err := unix.BytePtrFromString(device)