Skip to content

Commit

Permalink
meta: don't change arguments in txn for Fallocate & CopyFileRange (#2402
Browse files Browse the repository at this point in the history
)
  • Loading branch information
SandyXSD authored Jul 27, 2022
1 parent 888549d commit bb85bd1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/meta/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@ func (m *redisMeta) Fallocate(ctx Context, inode Ino, mode uint8, off uint64, si
_, err = tx.TxPipelined(ctx, func(pipe redis.Pipeliner) error {
pipe.Set(ctx, m.inodeKey(inode), m.marshal(&t), 0)
if mode&(fallocZeroRange|fallocPunchHole) != 0 && off < old {
off, size := off, size
if off+size > old {
size = old - off
}
Expand Down Expand Up @@ -2041,6 +2042,7 @@ func (m *redisMeta) CopyFileRange(ctx Context, fin Ino, offIn uint64, fout Ino,
*copied = 0
return nil
}
size := size
if offIn+size > sattr.Length {
size = sattr.Length - offIn
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/meta/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@ func (m *dbMeta) Fallocate(ctx Context, inode Ino, mode uint8, off uint64, size
return err
}
if mode&(fallocZeroRange|fallocPunchHole) != 0 && off < old {
off, size := off, size
if off+size > old {
size = old - off
}
Expand Down Expand Up @@ -2043,6 +2044,7 @@ func (m *dbMeta) CopyFileRange(ctx Context, fin Ino, offIn uint64, fout Ino, off
*copied = 0
return nil
}
size := size
if offIn+size > nin.Length {
size = nin.Length - offIn
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/meta/tkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ func (m *kvMeta) Fallocate(ctx Context, inode Ino, mode uint8, off uint64, size
t.Ctimensec = uint32(now.Nanosecond())
tx.set(m.inodeKey(inode), m.marshal(&t))
if mode&(fallocZeroRange|fallocPunchHole) != 0 && off < old {
off, size := off, size
if off+size > old {
size = old - off
}
Expand Down Expand Up @@ -1727,6 +1728,7 @@ func (m *kvMeta) CopyFileRange(ctx Context, fin Ino, offIn uint64, fout Ino, off
*copied = 0
return nil
}
size := size
if offIn+size > sattr.Length {
size = sattr.Length - offIn
}
Expand Down

0 comments on commit bb85bd1

Please sign in to comment.