Skip to content

Commit

Permalink
Fix rebase artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Mar 1, 2021
1 parent 300bf45 commit 0815066
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 98 deletions.
32 changes: 0 additions & 32 deletions pkg/storage/fs/ocis/ocis_unix.go

This file was deleted.

36 changes: 0 additions & 36 deletions pkg/storage/fs/ocis/ocis_windows.go

This file was deleted.

16 changes: 8 additions & 8 deletions pkg/storage/utils/decomposedfs/decomposed.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,26 @@ func (fs *Decomposedfs) Shutdown(ctx context.Context) error {
// GetQuota returns the quota available
// TODO Document in the cs3 should we return quota or free space?
func (fs *Decomposedfs) GetQuota(ctx context.Context) (uint64, uint64, error) {
var node *node.Node
var n *node.Node
var err error
if node, err = fs.lu.HomeOrRootNode(ctx); err != nil {
if n, err = fs.lu.HomeOrRootNode(ctx); err != nil {
return 0, 0, err
}

if !node.Exists {
err = errtypes.NotFound(filepath.Join(node.ParentID, node.Name))
if !n.Exists {
err = errtypes.NotFound(filepath.Join(n.ParentID, n.Name))
return 0, 0, err
}

rp, err := fs.p.AssemblePermissions(ctx, node)
rp, err := fs.p.AssemblePermissions(ctx, n)
switch {
case err != nil:
return 0, 0, errtypes.InternalError(err.Error())
case !rp.GetQuota:
return 0, 0, errtypes.PermissionDenied(node.ID)
return 0, 0, errtypes.PermissionDenied(n.ID)
}

ri, err := node.AsResourceInfo(ctx, rp, []string{"treesize", "quota"})
ri, err := n.AsResourceInfo(ctx, rp, []string{"treesize", "quota"})
if err != nil {
return 0, 0, err
}
Expand All @@ -155,7 +155,7 @@ func (fs *Decomposedfs) GetQuota(ctx context.Context) (uint64, uint64, error) {
quotaStr = string(ri.Opaque.Map["quota"].Value)
}
stat := syscall.Statfs_t{}
err = syscall.Statfs(fs.lu.toInternalPath(node.ID), &stat)
err = syscall.Statfs(n.InternalPath(), &stat)
if err != nil {
return 0, 0, err
}
Expand Down
23 changes: 7 additions & 16 deletions pkg/storage/utils/decomposedfs/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,22 +534,13 @@ func (n *Node) AsResourceInfo(ctx context.Context, rp *provider.ResourcePermissi
readChecksumIntoOpaque(ctx, nodePath, storageprovider.XSAdler32, ri)
}
// quota
if _, ok := mdKeysMap[_quotaKey]; (nodeType == provider.ResourceType_RESOURCE_TYPE_CONTAINER) && returnAllKeys || ok {
if _, ok := mdKeysMap[QuotaKey]; (nodeType == provider.ResourceType_RESOURCE_TYPE_CONTAINER) && returnAllKeys || ok {
var quotaPath string
if n.lu.Options.EnableHome {
if r, err := n.lu.HomeNode(ctx); err == nil {
quotaPath = n.lu.toInternalPath(r.ID)
readQuotaIntoOpaque(ctx, quotaPath, ri)
} else {
sublog.Error().Err(err).Msg("error determining home node for quota")
}
if r, err := n.lu.HomeOrRootNode(ctx); err == nil {
quotaPath = r.InternalPath()
readQuotaIntoOpaque(ctx, quotaPath, ri)
} else {
if r, err := n.lu.RootNode(ctx); err == nil {
quotaPath = n.lu.toInternalPath(r.ID)
readQuotaIntoOpaque(ctx, quotaPath, ri)
} else {
sublog.Error().Err(err).Msg("error determining root node for quota")
}
sublog.Error().Err(err).Msg("error determining home or root node for quota")
}
}

Expand Down Expand Up @@ -643,7 +634,7 @@ func readQuotaIntoOpaque(ctx context.Context, nodePath string, ri *provider.Reso
Map: map[string]*types.OpaqueEntry{},
}
}
ri.Opaque.Map[_quotaKey] = &types.OpaqueEntry{
ri.Opaque.Map[QuotaKey] = &types.OpaqueEntry{
Decoder: "plain",
Value: v,
}
Expand Down Expand Up @@ -690,7 +681,7 @@ func (n *Node) CalculateTreeSize(ctx context.Context) (uint64, error) {
// read from attr
var b []byte
// xattr.Get will follow the symlink
if b, err = xattr.Get(cPath, treesizeAttr); err != nil {
if b, err = xattr.Get(cPath, xattrs.TreesizeAttr); err != nil {
// TODO recursively descend and recalculate treesize
continue // continue after an error
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/storage/utils/decomposedfs/tree/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,17 +487,16 @@ func (t *Tree) Propagate(ctx context.Context, n *node.Node) (err error) {
sublog.Error().Err(err).Time("tmtime", sTime).Msg("could not update tmtime of parent node")
} else {
sublog.Debug().Time("tmtime", sTime).Msg("updated tmtime of parent node")
} }
}
}

if err := n.UnsetTempEtag(); err != nil {
sublog.Error().Err(err).Msg("could not remove temporary etag attribute")
}

}

// size accounting
if t.lu.Options.TreeSizeAccounting {
if t.treeSizeAccounting {
// update the treesize if it differs from the current size
updateTreeSize := false

Expand Down Expand Up @@ -526,7 +525,6 @@ func (t *Tree) Propagate(ctx context.Context, n *node.Node) (err error) {
Msg("parent size matches calculated size, not updating")
}


if updateTreeSize {
// update the tree time of the parent node
if err = n.SetTreeSize(calculatedTreeSize); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/utils/decomposedfs/xattrs/xattrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ const (
// propagated when treesize_accounting is true and
// user.ocis.propagation=1 is set
// stored as uint64, little endian
TreesizeAttr string = ocisPrefix + "treesize"
TreesizeAttr string = OcisPrefix + "treesize"

// the quota for the storage space / tree, regardless who accesses it
QuotaAttr string = ocisPrefix + "quota"
QuotaAttr string = OcisPrefix + "quota"

UserAcePrefix string = "u:"
GroupAcePrefix string = "g:"
Expand Down

0 comments on commit 0815066

Please sign in to comment.