All pastes #29599 Raw Edit

neuron

public text v1 · immutable
#29599 ·published 2005-11-20 15:08 UTC
rendered paste body
implement direct compress on write in fuse_write
implement direct decompress on write in fuse_read
  - This means we can only compress in buffer sizes of 4096 bytes. - have to be able to disable this (ifdef or per file?)
  - This is WAY faster.
  - We can fallback to background compress/decompress on more advanced file functions such as modifying in the middle of a file.
  
Bugs in fusecompress:
  Threading problems.
    - The background scanning thread has to be sync'ed with the main thread, to avoid it trying to compress/decompress a file which is still in use.

Whats needed:
  - In memory database (using kernel linked lists?) of open files.
    database.c ahs functions that locks access to the global database on add
    each database entry (fi->fh->database) also has a seperate lock.
  
fuse_open:
  - search database, if no file found then create an entry for it.
    fi->fh->database = search_and_create_new_in_cache () ; #this returns a locked fi->fh->database entry.
    fi->fh->database->accesses++;
    fi->fh->database->compressed = boolean, true if file is compressed, false otherwise.
  unlock fi->fh->database;
  
  
# if two files use this function, it'll lock the database, realize offset is wrong, decompress the file, do pwrite and unlock, that way the next write will start using pwrite aswell.
fuse_write:
  lock fi->fh->database
  if fi->fh->database->compressed {
      write direct with compressor 
        - only write direct if filelength == 0 OR fi->fh->database->offset == offset (which it will be in buffered writes, 4096 bytes at the time)
          - if offset is wrong simply decompress file and use pwrite
        - it also means it has to contain compressor info, like zlibstream
  } else {
      pwrite
  }
  unlock fi->fh->database
  
# This should have seperate compression info (like offset/zlibstream) in fi->fh, as we can easily do multiple reads from one file, but it still has to check ->compressed.
fuse_read:
  lock fi->fh->database
  if fi->fh->database->compressed {
      read direct with decompresser
  } else {
      pread
  }
  unlock fi->fh->database
  
fuse_close:
  lock fi->fh->database;
  - if fi->fh->database->accesses - 1 == 0;
    if !fi->fh->database->compressed then
      background compress
    free fi->fh->database
  unlock fi->fh->database;