|
26 | 26 | #include "xfs_health.h" |
27 | 27 | #include "xfs_symlink_remote.h" |
28 | 28 |
|
29 | | -/* ----- Kernel only functions below ----- */ |
30 | | -int |
31 | | -xfs_readlink_bmap_ilocked( |
32 | | - struct xfs_inode *ip, |
33 | | - char *link) |
34 | | -{ |
35 | | - struct xfs_mount *mp = ip->i_mount; |
36 | | - struct xfs_bmbt_irec mval[XFS_SYMLINK_MAPS]; |
37 | | - struct xfs_buf *bp; |
38 | | - xfs_daddr_t d; |
39 | | - char *cur_chunk; |
40 | | - int pathlen = ip->i_disk_size; |
41 | | - int nmaps = XFS_SYMLINK_MAPS; |
42 | | - int byte_cnt; |
43 | | - int n; |
44 | | - int error = 0; |
45 | | - int fsblocks = 0; |
46 | | - int offset; |
47 | | - |
48 | | - xfs_assert_ilocked(ip, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL); |
49 | | - |
50 | | - fsblocks = xfs_symlink_blocks(mp, pathlen); |
51 | | - error = xfs_bmapi_read(ip, 0, fsblocks, mval, &nmaps, 0); |
52 | | - if (error) |
53 | | - goto out; |
54 | | - |
55 | | - offset = 0; |
56 | | - for (n = 0; n < nmaps; n++) { |
57 | | - d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock); |
58 | | - byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount); |
59 | | - |
60 | | - error = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 0, |
61 | | - &bp, &xfs_symlink_buf_ops); |
62 | | - if (xfs_metadata_is_sick(error)) |
63 | | - xfs_inode_mark_sick(ip, XFS_SICK_INO_SYMLINK); |
64 | | - if (error) |
65 | | - return error; |
66 | | - byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt); |
67 | | - if (pathlen < byte_cnt) |
68 | | - byte_cnt = pathlen; |
69 | | - |
70 | | - cur_chunk = bp->b_addr; |
71 | | - if (xfs_has_crc(mp)) { |
72 | | - if (!xfs_symlink_hdr_ok(ip->i_ino, offset, |
73 | | - byte_cnt, bp)) { |
74 | | - xfs_inode_mark_sick(ip, XFS_SICK_INO_SYMLINK); |
75 | | - error = -EFSCORRUPTED; |
76 | | - xfs_alert(mp, |
77 | | -"symlink header does not match required off/len/owner (0x%x/Ox%x,0x%llx)", |
78 | | - offset, byte_cnt, ip->i_ino); |
79 | | - xfs_buf_relse(bp); |
80 | | - goto out; |
81 | | - |
82 | | - } |
83 | | - |
84 | | - cur_chunk += sizeof(struct xfs_dsymlink_hdr); |
85 | | - } |
86 | | - |
87 | | - memcpy(link + offset, cur_chunk, byte_cnt); |
88 | | - |
89 | | - pathlen -= byte_cnt; |
90 | | - offset += byte_cnt; |
91 | | - |
92 | | - xfs_buf_relse(bp); |
93 | | - } |
94 | | - ASSERT(pathlen == 0); |
95 | | - |
96 | | - link[ip->i_disk_size] = '\0'; |
97 | | - error = 0; |
98 | | - |
99 | | - out: |
100 | | - return error; |
101 | | -} |
102 | | - |
103 | 29 | int |
104 | 30 | xfs_readlink( |
105 | 31 | struct xfs_inode *ip, |
@@ -141,7 +67,7 @@ xfs_readlink( |
141 | 67 | memcpy(link, ip->i_df.if_data, pathlen + 1); |
142 | 68 | error = 0; |
143 | 69 | } else { |
144 | | - error = xfs_readlink_bmap_ilocked(ip, link); |
| 70 | + error = xfs_symlink_remote_read(ip, link); |
145 | 71 | } |
146 | 72 |
|
147 | 73 | xfs_iunlock(ip, XFS_ILOCK_SHARED); |
|
0 commit comments