Hi Richard, On Fri, Dec 09, 2022 at 08:22:41AM +0000, Richard W.M. Jones wrote: > On Fri, Dec 09, 2022 at 04:12:18PM +0800, Ming Lei wrote: > > Hello Richard and Guys, > > > > I am trying to figure out one PR for ubdsrv to sync with upstream. > > > > I found the following change in history update: > > > > commit 2ab1e571717a13edddc572269608e918e449a3b8 (origin/main) > > Author: Richard W.M. Jones <rjones@xxxxxxxxxx> > > Date: Thu Nov 3 11:33:42 2022 +0000 > > > > Move to a newer tag (1.0-rc3 + a couple of upstream patches) > > > > diff --git a/sources b/sources > > index 47e83d8..1735716 100644 > > --- a/sources > > +++ b/sources > > @@ -1 +1 @@ > > -SHA512 (ubdsrv-698c92c9d292903adae142a86d2fee10fce91850.tar.gz) = a12e218b6d97631b9726cdaa2e14dfb7f4df422dd77265701f40ba8704c7d4ccac6c632f635115863f8694bd626f06f67e2ebdf93ae92778a0dae3cddb0259c6 > > +SHA512 (ubdsrv-ca8baff898868f2ee6f5cdda9c16cf8d94435262.tar.gz) = 9d85271cc73026e7ff8a58153cffb4fd9f760c136d790e0b681cd6b903813cd9d9b98bba934c7ef1248ee0514fe7a6967d3ee65afd6cc44ea0bd3a0796c62ff3 > > diff --git a/ubdsrv.spec b/ubdsrv.spec > > These are generated by me running "fedpkg sources". I don't believe > it's possible for non-packagers to use this (since it actually uploads > the file to Fedora servers), but in any case it doesn't matter, just > make a note of the new commit has you want to use when creating the PR. I just created PR#2 for sync ubdsrv with upstream commit 483d710ab8630304d13b59c2776f7386a566c467, and one new public header is added. Also nbdublk needs to sync with this API change, which is basically stable now, and the attached patch is verified, please update nbdublk too. thanks, Ming
diff --git a/ublk/nbdublk.c b/ublk/nbdublk.c index 53af840..00aa23e 100644 --- a/ublk/nbdublk.c +++ b/ublk/nbdublk.c @@ -166,6 +166,7 @@ main (int argc, char *argv[]) uint64_t max_block_size; const char *s; struct ublksrv_dev_data data = { .dev_id = -1 }; + const struct ublksrv_ctrl_dev_info *dinfo; struct sigaction sa = { 0 }; for (;;) { @@ -420,6 +421,8 @@ main (int argc, char *argv[]) exit (EXIT_FAILURE); } + dinfo = ublksrv_ctrl_get_dev_info(dev); + /* Register signal handlers to try to stop the device. */ sa.sa_handler = signal_handler; sigaction (SIGHUP, &sa, NULL); @@ -432,14 +435,14 @@ main (int argc, char *argv[]) if (r < 0) { errno = -r; fprintf (stderr, "%s: ublksrv_ctrl_add_dev: "DEVICE_PREFIX "%d: %m\n", - argv[0], dev->dev_info.dev_id); + argv[0], dinfo->dev_id); ublksrv_ctrl_deinit (dev); exit (EXIT_FAILURE); } if (verbose) fprintf (stderr, "%s: created %s%d\n", - argv[0], DEVICE_PREFIX, dev->dev_info.dev_id); + argv[0], DEVICE_PREFIX, dinfo->dev_id); /* XXX nbdfuse creates a pid file. However I reason that you can * tell if the service is available when the block device is created diff --git a/ublk/tgt.c b/ublk/tgt.c index e25e072..3fb2223 100644 --- a/ublk/tgt.c +++ b/ublk/tgt.c @@ -33,6 +33,7 @@ #define _Atomic /**/ #endif +#include <limits.h> #include <ublksrv.h> #include <ublksrv_aio.h> @@ -53,7 +54,7 @@ * The thread_info entry is shared between each pair of threads. */ struct thread_info { - struct ublksrv_dev *dev; + const struct ublksrv_dev *dev; size_t i; /* index into nbd.ptr[], also q_id */ pthread_t io_uring_thread; pthread_t nbd_work_thread; @@ -208,7 +209,7 @@ nbd_work_thread (void *vpinfo) ublksrv_aio_complete_worker (aio_ctx, &compl); - if (nbd_poll2 (h, aio_ctx->efd, -1) == -1) { + if (nbd_poll2 (h, ublksrv_aio_get_efd(aio_ctx), -1) == -1) { fprintf (stderr, "%s\n", nbd_get_error ()); exit (EXIT_FAILURE); } @@ -221,15 +222,17 @@ static void * io_uring_thread (void *vpinfo) { struct thread_info *thread_info = vpinfo; - struct ublksrv_dev *dev = thread_info->dev; - const unsigned dev_id = dev->ctrl_dev->dev_info.dev_id; + const struct ublksrv_dev *dev = thread_info->dev; + const struct ublksrv_ctrl_dev *cdev = ublksrv_get_ctrl_dev(dev); + const struct ublksrv_ctrl_dev_info *dinfo = ublksrv_ctrl_get_dev_info(cdev); + const unsigned dev_id = dinfo->dev_id; const size_t q_id = thread_info->i; - struct ublksrv_queue *q; + const struct ublksrv_queue *q; int r; + int tid = gettid(); pthread_mutex_lock (&jbuf_lock); - ublksrv_json_write_queue_info (dev->ctrl_dev, jbuf, sizeof jbuf, - q_id, gettid ()); + ublksrv_json_write_queue_info (cdev, jbuf, sizeof jbuf, q_id, tid); pthread_mutex_unlock (&jbuf_lock); q = ublksrv_queue_init (dev, q_id, NULL); @@ -240,7 +243,7 @@ io_uring_thread (void *vpinfo) if (verbose) fprintf (stderr, "%s: ublk tid %d dev %d queue %d started\n", - "nbdublk", q->tid, dev_id, q->q_id); + "nbdublk", tid, dev_id, q->q_id); for (;;) { r = ublksrv_process_io (q); @@ -255,7 +258,7 @@ io_uring_thread (void *vpinfo) if (verbose) fprintf (stderr, "%s: ublk tid %d dev %d queue %d exited\n", - "nbdublk", q->tid, dev_id, q->q_id); + "nbdublk", tid, dev_id, q->q_id); ublksrv_queue_deinit (q); return NULL; @@ -265,7 +268,7 @@ static int set_parameters (struct ublksrv_ctrl_dev *ctrl_dev, const struct ublksrv_dev *dev) { - struct ublksrv_ctrl_dev_info *dinfo = &ctrl_dev->dev_info; + const struct ublksrv_ctrl_dev_info *dinfo = ublksrv_ctrl_get_dev_info(ctrl_dev); const unsigned attrs = (readonly ? UBLK_ATTR_READ_ONLY : 0) | (rotational ? UBLK_ATTR_ROTATIONAL : 0) | @@ -305,8 +308,8 @@ set_parameters (struct ublksrv_ctrl_dev *ctrl_dev, int start_daemon (struct ublksrv_ctrl_dev *ctrl_dev) { - const struct ublksrv_ctrl_dev_info *dinfo = &ctrl_dev->dev_info; - struct ublksrv_dev *dev; + const struct ublksrv_ctrl_dev_info *dinfo = ublksrv_ctrl_get_dev_info(ctrl_dev); + const struct ublksrv_dev *dev; size_t i; int r; @@ -418,7 +421,8 @@ start_daemon (struct ublksrv_ctrl_dev *ctrl_dev) static int init_tgt (struct ublksrv_dev *dev, int type, int argc, char *argv[]) { - const struct ublksrv_ctrl_dev_info *info = &dev->ctrl_dev->dev_info; + const struct ublksrv_ctrl_dev *cdev = ublksrv_get_ctrl_dev(dev); + const struct ublksrv_ctrl_dev_info *info = ublksrv_ctrl_get_dev_info(cdev); struct ublksrv_tgt_info *tgt = &dev->tgt; struct ublksrv_tgt_base_json tgt_json = { .type = type, @@ -435,14 +439,14 @@ init_tgt (struct ublksrv_dev *dev, int type, int argc, char *argv[]) tgt->tgt_ring_depth = info->queue_depth; tgt->nr_fds = 0; - ublksrv_json_write_dev_info (dev->ctrl_dev, jbuf, sizeof jbuf); + ublksrv_json_write_dev_info (ublksrv_get_ctrl_dev(dev), jbuf, sizeof jbuf); ublksrv_json_write_target_base_info (jbuf, sizeof jbuf, &tgt_json); return 0; } static void -handle_event (struct ublksrv_queue *q) +handle_event (const struct ublksrv_queue *q) { struct ublksrv_aio_ctx *aio_ctx = thread_info.ptr[q->q_id].aio_ctx; @@ -454,16 +458,16 @@ handle_event (struct ublksrv_queue *q) } static int -handle_io_async (struct ublksrv_queue *q, int tag) +handle_io_async (const struct ublksrv_queue *q, const struct ublk_io_data *io) { struct ublksrv_aio_ctx *aio_ctx = thread_info.ptr[q->q_id].aio_ctx; - const struct ublksrv_io_desc *iod = ublksrv_get_iod (q, tag); + const struct ublksrv_io_desc *iod = io->iod; struct ublksrv_aio *req = ublksrv_aio_alloc_req (aio_ctx, 0); req->io = *iod; - req->id = ublksrv_aio_pid_tag (q->q_id, tag); + req->id = ublksrv_aio_pid_tag (q->q_id, io->tag); if (verbose) - fprintf (stderr, "%s: qid %d tag %d\n", "nbdublk", q->q_id, tag); + fprintf (stderr, "%s: qid %d tag %d\n", "nbdublk", q->q_id, io->tag); ublksrv_aio_submit_req (aio_ctx, q, req); return 0;
_______________________________________________ devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue