Darrick J. Wong | 673930c | 2016-08-03 11:33:43 +1000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2014 Red Hat, Inc. |
| 3 | * All Rights Reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it would be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write the Free Software Foundation, |
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | #include "xfs.h" |
| 19 | #include "xfs_fs.h" |
| 20 | #include "xfs_shared.h" |
| 21 | #include "xfs_format.h" |
| 22 | #include "xfs_log_format.h" |
| 23 | #include "xfs_trans_resv.h" |
| 24 | #include "xfs_bit.h" |
| 25 | #include "xfs_sb.h" |
| 26 | #include "xfs_mount.h" |
| 27 | #include "xfs_defer.h" |
| 28 | #include "xfs_da_format.h" |
| 29 | #include "xfs_da_btree.h" |
| 30 | #include "xfs_btree.h" |
| 31 | #include "xfs_trans.h" |
| 32 | #include "xfs_alloc.h" |
| 33 | #include "xfs_rmap.h" |
| 34 | #include "xfs_trans_space.h" |
| 35 | #include "xfs_trace.h" |
| 36 | #include "xfs_error.h" |
| 37 | #include "xfs_extent_busy.h" |
| 38 | |
| 39 | int |
| 40 | xfs_rmap_free( |
| 41 | struct xfs_trans *tp, |
| 42 | struct xfs_buf *agbp, |
| 43 | xfs_agnumber_t agno, |
| 44 | xfs_agblock_t bno, |
| 45 | xfs_extlen_t len, |
| 46 | struct xfs_owner_info *oinfo) |
| 47 | { |
| 48 | struct xfs_mount *mp = tp->t_mountp; |
| 49 | int error = 0; |
| 50 | |
| 51 | if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) |
| 52 | return 0; |
| 53 | |
| 54 | trace_xfs_rmap_unmap(mp, agno, bno, len, false, oinfo); |
| 55 | if (1) |
| 56 | goto out_error; |
| 57 | trace_xfs_rmap_unmap_done(mp, agno, bno, len, false, oinfo); |
| 58 | return 0; |
| 59 | |
| 60 | out_error: |
| 61 | trace_xfs_rmap_unmap_error(mp, agno, error, _RET_IP_); |
| 62 | return error; |
| 63 | } |
| 64 | |
| 65 | int |
| 66 | xfs_rmap_alloc( |
| 67 | struct xfs_trans *tp, |
| 68 | struct xfs_buf *agbp, |
| 69 | xfs_agnumber_t agno, |
| 70 | xfs_agblock_t bno, |
| 71 | xfs_extlen_t len, |
| 72 | struct xfs_owner_info *oinfo) |
| 73 | { |
| 74 | struct xfs_mount *mp = tp->t_mountp; |
| 75 | int error = 0; |
| 76 | |
| 77 | if (!xfs_sb_version_hasrmapbt(&mp->m_sb)) |
| 78 | return 0; |
| 79 | |
| 80 | trace_xfs_rmap_map(mp, agno, bno, len, false, oinfo); |
| 81 | if (1) |
| 82 | goto out_error; |
| 83 | trace_xfs_rmap_map_done(mp, agno, bno, len, false, oinfo); |
| 84 | return 0; |
| 85 | |
| 86 | out_error: |
| 87 | trace_xfs_rmap_map_error(mp, agno, error, _RET_IP_); |
| 88 | return error; |
| 89 | } |