diff options
Diffstat (limited to 'fs/ufs/balloc.c')
| -rw-r--r-- | fs/ufs/balloc.c | 65 | 
1 files changed, 27 insertions, 38 deletions
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c index 46f7a807bbc..7bc20809c99 100644 --- a/fs/ufs/balloc.c +++ b/fs/ufs/balloc.c @@ -24,7 +24,7 @@  #define INVBLOCK ((u64)-1L) -static u64 ufs_add_fragments(struct inode *, u64, unsigned, unsigned, int *); +static u64 ufs_add_fragments(struct inode *, u64, unsigned, unsigned);  static u64 ufs_alloc_fragments(struct inode *, unsigned, u64, unsigned, int *);  static u64 ufs_alloccg_block(struct inode *, struct ufs_cg_private_info *, u64, int *);  static u64 ufs_bitmap_search (struct super_block *, struct ufs_cg_private_info *, u64, unsigned); @@ -38,7 +38,6 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count)  {  	struct super_block * sb;  	struct ufs_sb_private_info * uspi; -	struct ufs_super_block_first * usb1;  	struct ufs_cg_private_info * ucpi;  	struct ufs_cylinder_group * ucg;  	unsigned cgno, bit, end_bit, bbase, blkmap, i; @@ -46,7 +45,6 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count)  	sb = inode->i_sb;  	uspi = UFS_SB(sb)->s_uspi; -	usb1 = ubh_get_usb_first(uspi);  	UFSD("ENTER, fragment %llu, count %u\n",  	     (unsigned long long)fragment, count); @@ -54,7 +52,7 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count)  	if (ufs_fragnum(fragment) + count > uspi->s_fpg)  		ufs_error (sb, "ufs_free_fragments", "internal error"); -	lock_super(sb); +	lock_ufs(sb);  	cgno = ufs_dtog(uspi, fragment);  	bit = ufs_dtogd(uspi, fragment); @@ -116,14 +114,14 @@ void ufs_free_fragments(struct inode *inode, u64 fragment, unsigned count)  	ubh_mark_buffer_dirty (UCPI_UBH(ucpi));  	if (sb->s_flags & MS_SYNCHRONOUS)  		ubh_sync_block(UCPI_UBH(ucpi)); -	sb->s_dirt = 1; +	ufs_mark_sb_dirty(sb); -	unlock_super (sb); +	unlock_ufs(sb);  	UFSD("EXIT\n");  	return;  failed: -	unlock_super (sb); +	unlock_ufs(sb);  	UFSD("EXIT (FAILED)\n");  	return;  } @@ -135,7 +133,6 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count)  {  	struct super_block * sb;  	struct ufs_sb_private_info * uspi; -	struct ufs_super_block_first * usb1;  	struct ufs_cg_private_info * ucpi;  	struct ufs_cylinder_group * ucg;  	unsigned overflow, cgno, bit, end_bit, i; @@ -143,7 +140,6 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count)  	sb = inode->i_sb;  	uspi = UFS_SB(sb)->s_uspi; -	usb1 = ubh_get_usb_first(uspi);  	UFSD("ENTER, fragment %llu, count %u\n",  	     (unsigned long long)fragment, count); @@ -155,7 +151,7 @@ void ufs_free_blocks(struct inode *inode, u64 fragment, unsigned count)  		goto failed;  	} -	lock_super(sb); +	lock_ufs(sb);  do_more:  	overflow = 0; @@ -214,13 +210,13 @@ do_more:  		goto do_more;  	} -	sb->s_dirt = 1; -	unlock_super (sb); +	ufs_mark_sb_dirty(sb); +	unlock_ufs(sb);  	UFSD("EXIT\n");  	return;  failed_unlock: -	unlock_super (sb); +	unlock_ufs(sb);  failed:  	UFSD("EXIT (FAILED)\n");  	return; @@ -361,7 +357,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,  	usb1 = ubh_get_usb_first(uspi);  	*err = -ENOSPC; -	lock_super (sb); +	lock_ufs(sb);  	tmp = ufs_data_ptr_to_cpu(sb, p);  	if (count + ufs_fragnum(fragment) > uspi->s_fpb) { @@ -382,19 +378,19 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,  				  "fragment %llu, tmp %llu\n",  				  (unsigned long long)fragment,  				  (unsigned long long)tmp); -			unlock_super(sb); +			unlock_ufs(sb);  			return INVBLOCK;  		}  		if (fragment < UFS_I(inode)->i_lastfrag) {  			UFSD("EXIT (ALREADY ALLOCATED)\n"); -			unlock_super (sb); +			unlock_ufs(sb);  			return 0;  		}  	}  	else {  		if (tmp) {  			UFSD("EXIT (ALREADY ALLOCATED)\n"); -			unlock_super(sb); +			unlock_ufs(sb);  			return 0;  		}  	} @@ -403,7 +399,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,  	 * There is not enough space for user on the device  	 */  	if (!capable(CAP_SYS_RESOURCE) && ufs_freespace(uspi, UFS_MINFREE) <= 0) { -		unlock_super (sb); +		unlock_ufs(sb);  		UFSD("EXIT (FAILED)\n");  		return 0;  	} @@ -424,12 +420,11 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,  			ufs_cpu_to_data_ptr(sb, p, result);  			*err = 0;  			UFS_I(inode)->i_lastfrag = -				max_t(u32, UFS_I(inode)->i_lastfrag, -				      fragment + count); +				max(UFS_I(inode)->i_lastfrag, fragment + count);  			ufs_clear_frags(inode, result + oldcount,  					newcount - oldcount, locked_page != NULL);  		} -		unlock_super(sb); +		unlock_ufs(sb);  		UFSD("EXIT, result %llu\n", (unsigned long long)result);  		return result;  	} @@ -437,13 +432,14 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,  	/*  	 * resize block  	 */ -	result = ufs_add_fragments (inode, tmp, oldcount, newcount, err); +	result = ufs_add_fragments(inode, tmp, oldcount, newcount);  	if (result) {  		*err = 0; -		UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); +		UFS_I(inode)->i_lastfrag = max(UFS_I(inode)->i_lastfrag, +						fragment + count);  		ufs_clear_frags(inode, result + oldcount, newcount - oldcount,  				locked_page != NULL); -		unlock_super(sb); +		unlock_ufs(sb);  		UFSD("EXIT, result %llu\n", (unsigned long long)result);  		return result;  	} @@ -479,8 +475,9 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,  				   uspi->s_sbbase + result, locked_page);  		ufs_cpu_to_data_ptr(sb, p, result);  		*err = 0; -		UFS_I(inode)->i_lastfrag = max_t(u32, UFS_I(inode)->i_lastfrag, fragment + count); -		unlock_super(sb); +		UFS_I(inode)->i_lastfrag = max(UFS_I(inode)->i_lastfrag, +						fragment + count); +		unlock_ufs(sb);  		if (newcount < request)  			ufs_free_fragments (inode, result + newcount, request - newcount);  		ufs_free_fragments (inode, tmp, oldcount); @@ -488,17 +485,16 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,  		return result;  	} -	unlock_super(sb); +	unlock_ufs(sb);  	UFSD("EXIT (FAILED)\n");  	return 0;  }		  static u64 ufs_add_fragments(struct inode *inode, u64 fragment, -			     unsigned oldcount, unsigned newcount, int *err) +			     unsigned oldcount, unsigned newcount)  {  	struct super_block * sb;  	struct ufs_sb_private_info * uspi; -	struct ufs_super_block_first * usb1;  	struct ufs_cg_private_info * ucpi;  	struct ufs_cylinder_group * ucg;  	unsigned cgno, fragno, fragoff, count, fragsize, i; @@ -508,7 +504,6 @@ static u64 ufs_add_fragments(struct inode *inode, u64 fragment,  	sb = inode->i_sb;  	uspi = UFS_SB(sb)->s_uspi; -	usb1 = ubh_get_usb_first (uspi);  	count = newcount - oldcount;  	cgno = ufs_dtog(uspi, fragment); @@ -556,7 +551,7 @@ static u64 ufs_add_fragments(struct inode *inode, u64 fragment,  	ubh_mark_buffer_dirty (UCPI_UBH(ucpi));  	if (sb->s_flags & MS_SYNCHRONOUS)  		ubh_sync_block(UCPI_UBH(ucpi)); -	sb->s_dirt = 1; +	ufs_mark_sb_dirty(sb);  	UFSD("EXIT, fragment %llu\n", (unsigned long long)fragment); @@ -576,7 +571,6 @@ static u64 ufs_alloc_fragments(struct inode *inode, unsigned cgno,  {  	struct super_block * sb;  	struct ufs_sb_private_info * uspi; -	struct ufs_super_block_first * usb1;  	struct ufs_cg_private_info * ucpi;  	struct ufs_cylinder_group * ucg;  	unsigned oldcg, i, j, k, allocsize; @@ -587,7 +581,6 @@ static u64 ufs_alloc_fragments(struct inode *inode, unsigned cgno,  	sb = inode->i_sb;  	uspi = UFS_SB(sb)->s_uspi; -	usb1 = ubh_get_usb_first(uspi);  	oldcg = cgno;  	/* @@ -676,7 +669,7 @@ succed:  	ubh_mark_buffer_dirty (UCPI_UBH(ucpi));  	if (sb->s_flags & MS_SYNCHRONOUS)  		ubh_sync_block(UCPI_UBH(ucpi)); -	sb->s_dirt = 1; +	ufs_mark_sb_dirty(sb);  	result += cgno * uspi->s_fpg;  	UFSD("EXIT3, result %llu\n", (unsigned long long)result); @@ -689,7 +682,6 @@ static u64 ufs_alloccg_block(struct inode *inode,  {  	struct super_block * sb;  	struct ufs_sb_private_info * uspi; -	struct ufs_super_block_first * usb1;  	struct ufs_cylinder_group * ucg;  	u64 result, blkno; @@ -697,7 +689,6 @@ static u64 ufs_alloccg_block(struct inode *inode,  	sb = inode->i_sb;  	uspi = UFS_SB(sb)->s_uspi; -	usb1 = ubh_get_usb_first(uspi);  	ucg = ubh_get_ucg(UCPI_UBH(ucpi));  	if (goal == 0) { @@ -793,7 +784,6 @@ static u64 ufs_bitmap_search(struct super_block *sb,  		0x0, 0x2, 0x6, 0xe, 0x1e, 0x3e, 0x7e, 0xfe, 0x1fe  	};  	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; -	struct ufs_super_block_first *usb1;  	struct ufs_cylinder_group *ucg;  	unsigned start, length, loc;  	unsigned pos, want, blockmap, mask, end; @@ -802,7 +792,6 @@ static u64 ufs_bitmap_search(struct super_block *sb,  	UFSD("ENTER, cg %u, goal %llu, count %u\n", ucpi->c_cgx,  	     (unsigned long long)goal, count); -	usb1 = ubh_get_usb_first (uspi);  	ucg = ubh_get_ucg(UCPI_UBH(ucpi));  	if (goal)  | 
