Skip to content

Commit 6b2c742

Browse files
committed
libcephfs_proxy: implement client side async rw operation
Signed-off-by: Xavi Hernandez <[email protected]>
1 parent e236678 commit 6b2c742

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

src/libcephfs_proxy/libcephfs_proxy.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ __public int ceph_create(struct ceph_mount_info **cmount, const char *const id)
181181
sd = err;
182182

183183
proxy_link_negotiate_init(&ceph_mount->neg, 0, PROXY_FEAT_ALL, 0,
184-
PROXY_FEAT_ASYNC_CBK);
184+
PROXY_FEAT_ASYNC_IO);
185185

186186
err = proxy_link_handshake_client(&ceph_mount->link, sd,
187187
&ceph_mount->neg,
@@ -911,3 +911,38 @@ __public UserPerm *ceph_mount_perms(struct ceph_mount_info *cmount)
911911

912912
return value_ptr(ans.userperm);
913913
}
914+
915+
__public int64_t ceph_ll_nonblocking_readv_writev(
916+
struct ceph_mount_info *cmount, struct ceph_ll_io_info *io_info)
917+
{
918+
CEPH_REQ(ceph_ll_nonblocking_readv_writev, req,
919+
io_info->write ? io_info->iovcnt : 0, ans, 0);
920+
int32_t i, err;
921+
922+
if ((cmount->neg.v1.enabled & PROXY_FEAT_ASYNC_IO) == 0) {
923+
return -EOPNOTSUPP;
924+
}
925+
926+
req.info = ptr_checksum(&cmount->async.random, io_info);
927+
req.fh = (uintptr_t)io_info->fh;
928+
req.off = io_info->off;
929+
req.size = 0;
930+
req.write = io_info->write;
931+
req.fsync = io_info->fsync;
932+
req.syncdataonly = io_info->syncdataonly;
933+
934+
for (i = 0; i < io_info->iovcnt; i++) {
935+
if (io_info->write) {
936+
CEPH_BUFF_ADD(req, io_info->iov[i].iov_base,
937+
io_info->iov[i].iov_len);
938+
}
939+
req.size += io_info->iov[i].iov_len;
940+
}
941+
942+
err = CEPH_PROCESS(cmount, LIBCEPHFSD_OP_LL_NONBLOCKING_RW, req, ans);
943+
if (err < 0) {
944+
return err;
945+
}
946+
947+
return ans.res;
948+
}

src/libcephfs_proxy/proxy.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
((_type *)((uintptr_t)(_ptr) - offset_of(_type, _field)))
2727

2828
enum {
29+
/* Support for ceph_ll_nonblocking_readv_writev */
30+
PROXY_FEAT_ASYNC_IO = 0x00000001,
31+
2932
/* Mask of all features requiring the asynchronous callback handling. */
3033
PROXY_FEAT_ASYNC_CBK = 0x00000001,
3134

src/libcephfs_proxy/proxy_requests.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
#define CEPH_DATA(_name, _data, _data_count) \
4242
proxy_##_name##_##_data##_t _data; \
43-
struct iovec _data##_iov[_data_count + 1]; \
43+
struct iovec _data##_iov[(_data_count) + 1]; \
4444
int32_t _data##_count = 0; \
4545
CEPH_BUFF_ADD(_data, &_data, sizeof(_data))
4646

0 commit comments

Comments
 (0)