-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Kernel/Filesystem+Tests: Fix RAMFS block count reporting, introduce a test #25077
base: master
Are you sure you want to change the base?
Conversation
I'm not sure if this is fixable unless we want to go into templated functions instead of macros. We assign the left-hand side and the right-hand side to In this particular case, EDIT: Remainder of the review is pending, once I'm back at my PC. |
@@ -122,6 +122,7 @@ ErrorOr<void> RAMFSInode::ensure_allocated_blocks(size_t offset, size_t io_size) | |||
} | |||
} | |||
clean_allocated_blocks_on_failure.disarm(); | |||
m_metadata.block_count = m_blocks.size(); |
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.
Does it fix the issue actually? I don't see where we set the block size for RAMFS
so it will essentially multiply the block count by 0, isn't it correct?
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.
Block size is assumed to be 512/1024/"whatever the user puts in" by du
. I don't think POSIX has a facility to retrieve the filesystem block size?
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.
Addendum: Ah, yeah, there is st_blksize
. If we have that implemented then we should make sure that it's set.
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.
st_blksize is being set by two classes down the line, in BlockBasedFileSystem.h (precisely here). I checked, and for our purposes it's always 512. Is this enough, or should we for some reason set it again in this Inode.cpp?
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.
RAMFS
is not inheriting from BlockBasedFileSystem
, so setting this there is probably not affecting us anyway.
Each data block is using a 128 KiB space, so 512 bytes is probably incorrect anyway.
serenity/Kernel/FileSystem/RAMFS/Inode.h
Lines 69 to 75 in ad4bd36
struct DataBlock { | |
public: | |
using List = Vector<OwnPtr<DataBlock>>; | |
static ErrorOr<NonnullOwnPtr<DataBlock>> create(); | |
constexpr static size_t block_size = 128 * KiB; |
In #19867, I actually reduced this to 4 KiB. But 128 KiB is way too big to do anything useful with it.
Maybe change the block size to PAGE_SIZE:
constexpr static size_t data_block_size = PAGE_SIZE;
and then change st_blksize by setting it to that size as well.
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.
oops, mb. I'm not sure where it gets the 512 from then (I did verify that it does)
will push a fix later
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions! |
I tried making the test for this as generic as possible, so we can extend it onto more FSes (once we start testing those more widely in the future). Currently it runs against RAMFS itself and Ext2FS, because that was the easiest to set up.
L21 from TestFileSystemReportedSize.cpp isn't an EXPECT_EQ due to the macro complaining about not being able to compare between two types; maybe this is something we should look into fixing in the future?