.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* -*- mode: c; c-basic-offset: 8; -*- |
---|
2 | 3 | * vim: noexpandtab sw=8 ts=8 sts=0: |
---|
3 | 4 | * |
---|
4 | 5 | * move_extents.c |
---|
5 | 6 | * |
---|
6 | 7 | * Copyright (C) 2011 Oracle. All rights reserved. |
---|
7 | | - * |
---|
8 | | - * This program is free software; you can redistribute it and/or |
---|
9 | | - * modify it under the terms of the GNU General Public |
---|
10 | | - * License version 2 as published by the Free Software Foundation. |
---|
11 | | - * |
---|
12 | | - * This program is distributed in the hope that it will be useful, |
---|
13 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
15 | | - * General Public License for more details. |
---|
16 | 8 | */ |
---|
17 | 9 | #include <linux/fs.h> |
---|
18 | 10 | #include <linux/types.h> |
---|
.. | .. |
---|
115 | 107 | */ |
---|
116 | 108 | replace_rec.e_flags = ext_flags & ~OCFS2_EXT_REFCOUNTED; |
---|
117 | 109 | |
---|
118 | | - ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), |
---|
119 | | - context->et.et_root_bh, |
---|
120 | | - OCFS2_JOURNAL_ACCESS_WRITE); |
---|
121 | | - if (ret) { |
---|
122 | | - mlog_errno(ret); |
---|
123 | | - goto out; |
---|
124 | | - } |
---|
125 | | - |
---|
126 | 110 | ret = ocfs2_split_extent(handle, &context->et, path, index, |
---|
127 | 111 | &replace_rec, context->meta_ac, |
---|
128 | 112 | &context->dealloc); |
---|
.. | .. |
---|
130 | 114 | mlog_errno(ret); |
---|
131 | 115 | goto out; |
---|
132 | 116 | } |
---|
133 | | - |
---|
134 | | - ocfs2_journal_dirty(handle, context->et.et_root_bh); |
---|
135 | 117 | |
---|
136 | 118 | context->new_phys_cpos = new_p_cpos; |
---|
137 | 119 | |
---|
.. | .. |
---|
454 | 436 | bg = (struct ocfs2_group_desc *)gd_bh->b_data; |
---|
455 | 437 | |
---|
456 | 438 | if (vict_blkno < (le64_to_cpu(bg->bg_blkno) + |
---|
457 | | - le16_to_cpu(bg->bg_bits))) { |
---|
| 439 | + (le16_to_cpu(bg->bg_bits) << bits_per_unit))) { |
---|
458 | 440 | |
---|
459 | 441 | *ret_bh = gd_bh; |
---|
460 | 442 | *vict_bit = (vict_blkno - blkno) >> |
---|
.. | .. |
---|
569 | 551 | last_free_bits++; |
---|
570 | 552 | |
---|
571 | 553 | if (last_free_bits == move_len) { |
---|
| 554 | + i -= move_len; |
---|
572 | 555 | *goal_bit = i; |
---|
573 | 556 | *phys_cpos = base_cpos + i; |
---|
574 | 557 | break; |
---|
.. | .. |
---|
1040 | 1023 | |
---|
1041 | 1024 | context->range = ⦥ |
---|
1042 | 1025 | |
---|
| 1026 | + /* |
---|
| 1027 | + * ok, the default theshold for the defragmentation |
---|
| 1028 | + * is 1M, since our maximum clustersize was 1M also. |
---|
| 1029 | + * any thought? |
---|
| 1030 | + */ |
---|
| 1031 | + if (!range.me_threshold) |
---|
| 1032 | + range.me_threshold = 1024 * 1024; |
---|
| 1033 | + |
---|
| 1034 | + if (range.me_threshold > i_size_read(inode)) |
---|
| 1035 | + range.me_threshold = i_size_read(inode); |
---|
| 1036 | + |
---|
1043 | 1037 | if (range.me_flags & OCFS2_MOVE_EXT_FL_AUTO_DEFRAG) { |
---|
1044 | 1038 | context->auto_defrag = 1; |
---|
1045 | | - /* |
---|
1046 | | - * ok, the default theshold for the defragmentation |
---|
1047 | | - * is 1M, since our maximum clustersize was 1M also. |
---|
1048 | | - * any thought? |
---|
1049 | | - */ |
---|
1050 | | - if (!range.me_threshold) |
---|
1051 | | - range.me_threshold = 1024 * 1024; |
---|
1052 | | - |
---|
1053 | | - if (range.me_threshold > i_size_read(inode)) |
---|
1054 | | - range.me_threshold = i_size_read(inode); |
---|
1055 | 1039 | |
---|
1056 | 1040 | if (range.me_flags & OCFS2_MOVE_EXT_FL_PART_DEFRAG) |
---|
1057 | 1041 | context->partial = 1; |
---|