Skip to contentSkip to conversation

struct page question

DISCUSSION Luben Tuikov 2 participants 4 messages Sep 24, 2002 – Sep 26, 2002

lore
Share & tools
lore
#0 lore raw

Is it possible to build a struct page *page, where page_address(page) == some virtual address (not high mem of course)?

The reason I want to do this is so that I can pass it to generic_make_request(), having only a pointer to a buffer and size to a buffer, and the fact that not all devices have request_fn() exposed (e.g. md).

Apparently I cannot just set b_data and b_size, b_page also has to be set and it also seems that it will not work if page_address(b_page) != b_data...

Thanks,

Signature · 1 line
Luben
#1 lore raw
Quoted 11 lines · Luben Tuikov

Is it possible to build a struct page *page, where page_address(page) == some virtual address (not high mem of course)?

The reason I want to do this is so that I can pass it to generic_make_request(), having only a pointer to a buffer and size to a buffer, and the fact that not all devices have request_fn() exposed (e.g. md).

Apparently I cannot just set b_data and b_size, b_page also has to be set and it also seems that it will not work if page_address(b_page) != b_data...

bh->b_page = virt_to_page(va);
bh->b_data = va;

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 7 lines · Jens Axboe
Quoted 4 lines

Apparently I cannot just set b_data and b_size, b_page also has to be set and it also seems that it will not work if page_address(b_page) != b_data...

bh->b_page = virt_to_page(va);
bh->b_data = va;

Thanks Jens again.

My doubts are that va might not point to page->virtual, but may point ``in the middle'' of the page, in which case md will cough up since it does the page_address(b_page) != b_data then BUG()...

I.e. I cannot guarantee about where va points (just that it is NOT highmem).

Signature · 1 line
Luben
#3 lore raw
Quoted 9 lines · Luben Tuikov
Quoted 7 lines · Jens Axboe
Quoted 4 lines

Apparently I cannot just set b_data and b_size, b_page also has to be set and it also seems that it will not work if page_address(b_page) != b_data...

bh->b_page = virt_to_page(va);
bh->b_data = va;

Quoted 6 lines

Thanks Jens again.

My doubts are that va might not point to page->virtual, but may point ``in the middle'' of the page, in which case md will cough up since it does the page_address(b_page) != b_data then BUG()...

It's quite legal for b_data to point to somewhere in the middle of the page. See usage of bh_offset(). What coughs up and where?

Signature · 1 line
Jens Axboe