drbd: Request lookup code cleanup (1)

Move _ar_id_to_req() to drbd_receiver.c and mark it non-inline.  Remove
the leading underscores from _ar_id_to_req() and _ack_id_to_req().  Mark
ar_hash_slot() inline.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
This commit is contained in:
Andreas Gruenbacher 2011-01-05 23:27:02 +01:00 committed by Philipp Reisner
parent 9c50842a35
commit 5162458564
2 changed files with 27 additions and 26 deletions

View File

@ -1469,6 +1469,24 @@ fail:
return false; return false;
} }
/* when we receive the answer for a read request,
* verify that we actually know about it */
static struct drbd_request *ar_id_to_req(struct drbd_conf *mdev, u64 id,
sector_t sector)
{
struct hlist_head *slot = ar_hash_slot(mdev, sector);
struct hlist_node *n;
struct drbd_request *req;
hlist_for_each_entry(req, n, slot, collision) {
if ((unsigned long)req == (unsigned long)id) {
D_ASSERT(req->sector == sector);
return req;
}
}
return NULL;
}
static int receive_DataReply(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size) static int receive_DataReply(struct drbd_conf *mdev, enum drbd_packets cmd, unsigned int data_size)
{ {
struct drbd_request *req; struct drbd_request *req;
@ -1479,7 +1497,7 @@ static int receive_DataReply(struct drbd_conf *mdev, enum drbd_packets cmd, unsi
sector = be64_to_cpu(p->sector); sector = be64_to_cpu(p->sector);
spin_lock_irq(&mdev->req_lock); spin_lock_irq(&mdev->req_lock);
req = _ar_id_to_req(mdev, p->block_id, sector); req = ar_id_to_req(mdev, p->block_id, sector);
spin_unlock_irq(&mdev->req_lock); spin_unlock_irq(&mdev->req_lock);
if (unlikely(!req)) { if (unlikely(!req)) {
dev_err(DEV, "Got a corrupt block_id/sector pair(1).\n"); dev_err(DEV, "Got a corrupt block_id/sector pair(1).\n");
@ -4222,8 +4240,8 @@ static int got_IsInSync(struct drbd_conf *mdev, struct p_header80 *h)
/* when we receive the ACK for a write request, /* when we receive the ACK for a write request,
* verify that we actually know about it */ * verify that we actually know about it */
static struct drbd_request *_ack_id_to_req(struct drbd_conf *mdev, static struct drbd_request *ack_id_to_req(struct drbd_conf *mdev, u64 id,
u64 id, sector_t sector) sector_t sector)
{ {
struct hlist_head *slot = tl_hash_slot(mdev, sector); struct hlist_head *slot = tl_hash_slot(mdev, sector);
struct hlist_node *n; struct hlist_node *n;
@ -4232,7 +4250,7 @@ static struct drbd_request *_ack_id_to_req(struct drbd_conf *mdev,
hlist_for_each_entry(req, n, slot, collision) { hlist_for_each_entry(req, n, slot, collision) {
if ((unsigned long)req == (unsigned long)id) { if ((unsigned long)req == (unsigned long)id) {
if (req->sector != sector) { if (req->sector != sector) {
dev_err(DEV, "_ack_id_to_req: found req %p but it has " dev_err(DEV, "ack_id_to_req: found req %p but it has "
"wrong sector (%llus versus %llus)\n", req, "wrong sector (%llus versus %llus)\n", req,
(unsigned long long)req->sector, (unsigned long long)req->sector,
(unsigned long long)sector); (unsigned long long)sector);
@ -4306,7 +4324,7 @@ static int got_BlockAck(struct drbd_conf *mdev, struct p_header80 *h)
} }
return validate_req_change_req_state(mdev, p->block_id, sector, return validate_req_change_req_state(mdev, p->block_id, sector,
_ack_id_to_req, __func__ , what); ack_id_to_req, __func__, what);
} }
static int got_NegAck(struct drbd_conf *mdev, struct p_header80 *h) static int got_NegAck(struct drbd_conf *mdev, struct p_header80 *h)
@ -4326,7 +4344,7 @@ static int got_NegAck(struct drbd_conf *mdev, struct p_header80 *h)
} }
spin_lock_irq(&mdev->req_lock); spin_lock_irq(&mdev->req_lock);
req = _ack_id_to_req(mdev, p->block_id, sector); req = ack_id_to_req(mdev, p->block_id, sector);
if (!req) { if (!req) {
spin_unlock_irq(&mdev->req_lock); spin_unlock_irq(&mdev->req_lock);
if (mdev->net_conf->wire_protocol == DRBD_PROT_A || if (mdev->net_conf->wire_protocol == DRBD_PROT_A ||
@ -4363,7 +4381,7 @@ static int got_NegDReply(struct drbd_conf *mdev, struct p_header80 *h)
(unsigned long long)sector, be32_to_cpu(p->blksize)); (unsigned long long)sector, be32_to_cpu(p->blksize));
return validate_req_change_req_state(mdev, p->block_id, sector, return validate_req_change_req_state(mdev, p->block_id, sector,
_ar_id_to_req, __func__ , neg_acked); ar_id_to_req, __func__ , neg_acked);
} }
static int got_NegRSDReply(struct drbd_conf *mdev, struct p_header80 *h) static int got_NegRSDReply(struct drbd_conf *mdev, struct p_header80 *h)

View File

@ -241,30 +241,13 @@ struct hlist_head *tl_hash_slot(struct drbd_conf *mdev, sector_t sector)
} }
/* application reads (drbd_request objects) */ /* application reads (drbd_request objects) */
static struct hlist_head *ar_hash_slot(struct drbd_conf *mdev, sector_t sector) static inline
struct hlist_head *ar_hash_slot(struct drbd_conf *mdev, sector_t sector)
{ {
return mdev->app_reads_hash return mdev->app_reads_hash
+ ((unsigned int)(sector) % APP_R_HSIZE); + ((unsigned int)(sector) % APP_R_HSIZE);
} }
/* when we receive the answer for a read request,
* verify that we actually know about it */
static inline struct drbd_request *_ar_id_to_req(struct drbd_conf *mdev,
u64 id, sector_t sector)
{
struct hlist_head *slot = ar_hash_slot(mdev, sector);
struct hlist_node *n;
struct drbd_request *req;
hlist_for_each_entry(req, n, slot, collision) {
if ((unsigned long)req == (unsigned long)id) {
D_ASSERT(req->sector == sector);
return req;
}
}
return NULL;
}
static inline void drbd_req_make_private_bio(struct drbd_request *req, struct bio *bio_src) static inline void drbd_req_make_private_bio(struct drbd_request *req, struct bio *bio_src)
{ {
struct bio *bio; struct bio *bio;