From: Zhukov Andrew <zhukov.andrew@xakep.ru>
To: linux-newbie@vger.kernel.org
Subject: generic_make_request - callback does not work
Date: Sat, 24 Mar 2012 20:38:36 +0400 [thread overview]
Message-ID: <CAA3FJ=SNw9AEvriERDfyPuwcwLEkeku=Zb8q-Rp48Yyxwgx95w@mail.gmail.com> (raw)
Hi all!
I have the next code of driver:
void my_end_request(struct bio* child, int error)
{
my_private_t* private = child->bi_private;
complete((struct completion*)private->completion);
}
int my_submit_request
(
my_handle_t* handle,
int rw,
int mode,
struct bio* bio,
void* user_private_data,
bio_end_io_t* user_callback
)
{
struct bio* child = NULL;
my_private_t* private = NULL;
my_registry_t* registry = NULL;
int direction = -1;
DECLARE_COMPLETION_ONSTACK(completion);
registry = handle->registry;
direction = bio_data_dir(bio);
child = bio_clone(bio, GFP_NOIO);
private = my_private_get(registry->my_cache_private); // here we get
a structure, that contains some of our data
child->bi_end_io = (bio_end_io_t*)my_end_request; // set the callback
child->bi_bdev = handle->bdev; // reading will be doing from this device
private->completion = &completion;
private->parent = bio;
private->user_private_data = user_private_data;
private->user_callback = user_callback;
private->mode = mode;
private->handle = handle;
child->bi_private = private;
generic_make_request(child);
wait_for_completion(&completion); // waiting to complete the reading
// yet another code
}
I'm trying to redirect requests (only read) to another device. In a
function my_submit_request I'm call the bio_clone and then
generic_make_request.
And also I'm call wait_for_completion (& completion) for waiting for
the reading. The callback function should work when the reading will
be completed.
The problem is, no callback call, and wait_for_completion does not
return control.
What am I doing wrong?
--
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
reply other threads:[~2012-03-24 16:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAA3FJ=SNw9AEvriERDfyPuwcwLEkeku=Zb8q-Rp48Yyxwgx95w@mail.gmail.com' \
--to=zhukov.andrew@xakep.ru \
--cc=linux-newbie@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).