Skip to content
  • Markus Armbruster's avatar
    c602a489
    block: Clean up bdrv_flush_all() · c602a489
    Markus Armbruster authored
    
    
    Change (!bdrv_is_removable(bs) || bdrv_is_inserted(bs)) to just
    bdrv_is_inserted().  Rationale:
    
        The value of bdrv_is_removable(bs) matters only when
        bdrv_is_inserted(bs) is false.
    
        bdrv_is_inserted(bs) is true when bs is open (bs->drv != NULL) and
        not an empty host drive (CD-ROM or floppy).
    
        Therefore, bdrv_is_removable(bs) matters only when:
    
        1. bs is not open
           old: may call bdrv_flush(bs), which does nothing
           new: won't call
    
        2. bs is an empty host drive
           old: may call bdrv_flush(bs), which calls driver method
                raw_flush(), which calls fdatasync() or equivalent, which
                can't do anything useful while the drive is empty
           new: won't call
    
    Result is bs->drv && !bdrv_is_read_only(bs) && bdrv_is_inserted(bs).
    bdrv_is_inserted(bs) implies bs->drv.  Drop the redundant test.
    
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    c602a489
    block: Clean up bdrv_flush_all()
    Markus Armbruster authored
    
    
    Change (!bdrv_is_removable(bs) || bdrv_is_inserted(bs)) to just
    bdrv_is_inserted().  Rationale:
    
        The value of bdrv_is_removable(bs) matters only when
        bdrv_is_inserted(bs) is false.
    
        bdrv_is_inserted(bs) is true when bs is open (bs->drv != NULL) and
        not an empty host drive (CD-ROM or floppy).
    
        Therefore, bdrv_is_removable(bs) matters only when:
    
        1. bs is not open
           old: may call bdrv_flush(bs), which does nothing
           new: won't call
    
        2. bs is an empty host drive
           old: may call bdrv_flush(bs), which calls driver method
                raw_flush(), which calls fdatasync() or equivalent, which
                can't do anything useful while the drive is empty
           new: won't call
    
    Result is bs->drv && !bdrv_is_read_only(bs) && bdrv_is_inserted(bs).
    bdrv_is_inserted(bs) implies bs->drv.  Drop the redundant test.
    
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
Loading