patch-2.3.9 linux/fs/ext2/truncate.c
Next file: linux/fs/fat/file.c
Previous file: linux/fs/ext2/symlink.c
Back to the patch index
Back to the overall index
- Lines: 90
- Date:
Tue Jun 29 09:22:08 1999
- Orig file:
v2.3.8/linux/fs/ext2/truncate.c
- Orig date:
Tue Jun 22 13:56:06 1999
diff -u --recursive --new-file v2.3.8/linux/fs/ext2/truncate.c linux/fs/ext2/truncate.c
@@ -129,7 +129,7 @@
if (*(ind++))
goto in_use;
- if (bh->b_count == 1) {
+ if (atomic_read(&bh->b_count) == 1) {
int tmp;
tmp = le32_to_cpu(*p);
*p = 0;
@@ -141,7 +141,7 @@
bforget(bh);
if (ind_bh)
mark_buffer_dirty(ind_bh, 1);
- ext2_free_blocks (inode, tmp, 1);
+ ext2_free_blocks(inode, tmp, 1);
goto out;
}
retry = 1;
@@ -158,11 +158,10 @@
}
#define DATA_BUFFER_USED(bh) \
- (bh->b_count || buffer_locked(bh))
+ (atomic_read(&bh->b_count) || buffer_locked(bh))
static int trunc_direct (struct inode * inode)
{
- struct buffer_head * bh;
int i, retry = 0;
unsigned long block_to_free = 0, free_count = 0;
int blocks = inode->i_sb->s_blocksize / 512;
@@ -175,19 +174,9 @@
if (!tmp)
continue;
- bh = find_buffer(inode->i_dev, tmp, inode->i_sb->s_blocksize);
- if (bh) {
- if (DATA_BUFFER_USED(bh)) {
- retry = 1;
- continue;
- }
- bh->b_count++;
- }
-
*p = 0;
inode->i_blocks -= blocks;
mark_inode_dirty(inode);
- bforget(bh);
/* accumulate blocks to free if they're contiguous */
if (free_count == 0)
@@ -206,8 +195,7 @@
return retry;
}
-static int trunc_indirect (struct inode * inode, int offset, u32 * p,
- struct buffer_head *dind_bh)
+static int trunc_indirect (struct inode * inode, int offset, u32 * p, struct buffer_head *dind_bh)
{
struct buffer_head * ind_bh;
int i, tmp, retry = 0;
@@ -242,28 +230,15 @@
indirect_block = 0;
for (i = indirect_block ; i < addr_per_block ; i++) {
u32 * ind = i + (u32 *) ind_bh->b_data;
- struct buffer_head * bh;
wait_on_buffer(ind_bh);
tmp = le32_to_cpu(*ind);
if (!tmp)
continue;
- /*
- * Use find_buffer so we don't block here.
- */
- bh = find_buffer(inode->i_dev, tmp, inode->i_sb->s_blocksize);
- if (bh) {
- if (DATA_BUFFER_USED(bh)) {
- retry = 1;
- continue;
- }
- bh->b_count++;
- }
*ind = 0;
inode->i_blocks -= blocks;
mark_inode_dirty(inode);
- bforget(bh);
mark_buffer_dirty(ind_bh, 1);
/* accumulate blocks to free if they're contiguous */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)