mirror of
https://github.com/ceph/ceph
synced 2025-03-06 16:28:28 +00:00
cleaned up mds map requesting
This commit is contained in:
parent
9296475397
commit
7aa095a853
5
src/TODO
5
src/TODO
@ -24,6 +24,11 @@ kernel client
|
||||
- clean up ceph_send_fault
|
||||
- more testing
|
||||
- callbacks for 'remote reset' (once 'caps' branch is merged in)
|
||||
|
||||
- TCP_CLOSE case in callback.. should it set CLOSED bit?
|
||||
- ceph_queue_read .. check READING bit?
|
||||
-
|
||||
|
||||
- mds client
|
||||
- pin inodes with caps (igrab/iput?)
|
||||
- mechanism to close out old caps
|
||||
|
@ -162,6 +162,18 @@ static struct ceph_msg *create_session_msg(__u32 op, __u64 seq)
|
||||
return msg;
|
||||
}
|
||||
|
||||
static void wait_for_new_map(struct ceph_mds_client *mdsc)
|
||||
{
|
||||
dout(30, "wait_for_new_map enter\n");
|
||||
if (mdsc->last_requested_map < mdsc->mdsmap->m_epoch)
|
||||
ceph_monc_request_mdsmap(&mdsc->client->monc, mdsc->mdsmap->m_epoch);
|
||||
|
||||
spin_unlock(&mdsc->lock);
|
||||
wait_for_completion(&mdsc->map_waiters);
|
||||
spin_lock(&mdsc->lock);
|
||||
dout(30, "wait_for_new_map exit\n");
|
||||
}
|
||||
|
||||
static int open_session(struct ceph_mds_client *mdsc, struct ceph_mds_session *session, int mds)
|
||||
{
|
||||
struct ceph_msg *msg;
|
||||
@ -171,16 +183,11 @@ static int open_session(struct ceph_mds_client *mdsc, struct ceph_mds_session *s
|
||||
mstate = ceph_mdsmap_get_state(mdsc->mdsmap, mds);
|
||||
dout(10, "open_session to mds%d, state %d\n", mds, mstate);
|
||||
if (mstate < CEPH_MDS_STATE_ACTIVE) {
|
||||
ceph_monc_request_mdsmap(&mdsc->client->monc, mdsc->mdsmap->m_epoch);
|
||||
spin_unlock(&mdsc->lock);
|
||||
dout(30, "open_session waiting on map\n");
|
||||
wait_for_completion(&mdsc->map_waiters);
|
||||
dout(30, "open_session done waiting on map\n");
|
||||
spin_lock(&mdsc->lock);
|
||||
|
||||
wait_for_new_map(mdsc);
|
||||
mstate = ceph_mdsmap_get_state(mdsc->mdsmap, mds);
|
||||
if (mstate < CEPH_MDS_STATE_ACTIVE) {
|
||||
dout(30, "open_session still not active...\n");
|
||||
dout(30, "open_session mds%d now %d, still not active...\n",
|
||||
mds, mstate);
|
||||
return -EAGAIN; /* hrm, try again? */
|
||||
}
|
||||
}
|
||||
@ -258,15 +265,7 @@ bad:
|
||||
}
|
||||
|
||||
|
||||
static void wait_for_new_map(struct ceph_mds_client *mdsc)
|
||||
{
|
||||
dout(30, "wait_for_new_map enter\n");
|
||||
if (mdsc->last_requested_map < mdsc->mdsmap->m_epoch)
|
||||
ceph_monc_request_mdsmap(&mdsc->client->monc, mdsc->mdsmap->m_epoch);
|
||||
|
||||
wait_for_completion(&mdsc->map_waiters);
|
||||
dout(30, "wait_for_new_map exit\n");
|
||||
}
|
||||
|
||||
/* exported functions */
|
||||
|
||||
@ -362,11 +361,8 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc, struct ceph_msg *msg,
|
||||
retry:
|
||||
mds = choose_mds(mdsc, req);
|
||||
if (mds < 0) {
|
||||
/* wait for new mdsmap */
|
||||
spin_unlock(&mdsc->lock);
|
||||
dout(30, "do_request waiting for new mdsmap\n");
|
||||
wait_for_new_map(mdsc);
|
||||
spin_lock(&mdsc->lock);
|
||||
goto retry;
|
||||
}
|
||||
dout(30, "do_request chose mds%d\n", mds);
|
||||
@ -900,6 +896,7 @@ void ceph_mdsc_handle_map(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
|
||||
dout(2, "got first mdsmap %u\n", newmap->m_epoch);
|
||||
mdsc->mdsmap = newmap;
|
||||
}
|
||||
ceph_monc_got_mdsmap(&mdsc->client->monc, newmap->m_epoch); /* stop asking */
|
||||
spin_unlock(&mdsc->lock);
|
||||
complete(&mdsc->map_waiters);
|
||||
return;
|
||||
|
@ -82,36 +82,39 @@ int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl)
|
||||
return -ENOMEM;
|
||||
spin_lock_init(&monc->lock);
|
||||
INIT_RADIX_TREE(&monc->statfs_request_tree, GFP_KERNEL);
|
||||
monc->last_tid = 0;
|
||||
monc->want_mdsmap = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int request_mdsmap(struct ceph_mon_client *monc)
|
||||
int ceph_monc_request_mdsmap(struct ceph_mon_client *monc, __u32 have)
|
||||
{
|
||||
struct ceph_msg *msg;
|
||||
int mon = pick_mon(monc, -1);
|
||||
|
||||
dout(10, "request_mdsmap to mon%d have %u\n", mon, monc->want_mdsmap_epoch_gt);
|
||||
msg = ceph_msg_new(CEPH_MSG_MDS_GETMAP, sizeof(ceph_epoch_t), 0, 0, 0);
|
||||
dout(5, "ceph_monc_request_mdsmap from mon%d have %u\n", mon, have);
|
||||
monc->want_mdsmap = have;
|
||||
msg = ceph_msg_new(CEPH_MSG_MDS_GETMAP, sizeof(__u32), 0, 0, 0);
|
||||
if (IS_ERR(msg))
|
||||
return PTR_ERR(msg);
|
||||
*(__le32*)msg->front.iov_base = cpu_to_le32(monc->want_mdsmap_epoch_gt);
|
||||
*(__le32*)msg->front.iov_base = cpu_to_le32(have);
|
||||
msg->hdr.dst = monc->monmap->mon_inst[mon];
|
||||
ceph_msg_send(monc->client->msgr, msg, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void ceph_monc_request_mdsmap(struct ceph_mon_client *monc, __u64 have)
|
||||
int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, __u32 have)
|
||||
{
|
||||
dout(5, "ceph_monc_request_mdsmap -- IMPLEMENT ME\n");
|
||||
|
||||
if (have <= monc->want_mdsmap_epoch_gt) {
|
||||
dout(5, " already waiting for > %u\n", monc->want_mdsmap_epoch_gt);
|
||||
return;
|
||||
if (have > monc->want_mdsmap) {
|
||||
monc->want_mdsmap = 0;
|
||||
dout(5, "ceph_monc_got_mdsmap have %u > wanted %u\n",
|
||||
have, monc->want_mdsmap);
|
||||
return 0;
|
||||
} else {
|
||||
dout(5, "ceph_monc_got_mdsmap have %u <= wanted %u *****\n",
|
||||
have, monc->want_mdsmap);
|
||||
return -EAGAIN;
|
||||
}
|
||||
monc->want_mdsmap_epoch_gt = have;
|
||||
request_mdsmap(monc);
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ struct ceph_mon_client {
|
||||
struct radix_tree_root statfs_request_tree; /* statfs requests */
|
||||
u64 last_tid;
|
||||
|
||||
u32 want_mdsmap_epoch_gt;
|
||||
u32 want_mdsmap; /* protected by caller's lock */
|
||||
};
|
||||
|
||||
extern struct ceph_monmap *ceph_monmap_decode(void *p, void *end);
|
||||
@ -39,7 +39,10 @@ extern int ceph_monmap_contains(struct ceph_monmap *m, struct ceph_entity_addr *
|
||||
|
||||
extern int ceph_monc_init(struct ceph_mon_client *monc, struct ceph_client *cl);
|
||||
|
||||
extern void ceph_monc_request_mdsmap(struct ceph_mon_client *monc, __u64 have);
|
||||
extern int ceph_monc_request_mdsmap(struct ceph_mon_client *monc, __u32 have);
|
||||
extern int ceph_monc_got_mdsmap(struct ceph_mon_client *monc, __u32 have);
|
||||
|
||||
|
||||
extern void ceph_monc_request_osdmap(struct ceph_mon_client *monc, __u64 have);
|
||||
extern void ceph_monc_request_umount(struct ceph_mon_client *monc);
|
||||
extern void ceph_monc_report_failure(struct ceph_mon_client *monc, struct ceph_entity_inst *who);
|
||||
|
Loading…
Reference in New Issue
Block a user