Lines Matching full:if
46 #if defined(__APPLE__) && (__MACH__)
48 #if defined(HAVE_HOST_BLOCK_DEVICE)
72 #if defined(CONFIG_BLKZONED)
89 #if defined(CONFIG_FALLOCATE_PUNCH_HOLE) || defined(CONFIG_FALLOCATE_ZERO_RANGE)
92 #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
128 /* Approximate O_DIRECT with O_DSYNC if O_DIRECT isn't available */
153 * Even if each path is in a separate path group (path_grouping_policy set to
213 if (s->fd >= 0) { in fd_open()
257 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
268 if ((err) == EAGAIN || (err) == EACCES) { \
275 #if defined(__NetBSD__)
284 if (lstat(fname, &sb) < 0) { in raw_normalize_devicepath()
289 if (!S_ISBLK(sb.st_mode)) { in raw_normalize_devicepath()
293 if (dp == NULL) { in raw_normalize_devicepath()
335 if (ioctl(fd, ioctl_list[i], §or_size) >= 0) { in probe_logical_blocksize()
352 if (ioctl(fd, BLKPBSZGET, blk_size) < 0) { in probe_physical_blocksize()
362 * Returns true if no alignment restrictions are necessary even for files
367 * avoided if we know that byte alignment is okay for the file.
376 if (ret == 0 && buf.f_type == NFS_SUPER_MAGIC) { in dio_byte_aligned()
387 if ((bs->open_flags & BDRV_O_NOCACHE) != 0 && !dio_byte_aligned(s->fd)) { in raw_needs_alignment()
394 /* Check if read is allowed with given memory buffer and length.
402 if (ret >= 0) { in raw_is_io_aligned()
411 if (errno != EINVAL) { in raw_is_io_aligned()
428 if (bdrv_is_sg(bs) || !s->needs_alignment) { in raw_probe_alignment()
437 if (probe_logical_blocksize(fd, &bs->bl.request_alignment) < 0) { in raw_probe_alignment()
452 if (ioctl(fd, _IOR('X', 30, struct xfs_dioattr), &da) >= 0) { in raw_probe_alignment()
460 * If we could not get the sizes so far, we can only guess them. First try in raw_probe_alignment()
463 * Gluster). If buf_align cannot be detected, we fallback to the value of in raw_probe_alignment()
467 if (!bs->bl.request_alignment) { in raw_probe_alignment()
473 if (raw_is_io_aligned(fd, buf, align)) { in raw_probe_alignment()
482 if (!s->buf_align) { in raw_probe_alignment()
488 if (raw_is_io_aligned(fd, buf + align, max_align)) { in raw_probe_alignment()
497 if (!s->buf_align || !bs->bl.request_alignment) { in raw_probe_alignment()
505 #if defined(BLKROGET) in check_hdev_writable()
510 * bdrv_open() is supposed to fail if the disk is read-only. Explicitly in check_hdev_writable()
517 if (fstat(fd, &st)) { in check_hdev_writable()
521 if (!S_ISBLK(st.st_mode)) { in check_hdev_writable()
525 if (ioctl(fd, BLKROGET, &readonly) < 0) { in check_hdev_writable()
529 if (readonly) { in check_hdev_writable()
544 if (bdrv_flags & BDRV_O_AUTO_RDONLY) { in raw_parse_flags()
546 } else if (bdrv_flags & BDRV_O_RDWR) { in raw_parse_flags()
550 if (read_write) { in raw_parse_flags()
558 if ((bdrv_flags & BDRV_O_NOCACHE)) { in raw_parse_flags()
598 #if defined(__linux__)
631 if (!qemu_opts_absorb_qdict(opts, options, errp)) { in raw_open_common()
639 if (ret != 0) { in raw_open_common()
643 if (bdrv_flags & BDRV_O_NATIVE_AIO) { in raw_open_common()
646 } else if (bdrv_flags & BDRV_O_IO_URING) { in raw_open_common()
656 if (local_err) { in raw_open_common()
672 if (local_err) { in raw_open_common()
680 if (!qemu_has_ofd_lock()) { in raw_open_common()
698 if (str) { in raw_open_common()
700 if (local_err) { in raw_open_common()
718 if (ret < 0) { in raw_open_common()
719 if (ret == -EROFS) { in raw_open_common()
727 if (s->open_flags & O_RDWR) { in raw_open_common()
729 if (ret < 0) { in raw_open_common()
740 if (s->use_linux_aio && !(s->open_flags & O_DIRECT)) { in raw_open_common()
746 if (s->use_linux_aio) { in raw_open_common()
750 if (s->use_linux_aio) { in raw_open_common()
759 if (s->use_linux_io_uring) { in raw_open_common()
770 if (fstat(s->fd, &st) < 0) { in raw_open_common()
776 if (!device) { in raw_open_common()
777 if (!S_ISREG(st.st_mode)) { in raw_open_common()
786 if (!(S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode))) { in raw_open_common()
799 if ((bs->bl.zoned != BLK_Z_NONE) && in raw_open_common()
808 if (S_ISCHR(st.st_mode)) { in raw_open_common()
821 if (s->use_linux_aio && !laio_has_fua()) { in raw_open_common()
823 } else if (s->use_linux_io_uring && !luring_has_fua()) { in raw_open_common()
828 if (S_ISREG(st.st_mode)) { in raw_open_common()
834 if (ret < 0 && s->fd != -1) { in raw_open_common()
837 if (filename && (bdrv_flags & BDRV_O_TEMPORARY)) { in raw_open_common()
863 * file; if @unlock == true, also unlock the unneeded bytes.
875 if (s) { in raw_apply_lock_bytes()
883 if (unlock) { in raw_apply_lock_bytes()
895 if ((perm_lock_bits & bit) && !(locked_perm & bit)) { in raw_apply_lock_bytes()
897 if (ret) { in raw_apply_lock_bytes()
901 } else if (s) { in raw_apply_lock_bytes()
904 } else if (unlock && (locked_perm & bit) && !(perm_lock_bits & bit)) { in raw_apply_lock_bytes()
906 if (ret) { in raw_apply_lock_bytes()
909 } else if (s) { in raw_apply_lock_bytes()
917 if ((shared_perm_lock_bits & bit) && !(locked_shared_perm & bit)) { in raw_apply_lock_bytes()
919 if (ret) { in raw_apply_lock_bytes()
923 } else if (s) { in raw_apply_lock_bytes()
926 } else if (unlock && (locked_shared_perm & bit) && in raw_apply_lock_bytes()
929 if (ret) { in raw_apply_lock_bytes()
932 } else if (s) { in raw_apply_lock_bytes()
950 if (perm & p) { in raw_check_lock_bytes()
952 if (ret) { in raw_check_lock_bytes()
966 if (!(shared_perm & p)) { in raw_check_lock_bytes()
968 if (ret) { in raw_check_lock_bytes()
991 if (!s->use_lock) { in raw_handle_perm_lock()
995 if (bdrv_get_flags(bs) & BDRV_O_INACTIVE) { in raw_handle_perm_lock()
1001 if ((s->perm | new_perm) == s->perm && in raw_handle_perm_lock()
1005 * We are going to unlock bytes, it should not fail. If it fail due in raw_handle_perm_lock()
1016 if (!ret) { in raw_handle_perm_lock()
1018 if (!ret) { in raw_handle_perm_lock()
1029 if (local_err) { in raw_handle_perm_lock()
1039 if (local_err) { in raw_handle_perm_lock()
1056 if (flags == -1) { in fcntl_setfl()
1059 if (fcntl(fd, F_SETFL, flags | flag) == -1) { in fcntl_setfl()
1079 if (s->type == FTYPE_CD) { in raw_reconfigure_getfd()
1094 if (*open_flags == s->open_flags) { in raw_reconfigure_getfd()
1099 if ((*open_flags & ~fcntl_flags) == (s->open_flags & ~fcntl_flags)) { in raw_reconfigure_getfd()
1102 if (fd >= 0) { in raw_reconfigure_getfd()
1104 if (ret) { in raw_reconfigure_getfd()
1111 /* If we cannot use fcntl, or fcntl failed, fall back to qemu_open() */ in raw_reconfigure_getfd()
1112 if (fd == -1) { in raw_reconfigure_getfd()
1115 if (ret >= 0) { in raw_reconfigure_getfd()
1117 if (fd == -1) { in raw_reconfigure_getfd()
1123 if (fd != -1 && (*open_flags & O_RDWR)) { in raw_reconfigure_getfd()
1125 if (ret < 0) { in raw_reconfigure_getfd()
1153 if (!qemu_opts_absorb_qdict(opts, state->options, errp)) { in raw_reopen_prepare()
1205 /* nothing to do if NULL, we didn't get far enough */ in raw_reopen_abort()
1206 if (rs == NULL) { in raw_reopen_abort()
1220 if (S_ISBLK(st->st_mode)) { in hdev_get_max_hw_transfer()
1222 if (ioctl(fd, BLKSECTGET, &max_sectors) == 0) { in hdev_get_max_hw_transfer()
1227 if (ioctl(fd, BLKSECTGET, &max_bytes) == 0) { in hdev_get_max_hw_transfer()
1246 if (!S_ISBLK(st->st_mode)) { in get_sysfs_str_val()
1253 if (!g_file_get_contents(sysfspath, val, &len, NULL)) { in get_sysfs_str_val()
1260 if (*(p + len - 1) == '\n') { in get_sysfs_str_val()
1267 #if defined(CONFIG_BLKZONED)
1274 if (ret < 0) { in get_sysfs_zoned_model()
1278 if (strcmp(val, "host-managed") == 0) { in get_sysfs_zoned_model()
1280 } else if (strcmp(val, "host-aware") == 0) { in get_sysfs_zoned_model()
1282 } else if (strcmp(val, "none") == 0) { in get_sysfs_zoned_model()
1303 if (ret < 0) { in get_sysfs_long_val()
1309 if (ret == 0 && end && *end == '\0') { in get_sysfs_long_val()
1327 if (ret < 0) { in get_sysfs_u32_val()
1333 if (ret == 0 && end && *end == '\0') { in get_sysfs_u32_val()
1345 if (S_ISCHR(st->st_mode)) { in hdev_get_max_segments()
1346 if (ioctl(fd, SG_GET_SG_TABLESIZE, &ret) == 0) { in hdev_get_max_segments()
1374 #if defined(CONFIG_BLKZONED)
1376 * If the reset_all flag is true, then the wps of zone whose state is
1403 if (ret != 0) { in get_zones_wp()
1409 if (!rep->nr_zones) { in get_zones_wp()
1421 if (blkz[i].type == BLK_ZONE_TYPE_CONVENTIONAL) { in get_zones_wp()
1435 if (reset_all) { in get_zones_wp()
1453 if (get_zones_wp(bs, fd, offset, nrz, 0) < 0) { in update_zones_wp()
1466 if (ret < 0 || zoned == BLK_Z_NONE) { in raw_refresh_zoned_limits()
1472 if (ret >= 0) { in raw_refresh_zoned_limits()
1477 if (ret >= 0) { in raw_refresh_zoned_limits()
1485 if (ret < 0) { in raw_refresh_zoned_limits()
1489 } else if (!ret) { in raw_refresh_zoned_limits()
1496 if (ret < 0) { in raw_refresh_zoned_limits()
1500 } else if (!ret) { in raw_refresh_zoned_limits()
1507 if (ret > 0) { in raw_refresh_zoned_limits()
1512 if (ret >= 0) { in raw_refresh_zoned_limits()
1521 if (ret < 0) { in raw_refresh_zoned_limits()
1557 if (fstat(s->fd, &st)) { in raw_refresh_limits()
1561 #if defined(__APPLE__) && (__MACH__) in raw_refresh_limits()
1564 if (!fstatfs(s->fd, &buf)) { in raw_refresh_limits()
1570 if (bdrv_is_sg(bs) || S_ISBLK(st.st_mode)) { in raw_refresh_limits()
1573 if (ret > 0 && ret <= BDRV_REQUEST_MAX_BYTES) { in raw_refresh_limits()
1578 if (ret > 0) { in raw_refresh_limits()
1583 if (S_ISBLK(st.st_mode)) { in raw_refresh_limits()
1588 if (ret == 0 && dalign != 0) { in raw_refresh_limits()
1592 if (dalign < ralign && (ralign % dalign == 0)) { in raw_refresh_limits()
1597 if (dalign % ralign != 0) { in raw_refresh_limits()
1631 /* If DASD or zoned devices, get blocksizes */ in hdev_probe_blocksizes()
1632 if (check_for_dasd(s->fd) < 0) { in hdev_probe_blocksizes()
1634 if (bs->bl.zoned == BLK_Z_NONE) { in hdev_probe_blocksizes()
1639 if (ret < 0) { in hdev_probe_blocksizes()
1657 /* If DASD, get its geometry */ in hdev_probe_geometry()
1658 if (check_for_dasd(s->fd) < 0) { in hdev_probe_geometry()
1661 if (ioctl(s->fd, HDIO_GETGEO, &ioctl_geo) < 0) { in hdev_probe_geometry()
1666 if (!ioctl_geo.heads || !ioctl_geo.sectors || !ioctl_geo.cylinders) { in hdev_probe_geometry()
1670 if (ioctl_geo.start != 0) { in hdev_probe_geometry()
1686 #if defined(__linux__)
1695 if (ret == -1) { in handle_aiocb_ioctl()
1709 if (s->page_cache_inconsistent) { in handle_aiocb_flush()
1714 if (ret == -1) { in handle_aiocb_flush()
1730 if ((s->open_flags & O_DIRECT) == 0) { in handle_aiocb_flush()
1788 if (len == -1) { in handle_aiocb_rw_vector()
1798 * reads are only returned if the end of the file is reached.
1806 if (aiocb->aio_type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) { in handle_aiocb_rw_linear()
1817 if (len == -1 && errno == EINTR) { in handle_aiocb_rw_linear()
1819 } else if (len == -1 && errno == EINVAL && in handle_aiocb_rw_linear()
1828 } else if (len == -1) { in handle_aiocb_rw_linear()
1831 } else if (len == 0) { in handle_aiocb_rw_linear()
1846 if (!(aiocb->aio_type & QEMU_AIO_MISALIGNED)) { in handle_aiocb_rw()
1848 * If there is just a single buffer, and it is properly aligned in handle_aiocb_rw()
1851 if (aiocb->io.niov == 1) { in handle_aiocb_rw()
1859 * buffer if it's not supported. in handle_aiocb_rw()
1861 if (preadv_present) { in handle_aiocb_rw()
1863 if (nbytes == aiocb->aio_nbytes || in handle_aiocb_rw()
1882 if (buf == NULL) { in handle_aiocb_rw()
1887 if (aiocb->aio_type & QEMU_AIO_WRITE) { in handle_aiocb_rw()
1899 if (!(aiocb->aio_type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND))) { in handle_aiocb_rw()
1906 if (copy > aiocb->io.iov[i].iov_len) { in handle_aiocb_rw()
1919 if (nbytes == aiocb->aio_nbytes) { in handle_aiocb_rw()
1921 } else if (nbytes >= 0 && nbytes < aiocb->aio_nbytes) { in handle_aiocb_rw()
1922 if (aiocb->aio_type & QEMU_AIO_WRITE) { in handle_aiocb_rw()
1935 #if defined(CONFIG_FALLOCATE) || defined(BLKZEROOUT) || defined(BLKDISCARD)
1938 if (err == -ENODEV || err == -ENOSYS || err == -EOPNOTSUPP || in translate_err()
1950 if (fallocate(fd, mode, offset, len) == 0) { in do_fallocate()
1963 if (!s->has_write_zeroes) { in handle_aiocb_write_zeroes_block()
1969 * BLKDEV_ZERO_NOFALLBACK, so we can't call this if we have to avoid slow in handle_aiocb_write_zeroes_block()
1971 if (!(aiocb->aio_type & QEMU_AIO_NO_FALLBACK)) { in handle_aiocb_write_zeroes_block()
1974 if (ioctl(aiocb->aio_fildes, BLKZEROOUT, range) == 0) { in handle_aiocb_write_zeroes_block()
1980 if (ret == -ENOTSUP) { in handle_aiocb_write_zeroes_block()
1997 if (aiocb->aio_type & QEMU_AIO_BLKDEV) { in handle_aiocb_write_zeroes()
2002 if (s->has_write_zeroes) { in handle_aiocb_write_zeroes()
2005 if (ret == -ENOTSUP) { in handle_aiocb_write_zeroes()
2007 } else if (ret == 0 || ret != -EINVAL) { in handle_aiocb_write_zeroes()
2020 if (s->has_discard && s->has_fallocate) { in handle_aiocb_write_zeroes()
2024 if (ret == 0) { in handle_aiocb_write_zeroes()
2026 if (ret == 0 || ret != -ENOTSUP) { in handle_aiocb_write_zeroes()
2030 } else if (ret == -EINVAL) { in handle_aiocb_write_zeroes()
2041 } else if (ret != -ENOTSUP) { in handle_aiocb_write_zeroes()
2053 if (s->has_fallocate && len >= 0 && aiocb->aio_offset >= len) { in handle_aiocb_write_zeroes()
2055 if (ret == 0 || ret != -ENOTSUP) { in handle_aiocb_write_zeroes()
2085 /* If we couldn't manage to unmap while guaranteed that the area reads as in handle_aiocb_write_zeroes_unmap()
2110 #if defined(CONFIG_BLKZONED)
2171 #if defined(CONFIG_BLKZONED)
2201 if (ret != 0) { in handle_aiocb_zone_report()
2207 if (!rep->nr_zones) { in handle_aiocb_zone_report()
2213 if (ret != 0) { in handle_aiocb_zone_report()
2227 #if defined(CONFIG_BLKZONED)
2262 if (ret == 0) { in handle_aiocb_copy_range()
2267 if (ret < 0) { in handle_aiocb_copy_range()
2288 if (!s->has_discard) { in handle_aiocb_discard()
2292 if (aiocb->aio_type & QEMU_AIO_BLKDEV) { in handle_aiocb_discard()
2296 if (ioctl(aiocb->aio_fildes, BLKDISCARD, range) == 0) { in handle_aiocb_discard()
2314 if (fcntl(s->fd, F_PUNCHHOLE, &fpunchhole) == -1) { in handle_aiocb_discard()
2322 if (ret == -ENOTSUP) { in handle_aiocb_discard()
2375 if (fstat(fd, &st) < 0) { in handle_aiocb_truncate()
2382 if (current_length > offset && prealloc != PREALLOC_MODE_OFF) { in handle_aiocb_truncate()
2392 * file systems that do not support fallocate(), trying to check if a in handle_aiocb_truncate()
2395 if (offset != current_length) { in handle_aiocb_truncate()
2398 if (result != 0) { in handle_aiocb_truncate()
2402 } else if (current_length == 0) { in handle_aiocb_truncate()
2404 * posix_fallocate() uses fallocate() if the filesystem in handle_aiocb_truncate()
2405 * supports it, or fallback to manually writing zeroes. If in handle_aiocb_truncate()
2429 if (ftruncate(fd, offset) != 0) { in handle_aiocb_truncate()
2438 if (seek_result < 0) { in handle_aiocb_truncate()
2448 if (result < 0) { in handle_aiocb_truncate()
2449 if (errno == EINTR) { in handle_aiocb_truncate()
2459 if (result >= 0) { in handle_aiocb_truncate()
2461 if (result < 0) { in handle_aiocb_truncate()
2471 if (ftruncate(fd, offset) != 0) { in handle_aiocb_truncate()
2474 } else if (current_length == 0 && offset > current_length) { in handle_aiocb_truncate()
2487 if (result < 0) { in handle_aiocb_truncate()
2488 if (ftruncate(fd, current_length) < 0) { in handle_aiocb_truncate()
2504 * Check if all memory in this vector is sector aligned.
2514 if ((uintptr_t) qiov->iov[i].iov_base % alignment) { in bdrv_qiov_is_aligned()
2517 if (qiov->iov[i].iov_len % len) { in bdrv_qiov_is_aligned()
2531 if (!s->use_linux_io_uring) { in raw_check_linux_io_uring()
2536 if (unlikely(!aio_setup_linux_io_uring(ctx, &local_err))) { in raw_check_linux_io_uring()
2552 if (!s->use_linux_aio) { in raw_check_linux_aio()
2557 if (unlikely(!aio_setup_linux_aio(ctx, &local_err))) { in raw_check_linux_aio()
2576 if (fd_open(bs) < 0) in raw_co_prw()
2578 #if defined(CONFIG_BLKZONED) in raw_co_prw()
2579 if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) && in raw_co_prw()
2582 if (type & QEMU_AIO_ZONE_APPEND) { in raw_co_prw()
2591 * either libaio or io_uring interface. If not fail back to regular thread in raw_co_prw()
2592 * pool read/write code which emulates this for us if we in raw_co_prw()
2595 if (s->needs_alignment && !bdrv_qiov_is_aligned(bs, qiov)) { in raw_co_prw()
2598 } else if (raw_check_linux_io_uring(s)) { in raw_co_prw()
2604 } else if (raw_check_linux_aio(s)) { in raw_co_prw()
2626 if (ret == 0 && (flags & BDRV_REQ_FUA)) { in raw_co_prw()
2627 /* TODO Use pwritev2() instead if it's available */ in raw_co_prw()
2633 #if defined(CONFIG_BLKZONED) in raw_co_prw()
2634 if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) && in raw_co_prw()
2637 if (ret == 0) { in raw_co_prw()
2639 if (!BDRV_ZT_IS_CONV(*wp)) { in raw_co_prw()
2640 if (type & QEMU_AIO_ZONE_APPEND) { in raw_co_prw()
2645 /* Advance the wp if needed */ in raw_co_prw()
2646 if (offset + bytes > *wp) { in raw_co_prw()
2684 if (ret < 0) { in raw_co_flush_to_disk()
2695 if (raw_check_linux_io_uring(s)) { in raw_co_flush_to_disk()
2700 if (s->has_laio_fdsync && raw_check_linux_aio(s)) { in raw_co_flush_to_disk()
2711 if (s->fd >= 0) { in raw_close()
2712 #if defined(CONFIG_BLKZONED) in raw_close()
2754 if (fstat(s->fd, &st)) { in raw_co_truncate()
2760 if (S_ISREG(st.st_mode)) { in raw_co_truncate()
2765 if (prealloc != PREALLOC_MODE_OFF) { in raw_co_truncate()
2771 if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) { in raw_co_truncate()
2774 if (offset != cur_length && exact) { in raw_co_truncate()
2777 } else if (offset > cur_length) { in raw_co_truncate()
2796 if (fstat(fd, &st)) in raw_getlength()
2798 if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) { in raw_getlength()
2801 if (ioctl(fd, DIOCGDINFO, &dl)) in raw_getlength()
2815 if (fstat(fd, &st)) in raw_getlength()
2817 if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) { in raw_getlength()
2820 if (ioctl(fd, DIOCGWEDGEINFO, &dkw) != -1) { in raw_getlength()
2825 if (ioctl(fd, DIOCGDINFO, &dl)) in raw_getlength()
2842 if (ret < 0) { in raw_getlength()
2850 if (ret != -1) { in raw_getlength()
2859 if (size < 0) { in raw_getlength()
2871 #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) in raw_getlength()
2877 if (ret < 0) in raw_getlength()
2880 #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__) in raw_getlength()
2883 if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) { in raw_getlength()
2886 if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size)) { in raw_getlength()
2891 if (size == 0) { in raw_getlength()
2893 if (ioctl(fd, DIOCGPART, &pi) == 0) { in raw_getlength()
2898 #if defined(DKIOCGETBLOCKCOUNT) && defined(DKIOCGETBLOCKSIZE) in raw_getlength()
2899 if (size == 0) { in raw_getlength()
2903 if (ioctl(fd, DKIOCGETBLOCKCOUNT, §ors) == 0 in raw_getlength()
2909 if (size == 0) { in raw_getlength()
2912 if (size < 0) { in raw_getlength()
2915 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) in raw_getlength()
2919 if (size == 2048LL * (unsigned)-1) in raw_getlength()
2922 if (size <= 0 && !reopened && cdrom_reopen(bs) >= 0) { in raw_getlength()
2930 if (size < 0) { in raw_getlength()
2944 if (ret < 0) { in raw_getlength()
2949 if (size < 0) { in raw_getlength()
2966 if (fstat(s->fd, &st) < 0) { in raw_co_get_allocated_file_size()
2985 if (!file_opts->has_nocow) { in raw_co_create()
2988 if (!file_opts->has_preallocation) { in raw_co_create()
2991 if (!file_opts->has_extent_size_hint) { in raw_co_create()
2994 if (file_opts->extent_size_hint > UINT32_MAX) { in raw_co_create()
3002 if (fd < 0) { in raw_co_create()
3012 * size given in the options. If someone else were to resize it in raw_co_create()
3022 if (result < 0) { in raw_co_create()
3028 if (result < 0) { in raw_co_create()
3037 if (result < 0) { in raw_co_create()
3041 if (file_opts->nocow) { in raw_co_create()
3049 if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) { in raw_co_create()
3058 * only printed if the option was explicitly specified. in raw_co_create()
3063 if (result == 0) { in raw_co_create()
3068 if (result < 0 && file_opts->has_extent_size_hint && in raw_co_create()
3081 if (result < 0) { in raw_co_create()
3087 if (local_err) { in raw_co_create()
3088 /* The above call should not fail, and if it does, that does in raw_co_create()
3096 if (qemu_close(fd) != 0 && result == 0) { in raw_co_create()
3123 if (qemu_opt_get(opts, BLOCK_OPT_EXTENT_SIZE_HINT)) { in raw_co_create_opts()
3133 if (local_err) { in raw_co_create_opts()
3160 if (!(stat(bs->filename, &st) == 0) || !S_ISREG(st.st_mode)) { in raw_co_delete_file()
3167 if (ret < 0) { in raw_co_delete_file()
3179 * If @start is not in a hole, store @start in @data, and the
3181 * If @start is in a non-trailing hole, store @start in @hole and the
3183 * If @start is in a trailing hole or beyond EOF, return -ENXIO.
3184 * If we can't find out, return a negative errno other than -ENXIO.
3189 #if defined SEEK_HOLE && defined SEEK_DATA in find_allocation()
3199 * If the latter happens, the file has been truncated behind in find_allocation()
3205 if (offs < 0) { in find_allocation()
3209 if (offs < start) { in find_allocation()
3215 if (offs > start) { in find_allocation()
3227 * If this happens here, a hole has been dug behind our back in find_allocation()
3233 * If that happens here, a hole has been dug behind our back in find_allocation()
3236 * If this happens, the file has been truncated behind our in find_allocation()
3242 if (offs < 0) { in find_allocation()
3246 if (offs < start) { in find_allocation()
3252 if (offs > start) { in find_allocation()
3256 * all bets are off. Treating it as if it there was data all in find_allocation()
3280 * 'bytes' is a soft cap for 'pnum'. If the information is free, 'pnum' may
3296 if (ret < 0) { in raw_co_block_status()
3300 if (!(mode & BDRV_WANT_ZERO)) { in raw_co_block_status()
3309 if (ret == -ENXIO) { in raw_co_block_status()
3313 } else if (ret < 0) { in raw_co_block_status()
3317 } else if (data == offset) { in raw_co_block_status()
3324 * round up if necessary. in raw_co_block_status()
3326 if (!QEMU_IS_ALIGNED(*pnum, bs->bl.request_alignment)) { in raw_co_block_status()
3328 if (file_length > 0) { in raw_co_block_status()
3347 #if defined(__linux__)
3373 /* Unmap previous window if size has changed */ in check_cache_dropped()
3375 if (new_length != length) { in check_cache_dropped()
3383 if (new_window == MAP_FAILED) { in check_cache_dropped()
3392 if (ret < 0) { in check_cache_dropped()
3399 if (vec[i] & 0x1) { in check_cache_dropped()
3403 if (i < vec_end) { in check_cache_dropped()
3409 if (window) { in check_cache_dropped()
3424 if (ret < 0) { in raw_co_invalidate_cache()
3429 if (!s->drop_cache) { in raw_co_invalidate_cache()
3433 if (s->open_flags & O_DIRECT) { in raw_co_invalidate_cache()
3437 #if defined(__linux__) in raw_co_invalidate_cache()
3440 if (ret < 0) { in raw_co_invalidate_cache()
3450 if (ret != 0) { /* the return value is a positive errno */ in raw_co_invalidate_cache()
3455 if (s->check_cache_dropped) { in raw_co_invalidate_cache()
3470 if (ret) { in raw_account_discard()
3485 #if defined(CONFIG_BLKZONED)
3509 #if defined(CONFIG_BLKZONED)
3523 if (offset & zone_size_mask) { in raw_co_zone_mgmt()
3529 if (((offset + len) < capacity && len & zone_size_mask) || in raw_co_zone_mgmt()
3539 if (BDRV_ZT_IS_CONV(*wp) && len != capacity) { in raw_co_zone_mgmt()
3580 if (ret != 0) { in raw_co_zone_mgmt()
3586 if (zo == BLKRESETZONE && len == capacity) { in raw_co_zone_mgmt()
3588 if (ret < 0) { in raw_co_zone_mgmt()
3592 } else if (zo == BLKRESETZONE) { in raw_co_zone_mgmt()
3596 } else if (zo == BLKFINISHZONE) { in raw_co_zone_mgmt()
3608 #if defined(CONFIG_BLKZONED)
3618 if (*offset & zone_size_mask) { in raw_co_zone_append()
3628 if (iov_len & wg_mask) { in raw_co_zone_append()
3657 if (blkdev) { in raw_do_pdiscard()
3681 if (offset + bytes > bs->total_sectors * BDRV_SECTOR_SIZE) { in raw_do_pwrite_zeroes()
3687 * discarded if they happen beyond a concurrently running in raw_do_pwrite_zeroes()
3722 if (blkdev) { in raw_do_pwrite_zeroes()
3725 if (flags & BDRV_REQ_NO_FALLBACK) { in raw_do_pwrite_zeroes()
3729 if (flags & BDRV_REQ_MAY_UNMAP) { in raw_do_pwrite_zeroes()
3770 if (!ret && attr.fsx_extsize != 0) { in raw_get_specific_info()
3800 #if defined(HAVE_HOST_BLOCK_DEVICE)
3852 /* We may need a new fd if auto-read-only switches the mode */ in raw_check_perm()
3854 if (ret < 0) { in raw_check_perm()
3856 } else if (ret != s->fd) { in raw_check_perm()
3860 * Fail already check_perm() if we can't get a working O_DIRECT in raw_check_perm()
3864 if (local_err) { in raw_check_perm()
3876 if (ret < 0) { in raw_check_perm()
3881 if (s->perm_change_fd && s->use_lock) { in raw_check_perm()
3884 if (ret < 0) { in raw_check_perm()
3892 if (s->perm_change_fd) { in raw_check_perm()
3905 if (s->perm_change_fd && s->fd != s->perm_change_fd) { in raw_set_perm()
3923 if (s->perm_change_fd) { in raw_abort_perm_update()
3952 if (src->bs->drv->bdrv_co_copy_range_to != raw_co_copy_range_to) { in raw_co_copy_range_to()
3957 if (fd_open(src->bs) < 0 || fd_open(dst->bs) < 0) { in raw_co_copy_range_to()
4020 #if defined(HAVE_HOST_BLOCK_DEVICE)
4022 #if defined(__APPLE__) && defined(__MACH__)
4035 if ( KERN_SUCCESS != kernResult ) { in FindEjectableOpticalMedia()
4042 if (classesToMatch == NULL) { in FindEjectableOpticalMedia()
4051 if (kernResult != KERN_SUCCESS) { in FindEjectableOpticalMedia()
4057 /* If a match was found, leave the loop */ in FindEjectableOpticalMedia()
4058 if (*mediaIterator != 0) { in FindEjectableOpticalMedia()
4074 if ( nextMedia ) in GetBSDPath()
4078 if ( bsdPathAsCFString ) { in GetBSDPath()
4081 if (flags & BDRV_O_NOCACHE) { in GetBSDPath()
4085 …if ( CFStringGetCString( bsdPathAsCFString, bsdPath + devPathLength, maxPathSize - devPathLength, … in GetBSDPath()
4108 if (fd >= 0) { in setup_cdrom()
4115 /* if a working partition on the device was not found */ in setup_cdrom()
4116 if (partition_found == false) { in setup_cdrom()
4128 error_report("If device %s is mounted on the desktop, unmount" in print_unmounting_directions()
4142 if (strstart(filename, "/dev/cdrom", NULL)) in hdev_probe_device()
4145 if (stat(filename, &st) >= 0 && in hdev_probe_device()
4162 #if defined(__linux__) in hdev_is_sg()
4170 if (stat(bs->filename, &st) < 0 || !S_ISCHR(st.st_mode)) { in hdev_is_sg()
4175 if (ret < 0) { in hdev_is_sg()
4180 if (ret >= 0) { in hdev_is_sg()
4196 #if defined(__APPLE__) && defined(__MACH__) in hdev_open()
4207 /* If using a real cdrom */ in hdev_open()
4208 if (strcmp(filename, "/dev/cdrom") == 0) { in hdev_open()
4214 if (mediaType == NULL) { in hdev_open()
4222 if (ret_val != KERN_SUCCESS) { in hdev_open()
4228 /* If a real optical drive was not found */ in hdev_open()
4229 if (bsd_path[0] == '\0') { in hdev_open()
4235 /* If using a cdrom disc and finding a partition on the disc failed */ in hdev_open()
4236 if (strncmp(mediaType, kIOCDMediaClass, 9) == 0 && in hdev_open()
4247 if (mediaIterator) { in hdev_open()
4250 if (error_occurred) { in hdev_open()
4259 if (ret < 0) { in hdev_open()
4260 #if defined(__APPLE__) && defined(__MACH__) in hdev_open()
4261 if (*bsd_path) { in hdev_open()
4264 /* if a physical device experienced an error while being opened */ in hdev_open()
4265 if (strncmp(filename, "/dev/", 5) == 0) { in hdev_open()
4281 #if defined(__linux__)
4282 #if defined(DM_MPATH_PROBE_PATHS)
4285 if (ret < 0) { in sgio_path_error()
4296 * If the device was suspended for another reason, we'll wait and in sgio_path_error()
4307 if (io_hdr->host_status != SCSI_HOST_OK) { in sgio_path_error()
4332 if (!s->use_mpath) { in hdev_co_ioctl_sgio_retry()
4336 if (!sgio_path_error(ret, acb->ioctl.buf)) { in hdev_co_ioctl_sgio_retry()
4352 if (ret == -ENOTTY) { in hdev_co_ioctl_sgio_retry()
4354 } else if (ret == -EAGAIN) { in hdev_co_ioctl_sgio_retry()
4377 if (ret < 0) { in hdev_co_ioctl()
4381 if (req == SG_IO && s->pr_mgr) { in hdev_co_ioctl()
4383 if (io_hdr->cmdp[0] == PERSISTENT_RESERVE_OUT || in hdev_co_ioctl()
4416 if (ret < 0) { in hdev_co_pdiscard()
4429 if (rc < 0) { in hdev_co_pwrite_zeroes()
4480 #if defined(CONFIG_BLKZONED)
4488 #if defined(__linux__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
4510 /* open will not fail even if no CD is inserted, so add O_NONBLOCK */ in cdrom_open()
4521 if (fd < 0) { in cdrom_probe_device()
4525 if (ret == -1 || !S_ISBLK(st.st_mode)) { in cdrom_probe_device()
4531 if (ret >= 0) in cdrom_probe_device()
4553 if (eject_flag) { in cdrom_co_eject()
4554 if (ioctl(s->fd, CDROMEJECT, NULL) < 0) in cdrom_co_eject()
4557 if (ioctl(s->fd, CDROMCLOSETRAY, NULL) < 0) in cdrom_co_eject()
4566 if (ioctl(s->fd, CDROM_LOCKDOOR, locked) < 0) { in cdrom_co_lock_medium()
4568 * Note: an error can happen if the distribution automatically in cdrom_co_lock_medium()
4611 #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
4621 if (ret) { in cdrom_open()
4632 if (strstart(filename, "/dev/cd", NULL) || in cdrom_probe_device()
4647 if (s->fd >= 0) in cdrom_reopen()
4650 if (fd < 0) { in cdrom_reopen()
4670 if (s->fd < 0) in cdrom_co_eject()
4675 if (eject_flag) { in cdrom_co_eject()
4676 if (ioctl(s->fd, CDIOCEJECT) < 0) in cdrom_co_eject()
4679 if (ioctl(s->fd, CDIOCCLOSE) < 0) in cdrom_co_eject()
4690 if (s->fd < 0) in cdrom_co_lock_medium()
4692 if (ioctl(s->fd, (locked ? CDIOCPREVENT : CDIOCALLOW)) < 0) { in cdrom_co_lock_medium()
4694 * Note: an error can happen if the distribution automatically in cdrom_co_lock_medium()
4742 #if defined(HAVE_HOST_BLOCK_DEVICE) in bdrv_file_init()
4747 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) in bdrv_file_init()