mirror of
https://github.com/minio/minio.git
synced 2025-01-11 23:13:23 -05:00
fs: Close object fs.json before deletion (#10092)
NFS fails when deleting a file while it is already opened. The reason is that the object fs.json meta file is opened but not closed before removal.
This commit is contained in:
parent
38f60b3c1d
commit
518f44908c
22
cmd/fs-v1.go
22
cmd/fs-v1.go
@ -1237,25 +1237,31 @@ func (fs *FSObjects) DeleteObject(ctx context.Context, bucket, object string, op
|
||||
return objInfo, toObjectErr(err, bucket)
|
||||
}
|
||||
|
||||
var rwlk *lock.LockedFile
|
||||
|
||||
minioMetaBucketDir := pathJoin(fs.fsPath, minioMetaBucket)
|
||||
fsMetaPath := pathJoin(minioMetaBucketDir, bucketMetaPrefix, bucket, object, fs.metaJSONFile)
|
||||
if bucket != minioMetaBucket {
|
||||
rwlk, lerr := fs.rwPool.Write(fsMetaPath)
|
||||
if lerr == nil {
|
||||
// This close will allow for fs locks to be synchronized on `fs.json`.
|
||||
defer rwlk.Close()
|
||||
}
|
||||
if lerr != nil && lerr != errFileNotFound {
|
||||
logger.LogIf(ctx, lerr)
|
||||
return objInfo, toObjectErr(lerr, bucket, object)
|
||||
rwlk, err = fs.rwPool.Write(fsMetaPath)
|
||||
if err != nil && err != errFileNotFound {
|
||||
logger.LogIf(ctx, err)
|
||||
return objInfo, toObjectErr(err, bucket, object)
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the object.
|
||||
if err = fsDeleteFile(ctx, pathJoin(fs.fsPath, bucket), pathJoin(fs.fsPath, bucket, object)); err != nil {
|
||||
if rwlk != nil {
|
||||
rwlk.Close()
|
||||
}
|
||||
return objInfo, toObjectErr(err, bucket, object)
|
||||
}
|
||||
|
||||
// Close fsMetaPath before deletion
|
||||
if rwlk != nil {
|
||||
rwlk.Close()
|
||||
}
|
||||
|
||||
if bucket != minioMetaBucket {
|
||||
// Delete the metadata object.
|
||||
err = fsDeleteFile(ctx, minioMetaBucketDir, fsMetaPath)
|
||||
|
Loading…
Reference in New Issue
Block a user