1 | /***************************************************************************** |
2 | |
3 | Copyright (c) 1995, 2015, Oracle and/or its affiliates. All Rights Reserved. |
4 | |
5 | This program is free software; you can redistribute it and/or modify it under |
6 | the terms of the GNU General Public License as published by the Free Software |
7 | Foundation; version 2 of the License. |
8 | |
9 | This program is distributed in the hope that it will be useful, but WITHOUT |
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
11 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
12 | |
13 | You should have received a copy of the GNU General Public License along with |
14 | this program; if not, write to the Free Software Foundation, Inc., |
15 | 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA |
16 | |
17 | *****************************************************************************/ |
18 | |
19 | /******************************************************************//** |
20 | @file include/fut0fut.ic |
21 | File-based utilities |
22 | |
23 | Created 12/13/1995 Heikki Tuuri |
24 | ***********************************************************************/ |
25 | |
26 | #include "sync0rw.h" |
27 | #include "buf0buf.h" |
28 | |
29 | /** Gets a pointer to a file address and latches the page. |
30 | @param[in] space space id |
31 | @param[in] page_size page size |
32 | @param[in] addr file address |
33 | @param[in] rw_latch RW_S_LATCH, RW_X_LATCH, RW_SX_LATCH |
34 | @param[in,out] mtr mini-transaction |
35 | @param[out] ptr_block file page |
36 | @return pointer to a byte in (*ptr_block)->frame; the *ptr_block is |
37 | bufferfixed and latched */ |
38 | UNIV_INLINE |
39 | byte* |
40 | fut_get_ptr( |
41 | ulint space, |
42 | const page_size_t& page_size, |
43 | fil_addr_t addr, |
44 | rw_lock_type_t rw_latch, |
45 | mtr_t* mtr, |
46 | buf_block_t** ptr_block) |
47 | { |
48 | buf_block_t* block; |
49 | byte* ptr = NULL; |
50 | |
51 | ut_ad(addr.boffset < srv_page_size); |
52 | ut_ad((rw_latch == RW_S_LATCH) |
53 | || (rw_latch == RW_X_LATCH) |
54 | || (rw_latch == RW_SX_LATCH)); |
55 | |
56 | block = buf_page_get(page_id_t(space, addr.page), page_size, |
57 | rw_latch, mtr); |
58 | |
59 | ptr = buf_block_get_frame(block) + addr.boffset; |
60 | |
61 | buf_block_dbg_add_level(block, SYNC_NO_ORDER_CHECK); |
62 | |
63 | if (ptr_block != NULL) { |
64 | *ptr_block = block; |
65 | } |
66 | |
67 | return(ptr); |
68 | } |
69 | |