hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/ocfs2/suballoc.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* -*- mode: c; c-basic-offset: 8; -*-
23 * vim: noexpandtab sw=8 ts=8 sts=0:
34 *
....@@ -7,21 +8,6 @@
78 * Inspired by ext3 block groups.
89 *
910 * Copyright (C) 2002, 2004 Oracle. All rights reserved.
10
- *
11
- * This program is free software; you can redistribute it and/or
12
- * modify it under the terms of the GNU General Public
13
- * License as published by the Free Software Foundation; either
14
- * version 2 of the License, or (at your option) any later version.
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
- * General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU General Public
22
- * License along with this program; if not, write to the
23
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24
- * Boston, MA 021110-1307, USA.
2511 */
2612
2713 #include <linux/fs.h>
....@@ -710,7 +696,7 @@
710696
711697 bg_bh = ocfs2_block_group_alloc_contig(osb, handle, alloc_inode,
712698 ac, cl);
713
- if (IS_ERR(bg_bh) && (PTR_ERR(bg_bh) == -ENOSPC))
699
+ if (PTR_ERR(bg_bh) == -ENOSPC)
714700 bg_bh = ocfs2_block_group_alloc_discontig(handle,
715701 alloc_inode,
716702 ac, cl);
....@@ -1266,21 +1252,24 @@
12661252 int nr)
12671253 {
12681254 struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data;
1255
+ struct journal_head *jh;
12691256 int ret;
12701257
12711258 if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap))
12721259 return 0;
12731260
1274
- if (!buffer_jbd(bg_bh))
1261
+ jh = jbd2_journal_grab_journal_head(bg_bh);
1262
+ if (!jh)
12751263 return 1;
12761264
1277
- jbd_lock_bh_state(bg_bh);
1278
- bg = (struct ocfs2_group_desc *) bh2jh(bg_bh)->b_committed_data;
1265
+ spin_lock(&jh->b_state_lock);
1266
+ bg = (struct ocfs2_group_desc *) jh->b_committed_data;
12791267 if (bg)
12801268 ret = !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap);
12811269 else
12821270 ret = 1;
1283
- jbd_unlock_bh_state(bg_bh);
1271
+ spin_unlock(&jh->b_state_lock);
1272
+ jbd2_journal_put_journal_head(jh);
12841273
12851274 return ret;
12861275 }
....@@ -2401,6 +2390,7 @@
24012390 int status;
24022391 unsigned int tmp;
24032392 struct ocfs2_group_desc *undo_bg = NULL;
2393
+ struct journal_head *jh;
24042394
24052395 /* The caller got this descriptor from
24062396 * ocfs2_read_group_descriptor(). Any corruption is a code bug. */
....@@ -2419,10 +2409,10 @@
24192409 goto bail;
24202410 }
24212411
2412
+ jh = bh2jh(group_bh);
24222413 if (undo_fn) {
2423
- jbd_lock_bh_state(group_bh);
2424
- undo_bg = (struct ocfs2_group_desc *)
2425
- bh2jh(group_bh)->b_committed_data;
2414
+ spin_lock(&jh->b_state_lock);
2415
+ undo_bg = (struct ocfs2_group_desc *) jh->b_committed_data;
24262416 BUG_ON(!undo_bg);
24272417 }
24282418
....@@ -2437,7 +2427,7 @@
24372427 le16_add_cpu(&bg->bg_free_bits_count, num_bits);
24382428 if (le16_to_cpu(bg->bg_free_bits_count) > le16_to_cpu(bg->bg_bits)) {
24392429 if (undo_fn)
2440
- jbd_unlock_bh_state(group_bh);
2430
+ spin_unlock(&jh->b_state_lock);
24412431 return ocfs2_error(alloc_inode->i_sb, "Group descriptor # %llu has bit count %u but claims %u are freed. num_bits %d\n",
24422432 (unsigned long long)le64_to_cpu(bg->bg_blkno),
24432433 le16_to_cpu(bg->bg_bits),
....@@ -2446,7 +2436,7 @@
24462436 }
24472437
24482438 if (undo_fn)
2449
- jbd_unlock_bh_state(group_bh);
2439
+ spin_unlock(&jh->b_state_lock);
24502440
24512441 ocfs2_journal_dirty(handle, group_bh);
24522442 bail:
....@@ -2520,9 +2510,6 @@
25202510
25212511 bail:
25222512 brelse(group_bh);
2523
-
2524
- if (status)
2525
- mlog_errno(status);
25262513 return status;
25272514 }
25282515
....@@ -2593,8 +2580,6 @@
25932580 num_clusters);
25942581
25952582 out:
2596
- if (status)
2597
- mlog_errno(status);
25982583 return status;
25992584 }
26002585