Defragment mounted XFS filesystem.
    In order to mount a filesystem, device should be properly mounted and writable.

    CLI Example:

    .. code-block:: bash

        salt '*' xfs.defragment /dev/sda1

def defragment(device):
    '''
    Defragment mounted XFS filesystem.
    In order to mount a filesystem, device should be properly mounted and writable.

    CLI Example:

    .. code-block:: bash

        salt '*' xfs.defragment /dev/sda1
    '''
    if device == '/':
        raise CommandExecutionError("Root is not a device.")

    if not _get_mounts().get(device):
        raise CommandExecutionError("Device \"{0}\" is not mounted".format(device))

    out = __salt__['cmd.run_all']("xfs_fsr {0}".format(device))
    _verify_run(out)

    return {
        'log': out['stdout']
    }