aboutsummaryrefslogtreecommitdiff
path: root/weed/s3api/s3api_bucket_config.go
diff options
context:
space:
mode:
authorchrislu <chris.lu@gmail.com>2025-12-05 20:59:21 -0800
committerchrislu <chris.lu@gmail.com>2025-12-05 21:32:41 -0800
commit4e5e8db431f86a873e3ba7940b77c469ef9fc6ed (patch)
tree94a5cb278c034667e6742a9a22d8398cf4be71a6 /weed/s3api/s3api_bucket_config.go
parentacd7f1a4d551108f296455a480356db17cec3a5b (diff)
downloadseaweedfs-4e5e8db431f86a873e3ba7940b77c469ef9fc6ed.tar.xz
seaweedfs-4e5e8db431f86a873e3ba7940b77c469ef9fc6ed.zip
s3api: skip object lock check for buckets without object lockorigin/optimize-delete-lookups
Optimize DELETE and PUT operations by skipping the object lock protection check for buckets that don't have object lock enabled. Previously, enforceObjectLockProtections was always called, which performed an expensive entry lookup even for buckets without object lock. This optimization: - Adds isObjectLockEnabled() helper that uses cached bucket config - Skips enforceObjectLockProtections for buckets without object lock - Applies to both versioned and non-versioned DELETE paths - Applies to PUT operations on non-versioned buckets Performance impact: For buckets without object lock (the common case), this eliminates one filer lookup per DELETE/PUT operation.
Diffstat (limited to 'weed/s3api/s3api_bucket_config.go')
-rw-r--r--weed/s3api/s3api_bucket_config.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/weed/s3api/s3api_bucket_config.go b/weed/s3api/s3api_bucket_config.go
index a10374339..2df84179a 100644
--- a/weed/s3api/s3api_bucket_config.go
+++ b/weed/s3api/s3api_bucket_config.go
@@ -548,6 +548,15 @@ func (s3a *S3ApiServer) getBucketVersioningStatus(bucket string) (string, s3err.
return config.Versioning, s3err.ErrNone
}
+// isObjectLockEnabled checks if object lock is enabled for a bucket (cached check)
+func (s3a *S3ApiServer) isObjectLockEnabled(bucket string) bool {
+ config, errCode := s3a.getBucketConfig(bucket)
+ if errCode != s3err.ErrNone {
+ return false
+ }
+ return config.ObjectLockConfig != nil
+}
+
// setBucketVersioningStatus sets the versioning status for a bucket
func (s3a *S3ApiServer) setBucketVersioningStatus(bucket, status string) s3err.ErrorCode {
errCode := s3a.updateBucketConfig(bucket, func(config *BucketConfig) error {