• Chris Mason's avatar
    Btrfs: Add ordered async work queues · 4a69a410
    Chris Mason authored
    Btrfs uses kernel threads to create async work queues for cpu intensive
    operations such as checksumming and decompression.  These work well,
    but they make it difficult to keep IO order intact.
    
    A single writepages call from pdflush or fsync will turn into a number
    of bios, and each bio is checksummed in parallel.  Once the checksum is
    computed, the bio is sent down to the disk, and since we don't control
    the order in which the parallel operations happen, they might go down to
    the disk in almost any order.
    
    The code deals with this somewhat by having deep work queues for a single
    kernel thread, making it very likely that a single thread will process all
    the bios for a single inode.
    
    This patch introduces an explicitly ordered work queue.  As work structs
    are placed into the queue they are put onto the tail of a list.  They have
    three callbacks:
    
    ->func (cpu intensive processing here)
    ->ordered_func (order sensitive processing here)
    ->ordered_free (free the work struct, ...
    4a69a410
async-thread.c 11 KB