Unfortunately, another serious issue has been identified in the S3 background operations.
The core of the problem lies in the unconventional design of the folder system in Amazon S3. In Amazon S3, folders do not exist in the conventional sense of a file system. S3 is a "flat" object storage service, wherein all files (objects) reside at the same level within a bucket. What appears as folders in the management console or via file managers is merely a visual abstraction based on object key names. Consequently, folders in S3 can be categorized into two types:
-
Explicitly created folders: These are generated either by executing a command such as
aws s3api put-object --bucket bucket_name --key folder_name/ (the trailing slash is mandatory)
or by clicking the "Create Folder" button in the AWS Console. In such cases, S3 creates an empty object of 0 bytes whose key ends with a forward slash (e.g., folder_name/). This construct exists solely to enable the interface to display an "empty directory." The presence of such a directory can be verified using the headObject API call, which will return a successful response (200 OK) along with metadata for this special empty object:
ContentLength: 0
ContentType: typically application/x-directory (set by the Console)
ETag and LastModified: present, as with any standard object
-
Implicit folders: These arise automatically when uploading files with a hierarchical key path. For instance, uploading a file with the key photos/vacation/sea.jpg will cause the prefixes photos/ and photos/vacation/ to appear as folders.
In the majority of use cases, folders in S3 are of the second type. Unfortunately, it is precisely these implicit folders that introduce significant complications. For example, invoking headObject for the key photos/ will return a 404 Not Found error. From S3's perspective, no object with that exact key exists; only objects whose keys begin with that prefix are present. Furthermore, when all objects within such implicit "folders" are deleted, the folder structure disappears automatically.
This behavior is documented in the AWS guide: Organizing objects in the Amazon S3 console by using folders. Additionally, a comprehensive article on this topic is available: The Strange Case of Amazon S3 Bucket Folders.
Returning to the zenfs background operations for S3: during read, write, and similar operations, zenfs performs stat calls on the directories containing the target files. As expected, it receives a 404 Not Found response for implicit folders, which subsequently leads to failures in file read/write operations. This issue stems directly from the aforementioned peculiarity of S3's object model.
I have endeavored to describe the problem in as much detail as possible. Should you require further clarification, I would be glad to address any questions.
Unfortunately, another serious issue has been identified in the S3 background operations.
The core of the problem lies in the unconventional design of the folder system in Amazon S3. In Amazon S3, folders do not exist in the conventional sense of a file system. S3 is a "flat" object storage service, wherein all files (objects) reside at the same level within a bucket. What appears as folders in the management console or via file managers is merely a visual abstraction based on object key names. Consequently, folders in S3 can be categorized into two types:
Explicitly created folders: These are generated either by executing a command such as
aws s3api put-object --bucket bucket_name --key folder_name/(the trailing slash is mandatory)or by clicking the "Create Folder" button in the AWS Console. In such cases, S3 creates an empty object of 0 bytes whose key ends with a forward slash (e.g.,
folder_name/). This construct exists solely to enable the interface to display an "empty directory." The presence of such a directory can be verified using theheadObjectAPI call, which will return a successful response (200 OK) along with metadata for this special empty object:ContentLength: 0ContentType: typicallyapplication/x-directory(set by the Console)ETagandLastModified: present, as with any standard objectImplicit folders: These arise automatically when uploading files with a hierarchical key path. For instance, uploading a file with the key
photos/vacation/sea.jpgwill cause the prefixesphotos/andphotos/vacation/to appear as folders.In the majority of use cases, folders in S3 are of the second type. Unfortunately, it is precisely these implicit folders that introduce significant complications. For example, invoking
headObjectfor the keyphotos/will return a404 Not Founderror. From S3's perspective, no object with that exact key exists; only objects whose keys begin with that prefix are present. Furthermore, when all objects within such implicit "folders" are deleted, the folder structure disappears automatically.This behavior is documented in the AWS guide: Organizing objects in the Amazon S3 console by using folders. Additionally, a comprehensive article on this topic is available: The Strange Case of Amazon S3 Bucket Folders.
Returning to the zenfs background operations for S3: during read, write, and similar operations, zenfs performs
statcalls on the directories containing the target files. As expected, it receives a404 Not Foundresponse for implicit folders, which subsequently leads to failures in file read/write operations. This issue stems directly from the aforementioned peculiarity of S3's object model.I have endeavored to describe the problem in as much detail as possible. Should you require further clarification, I would be glad to address any questions.