Skip to content

Commit 06894ef

Browse files
Matias Bjørlingaxboe
authored andcommitted
lightnvm: use end_io callback instead of instance
When the lightnvm core had the "gennvm" layer between the device and the target, there was a need for the core to be able to figure out which target it should send an end_io callback to. Leading to a "double" end_io, first for the media manager instance, and then for the target instance. Now that core and gennvm is merged, there is no longer a need for this, and a single end_io callback will do. Signed-off-by: Matias Bjørling <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 84d4add commit 06894ef

File tree

6 files changed

+13
-20
lines changed

6 files changed

+13
-20
lines changed

drivers/block/null_blk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,8 @@ static void null_lnvm_end_io(struct request *rq, int error)
420420
{
421421
struct nvm_rq *rqd = rq->end_io_data;
422422

423-
nvm_end_io(rqd, error);
423+
rqd->error = error;
424+
nvm_end_io(rqd);
424425

425426
blk_put_request(rq);
426427
}

drivers/lightnvm/core.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -773,17 +773,16 @@ void nvm_free_rqd_ppalist(struct nvm_dev *dev, struct nvm_rq *rqd)
773773
}
774774
EXPORT_SYMBOL(nvm_free_rqd_ppalist);
775775

776-
void nvm_end_io(struct nvm_rq *rqd, int error)
776+
void nvm_end_io(struct nvm_rq *rqd)
777777
{
778778
struct nvm_tgt_dev *tgt_dev = rqd->dev;
779-
struct nvm_tgt_instance *ins = rqd->ins;
780779

781780
/* Convert address space */
782781
if (tgt_dev)
783782
nvm_rq_dev_to_tgt(tgt_dev, rqd);
784783

785-
rqd->error = error;
786-
ins->tt->end_io(rqd);
784+
if (rqd->end_io)
785+
rqd->end_io(rqd);
787786
}
788787
EXPORT_SYMBOL(nvm_end_io);
789788

drivers/lightnvm/rrpc.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ static void rrpc_end_io_write(struct rrpc *rrpc, struct rrpc_rq *rrqd,
779779

780780
static void rrpc_end_io(struct nvm_rq *rqd)
781781
{
782-
struct rrpc *rrpc = container_of(rqd->ins, struct rrpc, instance);
782+
struct rrpc *rrpc = rqd->private;
783783
struct nvm_tgt_dev *dev = rrpc->dev;
784784
struct rrpc_rq *rrqd = nvm_rq_to_pdu(rqd);
785785
uint8_t npages = rqd->nr_ppas;
@@ -972,8 +972,9 @@ static int rrpc_submit_io(struct rrpc *rrpc, struct bio *bio,
972972

973973
bio_get(bio);
974974
rqd->bio = bio;
975-
rqd->ins = &rrpc->instance;
975+
rqd->private = rrpc;
976976
rqd->nr_ppas = nr_pages;
977+
rqd->end_io = rrpc_end_io;
977978
rrq->flags = flags;
978979

979980
err = nvm_submit_io(dev, rqd);
@@ -1532,7 +1533,6 @@ static void *rrpc_init(struct nvm_tgt_dev *dev, struct gendisk *tdisk)
15321533
if (!rrpc)
15331534
return ERR_PTR(-ENOMEM);
15341535

1535-
rrpc->instance.tt = &tt_rrpc;
15361536
rrpc->dev = dev;
15371537
rrpc->disk = tdisk;
15381538

@@ -1611,7 +1611,6 @@ static struct nvm_tgt_type tt_rrpc = {
16111611

16121612
.make_rq = rrpc_make_rq,
16131613
.capacity = rrpc_capacity,
1614-
.end_io = rrpc_end_io,
16151614

16161615
.init = rrpc_init,
16171616
.exit = rrpc_exit,

drivers/lightnvm/rrpc.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,6 @@ struct rrpc_lun {
102102
};
103103

104104
struct rrpc {
105-
/* instance must be kept in top to resolve rrpc in unprep */
106-
struct nvm_tgt_instance instance;
107-
108105
struct nvm_tgt_dev *dev;
109106
struct gendisk *disk;
110107

drivers/nvme/host/lightnvm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ static void nvme_nvm_end_io(struct request *rq, int error)
484484
struct nvm_rq *rqd = rq->end_io_data;
485485

486486
rqd->ppa_status = nvme_req(rq)->result.u64;
487-
nvm_end_io(rqd, error);
487+
rqd->error = error;
488+
nvm_end_io(rqd);
488489

489490
kfree(nvme_req(rq)->cmd);
490491
blk_mq_free_request(rq);

include/linux/lightnvm.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,6 @@ struct nvm_target {
213213
struct gendisk *disk;
214214
};
215215

216-
struct nvm_tgt_instance {
217-
struct nvm_tgt_type *tt;
218-
};
219-
220216
#define ADDR_EMPTY (~0ULL)
221217

222218
#define NVM_VERSION_MAJOR 1
@@ -227,7 +223,6 @@ struct nvm_rq;
227223
typedef void (nvm_end_io_fn)(struct nvm_rq *);
228224

229225
struct nvm_rq {
230-
struct nvm_tgt_instance *ins;
231226
struct nvm_tgt_dev *dev;
232227

233228
struct bio *bio;
@@ -251,6 +246,8 @@ struct nvm_rq {
251246

252247
u64 ppa_status; /* ppa media status */
253248
int error;
249+
250+
void *private;
254251
};
255252

256253
static inline struct nvm_rq *nvm_rq_from_pdu(void *pdu)
@@ -450,7 +447,6 @@ struct nvm_tgt_type {
450447
/* target entry points */
451448
nvm_tgt_make_rq_fn *make_rq;
452449
nvm_tgt_capacity_fn *capacity;
453-
nvm_end_io_fn *end_io;
454450

455451
/* module-specific init/teardown */
456452
nvm_tgt_init_fn *init;
@@ -484,7 +480,7 @@ extern int nvm_get_l2p_tbl(struct nvm_tgt_dev *, u64, u32, nvm_l2p_update_fn *,
484480
void *);
485481
extern int nvm_get_area(struct nvm_tgt_dev *, sector_t *, sector_t);
486482
extern void nvm_put_area(struct nvm_tgt_dev *, sector_t);
487-
extern void nvm_end_io(struct nvm_rq *, int);
483+
extern void nvm_end_io(struct nvm_rq *);
488484
extern int nvm_bb_tbl_fold(struct nvm_dev *, u8 *, int);
489485
extern int nvm_get_tgt_bb_tbl(struct nvm_tgt_dev *, struct ppa_addr, u8 *);
490486

0 commit comments

Comments
 (0)