[10:36] <SysMan-One> Hello There!
[10:36]  * apw looks up
[10:36] <SysMan-One> I have a question is related to the Block I/O.
[10:36] <SysMan-One> It's acceptable here or not ?
[10:37] <apw> i would ask and see what happens, as without more context i doubt i can tell if it is going to be off topic
[10:37] <SysMan-One> Ok.
[10:38] <SysMan-One> I working on filter-driver which is live on top of other block-device.
[10:39] <SysMan-One> I intercept READ/WRITE request to performs modifications of disk sectors before write to disk and before return to kernel.
[10:40] <apw> something like device-mapper then
[10:41] <SysMan-One> Right!  The first question: I clonning oroginal BIO and  buffers to be written to disk as follows:
[10:42] <SysMan-One> 	if ( !(*dst = bio_clone_bioset(src, gfp /* GFP_KERNEL */, src->bi_pool /* NULL*/)) )
[10:42] <SysMan-One> 		{
[10:42] <SysMan-One> 		printk(KERN_ERR  __MODULE__ ": bio_clone_bioset() -> NULL\n");
[10:42] <SysMan-One> 		return	-ENOMEM;
[10:42] <SysMan-One> 		}
[10:42] <SysMan-One> 	if ( status = bio_alloc_pages(*dst , GFP_KERNEL))
[10:42] <SysMan-One> 		{
[10:42] <SysMan-One> 		printk(KERN_ERR  __MODULE__ ": bio_alloc_pages() -> %d\n", status);
[10:42] <SysMan-One> 		return	status;
[10:42] <SysMan-One> 		}
[10:42] <SysMan-One> bio_copy_data(*dst, src);
[10:42] <SysMan-One> Is it correct way ?
[10:43] <SysMan-One> Sorry, forgot include header:
[10:43] <SysMan-One> static int __dua_bio_clone	(
[10:43] <SysMan-One> 		struct bio	*src,
[10:43] <SysMan-One> 		struct bio	**dst
[10:43] <SysMan-One> 			)
[10:43] <SysMan-One> {
[10:43] <SysMan-One> int	status;
[10:43] <SysMan-One> gfp_t	gfp =  GFP_NOIO; //GFP_KERNEL; // (GFP_NOIO | __GFP_HIGH);
[10:46] <SysMan-One> So, is there someone who can help me to resolve question ?
[10:54] <apw> SysMan-One, i would look at what device-mapper does as it is likley the kind of framework you are becoming
[10:54] <apw> though why would you not make this a device-mapper personality in that case
[10:57] <SysMan-One> Thanks for you attention. A some task conditions prevents to use device-mapper way, it's not my choice.
[10:57] <apw> but as it is doing the same kind of things, it is likley got the right ways of doing things in it
[10:58] <apw> one of the encryption personalitys sounds closest
[10:59] <SysMan-One> I understand ... I cannot explain more about of the project, but u are right here, it's transparent en/de-cryption.
[11:01] <SysMan-One> Can i  ask  second question ?
[11:01] <apw> yep
[11:01] <SysMan-One> Ok. Thanks.
[11:04] <SysMan-One> I wrote "my_endio" routine to performs processing of the read disk blocks. I'll past some portions of code follows, ok ?
[11:04] <apw> better to pastebinit
[11:04] <SysMan-One> Hmmm ... It's about of 60-70 lines.
[11:05] <apw> right which is about 58 lines too much to paste in irc, as it comes out a one line per second and annoys everyone
[11:06] <SysMan-One> Ok. Will use pastebin and post the link.
[11:13] <SysMan-One> The piece of code which is supposed to process read disk blocks has been placed at the : https://pastebin.com/Pdyf4dNL
[11:13] <SysMan-One> May be I doing something wrong with iterators ?
[11:23] <apw> doesn't bio_copy_block do the sort of thing you are doing, so how it handles them (which seems different) might help
[11:27] <SysMan-One> I working under 4.4 and 4.15 kernels (Ubuntu 16) . I did not found "bio_copy_block" routine in the headers and sources. Do u mean something other ?
[11:28] <apw> in mainline kernel linus' tip it exists and looks like something you could use as a template
[11:30] <SysMan-One> bio_copy_data - works for me, my primary question is related to memory allocation:
[11:30] <SysMan-One>  bio_clone_bioset(src, GFP_NOIO, src->bi_pool) - it's right usage ?
[11:31] <SysMan-One> using GFP_KERNEL in  bio_alloc_pages(*dst , GFP_KERNEL) - is acceptable ?
[11:33] <SysMan-One> (yes, bio_copy_data I have used as template) - but why .bv_length is zero ?!
[11:38] <SysMan-One> Hello !
[11:38] <SysMan-One> Can we off from main chatting or it will bother u ?
[11:39] <apw> sure
[12:11] <apw> in both cases you care about whether it is safe to block there
[12:12] <apw> what locks you have held etc, as to whether it is safe
[12:12] <apw> using NOIO seems logical as you are trying to do IO now, and if you
[12:12] <apw> cannot get enough memory to do _this_ io, trying to do io to free memory is no more likely to work
[22:42] <kees> apw: can I convince you to enable some kernel options? :) https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1783651
[23:02] <tyhicks> kees (cc apw): thanks - I left a comment but I'm at my eod at this point so that's all I can do for now :)
[23:58] <kees> tyhicks: thanks! I don't want the sanity checking -- I think that's too heavy-duty for the general case.