• J
    Btrfs: fix qgroup rescan resume on mount · b382a324
    Jan Schmidt 提交于
    When called during mount, we cannot start the rescan worker thread until
    open_ctree is done. This commit restuctures the qgroup rescan internals to
    enable a clean deferral of the rescan resume operation.
    
    First of all, the struct qgroup_rescan is removed, saving us a malloc and
    some initialization synchronizations problems. Its only element (the worker
    struct) now lives within fs_info just as the rest of the rescan code.
    
    Then setting up a rescan worker is split into several reusable stages.
    Currently we have three different rescan startup scenarios:
    	(A) rescan ioctl
    	(B) rescan resume by mount
    	(C) rescan by quota enable
    
    Each case needs its own combination of the four following steps:
    	(1) set the progress [A, C: zero; B: state of umount]
    	(2) commit the transaction [A]
    	(3) set the counters [A, C: zero; B: state of umount]
    	(4) start worker [A, B, C]
    
    qgroup_rescan_init does step (1). There's no extra function added to commit
    a transaction, we've got that already. qgroup_rescan_zero_tracking does
    step (3). Step (4) is nothing more than a call to the generic
    btrfs_queue_worker.
    
    We also get rid of a double check for the rescan progress during
    btrfs_qgroup_account_ref, which is no longer required due to having step 2
    from the list above.
    
    As a side effect, this commit prepares to move the rescan start code from
    btrfs_run_qgroups (which is run during commit) to a less time critical
    section.
    Signed-off-by: NJan Schmidt <list.btrfs@jan-o-sch.net>
    Signed-off-by: NJosef Bacik <jbacik@fusionio.com>
    b382a324
disk-io.c 109.4 KB