Re: [patch] ext2/inode.c fixes

Andrea Arcangeli (andrea@suse.de)
Mon, 9 Aug 1999 02:22:07 +0200 (CEST)


On Mon, 9 Aug 1999, Andrea Arcangeli wrote:

>This patch will make ext2:
>
>o robust against possible sleeps of mark_buffer_dirty()
>o will avoid silenty ignoring the allocation of the last block
> under us when BUG() will be #undef. If I understood well
> the reason nobody can race with the allocation of the real data
> block is that we are serialized by the per-page-lock (the buffer
> is always <= PAGE_SIZE).
>o will avoid ignoring somebody racing with us in the block_getblk
> path.

This second incremental patch (I posted intentionally two separate patches
since these are different issues) will do:

o set -EFBIG only when necessary
o avoid us to return the pointer of a buffer that we bforgot since
it's not the interesting one anymore.
o return -ENOSPC also if we can't alloc a block anymore from
block_getblk as we do for inode_getblk.

--- 2.3.13-pre8-tmp/fs/ext2/inode.c.~2~ Mon Aug 9 01:54:19 1999
+++ 2.3.13-pre8-tmp/fs/ext2/inode.c Mon Aug 9 02:00:36 1999
@@ -202,6 +202,7 @@
struct buffer_head * result;
int blocksize = inode->i_sb->s_blocksize;

+ result = NULL;
p = inode->u.ext2_i.i_data + nr;
repeat:
tmp = le32_to_cpu(*p);
@@ -217,7 +218,6 @@
return NULL;
}
}
- *err = -EFBIG;

/* Check file limits.. */
{
@@ -253,10 +253,10 @@
ext2_debug ("goal = %d.\n", goal);

tmp = ext2_alloc_block (inode, goal, err);
- if (!tmp) {
- *err = -ENOSPC;
+ *err = -ENOSPC;
+ if (!tmp)
return NULL;
- }
+ *err = 0;
if (metadata) {
result = getblk (inode->i_dev, tmp, blocksize);
memset(result->b_data, 0, blocksize);
@@ -265,6 +265,7 @@
if (*p) {
ext2_free_blocks (inode, tmp, 1);
bforget (result);
+ result = NULL;
goto repeat;
}
} else {
@@ -280,8 +281,6 @@
goto repeat;
}
*phys = tmp;
- result = NULL;
- *err = 0;
*new = 1;
}
*p = cpu_to_le32(tmp);
@@ -340,13 +339,13 @@
goto out;
}
}
- *err = -EFBIG;

limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
if (limit < RLIM_INFINITY) {
limit >>= EXT2_BLOCK_SIZE_BITS(inode->i_sb);
if (new_block >= limit) {
send_sig(SIGXFSZ, current, 0);
+ *err = -EFBIG;
goto out;
}
}
@@ -364,8 +363,10 @@
goal = bh->b_blocknr;
}
tmp = ext2_alloc_block (inode, goal, err);
+ *err = -ENOSPC;
if (!tmp)
goto out;
+ *err = 0;
if (metadata) {
result = getblk (bh->b_dev, tmp, blocksize);
memset(result->b_data, 0, inode->i_sb->s_blocksize);
@@ -374,6 +375,7 @@
if (*p) {
ext2_free_blocks (inode, tmp, 1);
bforget (result);
+ result = NULL;
goto repeat;
}
} else {

Andrea

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/