hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/fs/ocfs2/move_extents.c
....@@ -1,18 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /* -*- mode: c; c-basic-offset: 8; -*-
23 * vim: noexpandtab sw=8 ts=8 sts=0:
34 *
45 * move_extents.c
56 *
67 * 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.
168 */
179 #include <linux/fs.h>
1810 #include <linux/types.h>
....@@ -115,14 +107,6 @@
115107 */
116108 replace_rec.e_flags = ext_flags & ~OCFS2_EXT_REFCOUNTED;
117109
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
-
126110 ret = ocfs2_split_extent(handle, &context->et, path, index,
127111 &replace_rec, context->meta_ac,
128112 &context->dealloc);
....@@ -130,8 +114,6 @@
130114 mlog_errno(ret);
131115 goto out;
132116 }
133
-
134
- ocfs2_journal_dirty(handle, context->et.et_root_bh);
135117
136118 context->new_phys_cpos = new_p_cpos;
137119
....@@ -454,7 +436,7 @@
454436 bg = (struct ocfs2_group_desc *)gd_bh->b_data;
455437
456438 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))) {
458440
459441 *ret_bh = gd_bh;
460442 *vict_bit = (vict_blkno - blkno) >>
....@@ -569,6 +551,7 @@
569551 last_free_bits++;
570552
571553 if (last_free_bits == move_len) {
554
+ i -= move_len;
572555 *goal_bit = i;
573556 *phys_cpos = base_cpos + i;
574557 break;
....@@ -1040,18 +1023,19 @@
10401023
10411024 context->range = &range;
10421025
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
+
10431037 if (range.me_flags & OCFS2_MOVE_EXT_FL_AUTO_DEFRAG) {
10441038 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);
10551039
10561040 if (range.me_flags & OCFS2_MOVE_EXT_FL_PART_DEFRAG)
10571041 context->partial = 1;