[Patch 5/10]: ext3 online resize: lock newly-created buffers
From: Stephen Tweedie (sct_at_redhat.com)
Date: 09/30/04
- Previous message: Stephen Tweedie: "[Patch 4/10]: ext3 online resize: Use IS_RDONLY()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Sep 2004 14:23:39 +0100 To: linux-kernel@vger.kernel.org, Andrew Morton <akpm@osdl.org>, Andreas Dilger <adilger@clusterfs.com>, "Theodore Ts'o" <tytso@mit.edu>, ext2-devel@lists.sourceforge.net
Lock buffers before initialising their contents to avoid any risk of
being overwritten by the results of a parallel read.
Signed-off-by: Stephen Tweedie <sct@redhat.com>
--- linux-2.6.9-rc2-mm4/fs/ext3/resize.c.=K0004=.orig
+++ linux-2.6.9-rc2-mm4/fs/ext3/resize.c
@@ -118,13 +118,16 @@ static struct buffer_head *bclean(handle
int err;
bh = sb_getblk(sb, blk);
- set_buffer_uptodate(bh);
if ((err = ext3_journal_get_write_access(handle, bh))) {
brelse(bh);
bh = ERR_PTR(err);
- } else
+ } else {
+ lock_buffer(bh);
memset(bh->b_data, 0, sb->s_blocksize);
-
+ set_buffer_uptodate(bh);
+ unlock_buffer(bh);
+ }
+
return bh;
}
@@ -201,12 +204,14 @@ static int setup_new_group_blocks(struct
ext3_debug("update backup group %#04lx (+%d)\n", block, bit);
gdb = sb_getblk(sb, block);
- set_buffer_uptodate(gdb);
if ((err = ext3_journal_get_write_access(handle, gdb))) {
brelse(gdb);
goto exit_bh;
}
+ lock_buffer(bh);
memcpy(gdb->b_data, sbi->s_group_desc[i], bh->b_size);
+ set_buffer_uptodate(gdb);
+ unlock_buffer(bh);
ext3_journal_dirty_metadata(handle, gdb);
ext3_set_bit(bit, bh->b_data);
brelse(gdb);
@@ -642,14 +647,16 @@ static void update_backups(struct super_
break;
bh = sb_getblk(sb, group * bpg + blk_off);
- set_buffer_uptodate(bh);
ext3_debug(sb, __FUNCTION__, "update metadata backup %#04lx\n",
bh->b_blocknr);
if ((err = ext3_journal_get_write_access(handle, bh)))
break;
+ lock_buffer(bh);
memcpy(bh->b_data, data, size);
if (rest)
memset(bh->b_data + size, 0, rest);
+ set_buffer_uptodate(bh);
+ unlock_buffer(bh);
ext3_journal_dirty_metadata(handle, bh);
brelse(bh);
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
- Previous message: Stephen Tweedie: "[Patch 4/10]: ext3 online resize: Use IS_RDONLY()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
- Compaq 1850R
... I hope to install this weekend and hope to avoid any major issues. ...
Tanks... ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
(Debian-User) - Re: xrdb questions
... Andrew Cady writes: ... That's why I told you how to avoid it! ...
up all the time and is rarely rebooted, emacs must be closed and ... To UNSUBSCRIBE,
email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ... (Debian-User) - Fw: Fw: Katherine or Catherine de Beaumont and her parents??? 16th century
... I try to avoid those, if I haven't tell me and I will remove them. ... I don't
appreciate guesses of wishfull thinking. ... To unsubscribe from the list, please
send an email to GEN-MEDIEVAL-request@xxxxxxxxxxxx with the word 'unsubscribe' without the quotes in
the subject and the body of the message ... No virus found in this incoming message. ...
(soc.genealogy.medieval) - Re: XFCE memory leak in Lenny
... xfdesktop4 still leaks memory badly. ... Bugs: 376177 376372 373010 ...
You can avoid the memory leaks by disabling desktop management and not ... To UNSUBSCRIBE,
email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ... (Debian-User) - Re: kernel upgrading problem
... you should avoid top posting. ... you should avoid quoting the entire
message (not snipping). ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx
... (Debian-User)