• Mike Snitzer's avatar
    dm thin metadata: do not write metadata if no changes occurred · 873f258b
    Mike Snitzer authored
    Otherwise, just activating a thin-pool and thin device and then
    deactivating them will cause the thin-pool metadata to be changed
    (e.g. superblock written) -- even without any metadata being changed.
    
    Add 'in_service' flag to struct dm_pool_metadata and set it in
    pmd_write_lock() because all on-disk metadata changes must take a write
    lock of pmd->root_lock.  Once 'in_service' is set it is never cleared.
    __commit_transaction() will return 0 if 'in_service' is not set.
    dm_pool_commit_metadata() is updated to use __pmd_write_lock() so that
    it isn't the sole reason for putting a thin-pool in service.
    
    Also fix dm_pool_commit_metadata() to open the next transaction if the
    return from __commit_transaction() is 0.  Not seeing why the early
    return ever made since for a return of 0 given that dm-io's async_io(),
    as used by bufio, always returns 0.
    Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
    873f258b
dm-thin-metadata.c 46.3 KB