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) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  linux/fs/sysv/balloc.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  *  minix/bitmap.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  Copyright (C) 1991, 1992  Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *  ext/freelists.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *  Copyright (C) 1992  Remy Card (card@masi.ibp.fr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *  xenix/alloc.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *  Copyright (C) 1992  Doug Evans
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *  coh/alloc.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *  Copyright (C) 1993  Pascal Haible, Bruno Haible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *  sysv/balloc.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *  Copyright (C) 1993  Bruno Haible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *  This file contains code for allocating/freeing blocks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/buffer_head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include "sysv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) /* We don't trust the value of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)    sb->sv_sbd2->s_tfree = *sb->sv_free_blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)    but we nevertheless keep it up to date. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) static inline sysv_zone_t *get_chunk(struct super_block *sb, struct buffer_head *bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	char *bh_data = bh->b_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	if (SYSV_SB(sb)->s_type == FSTYPE_SYSV4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 		return (sysv_zone_t*)(bh_data+4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		return (sysv_zone_t*)(bh_data+2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /* NOTE NOTE NOTE: nr is a block number _as_ _stored_ _on_ _disk_ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) void sysv_free_block(struct super_block * sb, sysv_zone_t nr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	struct sysv_sb_info * sbi = SYSV_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	struct buffer_head * bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	sysv_zone_t *blocks = sbi->s_bcache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	unsigned count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	unsigned block = fs32_to_cpu(sbi, nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	 * This code does not work at all for AFS (it has a bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	 * free list).  As AFS is supposed to be read-only no one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	 * should call this for an AFS filesystem anyway...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	if (sbi->s_type == FSTYPE_AFS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	if (block < sbi->s_firstdatazone || block >= sbi->s_nzones) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		printk("sysv_free_block: trying to free block not in datazone\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	mutex_lock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	count = fs16_to_cpu(sbi, *sbi->s_bcache_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	if (count > sbi->s_flc_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		printk("sysv_free_block: flc_count > flc_size\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		mutex_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	/* If the free list head in super-block is full, it is copied
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	 * into this block being freed, ditto if it's completely empty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	 * (applies only on Coherent).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	if (count == sbi->s_flc_size || count == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		block += sbi->s_block_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		bh = sb_getblk(sb, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		if (!bh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			printk("sysv_free_block: getblk() failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 			mutex_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		memset(bh->b_data, 0, sb->s_blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		*(__fs16*)bh->b_data = cpu_to_fs16(sbi, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		memcpy(get_chunk(sb,bh), blocks, count * sizeof(sysv_zone_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		mark_buffer_dirty(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		set_buffer_uptodate(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	sbi->s_bcache[count++] = nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	*sbi->s_bcache_count = cpu_to_fs16(sbi, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	fs32_add(sbi, sbi->s_free_blocks, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	dirty_sb(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	mutex_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) sysv_zone_t sysv_new_block(struct super_block * sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	struct sysv_sb_info *sbi = SYSV_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	unsigned int block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	sysv_zone_t nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	struct buffer_head * bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	unsigned count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	mutex_lock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	count = fs16_to_cpu(sbi, *sbi->s_bcache_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	if (count == 0) /* Applies only to Coherent FS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		goto Enospc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	nr = sbi->s_bcache[--count];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	if (nr == 0)  /* Applies only to Xenix FS, SystemV FS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		goto Enospc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	block = fs32_to_cpu(sbi, nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	*sbi->s_bcache_count = cpu_to_fs16(sbi, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	if (block < sbi->s_firstdatazone || block >= sbi->s_nzones) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 		printk("sysv_new_block: new block %d is not in data zone\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 			block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		goto Enospc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	if (count == 0) { /* the last block continues the free list */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		unsigned count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		block += sbi->s_block_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		if (!(bh = sb_bread(sb, block))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 			printk("sysv_new_block: cannot read free-list block\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 			/* retry this same block next time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			*sbi->s_bcache_count = cpu_to_fs16(sbi, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 			goto Enospc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		count = fs16_to_cpu(sbi, *(__fs16*)bh->b_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		if (count > sbi->s_flc_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 			printk("sysv_new_block: free-list block with >flc_size entries\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 			brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 			goto Enospc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		*sbi->s_bcache_count = cpu_to_fs16(sbi, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		memcpy(sbi->s_bcache, get_chunk(sb, bh),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 				count * sizeof(sysv_zone_t));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	/* Now the free list head in the superblock is valid again. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	fs32_add(sbi, sbi->s_free_blocks, -1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	dirty_sb(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	mutex_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	return nr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) Enospc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	mutex_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) unsigned long sysv_count_free_blocks(struct super_block * sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	struct sysv_sb_info * sbi = SYSV_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	int sb_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	struct buffer_head * bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	sysv_zone_t *blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	unsigned block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	int n;
^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) 	 * This code does not work at all for AFS (it has a bitmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	 * free list).  As AFS is supposed to be read-only we just
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	 * lie and say it has no free block at all.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	if (sbi->s_type == FSTYPE_AFS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	mutex_lock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	sb_count = fs32_to_cpu(sbi, *sbi->s_free_blocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	if (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		goto trust_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	/* this causes a lot of disk traffic ... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	n = fs16_to_cpu(sbi, *sbi->s_bcache_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	blocks = sbi->s_bcache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	while (1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		sysv_zone_t zone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		if (n > sbi->s_flc_size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 			goto E2big;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		zone = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		while (n && (zone = blocks[--n]) != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 			count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		if (zone == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		block = fs32_to_cpu(sbi, zone);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		if (bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 			brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		if (block < sbi->s_firstdatazone || block >= sbi->s_nzones)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 			goto Einval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		block += sbi->s_block_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		bh = sb_bread(sb, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		if (!bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 			goto Eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		n = fs16_to_cpu(sbi, *(__fs16*)bh->b_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		blocks = get_chunk(sb, bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	if (count != sb_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		goto Ecount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	mutex_unlock(&sbi->s_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) Einval:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	printk("sysv_count_free_blocks: new block %d is not in data zone\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	goto trust_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) Eio:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	printk("sysv_count_free_blocks: cannot read free-list block\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	goto trust_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) E2big:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	printk("sysv_count_free_blocks: >flc_size entries in free-list block\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	if (bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) trust_sb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	count = sb_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) Ecount:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	printk("sysv_count_free_blocks: free block count was %d, "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		"correcting to %d\n", sb_count, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	if (!sb_rdonly(sb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		*sbi->s_free_blocks = cpu_to_fs32(sbi, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		dirty_sb(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) }