* [PATCH] xfs: bulkstat doesn't release AGI buffer on error
@ 2014-10-14 22:12 Dave Chinner
2014-10-15 12:59 ` Brian Foster
2014-10-16 13:45 ` Eric Sandeen
0 siblings, 2 replies; 3+ messages in thread
From: Dave Chinner @ 2014-10-14 22:12 UTC (permalink / raw)
To: xfs
From: Dave Chinner <dchinner@redhat.com>
The recent refactoring of the bulkstat code left a small landmine in
the code. If a inobt read fails, then the tree walk is aborted and
returns without releasing the AGI buffer or freeing the cursor. This
can lead to a subsequent bulkstat call hanging trying to grab the
AGI buffer again.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
fs/xfs/xfs_itable.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index f1deb96..ef8ea05 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -427,7 +427,7 @@ xfs_bulkstat(
error = xfs_bulkstat_grab_ichunk(cur, agino, &icount, &r);
if (error)
- break;
+ goto del_cursor;
if (icount) {
irbp->ir_startino = r.ir_startino;
irbp->ir_freecount = r.ir_freecount;
@@ -442,7 +442,7 @@ xfs_bulkstat(
error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &tmp);
}
if (error)
- break;
+ goto del_cursor;
/*
* Loop through inode btree records in this ag,
@@ -454,7 +454,7 @@ xfs_bulkstat(
error = xfs_inobt_get_rec(cur, &r, &i);
if (error || i == 0) {
end_of_ag = 1;
- break;
+ goto del_cursor;
}
/*
@@ -476,13 +476,17 @@ xfs_bulkstat(
error = xfs_btree_increment(cur, 0, &tmp);
cond_resched();
}
+
/*
- * Drop the btree buffers and the agi buffer.
- * We can't hold any of the locks these represent
- * when calling iget.
+ * Drop the btree buffers and the agi buffer as we can't hold any
+ * of the locks these represent when calling iget. If there is a
+ * pending error, then we are done.
*/
+del_cursor:
xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
xfs_buf_relse(agbp);
+ if (error)
+ break;
/*
* Now format all the good inodes into the user's buffer.
*/
--
2.0.0
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: bulkstat doesn't release AGI buffer on error
2014-10-14 22:12 [PATCH] xfs: bulkstat doesn't release AGI buffer on error Dave Chinner
@ 2014-10-15 12:59 ` Brian Foster
2014-10-16 13:45 ` Eric Sandeen
1 sibling, 0 replies; 3+ messages in thread
From: Brian Foster @ 2014-10-15 12:59 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs
On Wed, Oct 15, 2014 at 09:12:08AM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> The recent refactoring of the bulkstat code left a small landmine in
> the code. If a inobt read fails, then the tree walk is aborted and
> returns without releasing the AGI buffer or freeing the cursor. This
> can lead to a subsequent bulkstat call hanging trying to grab the
> AGI buffer again.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/xfs_itable.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index f1deb96..ef8ea05 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -427,7 +427,7 @@ xfs_bulkstat(
>
> error = xfs_bulkstat_grab_ichunk(cur, agino, &icount, &r);
> if (error)
> - break;
> + goto del_cursor;
> if (icount) {
> irbp->ir_startino = r.ir_startino;
> irbp->ir_freecount = r.ir_freecount;
> @@ -442,7 +442,7 @@ xfs_bulkstat(
> error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &tmp);
> }
> if (error)
> - break;
> + goto del_cursor;
>
> /*
> * Loop through inode btree records in this ag,
> @@ -454,7 +454,7 @@ xfs_bulkstat(
> error = xfs_inobt_get_rec(cur, &r, &i);
> if (error || i == 0) {
> end_of_ag = 1;
> - break;
> + goto del_cursor;
> }
>
> /*
> @@ -476,13 +476,17 @@ xfs_bulkstat(
> error = xfs_btree_increment(cur, 0, &tmp);
> cond_resched();
> }
> +
> /*
> - * Drop the btree buffers and the agi buffer.
> - * We can't hold any of the locks these represent
> - * when calling iget.
> + * Drop the btree buffers and the agi buffer as we can't hold any
> + * of the locks these represent when calling iget. If there is a
> + * pending error, then we are done.
> */
> +del_cursor:
> xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
> xfs_buf_relse(agbp);
> + if (error)
> + break;
> /*
> * Now format all the good inodes into the user's buffer.
> */
> --
> 2.0.0
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: bulkstat doesn't release AGI buffer on error
2014-10-14 22:12 [PATCH] xfs: bulkstat doesn't release AGI buffer on error Dave Chinner
2014-10-15 12:59 ` Brian Foster
@ 2014-10-16 13:45 ` Eric Sandeen
1 sibling, 0 replies; 3+ messages in thread
From: Eric Sandeen @ 2014-10-16 13:45 UTC (permalink / raw)
To: Dave Chinner, xfs
On 10/14/14 5:12 PM, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> The recent refactoring of the bulkstat code left a small landmine in
> the code. If a inobt read fails, then the tree walk is aborted and
> returns without releasing the AGI buffer or freeing the cursor. This
> can lead to a subsequent bulkstat call hanging trying to grab the
> AGI buffer again.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Can you add a cc: stable, too?
> ---
> fs/xfs/xfs_itable.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index f1deb96..ef8ea05 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -427,7 +427,7 @@ xfs_bulkstat(
>
> error = xfs_bulkstat_grab_ichunk(cur, agino, &icount, &r);
> if (error)
> - break;
> + goto del_cursor;
> if (icount) {
> irbp->ir_startino = r.ir_startino;
> irbp->ir_freecount = r.ir_freecount;
> @@ -442,7 +442,7 @@ xfs_bulkstat(
> error = xfs_inobt_lookup(cur, 0, XFS_LOOKUP_GE, &tmp);
> }
> if (error)
> - break;
> + goto del_cursor;
>
> /*
> * Loop through inode btree records in this ag,
> @@ -454,7 +454,7 @@ xfs_bulkstat(
> error = xfs_inobt_get_rec(cur, &r, &i);
> if (error || i == 0) {
> end_of_ag = 1;
> - break;
> + goto del_cursor;
> }
>
> /*
> @@ -476,13 +476,17 @@ xfs_bulkstat(
> error = xfs_btree_increment(cur, 0, &tmp);
> cond_resched();
> }
> +
> /*
> - * Drop the btree buffers and the agi buffer.
> - * We can't hold any of the locks these represent
> - * when calling iget.
> + * Drop the btree buffers and the agi buffer as we can't hold any
> + * of the locks these represent when calling iget. If there is a
> + * pending error, then we are done.
> */
> +del_cursor:
> xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR);
> xfs_buf_relse(agbp);
> + if (error)
> + break;
> /*
> * Now format all the good inodes into the user's buffer.
> */
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-10-16 13:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-14 22:12 [PATCH] xfs: bulkstat doesn't release AGI buffer on error Dave Chinner
2014-10-15 12:59 ` Brian Foster
2014-10-16 13:45 ` Eric Sandeen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox