-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement statfs with synthetic values #1118
base: main
Are you sure you want to change the base?
Changes from 1 commit
89df80a
1a5b59c
e0b9c73
83d94bb
99d7537
4e2e2b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,6 +107,42 @@ pub struct DirectoryEntry { | |
lookup: LookedUp, | ||
} | ||
|
||
#[derive(Debug)] | ||
/// Reply to a 'statfs' call | ||
pub struct StatFs { | ||
/// Total number of blocks | ||
pub total_blocks: u64, | ||
/// Number of free blocks | ||
pub free_blocks: u64, | ||
/// Number of free blocks available to unprivileged user | ||
pub available_blocks: u64, | ||
/// Number of inodes in file system | ||
pub total_inodes: u64, | ||
/// Available inodes | ||
pub free_inodes: u64, | ||
/// Optimal transfer block size | ||
pub block_size: u32, | ||
/// Maximum name length | ||
pub maximum_name_length: u32, | ||
/// Fragement size | ||
pub fragment_size: u32, | ||
} | ||
|
||
impl Default for StatFs { | ||
fn default() -> Self { | ||
Self { | ||
total_blocks: 0, | ||
free_blocks: 0, | ||
available_blocks: 0, | ||
total_inodes: 0, | ||
free_inodes: 0, | ||
block_size: 512, | ||
maximum_name_length: 255, | ||
fragment_size: 0, | ||
} | ||
} | ||
} | ||
c-hagem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
impl<Client, Prefetcher> S3Filesystem<Client, Prefetcher> | ||
where | ||
Client: ObjectClient + Clone + Send + Sync + 'static, | ||
|
@@ -789,6 +825,24 @@ where | |
} | ||
Ok(self.superblock.unlink(&self.client, parent_ino, name).await?) | ||
} | ||
|
||
pub async fn statfs(&self, _ino: InodeNo) -> Result<StatFs, Error> { | ||
const FREE_BLOCKS: u64 = u64::MAX / 2; | ||
const FREE_INODES: u64 = u64::MAX / 2; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure where any boundaries may lie, but I think we can take this down by 1024 at least. (In this case, I think we are fine to adjust these values in the future.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed it, assuming taking down means |
||
// According to https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html any S3 object name can be at most | ||
// 1024 bytes. | ||
const MAX_NAME_LENGTH: u32 = 1024; | ||
c-hagem marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
let reply = StatFs { | ||
free_blocks: FREE_BLOCKS, | ||
available_blocks: FREE_BLOCKS, | ||
free_inodes: FREE_INODES, | ||
maximum_name_length: MAX_NAME_LENGTH, | ||
total_blocks: FREE_BLOCKS, | ||
..Default::default() | ||
}; | ||
Ok(reply) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: didn't catch this last time, but we always put Rustdoc comments above macros (so its clear what macros are applied to the struct)
non-blocking