* [PATCH] xfs: kill xfs_buf_geterror()
@ 2014-05-22 23:53 Dave Chinner
2014-05-23 17:51 ` Brian Foster
2014-05-27 10:44 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Dave Chinner @ 2014-05-22 23:53 UTC (permalink / raw)
To: xfs
From: Dave Chinner <dchinner@redhat.com>
Most of the callers are just calling ASSERT(!xfs_buf_geterror())
which means they are checking for bp->b_error == 0. If bp is null in
this case, we will assert fail, and hence it's no different in
result to oopsing because of a null bp. In some cases, errors have
already been checked for or the function returning the buffer can't
return a buffer with an error, so it's just a redundant assert.
Either way, the assert can either be removed.
The other two non-assert callers can just test for a buffer and
error properly.
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
fs/xfs/xfs_alloc.c | 1 -
fs/xfs/xfs_btree.c | 12 ++----------
fs/xfs/xfs_buf.h | 5 -----
fs/xfs/xfs_buf_item.c | 2 +-
fs/xfs/xfs_dquot.c | 6 +++---
fs/xfs/xfs_ialloc.c | 1 -
fs/xfs/xfs_log.c | 2 +-
fs/xfs/xfs_rtbitmap.c | 1 -
8 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index c1cf6a3..077c3417 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -541,7 +541,6 @@ xfs_alloc_read_agfl(
XFS_FSS_TO_BB(mp, 1), 0, &bp, &xfs_agfl_buf_ops);
if (error)
return error;
- ASSERT(!xfs_buf_geterror(bp));
xfs_buf_set_ref(bp, XFS_AGFL_REF);
*bpp = bp;
return 0;
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index 182bac2..bf810c6 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -553,14 +553,11 @@ xfs_btree_get_bufl(
xfs_fsblock_t fsbno, /* file system block number */
uint lock) /* lock flags for get_buf */
{
- xfs_buf_t *bp; /* buffer pointer (return value) */
xfs_daddr_t d; /* real disk block address */
ASSERT(fsbno != NULLFSBLOCK);
d = XFS_FSB_TO_DADDR(mp, fsbno);
- bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
- ASSERT(!xfs_buf_geterror(bp));
- return bp;
+ return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
}
/*
@@ -575,15 +572,12 @@ xfs_btree_get_bufs(
xfs_agblock_t agbno, /* allocation group block number */
uint lock) /* lock flags for get_buf */
{
- xfs_buf_t *bp; /* buffer pointer (return value) */
xfs_daddr_t d; /* real disk block address */
ASSERT(agno != NULLAGNUMBER);
ASSERT(agbno != NULLAGBLOCK);
d = XFS_AGB_TO_DADDR(mp, agno, agbno);
- bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
- ASSERT(!xfs_buf_geterror(bp));
- return bp;
+ return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
}
/*
@@ -723,7 +717,6 @@ xfs_btree_read_bufl(
mp->m_bsize, lock, &bp, ops);
if (error)
return error;
- ASSERT(!xfs_buf_geterror(bp));
if (bp)
xfs_buf_set_ref(bp, refval);
*bpp = bp;
@@ -1179,7 +1172,6 @@ xfs_btree_read_buf_block(
if (error)
return error;
- ASSERT(!xfs_buf_geterror(*bpp));
xfs_btree_set_refs(cur, *bpp);
*block = XFS_BUF_TO_BLOCK(*bpp);
return 0;
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 0e47fd1..3a7a552 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -298,11 +298,6 @@ extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *,
extern int xfs_bioerror_relse(struct xfs_buf *);
-static inline int xfs_buf_geterror(xfs_buf_t *bp)
-{
- return bp ? bp->b_error : ENOMEM;
-}
-
/* Buffer Utility Routines */
extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t);
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 64b17f5..4654338 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -1052,7 +1052,7 @@ xfs_buf_iodone_callbacks(
static ulong lasttime;
static xfs_buftarg_t *lasttarg;
- if (likely(!xfs_buf_geterror(bp)))
+ if (likely(!bp->b_error))
goto do_callbacks;
/*
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 5fec738..3ee0cd4 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -353,10 +353,10 @@ xfs_qm_dqalloc(
dqp->q_blkno,
mp->m_quotainfo->qi_dqchunklen,
0);
-
- error = xfs_buf_geterror(bp);
- if (error)
+ if (!bp) {
+ error = ENOMEM;
goto error1;
+ }
bp->b_ops = &xfs_dquot_buf_ops;
/*
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index e8dfaf0..5960e55 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -2129,7 +2129,6 @@ xfs_read_agi(
if (error)
return error;
- ASSERT(!xfs_buf_geterror(*bpp));
xfs_buf_set_ref(*bpp, XFS_AGI_REF);
return 0;
}
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 3554098..292308d 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1165,7 +1165,7 @@ xlog_iodone(xfs_buf_t *bp)
/*
* Race to shutdown the filesystem if we see an error.
*/
- if (XFS_TEST_ERROR((xfs_buf_geterror(bp)), l->l_mp,
+ if (XFS_TEST_ERROR(bp->b_error, l->l_mp,
XFS_ERRTAG_IODONE_IOERR, XFS_RANDOM_IODONE_IOERR)) {
xfs_buf_ioerror_alert(bp, __func__);
xfs_buf_stale(bp);
diff --git a/fs/xfs/xfs_rtbitmap.c b/fs/xfs/xfs_rtbitmap.c
index b1f2fe8..f4dd697 100644
--- a/fs/xfs/xfs_rtbitmap.c
+++ b/fs/xfs/xfs_rtbitmap.c
@@ -74,7 +74,6 @@ xfs_rtbuf_get(
mp->m_bsize, 0, &bp, NULL);
if (error)
return error;
- ASSERT(!xfs_buf_geterror(bp));
*bpp = bp;
return 0;
}
--
1.9.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: kill xfs_buf_geterror()
2014-05-22 23:53 [PATCH] xfs: kill xfs_buf_geterror() Dave Chinner
@ 2014-05-23 17:51 ` Brian Foster
2014-05-27 10:44 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Brian Foster @ 2014-05-23 17:51 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs
On Fri, May 23, 2014 at 09:53:27AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> Most of the callers are just calling ASSERT(!xfs_buf_geterror())
> which means they are checking for bp->b_error == 0. If bp is null in
> this case, we will assert fail, and hence it's no different in
> result to oopsing because of a null bp. In some cases, errors have
> already been checked for or the function returning the buffer can't
> return a buffer with an error, so it's just a redundant assert.
> Either way, the assert can either be removed.
>
> The other two non-assert callers can just test for a buffer and
> error properly.
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
Looks good to me.
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/xfs_alloc.c | 1 -
> fs/xfs/xfs_btree.c | 12 ++----------
> fs/xfs/xfs_buf.h | 5 -----
> fs/xfs/xfs_buf_item.c | 2 +-
> fs/xfs/xfs_dquot.c | 6 +++---
> fs/xfs/xfs_ialloc.c | 1 -
> fs/xfs/xfs_log.c | 2 +-
> fs/xfs/xfs_rtbitmap.c | 1 -
> 8 files changed, 7 insertions(+), 23 deletions(-)
>
> diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
> index c1cf6a3..077c3417 100644
> --- a/fs/xfs/xfs_alloc.c
> +++ b/fs/xfs/xfs_alloc.c
> @@ -541,7 +541,6 @@ xfs_alloc_read_agfl(
> XFS_FSS_TO_BB(mp, 1), 0, &bp, &xfs_agfl_buf_ops);
> if (error)
> return error;
> - ASSERT(!xfs_buf_geterror(bp));
> xfs_buf_set_ref(bp, XFS_AGFL_REF);
> *bpp = bp;
> return 0;
> diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
> index 182bac2..bf810c6 100644
> --- a/fs/xfs/xfs_btree.c
> +++ b/fs/xfs/xfs_btree.c
> @@ -553,14 +553,11 @@ xfs_btree_get_bufl(
> xfs_fsblock_t fsbno, /* file system block number */
> uint lock) /* lock flags for get_buf */
> {
> - xfs_buf_t *bp; /* buffer pointer (return value) */
> xfs_daddr_t d; /* real disk block address */
>
> ASSERT(fsbno != NULLFSBLOCK);
> d = XFS_FSB_TO_DADDR(mp, fsbno);
> - bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
> - ASSERT(!xfs_buf_geterror(bp));
> - return bp;
> + return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
> }
>
> /*
> @@ -575,15 +572,12 @@ xfs_btree_get_bufs(
> xfs_agblock_t agbno, /* allocation group block number */
> uint lock) /* lock flags for get_buf */
> {
> - xfs_buf_t *bp; /* buffer pointer (return value) */
> xfs_daddr_t d; /* real disk block address */
>
> ASSERT(agno != NULLAGNUMBER);
> ASSERT(agbno != NULLAGBLOCK);
> d = XFS_AGB_TO_DADDR(mp, agno, agbno);
> - bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
> - ASSERT(!xfs_buf_geterror(bp));
> - return bp;
> + return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
> }
>
> /*
> @@ -723,7 +717,6 @@ xfs_btree_read_bufl(
> mp->m_bsize, lock, &bp, ops);
> if (error)
> return error;
> - ASSERT(!xfs_buf_geterror(bp));
> if (bp)
> xfs_buf_set_ref(bp, refval);
> *bpp = bp;
> @@ -1179,7 +1172,6 @@ xfs_btree_read_buf_block(
> if (error)
> return error;
>
> - ASSERT(!xfs_buf_geterror(*bpp));
> xfs_btree_set_refs(cur, *bpp);
> *block = XFS_BUF_TO_BLOCK(*bpp);
> return 0;
> diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
> index 0e47fd1..3a7a552 100644
> --- a/fs/xfs/xfs_buf.h
> +++ b/fs/xfs/xfs_buf.h
> @@ -298,11 +298,6 @@ extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *,
>
> extern int xfs_bioerror_relse(struct xfs_buf *);
>
> -static inline int xfs_buf_geterror(xfs_buf_t *bp)
> -{
> - return bp ? bp->b_error : ENOMEM;
> -}
> -
> /* Buffer Utility Routines */
> extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t);
>
> diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> index 64b17f5..4654338 100644
> --- a/fs/xfs/xfs_buf_item.c
> +++ b/fs/xfs/xfs_buf_item.c
> @@ -1052,7 +1052,7 @@ xfs_buf_iodone_callbacks(
> static ulong lasttime;
> static xfs_buftarg_t *lasttarg;
>
> - if (likely(!xfs_buf_geterror(bp)))
> + if (likely(!bp->b_error))
> goto do_callbacks;
>
> /*
> diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
> index 5fec738..3ee0cd4 100644
> --- a/fs/xfs/xfs_dquot.c
> +++ b/fs/xfs/xfs_dquot.c
> @@ -353,10 +353,10 @@ xfs_qm_dqalloc(
> dqp->q_blkno,
> mp->m_quotainfo->qi_dqchunklen,
> 0);
> -
> - error = xfs_buf_geterror(bp);
> - if (error)
> + if (!bp) {
> + error = ENOMEM;
> goto error1;
> + }
> bp->b_ops = &xfs_dquot_buf_ops;
>
> /*
> diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
> index e8dfaf0..5960e55 100644
> --- a/fs/xfs/xfs_ialloc.c
> +++ b/fs/xfs/xfs_ialloc.c
> @@ -2129,7 +2129,6 @@ xfs_read_agi(
> if (error)
> return error;
>
> - ASSERT(!xfs_buf_geterror(*bpp));
> xfs_buf_set_ref(*bpp, XFS_AGI_REF);
> return 0;
> }
> diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
> index 3554098..292308d 100644
> --- a/fs/xfs/xfs_log.c
> +++ b/fs/xfs/xfs_log.c
> @@ -1165,7 +1165,7 @@ xlog_iodone(xfs_buf_t *bp)
> /*
> * Race to shutdown the filesystem if we see an error.
> */
> - if (XFS_TEST_ERROR((xfs_buf_geterror(bp)), l->l_mp,
> + if (XFS_TEST_ERROR(bp->b_error, l->l_mp,
> XFS_ERRTAG_IODONE_IOERR, XFS_RANDOM_IODONE_IOERR)) {
> xfs_buf_ioerror_alert(bp, __func__);
> xfs_buf_stale(bp);
> diff --git a/fs/xfs/xfs_rtbitmap.c b/fs/xfs/xfs_rtbitmap.c
> index b1f2fe8..f4dd697 100644
> --- a/fs/xfs/xfs_rtbitmap.c
> +++ b/fs/xfs/xfs_rtbitmap.c
> @@ -74,7 +74,6 @@ xfs_rtbuf_get(
> mp->m_bsize, 0, &bp, NULL);
> if (error)
> return error;
> - ASSERT(!xfs_buf_geterror(bp));
> *bpp = bp;
> return 0;
> }
> --
> 1.9.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: kill xfs_buf_geterror()
2014-05-22 23:53 [PATCH] xfs: kill xfs_buf_geterror() Dave Chinner
2014-05-23 17:51 ` Brian Foster
@ 2014-05-27 10:44 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2014-05-27 10:44 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs
On Fri, May 23, 2014 at 09:53:27AM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> Most of the callers are just calling ASSERT(!xfs_buf_geterror())
> which means they are checking for bp->b_error == 0. If bp is null in
> this case, we will assert fail, and hence it's no different in
> result to oopsing because of a null bp. In some cases, errors have
> already been checked for or the function returning the buffer can't
> return a buffer with an error, so it's just a redundant assert.
> Either way, the assert can either be removed.
>
> The other two non-assert callers can just test for a buffer and
> error properly.
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
_______________________________________________
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-05-27 10:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-22 23:53 [PATCH] xfs: kill xfs_buf_geterror() Dave Chinner
2014-05-23 17:51 ` Brian Foster
2014-05-27 10:44 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox