Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions pkg/meta/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ type engine interface {
doLink(ctx Context, inode, parent Ino, name string, attr *Attr) syscall.Errno
doUnlink(ctx Context, parent Ino, name string, attr *Attr, skipCheckTrash ...bool) syscall.Errno
doRmdir(ctx Context, parent Ino, name string, inode *Ino, attr *Attr, skipCheckTrash ...bool) syscall.Errno
doBatchUnlink(ctx Context, parent Ino, entries []Entry, length *int64, space *int64, inodes *int64, userGroupQuotas *[]UserGroupQuotaDelta, skipCheckTrash ...bool) (errno syscall.Errno)
doReadlink(ctx Context, inode Ino, noatime bool) (int64, []byte, error)
doReaddir(ctx Context, inode Ino, plus uint8, entries *[]*Entry, limit int) syscall.Errno
doRename(ctx Context, parentSrc Ino, nameSrc string, parentDst Ino, nameDst string, flags uint32, inode, tinode *Ino, attr, tattr *Attr) syscall.Errno
Expand Down Expand Up @@ -1461,6 +1462,44 @@ func (m *baseMeta) Rmdir(ctx Context, parent Ino, name string, skipCheckTrash ..
return st
}

func (m *baseMeta) BatchUnlink(ctx Context, parent Ino, entries []Entry, count *uint64, skipCheckTrash bool) syscall.Errno {
var length int64
var space int64
var inodes int64
var userGroupQuotas []UserGroupQuotaDelta
st := m.en.doBatchUnlink(ctx, parent, entries, &length, &space, &inodes, &userGroupQuotas, skipCheckTrash)
if st == 0 {
m.updateDirStat(ctx, parent, -length, -space, -inodes)
if !parent.IsTrash() {
m.updateDirQuota(ctx, parent, -space, -inodes)
for _, quota := range userGroupQuotas {
m.updateUserGroupQuota(ctx, quota.Uid, quota.Gid, -quota.Space, -quota.Inodes)
}
}
if count != nil && len(entries) > 0 {
atomic.AddUint64(count, uint64(len(entries)))
}
} else if st == syscall.ENOTSUP {
for _, e := range entries {
if e.Attr.Typ == TypeDirectory {
continue
}
if ctx.Canceled() {
return syscall.EINTR
}
if st := m.Unlink(ctx, parent, string(e.Name), skipCheckTrash); st != 0 && st != syscall.ENOENT {
return st
}
if count != nil {
atomic.AddUint64(count, 1)
}
}
} else if st != 0 {
return st
}
return 0
}

func (m *baseMeta) Rename(ctx Context, parentSrc Ino, nameSrc string, parentDst Ino, nameDst string, flags uint32, inode *Ino, attr *Attr) syscall.Errno {
if parentSrc == RootInode && nameSrc == TrashName || parentDst == RootInode && nameDst == TrashName {
return syscall.EPERM
Expand Down
8 changes: 8 additions & 0 deletions pkg/meta/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,14 @@ type Summary struct {
Dirs uint64
}

// UserGroupQuotaDelta represents quota changes for a specific user and group.
type UserGroupQuotaDelta struct {
Uid uint32
Gid uint32
Space int64
Inodes int64
}

type TreeSummary struct {
Inode Ino
Path string
Expand Down
4 changes: 4 additions & 0 deletions pkg/meta/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,10 @@ func (m *redisMeta) doUnlink(ctx Context, parent Ino, name string, attr *Attr, s
return errno(err)
}

func (m *redisMeta) doBatchUnlink(ctx Context, parent Ino, entries []Entry, length *int64, space *int64, inodes *int64, userGroupQuotas *[]UserGroupQuotaDelta, skipCheckTrash ...bool) syscall.Errno {
return syscall.ENOTSUP
}

func (m *redisMeta) doRmdir(ctx Context, parent Ino, name string, pinode *Ino, oldAttr *Attr, skipCheckTrash ...bool) syscall.Errno {
var trash Ino
if !(len(skipCheckTrash) == 1 && skipCheckTrash[0]) {
Expand Down
Loading
Loading