Message ID | 1600255152-16086-7-git-send-email-kaixuxia@tencent.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | xfs: random fixes and code cleanup | expand |
On Wed, Sep 16, 2020 at 07:19:09PM +0800, xiakaixu1987@gmail.com wrote: > From: Kaixu Xia <kaixuxia@tencent.com> > > We can do the assert directly for the return value of xfs_mod_fdblocks() > function, and the variable error is unnecessary, so remove it. > > Signed-off-by: Kaixu Xia <kaixuxia@tencent.com> > --- > fs/xfs/xfs_trans.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c > index d33d0ba6f3bd..caa207220e2c 100644 > --- a/fs/xfs/xfs_trans.c > +++ b/fs/xfs/xfs_trans.c > @@ -573,7 +573,6 @@ xfs_trans_unreserve_and_mod_sb( > int64_t rtxdelta = 0; > int64_t idelta = 0; > int64_t ifreedelta = 0; > - int error; > > /* calculate deltas */ > if (tp->t_blk_res > 0) > @@ -596,10 +595,8 @@ xfs_trans_unreserve_and_mod_sb( > } > > /* apply the per-cpu counters */ > - if (blkdelta) { > - error = xfs_mod_fdblocks(mp, blkdelta, rsvd); > - ASSERT(!error); > - } > + if (blkdelta) > + ASSERT(!xfs_mod_fdblocks(mp, blkdelta, rsvd)); Um.... did you test this with ASSERTs disabled? Because this compiles the free block counter update out of the function on non-debug kernels, which (AFAICT) will cause fs corruption... --D > > if (idelta) { > percpu_counter_add_batch(&mp->m_icount, idelta, > -- > 2.20.0 >
Hi Darrick, On 2020/9/17 0:45, Darrick J. Wong wrote: > On Wed, Sep 16, 2020 at 07:19:09PM +0800, xiakaixu1987@gmail.com wrote: >> From: Kaixu Xia <kaixuxia@tencent.com> >> >> We can do the assert directly for the return value of xfs_mod_fdblocks() >> function, and the variable error is unnecessary, so remove it. >> >> Signed-off-by: Kaixu Xia <kaixuxia@tencent.com> >> --- >> fs/xfs/xfs_trans.c | 7 ++----- >> 1 file changed, 2 insertions(+), 5 deletions(-) >> >> diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c >> index d33d0ba6f3bd..caa207220e2c 100644 >> --- a/fs/xfs/xfs_trans.c >> +++ b/fs/xfs/xfs_trans.c >> @@ -573,7 +573,6 @@ xfs_trans_unreserve_and_mod_sb( >> int64_t rtxdelta = 0; >> int64_t idelta = 0; >> int64_t ifreedelta = 0; >> - int error; >> >> /* calculate deltas */ >> if (tp->t_blk_res > 0) >> @@ -596,10 +595,8 @@ xfs_trans_unreserve_and_mod_sb( >> } >> >> /* apply the per-cpu counters */ >> - if (blkdelta) { >> - error = xfs_mod_fdblocks(mp, blkdelta, rsvd); >> - ASSERT(!error); >> - } >> + if (blkdelta) >> + ASSERT(!xfs_mod_fdblocks(mp, blkdelta, rsvd)); > > Um.... did you test this with ASSERTs disabled? Because this compiles > the free block counter update out of the function on non-debug kernels, > which (AFAICT) will cause fs corruption... Yes,thanks for pointing out... My fault... > > --D > >> >> if (idelta) { >> percpu_counter_add_batch(&mp->m_icount, idelta, >> -- >> 2.20.0 >>
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index d33d0ba6f3bd..caa207220e2c 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c @@ -573,7 +573,6 @@ xfs_trans_unreserve_and_mod_sb( int64_t rtxdelta = 0; int64_t idelta = 0; int64_t ifreedelta = 0; - int error; /* calculate deltas */ if (tp->t_blk_res > 0) @@ -596,10 +595,8 @@ xfs_trans_unreserve_and_mod_sb( } /* apply the per-cpu counters */ - if (blkdelta) { - error = xfs_mod_fdblocks(mp, blkdelta, rsvd); - ASSERT(!error); - } + if (blkdelta) + ASSERT(!xfs_mod_fdblocks(mp, blkdelta, rsvd)); if (idelta) { percpu_counter_add_batch(&mp->m_icount, idelta,