* [PATCH] ext4: Remove blocks from inode prealloc list on failure
@ 2009-12-01 18:17 Curt Wohlgemuth
2009-12-04 1:10 ` tytso
2009-12-04 9:46 ` Aneesh Kumar K.V
0 siblings, 2 replies; 6+ messages in thread
From: Curt Wohlgemuth @ 2009-12-01 18:17 UTC (permalink / raw)
To: ext4 development
This fixes a leak of blocks in an inode prealloc list if device failures
cause ext4_mb_mark_diskspace_used() to fail.
Signed-off-by: Curt Wohlgemuth <curtw@google.com>
---
diff -uprN orig/fs/ext4/mballoc.c new/fs/ext4/mballoc.c
--- orig/fs/ext4/mballoc.c 2009-12-01 09:27:25.000000000 -0800
+++ new/fs/ext4/mballoc.c 2009-12-01 09:28:38.000000000 -0800
@@ -3011,6 +3011,22 @@ static void ext4_mb_collect_stats(struct
}
/*
+ * Called on failure; free up any blocks from the inode PA for this
+ * context.
+ */
+static void ext4_discard_inode_pa(struct ext4_allocation_context *ac)
+{
+ struct ext4_prealloc_space *pa = ac->ac_pa;
+ int len;
+
+ if (pa && pa->pa_type == MB_INODE_PA) {
+ len = ac->ac_b_ex.fe_len;
+ pa->pa_free += len;
+ }
+
+}
+
+/*
* use blocks preallocated to inode
*/
static void ext4_mb_use_inode_pa(struct ext4_allocation_context *ac,
@@ -4295,6 +4311,7 @@ repeat:
ac->ac_status = AC_STATUS_CONTINUE;
goto repeat;
} else if (*errp) {
+ ext4_discard_inode_pa(ac);
ac->ac_b_ex.fe_len = 0;
ar->len = 0;
ext4_mb_show_ac(ac);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ext4: Remove blocks from inode prealloc list on failure
2009-12-01 18:17 [PATCH] ext4: Remove blocks from inode prealloc list on failure Curt Wohlgemuth
@ 2009-12-04 1:10 ` tytso
2009-12-04 9:43 ` Aneesh Kumar K.V
2009-12-04 9:46 ` Aneesh Kumar K.V
1 sibling, 1 reply; 6+ messages in thread
From: tytso @ 2009-12-04 1:10 UTC (permalink / raw)
To: Curt Wohlgemuth; +Cc: ext4 development
On Tue, Dec 01, 2009 at 10:17:02AM -0800, Curt Wohlgemuth wrote:
> This fixes a leak of blocks in an inode prealloc list if device failures
> cause ext4_mb_mark_diskspace_used() to fail.
I was going to say that it didn't make sense for
ext4_discard_inode_pa() should be its own function, but maybe we need
function that returns blocks back to the either inode *or* the group
preallocation list? Otherwise right now it looks like we would also
be potentially leaking blocks from the group preallocation list in
case of a device failure?
- Ted
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ext4: Remove blocks from inode prealloc list on failure
2009-12-04 1:10 ` tytso
@ 2009-12-04 9:43 ` Aneesh Kumar K.V
0 siblings, 0 replies; 6+ messages in thread
From: Aneesh Kumar K.V @ 2009-12-04 9:43 UTC (permalink / raw)
To: tytso; +Cc: Curt Wohlgemuth, ext4 development
On Thu, Dec 03, 2009 at 08:10:22PM -0500, tytso@mit.edu wrote:
> On Tue, Dec 01, 2009 at 10:17:02AM -0800, Curt Wohlgemuth wrote:
> > This fixes a leak of blocks in an inode prealloc list if device failures
> > cause ext4_mb_mark_diskspace_used() to fail.
>
> I was going to say that it didn't make sense for
> ext4_discard_inode_pa() should be its own function, but maybe we need
> function that returns blocks back to the either inode *or* the group
> preallocation list? Otherwise right now it looks like we would also
> be potentially leaking blocks from the group preallocation list in
> case of a device failure?
For group preallocation we update the group prealloc values in
ext4_mb_release_context and we use ac->ac_b_ex.fe_len to find
out the count of blocks allocated. So i guess we are not going
to leak blocks from group prealloc space.
-aneesh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ext4: Remove blocks from inode prealloc list on failure
2009-12-01 18:17 [PATCH] ext4: Remove blocks from inode prealloc list on failure Curt Wohlgemuth
2009-12-04 1:10 ` tytso
@ 2009-12-04 9:46 ` Aneesh Kumar K.V
2009-12-04 19:14 ` Curt Wohlgemuth
1 sibling, 1 reply; 6+ messages in thread
From: Aneesh Kumar K.V @ 2009-12-04 9:46 UTC (permalink / raw)
To: Curt Wohlgemuth; +Cc: ext4 development
On Tue, Dec 01, 2009 at 10:17:02AM -0800, Curt Wohlgemuth wrote:
> This fixes a leak of blocks in an inode prealloc list if device failures
> cause ext4_mb_mark_diskspace_used() to fail.
>
> Signed-off-by: Curt Wohlgemuth <curtw@google.com>
> ---
> diff -uprN orig/fs/ext4/mballoc.c new/fs/ext4/mballoc.c
> --- orig/fs/ext4/mballoc.c 2009-12-01 09:27:25.000000000 -0800
> +++ new/fs/ext4/mballoc.c 2009-12-01 09:28:38.000000000 -0800
> @@ -3011,6 +3011,22 @@ static void ext4_mb_collect_stats(struct
> }
>
> /*
> + * Called on failure; free up any blocks from the inode PA for this
> + * context.
> + */
> +static void ext4_discard_inode_pa(struct ext4_allocation_context *ac)
> +{
> + struct ext4_prealloc_space *pa = ac->ac_pa;
> + int len;
> +
> + if (pa && pa->pa_type == MB_INODE_PA) {
> + len = ac->ac_b_ex.fe_len;
> + pa->pa_free += len;
> + }
> +
> +}
Can you name it as discard allocated blocks and add a comment saying why
we don't need it for MB_GROUP_PA ? Otherwise
Acked-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> +
> +/*
> * use blocks preallocated to inode
> */
> static void ext4_mb_use_inode_pa(struct ext4_allocation_context *ac,
> @@ -4295,6 +4311,7 @@ repeat:
> ac->ac_status = AC_STATUS_CONTINUE;
> goto repeat;
> } else if (*errp) {
> + ext4_discard_inode_pa(ac);
> ac->ac_b_ex.fe_len = 0;
> ar->len = 0;
> ext4_mb_show_ac(ac);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ext4: Remove blocks from inode prealloc list on failure
2009-12-04 9:46 ` Aneesh Kumar K.V
@ 2009-12-04 19:14 ` Curt Wohlgemuth
2009-12-09 3:21 ` tytso
0 siblings, 1 reply; 6+ messages in thread
From: Curt Wohlgemuth @ 2009-12-04 19:14 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: ext4 development
> Can you name it as discard allocated blocks and add a comment saying why
> we don't need it for MB_GROUP_PA ? Otherwise
>
> Acked-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
This fixes a leak of blocks in an inode prealloc list if device failures
cause ext4_mb_mark_diskspace_used() to fail.
Signed-off-by: Curt Wohlgemuth <curtw@google.com>
---
diff -uprN orig/fs/ext4/mballoc.c new/fs/ext4/mballoc.c
--- orig/fs/ext4/mballoc.c 2009-12-01 09:27:25.000000000 -0800
+++ new/fs/ext4/mballoc.c 2009-12-04 11:09:03.000000000 -0800
@@ -3011,6 +3011,24 @@ static void ext4_mb_collect_stats(struct
}
/*
+ * Called on failure; free up any blocks from the inode PA for this
+ * context. We don't need this for MB_GROUP_PA because we only change
+ * pa_free in ext4_mb_release_context(), but on failure, we've already
+ * zeroed out ac->ac_b_ex.fe_len, so group_pa->pa_free is not changed.
+ */
+static void ext4_discard_allocated_blocks(struct ext4_allocation_context *ac)
+{
+ struct ext4_prealloc_space *pa = ac->ac_pa;
+ int len;
+
+ if (pa && pa->pa_type == MB_INODE_PA) {
+ len = ac->ac_b_ex.fe_len;
+ pa->pa_free += len;
+ }
+
+}
+
+/*
* use blocks preallocated to inode
*/
static void ext4_mb_use_inode_pa(struct ext4_allocation_context *ac,
@@ -4295,6 +4313,7 @@ repeat:
ac->ac_status = AC_STATUS_CONTINUE;
goto repeat;
} else if (*errp) {
+ ext4_discard_allocated_blocks(ac);
ac->ac_b_ex.fe_len = 0;
ar->len = 0;
ext4_mb_show_ac(ac);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ext4: Remove blocks from inode prealloc list on failure
2009-12-04 19:14 ` Curt Wohlgemuth
@ 2009-12-09 3:21 ` tytso
0 siblings, 0 replies; 6+ messages in thread
From: tytso @ 2009-12-09 3:21 UTC (permalink / raw)
To: Curt Wohlgemuth; +Cc: Aneesh Kumar K.V, ext4 development
On Fri, Dec 04, 2009 at 11:14:40AM -0800, Curt Wohlgemuth wrote:
> > Can you name it as discard allocated blocks and add a comment saying why
> > we don't need it for MB_GROUP_PA ? Otherwise
> >
> > Acked-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
>
> This fixes a leak of blocks in an inode prealloc list if device failures
> cause ext4_mb_mark_diskspace_used() to fail.
>
> Signed-off-by: Curt Wohlgemuth <curtw@google.com>
Added to the ext4 patch queue, thanks.
- Ted
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-12-09 3:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-01 18:17 [PATCH] ext4: Remove blocks from inode prealloc list on failure Curt Wohlgemuth
2009-12-04 1:10 ` tytso
2009-12-04 9:43 ` Aneesh Kumar K.V
2009-12-04 9:46 ` Aneesh Kumar K.V
2009-12-04 19:14 ` Curt Wohlgemuth
2009-12-09 3:21 ` tytso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox