* [PATCH] ext4: fix unjournalled bg descriptor while initializing inode bitmap
@ 2014-07-05 20:28 Theodore Ts'o
2014-07-08 6:46 ` Lukáš Czerner
0 siblings, 1 reply; 2+ messages in thread
From: Theodore Ts'o @ 2014-07-05 20:28 UTC (permalink / raw)
To: Ext4 Developers List; +Cc: Theodore Ts'o, stable
The first time that we allocate from an uninitialized inode allocation
bitmap, if the block allocation bitmap is also uninitalized, we need
to get write access to the block group descriptor before we start
modifying the block group descriptor flags and updating the free block
count, etc. Otherwise, there is the potential of a bad journal
checksum (if journal checksums are enabled), and of the file system
becoming inconsistent if we crash at exactly the wrong time.
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@vger.kernel.org
---
fs/ext4/ialloc.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index a87455d..0840bf3 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -874,6 +874,13 @@ got:
goto out;
}
+ BUFFER_TRACE(group_desc_bh, "get_write_access");
+ err = ext4_journal_get_write_access(handle, group_desc_bh);
+ if (err) {
+ ext4_std_error(sb, err);
+ goto out;
+ }
+
/* We may have to initialize the block bitmap if it isn't already */
if (ext4_has_group_desc_csum(sb) &&
gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
@@ -910,13 +917,6 @@ got:
}
}
- BUFFER_TRACE(group_desc_bh, "get_write_access");
- err = ext4_journal_get_write_access(handle, group_desc_bh);
- if (err) {
- ext4_std_error(sb, err);
- goto out;
- }
-
/* Update the relevant bg descriptor fields */
if (ext4_has_group_desc_csum(sb)) {
int free;
--
2.0.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ext4: fix unjournalled bg descriptor while initializing inode bitmap
2014-07-05 20:28 [PATCH] ext4: fix unjournalled bg descriptor while initializing inode bitmap Theodore Ts'o
@ 2014-07-08 6:46 ` Lukáš Czerner
0 siblings, 0 replies; 2+ messages in thread
From: Lukáš Czerner @ 2014-07-08 6:46 UTC (permalink / raw)
To: Theodore Ts'o; +Cc: Ext4 Developers List, stable
On Sat, 5 Jul 2014, Theodore Ts'o wrote:
> Date: Sat, 5 Jul 2014 16:28:51 -0400
> From: Theodore Ts'o <tytso@mit.edu>
> To: Ext4 Developers List <linux-ext4@vger.kernel.org>
> Cc: Theodore Ts'o <tytso@mit.edu>, stable@vger.kernel.org
> Subject: [PATCH] ext4: fix unjournalled bg descriptor while initializing inode
> bitmap
>
> The first time that we allocate from an uninitialized inode allocation
> bitmap, if the block allocation bitmap is also uninitalized, we need
> to get write access to the block group descriptor before we start
> modifying the block group descriptor flags and updating the free block
> count, etc. Otherwise, there is the potential of a bad journal
> checksum (if journal checksums are enabled), and of the file system
> becoming inconsistent if we crash at exactly the wrong time.
Looks good.
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
>
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
> Cc: stable@vger.kernel.org
> ---
> fs/ext4/ialloc.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
> index a87455d..0840bf3 100644
> --- a/fs/ext4/ialloc.c
> +++ b/fs/ext4/ialloc.c
> @@ -874,6 +874,13 @@ got:
> goto out;
> }
>
> + BUFFER_TRACE(group_desc_bh, "get_write_access");
> + err = ext4_journal_get_write_access(handle, group_desc_bh);
> + if (err) {
> + ext4_std_error(sb, err);
> + goto out;
> + }
> +
> /* We may have to initialize the block bitmap if it isn't already */
> if (ext4_has_group_desc_csum(sb) &&
> gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) {
> @@ -910,13 +917,6 @@ got:
> }
> }
>
> - BUFFER_TRACE(group_desc_bh, "get_write_access");
> - err = ext4_journal_get_write_access(handle, group_desc_bh);
> - if (err) {
> - ext4_std_error(sb, err);
> - goto out;
> - }
> -
> /* Update the relevant bg descriptor fields */
> if (ext4_has_group_desc_csum(sb)) {
> int free;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-07-08 6:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-05 20:28 [PATCH] ext4: fix unjournalled bg descriptor while initializing inode bitmap Theodore Ts'o
2014-07-08 6:46 ` Lukáš Czerner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).