.. | .. |
---|
| 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 | * |
---|
.. | .. |
---|
6 | 7 | * Node local data allocation |
---|
7 | 8 | * |
---|
8 | 9 | * 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. |
---|
24 | 10 | */ |
---|
25 | 11 | |
---|
26 | 12 | #include <linux/fs.h> |
---|
.. | .. |
---|
439 | 425 | bh = osb->local_alloc_bh; |
---|
440 | 426 | alloc = (struct ocfs2_dinode *) bh->b_data; |
---|
441 | 427 | |
---|
442 | | - alloc_copy = kmalloc(bh->b_size, GFP_NOFS); |
---|
| 428 | + alloc_copy = kmemdup(alloc, bh->b_size, GFP_NOFS); |
---|
443 | 429 | if (!alloc_copy) { |
---|
444 | 430 | status = -ENOMEM; |
---|
445 | 431 | goto out_commit; |
---|
446 | 432 | } |
---|
447 | | - memcpy(alloc_copy, alloc, bh->b_size); |
---|
448 | 433 | |
---|
449 | 434 | status = ocfs2_journal_access_di(handle, INODE_CACHE(local_alloc_inode), |
---|
450 | 435 | bh, OCFS2_JOURNAL_ACCESS_WRITE); |
---|
.. | .. |
---|
692 | 677 | /* |
---|
693 | 678 | * Under certain conditions, the window slide code |
---|
694 | 679 | * 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 |
---|
696 | 681 | * here and return -ENOSPC if necessary. |
---|
697 | 682 | */ |
---|
698 | 683 | status = -ENOSPC; |
---|
.. | .. |
---|
841 | 826 | u32 *numbits, |
---|
842 | 827 | struct ocfs2_alloc_reservation *resv) |
---|
843 | 828 | { |
---|
844 | | - int numfound = 0, bitoff, left, startoff, lastzero; |
---|
| 829 | + int numfound = 0, bitoff, left, startoff; |
---|
845 | 830 | int local_resv = 0; |
---|
846 | 831 | struct ocfs2_alloc_reservation r; |
---|
847 | 832 | void *bitmap = NULL; |
---|
.. | .. |
---|
879 | 864 | bitmap = OCFS2_LOCAL_ALLOC(alloc)->la_bitmap; |
---|
880 | 865 | |
---|
881 | 866 | numfound = bitoff = startoff = 0; |
---|
882 | | - lastzero = -1; |
---|
883 | 867 | left = le32_to_cpu(alloc->id1.bitmap1.i_total); |
---|
884 | 868 | while ((bitoff = ocfs2_find_next_zero_bit(bitmap, left, startoff)) != -1) { |
---|
885 | 869 | if (bitoff == left) { |
---|
.. | .. |
---|
1288 | 1272 | * local alloc shutdown won't try to double free main bitmap |
---|
1289 | 1273 | * bits. Make a copy so the sync function knows which bits to |
---|
1290 | 1274 | * 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); |
---|
1292 | 1276 | if (!alloc_copy) { |
---|
1293 | 1277 | status = -ENOMEM; |
---|
1294 | 1278 | mlog_errno(status); |
---|
1295 | 1279 | goto bail; |
---|
1296 | 1280 | } |
---|
1297 | | - memcpy(alloc_copy, alloc, osb->local_alloc_bh->b_size); |
---|
1298 | 1281 | |
---|
1299 | 1282 | status = ocfs2_journal_access_di(handle, |
---|
1300 | 1283 | INODE_CACHE(local_alloc_inode), |
---|