From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============7119080398439739954==" MIME-Version: 1.0 From: Zhengyu Zhang Subject: Re: [SPDK] how to use blobstore with pthread Date: Tue, 16 Jan 2018 09:29:45 +0800 Message-ID: In-Reply-To: 2BFA8F2383C3784C90698C10BC0963195EF5238F@SHSMSX103.ccr.corp.intel.com List-ID: To: spdk@lists.01.org --===============7119080398439739954== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Cunyin, Thanks for your reply! I do call spdk_bs_alloc_io_channle() before the read/write. But since the function needs a `struct spdk_blob_store *bs` parameter, we have to call it after spdk_bs_init/load, usually in init/load callbacks. But spdk_bs_init/load is where segmentation fault happens: (gdb) bt #0 0x0000000000000000 in ?? () #1 0x0000000000430290 in spdk_poller_register (fn=3Dfn(a)entry=3D0x4065f0 , arg=3D0x2629080, period_microseconds =3D period_microseconds(a)entry=3D0)at io_channel.c:226 #2 0x00000000004065c1 in ioat_create_cb (io_device=3D, ctx_buf=3D0x7f16ac00ecc0) at copy_engine_ioat.c:206 #3 0x000000000043074c in spdk_get_io_channel (io_device=3D0x67d020 ) at io_channel.c:453 #4 0x000000000042d11b in copy_create_cb (io_device=3D, ctx_buf=3D0x7f16ac00ec70) at copy_engine.c:186 #5 0x000000000043074c in spdk_get_io_channel (io_device=3D0x67d9d0 ) at io_channel.c:453 #6 0x0000000000429b69 in spdk_bdev_channel_create (io_device=3D, ctx_buf=3D0x7f16ac00ebc0) at bdev.c:847 #7 0x000000000043074c in spdk_get_io_channel (io_device=3D0x7f18abbeb5c0) at io_channel.c:453 #8 0x000000000041c426 in _spdk_bs_channel_create (io_device=3D0x7f16ac000a00, ctx_buf=3D0x7f16ac000b40) at blobstore.c:1425 #9 0x000000000043074c in spdk_get_io_channel (io_device=3Dio_device(a)entry=3D0x7f16ac000a00) at io_channel.c:453 #10 0x000000000041c588 in spdk_bs_register_md_thread (bs=3D0x7f16ac000a00) at blobstore.c:2649 #11 _spdk_bs_alloc (dev=3Ddev(a)entry=3D0x7f16ac000940, opts=3Dopts(a)entry=3D0x7f18bd414c10) at blobstore.c:1551 #12 0x000000000041f1ee in spdk_bs_init (dev=3D0x7f16ac000940, o=3Do(a)entry=3D0x0, cb_fn=3Dcb_fn(a)entry=3D0x405e70 , cb_arg=3Dcb_arg(a)entry=3D0x2622270) at blobstore.c:2279 #13 0x0000000000405dca in hello_work (hello_context=3D0x2622270) at hello_blob.c:412 #14 0x00007f18be74adc5 in start_thread () from /lib64/libpthread.so.0 Thanks! Zhengyu On 1/16/18 9:00 AM, Chang, Cunyin wrote: > Hi Zhengyu, > = > =C2=A0 > = > for new threads: > = > after you allocate thread, before you do the create, read, write, you > need allocate io channel by calling: > = > spdk_bs_alloc_io_channel(), > = > the blobs read/write need one IO channel. > = > =C2=A0 > = > -Cunyin > = > =C2=A0 > = > *From:*SPDK [mailto:spdk-bounces(a)lists.01.org] *On Behalf Of *Zhengyu Z= hang > *Sent:* Monday, January 15, 2018 11:20 PM > *To:* Storage Performance Development Kit > *Subject:* [SPDK] how to use blobstore with pthread > = > =C2=A0 > = > Hi list, > = > =C2=A0 > = > Could someone tell me how to integrate the=C2=A0blobstore=C2=A0into multi= thread > programs? I saw some examples using SPDK event framework to do > multithreading, but how to do that with the pthread=C2=A0library or C++ > std::thread is still mysterious to me... > = > =C2=A0 > = > My work flow is shown below. It gives me segmentation fault when it > init/load blobstore: > = > =C2=A0 > = > [main]: spdk_app_start -> get bdev -> pthread_create -> ... > = > =C2=A0 > = > [new threads]:=C2=A0 spdk_allocate_thread -> spdk_bdev_create_bs_dev -> > spdk_bs_init/load[SEG FAULT] -> create/open/write/ blobs > = > =C2=A0 > = > =C2=A0 > = > Thanks! > = > Zhengyu > = > =C2=A0 > = > =C2=A0 > = > =C2=A0 > = > =C2=A0 > = > --- > = > My thread routine: > = > =C2=A0 > = > + 393 #define THREAD_NUM=C2=A0 =C2=A0 (1) > = > + 394=C2=A0 > = > + 395 static void _spdk_send_msg(spdk_thread_fn fn, void *ctx, void > *thread_ctx) > = > + 396 { > = > + 397=C2=A0 =C2=A0 =C2=A0assert(false); > = > + 398 } > = > + 399=C2=A0 > = > + 400 int thread_routine(struct hello_context_t *hello_context) > = > + 401 { > = > + 402=C2=A0 =C2=A0 =C2=A0spdk_allocate_thread(_spdk_send_msg, NULL, NULL,= NULL, NULL); > = > + 403=C2=A0 > = > + 404=C2=A0 =C2=A0 =C2=A0struct spdk_bs_dev *bs_dev =3D NULL; > = > + 405=C2=A0 =C2=A0 =C2=A0bs_dev =3D spdk_bdev_create_bs_dev(hello_context= ->bdev, NULL, NULL); > = > + 406=C2=A0 =C2=A0 =C2=A0if (bs_dev =3D=3D NULL) { > = > + 407=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0SPDK_ERRLOG("Could not crea= te blob bdev!!\n"); > = > + 408=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0spdk_app_stop(-1); > = > + 409=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return; > = > + 410=C2=A0 =C2=A0 =C2=A0} > = > + 411=C2=A0 > = > + 412=C2=A0 =C2=A0 =C2=A0spdk_bs_init(bs_dev, NULL, bs_init_complete, hel= lo_context);=C2=A0 > // SEG FAULT > = > + 413 } > = > = > = > _______________________________________________ > SPDK mailing list > SPDK(a)lists.01.org > https://lists.01.org/mailman/listinfo/spdk >=20 --===============7119080398439739954==--