hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/xfs/xfs_symlink.c
....@@ -12,23 +12,15 @@
1212 #include "xfs_trans_resv.h"
1313 #include "xfs_bit.h"
1414 #include "xfs_mount.h"
15
-#include "xfs_da_format.h"
16
-#include "xfs_da_btree.h"
17
-#include "xfs_defer.h"
1815 #include "xfs_dir2.h"
1916 #include "xfs_inode.h"
20
-#include "xfs_ialloc.h"
21
-#include "xfs_alloc.h"
2217 #include "xfs_bmap.h"
2318 #include "xfs_bmap_btree.h"
24
-#include "xfs_bmap_util.h"
25
-#include "xfs_error.h"
2619 #include "xfs_quota.h"
20
+#include "xfs_symlink.h"
2721 #include "xfs_trans_space.h"
2822 #include "xfs_trace.h"
29
-#include "xfs_symlink.h"
3023 #include "xfs_trans.h"
31
-#include "xfs_log.h"
3224
3325 /* ----- Kernel only functions below ----- */
3426 int
....@@ -61,20 +53,10 @@
6153 d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock);
6254 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
6355
64
- bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 0,
65
- &xfs_symlink_buf_ops);
66
- if (!bp)
67
- return -ENOMEM;
68
- error = bp->b_error;
69
- if (error) {
70
- xfs_buf_ioerror_alert(bp, __func__);
71
- xfs_buf_relse(bp);
72
-
73
- /* bad CRC means corrupted metadata */
74
- if (error == -EFSBADCRC)
75
- error = -EFSCORRUPTED;
76
- goto out;
77
- }
56
+ error = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 0,
57
+ &bp, &xfs_symlink_buf_ops);
58
+ if (error)
59
+ return error;
7860 byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt);
7961 if (pathlen < byte_cnt)
8062 byte_cnt = pathlen;
....@@ -194,15 +176,12 @@
194176 return -ENAMETOOLONG;
195177 ASSERT(pathlen > 0);
196178
197
- udqp = gdqp = NULL;
198179 prid = xfs_get_initial_prid(dp);
199180
200181 /*
201182 * Make sure that we have allocated dquot(s) on disk.
202183 */
203
- error = xfs_qm_vop_dqalloc(dp,
204
- xfs_kuid_to_uid(current_fsuid()),
205
- xfs_kgid_to_gid(current_fsgid()), prid,
184
+ error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid,
206185 XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
207186 &udqp, &gdqp, &pdqp);
208187 if (error)
....@@ -212,7 +191,7 @@
212191 * The symlink will fit into the inode data fork?
213192 * There can't be any attributes so we get the whole variable part.
214193 */
215
- if (pathlen <= XFS_LITINO(mp, dp->i_d.di_version))
194
+ if (pathlen <= XFS_LITINO(mp))
216195 fs_blocks = 0;
217196 else
218197 fs_blocks = xfs_symlink_blocks(mp, pathlen);
....@@ -264,8 +243,7 @@
264243 */
265244 xfs_qm_vop_create_dqattach(tp, ip, udqp, gdqp, pdqp);
266245
267
- if (resblks)
268
- resblks -= XFS_IALLOC_SPACE_RES(mp);
246
+ resblks -= XFS_IALLOC_SPACE_RES(mp);
269247 /*
270248 * If the symlink will fit into the inode, write it inline.
271249 */
....@@ -273,7 +251,7 @@
273251 xfs_init_local_fork(ip, XFS_DATA_FORK, target_path, pathlen);
274252
275253 ip->i_d.di_size = pathlen;
276
- ip->i_d.di_format = XFS_DINODE_FMT_LOCAL;
254
+ ip->i_df.if_format = XFS_DINODE_FMT_LOCAL;
277255 xfs_trans_log_inode(tp, ip, XFS_ILOG_DDATA | XFS_ILOG_CORE);
278256 } else {
279257 int offset;
....@@ -286,8 +264,7 @@
286264 if (error)
287265 goto out_trans_cancel;
288266
289
- if (resblks)
290
- resblks -= fs_blocks;
267
+ resblks -= fs_blocks;
291268 ip->i_d.di_size = pathlen;
292269 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
293270
....@@ -298,12 +275,10 @@
298275
299276 d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock);
300277 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
301
- bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
302
- BTOBB(byte_cnt), 0);
303
- if (!bp) {
304
- error = -ENOMEM;
278
+ error = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
279
+ BTOBB(byte_cnt), 0, &bp);
280
+ if (error)
305281 goto out_trans_cancel;
306
- }
307282 bp->b_ops = &xfs_symlink_buf_ops;
308283
309284 byte_cnt = XFS_SYMLINK_BUF_SPACE(mp, byte_cnt);
....@@ -325,6 +300,7 @@
325300 }
326301 ASSERT(pathlen == 0);
327302 }
303
+ i_size_write(VFS_I(ip), ip->i_d.di_size);
328304
329305 /*
330306 * Create the directory entry for the symlink.
....@@ -409,7 +385,7 @@
409385 * either 1 or 2 extents and that we can
410386 * free them all in one bunmapi call.
411387 */
412
- ASSERT(ip->i_d.di_nextents > 0 && ip->i_d.di_nextents <= 2);
388
+ ASSERT(ip->i_df.if_nextents > 0 && ip->i_df.if_nextents <= 2);
413389
414390 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp);
415391 if (error)
....@@ -441,13 +417,12 @@
441417 * Invalidate the block(s). No validation is done.
442418 */
443419 for (i = 0; i < nmaps; i++) {
444
- bp = xfs_trans_get_buf(tp, mp->m_ddev_targp,
445
- XFS_FSB_TO_DADDR(mp, mval[i].br_startblock),
446
- XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0);
447
- if (!bp) {
448
- error = -ENOMEM;
420
+ error = xfs_trans_get_buf(tp, mp->m_ddev_targp,
421
+ XFS_FSB_TO_DADDR(mp, mval[i].br_startblock),
422
+ XFS_FSB_TO_BB(mp, mval[i].br_blockcount), 0,
423
+ &bp);
424
+ if (error)
449425 goto error_trans_cancel;
450
- }
451426 xfs_trans_binval(tp, bp);
452427 }
453428 /*