westerndigitalcorporation / zenfs

ZenFS is a storage backend for RocksDB that enables support for ZNS SSDs and SMR HDDs.
GNU General Public License v2.0
235 stars 86 forks source link

A question about ZenMetaLog::Read #289

Closed yakode closed 5 months ago

yakode commented 5 months ago

In the zenfs/fs /fszenfs.cc line 187, there is `ret = zbd->Read(data + read, readpos, to_read - read, false);`

I checked the definition of ZoneFsBackend:: Read and saw int Read(char *buf, int size, uint64_t pos, bool direct);

I don't understand it. I think ret = zbd_->Read(data + read, to_read - read, read_pos_, false); is more reasonable.

However, I saw many people compile and test ZenFS. So, it works correctly. My understanding is wrong. Please help me understand the source code. Thanks!!

MaisenbacherD commented 5 months ago

Hi @yakode Thanks for your question! zbd_ is an instance of ZonedBlockDevice which defines the Read as follows: https://github.com/westerndigitalcorporation/zenfs/blob/8337de1d72ce76ec3c7329aac1ec352661953017/fs/zbd_zenfs.h#L218

I agree that the inconsistency of the Read API is confusing.

Does that answer your question? :)

yakode commented 5 months ago

Dear @MaisenbacherD

Yesss! Very thank for your help! I understand it now :D Sorry for my carelessness ><