@@ -60,9 +60,19 @@ static inline ssize_t btrfs_pwrite(int fd, void *buf, size_t count,
return btrfs_direct_pio(WRITE, fd, buf, count, offset);
}
+static inline ssize_t btrfs_pread(int fd, void *buf, size_t count, off_t offset,
+ bool direct)
+{
+ if (!direct)
+ return pread(fd, buf, count, offset);
+
+ return btrfs_direct_pio(READ, fd, buf, count, offset);
+}
#else
#define btrfs_pwrite(fd, buf, count, offset, direct) \
({ (void)(direct); pwrite(fd, buf, count, offset); })
+#define btrfs_pread(fd, buf, count, offset, direct) \
+ ({ (void)(direct); pread(fd, buf, count, offset); })
#endif
#endif
@@ -35,6 +35,7 @@
#include "kernel-shared/print-tree.h"
#include "common/rbtree-utils.h"
#include "common/device-scan.h"
+#include "common/device-utils.h"
#include "crypto/hash.h"
/* specified errno for check_tree_block */
@@ -476,7 +477,8 @@ int read_extent_data(struct btrfs_fs_info *fs_info, char *data, u64 logical,
goto err;
}
- ret = pread64(device->fd, data, *len, multi->stripes[0].physical);
+ ret = btrfs_pread(device->fd, data, *len, multi->stripes[0].physical,
+ fs_info->zoned);
if (ret != *len)
ret = -EIO;
else
@@ -793,7 +793,8 @@ int read_extent_from_disk(struct extent_buffer *eb,
unsigned long offset, unsigned long len)
{
int ret;
- ret = pread(eb->fd, eb->data + offset, len, eb->dev_bytenr);
+ ret = btrfs_pread(eb->fd, eb->data + offset, len, eb->dev_bytenr,
+ eb->fs_info->zoned);
if (ret < 0) {
ret = -errno;
goto out;
@@ -850,8 +851,8 @@ int read_data_from_disk(struct btrfs_fs_info *info, void *buf, u64 offset,
return -EIO;
}
- ret = pread(device->fd, buf + total_read, read_len,
- multi->stripes[0].physical);
+ ret = btrfs_pread(device->fd, buf + total_read, read_len,
+ multi->stripes[0].physical, info->zoned);
kfree(multi);
if (ret < 0) {
fprintf(stderr, "Error reading %llu, %d\n", offset,
@@ -593,7 +593,7 @@ size_t btrfs_sb_io(int fd, void *buf, off_t offset, int rw)
return ret;
if (rw == READ)
- ret_sz = pread64(fd, buf, count, mapped);
+ ret_sz = btrfs_pread(fd, buf, count, mapped, true);
else
ret_sz = btrfs_pwrite(fd, buf, count, mapped, true);
Wrap pread with btrfs_pread as well. Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> --- common/device-utils.h | 10 ++++++++++ kernel-shared/disk-io.c | 4 +++- kernel-shared/extent_io.c | 7 ++++--- kernel-shared/zoned.c | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-)