From 04e71c44e9103b111852f8a66c08d9b4107b2b87 Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Wed, 8 Jan 2025 16:14:43 -0800 Subject: [PATCH] feat: nometa option to disable bucket/object metadata This adds a NoMeta MetadataStorer that might be useful for read only filesystems that are populated with data not from the gateway. The limitation is that no incoming metadata is stored with the buckets or objects, and all buckets and objects will only have default metadata. --- backend/meta/none.go | 54 +++++++++++++++++++++++++++++++++++++++++ backend/meta/sidecar.go | 14 +++++++++++ cmd/versitygw/posix.go | 13 ++++++++++ 3 files changed, 81 insertions(+) create mode 100644 backend/meta/none.go diff --git a/backend/meta/none.go b/backend/meta/none.go new file mode 100644 index 00000000..f6e48447 --- /dev/null +++ b/backend/meta/none.go @@ -0,0 +1,54 @@ +// Copyright 2025 Versity Software +// This file is licensed under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package meta + +import ( + "os" +) + +// NoMeta is a metadata storer that does not store metadata. +// This can be useful for read only mounts where attempting to store metadata +// would fail. +type NoMeta struct{} + +// RetrieveAttribute retrieves the value of a specific attribute for an object or a bucket. +// always returns ErrNoSuchKey +func (NoMeta) RetrieveAttribute(_ *os.File, _, _, _ string) ([]byte, error) { + return nil, ErrNoSuchKey +} + +// StoreAttribute stores the value of a specific attribute for an object or a bucket. +// always returns nil without storing the attribute +func (NoMeta) StoreAttribute(_ *os.File, _, _, _ string, _ []byte) error { + return nil +} + +// DeleteAttribute removes the value of a specific attribute for an object or a bucket. +// always returns nil without deleting the attribute +func (NoMeta) DeleteAttribute(_, _, _ string) error { + return nil +} + +// ListAttributes lists all attributes for an object or a bucket. +// always returns an empty list of attributes +func (NoMeta) ListAttributes(_, _ string) ([]string, error) { + return []string{}, nil +} + +// DeleteAttributes removes all attributes for an object or a bucket. +// always returns nil without deleting any attributes +func (NoMeta) DeleteAttributes(bucket, object string) error { + return nil +} diff --git a/backend/meta/sidecar.go b/backend/meta/sidecar.go index cf196659..253d52c5 100644 --- a/backend/meta/sidecar.go +++ b/backend/meta/sidecar.go @@ -1,3 +1,17 @@ +// Copyright 2025 Versity Software +// This file is licensed under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + package meta import ( diff --git a/cmd/versitygw/posix.go b/cmd/versitygw/posix.go index 9ff81771..79d8fc0c 100644 --- a/cmd/versitygw/posix.go +++ b/cmd/versitygw/posix.go @@ -30,6 +30,7 @@ var ( versioningDir string dirPerms uint sidecar string + nometa bool ) func posixCommand() *cli.Command { @@ -86,6 +87,12 @@ will be translated into the file /mnt/fs/gwroot/mybucket/a/b/c/myobject`, EnvVars: []string{"VGW_META_SIDECAR"}, Destination: &sidecar, }, + &cli.BoolFlag{ + Name: "nometa", + Usage: "disable metadata storage", + EnvVars: []string{"VGW_META_NONE"}, + Destination: &nometa, + }, }, } } @@ -101,6 +108,10 @@ func runPosix(ctx *cli.Context) error { return fmt.Errorf("invalid directory permissions: %d", dirPerms) } + if nometa && sidecar != "" { + return fmt.Errorf("cannot use both nometa and sidecar metadata") + } + opts := posix.PosixOpts{ ChownUID: chownuid, ChownGID: chowngid, @@ -118,6 +129,8 @@ func runPosix(ctx *cli.Context) error { } ms = sc opts.SideCarDir = sidecar + case nometa: + ms = meta.NoMeta{} default: ms = meta.XattrMeta{} err := meta.XattrMeta{}.Test(gwroot)