do not recreate deprecated delete-journal.bin, only read it (#15185)

simplify deprecated code, re-enable hot-swap replace disks
This commit is contained in:
Harshavardhana 2022-07-08 12:17:02 -07:00 committed by GitHub
parent ab9544c0d3
commit c2ddcb3b40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,18 +71,9 @@ func initTierDeletionJournal(ctx context.Context) (*tierJournal, error) {
tierMemJournal: newTierMemJoural(1000),
tierDiskJournal: newTierDiskJournal(),
}
for _, diskPath := range globalEndpoints.LocalDisksPaths() {
j.diskPath = diskPath
if err := os.MkdirAll(filepath.Dir(j.JournalPath()), os.FileMode(0o700)); err != nil {
logger.LogIf(ctx, err)
continue
}
err := j.Open()
if err != nil {
logger.LogIf(ctx, err)
continue
}
go j.deletePending(ctx) // for existing journal entries from previous MinIO versions
go j.processEntries(ctx) // for newer journal entries circa free-versions
@ -100,10 +91,8 @@ func (jd *tierDiskJournal) rotate() error {
if _, err := os.Stat(jd.ReadOnlyPath()); err == nil {
return nil
}
// Close the active journal if present.
jd.Close()
// Open a new active journal for subsequent journalling.
return jd.Open()
// Close the active journal if present and delete it.
return jd.Close()
}
type walkFn func(ctx context.Context, objName, rvID, tierName string) error
@ -117,8 +106,7 @@ func (jd *tierDiskJournal) JournalPath() string {
}
func (jd *tierDiskJournal) WalkEntries(ctx context.Context, fn walkFn) {
err := jd.rotate()
if err != nil {
if err := jd.rotate(); err != nil {
logger.LogIf(ctx, fmt.Errorf("tier-journal: failed to rotate pending deletes journal %s", err))
return
}
@ -226,21 +214,17 @@ func (jd *tierDiskJournal) Close() error {
if fi, err = f.Stat(); err != nil {
return err
}
defer f.Close()
f.Close() // close before rename()
// Skip renaming active journal if empty.
if fi.Size() == tierJournalHdrLen {
return nil
return os.Remove(jd.JournalPath())
}
jPath := jd.JournalPath()
jroPath := jd.ReadOnlyPath()
// Rotate active journal to perform pending deletes.
err = os.Rename(jPath, jroPath)
if err != nil {
return err
}
return nil
return os.Rename(jPath, jroPath)
}
// Open opens a new active journal. Note: calling Open on an opened journal is a