From 7b3e6db3b8a90ff48a8997c842c498a2f8f8aa49 Mon Sep 17 00:00:00 2001 From: sageweil Date: Thu, 22 Nov 2007 06:46:55 +0000 Subject: [PATCH] some kernel osd_client bits git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@2111 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/kernel/Makefile | 2 +- trunk/ceph/kernel/client.c | 12 ++++++++---- trunk/ceph/kernel/mds_client.c | 24 ++++++++++++++++++++++++ trunk/ceph/kernel/mds_client.h | 7 ++++--- trunk/ceph/kernel/osd_client.c | 2 +- trunk/ceph/kernel/osd_client.h | 21 +++++++++++++++++++++ 6 files changed, 59 insertions(+), 9 deletions(-) diff --git a/trunk/ceph/kernel/Makefile b/trunk/ceph/kernel/Makefile index 269f6b1da5ded..3be93433beb56 100644 --- a/trunk/ceph/kernel/Makefile +++ b/trunk/ceph/kernel/Makefile @@ -9,4 +9,4 @@ ceph-objs := super.o inode.o \ client.o \ mds_client.o mdsmap.o \ mon_client.o monmap.o \ - osd_client.o + osd_client.o crush/crush.o crush/mapper.o diff --git a/trunk/ceph/kernel/client.c b/trunk/ceph/kernel/client.c index b1919f9677f96..85007f781e9c8 100644 --- a/trunk/ceph/kernel/client.c +++ b/trunk/ceph/kernel/client.c @@ -59,6 +59,8 @@ static int mount(struct ceph_client *client, struct ceph_mount_args *args) int err; int attempts = 10; int which; + struct ceph_msg *open_msg; + struct ceph_msg *open_reply; client->mounting = 6; /* FIXME don't wait for osd map, for now */ @@ -88,13 +90,15 @@ trymount: goto trymount; return -EIO; } + ceph_msg_put(mount_msg); /* get handle for mount path */ - /*err = ceph_mdsc_open_dir(&client->mdsc, CEPH_INO_ROOT, args->path); - if (err) + err = ceph_mdsc_do(&client->mdsc, CEPH_MDS_OP_OPEN, + CEPH_INO_ROOT, args->path, 0, 0); + if (err < 0) return err; - */ - + + /* yay */ return 0; } diff --git a/trunk/ceph/kernel/mds_client.c b/trunk/ceph/kernel/mds_client.c index 961e9ad03b588..fe27d302a7236 100644 --- a/trunk/ceph/kernel/mds_client.c +++ b/trunk/ceph/kernel/mds_client.c @@ -328,6 +328,30 @@ retry: return reply; } +int ceph_mdsc_do(struct ceph_mds_client *mdsc, int op, + ceph_ino_t ino1, const char *path1, + ceph_ino_t ino2, const char *path2) +{ + struct ceph_msg *req, *reply; + struct ceph_client_reply_head *head; + int ret; + + req = ceph_mdsc_create_request_msg(&client->mdsc, op, ino1, path1, ino2, path2); + if (IS_ERR(req)) + return PTR_ERR(req); + + reply = ceph_mdsc_do_request(&client->mdsc, req, -1); + if (IS_ERR(reply)) + return PTR_ERR(reply); + + head = reply->front.iov_base; + ret = head->result; + + ceph_msg_put(reply); + return ret; +} + + void ceph_mdsc_handle_reply(struct ceph_mds_client *mdsc, struct ceph_msg *msg) { diff --git a/trunk/ceph/kernel/mds_client.h b/trunk/ceph/kernel/mds_client.h index 67f3e9188b739..e1e29df87f1c9 100644 --- a/trunk/ceph/kernel/mds_client.h +++ b/trunk/ceph/kernel/mds_client.h @@ -61,9 +61,10 @@ struct ceph_mds_client { struct completion map_waiters; }; -extern void ceph_mdsc_init(struct ceph_mds_client *mdsc, - struct ceph_client *client); -extern void ceph_mdsc_submit_request(struct ceph_mds_client *mdsc, struct ceph_msg *msg, int mds); +extern void ceph_mdsc_init(struct ceph_mds_client *mdsc, struct ceph_client *client); +struct ceph_msg *ceph_mdsc_do_request(struct ceph_mds_client *mdsc, struct ceph_msg *msg, int mds); +int ceph_mdsc_do(struct ceph_mds_client *mdsc, int op, ceph_ino_t ino1, const char *path1, ceph_ino_t ino2, const char *path2); + extern void ceph_mdsc_handle_reply(struct ceph_mds_client *mdsc, struct ceph_msg *msg); extern void ceph_mdsc_handle_forward(struct ceph_mds_client *mdsc, struct ceph_msg *msg); extern void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, struct ceph_msg *msg); diff --git a/trunk/ceph/kernel/osd_client.c b/trunk/ceph/kernel/osd_client.c index e4c88a5da1240..d605de180a7f1 100644 --- a/trunk/ceph/kernel/osd_client.c +++ b/trunk/ceph/kernel/osd_client.c @@ -2,7 +2,7 @@ #include #include -#include "../crush/crush.h" +#include "crush/crush.h" #include "osd_client.h" #include "messenger.h" diff --git a/trunk/ceph/kernel/osd_client.h b/trunk/ceph/kernel/osd_client.h index 11b56f90cf4bc..c8b1df80c8380 100644 --- a/trunk/ceph/kernel/osd_client.h +++ b/trunk/ceph/kernel/osd_client.h @@ -4,6 +4,8 @@ /* this will be equivalent to osdc/Objecter.h */ #include +#include +#include struct ceph_msg; @@ -23,9 +25,28 @@ struct ceph_osdmap { struct crush_map *crush; }; +enum { + REQUEST_ACK, REQUEST_SAFE +}; + +struct ceph_osd_request { + __u64 r_tid; + ceph_pg_t r_pgid; + int r_flags; + + atomic_t r_ref; + struct ceph_msg *r_request; + struct completion r_completion; +}; + struct ceph_osd_client { struct ceph_osdmap *osdmap; /* current osd map */ + __u64 last_tid; /* id of last mds request */ + struct radix_tree_root request_tree; /* pending mds requests */ + + __u64 last_requested_map; + struct completion map_waiters; }; extern void ceph_osdc_init(struct ceph_osd_client *osdc); -- 2.39.5