mirror of
https://github.com/minio/minio.git
synced 2025-04-10 06:30:07 -04:00
Tweak readall allocation and renameData buffer reuse (#13108)
Use a single allocation for reading the file, not the growing buffer of `io.ReadAll`. Reuse the write buffer if we can when writing metadata in RenameData.
This commit is contained in:
parent
88e0aa1cb2
commit
470553ff5d
@ -2091,7 +2091,8 @@ func (s *xlStorage) RenameData(ctx context.Context, srcVolume, srcPath string, f
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
dstBuf, err = xlMeta.AppendTo(nil)
|
dstBuf, err = xlMeta.AppendTo(metaDataPoolGet())
|
||||||
|
defer metaDataPoolPut(dstBuf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.LogIf(ctx, err)
|
logger.LogIf(ctx, err)
|
||||||
if legacyPreserved {
|
if legacyPreserved {
|
||||||
|
@ -135,7 +135,7 @@ GLOBAL FLAGS:
|
|||||||
}
|
}
|
||||||
data = b
|
data = b
|
||||||
default:
|
default:
|
||||||
return errors.New("unknown metadata version")
|
return fmt.Errorf("unknown metadata version %d", minor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Bool("data") {
|
if c.Bool("data") {
|
||||||
|
@ -34,6 +34,11 @@ func ReadFile(name string) ([]byte, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
st, err := f.Stat()
|
||||||
return io.ReadAll(f)
|
if err != nil {
|
||||||
|
return io.ReadAll(f)
|
||||||
|
}
|
||||||
|
dst := make([]byte, st.Size())
|
||||||
|
_, err = io.ReadFull(f, dst)
|
||||||
|
return dst, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user