mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
fix(client): fix appendExtentKey extent conflict
Signed-off-by: NaturalSelect <huangzhibin1@oppo.com>
This commit is contained in:
parent
b3f82108f3
commit
374018d88d
@ -394,6 +394,14 @@ func (f *File) Write(ctx context.Context, req *fuse.WriteRequest, resp *fuse.Wri
|
||||
|
||||
defer func() {
|
||||
f.super.ic.Delete(ino)
|
||||
|
||||
if log.EnableDebug() && err == nil {
|
||||
expectedSize := req.Offset + int64(len(req.Data))
|
||||
streamSize, _, _ := f.super.ec.FileSize(ino)
|
||||
if streamSize < int(expectedSize) {
|
||||
log.LogErrorf("[Write] ino(%v) uncorrect write, expected size(%v), actual size(%v)", ino, expectedSize, streamSize)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
var waitForFlush bool
|
||||
|
||||
@ -27,13 +27,14 @@ const (
|
||||
LogTimeFormat = "20060102150405000"
|
||||
)
|
||||
|
||||
func (s *Super) InodeGet(ino uint64) (*proto.InodeInfo, error) {
|
||||
info := s.ic.Get(ino)
|
||||
func (s *Super) InodeGet(ino uint64) (info *proto.InodeInfo, err error) {
|
||||
info = s.ic.Get(ino)
|
||||
|
||||
if info != nil {
|
||||
return info, nil
|
||||
}
|
||||
|
||||
info, err := s.mw.InodeGet_ll(ino)
|
||||
info, err = s.mw.InodeGet_ll(ino)
|
||||
if err != nil || info == nil {
|
||||
log.LogErrorf("InodeGet: ino(%v) err(%v) info(%v)", ino, err, info)
|
||||
if err != nil {
|
||||
@ -55,6 +56,7 @@ func (s *Super) InodeGet(ino uint64) (*proto.InodeInfo, error) {
|
||||
}
|
||||
}
|
||||
s.ec.RefreshExtentsCache(ino)
|
||||
log.LogInfof("[InodeGet] get ino(%v) inode(%v)", ino, info)
|
||||
return info, nil
|
||||
}
|
||||
|
||||
|
||||
@ -350,7 +350,7 @@ services:
|
||||
- ${DiskPath:-./docker_data}/client/log:/cfs/log
|
||||
- ./script/run_test.sh:/cfs/script/start.sh
|
||||
- ./script/start_client.sh:/cfs/script/start_client.sh
|
||||
- ./ltp/runtest/fs:/opt/ltp/runtest/fs
|
||||
# - ./ltp/runtest/fs:/opt/ltp/runtest/fs
|
||||
- ./s3tests:/opt/s3tests:ro
|
||||
privileged: true
|
||||
devices:
|
||||
|
||||
@ -310,7 +310,7 @@ services:
|
||||
- ${DiskPath:-./docker_data}/client/log:/cfs/log
|
||||
- ./script/run_test.sh:/cfs/script/start.sh
|
||||
- ./script/start_client.sh:/cfs/script/start_client.sh
|
||||
- ./ltp/runtest/fs:/opt/ltp/runtest/fs
|
||||
# - ./ltp/runtest/fs:/opt/ltp/runtest/fs
|
||||
- ./s3tests:/opt/s3tests:ro
|
||||
privileged: true
|
||||
devices:
|
||||
@ -333,7 +333,7 @@ services:
|
||||
- ${DiskPath:-./docker_data}/client/log:/cfs/log
|
||||
- ./script/run_test.sh:/cfs/script/start.sh
|
||||
- ./script/start_client.sh:/cfs/script/start_client.sh
|
||||
- ./ltp/runtest/fs:/opt/ltp/runtest/fs
|
||||
# - ./ltp/runtest/fs:/opt/ltp/runtest/fs
|
||||
- ./s3tests:/opt/s3tests:ro
|
||||
privileged: true
|
||||
devices:
|
||||
|
||||
@ -436,7 +436,7 @@ services:
|
||||
- ${DiskPath:-./docker_data}/client/log:/cfs/log
|
||||
- ./script/run_test.sh:/cfs/script/start.sh
|
||||
- ./script/start_client.sh:/cfs/script/start_client.sh
|
||||
- ./ltp/runtest/fs:/opt/ltp/runtest/fs
|
||||
# - ./ltp/runtest/fs:/opt/ltp/runtest/fs
|
||||
- ./s3tests:/opt/s3tests:ro
|
||||
privileged: true
|
||||
devices:
|
||||
|
||||
@ -497,11 +497,11 @@ func (client *ExtentClient) FileSize(inode uint64) (size int, gen uint64, valid
|
||||
}
|
||||
|
||||
// SetFileSize set the file size.
|
||||
func (client *ExtentClient) SetFileSize(inode uint64, size int) {
|
||||
func (client *ExtentClient) SetFileSize(inode uint64, size int, sync bool) {
|
||||
s := client.GetStreamer(inode)
|
||||
if s != nil {
|
||||
log.LogDebugf("SetFileSize: ino(%v) size(%v)", inode, size)
|
||||
s.extents.SetSize(uint64(size), true)
|
||||
s.extents.SetSize(uint64(size), sync)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -396,11 +396,12 @@ begin:
|
||||
}
|
||||
total += writeSize
|
||||
}
|
||||
if filesize, _ := s.extents.Size(); offset+total > filesize {
|
||||
filesize, _ := s.extents.Size()
|
||||
if offset+total > filesize {
|
||||
s.extents.SetSize(uint64(offset+total), false)
|
||||
log.LogDebugf("Streamer write: ino(%v) filesize changed to (%v)", s.inode, offset+total)
|
||||
}
|
||||
log.LogDebugf("Streamer write exit: ino(%v) offset(%v) size(%v) done total(%v) err(%v)", s.inode, offset, size, total, err)
|
||||
log.LogDebugf("Streamer write exit: ino(%v) filesize(%v) offset(%v) size(%v) done total(%v) err(%v)", s.inode, filesize, offset, size, total, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user