diff options
Diffstat (limited to 'fs/xfs/xfs_extfree_item.c')
-rw-r--r-- | fs/xfs/xfs_extfree_item.c | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index f19282ec8549..6cf6d8769b97 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include "xfs_trans.h" | 23 | #include "xfs_trans.h" |
24 | #include "xfs_buf_item.h" | 24 | #include "xfs_buf_item.h" |
25 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_dir.h" | ||
27 | #include "xfs_dmapi.h" | 26 | #include "xfs_dmapi.h" |
28 | #include "xfs_mount.h" | 27 | #include "xfs_mount.h" |
29 | #include "xfs_trans_priv.h" | 28 | #include "xfs_trans_priv.h" |
@@ -294,6 +293,62 @@ xfs_efi_init(xfs_mount_t *mp, | |||
294 | } | 293 | } |
295 | 294 | ||
296 | /* | 295 | /* |
296 | * Copy an EFI format buffer from the given buf, and into the destination | ||
297 | * EFI format structure. | ||
298 | * The given buffer can be in 32 bit or 64 bit form (which has different padding), | ||
299 | * one of which will be the native format for this kernel. | ||
300 | * It will handle the conversion of formats if necessary. | ||
301 | */ | ||
302 | int | ||
303 | xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt) | ||
304 | { | ||
305 | xfs_efi_log_format_t *src_efi_fmt = (xfs_efi_log_format_t *)buf->i_addr; | ||
306 | uint i; | ||
307 | uint len = sizeof(xfs_efi_log_format_t) + | ||
308 | (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_t); | ||
309 | uint len32 = sizeof(xfs_efi_log_format_32_t) + | ||
310 | (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_32_t); | ||
311 | uint len64 = sizeof(xfs_efi_log_format_64_t) + | ||
312 | (src_efi_fmt->efi_nextents - 1) * sizeof(xfs_extent_64_t); | ||
313 | |||
314 | if (buf->i_len == len) { | ||
315 | memcpy((char *)dst_efi_fmt, (char*)src_efi_fmt, len); | ||
316 | return 0; | ||
317 | } else if (buf->i_len == len32) { | ||
318 | xfs_efi_log_format_32_t *src_efi_fmt_32 = | ||
319 | (xfs_efi_log_format_32_t *)buf->i_addr; | ||
320 | |||
321 | dst_efi_fmt->efi_type = src_efi_fmt_32->efi_type; | ||
322 | dst_efi_fmt->efi_size = src_efi_fmt_32->efi_size; | ||
323 | dst_efi_fmt->efi_nextents = src_efi_fmt_32->efi_nextents; | ||
324 | dst_efi_fmt->efi_id = src_efi_fmt_32->efi_id; | ||
325 | for (i = 0; i < dst_efi_fmt->efi_nextents; i++) { | ||
326 | dst_efi_fmt->efi_extents[i].ext_start = | ||
327 | src_efi_fmt_32->efi_extents[i].ext_start; | ||
328 | dst_efi_fmt->efi_extents[i].ext_len = | ||
329 | src_efi_fmt_32->efi_extents[i].ext_len; | ||
330 | } | ||
331 | return 0; | ||
332 | } else if (buf->i_len == len64) { | ||
333 | xfs_efi_log_format_64_t *src_efi_fmt_64 = | ||
334 | (xfs_efi_log_format_64_t *)buf->i_addr; | ||
335 | |||
336 | dst_efi_fmt->efi_type = src_efi_fmt_64->efi_type; | ||
337 | dst_efi_fmt->efi_size = src_efi_fmt_64->efi_size; | ||
338 | dst_efi_fmt->efi_nextents = src_efi_fmt_64->efi_nextents; | ||
339 | dst_efi_fmt->efi_id = src_efi_fmt_64->efi_id; | ||
340 | for (i = 0; i < dst_efi_fmt->efi_nextents; i++) { | ||
341 | dst_efi_fmt->efi_extents[i].ext_start = | ||
342 | src_efi_fmt_64->efi_extents[i].ext_start; | ||
343 | dst_efi_fmt->efi_extents[i].ext_len = | ||
344 | src_efi_fmt_64->efi_extents[i].ext_len; | ||
345 | } | ||
346 | return 0; | ||
347 | } | ||
348 | return EFSCORRUPTED; | ||
349 | } | ||
350 | |||
351 | /* | ||
297 | * This is called by the efd item code below to release references to | 352 | * This is called by the efd item code below to release references to |
298 | * the given efi item. Each efd calls this with the number of | 353 | * the given efi item. Each efd calls this with the number of |
299 | * extents that it has logged, and when the sum of these reaches | 354 | * extents that it has logged, and when the sum of these reaches |