.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* -*- mode: c; c-basic-offset: 8; -*- |
---|
2 | 3 | * vim: noexpandtab sw=8 ts=8 sts=0: |
---|
3 | 4 | * |
---|
.. | .. |
---|
7 | 8 | * Inspired by ext3 block groups. |
---|
8 | 9 | * |
---|
9 | 10 | * 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. |
---|
25 | 11 | */ |
---|
26 | 12 | |
---|
27 | 13 | #include <linux/fs.h> |
---|
.. | .. |
---|
710 | 696 | |
---|
711 | 697 | bg_bh = ocfs2_block_group_alloc_contig(osb, handle, alloc_inode, |
---|
712 | 698 | ac, cl); |
---|
713 | | - if (IS_ERR(bg_bh) && (PTR_ERR(bg_bh) == -ENOSPC)) |
---|
| 699 | + if (PTR_ERR(bg_bh) == -ENOSPC) |
---|
714 | 700 | bg_bh = ocfs2_block_group_alloc_discontig(handle, |
---|
715 | 701 | alloc_inode, |
---|
716 | 702 | ac, cl); |
---|
.. | .. |
---|
1266 | 1252 | int nr) |
---|
1267 | 1253 | { |
---|
1268 | 1254 | struct ocfs2_group_desc *bg = (struct ocfs2_group_desc *) bg_bh->b_data; |
---|
| 1255 | + struct journal_head *jh; |
---|
1269 | 1256 | int ret; |
---|
1270 | 1257 | |
---|
1271 | 1258 | if (ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap)) |
---|
1272 | 1259 | return 0; |
---|
1273 | 1260 | |
---|
1274 | | - if (!buffer_jbd(bg_bh)) |
---|
| 1261 | + jh = jbd2_journal_grab_journal_head(bg_bh); |
---|
| 1262 | + if (!jh) |
---|
1275 | 1263 | return 1; |
---|
1276 | 1264 | |
---|
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; |
---|
1279 | 1267 | if (bg) |
---|
1280 | 1268 | ret = !ocfs2_test_bit(nr, (unsigned long *)bg->bg_bitmap); |
---|
1281 | 1269 | else |
---|
1282 | 1270 | ret = 1; |
---|
1283 | | - jbd_unlock_bh_state(bg_bh); |
---|
| 1271 | + spin_unlock(&jh->b_state_lock); |
---|
| 1272 | + jbd2_journal_put_journal_head(jh); |
---|
1284 | 1273 | |
---|
1285 | 1274 | return ret; |
---|
1286 | 1275 | } |
---|
.. | .. |
---|
2401 | 2390 | int status; |
---|
2402 | 2391 | unsigned int tmp; |
---|
2403 | 2392 | struct ocfs2_group_desc *undo_bg = NULL; |
---|
| 2393 | + struct journal_head *jh; |
---|
2404 | 2394 | |
---|
2405 | 2395 | /* The caller got this descriptor from |
---|
2406 | 2396 | * ocfs2_read_group_descriptor(). Any corruption is a code bug. */ |
---|
.. | .. |
---|
2419 | 2409 | goto bail; |
---|
2420 | 2410 | } |
---|
2421 | 2411 | |
---|
| 2412 | + jh = bh2jh(group_bh); |
---|
2422 | 2413 | 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; |
---|
2426 | 2416 | BUG_ON(!undo_bg); |
---|
2427 | 2417 | } |
---|
2428 | 2418 | |
---|
.. | .. |
---|
2437 | 2427 | le16_add_cpu(&bg->bg_free_bits_count, num_bits); |
---|
2438 | 2428 | if (le16_to_cpu(bg->bg_free_bits_count) > le16_to_cpu(bg->bg_bits)) { |
---|
2439 | 2429 | if (undo_fn) |
---|
2440 | | - jbd_unlock_bh_state(group_bh); |
---|
| 2430 | + spin_unlock(&jh->b_state_lock); |
---|
2441 | 2431 | return ocfs2_error(alloc_inode->i_sb, "Group descriptor # %llu has bit count %u but claims %u are freed. num_bits %d\n", |
---|
2442 | 2432 | (unsigned long long)le64_to_cpu(bg->bg_blkno), |
---|
2443 | 2433 | le16_to_cpu(bg->bg_bits), |
---|
.. | .. |
---|
2446 | 2436 | } |
---|
2447 | 2437 | |
---|
2448 | 2438 | if (undo_fn) |
---|
2449 | | - jbd_unlock_bh_state(group_bh); |
---|
| 2439 | + spin_unlock(&jh->b_state_lock); |
---|
2450 | 2440 | |
---|
2451 | 2441 | ocfs2_journal_dirty(handle, group_bh); |
---|
2452 | 2442 | bail: |
---|
.. | .. |
---|
2520 | 2510 | |
---|
2521 | 2511 | bail: |
---|
2522 | 2512 | brelse(group_bh); |
---|
2523 | | - |
---|
2524 | | - if (status) |
---|
2525 | | - mlog_errno(status); |
---|
2526 | 2513 | return status; |
---|
2527 | 2514 | } |
---|
2528 | 2515 | |
---|
.. | .. |
---|
2593 | 2580 | num_clusters); |
---|
2594 | 2581 | |
---|
2595 | 2582 | out: |
---|
2596 | | - if (status) |
---|
2597 | | - mlog_errno(status); |
---|
2598 | 2583 | return status; |
---|
2599 | 2584 | } |
---|
2600 | 2585 | |
---|