hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/fs/ocfs2/localalloc.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 *
....@@ -6,21 +7,6 @@
67 * Node local data allocation
78 *
89 * Copyright (C) 2002, 2004 Oracle. All rights reserved.
9
- *
10
- * This program is free software; you can redistribute it and/or
11
- * modify it under the terms of the GNU General Public
12
- * License as published by the Free Software Foundation; either
13
- * version 2 of the License, or (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
- * General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU General Public
21
- * License along with this program; if not, write to the
22
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23
- * Boston, MA 021110-1307, USA.
2410 */
2511
2612 #include <linux/fs.h>
....@@ -439,12 +425,11 @@
439425 bh = osb->local_alloc_bh;
440426 alloc = (struct ocfs2_dinode *) bh->b_data;
441427
442
- alloc_copy = kmalloc(bh->b_size, GFP_NOFS);
428
+ alloc_copy = kmemdup(alloc, bh->b_size, GFP_NOFS);
443429 if (!alloc_copy) {
444430 status = -ENOMEM;
445431 goto out_commit;
446432 }
447
- memcpy(alloc_copy, alloc, bh->b_size);
448433
449434 status = ocfs2_journal_access_di(handle, INODE_CACHE(local_alloc_inode),
450435 bh, OCFS2_JOURNAL_ACCESS_WRITE);
....@@ -692,7 +677,7 @@
692677 /*
693678 * Under certain conditions, the window slide code
694679 * might have reduced the number of bits available or
695
- * disabled the the local alloc entirely. Re-check
680
+ * disabled the local alloc entirely. Re-check
696681 * here and return -ENOSPC if necessary.
697682 */
698683 status = -ENOSPC;
....@@ -841,7 +826,7 @@
841826 u32 *numbits,
842827 struct ocfs2_alloc_reservation *resv)
843828 {
844
- int numfound = 0, bitoff, left, startoff, lastzero;
829
+ int numfound = 0, bitoff, left, startoff;
845830 int local_resv = 0;
846831 struct ocfs2_alloc_reservation r;
847832 void *bitmap = NULL;
....@@ -879,7 +864,6 @@
879864 bitmap = OCFS2_LOCAL_ALLOC(alloc)->la_bitmap;
880865
881866 numfound = bitoff = startoff = 0;
882
- lastzero = -1;
883867 left = le32_to_cpu(alloc->id1.bitmap1.i_total);
884868 while ((bitoff = ocfs2_find_next_zero_bit(bitmap, left, startoff)) != -1) {
885869 if (bitoff == left) {
....@@ -1288,13 +1272,12 @@
12881272 * local alloc shutdown won't try to double free main bitmap
12891273 * bits. Make a copy so the sync function knows which bits to
12901274 * free. */
1291
- alloc_copy = kmalloc(osb->local_alloc_bh->b_size, GFP_NOFS);
1275
+ alloc_copy = kmemdup(alloc, osb->local_alloc_bh->b_size, GFP_NOFS);
12921276 if (!alloc_copy) {
12931277 status = -ENOMEM;
12941278 mlog_errno(status);
12951279 goto bail;
12961280 }
1297
- memcpy(alloc_copy, alloc, osb->local_alloc_bh->b_size);
12981281
12991282 status = ocfs2_journal_access_di(handle,
13001283 INODE_CACHE(local_alloc_inode),