Joseph Qi
2015-Apr-01 00:43 UTC
[Ocfs2-devel] [PATCH] ocfs2: check if the ocfs2 lock resource be initialized before calling ocfs2_dlm_lock
Hi Andrew, On 2015/4/1 6:13, Andrew Morton wrote:> On Mon, 30 Mar 2015 11:22:13 +0800 alex chen <alex.chen at huawei.com> wrote: > >> --- a/fs/ocfs2/dlmglue.c >> +++ b/fs/ocfs2/dlmglue.c >> @@ -1391,6 +1391,11 @@ static int __ocfs2_cluster_lock(struct ocfs2_super *osb, >> int noqueue_attempted = 0; >> int dlm_locked = 0; >> >> + if (!(lockres->l_flags & OCFS2_LOCK_INITIALIZED)) { >> + mlog_errno(-EINVAL); >> + return -EINVAL; >> + } > > hm. How about we do this? > > > From: Andrew Morton <akpm at linux-foundation.org> > Subject: ocfs2: make mlog_errno return the errno > > ocfs2 does > > mlog_errno(v); > return v; > > in many places. Change mlog_errno() so we can do > > return mlog_errno(v); >I don't think this is fit for all. In many places it should do cleanup rather than just return the error code.> For some weird reason this patch reduces the size of ocfs2 by 6k: > > akpm3:/usr/src/25> size fs/ocfs2/ocfs2.ko > text data bss dec hex filename > 1146613 82767 832192 2061572 1f7504 fs/ocfs2/ocfs2.ko-before > 1140857 82767 832192 2055816 1f5e88 fs/ocfs2/ocfs2.ko-after > > Cc: Mark Fasheh <mfasheh at suse.com> > Cc: Joel Becker <jlbec at evilplan.org> > Cc: alex chen <alex.chen at huawei.com> > Signed-off-by: Andrew Morton <akpm at linux-foundation.org> > --- > > fs/ocfs2/cluster/masklog.h | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff -puN fs/ocfs2/cluster/masklog.h~a fs/ocfs2/cluster/masklog.h > --- a/fs/ocfs2/cluster/masklog.h~a > +++ a/fs/ocfs2/cluster/masklog.h > @@ -196,13 +196,14 @@ extern struct mlog_bits mlog_and_bits, m > } \ > } while (0) > > -#define mlog_errno(st) do { \ > +#define mlog_errno(st) ({ \ > int _st = (st); \ > if (_st != -ERESTARTSYS && _st != -EINTR && \ > _st != AOP_TRUNCATED_PAGE && _st != -ENOSPC && \ > _st != -EDQUOT) \ > mlog(ML_ERROR, "status = %lld\n", (long long)_st); \ > -} while (0) > + st; \ > +}) > > #define mlog_bug_on_msg(cond, fmt, args...) do { \ > if (cond) { \ > _ > > > . >
Andrew Morton
2015-Apr-01 02:19 UTC
[Ocfs2-devel] [PATCH] ocfs2: check if the ocfs2 lock resource be initialized before calling ocfs2_dlm_lock
On Wed, 1 Apr 2015 08:43:45 +0800 Joseph Qi <joseph.qi at huawei.com> wrote:> > From: Andrew Morton <akpm at linux-foundation.org> > > Subject: ocfs2: make mlog_errno return the errno > > > > ocfs2 does > > > > mlog_errno(v); > > return v; > > > > in many places. Change mlog_errno() so we can do > > > > return mlog_errno(v); > > > I don't think this is fit for all. > In many places it should do cleanup rather than just return the error > code.There are about 50 sites which can use this.
alex chen
2015-Apr-02 03:14 UTC
[Ocfs2-devel] [PATCH] ocfs2: check if the ocfs2 lock resource be initialized before calling ocfs2_dlm_lock
Hi Andrew, On 2015/4/1 10:19, Andrew Morton wrote:> On Wed, 1 Apr 2015 08:43:45 +0800 Joseph Qi <joseph.qi at huawei.com> wrote: > >>> From: Andrew Morton <akpm at linux-foundation.org> >>> Subject: ocfs2: make mlog_errno return the errno >>> >>> ocfs2 does >>> >>> mlog_errno(v); >>> return v; >>> >>> in many places. Change mlog_errno() so we can do >>> >>> return mlog_errno(v); >>> >> I don't think this is fit for all. >> In many places it should do cleanup rather than just return the error >> code. > > There are about 50 sites which can use this. >Can we define a new macro 'mlog_errno_return' as described below ? In addition, ocfs2 does if (v) mlog_errno(v); return v; in some places. In order to deal with this situation we can judge if 'st' is not equal to zero before printing log. Thanks Alex --- fs/ocfs2/cluster/masklog.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h index 2260fb9..269fef9 100644 --- a/fs/ocfs2/cluster/masklog.h +++ b/fs/ocfs2/cluster/masklog.h @@ -204,6 +204,15 @@ extern struct mlog_bits mlog_and_bits, mlog_not_bits; mlog(ML_ERROR, "status = %lld\n", (long long)_st); \ } while (0) +#define mlog_errno_return(st) ({ \ + int _st = (st); \ + if (_st != 0 && _st != -ERESTARTSYS && _st != -EINTR && \ + _st != AOP_TRUNCATED_PAGE && _st != -ENOSPC && \ + _st != -EDQUOT) \ + mlog(ML_ERROR, "status = %lld\n", (long long)_st); \ + st; \ +}) + #define mlog_bug_on_msg(cond, fmt, args...) do { \ if (cond) { \ mlog(ML_ERROR, "bug expression: " #cond "\n"); \ -- 1.8.4.3