Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  *  linux/fs/hfs/bitmap.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 1996-1997  Paul H. Hargrove
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * (C) 2003 Ardis Technologies <roman@ardistech.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * This file may be distributed under the terms of the GNU General Public License.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * Based on GPLed code Copyright (C) 1995  Michael Dreher
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * This file contains the code to modify the volume bitmap:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  * search/set/clear bits.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include "hfs_fs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  * hfs_find_zero_bit()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *  Given a block of memory, its length in bits, and a starting bit number,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *  determine the number of the first zero bits (in left-to-right ordering)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *  in that range.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *  Returns >= 'size' if no zero bits are found in the range.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *  Accesses memory in 32-bit aligned chunks of 32-bits and thus
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *  may read beyond the 'size'th bit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) static u32 hfs_find_set_zero_bits(__be32 *bitmap, u32 size, u32 offset, u32 *max)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	__be32 *curr, *end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	u32 mask, start, len, n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	__be32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	len = *max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	if (!len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		return size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	curr = bitmap + (offset / 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	end = bitmap + ((size + 31) / 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	/* scan the first partial u32 for zero bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	val = *curr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	if (~val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		n = be32_to_cpu(val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		i = offset % 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		mask = (1U << 31) >> i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		for (; i < 32; mask >>= 1, i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 			if (!(n & mask))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 				goto found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	/* scan complete u32s for the first zero bit */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	while (++curr < end) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		val = *curr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		if (~val) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 			n = be32_to_cpu(val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			mask = 1 << 31;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 			for (i = 0; i < 32; mask >>= 1, i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 				if (!(n & mask))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 					goto found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	return size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) found:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	start = (curr - bitmap) * 32 + i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	if (start >= size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		return start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	/* do any partial u32 at the start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	len = min(size - start, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		n |= mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		if (++i >= 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		mask >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		if (!--len || n & mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 			goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	if (!--len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	*curr++ = cpu_to_be32(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	/* do full u32s */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		n = be32_to_cpu(*curr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		if (len < 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		if (n) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			len = 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		*curr++ = cpu_to_be32(0xffffffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		len -= 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	/* do any partial u32 at end */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	mask = 1U << 31;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	for (i = 0; i < len; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		if (n & mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		n |= mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		mask >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	*curr = cpu_to_be32(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	*max = (curr - bitmap) * 32 + i - start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	return start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  * hfs_vbm_search_free()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)  *   Search for 'num_bits' consecutive cleared bits in the bitmap blocks of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)  *   the hfs MDB. 'mdb' had better be locked or the returned range
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)  *   may be no longer free, when this functions returns!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)  *   XXX Currently the search starts from bit 0, but it should start with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)  *   the bit number stored in 's_alloc_ptr' of the MDB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)  * Input Variable(s):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)  *   struct hfs_mdb *mdb: Pointer to the hfs MDB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)  *   u16 *num_bits: Pointer to the number of cleared bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)  *     to search for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  * Output Variable(s):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)  *   u16 *num_bits: The number of consecutive clear bits of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  *     returned range. If the bitmap is fragmented, this will be less than
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  *     requested and it will be zero, when the disk is full.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)  *   The number of the first bit of the range of cleared bits which has been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)  *   found. When 'num_bits' is zero, this is invalid!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  * Preconditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  *   'mdb' points to a "valid" (struct hfs_mdb).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)  *   'num_bits' points to a variable of type (u16), which contains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)  *	the number of cleared bits to find.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)  * Postconditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)  *   'num_bits' is set to the length of the found sequence.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) u32 hfs_vbm_search_free(struct super_block *sb, u32 goal, u32 *num_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	void *bitmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	u32 pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	/* make sure we have actual work to perform */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	if (!*num_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	mutex_lock(&HFS_SB(sb)->bitmap_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	bitmap = HFS_SB(sb)->bitmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	pos = hfs_find_set_zero_bits(bitmap, HFS_SB(sb)->fs_ablocks, goal, num_bits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	if (pos >= HFS_SB(sb)->fs_ablocks) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		if (goal)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			pos = hfs_find_set_zero_bits(bitmap, goal, 0, num_bits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		if (pos >= HFS_SB(sb)->fs_ablocks) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 			*num_bits = pos = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	hfs_dbg(BITMAP, "alloc_bits: %u,%u\n", pos, *num_bits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	HFS_SB(sb)->free_ablocks -= *num_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	hfs_bitmap_dirty(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	mutex_unlock(&HFS_SB(sb)->bitmap_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	return pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)  * hfs_clear_vbm_bits()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  * Description:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  *   Clear the requested bits in the volume bitmap of the hfs filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  * Input Variable(s):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  *   struct hfs_mdb *mdb: Pointer to the hfs MDB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)  *   u16 start: The offset of the first bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)  *   u16 count: The number of bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)  * Output Variable(s):
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)  *   None
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)  *    0: no error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)  *   -1: One of the bits was already clear.  This is a strange
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)  *	 error and when it happens, the filesystem must be repaired!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)  *   -2: One or more of the bits are out of range of the bitmap.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)  * Preconditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187)  *   'mdb' points to a "valid" (struct hfs_mdb).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)  * Postconditions:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)  *   Starting with bit number 'start', 'count' bits in the volume bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)  *   are cleared. The affected bitmap blocks are marked "dirty", the free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)  *   block count of the MDB is updated and the MDB is marked dirty.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) int hfs_clear_vbm_bits(struct super_block *sb, u16 start, u16 count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	__be32 *curr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	u32 mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	int i, len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	/* is there any actual work to be done? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	if (!count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	hfs_dbg(BITMAP, "clear_bits: %u,%u\n", start, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	/* are all of the bits in range? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	if ((start + count) > HFS_SB(sb)->fs_ablocks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		return -2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	mutex_lock(&HFS_SB(sb)->bitmap_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	/* bitmap is always on a 32-bit boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	curr = HFS_SB(sb)->bitmap + (start / 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	len = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	/* do any partial u32 at the start */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	i = start % 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	if (i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		int j = 32 - i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		mask = 0xffffffffU << j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		if (j > count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 			mask |= 0xffffffffU >> (i + count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			*curr &= cpu_to_be32(mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		*curr++ &= cpu_to_be32(mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		count -= j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	/* do full u32s */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	while (count >= 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		*curr++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		count -= 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	/* do any partial u32 at end */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	if (count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		mask = 0xffffffffU >> count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		*curr &= cpu_to_be32(mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	HFS_SB(sb)->free_ablocks += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	mutex_unlock(&HFS_SB(sb)->bitmap_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	hfs_bitmap_dirty(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }