From morrone2 at llnl.gov Tue Dec 1 03:33:39 2015 From: morrone2 at llnl.gov (Christopher J. Morrone) Date: Mon, 30 Nov 2015 19:33:39 -0800 Subject: [lustre-devel] Should we have fewer releases? In-Reply-To: <84F441B5-CB1E-4899-BCB1-4A3A25C94B19@intel.com> References: <563A6351.4080407@llnl.gov> <563BCDDE.9060103@llnl.gov> <7AE60ED4-FCA4-4263-887B-5DFC8A0866DA@intel.com> <563D24F2.8050108@llnl.gov> <84F441B5-CB1E-4899-BCB1-4A3A25C94B19@intel.com> Message-ID: <565D1513.2060401@llnl.gov> On 11/07/2015 12:36 AM, Drokin, Oleg wrote: > Hello! > > On Nov 6, 2015, at 5:08 PM, Christopher J. Morrone wrote: > >> On 11/06/2015 06:39 AM, Drokin, Oleg wrote: >>> Hello! >>> >>> On Nov 5, 2015, at 4:45 PM, Christopher J. Morrone wrote: >>>> On the contrary, we need to go in the opposite direction to achieve those goals. We need to shorten the release cycle and have more frequent releases. I would recommend that we move to to a roughly three month release cycle. Some of the benefits might be: >>>> >>>> * Less change and accumulate before the release >>>> * The penalty for missing a release landing window is reduced when releases are more often >>>> * Code reviewers have less pressure to land unfinished and/or insufficiently reviewed and tested code when the penalty is reduced >>>> * Less change means less to test and fix at release time >>>> * Bug authors are more likely to still remember what they did and participate in cleanup. >>>> * Less time before bugs that slip through the cracks appear in a major release >>>> * Reduces developer frustration with long freeze windows >>>> * Encourages developers to rally more frequently around the landing windows instead of falling into a long period of silence and then trying to shove a bunch of code in just before freeze. (They'll still try to ram things in just before freeze, but with more frequent landing windows the amount will be smaller and more manageable.) >>> >>> Bringing this to the logical extreme - we should just have one release per major feature. >> >> It do not agree that it is logical to extend the argument to that extreme. That is the "Appeal to Extremes" logical fallacy. > > It probably is. But it's sometimes useful still. > >> I also don't think it is appropriate to conflate major releases with major features. When/if we move to a shorter release cycle, it would be entirely appropriate to put out a major release with no headline "major features". It is totally acceptable to release the many changes that did make it in the landing window. Even if none of the changes individually count as "major", they still collectively represent a major amount of work. > > Yes, I agree there could be releases with no major new features, though attempts to make them in the past were not met with great enthusiasm. > >> Right now we combine that major amount of work with seriously destabilizing new features that more than offset all the bug fixing that went on. Why do we insist on making those destabilizing influences a requirement for a release? > > That's what people want, apparently. Features are developed because there's a need for them. Yes, people want everything. While we want features, we want stability just as much. So far stability has been playing second chair to features with Lustre. We can't stop adding features, but we do need to shift the level of balance a bit. >> Whether a major feature makes it into any particular release should be judge primarily on the quality and completeness of code, testing, and documentation for said feature. Further, how many major features can be landed in a release would be gated on the amount of manpower we have for review and testing. If 3 major features are truely complete and ready to land, but we can only fully vet 1 in the landing window, well, only one will land. We'll have to make a judgement call as a community on the priority and work on that. > > I am skeptical this is going to work. If a feature is perceived to be ready, but is not accepted for whatever reason, those who feel they need it would just find some way of using it anyway. > And it would lead to more fragmentation in the end. If you really think about it, we already have that fragmentation today. Hopefully the burden of constantly refreshing one's private major features to work with master will convince organizations that it is in their best effort to upstream their code. I think that what causes people to be most annoyed and stop working with an upstream is when the upstream developers are uncommunicative and seemingly arbitrary. We could use some work in that area, I think, if we are all honest. I think that if we all discuss landing priority and some's feature is deemed too low to get into the current release, yes, that author will be disappointed. But I think that the vast majority of developers would also be understanding. They would especially be understanding if we explain that it will be at the top of the list for the next landing cycle. Feedback and communication go a long way to keeping everyone content. >> In summary: I think we should decouple the concept of major releases and major features. Major releases do not need to be subject to major features. > > Should there be a period where no new features were developed into the "Ready to include" state, yes - I am all for it. > I guess you think this is going to be easier to achieve by shortening time to next release. It's just right now we have such a backlog of features that that might not be a realistic assumption. We have a backlog of stability and usability too. I don't care how big the feature backlog is, we can't allow them in unless they are reasonably stable. >>> Sadly, I think the stabilization process is not likely to get any shorter. >> Do not see a connection between the amount of change and the time it takes to stabilize that change? Can you explain why you think that? > > Testing (and vetting) takes a fixed time. For large scale community testing we also depend on large systems availability schedule. These do not change. If you are right that test dates on large systems are unchangeable, then our current unpredicatble releases are completely incompatible with that model. But, with all due respect, I think you are wrong about that. Test dates on large machines _are_ changeable. Those dates need to be scheduled in advance, but we _can_ change when those future testing windows will be. Also, if we can't find ways to improve SQA other than small testing windows on large systems, then we may as well just give up on Lustre now. That will never result in quality software. Fortunately, I do not believe that is the case. I think there are many ways that we can improve the development processes over time to result in higher quality software. Testing won't catch enough on its own. > Any problems found would require a retest once the fix is in place. > Then there's a backlog of "deferred" bugs that are not deemed super critical, but as number of truly critical bugs goes down, I suspect those bugs from backlog would be viewed > as more serious (and I don't think it's a bad thing). > > Of course I might be all wrong on this, but it's just my feeling. If we take any past Lustre release and add another X months of pure code freeze and stabilization, > do you think that particular release would not have benefitted from that? > I suspect same is true of (almost?) any other software project. Not really. We have already been adding X months of code freeze randomly as needed. Once the easily found bugs are squashed the developers move on to adding new bugs^H^H^H^Hfeatures. I don't think that testing alone is going to solve our quality problem. [cut some things we agreed upon] >> If we have release every three months on a _reliable_ schedule, that will give prospective testers the ability to plan their testing time ahead, increases the probability that each prospective tester will have spare time that aligns with one of our release testing windows. > > We need all the diverse testing we can get and then some. So there's no disagreement from me here. > If you think just by doubling the number of releases gets us double the testing time from community, that alone might be worth it. No, I don't think the testing will double. I think a smaller overall improvement (10%? 20%? 30%?) might be reasonable. I want this change not primarily for testing, but for the other advantages that it can provide to the development process. Mainly it allows us to start getting control of the amount of change in each release. Less change and shorter delay between landing and testing will tend to decrease the difficulty of removing the bugs that we find. We are under less pressure to land unfinished features because the penalty for missing a release is lowered (only 3 months until the next release instead of the current 6-9 months). Etc. [cut] >> Making the releases more frequently and on a reliable schedule is not magic; it will not fix everything about our development process on its own. Nevertheless I do believe that it will be a key supporting element in improving our software development and SQA processes. > > We just need to ensure the rate at which bugs are introduced is a lot smaller than the rate at which bugs are fixed. ;) > And we need to also achieve this without choking new features somehow. I agree! We haven't been too successful at introducing fewer bugs than we fix thus far with Lustre. :) The painful truth is that feature progress probably needs to be slower if we want higher quality software in the future. We shouldn't stop feature development, but we should take more care in their landing than we have in the past if we want stability to improve. It is always a balancing game. Chris From Valdis.Kletnieks at vt.edu Tue Dec 1 22:05:15 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Tue, 1 Dec 2015 17:05:15 -0500 Subject: [lustre-devel] [lustre cleanups 2/6] Fix set-but-unused whinge. In-Reply-To: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: <1449007519-73974-3-git-send-email-Valdis.Kletnieks@vt.edu> drivers/staging/lustre/lustre/fid/lproc_fid.c: In function 'ldebugfs_fid_write_common': drivers/staging/lustre/lustre/fid/lproc_fid.c:67:6: warning: variable 'rc' set but not used [-Wunused-but-set-variable] int rc; We fix it by *using* the return code to help bulletproof it. It says it's test code - it should be *more* bulletproof than production, not less. Signed-off-by: Valdis Kletnieks --- diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index ce90c1c54a63..eff011f30fa5 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -85,6 +85,8 @@ ldebugfs_fid_write_common(const char __user *buffer, size_t count, rc = sscanf(kernbuf, "[%llx - %llx]\n", (unsigned long long *)&tmp.lsr_start, (unsigned long long *)&tmp.lsr_end); + if (rc != 2) + return -EINVAL; if (!range_is_sane(&tmp) || range_is_zero(&tmp) || tmp.lsr_start < range->lsr_start || tmp.lsr_end > range->lsr_end) return -EINVAL; -- 2.6.3 From Valdis.Kletnieks at vt.edu Tue Dec 1 22:05:13 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Tue, 1 Dec 2015 17:05:13 -0500 Subject: [lustre-devel] [lustre cleanups 0/6] Patch series to make lustre safe(r) for W=1 compiles Message-ID: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> Start of a batch series to clean up the Lustre tree. Other people have done some sparse and checkpatch cleanups, but I found a bunch of stuff building with W=1. Valdis Kletnieks (6): Swap inline/const to kill 272 warnings Fix set-but-unused whinge. Clean up another C warnining: Fix another C compiler whine: Nuke an unsigned >= 0 assert Nuke another unsigned >= 0 assert drivers/staging/lustre/lustre/fid/lproc_fid.c | 1 + drivers/staging/lustre/lustre/include/lu_object.h | 2 +- drivers/staging/lustre/lustre/include/lustre_cfg.h | 4 -- drivers/staging/lustre/lustre/libcfs/module.c | 15 ++++---- drivers/staging/lustre/lustre/llite/rw.c | 1 - drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 1 - 7 files changed, 26 insertions(+), 41 deletions(-) -- 2.6.3 From Valdis.Kletnieks at vt.edu Tue Dec 1 22:05:17 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Tue, 1 Dec 2015 17:05:17 -0500 Subject: [lustre-devel] [lustre cleanups 4/6] Fix another C compiler whine: In-Reply-To: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: <1449007519-73974-5-git-send-email-Valdis.Kletnieks@vt.edu> CC [M] drivers/staging/lustre/lustre/libcfs/module.o drivers/staging/lustre/lustre/libcfs/module.c: In function 'lustre_insert_debugfs': drivers/staging/lustre/lustre/libcfs/module.c:670:17: warning: variable 'entry' set but not used [-Wunused-but-set-variable] struct dentry *entry; ^ Just ignore the dentry returned, and add a comment that we *know* we're not really leaking the dentry because something else will be able to reap it via recursion. Signed-off-by: Valdis Kletnieks --- :100644 100644 96d9d4651a51... 4438dc426b54... M drivers/staging/lustre/lustre/libcfs/module.c drivers/staging/lustre/lustre/libcfs/module.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 96d9d4651a51..4438dc426b54 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -667,8 +667,6 @@ static const struct file_operations lnet_debugfs_file_operations = { void lustre_insert_debugfs(struct ctl_table *table, const struct lnet_debugfs_symlink_def *symlinks) { - struct dentry *entry; - if (lnet_debugfs_root == NULL) lnet_debugfs_root = debugfs_create_dir("lnet", NULL); @@ -676,15 +676,18 @@ void lustre_insert_debugfs(struct ctl_table *table, if (IS_ERR_OR_NULL(lnet_debugfs_root)) return; + /* We don't save the dentry returned in next two calls, because + * we don't call debugfs_remove() but rather remove_recursive() + */ for (; table->procname; table++) - entry = debugfs_create_file(table->procname, table->mode, - lnet_debugfs_root, table, - &lnet_debugfs_file_operations); + debugfs_create_file(table->procname, table->mode, + lnet_debugfs_root, table, + &lnet_debugfs_file_operations); for (; symlinks && symlinks->name; symlinks++) - entry = debugfs_create_symlink(symlinks->name, - lnet_debugfs_root, - symlinks->target); + debugfs_create_symlink(symlinks->name, + lnet_debugfs_root, + symlinks->target); } EXPORT_SYMBOL_GPL(lustre_insert_debugfs); -- 2.6.3 From Valdis.Kletnieks at vt.edu Tue Dec 1 22:05:16 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Tue, 1 Dec 2015 17:05:16 -0500 Subject: [lustre-devel] [lustre cleanups 3/6] Clean up another C warnining: In-Reply-To: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: <1449007519-73974-4-git-send-email-Valdis.Kletnieks@vt.edu> drivers/staging/lustre/lustre/fid/../include/lustre_cfg.h: In function 'lustre_cfg_free': drivers/staging/lustre/lustre/fid/../include/lustre_cfg.h:253:6: warning: variable 'len' set but not used [-Wunused-but-set-variable] int len; Yep, we're just gonna call kfree, no need to calculate len. Bye-bye. Signed-off-by: Valdis Kletnieks --- diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index eb6b292b7b25..d30d8b054c92 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -252,10 +252,6 @@ static inline struct lustre_cfg *lustre_cfg_new(int cmd, static inline void lustre_cfg_free(struct lustre_cfg *lcfg) { - int len; - - len = lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens); - kfree(lcfg); return; } -- 2.6.3 From Valdis.Kletnieks at vt.edu Tue Dec 1 22:05:14 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Tue, 1 Dec 2015 17:05:14 -0500 Subject: [lustre-devel] [lustre cleanups 1/6] Swap inline/const to kill 272 warnings In-Reply-To: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: <1449007519-73974-2-git-send-email-Valdis.Kletnieks@vt.edu> Start of a batch series to clean up the Lustre tree. Other people have done some sparse and checkpatch cleanups, but I found a bunch of stuff building with W=1. Low-hanging fruit first: CC [M] drivers/staging/lustre/lustre/fid/fid_request.o In file included from drivers/staging/lustre/lustre/fid/../include/lustre_net.h:66:0, from drivers/staging/lustre/lustre/fid/../include/lustre_lib.h:64, from drivers/staging/lustre/lustre/fid/../include/obd.h:52, from drivers/staging/lustre/lustre/fid/fid_request.c:48: drivers/staging/lustre/lustre/fid/../include/lu_object.h:765:1: warning: 'inline' is not at beginning of declaration [-Wold-style- declaration] static const inline struct lu_device_operations * ^ So we just swap inline and const. 272 warnings gone. :) Signed-off-by: Valdis Kletnieks --- diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index fa78689748a9..176724f60c1b 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -756,7 +756,7 @@ static inline const struct lu_fid *lu_object_fid(const struct lu_object *o) /** * return device operations vector for this object */ -static const inline struct lu_device_operations * +static inline const struct lu_device_operations * lu_object_ops(const struct lu_object *o) { return o->lo_dev->ld_ops; -- 2.6.3 From Valdis.Kletnieks at vt.edu Tue Dec 1 22:05:19 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Tue, 1 Dec 2015 17:05:19 -0500 Subject: [lustre-devel] [lustre cleanups 6/6] Nuke another unsigned >= 0 assert In-Reply-To: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: <1449007519-73974-7-git-send-email-Valdis.Kletnieks@vt.edu> Clean up another case of the compiler remininding the programmer they are an idiot: drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c:308:34: warning: comparison of u nsigned expression >= 0 is always true [-Wtype-limits] LASSERT(page_pools.epp_waitqlen >= 0); Just lose the assert, and save a page of compiler spew. Signed-off-by: Valdis Kletnieks --- diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index cd8a9987f7ac..1f326673f089 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -304,7 +304,6 @@ static unsigned long enc_pools_cleanup(struct page ***pools, int npools) static inline void enc_pools_wakeup(void) { assert_spin_locked(&page_pools.epp_lock); - LASSERT(page_pools.epp_waitqlen >= 0); if (unlikely(page_pools.epp_waitqlen)) { LASSERT(waitqueue_active(&page_pools.epp_waitq)); -- 2.6.3 From Valdis.Kletnieks at vt.edu Tue Dec 1 22:05:18 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Tue, 1 Dec 2015 17:05:18 -0500 Subject: [lustre-devel] [lustre cleanups 5/6] Nuke an unsigned >= 0 assert In-Reply-To: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: <1449007519-73974-6-git-send-email-Valdis.Kletnieks@vt.edu> Writing asserts for almost-never-can-happen things can be valuable. Writing an assert that tests that an "unsigned int" hasn't gone negative isn't. And it generates an *ugly* message: drivers/staging/lustre/lustre/llite/rw.c:763:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] LASSERTF(reserved >= 0, "reserved %lu\n", reserved); ^ include/linux/compiler.h:137:45: note: in definition of macro 'unlikely' # define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0)) ^ drivers/staging/lustre/lustre/llite/rw.c:763:2: note: in expansion of macro 'LASSERTF' LASSERTF(reserved >= 0, "reserved %lu\n", reserved); ^ drivers/staging/lustre/lustre/llite/rw.c:763:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] LASSERTF(reserved >= 0, "reserved %lu\n", reserved); ^ include/linux/compiler.h:137:53: note: in definition of macro 'unlikely' # define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0)) ^ drivers/staging/lustre/lustre/llite/rw.c:763:2: note: in expansion of macro 'LASSERTF' LASSERTF(reserved >= 0, "reserved %lu\n", reserved); ^ drivers/staging/lustre/lustre/llite/rw.c:763:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] LASSERTF(reserved >= 0, "reserved %lu\n", reserved); ^ include/linux/compiler.h:110:47: note: in definition of macro 'likely_notrace' #define likely_notrace(x) __builtin_expect(!!(x), 1) ^ include/linux/compiler.h:137:58: note: in expansion of macro '__branch_check__' # define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0)) ^ drivers/staging/lustre/lustre/llite/../include/linux/../../../include/linux/libcfs/libcfs_private.h:58:6: note: in expansion of macro 'unlikely' if (unlikely(!(cond))) { \ ^ drivers/staging/lustre/lustre/llite/rw.c:763:2: note: in expansion of macro 'LASSERTF' LASSERTF(reserved >= 0, "reserved %lu\n", reserved); ^ Umm, thank you, GCC. We'll delete the problem line so ne never see that spew again. Signed-off-by: Valdis Kletnieks --- diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index f79193fa2fb7..39390aab9da2 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -764,7 +764,6 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, ret = ll_read_ahead_pages(env, io, queue, ria, &reserved, mapping, &ra_end); - LASSERTF(reserved >= 0, "reserved %lu\n", reserved); if (reserved != 0) ll_ra_count_put(ll_i2sbi(inode), reserved); -- 2.6.3 From dan.carpenter at oracle.com Wed Dec 2 07:46:17 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 2 Dec 2015 10:46:17 +0300 Subject: [lustre-devel] [PATCH 02/40] staging: lustre: fix 'NULL pointer dereference' errors for LNet In-Reply-To: <1448062576-23757-3-git-send-email-jsimmons@infradead.org> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-3-git-send-email-jsimmons@infradead.org> Message-ID: <20151202074617.GI18797@mwanda> On Fri, Nov 20, 2015 at 06:35:38PM -0500, James Simmons wrote: > From: Sebastien Buisson > > Fix 'NULL pointer dereference' defects found by Coverity version > 6.5.3: > Dereference after null check (FORWARD_NULL) > For instance, Passing null pointer to a function which dereferences > it. > Dereference before null check (REVERSE_INULL) > Null-checking variable suggests that it may be null, but it has > already been dereferenced on all paths leading to the check. > Dereference null return value (NULL_RETURNS) > > The following fixes for the LNet layer are broken out of patch > http://review.whamcloud.com/4720. > > Signed-off-by: Sebastien Buisson > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2217 > Reviewed-on: http://review.whamcloud.com/4720 > Reviewed-by: Dmitry Eremin > Reviewed-by: Oleg Drokin > --- > .../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 2 +- > drivers/staging/lustre/lnet/lnet/lib-move.c | 2 + > drivers/staging/lustre/lnet/selftest/conctl.c | 51 ++++++++++---------- > 3 files changed, 29 insertions(+), 26 deletions(-) > > diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > index de0f85f..0f4154c 100644 > --- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > +++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c > @@ -2829,7 +2829,7 @@ int kiblnd_startup(lnet_ni_t *ni) > return 0; > > failed: > - if (net->ibn_dev == NULL && ibdev != NULL) > + if (net && net->ibn_dev == NULL && ibdev != NULL) > kiblnd_destroy_dev(ibdev); > > net_failed: I think the warning must be for a really really old version. This was fixed in: 3247c4e5ef5d ('staging: lustre: lnet: klnds: o2iblnd: fix null dereference on failed path in o2iblnd.c'). The new NULL check is superflous. > diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c > index 5631f60..7a68382 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-move.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c > @@ -162,6 +162,7 @@ lnet_iov_nob(unsigned int niov, struct kvec *iov) > { > unsigned int nob = 0; > > + LASSERT(niov == 0 || iov); > while (niov-- > 0) > nob += (iov++)->iov_len; > > @@ -280,6 +281,7 @@ lnet_kiov_nob(unsigned int niov, lnet_kiov_t *kiov) > { > unsigned int nob = 0; > > + LASSERT(niov == 0 || kiov); > while (niov-- > 0) > nob += (kiov++)->kiov_len; > Fine, I suppose. > diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c > index 556c837..2ca7d0e 100644 > --- a/drivers/staging/lustre/lnet/selftest/conctl.c > +++ b/drivers/staging/lustre/lnet/selftest/conctl.c > @@ -679,45 +679,46 @@ static int > lst_stat_query_ioctl(lstio_stat_args_t *args) > { > int rc; > - char *name; > + char *name = NULL; > > /* TODO: not finished */ > if (args->lstio_sta_key != console_session.ses_key) > return -EACCES; > > - if (args->lstio_sta_resultp == NULL || > - (args->lstio_sta_namep == NULL && > - args->lstio_sta_idsp == NULL) || > - args->lstio_sta_nmlen <= 0 || > - args->lstio_sta_nmlen > LST_NAME_SIZE) > - return -EINVAL; > - > - if (args->lstio_sta_idsp != NULL && > - args->lstio_sta_count <= 0) > + if (!args->lstio_sta_resultp) > return -EINVAL; > > - LIBCFS_ALLOC(name, args->lstio_sta_nmlen + 1); > - if (name == NULL) > - return -ENOMEM; > - > - if (copy_from_user(name, args->lstio_sta_namep, > - args->lstio_sta_nmlen)) { > - LIBCFS_FREE(name, args->lstio_sta_nmlen + 1); > - return -EFAULT; > - } > + if (args->lstio_sta_idsp) { > + if (args->lstio_sta_count <= 0) > + return -EINVAL; > > - if (args->lstio_sta_idsp == NULL) { > - rc = lstcon_group_stat(name, args->lstio_sta_timeout, > - args->lstio_sta_resultp); > - } else { > rc = lstcon_nodes_stat(args->lstio_sta_count, > args->lstio_sta_idsp, > args->lstio_sta_timeout, > args->lstio_sta_resultp); > - } > + } else if (args->lstio_sta_namep) { > + if (args->lstio_sta_nmlen <= 0 || > + args->lstio_sta_nmlen > LST_NAME_SIZE) > + return -EINVAL; > + > + LIBCFS_ALLOC(name, args->lstio_sta_nmlen + 1); > + if (!name) > + return -ENOMEM; > > - LIBCFS_FREE(name, args->lstio_sta_nmlen + 1); > + rc = copy_from_user(name, args->lstio_sta_namep, > + args->lstio_sta_nmlen); > + if (!rc) > + rc = lstcon_group_stat(name, args->lstio_sta_timeout, > + args->lstio_sta_resultp); > + else > + rc = -EFAULT; > > + } else { > + rc = -EINVAL; > + } > + > + if (name) > + LIBCFS_FREE(name, args->lstio_sta_nmlen + 1); There is no bug fix here. This code was fine when it was merged into the kernel in 2013 so I have no idea how out of date the static checker warning is... The new code doesn't do unnecessary allocations so that's good but "name" should be declared in the block where it is used instead of at the start of the function. Btw, we assume that the user gives us a NUL terminated string for "name" so we should fix that bug as well. TODO: lustre: don't assume "name" is NUL terminated regards, dan carpenter From dan.carpenter at oracle.com Wed Dec 2 07:54:10 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 2 Dec 2015 10:54:10 +0300 Subject: [lustre-devel] [PATCH 03/40] staging: lustre: reflect down routes in /proc/sys/lnet/routes In-Reply-To: <1448062576-23757-4-git-send-email-jsimmons@infradead.org> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-4-git-send-email-jsimmons@infradead.org> Message-ID: <20151202075410.GJ18797@mwanda> On Fri, Nov 20, 2015 at 06:35:39PM -0500, James Simmons wrote: > From: Chris Horn > > We consider routes "down" if the router is down or the router > NI for the target network is down. This should be reflected > in the output of /proc/sys/lnet/routes > > Signed-off-by: Chris Horn > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3679 > Reviewed-on: http://review.whamcloud.com/7857 > Reviewed-by: Cory Spitz > Reviewed-by: Isaac Huang > Reviewed-by: Oleg Drokin > --- > .../staging/lustre/include/linux/lnet/lib-lnet.h | 13 ++++++++ > drivers/staging/lustre/lnet/lnet/lib-move.c | 32 ++++++++++---------- > drivers/staging/lustre/lnet/lnet/router_proc.c | 2 +- > 3 files changed, 30 insertions(+), 17 deletions(-) > > diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > index b61d504..09c6bfe 100644 > --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > @@ -64,6 +64,19 @@ extern lnet_t the_lnet; /* THE network */ > /** exclusive lock */ > #define LNET_LOCK_EX CFS_PERCPT_LOCK_EX > > +static inline int lnet_is_route_alive(lnet_route_t *route) > +{ > + /* gateway is down */ > + if (!route->lr_gateway->lp_alive) > + return 0; > + /* no NI status, assume it's alive */ > + if ((route->lr_gateway->lp_ping_feats & > + LNET_PING_FEAT_NI_STATUS) == 0) > + return 1; > + /* has NI status, check # down NIs */ > + return route->lr_downis == 0; > +} > + > static inline int lnet_is_wire_handle_none(lnet_handle_wire_t *wh) > { > return (wh->wh_interface_cookie == LNET_WIRE_HANDLE_COOKIE_NONE && > diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c > index 7a68382..c56de44 100644 > --- a/drivers/staging/lustre/lnet/lnet/lib-move.c > +++ b/drivers/staging/lustre/lnet/lnet/lib-move.c > @@ -1122,9 +1122,9 @@ static lnet_peer_t * > lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) > { > lnet_remotenet_t *rnet; > - lnet_route_t *rtr; > - lnet_route_t *rtr_best; > - lnet_route_t *rtr_last; > + lnet_route_t *route; > + lnet_route_t *best_route; > + lnet_route_t *last_route; Unrelated variable renaming. > struct lnet_peer *lp_best; > struct lnet_peer *lp; > int rc; > @@ -1137,13 +1137,12 @@ lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) > return NULL; > > lp_best = NULL; > - rtr_best = rtr_last = NULL; > - list_for_each_entry(rtr, &rnet->lrn_routes, lr_list) { > - lp = rtr->lr_gateway; > + best_route = NULL; > + last_route = NULL; Unrelated checkpatch fixes. > + list_for_each_entry(route, &rnet->lrn_routes, lr_list) { > + lp = route->lr_gateway; > > - if (!lp->lp_alive || /* gateway is down */ > - ((lp->lp_ping_feats & LNET_PING_FEAT_NI_STATUS) != 0 && > - rtr->lr_downis != 0)) /* NI to target is down */ > + if (!lnet_is_route_alive(route)) This section is related to the patch, we moved the check out into its own function. > continue; > > if (ni != NULL && lp->lp_ni != ni) > @@ -1153,28 +1152,29 @@ lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid) > return lp; > > if (lp_best == NULL) { > - rtr_best = rtr_last = rtr; > + best_route = route; > + last_route = route; More unrelated checkpatch fixes. > lp_best = lp; > continue; > } > > /* no protection on below fields, but it's harmless */ > - if (rtr_last->lr_seq - rtr->lr_seq < 0) > - rtr_last = rtr; > + if (last_route->lr_seq - route->lr_seq < 0) > + last_route = route; > > - rc = lnet_compare_routes(rtr, rtr_best); > + rc = lnet_compare_routes(route, best_route); > if (rc < 0) > continue; > > - rtr_best = rtr; > + best_route = route; > lp_best = lp; > } > > /* set sequence number on the best router to the latest sequence + 1 > * so we can round-robin all routers, it's race and inaccurate but > * harmless and functional */ > - if (rtr_best != NULL) > - rtr_best->lr_seq = rtr_last->lr_seq + 1; > + if (best_route) More checkpatch fixes. > + best_route->lr_seq = last_route->lr_seq + 1; > return lp_best; > } > > diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c > index 396c7c4..af7423f 100644 > --- a/drivers/staging/lustre/lnet/lnet/router_proc.c > +++ b/drivers/staging/lustre/lnet/lnet/router_proc.c > @@ -240,7 +240,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write, > unsigned int hops = route->lr_hops; > unsigned int priority = route->lr_priority; > lnet_nid_t nid = route->lr_gateway->lp_nid; > - int alive = route->lr_gateway->lp_alive; > + int alive = lnet_is_route_alive(route); This line is the bugfix. I know that people hate breaking patches up into reviewable patches but this is a one line fix which is hidden behind 30 lines of unrelated changes. It makes it very hard to follow what is going on. I have scripts to review checkpatch fixes basically automatically so it really really helps me when people do one thing per patch. regards, dan carpenter From dan.carpenter at oracle.com Wed Dec 2 09:23:50 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 2 Dec 2015 12:23:50 +0300 Subject: [lustre-devel] [PATCH 11/40] staging: lustre: DLC Feature dynamic net config In-Reply-To: <1448062576-23757-12-git-send-email-jsimmons@infradead.org> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-12-git-send-email-jsimmons@infradead.org> Message-ID: <20151202092349.GK18797@mwanda> On Fri, Nov 20, 2015 at 06:35:47PM -0500, James Simmons wrote: > + > + return 0; > > failed4: > - lnet_ping_target_fini(); > - failed3: > the_lnet.ln_refcount = 0; > + lnet_ping_md_unlink(pinfo, &md_handle); > + lnet_ping_info_free(pinfo); > + failed3: > lnet_acceptor_stop(); > + rc = LNetEQFree(the_lnet.ln_ping_target_eq); > + LASSERT(rc == 0); ^^^^^^^^^^^^^^^^ > failed2: > lnet_destroy_routes(); > lnet_shutdown_lndnis(); > @@ -1263,8 +1609,12 @@ LNetNIInit(lnet_pid_t requested_pid) > lnet_unprepare(); > failed0: > LASSERT(rc < 0); ^^^^^^^^^^^^^^^ These asserts contradict each other. But mostly please remove all the GW-BASIC style numbered labeled names from this patch. You wouldn't name your variables "int var1, var2, var3" so for label names you should give them meaningful names as well. Don't name them after the goto location, name them after the label location to say the first thing that the label does. err_fini: err_acceptor_stop: err_destroy_routes: err_empty_list: regards, dan carpenter From dan.carpenter at oracle.com Wed Dec 2 09:48:43 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 2 Dec 2015 12:48:43 +0300 Subject: [lustre-devel] [PATCH 12/40] staging: lustre: Dynamic LNet Configuration (DLC) IOCTL changes In-Reply-To: <1448062576-23757-13-git-send-email-jsimmons@infradead.org> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-13-git-send-email-jsimmons@infradead.org> Message-ID: <20151202094843.GL18797@mwanda> On Fri, Nov 20, 2015 at 06:35:48PM -0500, James Simmons wrote: > +int libcfs_ioctl_getdata_len(const struct libcfs_ioctl_hdr __user *arg, > + __u32 *len) > +{ > + struct libcfs_ioctl_hdr hdr; > > - orig_len = hdr->ioc_len; > - if (copy_from_user(buf, arg, hdr->ioc_len)) > + if (copy_from_user(&hdr, arg, sizeof(hdr))) > return -EFAULT; > - if (orig_len != data->ioc_len) > - return -EINVAL; This check was actually important. I don't see where it was moved to so it looks like this patch introduces a serious information leak. > > - if (libcfs_ioctl_is_invalid(data)) { > - CERROR("PORTALS: ioctl not correctly formatted\n"); > + if (hdr.ioc_version != LIBCFS_IOCTL_VERSION) { > + CERROR("LNET: version mismatch expected %#x, got %#x\n", > + LIBCFS_IOCTL_VERSION, hdr.ioc_version); > return -EINVAL; > } > > - if (data->ioc_inllen1) > - data->ioc_inlbuf1 = &data->ioc_bulk[0]; > + *len = hdr.ioc_len; > > - if (data->ioc_inllen2) > - data->ioc_inlbuf2 = &data->ioc_bulk[0] + > - cfs_size_round(data->ioc_inllen1); > + return 0; > +} > > +int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr *buf, __u32 buf_len, > + const void __user *arg) > +{ > + if (copy_from_user(buf, arg, buf_len)) > + return -EFAULT; > return 0; > } Don't introduce this wrapper. Abstraction layers just make the code harder to read and obscures bugs. Also the caller changes -EFAULT to -EINVAL so right away it starts to be buggy. > > diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c > index 75247e9..5348699 100644 > --- a/drivers/staging/lustre/lustre/libcfs/module.c > +++ b/drivers/staging/lustre/lustre/libcfs/module.c > @@ -54,6 +54,8 @@ > > # define DEBUG_SUBSYSTEM S_LNET > > +#define LIBCFS_MAX_IOCTL_BUF_LEN 2048 > + > #include "../../include/linux/libcfs/libcfs.h" > #include > > @@ -241,11 +243,21 @@ int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand) > } > EXPORT_SYMBOL(libcfs_deregister_ioctl); > > -static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd, > - void *arg, struct libcfs_ioctl_data *data) > +static int libcfs_ioctl_handle(struct cfs_psdev_file *pfile, unsigned long cmd, > + void *arg, struct libcfs_ioctl_hdr *hdr) > { > + struct libcfs_ioctl_data *data = NULL; > int err = -EINVAL; > > + if ((cmd <= IOC_LIBCFS_LNETST) || > + (cmd >= IOC_LIBCFS_REGISTER_MYNID)) { > + data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr); > + err = libcfs_ioctl_data_adjust(data); > + if (err != 0) { Generally, remove pointless double negatives like this. It should be just "if (err) " instead of "if (err != 0 != 0 != 0 != 0) " or whatever. > + return err; > + } > + } > + > switch (cmd) { > case IOC_LIBCFS_CLEAR_DEBUG: > libcfs_debug_clear_buffer(); > @@ -280,11 +292,11 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd, > err = -EINVAL; > down_read(&ioctl_list_sem); > list_for_each_entry(hand, &ioctl_list, item) { > - err = hand->handle_ioctl(cmd, data); > + err = hand->handle_ioctl(cmd, hdr); > if (err != -EINVAL) { > if (err == 0) > err = libcfs_ioctl_popdata(arg, > - data, sizeof(*data)); > + hdr, hdr->ioc_len); This variable has not been verified since the user wrote to it last so here is the information leak. regards, dan carpenter From dan.carpenter at oracle.com Wed Dec 2 11:20:55 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 2 Dec 2015 14:20:55 +0300 Subject: [lustre-devel] [PATCH 13/40] staging: lustre: Dynamic LNet Configuration (DLC) show command In-Reply-To: <1448062576-23757-14-git-send-email-jsimmons@infradead.org> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-14-git-send-email-jsimmons@infradead.org> Message-ID: <20151202112055.GM18797@mwanda> On Fri, Nov 20, 2015 at 06:35:49PM -0500, James Simmons wrote: > From: Amir Shehata > > This is the fifth patch of a set of patches that enables DLC. > > This patch adds the new structures which will be used > in the IOCTL communication. It also added a set of > show operations to show buffers, networks, statistics > and peer information. > > Signed-off-by: Amir Shehata > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-2456 > Change-Id: I96e5cb3dcf07289c6cd1deb46f4acb3c263ae21e > Reviewed-on: http://review.whamcloud.com/8022 > Reviewed-by: John L. Hammond > Reviewed-by: Doug Oucharek > Reviewed-by: James Simmons > Reviewed-by: Oleg Drokin > --- > .../lustre/include/linux/libcfs/libcfs_ioctl.h | 44 +++++++- > .../staging/lustre/include/linux/lnet/lib-dlc.h | 118 ++++++++++++++++++++ > .../staging/lustre/include/linux/lnet/lib-lnet.h | 5 + > drivers/staging/lustre/lnet/lnet/api-ni.c | 47 +++++++- > drivers/staging/lustre/lnet/lnet/module.c | 4 + > drivers/staging/lustre/lnet/lnet/peer.c | 61 ++++++++++ > .../lustre/lustre/libcfs/linux/linux-module.c | 3 +- > drivers/staging/lustre/lustre/libcfs/module.c | 15 ++- > 8 files changed, 282 insertions(+), 15 deletions(-) > create mode 100644 drivers/staging/lustre/include/linux/lnet/lib-dlc.h > > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h > index e14788c..f24330d 100644 > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h > @@ -41,7 +41,8 @@ > #ifndef __LIBCFS_IOCTL_H__ > #define __LIBCFS_IOCTL_H__ > > -#define LIBCFS_IOCTL_VERSION 0x0001000a > +#define LIBCFS_IOCTL_VERSION 0x0001000a > +#define LIBCFS_IOCTL_VERSION2 0x0001000b > > struct libcfs_ioctl_hdr { > __u32 ioc_len; > @@ -87,6 +88,13 @@ do { \ > data.ioc_hdr.ioc_len = sizeof(data); \ > } while (0) > > +#define LIBCFS_IOC_INIT_V2(data, hdr) \ > +do { \ > + memset(&(data), 0, sizeof(data)); \ > + (data).hdr.ioc_version = LIBCFS_IOCTL_VERSION2; \ > + (data).hdr.ioc_len = sizeof(data); \ > +} while (0) > + Do we really need this? > struct libcfs_ioctl_handler { > struct list_head item; > int (*handle_ioctl)(unsigned int cmd, struct libcfs_ioctl_hdr *hdr); > @@ -112,9 +120,6 @@ struct libcfs_ioctl_handler { > /* lnet ioctls */ > #define IOC_LIBCFS_GET_NI _IOWR('e', 50, long) > #define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, long) > -#define IOC_LIBCFS_ADD_ROUTE _IOWR('e', 52, long) > -#define IOC_LIBCFS_DEL_ROUTE _IOWR('e', 53, long) > -#define IOC_LIBCFS_GET_ROUTE _IOWR('e', 54, long) > #define IOC_LIBCFS_NOTIFY_ROUTER _IOWR('e', 55, long) > #define IOC_LIBCFS_UNCONFIGURE _IOWR('e', 56, long) > #define IOC_LIBCFS_PORTALS_COMPATIBILITY _IOWR('e', 57, long) > @@ -137,7 +142,36 @@ struct libcfs_ioctl_handler { > #define IOC_LIBCFS_DEL_INTERFACE _IOWR('e', 79, long) > #define IOC_LIBCFS_GET_INTERFACE _IOWR('e', 80, long) > > -#define IOC_LIBCFS_MAX_NR 80 > +/* > + * DLC Specific IOCTL numbers. > + * In order to maintain backward compatibility with any possible external > + * tools which might be accessing the IOCTL numbers, a new group of IOCTL > + * number have been allocated. > + */ > +#define IOCTL_CONFIG_SIZE struct lnet_ioctl_config_data > +#define IOC_LIBCFS_ADD_ROUTE _IOWR(IOC_LIBCFS_TYPE, 81, \ > + IOCTL_CONFIG_SIZE) > +#define IOC_LIBCFS_DEL_ROUTE _IOWR(IOC_LIBCFS_TYPE, 82, \ > + IOCTL_CONFIG_SIZE) > +#define IOC_LIBCFS_GET_ROUTE _IOWR(IOC_LIBCFS_TYPE, 83, \ > + IOCTL_CONFIG_SIZE) > +#define IOC_LIBCFS_ADD_NET _IOWR(IOC_LIBCFS_TYPE, 84, \ > + IOCTL_CONFIG_SIZE) > +#define IOC_LIBCFS_DEL_NET _IOWR(IOC_LIBCFS_TYPE, 85, \ > + IOCTL_CONFIG_SIZE) > +#define IOC_LIBCFS_GET_NET _IOWR(IOC_LIBCFS_TYPE, 86, \ > + IOCTL_CONFIG_SIZE) > +#define IOC_LIBCFS_CONFIG_RTR _IOWR(IOC_LIBCFS_TYPE, 87, \ > + IOCTL_CONFIG_SIZE) > +#define IOC_LIBCFS_ADD_BUF _IOWR(IOC_LIBCFS_TYPE, 88, \ > + IOCTL_CONFIG_SIZE) > +#define IOC_LIBCFS_GET_BUF _IOWR(IOC_LIBCFS_TYPE, 89, \ > + IOCTL_CONFIG_SIZE) > +#define IOC_LIBCFS_GET_PEER_INFO _IOWR(IOC_LIBCFS_TYPE, 90, \ > + IOCTL_CONFIG_SIZE) > +#define IOC_LIBCFS_GET_LNET_STATS _IOWR(IOC_LIBCFS_TYPE, 91, \ > + IOCTL_CONFIG_SIZE) > +#define IOC_LIBCFS_MAX_NR 91 Do it like this: #define IOC_LIBCFS_DEL_ROUTE _IOWR(IOC_LIBCFS_TYPE, 82, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_GET_ROUTE _IOWR(IOC_LIBCFS_TYPE, 83, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_ADD_NET _IOWR(IOC_LIBCFS_TYPE, 84, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_DEL_NET _IOWR(IOC_LIBCFS_TYPE, 85, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_GET_NET _IOWR(IOC_LIBCFS_TYPE, 86, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_CONFIG_RTR _IOWR(IOC_LIBCFS_TYPE, 87, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_ADD_BUF _IOWR(IOC_LIBCFS_TYPE, 88, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_GET_BUF _IOWR(IOC_LIBCFS_TYPE, 89, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_GET_PEER_INFO _IOWR(IOC_LIBCFS_TYPE, 90, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_GET_LNET_STATS _IOWR(IOC_LIBCFS_TYPE, 91, IOCTL_CONFIG_SIZE) #define IOC_LIBCFS_MAX_NR 91 > > static inline int libcfs_ioctl_packlen(struct libcfs_ioctl_data *data) > { > diff --git a/drivers/staging/lustre/include/linux/lnet/lib-dlc.h b/drivers/staging/lustre/include/linux/lnet/lib-dlc.h > new file mode 100644 > index 0000000..b6a2e91 > --- /dev/null > +++ b/drivers/staging/lustre/include/linux/lnet/lib-dlc.h > @@ -0,0 +1,118 @@ > +/* > + * GPL HEADER START > + * > + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 only, > + * as published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, but > + * WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * General Public License version 2 for more details (a copy is included > + * in the LICENSE file that accompanied this code). > + * > + * You should have received a copy of the GNU General Public License > + * version 2 along with this program; If not, see > + * http://www.gnu.org/licenses/gpl-2.0.html > + * > + * GPL HEADER END > + * > + * Contributers: > + * Amir Shehata > + */ > + > +#ifndef LNET_DLC_H > +#define LNET_DLC_H > + > +#include "../libcfs/libcfs_ioctl.h" > +#include "types.h" > + > +#define MAX_NUM_SHOW_ENTRIES 32 > +#define LNET_MAX_STR_LEN 128 > +#define LNET_MAX_SHOW_NUM_CPT 128 > + > +struct lnet_ioctl_net_config { > + char ni_interfaces[LNET_MAX_INTERFACES][LNET_MAX_STR_LEN]; > + __u32 ni_status; > + __u32 ni_cpts[LNET_MAX_SHOW_NUM_CPT]; > +}; > + > +#define LNET_TINY_BUF_IDX 0 > +#define LNET_SMALL_BUF_IDX 1 > +#define LNET_LARGE_BUF_IDX 2 > + > +/* # different router buffer pools */ > +#define LNET_NRBPOOLS (LNET_LARGE_BUF_IDX + 1) > + > +struct lnet_ioctl_pool_cfg { > + struct { > + __u32 pl_npages; > + __u32 pl_nbuffers; > + __u32 pl_credits; > + __u32 pl_mincredits; > + } pl_pools[LNET_NRBPOOLS]; > + __u32 pl_routing; > +}; > + > +struct lnet_ioctl_config_data { > + struct libcfs_ioctl_hdr cfg_hdr; > + > + __u32 cfg_net; > + __u32 cfg_count; > + __u64 cfg_nid; > + __u32 cfg_ncpts; > + > + union { > + struct { > + __u32 rtr_hop; > + __u32 rtr_priority; > + __u32 rtr_flags; > + } cfg_route; > + struct { > + char net_intf[LNET_MAX_STR_LEN]; > + __s32 net_peer_timeout; > + __s32 net_peer_tx_credits; > + __s32 net_peer_rtr_credits; > + __s32 net_max_tx_credits; > + __u32 net_cksum_algo; > + __u32 net_pad; > + } cfg_net; > + struct { > + __u32 buf_enable; > + __s32 buf_tiny; > + __s32 buf_small; > + __s32 buf_large; > + } cfg_buffers; > + } cfg_config_u; > + > + char cfg_bulk[0]; > +}; > + > +struct lnet_ioctl_peer { > + struct libcfs_ioctl_hdr pr_hdr; > + __u32 pr_count; > + __u32 pr_pad; > + __u64 pr_nid; > + > + union { > + struct { > + char cr_aliveness[LNET_MAX_STR_LEN]; > + __u32 cr_refcount; > + __u32 cr_ni_peer_tx_credits; > + __u32 cr_peer_tx_credits; > + __u32 cr_peer_rtr_credits; > + __u32 cr_peer_min_rtr_credits; > + __u32 cr_peer_tx_qnob; > + __u32 cr_ncpt; > + } pr_peer_credits; > + } pr_lnd_u; > +}; > + > +struct lnet_ioctl_lnet_stats { > + struct libcfs_ioctl_hdr st_hdr; > + struct lnet_counters st_cntrs; > +}; > + > +#endif /* LNET_DLC_H */ > diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > index 94d0dc5..f2874e0 100644 > --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > @@ -694,6 +694,11 @@ void lnet_peer_tables_cleanup(lnet_ni_t *ni); > void lnet_peer_tables_destroy(void); > int lnet_peer_tables_create(void); > void lnet_debug_peer(lnet_nid_t nid); > +int lnet_get_peers(int count, __u64 *nid, char *alivness, > + int *ncpt, int *refcount, > + int *ni_peer_tx_credits, int *peer_tx_credits, > + int *peer_rtr_credits, int *peer_min_rtr_credtis, > + int *peer_tx_qnob); > > static inline void > lnet_peer_set_alive(lnet_peer_t *lp) > diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c > index 9661f6a..165345c 100644 > --- a/drivers/staging/lustre/lnet/lnet/api-ni.c > +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c > @@ -39,6 +39,7 @@ > #include > > #include "../../include/linux/lnet/lib-lnet.h" > +#include "../../include/linux/lnet/lib-dlc.h" > > #define D_LNI D_CONSOLE > > @@ -1741,6 +1742,7 @@ int > LNetCtl(unsigned int cmd, void *arg) > { > struct libcfs_ioctl_data *data = arg; > + struct lnet_ioctl_config_data *config; > lnet_process_id_t id = {0}; > lnet_ni_t *ni; > int rc; > @@ -1765,16 +1767,51 @@ LNetCtl(unsigned int cmd, void *arg) > return (rc != 0) ? rc : lnet_check_routes(); > > case IOC_LIBCFS_DEL_ROUTE: > + config = arg; I think you need to verify: if (config->cfg_hdr->ioc_len < sizeof(*config)) return -EINVAL; > mutex_lock(&the_lnet.ln_api_mutex); > - rc = lnet_del_route(data->ioc_net, data->ioc_nid); > + rc = lnet_del_route(config->cfg_net, config->cfg_nid); > mutex_unlock(&the_lnet.ln_api_mutex); > return rc; > > case IOC_LIBCFS_GET_ROUTE: > - return lnet_get_route(data->ioc_count, > - &data->ioc_net, &data->ioc_count, > - &data->ioc_nid, &data->ioc_flags, > - &data->ioc_priority); > + config = arg; Verify ioc_len. > + return lnet_get_route(config->cfg_count, > + &config->cfg_net, > + &config->cfg_config_u.cfg_route.rtr_hop, > + &config->cfg_nid, > + &config->cfg_config_u.cfg_route.rtr_flags, > + &config->cfg_config_u.cfg_route. > + rtr_priority); > + > + case IOC_LIBCFS_ADD_NET: > + return 0; > + > + case IOC_LIBCFS_DEL_NET: > + return 0; > + > + case IOC_LIBCFS_GET_NET: > + return 0; > + > + case IOC_LIBCFS_GET_LNET_STATS: > + { Put this curly brace on the line before. > + struct lnet_ioctl_lnet_stats *lnet_stats = arg; > + Verify ioc_len is large enough. > + lnet_counters_get(&lnet_stats->st_cntrs); > + return 0; > + } > + > + case IOC_LIBCFS_CONFIG_RTR: > + return 0; > + > + case IOC_LIBCFS_ADD_BUF: > + return 0; > + > + case IOC_LIBCFS_GET_BUF: > + return 0; > + > + case IOC_LIBCFS_GET_PEER_INFO: > + return 0; > + > case IOC_LIBCFS_NOTIFY_ROUTER: > secs_passed = (ktime_get_real_seconds() - data->ioc_u64[0]); > return lnet_notify(NULL, data->ioc_nid, data->ioc_flags, > diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c > index 0afdad0..ffc5700 100644 > --- a/drivers/staging/lustre/lnet/lnet/module.c > +++ b/drivers/staging/lustre/lnet/lnet/module.c > @@ -36,6 +36,7 @@ > > #define DEBUG_SUBSYSTEM S_LNET > #include "../../include/linux/lnet/lib-lnet.h" > +#include "../../include/linux/lnet/lib-dlc.h" > > static int config_on_load; > module_param(config_on_load, int, 0444); > @@ -95,6 +96,9 @@ lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) > case IOC_LIBCFS_UNCONFIGURE: > return lnet_unconfigure(); > > + case IOC_LIBCFS_ADD_NET: > + return LNetCtl(cmd, hdr); > + > default: > /* Passing LNET_PID_ANY only gives me a ref if the net is up > * already; I'll need it to ensure the net can't go down while > diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c > index bb5a0bb..1402e27 100644 > --- a/drivers/staging/lustre/lnet/lnet/peer.c > +++ b/drivers/staging/lustre/lnet/lnet/peer.c > @@ -39,6 +39,7 @@ > #define DEBUG_SUBSYSTEM S_LNET > > #include "../../include/linux/lnet/lib-lnet.h" > +#include "../../include/linux/lnet/lib-dlc.h" > > int > lnet_peer_tables_create(void) > @@ -392,3 +393,63 @@ lnet_debug_peer(lnet_nid_t nid) > > lnet_net_unlock(cpt); > } > + > +int lnet_get_peers(int count, __u64 *nid, char *aliveness, > + int *ncpt, int *refcount, > + int *ni_peer_tx_credits, int *peer_tx_credits, > + int *peer_rtr_credits, int *peer_min_rtr_credits, > + int *peer_tx_qnob) > +{ > + struct lnet_peer_table *peer_table; > + lnet_peer_t *lp; > + int j; > + int lncpt, found = 0; > + > + /* get the number of CPTs */ > + lncpt = cfs_percpt_number(the_lnet.ln_peer_tables); > + > + /* > + * if the cpt number to be examined is >= the number of cpts in > + * the system then indicate that there are no more cpts to examin > + */ > + if (*ncpt > lncpt) > + return -1; Add some documentation to the start of the function to say what -1 means here. Or reading below it looks like normal error codes were intended. > + > + /* get the current table */ > + peer_table = the_lnet.ln_peer_tables[*ncpt]; > + /* if the ptable is NULL then there are no more cpts to examine */ > + if (!peer_table) > + return -1; > + > + lnet_net_lock(*ncpt); > + > + for (j = 0; j < LNET_PEER_HASH_SIZE && !found; j++) { > + struct list_head *peers = &peer_table->pt_hash[j]; > + > + list_for_each_entry(lp, peers, lp_hashlist) { > + if (count-- > 0) > + continue; > + > + snprintf(aliveness, LNET_MAX_STR_LEN, "NA"); > + if (lnet_isrouter(lp) || > + lnet_peer_aliveness_enabled(lp)) > + snprintf(aliveness, LNET_MAX_STR_LEN, > + lp->lp_alive ? "up" : "down"); > + > + *nid = lp->lp_nid; > + *refcount = lp->lp_refcount; > + *ni_peer_tx_credits = lp->lp_ni->ni_peertxcredits; > + *peer_tx_credits = lp->lp_txcredits; > + *peer_rtr_credits = lp->lp_rtrcredits; > + *peer_min_rtr_credits = lp->lp_mintxcredits; > + *peer_tx_qnob = lp->lp_txqnob; > + > + found = 1; > + } > + } > + lnet_net_unlock(*ncpt); > + > + *ncpt = lncpt; > + > + return found ? 0 : -ENOENT; > +} regards, dan carpenter From dan.carpenter at oracle.com Wed Dec 2 11:27:33 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 2 Dec 2015 14:27:33 +0300 Subject: [lustre-devel] [PATCH 14/40] staging: lustre: fix crash due to NULL networks string In-Reply-To: <1448062576-23757-15-git-send-email-jsimmons@infradead.org> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-15-git-send-email-jsimmons@infradead.org> Message-ID: <20151202112733.GN18797@mwanda> This feels like we are fixing a bug introduce in PATCH 11 when we removed a NULL check. Don't introduce bugs and then fix them in the same patchset; the fix has to be folded into the original patch. regards, dan carpenter From dan.carpenter at oracle.com Wed Dec 2 12:00:56 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 2 Dec 2015 15:00:56 +0300 Subject: [lustre-devel] [PATCH 13/40] staging: lustre: Dynamic LNet Configuration (DLC) show command In-Reply-To: <1448062576-23757-14-git-send-email-jsimmons@infradead.org> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-14-git-send-email-jsimmons@infradead.org> Message-ID: <20151202120056.GO18797@mwanda> On Fri, Nov 20, 2015 at 06:35:49PM -0500, James Simmons wrote: > +int lnet_get_peers(int count, __u64 *nid, char *aliveness, > + int *ncpt, int *refcount, > + int *ni_peer_tx_credits, int *peer_tx_credits, > + int *peer_rtr_credits, int *peer_min_rtr_credits, > + int *peer_tx_qnob) > +{ > + struct lnet_peer_table *peer_table; > + lnet_peer_t *lp; > + int j; > + int lncpt, found = 0; > + > + /* get the number of CPTs */ > + lncpt = cfs_percpt_number(the_lnet.ln_peer_tables); > + > + /* > + * if the cpt number to be examined is >= the number of cpts in > + * the system then indicate that there are no more cpts to examin > + */ > + if (*ncpt > lncpt) > + return -1; The comment is correct but the code is off by one. if (*ncpt >= lncpt) return -EINVAL; Also not a correct error code. I assume that you will review the whole patchset again and fix all the -1 returns, of course. regards, dan carpenter From dan.carpenter at oracle.com Wed Dec 2 12:11:54 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 2 Dec 2015 15:11:54 +0300 Subject: [lustre-devel] [PATCH 15/40] staging: lustre: DLC user/kernel space glue code In-Reply-To: <1448062576-23757-16-git-send-email-jsimmons@infradead.org> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-16-git-send-email-jsimmons@infradead.org> Message-ID: <20151202121154.GP18797@mwanda> On Fri, Nov 20, 2015 at 06:35:51PM -0500, James Simmons wrote: > From: Amir Shehata > > This is the sixth patch of a set of patches that enables DLC. > > This patch enables the user space to call into the kernel space > DLC code. Added handlers in the LNetCtl function to call > the new functions added for Dynamic Lnet Configuration > > Signed-off-by: Amir Shehata > ntel-bug-id: https://jira.hpdd.intel.com/browse/LU-2456 > Reviewed-on: http://review.whamcloud.com/8023 > Reviewed-by: James Simmons > Reviewed-by: Doug Oucharek > Reviewed-by: John L. Hammond > Reviewed-by: Oleg Drokin > --- > .../staging/lustre/include/linux/lnet/lib-lnet.h | 22 ++- > .../staging/lustre/include/linux/lnet/lib-types.h | 8 + > drivers/staging/lustre/lnet/lnet/api-ni.c | 172 ++++++++++++++++++-- > drivers/staging/lustre/lnet/lnet/module.c | 53 ++++++- > drivers/staging/lustre/lnet/lnet/peer.c | 34 ++-- > drivers/staging/lustre/lnet/lnet/router.c | 71 +++++++-- > 6 files changed, 307 insertions(+), 53 deletions(-) > > diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > index f2874e0..63919dd 100644 > --- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > +++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h > @@ -39,6 +39,7 @@ > #include "api.h" > #include "lnet.h" > #include "lib-types.h" > +#include "lib-dlc.h" > > extern lnet_t the_lnet; /* THE network */ > > @@ -456,6 +457,12 @@ int lnet_del_route(__u32 net, lnet_nid_t gw_nid); > void lnet_destroy_routes(void); > int lnet_get_route(int idx, __u32 *net, __u32 *hops, > lnet_nid_t *gateway, __u32 *alive, __u32 *priority); > +int lnet_get_net_config(int idx, __u32 *cpt_count, __u64 *nid, > + int *peer_timeout, int *peer_tx_credits, > + int *peer_rtr_cr, int *max_tx_credits, > + struct lnet_ioctl_net_config *net_config); > +int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg); > + > void lnet_router_debugfs_init(void); > void lnet_router_debugfs_fini(void); > int lnet_rtrpools_alloc(int im_a_router); > @@ -465,6 +472,10 @@ int lnet_rtrpools_enable(void); > void lnet_rtrpools_disable(void); > void lnet_rtrpools_free(int keep_pools); > lnet_remotenet_t *lnet_find_net_locked(__u32 net); > +int lnet_dyn_add_ni(lnet_pid_t requested_pid, char *nets, > + __s32 peer_timeout, __s32 peer_cr, __s32 peer_buf_cr, > + __s32 credits); > +int lnet_dyn_del_ni(__u32 net); > > int lnet_islocalnid(lnet_nid_t nid); > int lnet_islocalnet(__u32 net); > @@ -694,11 +705,12 @@ void lnet_peer_tables_cleanup(lnet_ni_t *ni); > void lnet_peer_tables_destroy(void); > int lnet_peer_tables_create(void); > void lnet_debug_peer(lnet_nid_t nid); > -int lnet_get_peers(int count, __u64 *nid, char *alivness, > - int *ncpt, int *refcount, > - int *ni_peer_tx_credits, int *peer_tx_credits, > - int *peer_rtr_credits, int *peer_min_rtr_credtis, > - int *peer_tx_qnob); > +int lnet_get_peer_info(__u32 peer_index, __u64 *nid, > + char alivness[LNET_MAX_STR_LEN], > + __u32 *cpt_iter, __u32 *refcount, > + __u32 *ni_peer_tx_credits, __u32 *peer_tx_credits, > + __u32 *peer_rtr_credits, __u32 *peer_min_rtr_credtis, > + __u32 *peer_tx_qnob); > > static inline void > lnet_peer_set_alive(lnet_peer_t *lp) > diff --git a/drivers/staging/lustre/include/linux/lnet/lib-types.h b/drivers/staging/lustre/include/linux/lnet/lib-types.h > index e7585b9..3282782 100644 > --- a/drivers/staging/lustre/include/linux/lnet/lib-types.h > +++ b/drivers/staging/lustre/include/linux/lnet/lib-types.h > @@ -611,6 +611,14 @@ typedef struct { > /* test protocol compatibility flags */ > int ln_testprotocompat; > > + /* > + * 0 - load the NIs from the mod params > + * 1 - do not load the NIs from the mod params > + * Reverse logic to ensure that other calls to LNetNIInit > + * need no change > + */ > + bool ln_nis_from_mod_params; > + > } lnet_t; > > #endif > diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c > index cc87900..125d018 100644 > --- a/drivers/staging/lustre/lnet/lnet/api-ni.c > +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c > @@ -1542,7 +1542,9 @@ LNetNIInit(lnet_pid_t requested_pid) > if (rc != 0) > goto failed0; > > - rc = lnet_parse_networks(&net_head, lnet_get_networks()); > + rc = lnet_parse_networks(&net_head, > + !the_lnet.ln_nis_from_mod_params ? > + lnet_get_networks() : ""); > if (rc < 0) > goto failed1; > > @@ -1657,6 +1659,93 @@ LNetNIFini(void) > } > EXPORT_SYMBOL(LNetNIFini); > > +/** > + * Grabs the ni data from the ni structure and fills the out > + * parameters > + * > + * \param[in] ni network interface structure > + * \param[out] cpt_count the number of cpts the ni is on > + * \param[out] nid Network Interface ID > + * \param[out] peer_timeout NI peer timeout > + * \param[out] peer_tx_crdits NI peer transmit credits > + * \param[out] peer_rtr_credits NI peer router credits > + * \param[out] max_tx_credits NI max transmit credit > + * \param[out] net_config Network configuration > + */ > +static void > +lnet_fill_ni_info(struct lnet_ni *ni, __u32 *cpt_count, __u64 *nid, > + int *peer_timeout, int *peer_tx_credits, > + int *peer_rtr_credits, int *max_tx_credits, > + struct lnet_ioctl_net_config *net_config) > +{ > + int i; > + > + if (!ni) > + return; > + > + if (!net_config) > + return; > + > + CLASSERT(ARRAY_SIZE(ni->ni_interfaces) == > + ARRAY_SIZE(net_config->ni_interfaces)); The kernel has a macro for this BUILD_BUG_ON(). > + > + if (ni->ni_interfaces[0]) { Couldn't we just break at the first NULL? > + for (i = 0; i < ARRAY_SIZE(ni->ni_interfaces); i++) { > + if (ni->ni_interfaces[i]) { > + strncpy(net_config->ni_interfaces[i], > + ni->ni_interfaces[i], > + sizeof(net_config->ni_interfaces[i])); > + } > + } > + } > + for (i = 0; i < ARRAY_SIZE(ni->ni_interfaces); i++) { if (!ni->ni_interfaces[i]) break; strncpy(net_config->ni_interfaces[i], ni->ni_interfaces[i], sizeof(net_config->ni_interfaces[i])); } > + *nid = ni->ni_nid; > + *peer_timeout = ni->ni_peertimeout; > + *peer_tx_credits = ni->ni_peertxcredits; > + *peer_rtr_credits = ni->ni_peerrtrcredits; > + *max_tx_credits = ni->ni_maxtxcredits; > + > + net_config->ni_status = ni->ni_status->ns_status; > + > + for (i = 0; > + ni->ni_cpts && i < ni->ni_ncpts && > + i < LNET_MAX_SHOW_NUM_CPT; This is really sort of a crap condition and either you are doing it to please an inferior static checker (don't write nonsense code to please the static checker) or there is something very confused about your code and you should fix it elsewhere. The loop here should be: for (i = 0; i < ni->ni_ncpts; i++) net_config->ni_cpts[i] = ni->ni_cpts[i]; > + i++) > + net_config->ni_cpts[i] = ni->ni_cpts[i]; > + > + *cpt_count = ni->ni_ncpts; > +} > + > +int > +lnet_get_net_config(int idx, __u32 *cpt_count, __u64 *nid, int *peer_timeout, > + int *peer_tx_credits, int *peer_rtr_credits, > + int *max_tx_credits, > + struct lnet_ioctl_net_config *net_config) > +{ > + struct lnet_ni *ni; > + struct list_head *tmp; > + int cpt; > + int rc = -ENOENT; > + > + cpt = lnet_net_lock_current(); > + > + list_for_each(tmp, &the_lnet.ln_nis) { > + ni = list_entry(tmp, lnet_ni_t, ni_list); > + if (idx-- == 0) { > + rc = 0; > + lnet_ni_lock(ni); > + lnet_fill_ni_info(ni, cpt_count, nid, peer_timeout, > + peer_tx_credits, peer_rtr_credits, > + max_tx_credits, net_config); > + lnet_ni_unlock(ni); > + break; > + } > + } Write it something like this: i = 0; list_for_each(tmp, &the_lnet.ln_nis) { if (i++ != idx) continue; ni = list_entry(tmp, lnet_ni_t, ni_list); lnet_ni_lock(ni); lnet_fill_ni_info(ni, cpt_count, nid, peer_timeout, peer_tx_credits, peer_rtr_credits, max_tx_credits, net_config); lnet_ni_unlock(ni); rc = 0; break; } > + > + lnet_net_unlock(cpt); > + return rc; > +} > + > int > lnet_dyn_add_ni(lnet_pid_t requested_pid, char *nets, > __s32 peer_timeout, __s32 peer_cr, __s32 peer_buf_cr, > @@ -1757,9 +1846,13 @@ LNetCtl(unsigned int cmd, void *arg) > return lnet_fail_nid(data->ioc_nid, data->ioc_count); > > case IOC_LIBCFS_ADD_ROUTE: > + config = arg; Check ioc_len. > mutex_lock(&the_lnet.ln_api_mutex); > - rc = lnet_add_route(data->ioc_net, data->ioc_count, > - data->ioc_nid, data->ioc_priority); > + rc = lnet_add_route(config->cfg_net, > + config->cfg_config_u.cfg_route.rtr_hop, > + config->cfg_nid, > + config->cfg_config_u.cfg_route. > + rtr_priority); > mutex_unlock(&the_lnet.ln_api_mutex); > return (rc != 0) ? rc : lnet_check_routes(); > > @@ -1780,14 +1873,28 @@ LNetCtl(unsigned int cmd, void *arg) > &config->cfg_config_u.cfg_route. > rtr_priority); > > - case IOC_LIBCFS_ADD_NET: > - return 0; > - > - case IOC_LIBCFS_DEL_NET: > - return 0; > + case IOC_LIBCFS_GET_NET: { > + struct lnet_ioctl_net_config *net_config; > > - case IOC_LIBCFS_GET_NET: > - return 0; > + config = arg; Check ioc_len. > + net_config = (struct lnet_ioctl_net_config *) > + config->cfg_bulk; > + if (!config || !net_config) We already dereferenced "config" so it's a bit late to check for NULL. But that's an interesting question if we need to add NULL checks every where. I forget. Please check this and reply to the email thread. > + return -1; This is not a correct error code. return -EINVAL. > + > + return lnet_get_net_config(config->cfg_count, > + &config->cfg_ncpts, > + &config->cfg_nid, > + &config->cfg_config_u.cfg_net. > + net_peer_timeout, > + &config->cfg_config_u.cfg_net. > + net_peer_tx_credits, > + &config->cfg_config_u.cfg_net. > + net_peer_rtr_credits, > + &config->cfg_config_u.cfg_net. > + net_max_tx_credits, > + net_config); Breaking it up like this is nasty. return lnet_get_net_config( config->cfg_count, &config->cfg_ncpts, &config->cfg_nid, &config->cfg_config_u.cfg_net.net_peer_timeout, &config->cfg_config_u.cfg_net.net_peer_tx_credits, &config->cfg_config_u.cfg_net.net_peer_rtr_credits, &config->cfg_config_u.cfg_net.net_max_tx_credits, net_config); It violates checkpatch.pl rules, but don't write ugly code just to make a tool happy. > + } > > case IOC_LIBCFS_GET_LNET_STATS: > { > @@ -1798,16 +1905,51 @@ LNetCtl(unsigned int cmd, void *arg) > } > > case IOC_LIBCFS_CONFIG_RTR: > + config = arg; ioc_len. > + mutex_lock(&the_lnet.ln_api_mutex); > + if (config->cfg_config_u.cfg_buffers.buf_enable) { > + rc = lnet_rtrpools_enable(); > + mutex_unlock(&the_lnet.ln_api_mutex); > + return rc; > + } > + lnet_rtrpools_disable(); > + mutex_unlock(&the_lnet.ln_api_mutex); > return 0; > > case IOC_LIBCFS_ADD_BUF: > - return 0; > + config = arg; ioc_len. > + mutex_lock(&the_lnet.ln_api_mutex); > + rc = lnet_rtrpools_adjust(config->cfg_config_u.cfg_buffers. > + buf_tiny, > + config->cfg_config_u.cfg_buffers. > + buf_small, > + config->cfg_config_u.cfg_buffers. > + buf_large); Ugh. > + mutex_unlock(&the_lnet.ln_api_mutex); > + return rc; > > - case IOC_LIBCFS_GET_BUF: > - return 0; > + case IOC_LIBCFS_GET_BUF: { > + struct lnet_ioctl_pool_cfg *pool_cfg; > > - case IOC_LIBCFS_GET_PEER_INFO: > - return 0; > + config = arg; ioc_len. > + pool_cfg = (struct lnet_ioctl_pool_cfg *)config->cfg_bulk; > + return lnet_get_rtr_pool_cfg(config->cfg_count, pool_cfg); > + } > + > + case IOC_LIBCFS_GET_PEER_INFO: { > + struct lnet_ioctl_peer *peer_info = arg; ioc_len. > + > + return lnet_get_peer_info(peer_info->pr_count, > + &peer_info->pr_nid, > + peer_info->pr_lnd_u.pr_peer_credits.cr_aliveness, > + &peer_info->pr_lnd_u.pr_peer_credits.cr_ncpt, > + &peer_info->pr_lnd_u.pr_peer_credits.cr_refcount, > + &peer_info->pr_lnd_u.pr_peer_credits.cr_ni_peer_tx_credits, > + &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_credits, > + &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_rtr_credits, > + &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_min_rtr_credits, > + &peer_info->pr_lnd_u.pr_peer_credits.cr_peer_tx_qnob); > + } > > case IOC_LIBCFS_NOTIFY_ROUTER: > secs_passed = (ktime_get_real_seconds() - data->ioc_u64[0]); > diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c > index ffc5700..281315c 100644 > --- a/drivers/staging/lustre/lnet/lnet/module.c > +++ b/drivers/staging/lustre/lnet/lnet/module.c > @@ -84,20 +84,69 @@ lnet_unconfigure(void) > return (refcount == 0) ? 0 : -EBUSY; > } > > +int > +lnet_dyn_configure(struct libcfs_ioctl_hdr *hdr) > +{ > + struct lnet_ioctl_config_data *conf = > + (struct lnet_ioctl_config_data *)hdr; > + int rc; > + We never checked ioc_len before calling this function so it could oops if we read unmapped memory. > + mutex_lock(&lnet_config_mutex); > + if (the_lnet.ln_niinit_self) Flip this around: if (!the_lnet.ln_niinit_self) { rc = -EINVAL; goto unlock; } rc = lnet_dyn_add_ni(LUSTRE_SRV_LNET_PID, ... > + rc = lnet_dyn_add_ni(LUSTRE_SRV_LNET_PID, > + conf->cfg_config_u.cfg_net.net_intf, > + conf->cfg_config_u.cfg_net. > + net_peer_timeout, > + conf->cfg_config_u.cfg_net. > + net_peer_tx_credits, > + conf->cfg_config_u.cfg_net. > + net_peer_rtr_credits, > + conf->cfg_config_u.cfg_net. > + net_max_tx_credits); > + else > + rc = -EINVAL; > + mutex_unlock(&lnet_config_mutex); > + return rc; > +} > + > +int > +lnet_dyn_unconfigure(struct libcfs_ioctl_hdr *hdr) > +{ > + struct lnet_ioctl_config_data *conf = > + (struct lnet_ioctl_config_data *)hdr; > + int rc; > + > + mutex_lock(&lnet_config_mutex); > + if (the_lnet.ln_niinit_self) Always consistently do error handling instead of success handling. if (!the_lnet.ln_niinit_self) { rc = -EINVAL; goto unlock; } > + rc = lnet_dyn_del_ni(conf->cfg_net); > + else > + rc = -EINVAL; > + mutex_unlock(&lnet_config_mutex); > + > + return rc; > +} > + > static int > lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_hdr *hdr) > { > int rc; > > switch (cmd) { > - case IOC_LIBCFS_CONFIGURE: > + case IOC_LIBCFS_CONFIGURE: { > + struct libcfs_ioctl_data *data = > + (struct libcfs_ioctl_data *)hdr; ioc_len. > + the_lnet.ln_nis_from_mod_params = data->ioc_flags; > return lnet_configure(NULL); > + } > > case IOC_LIBCFS_UNCONFIGURE: > return lnet_unconfigure(); > > case IOC_LIBCFS_ADD_NET: > - return LNetCtl(cmd, hdr); > + return lnet_dyn_configure(hdr); > + > + case IOC_LIBCFS_DEL_NET: > + return lnet_dyn_unconfigure(hdr); ioc_len etc. > > default: > /* Passing LNET_PID_ANY only gives me a ref if the net is up > diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c > index 1402e27..3b71812 100644 > --- a/drivers/staging/lustre/lnet/lnet/peer.c > +++ b/drivers/staging/lustre/lnet/lnet/peer.c > @@ -394,16 +394,18 @@ lnet_debug_peer(lnet_nid_t nid) > lnet_net_unlock(cpt); > } > > -int lnet_get_peers(int count, __u64 *nid, char *aliveness, > - int *ncpt, int *refcount, > - int *ni_peer_tx_credits, int *peer_tx_credits, > - int *peer_rtr_credits, int *peer_min_rtr_credits, > - int *peer_tx_qnob) > +int > +lnet_get_peer_info(__u32 peer_index, __u64 *nid, > + char aliveness[LNET_MAX_STR_LEN], > + __u32 *cpt_iter, __u32 *refcount, > + __u32 *ni_peer_tx_credits, __u32 *peer_tx_credits, > + __u32 *peer_rtr_credits, __u32 *peer_min_rtr_credits, > + __u32 *peer_tx_qnob) > { > struct lnet_peer_table *peer_table; > lnet_peer_t *lp; > - int j; > - int lncpt, found = 0; > + bool found = false; Unrelated. > + int lncpt, j; > > /* get the number of CPTs */ > lncpt = cfs_percpt_number(the_lnet.ln_peer_tables); > @@ -412,22 +414,22 @@ int lnet_get_peers(int count, __u64 *nid, char *aliveness, > * if the cpt number to be examined is >= the number of cpts in > * the system then indicate that there are no more cpts to examin > */ > - if (*ncpt > lncpt) > - return -1; > + if (*cpt_iter > lncpt) > + return -ENOENT; Don't mix unrelated changes. > > /* get the current table */ > - peer_table = the_lnet.ln_peer_tables[*ncpt]; > + peer_table = the_lnet.ln_peer_tables[*cpt_iter]; > /* if the ptable is NULL then there are no more cpts to examine */ > if (!peer_table) > - return -1; > + return -ENOENT; > > - lnet_net_lock(*ncpt); > + lnet_net_lock(*cpt_iter); > > for (j = 0; j < LNET_PEER_HASH_SIZE && !found; j++) { > struct list_head *peers = &peer_table->pt_hash[j]; > > list_for_each_entry(lp, peers, lp_hashlist) { > - if (count-- > 0) > + if (peer_index-- > 0) > continue; > > snprintf(aliveness, LNET_MAX_STR_LEN, "NA"); > @@ -444,12 +446,12 @@ int lnet_get_peers(int count, __u64 *nid, char *aliveness, > *peer_min_rtr_credits = lp->lp_mintxcredits; > *peer_tx_qnob = lp->lp_txqnob; > > - found = 1; > + found = true; > } > } > - lnet_net_unlock(*ncpt); > + lnet_net_unlock(*cpt_iter); > > - *ncpt = lncpt; > + *cpt_iter = lncpt; > > return found ? 0 : -ENOENT; > } > diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c > index 749085f..17e6795 100644 > --- a/drivers/staging/lustre/lnet/lnet/router.c > +++ b/drivers/staging/lustre/lnet/lnet/router.c > @@ -541,6 +541,42 @@ lnet_destroy_routes(void) > lnet_del_route(LNET_NIDNET(LNET_NID_ANY), LNET_NID_ANY); > } > > +int lnet_get_rtr_pool_cfg(int idx, struct lnet_ioctl_pool_cfg *pool_cfg) > +{ > + int i, rc = -ENOENT, lidx, j; > + > + if (!the_lnet.ln_rtrpools) > + return rc; Use literals where ever possible. return -ENOENT; > + > + for (i = 0; i < LNET_NRBPOOLS; i++) { > + lnet_rtrbufpool_t *rbp; > + > + lnet_net_lock(LNET_LOCK_EX); > + lidx = idx; > + cfs_percpt_for_each(rbp, j, the_lnet.ln_rtrpools) { > + if (lidx-- == 0) { Flip this around so you're not smooshed against the right side of the screen. if (i++ != idx) continue; Don't modify the original parameter. That way you can use it again and also it makes the code easier to understand. > + rc = 0; Put the rc = 0 at the end next to the break. rc is used by the return keep them near together so that the code is easier to understand. > + pool_cfg->pl_pools[i].pl_npages = > + rbp[i].rbp_npages; > + pool_cfg->pl_pools[i].pl_nbuffers = > + rbp[i].rbp_nbuffers; > + pool_cfg->pl_pools[i].pl_credits = > + rbp[i].rbp_credits; > + pool_cfg->pl_pools[i].pl_mincredits = > + rbp[i].rbp_mincredits; > + break; > + } > + } > + lnet_net_unlock(LNET_LOCK_EX); > + } > + > + lnet_net_lock(LNET_LOCK_EX); > + pool_cfg->pl_routing = the_lnet.ln_routing; > + lnet_net_unlock(LNET_LOCK_EX); > + > + return rc; > +} > + > int > lnet_get_route(int idx, __u32 *net, __u32 *hops, > lnet_nid_t *gateway, __u32 *alive, __u32 *priority) > @@ -1531,8 +1567,8 @@ lnet_rtrpools_alloc(int im_a_router) > return rc; > } > > -int > -lnet_rtrpools_adjust(int tiny, int small, int large) > +static int > +lnet_rtrpools_adjust_helper(int tiny, int small, int large) > { > int nrb = 0; > int rc = 0; > @@ -1540,19 +1576,10 @@ lnet_rtrpools_adjust(int tiny, int small, int large) > lnet_rtrbufpool_t *rtrp; > > /* > - * this function doesn't revert the changes if adding new buffers > - * failed. It's up to the user space caller to revert the > - * changes. > - */ > - > - if (!the_lnet.ln_routing) > - return 0; > - > - /* > * If the provided values for each buffer pool are different than the > * configured values, we need to take action. > */ > - if (tiny >= 0 && tiny != tiny_router_buffers) { > + if (tiny >= 0) { Unrelated cleanups. And below. regards, dan carpenter From dan.carpenter at oracle.com Wed Dec 2 12:34:50 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 2 Dec 2015 15:34:50 +0300 Subject: [lustre-devel] [PATCH 19/40] staging: lustre: copy out libcfs ioctl inline buffer In-Reply-To: <1448062576-23757-20-git-send-email-jsimmons@infradead.org> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-20-git-send-email-jsimmons@infradead.org> Message-ID: <20151202123450.GQ18797@mwanda> On Fri, Nov 20, 2015 at 06:35:55PM -0500, James Simmons wrote: > From: Liang Zhen > > - libcfs_ioctl_popdata should copy out inline buffers. > - code cleanup for libcfs ioctl handler > - error number fix for obd_ioctl_getdata > - add new function libcfs_ioctl_unpack for upcoming patches > Without looking at the patch, I can already tell you it should be four separate patches instead of one. Don't mix bug fixes and cleanups. This should not be a new rule for anyone. Guys, what the actual heck is going on??? This patchset is making me really depressed and I'm not even half way through. > Signed-off-by: Liang Zhen > Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435 > Reviewed-on: http://review.whamcloud.com/11313 > Reviewed-by: Bobi Jam > Reviewed-by: Johann Lombardi > Reviewed-by: Oleg Drokin > --- > .../lustre/include/linux/libcfs/libcfs_ioctl.h | 24 +++- > drivers/staging/lustre/lnet/lnet/api-ni.c | 2 + > .../lustre/lustre/libcfs/linux/linux-module.c | 45 +++++--- > drivers/staging/lustre/lustre/libcfs/module.c | 119 ++++++++------------ > .../lustre/lustre/obdclass/linux/linux-module.c | 17 +-- > 5 files changed, 97 insertions(+), 110 deletions(-) > > diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h > index f24330d..3468933 100644 > --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h > +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h > @@ -49,6 +49,9 @@ struct libcfs_ioctl_hdr { > __u32 ioc_version; > }; > > +/** max size to copy from userspace */ > +#define LIBCFS_IOC_DATA_MAX (128 * 1024) > + > struct libcfs_ioctl_data { > struct libcfs_ioctl_hdr ioc_hdr; > > @@ -240,11 +243,22 @@ static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data) > > int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand); > int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand); > -int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr *buf, __u32 buf_len, > - const void __user *arg); > -int libcfs_ioctl_getdata_len(const struct libcfs_ioctl_hdr __user *arg, > - __u32 *buf_len); > -int libcfs_ioctl_popdata(void *arg, void *buf, int size); > +int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp, > + struct libcfs_ioctl_hdr __user *uparam); > + > +static inline int libcfs_ioctl_popdata(struct libcfs_ioctl_hdr *hdr, > + struct libcfs_ioctl_hdr __user *uparam) > +{ > + if (copy_to_user(uparam, hdr, hdr->ioc_len)) > + return -EFAULT; > + return 0; > +} No. Don't do this. > + > +static inline void libcfs_ioctl_freedata(struct libcfs_ioctl_hdr *hdr) > +{ > + LIBCFS_FREE(hdr, hdr->ioc_len); > +} No. We need to transition to kmalloc() and kfree() instead of adding even more abstraction layers. In this patchset we add new calls to ALLOC() when we should be using normal kernel functions like kstrdup() but we can't because then we wouldn't have a size parameter to pass to LIBCFS_FREE(). > + > int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data); > > #endif /* __LIBCFS_IOCTL_H__ */ > diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c > index 949fa2f..4c4e6d3 100644 > --- a/drivers/staging/lustre/lnet/lnet/api-ni.c > +++ b/drivers/staging/lustre/lnet/lnet/api-ni.c > @@ -1838,6 +1838,8 @@ LNetCtl(unsigned int cmd, void *arg) > int rc; > unsigned long secs_passed; > > + CLASSERT(sizeof(struct lnet_ioctl_net_config) + > + sizeof(struct lnet_ioctl_config_data) < LIBCFS_IOC_DATA_MAX); BUILD_BUG_ON(). > LASSERT(the_lnet.ln_init); > > switch (cmd) { > diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c > index 1c31e2e..50a5464 100644 > --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c > +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-module.c > @@ -43,7 +43,7 @@ > int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data) > { > if (libcfs_ioctl_is_invalid(data)) { > - CERROR("LNET: ioctl not correctly formatted\n"); > + CERROR("libcfs ioctl: parameter not correctly formatted\n"); > return -EINVAL; > } > > @@ -57,39 +57,46 @@ int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data) > return 0; > } > > -int libcfs_ioctl_getdata_len(const struct libcfs_ioctl_hdr __user *arg, > - __u32 *len) > +int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp, > + struct libcfs_ioctl_hdr __user *uhdr) > { > struct libcfs_ioctl_hdr hdr; > + int err = 0; > > - if (copy_from_user(&hdr, arg, sizeof(hdr))) > + if (copy_from_user(&hdr, uhdr, sizeof(hdr))) > return -EFAULT; > > if (hdr.ioc_version != LIBCFS_IOCTL_VERSION && > hdr.ioc_version != LIBCFS_IOCTL_VERSION2) { > - CERROR("LNET: version mismatch expected %#x, got %#x\n", > + CERROR("libcfs ioctl: version mismatch expected %#x, got %#x\n", > LIBCFS_IOCTL_VERSION, hdr.ioc_version); > return -EINVAL; > } > > - *len = hdr.ioc_len; > + if (hdr.ioc_len < sizeof(struct libcfs_ioctl_data)) { > + CERROR("libcfs ioctl: user buffer too small for ioctl\n"); > + return -EINVAL; > + } It's sort of good to check here, but we will need to add all the other checks I mentioned as well. Also don't fix introduce bugs and fix them in the same patchset, the fix has to be folded into the buggy patch. > > - return 0; > -} > + if (hdr.ioc_len > LIBCFS_IOC_DATA_MAX) { > + CERROR("libcfs ioctl: user buffer is too large %d/%d\n", > + hdr.ioc_len, LIBCFS_IOC_DATA_MAX); > + return -EINVAL; > + } > > -int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr *buf, __u32 buf_len, > - const void __user *arg) > -{ > - if (copy_from_user(buf, arg, buf_len)) > - return -EFAULT; > - return 0; > -} > + LIBCFS_ALLOC(*hdr_pp, hdr.ioc_len); > + if (!*hdr_pp) > + return -ENOMEM; > + > + if (copy_from_user(*hdr_pp, uhdr, hdr.ioc_len)) { > + err = -EFAULT; > + goto failed; > + } We still need to re-check hdr.ioc_len after re-reading it from the user. Anyway, break this patch up and I will review it properly. regards, dan carpenter From dan.carpenter at oracle.com Wed Dec 2 12:44:47 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 2 Dec 2015 15:44:47 +0300 Subject: [lustre-devel] [PATCH 20/40] staging: lustre: fix kernel crash when network failed to start In-Reply-To: <1448062576-23757-21-git-send-email-jsimmons@infradead.org> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-21-git-send-email-jsimmons@infradead.org> Message-ID: <20151202124447.GR18797@mwanda> Fold this into the original patch. (Which you're going to have to redo anyway to fix the other bug and because of the GW-BASIC label names). regards, dan carpenter From dan.carpenter at oracle.com Wed Dec 2 12:59:45 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 2 Dec 2015 15:59:45 +0300 Subject: [lustre-devel] [PATCH 21/40] staging: lustre: improve LNet clean up code and API In-Reply-To: <1448062576-23757-22-git-send-email-jsimmons@infradead.org> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-22-git-send-email-jsimmons@infradead.org> Message-ID: <20151202125440.GS18797@mwanda> Actually we're going to have to redo so much code that it's not worth it for me to review the rest of these patches. Please just look over everything again: BAD: return -1; GOOD: return -EINVAL; BAD: failed0: GOOD: free_something: BAD: if (rc != 0) GOOD: if (rc) Do one thing per patch. Do not introduce a bug and then fix it in a later patch. Check ioc_len more carefully. Don't make the code look ugly just to please checkpatch.pl. Do error handling not success handling. Try to avoid indenting a far to the right. regards, dan carpenter From alexander.zarochentsev at seagate.com Wed Dec 2 13:20:59 2015 From: alexander.zarochentsev at seagate.com (Alexander Zarochentsev) Date: Wed, 2 Dec 2015 16:20:59 +0300 Subject: [lustre-devel] [PATCH 21/40] staging: lustre: improve LNet clean up code and API In-Reply-To: <20151202125440.GS18797@mwanda> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-22-git-send-email-jsimmons@infradead.org> <20151202125440.GS18797@mwanda> Message-ID: Hello, On Wed, Dec 2, 2015 at 3:59 PM, Dan Carpenter wrote: > Actually we're going to have to redo so much code that it's not worth it > for me to review the rest of these patches. Please just look over > everything again: > > BAD: return -1; > GOOD: return -EINVAL; > > BAD: failed0: > GOOD: free_something: > > BAD: if (rc != 0) > GOOD: if (rc) The latest suggestion is not correct, from http://wiki.lustre.org/Lustre_Coding_Guidelines : Conditional boolean (if (expr)), scalar (if (val != 0)) and pointer (if (ptr != NULL)) expressions should be written consistently. Thanks, -- Alexander Zarochentsev Seagate Technology, LLC www.seagate.com From dan.carpenter at oracle.com Wed Dec 2 13:59:30 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Wed, 2 Dec 2015 16:59:30 +0300 Subject: [lustre-devel] [PATCH 21/40] staging: lustre: improve LNet clean up code and API In-Reply-To: References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-22-git-send-email-jsimmons@infradead.org> <20151202125440.GS18797@mwanda> Message-ID: <20151202135930.GM7289@mwanda> On Wed, Dec 02, 2015 at 04:20:59PM +0300, Alexander Zarochentsev wrote: > > BAD: if (rc != 0) > > GOOD: if (rc) > > The latest suggestion is not correct, > from http://wiki.lustre.org/Lustre_Coding_Guidelines : > Conditional boolean (if (expr)), scalar (if (val != 0)) and pointer > (if (ptr != NULL)) expressions should be written consistently. Kernel style trumps Lustre style. Double negative don't not hurt readability. != NULL is a checkpatch.pl warning. Also comparisons like == false or == true are checkpatch warnings. I can think of two places where comparing with zero is appropriate and those are: 1) If you are talking about the numer zero. if (x == 0 || x == 2) 2) strcmp() and other *cmp() functions. if (strcmp(foo, bar) == 0) /* foo and bar are the same */ if (strcmp(foo, bar) < 0) /* foo less than bar */ if (strcmp(foo, bar) != 0) /* foo not the same as bar */ For "if (rc) {" a zero return doesn't mean zero, it means success so comparing against zero is bad style. regards, dan carpenter From andreas.dilger at intel.com Fri Dec 4 06:23:43 2015 From: andreas.dilger at intel.com (Dilger, Andreas) Date: Fri, 4 Dec 2015 06:23:43 +0000 Subject: [lustre-devel] [lustre cleanups 0/6] Patch series to make lustre safe(r) for W=1 compiles In-Reply-To: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449007519-73974-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: On 2015/12/01, 15:05, "Valdis Kletnieks" wrote: >Start of a batch series to clean up the Lustre tree. Other people have >done some sparse and checkpatch cleanups, but I found a bunch of >stuff building with W=1. Hello Valdis, thanks for these patches. Strictly speaking, they should also be sent to "Greg Kroah-Hartman " and also devel at driverdev.osuosl.org because Lustre is still in the staging tree. Also, for the patch subject line, it is standard to use something like: [PATCH 1/6] staging/lustre: Swap inline/const to kill 272 warnings as generated by "git format-patch". Could you please resubmit your patch series so that Greg sees your patches. Cheers, Andreas >Valdis Kletnieks (6): > > Swap inline/const to kill 272 warnings > Fix set-but-unused whinge. > Clean up another C warnining: > Fix another C compiler whine: > Nuke an unsigned >= 0 assert > Nuke another unsigned >= 0 assert > > drivers/staging/lustre/lustre/fid/lproc_fid.c | 1 + > drivers/staging/lustre/lustre/include/lu_object.h | 2 +- > drivers/staging/lustre/lustre/include/lustre_cfg.h | 4 -- > drivers/staging/lustre/lustre/libcfs/module.c | 15 ++++---- > drivers/staging/lustre/lustre/llite/rw.c | 1 - > drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 1 - > 7 files changed, 26 insertions(+), 41 deletions(-) > >-- >2.6.3 > > Cheers, Andreas -- Andreas Dilger Lustre Principal Architect Intel High Performance Data Division From green at linuxhacker.ru Fri Dec 4 23:23:08 2015 From: green at linuxhacker.ru (green at linuxhacker.ru) Date: Fri, 4 Dec 2015 18:23:08 -0500 Subject: [lustre-devel] [PATCH] staging/lustre: remove IOC_LIBCFS_PING_TEST ioctl Message-ID: <1449271388-3546416-1-git-send-email-green@linuxhacker.ru> From: James Simmons The ioctl IOC_LIBCFS_PING_TEST has not been used in ages. The recent nidstring changes which moved all the nidstring operations from libcfs to the LNet layer but this ioctl code was still using an nidstring operation that was causing a circular dependency loop between libcfs and LNet. Signed-off-by: James Simmons Signed-off-by: Oleg Drokin --- Would be great to have this accepted to fix the ugly circular dependency error Lustre is still causing in the Linus' tree when enabled. .../staging/lustre/include/linux/libcfs/libcfs_ioctl.h | 1 - drivers/staging/lustre/lustre/libcfs/module.c | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h index f5d741f..485ab26 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h @@ -110,7 +110,6 @@ struct libcfs_ioctl_handler { #define IOC_LIBCFS_CLEAR_DEBUG _IOWR('e', 31, long) #define IOC_LIBCFS_MARK_DEBUG _IOWR('e', 32, long) #define IOC_LIBCFS_MEMHOG _IOWR('e', 36, long) -#define IOC_LIBCFS_PING_TEST _IOWR('e', 37, long) /* lnet ioctls */ #define IOC_LIBCFS_GET_NI _IOWR('e', 50, long) #define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, long) diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 07a6859..e7c2b26 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -274,23 +274,6 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd, } break; - case IOC_LIBCFS_PING_TEST: { - extern void (kping_client)(struct libcfs_ioctl_data *); - void (*ping)(struct libcfs_ioctl_data *); - - CDEBUG(D_IOCTL, "doing %d pings to nid %s (%s)\n", - data->ioc_count, libcfs_nid2str(data->ioc_nid), - libcfs_nid2str(data->ioc_nid)); - ping = symbol_get(kping_client); - if (!ping) - CERROR("symbol_get failed\n"); - else { - ping(data); - symbol_put(kping_client); - } - return 0; - } - default: { struct libcfs_ioctl_handler *hand; -- 2.1.0 From linux at rasmusvillemoes.dk Sun Dec 6 00:41:31 2015 From: linux at rasmusvillemoes.dk (Rasmus Villemoes) Date: Sun, 6 Dec 2015 01:41:31 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: fix %.2X versus signed char issue Message-ID: <1449362492-20779-1-git-send-email-linux@rasmusvillemoes.dk> When char is signed and one of the bytes in lmm happens to have a byte value above 127, the result of printing that with %.2X will be 8 hex chars, the first 6 of which are 'F'. Worst case, we'll overrun our 'carefully' allocated buffer. I didn't have the tenacity to work through the gazillion and seven layers of macros behind CERROR, but I assume it'll all end at some function implemented in terms of the kernel's vsnprintf. Use %*phN for a hexdump. That'll cap the number of dumped bytes at 64. If that's a problem, the loop could be replaced by "bin2hex(buffer, lmm, lmm_bytes);". Signed-off-by: Rasmus Villemoes --- drivers/staging/lustre/lustre/lov/lov_pack.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c index 2fb1e974cc70..7f18d08929a5 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pack.c +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c @@ -258,22 +258,9 @@ static int lov_verify_lmm(void *lmm, int lmm_bytes, __u16 *stripe_count) int rc; if (lsm_op_find(le32_to_cpu(*(__u32 *)lmm)) == NULL) { - char *buffer; - int sz; - CERROR("bad disk LOV MAGIC: 0x%08X; dumping LMM (size=%d):\n", le32_to_cpu(*(__u32 *)lmm), lmm_bytes); - sz = lmm_bytes * 2 + 1; - buffer = libcfs_kvzalloc(sz, GFP_NOFS); - if (buffer != NULL) { - int i; - - for (i = 0; i < lmm_bytes; i++) - sprintf(buffer+2*i, "%.2X", ((char *)lmm)[i]); - buffer[sz - 1] = '\0'; - CERROR("%s\n", buffer); - kvfree(buffer); - } + CERROR("%*phN\n", lmm_bytes, lmm); return -EINVAL; } rc = lsm_op_find(le32_to_cpu(*(__u32 *)lmm))->lsm_lmm_verify(lmm, -- 2.6.1 From oleg.drokin at intel.com Tue Dec 8 17:40:27 2015 From: oleg.drokin at intel.com (Drokin, Oleg) Date: Tue, 8 Dec 2015 17:40:27 +0000 Subject: [lustre-devel] new tag 2.7.64 Message-ID: <7D81F951-9DE6-45BF-890F-876BED519DDF@intel.com> Hello! A new tag 2.7.64 has been created in the master branch of the Lustre community repo. Bye, Oleg From gregkh at linuxfoundation.org Tue Dec 8 21:30:27 2015 From: gregkh at linuxfoundation.org (Greg KH) Date: Tue, 8 Dec 2015 16:30:27 -0500 Subject: [lustre-devel] [PATCH] staging: lustre: add __user attributes to llite/file.c In-Reply-To: <1449606856-21619-1-git-send-email-nauxuron@wimdewith.com> References: <1449606856-21619-1-git-send-email-nauxuron@wimdewith.com> Message-ID: <20151208213027.GA31006@kroah.com> On Tue, Dec 08, 2015 at 09:34:16PM +0100, Wim de With wrote: > This fixes the following sparse warnings: > > drivers/staging/lustre/lustre/llite/file.c:1310:38: expected void const [noderef] *from > drivers/staging/lustre/lustre/llite/file.c:1310:38: got struct ll_recreate_obj * > drivers/staging/lustre/lustre/llite/file.c:1328:35: warning: incorrect type in argument 2 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:1328:35: expected void const [noderef] *from > drivers/staging/lustre/lustre/llite/file.c:1328:35: got struct lu_fid * > drivers/staging/lustre/lustre/llite/file.c:1475:35: warning: incorrect type in argument 2 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:1475:35: expected void const [noderef] *from > drivers/staging/lustre/lustre/llite/file.c:1475:35: got struct lov_user_md_v1 * > drivers/staging/lustre/lustre/llite/file.c:1500:35: warning: incorrect type in argument 2 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:1500:35: expected void const [noderef] *from > drivers/staging/lustre/lustre/llite/file.c:1500:35: got struct lov_user_md_v1 *lumv1p > drivers/staging/lustre/lustre/llite/file.c:1505:44: warning: incorrect type in argument 2 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:1505:44: expected void const [noderef] *from > drivers/staging/lustre/lustre/llite/file.c:1505:44: got struct lov_user_md_v3 *lumv3p > drivers/staging/lustre/lustre/llite/file.c:1516:17: warning: incorrect type in argument 1 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:1516:17: expected void const volatile [noderef] * > drivers/staging/lustre/lustre/llite/file.c:1516:17: got unsigned short * > drivers/staging/lustre/lustre/llite/file.c:1829:27: warning: incorrect type in argument 1 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:1829:27: expected void [noderef] *to > drivers/staging/lustre/lustre/llite/file.c:1829:27: got void * > drivers/staging/lustre/lustre/llite/file.c:2214:24: warning: incorrect type in argument 1 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2214:24: expected void const volatile [noderef] * > drivers/staging/lustre/lustre/llite/file.c:2214:24: got int * > drivers/staging/lustre/lustre/llite/file.c:2221:21: warning: incorrect type in argument 1 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2221:21: expected void const volatile [noderef] * > drivers/staging/lustre/lustre/llite/file.c:2221:21: got int * > drivers/staging/lustre/lustre/llite/file.c:2245:43: warning: incorrect type in argument 2 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2245:43: expected void const [noderef] *from > drivers/staging/lustre/lustre/llite/file.c:2245:43: got char * > drivers/staging/lustre/lustre/llite/file.c:2275:24: warning: incorrect type in argument 1 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2275:24: expected void const volatile [noderef] * > drivers/staging/lustre/lustre/llite/file.c:2275:24: got int * > drivers/staging/lustre/lustre/llite/file.c:2292:35: warning: incorrect type in argument 1 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2292:35: expected void [noderef] *to > drivers/staging/lustre/lustre/llite/file.c:2292:35: got void * > drivers/staging/lustre/lustre/llite/file.c:2299:44: warning: incorrect type in argument 2 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2299:44: expected void [noderef] *arg > drivers/staging/lustre/lustre/llite/file.c:2299:44: got void * > drivers/staging/lustre/lustre/llite/file.c:2304:43: warning: incorrect type in argument 2 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2304:43: expected void const [noderef] *from > drivers/staging/lustre/lustre/llite/file.c:2304:43: got char * > drivers/staging/lustre/lustre/llite/file.c:2310:46: warning: incorrect type in argument 1 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2310:46: expected void [noderef] *to > drivers/staging/lustre/lustre/llite/file.c:2310:46: got char * > drivers/staging/lustre/lustre/llite/file.c:2323:21: warning: incorrect type in argument 1 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2323:21: expected void const volatile [noderef] * > drivers/staging/lustre/lustre/llite/file.c:2323:21: got int * > drivers/staging/lustre/lustre/llite/file.c:2350:35: warning: incorrect type in argument 1 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2350:35: expected void [noderef] *to > drivers/staging/lustre/lustre/llite/file.c:2350:35: got void * > drivers/staging/lustre/lustre/llite/file.c:2361:36: warning: incorrect type in argument 1 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2361:36: expected void const [noderef] * > drivers/staging/lustre/lustre/llite/file.c:2361:36: got char * > drivers/staging/lustre/lustre/llite/file.c:2389:35: warning: incorrect type in argument 1 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2389:35: expected void [noderef] *to > drivers/staging/lustre/lustre/llite/file.c:2389:35: got char * > drivers/staging/lustre/lustre/llite/file.c:2483:36: warning: incorrect type in argument 1 (different address spaces) > drivers/staging/lustre/lustre/llite/file.c:2483:36: expected void const [noderef] * > drivers/staging/lustre/lustre/llite/file.c:2483:36: got void * > > It simply casts pointers to __user pointers in most cases, and changes a > few pointers to __user pointers. But that's not really fixing the issue here :( Doing this type of work is non-trivial for lustre, I wouldn't even recommend trying it out. It is going to require changes in how some of the structures are layed out, and probably some userspace tool changes as well. Sorry, I can't take this patch as-is. greg k-h From nauxuron at wimdewith.com Tue Dec 8 20:34:16 2015 From: nauxuron at wimdewith.com (Wim de With) Date: Tue, 8 Dec 2015 21:34:16 +0100 Subject: [lustre-devel] [PATCH] staging: lustre: add __user attributes to llite/file.c Message-ID: <1449606856-21619-1-git-send-email-nauxuron@wimdewith.com> This fixes the following sparse warnings: drivers/staging/lustre/lustre/llite/file.c:1310:38: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:1310:38: got struct ll_recreate_obj * drivers/staging/lustre/lustre/llite/file.c:1328:35: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:1328:35: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:1328:35: got struct lu_fid * drivers/staging/lustre/lustre/llite/file.c:1475:35: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:1475:35: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:1475:35: got struct lov_user_md_v1 * drivers/staging/lustre/lustre/llite/file.c:1500:35: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:1500:35: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:1500:35: got struct lov_user_md_v1 *lumv1p drivers/staging/lustre/lustre/llite/file.c:1505:44: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:1505:44: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:1505:44: got struct lov_user_md_v3 *lumv3p drivers/staging/lustre/lustre/llite/file.c:1516:17: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:1516:17: expected void const volatile [noderef] * drivers/staging/lustre/lustre/llite/file.c:1516:17: got unsigned short * drivers/staging/lustre/lustre/llite/file.c:1829:27: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:1829:27: expected void [noderef] *to drivers/staging/lustre/lustre/llite/file.c:1829:27: got void * drivers/staging/lustre/lustre/llite/file.c:2214:24: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2214:24: expected void const volatile [noderef] * drivers/staging/lustre/lustre/llite/file.c:2214:24: got int * drivers/staging/lustre/lustre/llite/file.c:2221:21: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2221:21: expected void const volatile [noderef] * drivers/staging/lustre/lustre/llite/file.c:2221:21: got int * drivers/staging/lustre/lustre/llite/file.c:2245:43: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2245:43: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:2245:43: got char * drivers/staging/lustre/lustre/llite/file.c:2275:24: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2275:24: expected void const volatile [noderef] * drivers/staging/lustre/lustre/llite/file.c:2275:24: got int * drivers/staging/lustre/lustre/llite/file.c:2292:35: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2292:35: expected void [noderef] *to drivers/staging/lustre/lustre/llite/file.c:2292:35: got void * drivers/staging/lustre/lustre/llite/file.c:2299:44: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2299:44: expected void [noderef] *arg drivers/staging/lustre/lustre/llite/file.c:2299:44: got void * drivers/staging/lustre/lustre/llite/file.c:2304:43: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2304:43: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:2304:43: got char * drivers/staging/lustre/lustre/llite/file.c:2310:46: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2310:46: expected void [noderef] *to drivers/staging/lustre/lustre/llite/file.c:2310:46: got char * drivers/staging/lustre/lustre/llite/file.c:2323:21: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2323:21: expected void const volatile [noderef] * drivers/staging/lustre/lustre/llite/file.c:2323:21: got int * drivers/staging/lustre/lustre/llite/file.c:2350:35: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2350:35: expected void [noderef] *to drivers/staging/lustre/lustre/llite/file.c:2350:35: got void * drivers/staging/lustre/lustre/llite/file.c:2361:36: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2361:36: expected void const [noderef] * drivers/staging/lustre/lustre/llite/file.c:2361:36: got char * drivers/staging/lustre/lustre/llite/file.c:2389:35: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2389:35: expected void [noderef] *to drivers/staging/lustre/lustre/llite/file.c:2389:35: got char * drivers/staging/lustre/lustre/llite/file.c:2483:36: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2483:36: expected void const [noderef] * drivers/staging/lustre/lustre/llite/file.c:2483:36: got void * It simply casts pointers to __user pointers in most cases, and changes a few pointers to __user pointers. Signed-off-by: Wim de With --- drivers/staging/lustre/lustre/llite/file.c | 43 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 02f2759..27fc7af 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1307,7 +1307,7 @@ static int ll_lov_recreate_obj(struct inode *inode, unsigned long arg) if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; - if (copy_from_user(&ucreat, (struct ll_recreate_obj *)arg, + if (copy_from_user(&ucreat, (struct ll_recreate_obj __user *)arg, sizeof(ucreat))) return -EFAULT; @@ -1325,7 +1325,7 @@ static int ll_lov_recreate_fid(struct inode *inode, unsigned long arg) if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; - if (copy_from_user(&fid, (struct lu_fid *)arg, sizeof(fid))) + if (copy_from_user(&fid, (struct lu_fid __user *)arg, sizeof(fid))) return -EFAULT; fid_to_ostid(&fid, &oi); @@ -1472,7 +1472,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file, if (lump == NULL) return -ENOMEM; - if (copy_from_user(lump, (struct lov_user_md *)arg, lum_size)) { + if (copy_from_user(lump, (struct lov_user_md __user *)arg, lum_size)) { kvfree(lump); return -EFAULT; } @@ -1490,8 +1490,10 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file, { struct lov_user_md_v3 lumv3; struct lov_user_md_v1 *lumv1 = (struct lov_user_md_v1 *)&lumv3; - struct lov_user_md_v1 *lumv1p = (struct lov_user_md_v1 *)arg; - struct lov_user_md_v3 *lumv3p = (struct lov_user_md_v3 *)arg; + struct lov_user_md_v1 __user *lumv1p = + (struct lov_user_md_v1 __user *)arg; + struct lov_user_md_v3 __user *lumv3p = + (struct lov_user_md_v3 __user *)arg; int lum_size, rc; int flags = FMODE_WRITE; @@ -1826,7 +1828,7 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) ret_bytes += (fiemap_s->fm_mapped_extents * sizeof(struct ll_fiemap_extent)); - if (copy_to_user((void *)arg, fiemap_s, ret_bytes)) + if (copy_to_user((void __user *)arg, fiemap_s, ret_bytes)) rc = -EFAULT; error: @@ -2211,14 +2213,14 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) switch (cmd) { case LL_IOC_GETFLAGS: /* Get the current value of the file flags */ - return put_user(fd->fd_flags, (int *)arg); + return put_user(fd->fd_flags, (int __user *)arg); case LL_IOC_SETFLAGS: case LL_IOC_CLRFLAGS: /* Set or clear specific file flags */ /* XXX This probably needs checks to ensure the flags are * not abused, and to handle any flag side effects. */ - if (get_user(flags, (int *) arg)) + if (get_user(flags, (int __user *)arg)) return -EFAULT; if (cmd == LL_IOC_SETFLAGS) { @@ -2242,8 +2244,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct file *file2; struct lustre_swap_layouts lsl; - if (copy_from_user(&lsl, (char *)arg, - sizeof(struct lustre_swap_layouts))) + if (copy_from_user(&lsl, (char __user *)arg, + sizeof(struct lustre_swap_layouts))) return -EFAULT; if ((file->f_flags & O_ACCMODE) == 0) /* O_RDONLY */ @@ -2272,7 +2274,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return ll_iocontrol(inode, file, cmd, arg); case FSFILT_IOC_GETVERSION_OLD: case FSFILT_IOC_GETVERSION: - return put_user(inode->i_generation, (int *)arg); + return put_user(inode->i_generation, (int __user *)arg); case LL_IOC_GROUP_LOCK: return ll_get_grouplock(inode, file, arg); case LL_IOC_GROUP_UNLOCK: @@ -2289,25 +2291,26 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case LL_IOC_FLUSHCTX: return ll_flush_ctx(inode); case LL_IOC_PATH2FID: { - if (copy_to_user((void *)arg, ll_inode2fid(inode), + if (copy_to_user((void __user *)arg, ll_inode2fid(inode), sizeof(struct lu_fid))) return -EFAULT; return 0; } case OBD_IOC_FID2PATH: - return ll_fid2path(inode, (void *)arg); + return ll_fid2path(inode, (void __user *)arg); case LL_IOC_DATA_VERSION: { struct ioc_data_version idv; int rc; - if (copy_from_user(&idv, (char *)arg, sizeof(idv))) + if (copy_from_user(&idv, (char __user *)arg, sizeof(idv))) return -EFAULT; rc = ll_data_version(inode, &idv.idv_version, !(idv.idv_flags & LL_DV_NOFLUSH)); - if (rc == 0 && copy_to_user((char *) arg, &idv, sizeof(idv))) + if (rc == 0 && copy_to_user((char __user *)arg, &idv, + sizeof(idv))) return -EFAULT; return rc; @@ -2320,7 +2323,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (mdtidx < 0) return mdtidx; - if (put_user((int)mdtidx, (int *)arg)) + if (put_user((int)mdtidx, (int __user *)arg)) return -EFAULT; return 0; @@ -2347,7 +2350,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), op_data, NULL); - if (copy_to_user((void *)arg, hus, sizeof(*hus))) + if (copy_to_user((void __user *)arg, hus, sizeof(*hus))) rc = -EFAULT; ll_finish_md_op_data(op_data); @@ -2358,7 +2361,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct hsm_state_set *hss; int rc; - hss = memdup_user((char *)arg, sizeof(*hss)); + hss = memdup_user((char __user *)arg, sizeof(*hss)); if (IS_ERR(hss)) return PTR_ERR(hss); @@ -2386,7 +2389,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), op_data, NULL); - if (copy_to_user((char *)arg, hca, sizeof(*hca))) + if (copy_to_user((char __user *)arg, hca, sizeof(*hca))) rc = -EFAULT; ll_finish_md_op_data(op_data); @@ -2480,7 +2483,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case LL_IOC_HSM_IMPORT: { struct hsm_user_import *hui; - hui = memdup_user((void *)arg, sizeof(*hui)); + hui = memdup_user((void __user *)arg, sizeof(*hui)); if (IS_ERR(hui)) return PTR_ERR(hui); -- 2.6.3 From niranjan.dighe at gmail.com Wed Dec 9 17:08:13 2015 From: niranjan.dighe at gmail.com (Niranjan Dighe) Date: Wed, 9 Dec 2015 22:38:13 +0530 Subject: [lustre-devel] [PATCH] staging: lustre/lustre/libcfs: Fix type mismatch reported by sparse Message-ID: <20151209170813.GA12216@codebox> The third argument to function kportal_memhog_alloc is expected to be gfp_t whereas the actual argument was unsigned int. Fix this by explicitly typecasting to gfp_t Signed-off-by: Niranjan Dighe --- drivers/staging/lustre/lustre/libcfs/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 96d9d46..9c79f6e 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -268,7 +268,7 @@ static int libcfs_ioctl_int(struct cfs_psdev_file *pfile, unsigned long cmd, /* XXX The ioc_flags is not GFP flags now, need to be fixed */ err = kportal_memhog_alloc(pfile->private_data, data->ioc_count, - data->ioc_flags); + (__force gfp_t)data->ioc_flags); if (err != 0) kportal_memhog_free(pfile->private_data); } -- 1.9.1 From paf at cray.com Wed Dec 9 22:00:03 2015 From: paf at cray.com (Patrick Farrell) Date: Wed, 9 Dec 2015 22:00:03 +0000 Subject: [lustre-devel] [PATCH] staging: lustre: add __user attributes to llite/file.c In-Reply-To: <1449606856-21619-1-git-send-email-nauxuron@wimdewith.com> References: <1449606856-21619-1-git-send-email-nauxuron@wimdewith.com> Message-ID: Greg just recently replied to a similar patch rejecting it. I don't have his response handy, but I bet you can find it in the archives. Briefly, this hides possible errors rather than fixing them. ________________________________________ From: lustre-devel [lustre-devel-bounces at lists.lustre.org] on behalf of Wim de With [nauxuron at wimdewith.com] Sent: Tuesday, December 08, 2015 2:34 PM To: oleg.drokin at intel.com; andreas.dilger at intel.com; gregkh at linuxfoundation.org Cc: devel at driverdev.osuosl.org; Wim de With; linux-kernel at vger.kernel.org; lustre-devel at lists.lustre.org Subject: [lustre-devel] [PATCH] staging: lustre: add __user attributes to llite/file.c This fixes the following sparse warnings: drivers/staging/lustre/lustre/llite/file.c:1310:38: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:1310:38: got struct ll_recreate_obj * drivers/staging/lustre/lustre/llite/file.c:1328:35: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:1328:35: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:1328:35: got struct lu_fid * drivers/staging/lustre/lustre/llite/file.c:1475:35: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:1475:35: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:1475:35: got struct lov_user_md_v1 * drivers/staging/lustre/lustre/llite/file.c:1500:35: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:1500:35: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:1500:35: got struct lov_user_md_v1 *lumv1p drivers/staging/lustre/lustre/llite/file.c:1505:44: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:1505:44: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:1505:44: got struct lov_user_md_v3 *lumv3p drivers/staging/lustre/lustre/llite/file.c:1516:17: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:1516:17: expected void const volatile [noderef] * drivers/staging/lustre/lustre/llite/file.c:1516:17: got unsigned short * drivers/staging/lustre/lustre/llite/file.c:1829:27: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:1829:27: expected void [noderef] *to drivers/staging/lustre/lustre/llite/file.c:1829:27: got void * drivers/staging/lustre/lustre/llite/file.c:2214:24: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2214:24: expected void const volatile [noderef] * drivers/staging/lustre/lustre/llite/file.c:2214:24: got int * drivers/staging/lustre/lustre/llite/file.c:2221:21: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2221:21: expected void const volatile [noderef] * drivers/staging/lustre/lustre/llite/file.c:2221:21: got int * drivers/staging/lustre/lustre/llite/file.c:2245:43: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2245:43: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:2245:43: got char * drivers/staging/lustre/lustre/llite/file.c:2275:24: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2275:24: expected void const volatile [noderef] * drivers/staging/lustre/lustre/llite/file.c:2275:24: got int * drivers/staging/lustre/lustre/llite/file.c:2292:35: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2292:35: expected void [noderef] *to drivers/staging/lustre/lustre/llite/file.c:2292:35: got void * drivers/staging/lustre/lustre/llite/file.c:2299:44: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2299:44: expected void [noderef] *arg drivers/staging/lustre/lustre/llite/file.c:2299:44: got void * drivers/staging/lustre/lustre/llite/file.c:2304:43: warning: incorrect type in argument 2 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2304:43: expected void const [noderef] *from drivers/staging/lustre/lustre/llite/file.c:2304:43: got char * drivers/staging/lustre/lustre/llite/file.c:2310:46: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2310:46: expected void [noderef] *to drivers/staging/lustre/lustre/llite/file.c:2310:46: got char * drivers/staging/lustre/lustre/llite/file.c:2323:21: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2323:21: expected void const volatile [noderef] * drivers/staging/lustre/lustre/llite/file.c:2323:21: got int * drivers/staging/lustre/lustre/llite/file.c:2350:35: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2350:35: expected void [noderef] *to drivers/staging/lustre/lustre/llite/file.c:2350:35: got void * drivers/staging/lustre/lustre/llite/file.c:2361:36: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2361:36: expected void const [noderef] * drivers/staging/lustre/lustre/llite/file.c:2361:36: got char * drivers/staging/lustre/lustre/llite/file.c:2389:35: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2389:35: expected void [noderef] *to drivers/staging/lustre/lustre/llite/file.c:2389:35: got char * drivers/staging/lustre/lustre/llite/file.c:2483:36: warning: incorrect type in argument 1 (different address spaces) drivers/staging/lustre/lustre/llite/file.c:2483:36: expected void const [noderef] * drivers/staging/lustre/lustre/llite/file.c:2483:36: got void * It simply casts pointers to __user pointers in most cases, and changes a few pointers to __user pointers. Signed-off-by: Wim de With --- drivers/staging/lustre/lustre/llite/file.c | 43 ++++++++++++++++-------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 02f2759..27fc7af 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -1307,7 +1307,7 @@ static int ll_lov_recreate_obj(struct inode *inode, unsigned long arg) if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; - if (copy_from_user(&ucreat, (struct ll_recreate_obj *)arg, + if (copy_from_user(&ucreat, (struct ll_recreate_obj __user *)arg, sizeof(ucreat))) return -EFAULT; @@ -1325,7 +1325,7 @@ static int ll_lov_recreate_fid(struct inode *inode, unsigned long arg) if (!capable(CFS_CAP_SYS_ADMIN)) return -EPERM; - if (copy_from_user(&fid, (struct lu_fid *)arg, sizeof(fid))) + if (copy_from_user(&fid, (struct lu_fid __user *)arg, sizeof(fid))) return -EFAULT; fid_to_ostid(&fid, &oi); @@ -1472,7 +1472,7 @@ static int ll_lov_setea(struct inode *inode, struct file *file, if (lump == NULL) return -ENOMEM; - if (copy_from_user(lump, (struct lov_user_md *)arg, lum_size)) { + if (copy_from_user(lump, (struct lov_user_md __user *)arg, lum_size)) { kvfree(lump); return -EFAULT; } @@ -1490,8 +1490,10 @@ static int ll_lov_setstripe(struct inode *inode, struct file *file, { struct lov_user_md_v3 lumv3; struct lov_user_md_v1 *lumv1 = (struct lov_user_md_v1 *)&lumv3; - struct lov_user_md_v1 *lumv1p = (struct lov_user_md_v1 *)arg; - struct lov_user_md_v3 *lumv3p = (struct lov_user_md_v3 *)arg; + struct lov_user_md_v1 __user *lumv1p = + (struct lov_user_md_v1 __user *)arg; + struct lov_user_md_v3 __user *lumv3p = + (struct lov_user_md_v3 __user *)arg; int lum_size, rc; int flags = FMODE_WRITE; @@ -1826,7 +1828,7 @@ static int ll_ioctl_fiemap(struct inode *inode, unsigned long arg) ret_bytes += (fiemap_s->fm_mapped_extents * sizeof(struct ll_fiemap_extent)); - if (copy_to_user((void *)arg, fiemap_s, ret_bytes)) + if (copy_to_user((void __user *)arg, fiemap_s, ret_bytes)) rc = -EFAULT; error: @@ -2211,14 +2213,14 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) switch (cmd) { case LL_IOC_GETFLAGS: /* Get the current value of the file flags */ - return put_user(fd->fd_flags, (int *)arg); + return put_user(fd->fd_flags, (int __user *)arg); case LL_IOC_SETFLAGS: case LL_IOC_CLRFLAGS: /* Set or clear specific file flags */ /* XXX This probably needs checks to ensure the flags are * not abused, and to handle any flag side effects. */ - if (get_user(flags, (int *) arg)) + if (get_user(flags, (int __user *)arg)) return -EFAULT; if (cmd == LL_IOC_SETFLAGS) { @@ -2242,8 +2244,8 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct file *file2; struct lustre_swap_layouts lsl; - if (copy_from_user(&lsl, (char *)arg, - sizeof(struct lustre_swap_layouts))) + if (copy_from_user(&lsl, (char __user *)arg, + sizeof(struct lustre_swap_layouts))) return -EFAULT; if ((file->f_flags & O_ACCMODE) == 0) /* O_RDONLY */ @@ -2272,7 +2274,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return ll_iocontrol(inode, file, cmd, arg); case FSFILT_IOC_GETVERSION_OLD: case FSFILT_IOC_GETVERSION: - return put_user(inode->i_generation, (int *)arg); + return put_user(inode->i_generation, (int __user *)arg); case LL_IOC_GROUP_LOCK: return ll_get_grouplock(inode, file, arg); case LL_IOC_GROUP_UNLOCK: @@ -2289,25 +2291,26 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case LL_IOC_FLUSHCTX: return ll_flush_ctx(inode); case LL_IOC_PATH2FID: { - if (copy_to_user((void *)arg, ll_inode2fid(inode), + if (copy_to_user((void __user *)arg, ll_inode2fid(inode), sizeof(struct lu_fid))) return -EFAULT; return 0; } case OBD_IOC_FID2PATH: - return ll_fid2path(inode, (void *)arg); + return ll_fid2path(inode, (void __user *)arg); case LL_IOC_DATA_VERSION: { struct ioc_data_version idv; int rc; - if (copy_from_user(&idv, (char *)arg, sizeof(idv))) + if (copy_from_user(&idv, (char __user *)arg, sizeof(idv))) return -EFAULT; rc = ll_data_version(inode, &idv.idv_version, !(idv.idv_flags & LL_DV_NOFLUSH)); - if (rc == 0 && copy_to_user((char *) arg, &idv, sizeof(idv))) + if (rc == 0 && copy_to_user((char __user *)arg, &idv, + sizeof(idv))) return -EFAULT; return rc; @@ -2320,7 +2323,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (mdtidx < 0) return mdtidx; - if (put_user((int)mdtidx, (int *)arg)) + if (put_user((int)mdtidx, (int __user *)arg)) return -EFAULT; return 0; @@ -2347,7 +2350,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), op_data, NULL); - if (copy_to_user((void *)arg, hus, sizeof(*hus))) + if (copy_to_user((void __user *)arg, hus, sizeof(*hus))) rc = -EFAULT; ll_finish_md_op_data(op_data); @@ -2358,7 +2361,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct hsm_state_set *hss; int rc; - hss = memdup_user((char *)arg, sizeof(*hss)); + hss = memdup_user((char __user *)arg, sizeof(*hss)); if (IS_ERR(hss)) return PTR_ERR(hss); @@ -2386,7 +2389,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = obd_iocontrol(cmd, ll_i2mdexp(inode), sizeof(*op_data), op_data, NULL); - if (copy_to_user((char *)arg, hca, sizeof(*hca))) + if (copy_to_user((char __user *)arg, hca, sizeof(*hca))) rc = -EFAULT; ll_finish_md_op_data(op_data); @@ -2480,7 +2483,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case LL_IOC_HSM_IMPORT: { struct hsm_user_import *hui; - hui = memdup_user((void *)arg, sizeof(*hui)); + hui = memdup_user((void __user *)arg, sizeof(*hui)); if (IS_ERR(hui)) return PTR_ERR(hui); -- 2.6.3 _______________________________________________ lustre-devel mailing list lustre-devel at lists.lustre.org http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org From qingsong.gou at ck-telecom.com Fri Dec 11 08:08:53 2015 From: qingsong.gou at ck-telecom.com (Jandy Gou) Date: Fri, 11 Dec 2015 16:08:53 +0800 Subject: [lustre-devel] [PATCH] staging: lustre: This patch fixes the following sparse warning: Message-ID: <1449821333-18036-1-git-send-email-qingsong.gou@ck-telecom.com> drivers/staging/lustre/lustre/osc/osc_cache.c:622:19: warning: symbol 'osc_extent_find' was not declared. Should it be static? drivers/staging/lustre/lustre/osc/osc_cache.c:1423:6: warning: symbol 'osc_unreserve_grant' was not declared. Should it be static? Signed-off-by: Jandy Gou --- drivers/staging/lustre/lustre/osc/osc_cache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index b1d1a87f..62cfca6 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -619,7 +619,7 @@ static inline int overlapped(struct osc_extent *ex1, struct osc_extent *ex2) * Find or create an extent which includes @index, core function to manage * extent tree. */ -struct osc_extent *osc_extent_find(const struct lu_env *env, +static struct osc_extent *osc_extent_find(const struct lu_env *env, struct osc_object *obj, pgoff_t index, int *grants) @@ -1420,7 +1420,7 @@ static void __osc_unreserve_grant(struct client_obd *cli, } } -void osc_unreserve_grant(struct client_obd *cli, +static void osc_unreserve_grant(struct client_obd *cli, unsigned int reserved, unsigned int unused) { client_obd_list_lock(&cli->cl_loi_list_lock); -- 1.9.1 From Valdis.Kletnieks at vt.edu Fri Dec 11 23:04:20 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Fri, 11 Dec 2015 18:04:20 -0500 Subject: [lustre-devel] [PATCH v2 1/6] staging/lustre: Silence warning about 'inline' In-Reply-To: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: <1449875065-35182-2-git-send-email-Valdis.Kletnieks@vt.edu> Low-hanging fruit first: CC [M] drivers/staging/lustre/lustre/fid/fid_request.o In file included from drivers/staging/lustre/lustre/fid/../include/lustre_net.h:66:0, from drivers/staging/lustre/lustre/fid/../include/lustre_lib.h:64, from drivers/staging/lustre/lustre/fid/../include/obd.h:52, from drivers/staging/lustre/lustre/fid/fid_request.c:48: drivers/staging/lustre/lustre/fid/../include/lu_object.h:765:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration] static const inline struct lu_device_operations * ^ So we just swap inline and const. 272 warnings gone. :) Signed-off-by: Valdis Kletnieks --- drivers/staging/lustre/lustre/include/lu_object.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h index fa78689748a9..176724f60c1b 100644 --- a/drivers/staging/lustre/lustre/include/lu_object.h +++ b/drivers/staging/lustre/lustre/include/lu_object.h @@ -756,7 +756,7 @@ static inline const struct lu_fid *lu_object_fid(const struct lu_object *o) /** * return device operations vector for this object */ -static const inline struct lu_device_operations * +static inline const struct lu_device_operations * lu_object_ops(const struct lu_object *o) { return o->lo_dev->ld_ops; -- 2.6.3 From Valdis.Kletnieks at vt.edu Fri Dec 11 23:04:23 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Fri, 11 Dec 2015 18:04:23 -0500 Subject: [lustre-devel] [PATCH v2 4/6] Fix another C compiler whine: set but not used In-Reply-To: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: <1449875065-35182-5-git-send-email-Valdis.Kletnieks@vt.edu> CC [M] drivers/staging/lustre/lustre/libcfs/module.o drivers/staging/lustre/lustre/libcfs/module.c: In function 'lustre_insert_debugfs': drivers/staging/lustre/lustre/libcfs/module.c:670:17: warning: variable 'entry' set but not used [-Wunused-but-set-variable] struct dentry *entry; ^ Just ignore the dentry returned, and add a comment that we *know* we're not really leaking the dentry because something else will be able to reap it via recursion. Signed-off-by: Valdis Kletnieks --- drivers/staging/lustre/lustre/libcfs/module.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index 96d9d4651a51..4438dc426b54 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -667,8 +667,6 @@ static const struct file_operations lnet_debugfs_file_operations = { void lustre_insert_debugfs(struct ctl_table *table, const struct lnet_debugfs_symlink_def *symlinks) { - struct dentry *entry; - if (lnet_debugfs_root == NULL) lnet_debugfs_root = debugfs_create_dir("lnet", NULL); @@ -676,15 +674,17 @@ void lustre_insert_debugfs(struct ctl_table *table, if (IS_ERR_OR_NULL(lnet_debugfs_root)) return; + /* We don't save the dentry returned in next two calls, because + * we don't call debugfs_remove() but rather remove_recursive() + */ for (; table->procname; table++) - entry = debugfs_create_file(table->procname, table->mode, - lnet_debugfs_root, table, - &lnet_debugfs_file_operations); + debugfs_create_file(table->procname, table->mode, + lnet_debugfs_root, table, + &lnet_debugfs_file_operations); for (; symlinks && symlinks->name; symlinks++) - entry = debugfs_create_symlink(symlinks->name, - lnet_debugfs_root, - symlinks->target); + debugfs_create_symlink(symlinks->name, lnet_debugfs_root, + symlinks->target); } EXPORT_SYMBOL_GPL(lustre_insert_debugfs); -- 2.6.3 From Valdis.Kletnieks at vt.edu Fri Dec 11 23:04:19 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Fri, 11 Dec 2015 18:04:19 -0500 Subject: [lustre-devel] [PATCH v2 0/6] Patch series to make lustre safe(r) for W=1 compiles Message-ID: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> Start of a batch series to clean up the Lustre tree. Other people have done some sparse and checkpatch cleanups, but I found a bunch of stuff building with W=1. There's probably more, but this was the really low-hanging obvious fruit. Valdis Kletnieks (6): staging/lustre: Silence warning about 'inline' staging/lustre: Fix set-but-unused whinge. staging/lustre: Clean up another C warnining: set but not used staging/lustre: Fix another C compiler whine: set but not used staging/lustre: Nuke an unsigned >= 0 assert staging/lustre: Nuke another unsigned >= 0 assert drivers/staging/lustre/lustre/fid/lproc_fid.c | 1 + drivers/staging/lustre/lustre/include/lu_object.h | 2 +- drivers/staging/lustre/lustre/include/lustre_cfg.h | 4 -- drivers/staging/lustre/lustre/libcfs/module.c | 15 ++++---- drivers/staging/lustre/lustre/llite/rw.c | 1 - drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 1 - 6 files changed, 9 insertions(+), 15 deletions(-) -- 2.6.3 From Valdis.Kletnieks at vt.edu Fri Dec 11 23:04:24 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Fri, 11 Dec 2015 18:04:24 -0500 Subject: [lustre-devel] [PATCH v2 5/6] Nuke an unsigned >= 0 assert In-Reply-To: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: <1449875065-35182-6-git-send-email-Valdis.Kletnieks@vt.edu> Writing asserts for almost-never-can-happen things can be valuable. Writing an assert that tests that an "unsigned int" hasn't gone negative isn't. And it generates an *ugly* message: drivers/staging/lustre/lustre/llite/rw.c:763:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] LASSERTF(reserved >= 0, "reserved %lu\n", reserved); ^ include/linux/compiler.h:137:45: note: in definition of macro 'unlikely' # define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0)) ^ drivers/staging/lustre/lustre/llite/rw.c:763:2: note: in expansion of macro 'LASSERTF' LASSERTF(reserved >= 0, "reserved %lu\n", reserved); ^ drivers/staging/lustre/lustre/llite/rw.c:763:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] LASSERTF(reserved >= 0, "reserved %lu\n", reserved); ^ include/linux/compiler.h:137:53: note: in definition of macro 'unlikely' # define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0)) ^ drivers/staging/lustre/lustre/llite/rw.c:763:2: note: in expansion of macro 'LASSERTF' LASSERTF(reserved >= 0, "reserved %lu\n", reserved); ^ drivers/staging/lustre/lustre/llite/rw.c:763:20: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] LASSERTF(reserved >= 0, "reserved %lu\n", reserved); ^ include/linux/compiler.h:110:47: note: in definition of macro 'likely_notrace' #define likely_notrace(x) __builtin_expect(!!(x), 1) ^ include/linux/compiler.h:137:58: note: in expansion of macro '__branch_check__' # define unlikely(x) (__builtin_constant_p(x) ? !!(x) : __branch_check__(x, 0)) ^ drivers/staging/lustre/lustre/llite/../include/linux/../../../include/linux/libcfs/libcfs_private.h:58:6: note: in expansion of macro 'unlikely' if (unlikely(!(cond))) { \ ^ drivers/staging/lustre/lustre/llite/rw.c:763:2: note: in expansion of macro 'LASSERTF' LASSERTF(reserved >= 0, "reserved %lu\n", reserved); ^ Umm, thank you, GCC. We'll delete the problem line so we never see that spew again. Signed-off-by: Valdis Kletnieks --- drivers/staging/lustre/lustre/llite/rw.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/llite/rw.c b/drivers/staging/lustre/lustre/llite/rw.c index f79193fa2fb7..39390aab9da2 100644 --- a/drivers/staging/lustre/lustre/llite/rw.c +++ b/drivers/staging/lustre/lustre/llite/rw.c @@ -764,7 +764,6 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io, ret = ll_read_ahead_pages(env, io, queue, ria, &reserved, mapping, &ra_end); - LASSERTF(reserved >= 0, "reserved %lu\n", reserved); if (reserved != 0) ll_ra_count_put(ll_i2sbi(inode), reserved); -- 2.6.3 From Valdis.Kletnieks at vt.edu Fri Dec 11 23:04:25 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Fri, 11 Dec 2015 18:04:25 -0500 Subject: [lustre-devel] [PATCH v2 6/6] Nuke another unsigned >= 0 assert In-Reply-To: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: <1449875065-35182-7-git-send-email-Valdis.Kletnieks@vt.edu> Clean up another case of the compiler remininding the programmer they are an idiot: drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c:308:34: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] LASSERT(page_pools.epp_waitqlen >= 0); Just lose the assert, and save a page of compiler spew. Signed-off-by: Valdis Kletnieks --- drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c index cd8a9987f7ac..1f326673f089 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c +++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c @@ -304,7 +304,6 @@ static unsigned long enc_pools_cleanup(struct page ***pools, int npools) static inline void enc_pools_wakeup(void) { assert_spin_locked(&page_pools.epp_lock); - LASSERT(page_pools.epp_waitqlen >= 0); if (unlikely(page_pools.epp_waitqlen)) { LASSERT(waitqueue_active(&page_pools.epp_waitq)); -- 2.6.3 From Valdis.Kletnieks at vt.edu Fri Dec 11 23:04:21 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Fri, 11 Dec 2015 18:04:21 -0500 Subject: [lustre-devel] [PATCH v2 2/6] Fix set-but-unused whinge. In-Reply-To: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: <1449875065-35182-3-git-send-email-Valdis.Kletnieks@vt.edu> drivers/staging/lustre/lustre/fid/lproc_fid.c: In function 'ldebugfs_fid_write_common': drivers/staging/lustre/lustre/fid/lproc_fid.c:67:6: warning: variable 'rc' set but not used [-Wunused-but-set-variable] int rc; We fix it by *using* the return code to help bulletproof it. It says it's test code - it should be *more* bulletproof than production, not less. Signed-off-by: Valdis Kletnieks --- drivers/staging/lustre/lustre/fid/lproc_fid.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c index ce90c1c54a63..eff011f30fa5 100644 --- a/drivers/staging/lustre/lustre/fid/lproc_fid.c +++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c @@ -85,6 +85,8 @@ ldebugfs_fid_write_common(const char __user *buffer, size_t count, rc = sscanf(kernbuf, "[%llx - %llx]\n", (unsigned long long *)&tmp.lsr_start, (unsigned long long *)&tmp.lsr_end); + if (rc != 2) + return -EINVAL; if (!range_is_sane(&tmp) || range_is_zero(&tmp) || tmp.lsr_start < range->lsr_start || tmp.lsr_end > range->lsr_end) return -EINVAL; -- 2.6.3 From Valdis.Kletnieks at vt.edu Fri Dec 11 23:04:22 2015 From: Valdis.Kletnieks at vt.edu (Valdis Kletnieks) Date: Fri, 11 Dec 2015 18:04:22 -0500 Subject: [lustre-devel] [PATCH v2 3/6] Clean up another C warnining: set but not used In-Reply-To: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> References: <1449875065-35182-1-git-send-email-Valdis.Kletnieks@vt.edu> Message-ID: <1449875065-35182-4-git-send-email-Valdis.Kletnieks@vt.edu> drivers/staging/lustre/lustre/fid/../include/lustre_cfg.h: In function 'lustre_cfg_free': drivers/staging/lustre/lustre/fid/../include/lustre_cfg.h:253:6: warning: variable 'len' set but not used [-Wunused-but-set-variable] int len; Yep, we're just gonna call kfree, no need to calculate len. Bye-bye. Signed-off-by: Valdis Kletnieks --- drivers/staging/lustre/lustre/include/lustre_cfg.h | 4 -- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_cfg.h b/drivers/staging/lustre/lustre/include/lustre_cfg.h index eb6b292b7b25..d30d8b054c92 100644 --- a/drivers/staging/lustre/lustre/include/lustre_cfg.h +++ b/drivers/staging/lustre/lustre/include/lustre_cfg.h @@ -252,10 +252,6 @@ static inline struct lustre_cfg *lustre_cfg_new(int cmd, static inline void lustre_cfg_free(struct lustre_cfg *lcfg) { - int len; - - len = lustre_cfg_len(lcfg->lcfg_bufcount, lcfg->lcfg_buflens); - kfree(lcfg); return; } From elfring at users.sourceforge.net Sun Dec 13 13:48:35 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Sun, 13 Dec 2015 14:48:35 +0100 Subject: [lustre-devel] [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations In-Reply-To: <566ABCD9.1060404@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> Message-ID: <566D7733.1030102@users.sourceforge.net> From: Markus Elfring Date: Sun, 13 Dec 2015 14:40:14 +0100 Several update suggestions were taken into account from static source code analysis. Markus Elfring (7): Delete unnecessary goto statements in six functions Rename a jump label for ptlrpc_req_finished() calls Rename a jump label for a kfree(key) call Delete an unnecessary variable initialisation in mgc_process_recover_log() Less checks in mgc_process_recover_log() after error detection A few checks less in mgc_process_recover_log() after error detection Rename a jump label for module_put() calls drivers/staging/lustre/lustre/llite/file.c | 26 ++--- drivers/staging/lustre/lustre/llite/lloop.c | 8 +- drivers/staging/lustre/lustre/llite/namei.c | 13 +-- drivers/staging/lustre/lustre/llite/xattr.c | 20 ++-- drivers/staging/lustre/lustre/mdc/mdc_request.c | 124 ++++++++++----------- drivers/staging/lustre/lustre/mgc/mgc_request.c | 53 ++++----- drivers/staging/lustre/lustre/osc/osc_request.c | 52 ++++----- drivers/staging/lustre/lustre/ptlrpc/llog_client.c | 22 ++-- 8 files changed, 152 insertions(+), 166 deletions(-) -- 2.6.3 From elfring at users.sourceforge.net Sun Dec 13 13:52:48 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Sun, 13 Dec 2015 14:52:48 +0100 Subject: [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions In-Reply-To: <566D7733.1030102@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> Message-ID: <566D7830.9060000@users.sourceforge.net> From: Markus Elfring Date: Sun, 13 Dec 2015 09:30:47 +0100 Six goto statements referred to a source code position directly behind them. Thus omit such unnecessary jumps. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/staging/lustre/lustre/llite/namei.c | 1 - drivers/staging/lustre/lustre/mdc/mdc_request.c | 7 ------- 2 files changed, 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 64db5e8..2113dd4 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -554,7 +554,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, retval = NULL; else retval = dentry; - goto out; out: if (req) ptlrpc_req_finished(req); diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 294c050..920b1e9 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -1181,7 +1181,6 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp, ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); - goto out; out: ptlrpc_req_finished(req); return rc; @@ -1216,7 +1215,6 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives) ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); - goto out; out: ptlrpc_req_finished(req); return rc; @@ -1282,7 +1280,6 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp) ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); - goto out; out: ptlrpc_req_finished(req); return rc; @@ -1362,8 +1359,6 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp, ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); - goto out; - out: ptlrpc_req_finished(req); return rc; @@ -1427,8 +1422,6 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); - goto out; - out: ptlrpc_req_finished(req); return rc; -- 2.6.3 From elfring at users.sourceforge.net Sun Dec 13 13:54:12 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Sun, 13 Dec 2015 14:54:12 +0100 Subject: [lustre-devel] [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls In-Reply-To: <566D7733.1030102@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> Message-ID: <566D7884.5050407@users.sourceforge.net> From: Markus Elfring Date: Sun, 13 Dec 2015 10:33:38 +0100 This issue was detected by using the Coccinelle software. Choose a jump label according to the current Linux coding style convention. I suggest to improve this implementation detail by the reuse of a script like the following for the semantic patch language. @rename_jump_label exists@ identifier work; type return_type; @@ return_type work(...) { ... when any goto -out +finish_request ; ... when any -out +finish_request : ptlrpc_req_finished(...); ... when any } Signed-off-by: Markus Elfring --- drivers/staging/lustre/lustre/llite/file.c | 26 +++++------ drivers/staging/lustre/lustre/llite/namei.c | 12 ++--- drivers/staging/lustre/lustre/llite/xattr.c | 20 ++++---- drivers/staging/lustre/lustre/mdc/mdc_request.c | 54 +++++++++++----------- drivers/staging/lustre/lustre/osc/osc_request.c | 28 +++++------ drivers/staging/lustre/lustre/ptlrpc/llog_client.c | 22 ++++----- 6 files changed, 81 insertions(+), 81 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 31cd6b3..b94df54 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -427,27 +427,27 @@ static int ll_intent_file_open(struct dentry *dentry, void *lmm, */ if (!it_disposition(itp, DISP_OPEN_OPEN) || it_open_error(DISP_OPEN_OPEN, itp)) - goto out; + goto finish_request; ll_release_openhandle(inode, itp); - goto out; + goto finish_request; } if (it_disposition(itp, DISP_LOOKUP_NEG)) { rc = -ENOENT; - goto out; + goto finish_request; } if (rc != 0 || it_open_error(DISP_OPEN_OPEN, itp)) { rc = rc ? rc : it_open_error(DISP_OPEN_OPEN, itp); CDEBUG(D_VFSTRACE, "lock enqueue: err: %d\n", rc); - goto out; + goto finish_request; } rc = ll_prep_inode(&inode, req, NULL, itp); if (!rc && itp->d.lustre.it_lock_mode) ll_set_lock_data(sbi->ll_md_exp, inode, itp, NULL); -out: +finish_request: ptlrpc_req_finished(req); ll_intent_drop_lock(itp); @@ -2900,13 +2900,13 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits) oit.it_create_mode &= ~M_CHECK_STALE; if (rc < 0) { rc = ll_inode_revalidate_fini(inode, rc); - goto out; + goto finish_request; } rc = ll_revalidate_it_finish(req, &oit, inode); if (rc != 0) { ll_intent_release(&oit); - goto out; + goto finish_request; } /* Unlinked? Unhash dentry, so it is not picked up later by @@ -2946,7 +2946,7 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits) rc = ll_prep_inode(&inode, req, NULL, NULL); } -out: +finish_request: ptlrpc_req_finished(req); return rc; } @@ -3315,25 +3315,25 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); if (body == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } lmmsize = body->eadatasize; if (lmmsize == 0) /* empty layout */ { rc = 0; - goto out; + goto finish_request; } lmm = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA, lmmsize); if (lmm == NULL) { rc = -EFAULT; - goto out; + goto finish_request; } lvbdata = libcfs_kvzalloc(lmmsize, GFP_NOFS); if (lvbdata == NULL) { rc = -ENOMEM; - goto out; + goto finish_request; } memcpy(lvbdata, lmm, lmmsize); @@ -3345,7 +3345,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock) lock->l_lvb_len = lmmsize; unlock_res_and_lock(lock); -out: +finish_request: ptlrpc_req_finished(req); return rc; } diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c index 2113dd4..7501f70 100644 --- a/drivers/staging/lustre/lustre/llite/namei.c +++ b/drivers/staging/lustre/lustre/llite/namei.c @@ -686,7 +686,7 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it) rc = ll_prep_inode(&inode, request, dir->i_sb, it); if (rc) { inode = ERR_PTR(rc); - goto out; + goto finish_request; } LASSERT(hlist_empty(&inode->i_dentry)); @@ -697,7 +697,7 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it) CDEBUG(D_DLMTRACE, "setting l_ast_data to inode %p (%lu/%u)\n", inode, inode->i_ino, inode->i_generation); ll_set_lock_data(sbi->ll_md_exp, inode, it, NULL); - out: + finish_request: ptlrpc_req_finished(request); return inode; } @@ -960,13 +960,13 @@ static int ll_unlink(struct inode *dir, struct dentry *dentry) rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request); ll_finish_md_op_data(op_data); if (rc) - goto out; + goto finish_request; ll_update_times(request, dir); ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_UNLINK, 1); rc = ll_objects_destroy(request, dir); - out: + finish_request: ptlrpc_req_finished(request); return rc; } @@ -1059,11 +1059,11 @@ static int ll_link(struct dentry *old_dentry, struct inode *dir, err = md_link(sbi->ll_md_exp, op_data, &request); ll_finish_md_op_data(op_data); if (err) - goto out; + goto finish_request; ll_update_times(request, dir); ll_stats_ops_tally(sbi, LPROC_LL_LINK, 1); -out: +finish_request: ptlrpc_req_finished(request); return err; } diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c index 660b8ac..8d3287c 100644 --- a/drivers/staging/lustre/lustre/llite/xattr.c +++ b/drivers/staging/lustre/lustre/llite/xattr.c @@ -390,19 +390,19 @@ getxattr_nocache: /* only detect the xattr size */ if (size == 0) { rc = body->eadatasize; - goto out; + goto finish_request; } if (size < body->eadatasize) { CERROR("server bug: replied size %u > %u\n", body->eadatasize, (int)size); rc = -ERANGE; - goto out; + goto finish_request; } if (body->eadatasize == 0) { rc = -ENODATA; - goto out; + goto finish_request; } /* do not need swab xattr data */ @@ -410,7 +410,7 @@ getxattr_nocache: body->eadatasize); if (!xdata) { rc = -EFAULT; - goto out; + goto finish_request; } memcpy(buffer, xdata, body->eadatasize); @@ -425,14 +425,14 @@ getxattr_nocache: (posix_acl_xattr_header *)buffer, rc); if (IS_ERR(acl)) { rc = PTR_ERR(acl); - goto out; + goto finish_request; } rc = ee_add(&sbi->ll_et, current_pid(), ll_inode2fid(inode), xattr_type, acl); if (unlikely(rc < 0)) { lustre_ext_acl_xattr_free(acl); - goto out; + goto finish_request; } } #endif @@ -444,7 +444,7 @@ out_xattr: ll_get_fsname(inode->i_sb, NULL, 0), rc); sbi->ll_flags &= ~LL_SBI_USER_XATTR; } -out: +finish_request: ptlrpc_req_finished(req); return rc; } @@ -555,7 +555,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) rc = ll_getxattr_common(inode, NULL, buffer, size, OBD_MD_FLXATTRLS); if (rc < 0) - goto out; + goto finish_request; if (buffer != NULL) { struct ll_sb_info *sbi = ll_i2sbi(inode); @@ -589,7 +589,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) if (rc2 < 0) { rc2 = 0; - goto out; + goto finish_request; } else if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)) { const int prefix_len = sizeof(XATTR_LUSTRE_PREFIX) - 1; const size_t name_len = sizeof("lov") - 1; @@ -608,7 +608,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size) } rc2 = total_len; } -out: +finish_request: ptlrpc_req_finished(request); rc = rc + rc2; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 920b1e9..2a76685 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -92,12 +92,12 @@ static int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid) rc = ptlrpc_queue_wait(req); if (rc) - goto out; + goto finish_request; body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY); if (body == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } *rootfid = body->fid1; @@ -105,7 +105,7 @@ static int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid) "root fid="DFID", last_committed=%llu\n", PFID(rootfid), lustre_msg_get_last_committed(req->rq_repmsg)); -out: +finish_request: ptlrpc_req_finished(req); return rc; } @@ -1084,17 +1084,17 @@ static int mdc_statfs(const struct lu_env *env, /* check connection error first */ if (imp->imp_connect_error) rc = imp->imp_connect_error; - goto out; + goto finish_request; } msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS); if (msfs == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } *osfs = *msfs; -out: +finish_request: ptlrpc_req_finished(req); output: class_import_put(imp); @@ -1163,7 +1163,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp, LUSTRE_MDS_VERSION, MDS_HSM_PROGRESS); if (req == NULL) { rc = -ENOMEM; - goto out; + goto finish_request; } mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0); @@ -1172,7 +1172,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp, req_hpk = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_PROGRESS); if (req_hpk == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } *req_hpk = *hpk; @@ -1181,7 +1181,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp, ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); -out: +finish_request: ptlrpc_req_finished(req); return rc; } @@ -1197,7 +1197,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives) MDS_HSM_CT_REGISTER); if (req == NULL) { rc = -ENOMEM; - goto out; + goto finish_request; } mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0); @@ -1207,7 +1207,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives) &RMF_MDS_HSM_ARCHIVE); if (archive_mask == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } *archive_mask = archives; @@ -1215,7 +1215,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives) ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); -out: +finish_request: ptlrpc_req_finished(req); return rc; } @@ -1246,18 +1246,18 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp, rc = mdc_queue_wait(req); if (rc) - goto out; + goto finish_request; req_hca = req_capsule_server_get(&req->rq_pill, &RMF_MDS_HSM_CURRENT_ACTION); if (req_hca == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } *hca = *req_hca; -out: +finish_request: ptlrpc_req_finished(req); return rc; } @@ -1272,7 +1272,7 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp) MDS_HSM_CT_UNREGISTER); if (req == NULL) { rc = -ENOMEM; - goto out; + goto finish_request; } mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0); @@ -1280,7 +1280,7 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp) ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); -out: +finish_request: ptlrpc_req_finished(req); return rc; } @@ -1311,17 +1311,17 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp, rc = mdc_queue_wait(req); if (rc) - goto out; + goto finish_request; req_hus = req_capsule_server_get(&req->rq_pill, &RMF_HSM_USER_STATE); if (req_hus == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } *hus = *req_hus; -out: +finish_request: ptlrpc_req_finished(req); return rc; } @@ -1352,14 +1352,14 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp, req_hss = req_capsule_client_get(&req->rq_pill, &RMF_HSM_STATE_SET); if (req_hss == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } *req_hss = *hss; ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); -out: +finish_request: ptlrpc_req_finished(req); return rc; } @@ -1377,7 +1377,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, req = ptlrpc_request_alloc(imp, &RQF_MDS_HSM_REQUEST); if (req == NULL) { rc = -ENOMEM; - goto out; + goto finish_request; } req_capsule_set_size(&req->rq_pill, &RMF_MDS_HSM_USER_ITEM, RCL_CLIENT, @@ -1398,7 +1398,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, req_hr = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_REQUEST); if (req_hr == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } *req_hr = hur->hur_request; @@ -1406,7 +1406,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, req_hui = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_USER_ITEM); if (req_hui == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } memcpy(req_hui, hur->hur_user_item, hur->hur_request.hr_itemcount * sizeof(struct hsm_user_item)); @@ -1415,14 +1415,14 @@ static int mdc_ioc_hsm_request(struct obd_export *exp, req_opaque = req_capsule_client_get(&req->rq_pill, &RMF_GENERIC_DATA); if (req_opaque == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } memcpy(req_opaque, hur_data(hur), hur->hur_request.hr_data_len); ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); -out: +finish_request: ptlrpc_req_finished(req); return rc; } diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index d6c1447..3a56fb7 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -291,12 +291,12 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, rc = ptlrpc_queue_wait(req); if (rc) - goto out; + goto finish_request; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); if (body == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode); @@ -306,7 +306,7 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, oinfo->oi_oa->o_blksize = cli_brw_size(exp->exp_obd); oinfo->oi_oa->o_valid |= OBD_MD_FLBLKSZ; - out: + finish_request: ptlrpc_req_finished(req); return rc; } @@ -336,18 +336,18 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, rc = ptlrpc_queue_wait(req); if (rc) - goto out; + goto finish_request; body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); if (body == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } lustre_get_wire_obdo(&req->rq_import->imp_connect_data, oinfo->oi_oa, &body->oa); -out: +finish_request: ptlrpc_req_finished(req); return rc; } @@ -1276,7 +1276,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, if (desc == NULL) { rc = -ENOMEM; - goto out; + goto finish_request; } /* NB request now owns desc and will free it when it gets freed */ @@ -1407,7 +1407,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli, *reqp = req; return 0; - out: + finish_request: ptlrpc_req_finished(req); return rc; } @@ -2513,17 +2513,17 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, rc = ptlrpc_queue_wait(req); if (rc) - goto out; + goto finish_request; msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS); if (msfs == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } *osfs = *msfs; - out: + finish_request: ptlrpc_req_finished(req); return rc; } @@ -2718,16 +2718,16 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); if (rc) - goto out; + goto finish_request; reply = req_capsule_server_get(&req->rq_pill, &RMF_OBD_ID); if (reply == NULL) { rc = -EPROTO; - goto out; + goto finish_request; } *((u64 *)val) = *reply; - out: + finish_request: ptlrpc_req_finished(req); return rc; } else if (KEY_IS(KEY_FIEMAP)) { diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c index 5122205..150d2ec 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c +++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c @@ -176,26 +176,26 @@ static int llog_client_next_block(const struct lu_env *env, ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); if (rc) - goto out; + goto finish_request; body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) { rc = -EFAULT; - goto out; + goto finish_request; } /* The log records are swabbed as they are processed */ ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA); if (ptr == NULL) { rc = -EFAULT; - goto out; + goto finish_request; } *cur_idx = body->lgd_saved_index; *cur_offset = body->lgd_cur_offset; memcpy(buf, ptr, len); -out: +finish_request: ptlrpc_req_finished(req); err_exit: LLOG_CLIENT_EXIT(loghandle->lgh_ctxt, imp); @@ -233,22 +233,22 @@ static int llog_client_prev_block(const struct lu_env *env, rc = ptlrpc_queue_wait(req); if (rc) - goto out; + goto finish_request; body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY); if (body == NULL) { rc = -EFAULT; - goto out; + goto finish_request; } ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA); if (ptr == NULL) { rc = -EFAULT; - goto out; + goto finish_request; } memcpy(buf, ptr, len); -out: +finish_request: ptlrpc_req_finished(req); err_exit: LLOG_CLIENT_EXIT(loghandle->lgh_ctxt, imp); @@ -282,12 +282,12 @@ static int llog_client_read_header(const struct lu_env *env, ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); if (rc) - goto out; + goto finish_request; hdr = req_capsule_server_get(&req->rq_pill, &RMF_LLOG_LOG_HDR); if (hdr == NULL) { rc = -EFAULT; - goto out; + goto finish_request; } memcpy(handle->lgh_hdr, hdr, sizeof(*hdr)); @@ -305,7 +305,7 @@ static int llog_client_read_header(const struct lu_env *env, CERROR("you may need to re-run lconf --write_conf.\n"); rc = -EIO; } -out: +finish_request: ptlrpc_req_finished(req); err_exit: LLOG_CLIENT_EXIT(handle->lgh_ctxt, imp); -- 2.6.3 From elfring at users.sourceforge.net Sun Dec 13 13:55:46 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Sun, 13 Dec 2015 14:55:46 +0100 Subject: [lustre-devel] [PATCH 3/7] staging: lustre: Rename a jump label for a kfree(key) call In-Reply-To: <566D7733.1030102@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> Message-ID: <566D78E2.9060209@users.sourceforge.net> From: Markus Elfring Date: Sun, 13 Dec 2015 10:56:35 +0100 This issue was detected by using the Coccinelle software. Choose a jump label according to the current Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/staging/lustre/lustre/mdc/mdc_request.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 2a76685..2085ba6 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -1125,7 +1125,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) if (!fid_is_sane(&gf->gf_fid)) { rc = -EINVAL; - goto out; + goto free_key; } /* Val is struct getinfo_fid2path result plus path */ @@ -1133,20 +1133,19 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf) rc = obd_get_info(NULL, exp, keylen, key, &vallen, gf, NULL); if (rc != 0 && rc != -EREMOTE) - goto out; + goto free_key; if (vallen <= sizeof(*gf)) { rc = -EPROTO; - goto out; + goto free_key; } else if (vallen > sizeof(*gf) + gf->gf_pathlen) { rc = -EOVERFLOW; - goto out; + goto free_key; } CDEBUG(D_IOCTL, "path get "DFID" from %llu #%d\n%s\n", PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path); - -out: +free_key: kfree(key); return rc; } -- 2.6.3 From elfring at users.sourceforge.net Sun Dec 13 13:56:43 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Sun, 13 Dec 2015 14:56:43 +0100 Subject: [lustre-devel] [PATCH 4/7] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log() In-Reply-To: <566D7733.1030102@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> Message-ID: <566D791B.7010604@users.sourceforge.net> From: Markus Elfring Date: Sun, 13 Dec 2015 12:00:32 +0100 The variable "mne_swab" will eventually be set to an appropriate value from a call of the ptlrpc_rep_need_swab() function. Thus let us omit the explicit initialisation at the beginning. Signed-off-by: Markus Elfring --- drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index 2c48847..da130f4 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -1293,7 +1293,7 @@ static int mgc_process_recover_log(struct obd_device *obd, struct page **pages; int nrpages; bool eof = true; - bool mne_swab = false; + bool mne_swab; int i; int ealen; int rc; -- 2.6.3 From elfring at users.sourceforge.net Sun Dec 13 13:57:38 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Sun, 13 Dec 2015 14:57:38 +0100 Subject: [lustre-devel] [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection In-Reply-To: <566D7733.1030102@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> Message-ID: <566D7952.7090401@users.sourceforge.net> From: Markus Elfring Date: Sun, 13 Dec 2015 12:21:17 +0100 A few checks would be performed by the mgc_process_recover_log() function even if it is known already that the passed variable "pages" contained a null pointer. * Let us return directly if a call of the kcalloc() function failed. * Move assignments for the variables "eof" and "req" behind this memory allocation. * Delete a sanity check then. Signed-off-by: Markus Elfring --- drivers/staging/lustre/lustre/mgc/mgc_request.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index da130f4..f3b4c30 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -1285,14 +1285,14 @@ static int mgc_apply_recover_logs(struct obd_device *mgc, static int mgc_process_recover_log(struct obd_device *obd, struct config_llog_data *cld) { - struct ptlrpc_request *req = NULL; + struct ptlrpc_request *req; struct config_llog_instance *cfg = &cld->cld_cfg; struct mgs_config_body *body; struct mgs_config_res *res; struct ptlrpc_bulk_desc *desc; struct page **pages; int nrpages; - bool eof = true; + bool eof; bool mne_swab; int i; int ealen; @@ -1309,10 +1309,11 @@ static int mgc_process_recover_log(struct obd_device *obd, nrpages = CONFIG_READ_NRPAGES_INIT; pages = kcalloc(nrpages, sizeof(*pages), GFP_KERNEL); - if (pages == NULL) { - rc = -ENOMEM; - goto out; - } + if (!pages) + return -ENOMEM; + + req = NULL; + eof = true; for (i = 0; i < nrpages; i++) { pages[i] = alloc_page(GFP_KERNEL); @@ -1432,14 +1433,12 @@ out: if (rc == 0 && !eof) goto again; - if (pages) { - for (i = 0; i < nrpages; i++) { - if (pages[i] == NULL) - break; - __free_page(pages[i]); - } - kfree(pages); + for (i = 0; i < nrpages; i++) { + if (pages[i] == NULL) + break; + __free_page(pages[i]); } + kfree(pages); return rc; } -- 2.6.3 From elfring at users.sourceforge.net Sun Dec 13 13:58:33 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Sun, 13 Dec 2015 14:58:33 +0100 Subject: [lustre-devel] [PATCH 6/7] staging: lustre: A few checks less in mgc_process_recover_log() after error detection In-Reply-To: <566D7733.1030102@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> Message-ID: <566D7989.6090205@users.sourceforge.net> From: Markus Elfring Date: Sun, 13 Dec 2015 13:03:58 +0100 A few checks would be performed by the mgc_process_recover_log() function even if it was determined that a call of the alloc_page() function failed. * This implementation detail could be improved by adjustments for jump targets according to the Linux coding style convention. * Move the assignment for the variable "eof" behind the memory allocation. * Delete another sanity check then. * The variable "req" will eventually be set to an appropriate pointer from a call of the ptlrpc_request_alloc() function. Thus let us omit the explicit initialisation before. Signed-off-by: Markus Elfring --- drivers/staging/lustre/lustre/mgc/mgc_request.c | 32 +++++++++++-------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c index f3b4c30..7048722 100644 --- a/drivers/staging/lustre/lustre/mgc/mgc_request.c +++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c @@ -1312,17 +1312,15 @@ static int mgc_process_recover_log(struct obd_device *obd, if (!pages) return -ENOMEM; - req = NULL; - eof = true; - for (i = 0; i < nrpages; i++) { pages[i] = alloc_page(GFP_KERNEL); if (pages[i] == NULL) { rc = -ENOMEM; - goto out; + goto free_pages; } } + eof = true; again: LASSERT(cld_is_recover(cld)); LASSERT(mutex_is_locked(&cld->cld_lock)); @@ -1330,12 +1328,12 @@ again: &RQF_MGS_CONFIG_READ); if (req == NULL) { rc = -ENOMEM; - goto out; + goto free_pages; } rc = ptlrpc_request_pack(req, LUSTRE_MGS_VERSION, MGS_CONFIG_READ); if (rc) - goto out; + goto finish_request; /* pack request */ body = req_capsule_client_get(&req->rq_pill, &RMF_MGS_CONFIG_BODY); @@ -1344,7 +1342,7 @@ again: if (strlcpy(body->mcb_name, cld->cld_logname, sizeof(body->mcb_name)) >= sizeof(body->mcb_name)) { rc = -E2BIG; - goto out; + goto finish_request; } body->mcb_offset = cfg->cfg_last_idx + 1; body->mcb_type = cld->cld_type; @@ -1356,7 +1354,7 @@ again: MGS_BULK_PORTAL); if (desc == NULL) { rc = -ENOMEM; - goto out; + goto finish_request; } for (i = 0; i < nrpages; i++) @@ -1365,12 +1363,12 @@ again: ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); if (rc) - goto out; + goto finish_request; res = req_capsule_server_get(&req->rq_pill, &RMF_MGS_CONFIG_RES); if (res->mcr_size < res->mcr_offset) { rc = -EINVAL; - goto out; + goto finish_request; } /* always update the index even though it might have errors with @@ -1384,18 +1382,18 @@ again: ealen = sptlrpc_cli_unwrap_bulk_read(req, req->rq_bulk, 0); if (ealen < 0) { rc = ealen; - goto out; + goto finish_request; } if (ealen > nrpages << PAGE_CACHE_SHIFT) { rc = -EINVAL; - goto out; + goto finish_request; } if (ealen == 0) { /* no logs transferred */ if (!eof) rc = -EINVAL; - goto out; + goto finish_request; } mne_swab = !!ptlrpc_rep_need_swab(req); @@ -1425,14 +1423,12 @@ again: ealen -= PAGE_CACHE_SIZE; } - -out: - if (req) - ptlrpc_req_finished(req); +finish_request: + ptlrpc_req_finished(req); if (rc == 0 && !eof) goto again; - +free_pages: for (i = 0; i < nrpages; i++) { if (pages[i] == NULL) break; -- 2.6.3 From elfring at users.sourceforge.net Sun Dec 13 14:00:12 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Sun, 13 Dec 2015 15:00:12 +0100 Subject: [lustre-devel] [PATCH 7/7] staging: lustre: Rename a jump label for module_put() calls In-Reply-To: <566D7733.1030102@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> Message-ID: <566D79EC.6050104@users.sourceforge.net> From: Markus Elfring Date: Sun, 13 Dec 2015 14:05:57 +0100 This issue was detected by using the Coccinelle software. Choose a jump label according to the current Linux coding style convention. I suggest to improve this implementation detail by the reuse of a script like the following for the semantic patch language. @rename_jump_label exists@ identifier target != put_module, work; type return_type; @@ return_type work(...) { ... when any goto -target +put_module ; ... when any -target +put_module : module_put(...); ... when any } Signed-off-by: Markus Elfring --- drivers/staging/lustre/lustre/llite/lloop.c | 8 ++-- drivers/staging/lustre/lustre/mdc/mdc_request.c | 52 ++++++++++++------------- drivers/staging/lustre/lustre/osc/osc_request.c | 24 ++++++------ 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c index 420d391..ebeef3b 100644 --- a/drivers/staging/lustre/lustre/llite/lloop.c +++ b/drivers/staging/lustre/lustre/llite/lloop.c @@ -484,14 +484,14 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused, error = -EBUSY; if (lo->lo_state != LLOOP_UNBOUND) - goto out; + goto put_module; mapping = file->f_mapping; inode = mapping->host; error = -EINVAL; if (!S_ISREG(inode->i_mode) || inode->i_sb->s_magic != LL_SUPER_MAGIC) - goto out; + goto put_module; if (!(file->f_mode & FMODE_WRITE)) lo_flags |= LO_FLAGS_READ_ONLY; @@ -500,7 +500,7 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused, if ((loff_t)(sector_t)size != size) { error = -EFBIG; - goto out; + goto put_module; } /* remove all pages in cache so as dirty pages not to be existent. */ @@ -542,7 +542,7 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused, down(&lo->lo_sem); return 0; -out: +put_module: /* This is safe: open() is still holding a reference. */ module_put(THIS_MODULE); return error; diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 2085ba6..eaeca9a 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -1734,7 +1734,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, switch (cmd) { case OBD_IOC_CHANGELOG_SEND: rc = mdc_ioc_changelog_send(obd, karg); - goto out; + goto put_module; case OBD_IOC_CHANGELOG_CLEAR: { struct ioc_changelog *icc = karg; struct changelog_setinfo cs = { @@ -1745,47 +1745,47 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, rc = obd_set_info_async(NULL, exp, strlen(KEY_CHANGELOG_CLEAR), KEY_CHANGELOG_CLEAR, sizeof(cs), &cs, NULL); - goto out; + goto put_module; } case OBD_IOC_FID2PATH: rc = mdc_ioc_fid2path(exp, karg); - goto out; + goto put_module; case LL_IOC_HSM_CT_START: rc = mdc_ioc_hsm_ct_start(exp, karg); /* ignore if it was already registered on this MDS. */ if (rc == -EEXIST) rc = 0; - goto out; + goto put_module; case LL_IOC_HSM_PROGRESS: rc = mdc_ioc_hsm_progress(exp, karg); - goto out; + goto put_module; case LL_IOC_HSM_STATE_GET: rc = mdc_ioc_hsm_state_get(exp, karg); - goto out; + goto put_module; case LL_IOC_HSM_STATE_SET: rc = mdc_ioc_hsm_state_set(exp, karg); - goto out; + goto put_module; case LL_IOC_HSM_ACTION: rc = mdc_ioc_hsm_current_action(exp, karg); - goto out; + goto put_module; case LL_IOC_HSM_REQUEST: rc = mdc_ioc_hsm_request(exp, karg); - goto out; + goto put_module; case OBD_IOC_CLIENT_RECOVER: rc = ptlrpc_recover_import(imp, data->ioc_inlbuf1, 0); if (rc < 0) - goto out; + goto put_module; rc = 0; - goto out; + goto put_module; case IOC_OSC_SET_ACTIVE: rc = ptlrpc_set_import_active(imp, data->ioc_offset); - goto out; + goto put_module; case OBD_IOC_POLL_QUOTACHECK: rc = mdc_quota_poll_check(exp, (struct if_quotacheck *)karg); - goto out; + goto put_module; case OBD_IOC_PING_TARGET: rc = ptlrpc_obd_ping(obd); - goto out; + goto put_module; /* * Normally IOC_OBD_STATFS, OBD_IOC_QUOTACTL iocontrol are handled by * LMV instead of MDC. But when the cluster is upgraded from 1.8, @@ -1798,7 +1798,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (*((__u32 *) data->ioc_inlbuf2) != 0) { rc = -ENODEV; - goto out; + goto put_module; } /* copy UUID */ @@ -1806,24 +1806,24 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, min_t(size_t, data->ioc_plen2, sizeof(struct obd_uuid)))) { rc = -EFAULT; - goto out; + goto put_module; } rc = mdc_statfs(NULL, obd->obd_self_export, &stat_buf, cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), 0); if (rc != 0) - goto out; + goto put_module; if (copy_to_user(data->ioc_pbuf1, &stat_buf, min_t(size_t, data->ioc_plen1, sizeof(stat_buf)))) { rc = -EFAULT; - goto out; + goto put_module; } rc = 0; - goto out; + goto put_module; } case OBD_IOC_QUOTACTL: { struct if_quotactl *qctl = karg; @@ -1832,7 +1832,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS); if (!oqctl) { rc = -ENOMEM; - goto out; + goto put_module; } QCTL_COPY(oqctl, qctl); @@ -1844,26 +1844,26 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, } kfree(oqctl); - goto out; + goto put_module; } case LL_IOC_GET_CONNECT_FLAGS: if (copy_to_user(uarg, exp_connect_flags_ptr(exp), sizeof(*exp_connect_flags_ptr(exp)))) { rc = -EFAULT; - goto out; + goto put_module; } rc = 0; - goto out; + goto put_module; case LL_IOC_LOV_SWAP_LAYOUTS: rc = mdc_ioc_swap_layouts(exp, karg); - goto out; + goto put_module; default: CERROR("unrecognised ioctl: cmd = %#x\n", cmd); rc = -ENOTTY; - goto out; + goto put_module; } -out: +put_module: module_put(THIS_MODULE); return rc; diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 3a56fb7..3ee1ff8 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -2611,7 +2611,7 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, len = 0; if (obd_ioctl_getdata(&buf, &len, uarg)) { err = -EINVAL; - goto out; + goto put_module; } data = (struct obd_ioctl_data *)buf; @@ -2619,13 +2619,13 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (sizeof(*desc) > data->ioc_inllen1) { obd_ioctl_freedata(buf, len); err = -EINVAL; - goto out; + goto put_module; } if (data->ioc_inllen2 < sizeof(uuid)) { obd_ioctl_freedata(buf, len); err = -EINVAL; - goto out; + goto put_module; } desc = (struct lov_desc *)data->ioc_inlbuf1; @@ -2643,39 +2643,39 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, if (err) err = -EFAULT; obd_ioctl_freedata(buf, len); - goto out; + goto put_module; } case LL_IOC_LOV_SETSTRIPE: err = obd_alloc_memmd(exp, karg); if (err > 0) err = 0; - goto out; + goto put_module; case LL_IOC_LOV_GETSTRIPE: err = osc_getstripe(karg, uarg); - goto out; + goto put_module; case OBD_IOC_CLIENT_RECOVER: err = ptlrpc_recover_import(obd->u.cli.cl_import, data->ioc_inlbuf1, 0); if (err > 0) err = 0; - goto out; + goto put_module; case IOC_OSC_SET_ACTIVE: err = ptlrpc_set_import_active(obd->u.cli.cl_import, data->ioc_offset); - goto out; + goto put_module; case OBD_IOC_POLL_QUOTACHECK: err = osc_quota_poll_check(exp, karg); - goto out; + goto put_module; case OBD_IOC_PING_TARGET: err = ptlrpc_obd_ping(obd); - goto out; + goto put_module; default: CDEBUG(D_INODE, "unrecognised ioctl %#x by %s\n", cmd, current_comm()); err = -ENOTTY; - goto out; + goto put_module; } -out: +put_module: module_put(THIS_MODULE); return err; } -- 2.6.3 From dan.carpenter at oracle.com Mon Dec 14 06:53:25 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Mon, 14 Dec 2015 09:53:25 +0300 Subject: [lustre-devel] [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls In-Reply-To: <566D7884.5050407@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7884.5050407@users.sourceforge.net> Message-ID: <20151214065325.GS5284@mwanda> Markus, please stop sending these things to rename out labels unless there is a bug. CodingStyle allows out labels. regards, dan carpenter From elfring at users.sourceforge.net Mon Dec 14 09:08:03 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Mon, 14 Dec 2015 10:08:03 +0100 Subject: [lustre-devel] [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls In-Reply-To: <20151214065325.GS5284@mwanda> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7884.5050407@users.sourceforge.net> <20151214065325.GS5284@mwanda> Message-ID: <566E86F3.9010209@users.sourceforge.net> > Markus, please stop sending these things to rename out labels unless > there is a bug. CodingStyle allows out labels. How does this feedback fit to information like the following? "… Chapter 7: … … Choose label names which say what the goto does or why the goto exists. … Avoid using GW-BASIC names … …" Regards, Markus From dan.carpenter at oracle.com Mon Dec 14 09:31:22 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Mon, 14 Dec 2015 12:31:22 +0300 Subject: [lustre-devel] [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls In-Reply-To: <566E86F3.9010209@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7884.5050407@users.sourceforge.net> <20151214065325.GS5284@mwanda> <566E86F3.9010209@users.sourceforge.net> Message-ID: <20151214093121.GU5284@mwanda> On Mon, Dec 14, 2015 at 10:08:03AM +0100, SF Markus Elfring wrote: > > Markus, please stop sending these things to rename out labels unless > > there is a bug. CodingStyle allows out labels. > > How does this feedback fit to information like the following? > > "… > Chapter 7: … > … > Choose label names which say what the goto does or why the goto exists. A lot of people think "out" says what the goto does and why it exists. I personally don't agree with them but if you look at when I complain about it, it's almost always when it causes a bug. > … Avoid using GW-BASIC names … Those when people just use numbers for their label names instead of words like out1, out2, out4, out5. It's a different thing. regards, dan carpenter From elfring at users.sourceforge.net Mon Dec 14 10:03:23 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Mon, 14 Dec 2015 11:03:23 +0100 Subject: [lustre-devel] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls In-Reply-To: <20151214093121.GU5284@mwanda> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7884.5050407@users.sourceforge.net> <20151214065325.GS5284@mwanda> <566E86F3.9010209@users.sourceforge.net> <20151214093121.GU5284@mwanda> Message-ID: <566E93EB.3000309@users.sourceforge.net> >>> Markus, please stop sending these things to rename out labels unless >>> there is a bug. CodingStyle allows out labels. >> >> How does this feedback fit to information like the following? >> >> "… >> Chapter 7: … >> … >> Choose label names which say what the goto does or why the goto exists. > > A lot of people think "out" says what the goto does and why it exists. I have got the impression that this short identifier is only partly appropriate. > I personally don't agree with them I guess that my opinion goes into a similar direction here. > but if you look at when I complain about it, it's almost always > when it causes a bug. I agree that the combination with bug fixing is more appealing than an attempt to improve coding style applications. >> … Avoid using GW-BASIC names … > > Those when people just use numbers for their label names instead of > words like out1, out2, out4, out5. It's a different thing. The difference is not so clear for me as it appears to you. How many software developers can still remember habits around the selection of such identifiers from GW-BASIC times? Regards, Markus From dan.carpenter at oracle.com Mon Dec 14 11:00:03 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Mon, 14 Dec 2015 14:00:03 +0300 Subject: [lustre-devel] [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection In-Reply-To: <566D7952.7090401@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7952.7090401@users.sourceforge.net> Message-ID: <20151214110003.GV5284@mwanda> On Sun, Dec 13, 2015 at 02:57:38PM +0100, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sun, 13 Dec 2015 12:21:17 +0100 > > A few checks would be performed by the mgc_process_recover_log() function > even if it is known already that the passed variable "pages" contained > a null pointer. > > * Let us return directly if a call of the kcalloc() function failed. > > * Move assignments for the variables "eof" and "req" behind > this memory allocation. Why? Then in the next patch it moves again. It's like cup shuffle to read these patches sometimes. regards, dan carpenter From elfring at users.sourceforge.net Mon Dec 14 12:04:14 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Mon, 14 Dec 2015 13:04:14 +0100 Subject: [lustre-devel] [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection In-Reply-To: <20151214110003.GV5284@mwanda> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7952.7090401@users.sourceforge.net> <20151214110003.GV5284@mwanda> Message-ID: <566EB03E.2000007@users.sourceforge.net> >> A few checks would be performed by the mgc_process_recover_log() function >> even if it is known already that the passed variable "pages" contained >> a null pointer. >> >> * Let us return directly if a call of the kcalloc() function failed. >> >> * Move assignments for the variables "eof" and "req" behind >> this memory allocation. > > Why? The positions of their initialisation depends on the selected exception handling implementation, doesn't it? Can you accept the proposed changes around the affected memory allocations? > Then in the next patch it moves again. This detail is a matter of patch granularity. > It's like cup shuffle to read these patches sometimes. Do you prefer to stash any changes together for a bigger update step? Regards, Markus From dan.carpenter at oracle.com Mon Dec 14 12:38:40 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Mon, 14 Dec 2015 15:38:40 +0300 Subject: [lustre-devel] [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection In-Reply-To: <566EB03E.2000007@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7952.7090401@users.sourceforge.net> <20151214110003.GV5284@mwanda> <566EB03E.2000007@users.sourceforge.net> Message-ID: <20151214123840.GX5284@mwanda> On Mon, Dec 14, 2015 at 01:04:14PM +0100, SF Markus Elfring wrote: > >> A few checks would be performed by the mgc_process_recover_log() function > >> even if it is known already that the passed variable "pages" contained > >> a null pointer. > >> > >> * Let us return directly if a call of the kcalloc() function failed. > >> > >> * Move assignments for the variables "eof" and "req" behind > >> this memory allocation. > > > > Why? > > The positions of their initialisation depends on the selected exception > handling implementation, doesn't it? > > Can you accept the proposed changes around the affected memory allocations? > Just leave it as-is if there is no reason. > > > Then in the next patch it moves again. > > This detail is a matter of patch granularity. > > > > It's like cup shuffle to read these patches sometimes. > > Do you prefer to stash any changes together for a bigger update step? Yes. Patches 5 and 6 would be easier to review if they were folded into one patch. regards, dan carpenter From elfring at users.sourceforge.net Mon Dec 14 12:45:11 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Mon, 14 Dec 2015 13:45:11 +0100 Subject: [lustre-devel] staging: lustre: Less checks in mgc_process_recover_log() after error detection In-Reply-To: <20151214123840.GX5284@mwanda> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7952.7090401@users.sourceforge.net> <20151214110003.GV5284@mwanda> <566EB03E.2000007@users.sourceforge.net> <20151214123840.GX5284@mwanda> Message-ID: <566EB9D7.9090904@users.sourceforge.net> >> Can you accept the proposed changes around the affected memory allocations? > > Just leave it as-is if there is no reason. I suggest to make the implementation of the function "mgc_process_recover_log" a bit more efficient. >> Do you prefer to stash any changes together for a bigger update step? > > Yes. Patches 5 and 6 would be easier to review if they were folded into > one patch. I do not like patch squashing for my update suggestions here. Regards, Markus From dan.carpenter at oracle.com Mon Dec 14 13:57:51 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Mon, 14 Dec 2015 16:57:51 +0300 Subject: [lustre-devel] staging: lustre: Less checks in mgc_process_recover_log() after error detection In-Reply-To: <566EB9D7.9090904@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7952.7090401@users.sourceforge.net> <20151214110003.GV5284@mwanda> <566EB03E.2000007@users.sourceforge.net> <20151214123840.GX5284@mwanda> <566EB9D7.9090904@users.sourceforge.net> Message-ID: <20151214135750.GY5284@mwanda> On Mon, Dec 14, 2015 at 01:45:11PM +0100, SF Markus Elfring wrote: > >> Do you prefer to stash any changes together for a bigger update step? > > > > Yes. Patches 5 and 6 would be easier to review if they were folded into > > one patch. > > I do not like patch squashing for my update suggestions here. I am a maintainer in drivers/staging. I am telling you what you need to do if you want us to apply your patch. What you do with that information is up to you. regards, dan carpenter From elfring at users.sourceforge.net Mon Dec 14 17:43:15 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Mon, 14 Dec 2015 18:43:15 +0100 Subject: [lustre-devel] staging: lustre: Less checks in mgc_process_recover_log() after error detection In-Reply-To: <20151214135750.GY5284@mwanda> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7952.7090401@users.sourceforge.net> <20151214110003.GV5284@mwanda> <566EB03E.2000007@users.sourceforge.net> <20151214123840.GX5284@mwanda> <566EB9D7.9090904@users.sourceforge.net> <20151214135750.GY5284@mwanda> Message-ID: <566EFFB3.708@users.sourceforge.net> >> I do not like patch squashing for my update suggestions here. > > I am a maintainer in drivers/staging. Thanks for this information. > I am telling you what you need to do if you want us to apply your patch. I am still waiting for a bit more constructive feedback for this patch series. How many days should I wait before I should send adjusted update suggestions for this approach? > What you do with that information is up to you. Our software development dialogue seems to trigger special challenges between us so far. Are you generally willing to change the exception handling for the memory allocations in the function "mgc_process_recover_log" at all? Regards, Markus From dan.carpenter at oracle.com Tue Dec 15 11:42:40 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 15 Dec 2015 14:42:40 +0300 Subject: [lustre-devel] staging: lustre: Less checks in mgc_process_recover_log() after error detection In-Reply-To: <566EFFB3.708@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7952.7090401@users.sourceforge.net> <20151214110003.GV5284@mwanda> <566EB03E.2000007@users.sourceforge.net> <20151214123840.GX5284@mwanda> <566EB9D7.9090904@users.sourceforge.net> <20151214135750.GY5284@mwanda> <566EFFB3.708@users.sourceforge.net> Message-ID: <20151215114240.GB5284@mwanda> On Mon, Dec 14, 2015 at 06:43:15PM +0100, SF Markus Elfring wrote: > Our software development dialogue seems to trigger special > challenges between us so far. I try very hard to review patches mechanically and not be biased so that after a while people know if their patches will be merged or not without waiting for feedback. In this case, I had asked you not to send patches renaming out labels and then the next day you sent me a string of patches renaming out labels. If you were a lustre dev then I would accept these renames definitely. But I believe that for anyone else, I would ask them what the point of doing these renames is. I do not think I have been unfair to you. There was no element of surprise. Part of the reason we have CodingStyle is so that we can tell people "That's not in CodingStyle, that's just your own opinion so don't redo code just because you have a different opinion from the maintainer." > Are you generally willing to change the exception handling for > the memory allocations in the function "mgc_process_recover_log" > at all? I like the first patch in this series. I do not like the renames. I don't care too much about patches 5 and 6 except that they should be folded together and you should not move "req" and "eof" around. Mostly I wish you would just focus on fixing bugs instead of these sorts of patches. It is a lot of work for me to explain how to redo patches but it is worth it for bugfixes. regards, dan carpenter From joe at perches.com Tue Dec 15 14:27:56 2015 From: joe at perches.com (Joe Perches) Date: Tue, 15 Dec 2015 06:27:56 -0800 Subject: [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions In-Reply-To: <566D7830.9060000@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7830.9060000@users.sourceforge.net> Message-ID: <1450189676.3551.1.camel@perches.com> On Sun, 2015-12-13 at 14:52 +0100, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sun, 13 Dec 2015 09:30:47 +0100 > > Six goto statements referred to a source code position directly behind them. > Thus omit such unnecessary jumps. I suggest you leave a blank line instead of deleting the goto. > diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c [] > @@ -554,7 +554,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, >   retval = NULL; >   else >   retval = dentry; > - goto out; >   out: >   if (req) >   ptlrpc_req_finished(req); etc.,, From dan.carpenter at oracle.com Tue Dec 15 14:41:34 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 15 Dec 2015 17:41:34 +0300 Subject: [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions In-Reply-To: <1450189676.3551.1.camel@perches.com> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7830.9060000@users.sourceforge.net> <1450189676.3551.1.camel@perches.com> Message-ID: <20151215144133.GC5284@mwanda> On Tue, Dec 15, 2015 at 06:27:56AM -0800, Joe Perches wrote: > On Sun, 2015-12-13 at 14:52 +0100, SF Markus Elfring wrote: > > From: Markus Elfring > > Date: Sun, 13 Dec 2015 09:30:47 +0100 > > > > Six goto statements referred to a source code position directly behind them. > > Thus omit such unnecessary jumps. > > I suggest you leave a blank line instead > of deleting the goto. > What is the point of the little bunny hop? regards, dan carpenter From elfring at users.sourceforge.net Tue Dec 15 15:00:34 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Tue, 15 Dec 2015 16:00:34 +0100 Subject: [lustre-devel] staging: lustre: Less checks in mgc_process_recover_log() after error detection In-Reply-To: <20151215114240.GB5284@mwanda> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7952.7090401@users.sourceforge.net> <20151214110003.GV5284@mwanda> <566EB03E.2000007@users.sourceforge.net> <20151214123840.GX5284@mwanda> <566EB9D7.9090904@users.sourceforge.net> <20151214135750.GY5284@mwanda> <566EFFB3.708@users.sourceforge.net> <20151215114240.GB5284@mwanda> Message-ID: <56702B12.6000805@users.sourceforge.net> > If you were a lustre dev then I would accept these renames definitely. I find this information interesting. Would any more contributors like to share their opinion? > I do not think I have been unfair to you. This view is correct in principle. > There was no element of surprise. I am trying to discuss further "special" update suggestions where the topic focus might evolve to new directions. I got the impression that you had some difficulties already with my previous proposals. So I am unsure about the general change acceptance from you alone. You pointed out that you are maintainer for this software area. I was not so aware about this detail while I noticed that you are very active Linux software developer. (You are not mentioned in the file "MAINTAINERS" for example.) > Part of the reason we have CodingStyle is so that we can tell people > "That's not in CodingStyle, that's just your own opinion so don't redo > code just because you have a different opinion from the maintainer." I find this description reasonable. But I see some challenges to improve the coding style specification. I would appreciate if some items can become less ambiguous and imprecise. I assume that a few recommendations from the script "checkpatch.pl" should also be mentioned there. > >> Are you generally willing to change the exception handling for >> the memory allocations in the function "mgc_process_recover_log" >> at all? > I like the first patch in this series. Thanks for a bit of positive feedback. > I do not like the renames. I guess that this design aspect can be clarified a bit more. > I don't care too much about patches 5 and 6 except that they should be > folded together and you should not move "req" and "eof" around. I can understand this concern better than your first response for these update steps. I might send an adjusted patch series a few days later. > Mostly I wish you would just focus on fixing bugs instead of these sorts > of patches. How often are deviations from the coding style also just ordinary bugs? It seems that changes for this area are occasionally not so attractive in comparison to software improvements for components which are more popular. Regards, Markus From joe at perches.com Tue Dec 15 15:02:31 2015 From: joe at perches.com (Joe Perches) Date: Tue, 15 Dec 2015 07:02:31 -0800 Subject: [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions In-Reply-To: <20151215144133.GC5284@mwanda> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7830.9060000@users.sourceforge.net> <1450189676.3551.1.camel@perches.com> <20151215144133.GC5284@mwanda> Message-ID: <1450191751.3551.14.camel@perches.com> On Tue, 2015-12-15 at 17:41 +0300, Dan Carpenter wrote: > On Tue, Dec 15, 2015 at 06:27:56AM -0800, Joe Perches wrote: > > On Sun, 2015-12-13 at 14:52 +0100, SF Markus Elfring wrote: > > > From: Markus Elfring > > > Date: Sun, 13 Dec 2015 09:30:47 +0100 > > > > > > Six goto statements referred to a source code position directly behind them. > > > Thus omit such unnecessary jumps. > > > > I suggest you leave a blank line instead > > of deleting the goto. > > > > What is the point of the little bunny hop? > > regards, > dan carpenter > -ENOPARSE little bunny hop (though I could have said "just leave a blank line) I think that code blocks are more obvious to read. This is the original code: result = foo(); if (result) goto label; result = bar(); if (result) goto label; result = baz(); if (result) goto label; label: go on... He proposes: result = foo(); if (result) goto label; result = bar(); if (result) goto label; result = baz(); label: go on... I don't find the test->goto label; label: use offensive, but if he does, I think keeping a blank line in place of the test->goto might be better. result = foo(); if (result) goto label; result = bar(); if (result) goto label; result = baz(); label: go on... From simmonsja at ornl.gov Tue Dec 15 17:10:39 2015 From: simmonsja at ornl.gov (Simmons, James A.) Date: Tue, 15 Dec 2015 17:10:39 +0000 Subject: [lustre-devel] [PATCH 21/40] staging: lustre: improve LNet clean up code and API In-Reply-To: <20151202125440.GS18797@mwanda> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-22-git-send-email-jsimmons@infradead.org> <20151202125440.GS18797@mwanda> Message-ID: <05bc05cb164b4d249f74683aef9c9d72@EXCHCS32.ornl.gov> >Actually we're going to have to redo so much code that it's not worth it >for me to review the rest of these patches. Sorry I didn't get back to you sooner but I was on vacation. Thanks for reviewing this work. Especially since this is the first major bug fixing merge for the lustre client which means a lot of pain involved to iron out how to do this. I have been pondering if pushing bug fixes before style cleanups is the right thing to do. I pushed a bunch of bug fixes earlier and none got merged which either means Greg is just backed up and hasn't the time to merge them or style issues are higher priority. Assuming these bug fixes are in scope of the staging tree. Should I continue to push this work first? Well either way I should update this patch series so it ready to merge at some point. >Please just look over everything again: > > BAD: return -1; >GOOD: return -EINVAL; > > BAD: failed0: >GOOD: free_something: > > BAD: if (rc != 0) >GOOD: if (rc) > >Do one thing per patch. >Do not introduce a bug and then fix it in a later patch. >Check ioc_len more carefully. >Don't make the code look ugly just to please checkpatch.pl. >Do error handling not success handling. >Try to avoid indenting a far to the right. Okay. Will start to do the patch cleanup. From dan.carpenter at oracle.com Tue Dec 15 17:41:18 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 15 Dec 2015 20:41:18 +0300 Subject: [lustre-devel] [PATCH 21/40] staging: lustre: improve LNet clean up code and API In-Reply-To: <05bc05cb164b4d249f74683aef9c9d72@EXCHCS32.ornl.gov> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-22-git-send-email-jsimmons@infradead.org> <20151202125440.GS18797@mwanda> <05bc05cb164b4d249f74683aef9c9d72@EXCHCS32.ornl.gov> Message-ID: <20151215174118.GD5284@mwanda> On Tue, Dec 15, 2015 at 05:10:39PM +0000, Simmons, James A. wrote: >I have been pondering if pushing bug fixes before style cleanups > is the right thing to do. Generally push the least controversial patches first so that if you have to redo one patch, then the rest are already applied and don't need to be changed. > I pushed a bunch of bug fixes earlier and none got > merged which either means Greg is just backed up and hasn't the time to > merge them or style issues are higher priority I have no idea which patchset you are talking about so I can't comment. Greg always (except if there is a mistake) applies things in first come first serve order. He doesn't sort them. > Assuming these bug fixes are in scope of the staging tree. Should I > continue to push this work first? You've pushed a bunch of stuff. I don't know which stuff has been applied and which has not. If no one replied to it and there isn't a dire issue such as a compile failure or it doesn't apply then Greg is likely to apply it. He doesn't silently patches, so you will get an email either way. regards, dan carpenter From dan.carpenter at oracle.com Tue Dec 15 17:48:44 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 15 Dec 2015 20:48:44 +0300 Subject: [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions In-Reply-To: <1450191751.3551.14.camel@perches.com> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7830.9060000@users.sourceforge.net> <1450189676.3551.1.camel@perches.com> <20151215144133.GC5284@mwanda> <1450191751.3551.14.camel@perches.com> Message-ID: <20151215174844.GE5284@mwanda> On Tue, Dec 15, 2015 at 07:02:31AM -0800, Joe Perches wrote: > This is the original code: > > result = foo(); > if (result) > goto label; > > result = bar(); > if (result) > goto label; > > result = baz(); > if (result) > goto label; > > label: > go on... > No. There is no test. The original code looks like: result = foo(); if (result) goto out; result = baz(); goto out; out: go on.. regards, dan carpenter From elfring at users.sourceforge.net Tue Dec 15 18:02:44 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Tue, 15 Dec 2015 19:02:44 +0100 Subject: [lustre-devel] staging: lustre: Delete unnecessary goto statements in six functions In-Reply-To: <1450191751.3551.14.camel@perches.com> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7830.9060000@users.sourceforge.net> <1450189676.3551.1.camel@perches.com> <20151215144133.GC5284@mwanda> <1450191751.3551.14.camel@perches.com> Message-ID: <567055C4.8000806@users.sourceforge.net> > This is the original code: Really …? > result = baz(); > if (result) > goto label; > > label: > go on... I do not see such a source code structure at the six places I propose to clean-up. > I don't find the test->goto label; label: use offensive, > but if he does, I think keeping a blank line in place of > the test->goto might be better. I find this an interesting view on source code layout. Are there any more opinions around such implementation details? Regards, Markus From simmonsja at ornl.gov Tue Dec 15 18:08:44 2015 From: simmonsja at ornl.gov (Simmons, James A.) Date: Tue, 15 Dec 2015 18:08:44 +0000 Subject: [lustre-devel] [PATCH 02/40] staging: lustre: fix 'NULL pointer dereference' errors for LNet In-Reply-To: <20151202074617.GI18797@mwanda> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-3-git-send-email-jsimmons@infradead.org> <20151202074617.GI18797@mwanda> Message-ID: <2d1f3c4a4b50489896fcc6f703768bb0@EXCHCS32.ornl.gov> >> diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c >> index 556c837..2ca7d0e 100644 >> --- a/drivers/staging/lustre/lnet/selftest/conctl.c >> +++ b/drivers/staging/lustre/lnet/selftest/conctl.c >> @@ -679,45 +679,46 @@ static int >> lst_stat_query_ioctl(lstio_stat_args_t *args) >> { >> int rc; >> - char *name; >> + char *name = NULL; >> >> /* TODO: not finished */ >> if (args->lstio_sta_key != console_session.ses_key) >> return -EACCES; >> >> - if (args->lstio_sta_resultp == NULL || >> - (args->lstio_sta_namep == NULL && >> - args->lstio_sta_idsp == NULL) || >> - args->lstio_sta_nmlen <= 0 || >> - args->lstio_sta_nmlen > LST_NAME_SIZE) >> - return -EINVAL; >> - >> - if (args->lstio_sta_idsp != NULL && >> - args->lstio_sta_count <= 0) >> + if (!args->lstio_sta_resultp) >> return -EINVAL; >> >> - LIBCFS_ALLOC(name, args->lstio_sta_nmlen + 1); >> - if (name == NULL) >> - return -ENOMEM; >> - >> - if (copy_from_user(name, args->lstio_sta_namep, >> - args->lstio_sta_nmlen)) { >> - LIBCFS_FREE(name, args->lstio_sta_nmlen + 1); >> - return -EFAULT; >> - } >> + if (args->lstio_sta_idsp) { >> + if (args->lstio_sta_count <= 0) >> + return -EINVAL; >> >> - if (args->lstio_sta_idsp == NULL) { >> - rc = lstcon_group_stat(name, args->lstio_sta_timeout, >> - args->lstio_sta_resultp); >> - } else { >> rc = lstcon_nodes_stat(args->lstio_sta_count, >> args->lstio_sta_idsp, >> args->lstio_sta_timeout, >> args->lstio_sta_resultp); >> - } >> + } else if (args->lstio_sta_namep) { >> + if (args->lstio_sta_nmlen <= 0 || >> + args->lstio_sta_nmlen > LST_NAME_SIZE) >> + return -EINVAL; >> + >> + LIBCFS_ALLOC(name, args->lstio_sta_nmlen + 1); >> + if (!name) >> + return -ENOMEM; >> >> - LIBCFS_FREE(name, args->lstio_sta_nmlen + 1); >> + rc = copy_from_user(name, args->lstio_sta_namep, >> + args->lstio_sta_nmlen); >> + if (!rc) >> + rc = lstcon_group_stat(name, args->lstio_sta_timeout, >> + args->lstio_sta_resultp); >> + else >> + rc = -EFAULT; >> >> + } else { >> + rc = -EINVAL; >> + } >> + >> + if (name) >> + LIBCFS_FREE(name, args->lstio_sta_nmlen + 1); > >There is no bug fix here. This code was fine when it was merged into >the kernel in 2013 so I have no idea how out of date the static checker >warning is... The new code doesn't do unnecessary allocations so that's >good but "name" should be declared in the block where it is used instead >of at the start of the function. Btw, we assume that the user gives us >a NUL terminated string for "name" so we should fix that bug as well. > >TODO: lustre: don't assume "name" is NUL terminated Ugh. I see breakage everywhere in this code :-( Need to address. I think we should convert that to strcpy_to_user as well. From joe at perches.com Tue Dec 15 18:10:11 2015 From: joe at perches.com (Joe Perches) Date: Tue, 15 Dec 2015 10:10:11 -0800 Subject: [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions In-Reply-To: <20151215174844.GE5284@mwanda> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7830.9060000@users.sourceforge.net> <1450189676.3551.1.camel@perches.com> <20151215144133.GC5284@mwanda> <1450191751.3551.14.camel@perches.com> <20151215174844.GE5284@mwanda> Message-ID: <1450203011.4142.4.camel@perches.com> On Tue, 2015-12-15 at 20:48 +0300, Dan Carpenter wrote: > On Tue, Dec 15, 2015 at 07:02:31AM -0800, Joe Perches wrote: > > This is the original code: > > > > result = foo(); > > if (result) > > goto label; > > > > result = bar(); > > if (result) > > goto label; > > > > result = baz(); > > if (result) > > goto label; > > > > label: > > go on... > > > > No.  There is no test.  The original code looks like: > > result = foo(); > if (result) > goto out; > result = baz(); > goto out; > out: > go on.. > > regards, > dan carpenter Here is the original code: --------------------- /* Copy hsm_progress struct */ req_hpk = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_PROGRESS); if (req_hpk == NULL) { rc = -EPROTO; goto out; } *req_hpk = *hpk; req_hpk->hpk_errval = lustre_errno_hton(hpk->hpk_errval); ptlrpc_request_set_replen(req); rc = mdc_queue_wait(req); goto out; out: ptlrpc_req_finished(req); return rc; } --------------------- I think if the last goto out; is to be removed, then it should be replaced by a blank line. It separates the last operation block from the return. cheers, Joe From simmonsja at ornl.gov Tue Dec 15 18:14:19 2015 From: simmonsja at ornl.gov (Simmons, James A.) Date: Tue, 15 Dec 2015 18:14:19 +0000 Subject: [lustre-devel] [PATCH 13/40] staging: lustre: Dynamic LNet Configuration (DLC) show command In-Reply-To: <20151202112055.GM18797@mwanda> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-14-git-send-email-jsimmons@infradead.org> <20151202112055.GM18797@mwanda> Message-ID: <944b6e806bc44a3fa4d6d5e1904a894a@EXCHCS32.ornl.gov> >> struct libcfs_ioctl_hdr { >> __u32 ioc_len; >> @@ -87,6 +88,13 @@ do { \ >> data.ioc_hdr.ioc_len = sizeof(data); \ >> } while (0) >> >> +#define LIBCFS_IOC_INIT_V2(data, hdr) \ >> +do { \ >> + memset(&(data), 0, sizeof(data)); \ >> + (data).hdr.ioc_version = LIBCFS_IOCTL_VERSION2; \ >> + (data).hdr.ioc_len = sizeof(data); \ >> +} while (0) >> + > >Do we really need this? Would you be okay if this was a inline function? This is used by user land and kernel space code. From dan.carpenter at oracle.com Tue Dec 15 18:19:32 2015 From: dan.carpenter at oracle.com (Dan Carpenter) Date: Tue, 15 Dec 2015 21:19:32 +0300 Subject: [lustre-devel] [PATCH 13/40] staging: lustre: Dynamic LNet Configuration (DLC) show command In-Reply-To: <944b6e806bc44a3fa4d6d5e1904a894a@EXCHCS32.ornl.gov> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-14-git-send-email-jsimmons@infradead.org> <20151202112055.GM18797@mwanda> <944b6e806bc44a3fa4d6d5e1904a894a@EXCHCS32.ornl.gov> Message-ID: <20151215181932.GH5177@mwanda> On Tue, Dec 15, 2015 at 06:14:19PM +0000, Simmons, James A. wrote: > > >> struct libcfs_ioctl_hdr { > >> __u32 ioc_len; > >> @@ -87,6 +88,13 @@ do { \ > >> data.ioc_hdr.ioc_len = sizeof(data); \ > >> } while (0) > >> > >> +#define LIBCFS_IOC_INIT_V2(data, hdr) \ > >> +do { \ > >> + memset(&(data), 0, sizeof(data)); \ > >> + (data).hdr.ioc_version = LIBCFS_IOCTL_VERSION2; \ > >> + (data).hdr.ioc_len = sizeof(data); \ > >> +} while (0) > >> + > > > >Do we really need this? > > Would you be okay if this was a inline function? This is used by user land and kernel space code. > I try (not very hard) to sound like a broken record but this business of sharing code with userland is a pain in the butt. It's not used in the kernel or in any patches you have sent. It would look better as an inline function though so I wouldn't have even noticed it. regards, dan carpenter From joe at perches.com Tue Dec 15 18:22:07 2015 From: joe at perches.com (Joe Perches) Date: Tue, 15 Dec 2015 10:22:07 -0800 Subject: [lustre-devel] staging: lustre: Delete unnecessary goto statements in six functions In-Reply-To: <567055C4.8000806@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7830.9060000@users.sourceforge.net> <1450189676.3551.1.camel@perches.com> <20151215144133.GC5284@mwanda> <1450191751.3551.14.camel@perches.com> <567055C4.8000806@users.sourceforge.net> Message-ID: <1450203727.4142.13.camel@perches.com> On Tue, 2015-12-15 at 19:02 +0100, SF Markus Elfring wrote: > > This is the original code: > Really …? > > result = baz(); > > if (result) > > goto label; > > > > label: > > go on... > > I do not see such a source code structure > at the six places I propose to clean-up. > > > > I don't find the test->goto label; label: use offensive, > > but if he does, I think keeping a blank line in place of > > the test->goto might be better. > > I find this an interesting view on source code layout. > Are there any more opinions around such implementation details? Or to put it another way, use a blank line before the first or only label in an error/out block. I don't find it different then commonly written blocks like: void foo(void) { ...; wind1(); val = func1(...); if (val) { printk(...); goto err_type; } wind2(); val = func2(...); if (val) { printk(...); goto err_type2; } ... return 0; err_type2: unwind2(); err_type: unwind1(); return -ERR; } Yes, you can elide all the blank lines, but using them can help readability. From elfring at users.sourceforge.net Tue Dec 15 18:26:57 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Tue, 15 Dec 2015 19:26:57 +0100 Subject: [lustre-devel] staging: lustre: Delete unnecessary goto statements in six functions In-Reply-To: <1450203011.4142.4.camel@perches.com> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7830.9060000@users.sourceforge.net> <1450189676.3551.1.camel@perches.com> <20151215144133.GC5284@mwanda> <1450191751.3551.14.camel@perches.com> <20151215174844.GE5284@mwanda> <1450203011.4142.4.camel@perches.com> Message-ID: <56705B71.6090307@users.sourceforge.net> > rc = mdc_queue_wait(req); > goto out; > out: > ptlrpc_req_finished(req); > return rc; > } > --------------------- > > I think if the last goto out; is to be removed, > then it should be replaced by a blank line. > > It separates the last operation block from the return. Would you like to point a very specific coding style issue out? How often should jump labels preceded with blank lines? Regards, Markus From joe at perches.com Tue Dec 15 18:34:11 2015 From: joe at perches.com (Joe Perches) Date: Tue, 15 Dec 2015 10:34:11 -0800 Subject: [lustre-devel] staging: lustre: Delete unnecessary goto statements in six functions In-Reply-To: <56705B71.6090307@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7830.9060000@users.sourceforge.net> <1450189676.3551.1.camel@perches.com> <20151215144133.GC5284@mwanda> <1450191751.3551.14.camel@perches.com> <20151215174844.GE5284@mwanda> <1450203011.4142.4.camel@perches.com> <56705B71.6090307@users.sourceforge.net> Message-ID: <1450204451.4142.19.camel@perches.com> On Tue, 2015-12-15 at 19:26 +0100, SF Markus Elfring wrote: > > rc = mdc_queue_wait(req); > > goto out; > > out: > > ptlrpc_req_finished(req); > > return rc; > > } > > --------------------- > > > > I think if the last goto out; is to be removed, > > then it should be replaced by a blank line. > > > > It separates the last operation block from the return. > > Would you like to point a very specific coding style issue out? Other than using vertical separation can help readability? I think there should _not_ be a hardened rule. Style is just a guide.  Do what you think appropriate. > How often should jump labels preceded with blank lines? When other nearby blocks are also separated by blank lines. Localized consistency can be useful. Inconsistency can make code harder to follow/predict. From simmonsja at ornl.gov Tue Dec 15 18:39:07 2015 From: simmonsja at ornl.gov (Simmons, James A.) Date: Tue, 15 Dec 2015 18:39:07 +0000 Subject: [lustre-devel] [PATCH 13/40] staging: lustre: Dynamic LNet Configuration (DLC) show command In-Reply-To: <20151215181932.GH5177@mwanda> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-14-git-send-email-jsimmons@infradead.org> <20151202112055.GM18797@mwanda> <944b6e806bc44a3fa4d6d5e1904a894a@EXCHCS32.ornl.gov> <20151215181932.GH5177@mwanda> Message-ID: <5a754fcb1c2f42cba72b558e41d03828@EXCHCS32.ornl.gov> >On Tue, Dec 15, 2015 at 06:14:19PM +0000, Simmons, James A. wrote: >> >> >> struct libcfs_ioctl_hdr { >> >> __u32 ioc_len; >> >> @@ -87,6 +88,13 @@ do { \ >> >> data.ioc_hdr.ioc_len = sizeof(data); \ >> >> } while (0) >> >> >> >> +#define LIBCFS_IOC_INIT_V2(data, hdr) \ >> >> +do { \ >> >> + memset(&(data), 0, sizeof(data)); \ >> >> + (data).hdr.ioc_version = LIBCFS_IOCTL_VERSION2; \ >> >> + (data).hdr.ioc_len = sizeof(data); \ >> >> +} while (0) >> >> + >> > >> >Do we really need this? >> >> Would you be okay if this was a inline function? This is used by user land and kernel space code. >> > >I try (not very hard) to sound like a broken record but this business of >sharing code with userland is a pain in the butt. It's not used in the >kernel or in any patches you have sent. > >It would look better as an inline function though so I wouldn't have >even noticed it. I'm glad you noticed. I just looked at the production source code and yep it is only used in the userland tools code. I need to update our tools so they don't break. Then we can remove these macros. From gregkh at linuxfoundation.org Tue Dec 15 18:48:03 2015 From: gregkh at linuxfoundation.org (Greg KH) Date: Tue, 15 Dec 2015 10:48:03 -0800 Subject: [lustre-devel] [PATCH] staging: lustre: fix address space mismatches In-Reply-To: <20151215165045.GA5213@bytefire-computer> References: <20151215165045.GA5213@bytefire-computer> Message-ID: <20151215184803.GB16129@kroah.com> On Tue, Dec 15, 2015 at 04:50:45PM +0000, Okash Khawaja wrote: > This patch fixes address space warnings from sparse. Function > lprocfs_write_helper() accepts user space buffer but was being > passed kernel space buffer by these functions: > > contention_seconds_store() > lockless_truncate_store() > > Since these functions are used to implement show and store functions of > lustre_attr object and since lustre_attr object is used to implement object > inheritance through use of `container_of`, the address space warnings > show up at multiple places inside driver's code base. > > This patch creates a user space version of lustre_attr object lustre_attr_u. > Keeping function names and signatures same - other than the __user attribute - > ensures that object inheritance continues to work as it was, but address > space discrepency is removed. That removes a whole bunch of address > space warnings. > > Signed-off-by: Okash Khawaja > --- > drivers/staging/lustre/lustre/include/lprocfs_status.h | 16 ++++++++++++++++ > drivers/staging/lustre/lustre/osc/lproc_osc.c | 12 ++++++------ > 2 files changed, 22 insertions(+), 6 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h > index f18c0c7..df6d9d5 100644 > --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h > +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h > @@ -698,6 +698,22 @@ static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store) > #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL) > #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store) > > +struct lustre_attr_u { > + struct attribute attr; > + ssize_t (*show)(struct kobject *kobj, struct attribute *attr, > + char *buf); > + ssize_t (*store)(struct kobject *kobj, struct attribute *attr, > + const char __user *buf, size_t len); sysfs files do not have __user pointers, something is really wrong here if that's the solution :( See the other comments in the mailing list archives for how messed up the __user and kernel pointers are in lustre, and how I'd not recommend anyone trying to fix them, unless you are a lustre developer and can test all of your changes... sorry, greg k-h From gregkh at linuxfoundation.org Tue Dec 15 18:48:42 2015 From: gregkh at linuxfoundation.org (Greg Kroah-Hartman) Date: Tue, 15 Dec 2015 10:48:42 -0800 Subject: [lustre-devel] [PATCH 13/40] staging: lustre: Dynamic LNet Configuration (DLC) show command In-Reply-To: <944b6e806bc44a3fa4d6d5e1904a894a@EXCHCS32.ornl.gov> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-14-git-send-email-jsimmons@infradead.org> <20151202112055.GM18797@mwanda> <944b6e806bc44a3fa4d6d5e1904a894a@EXCHCS32.ornl.gov> Message-ID: <20151215184842.GC16129@kroah.com> On Tue, Dec 15, 2015 at 06:14:19PM +0000, Simmons, James A. wrote: > > >> struct libcfs_ioctl_hdr { > >> __u32 ioc_len; > >> @@ -87,6 +88,13 @@ do { \ > >> data.ioc_hdr.ioc_len = sizeof(data); \ > >> } while (0) > >> > >> +#define LIBCFS_IOC_INIT_V2(data, hdr) \ > >> +do { \ > >> + memset(&(data), 0, sizeof(data)); \ > >> + (data).hdr.ioc_version = LIBCFS_IOCTL_VERSION2; \ > >> + (data).hdr.ioc_len = sizeof(data); \ > >> +} while (0) > >> + > > > >Do we really need this? > > Would you be okay if this was a inline function? This is used by user > land and kernel space code. Then your code is broken, please never do that. From elfring at users.sourceforge.net Tue Dec 15 18:49:39 2015 From: elfring at users.sourceforge.net (SF Markus Elfring) Date: Tue, 15 Dec 2015 19:49:39 +0100 Subject: [lustre-devel] staging: lustre: Delete unnecessary goto statements in six functions In-Reply-To: <1450204451.4142.19.camel@perches.com> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7830.9060000@users.sourceforge.net> <1450189676.3551.1.camel@perches.com> <20151215144133.GC5284@mwanda> <1450191751.3551.14.camel@perches.com> <20151215174844.GE5284@mwanda> <1450203011.4142.4.camel@perches.com> <56705B71.6090307@users.sourceforge.net> <1450204451.4142.19.camel@perches.com> Message-ID: <567060C3.5070608@users.sourceforge.net> > I think there should _not_ be a hardened rule. I guess that it can become hard to achieve consensus on a precise rule. > Style is just a guide. Generally nice … > Do what you think appropriate. I'm sorry for my evolving understanding. - But I imagine that your feedback can cause further software development troubles if the acceptance for this update suggestion will really depend on the number of blank lines before a jump label. Regards, Markus From joe at perches.com Tue Dec 15 18:55:11 2015 From: joe at perches.com (Joe Perches) Date: Tue, 15 Dec 2015 10:55:11 -0800 Subject: [lustre-devel] staging: lustre: Delete unnecessary goto statements in six functions In-Reply-To: <567060C3.5070608@users.sourceforge.net> References: <566ABCD9.1060404@users.sourceforge.net> <566D7733.1030102@users.sourceforge.net> <566D7830.9060000@users.sourceforge.net> <1450189676.3551.1.camel@perches.com> <20151215144133.GC5284@mwanda> <1450191751.3551.14.camel@perches.com> <20151215174844.GE5284@mwanda> <1450203011.4142.4.camel@perches.com> <56705B71.6090307@users.sourceforge.net> <1450204451.4142.19.camel@perches.com> <567060C3.5070608@users.sourceforge.net> Message-ID: <1450205711.4142.23.camel@perches.com> On Tue, 2015-12-15 at 19:49 +0100, SF Markus Elfring wrote: > > I think there should _not_ be a hardened rule. > I guess that it can become hard to achieve consensus on a precise rule. Consensus isn't unanimity. > I imagine that your feedback > can cause further software development troubles if the acceptance for > this update suggestion will really depend on the number of blank lines > before a jump label. The author of any particular bit of code can do whatever they want. Localized consistency is probably more valuable than global consistency. From okash.khawaja at gmail.com Tue Dec 15 16:50:45 2015 From: okash.khawaja at gmail.com (Okash Khawaja) Date: Tue, 15 Dec 2015 16:50:45 +0000 Subject: [lustre-devel] [PATCH] staging: lustre: fix address space mismatches Message-ID: <20151215165045.GA5213@bytefire-computer> This patch fixes address space warnings from sparse. Function lprocfs_write_helper() accepts user space buffer but was being passed kernel space buffer by these functions: contention_seconds_store() lockless_truncate_store() Since these functions are used to implement show and store functions of lustre_attr object and since lustre_attr object is used to implement object inheritance through use of `container_of`, the address space warnings show up at multiple places inside driver's code base. This patch creates a user space version of lustre_attr object lustre_attr_u. Keeping function names and signatures same - other than the __user attribute - ensures that object inheritance continues to work as it was, but address space discrepency is removed. That removes a whole bunch of address space warnings. Signed-off-by: Okash Khawaja --- drivers/staging/lustre/lustre/include/lprocfs_status.h | 16 ++++++++++++++++ drivers/staging/lustre/lustre/osc/lproc_osc.c | 12 ++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index f18c0c7..df6d9d5 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -698,6 +698,22 @@ static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store) #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL) #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store) +struct lustre_attr_u { + struct attribute attr; + ssize_t (*show)(struct kobject *kobj, struct attribute *attr, + char *buf); + ssize_t (*store)(struct kobject *kobj, struct attribute *attr, + const char __user *buf, size_t len); +}; + +#define LUSTRE_ATTR_U(name, mode, show, store) \ +static struct lustre_attr_u lustre_attr_u_##name = __ATTR(name, mode, show, \ + store) + +#define LUSTRE_RO_ATTR_U(name) LUSTRE_ATTR_U(name, 0444, name##_show, NULL) +#define LUSTRE_RW_ATTR_U(name) LUSTRE_ATTR_U(name, 0644, name##_show, \ + name##_store) + extern const struct sysfs_ops lustre_sysfs_ops; /* all quota proc functions */ diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c index c4d44e7..dd80780 100644 --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c @@ -474,7 +474,7 @@ static ssize_t contention_seconds_show(struct kobject *kobj, static ssize_t contention_seconds_store(struct kobject *kobj, struct attribute *attr, - const char *buffer, + const char __user *buffer, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, @@ -484,7 +484,7 @@ static ssize_t contention_seconds_store(struct kobject *kobj, return lprocfs_write_helper(buffer, count, &od->od_contention_time) ?: count; } -LUSTRE_RW_ATTR(contention_seconds); +LUSTRE_RW_ATTR_U(contention_seconds); static ssize_t lockless_truncate_show(struct kobject *kobj, struct attribute *attr, @@ -499,7 +499,7 @@ static ssize_t lockless_truncate_show(struct kobject *kobj, static ssize_t lockless_truncate_store(struct kobject *kobj, struct attribute *attr, - const char *buffer, + const char __user *buffer, size_t count) { struct obd_device *obd = container_of(kobj, struct obd_device, @@ -509,7 +509,7 @@ static ssize_t lockless_truncate_store(struct kobject *kobj, return lprocfs_write_helper(buffer, count, &od->od_lockless_truncate) ?: count; } -LUSTRE_RW_ATTR(lockless_truncate); +LUSTRE_RW_ATTR_U(lockless_truncate); static ssize_t destroys_in_flight_show(struct kobject *kobj, struct attribute *attr, @@ -766,13 +766,13 @@ int lproc_osc_attach_seqstat(struct obd_device *dev) static struct attribute *osc_attrs[] = { &lustre_attr_active.attr, &lustre_attr_checksums.attr, - &lustre_attr_contention_seconds.attr, + &lustre_attr_u_contention_seconds.attr, &lustre_attr_cur_dirty_bytes.attr, &lustre_attr_cur_grant_bytes.attr, &lustre_attr_cur_lost_grant_bytes.attr, &lustre_attr_destroys_in_flight.attr, &lustre_attr_grant_shrink_interval.attr, - &lustre_attr_lockless_truncate.attr, + &lustre_attr_u_lockless_truncate.attr, &lustre_attr_max_dirty_mb.attr, &lustre_attr_max_pages_per_rpc.attr, &lustre_attr_max_rpcs_in_flight.attr, -- 2.5.2 From simmonsja at ornl.gov Tue Dec 15 19:48:22 2015 From: simmonsja at ornl.gov (Simmons, James A.) Date: Tue, 15 Dec 2015 19:48:22 +0000 Subject: [lustre-devel] [PATCH 13/40] staging: lustre: Dynamic LNet Configuration (DLC) show command In-Reply-To: <20151215184842.GC16129@kroah.com> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-14-git-send-email-jsimmons@infradead.org> <20151202112055.GM18797@mwanda> <944b6e806bc44a3fa4d6d5e1904a894a@EXCHCS32.ornl.gov> <20151215184842.GC16129@kroah.com> Message-ID: <478967481871457488a1ea289237c7ab@EXCHCS32.ornl.gov> >On Tue, Dec 15, 2015 at 06:14:19PM +0000, Simmons, James A. wrote: >> >> >> struct libcfs_ioctl_hdr { >> >> __u32 ioc_len; >> >> @@ -87,6 +88,13 @@ do { \ >> >> data.ioc_hdr.ioc_len = sizeof(data); \ >> >> } while (0) >> >> >> >> +#define LIBCFS_IOC_INIT_V2(data, hdr) \ >> >> +do { \ >> >> + memset(&(data), 0, sizeof(data)); \ >> >> + (data).hdr.ioc_version = LIBCFS_IOCTL_VERSION2; \ >> >> + (data).hdr.ioc_len = sizeof(data); \ >> >> +} while (0) >> >> + >> > >> >Do we really need this? >> >> Would you be okay if this was a inline function? This is used by user >> land and kernel space code. > >Then your code is broken, please never do that. This brings up a good point. This header doesn't contain structures for userland so it is a uapi type header. Should such headers only contain data structures? From gregkh at linuxfoundation.org Tue Dec 15 19:55:45 2015 From: gregkh at linuxfoundation.org ('Greg Kroah-Hartman') Date: Tue, 15 Dec 2015 11:55:45 -0800 Subject: [lustre-devel] [PATCH 13/40] staging: lustre: Dynamic LNet Configuration (DLC) show command In-Reply-To: <478967481871457488a1ea289237c7ab@EXCHCS32.ornl.gov> References: <1448062576-23757-1-git-send-email-jsimmons@infradead.org> <1448062576-23757-14-git-send-email-jsimmons@infradead.org> <20151202112055.GM18797@mwanda> <944b6e806bc44a3fa4d6d5e1904a894a@EXCHCS32.ornl.gov> <20151215184842.GC16129@kroah.com> <478967481871457488a1ea289237c7ab@EXCHCS32.ornl.gov> Message-ID: <20151215195545.GA22077@kroah.com> On Tue, Dec 15, 2015 at 07:48:22PM +0000, Simmons, James A. wrote: > >On Tue, Dec 15, 2015 at 06:14:19PM +0000, Simmons, James A. wrote: > >> > >> >> struct libcfs_ioctl_hdr { > >> >> __u32 ioc_len; > >> >> @@ -87,6 +88,13 @@ do { \ > >> >> data.ioc_hdr.ioc_len = sizeof(data); \ > >> >> } while (0) > >> >> > >> >> +#define LIBCFS_IOC_INIT_V2(data, hdr) \ > >> >> +do { \ > >> >> + memset(&(data), 0, sizeof(data)); \ > >> >> + (data).hdr.ioc_version = LIBCFS_IOCTL_VERSION2; \ > >> >> + (data).hdr.ioc_len = sizeof(data); \ > >> >> +} while (0) > >> >> + > >> > > >> >Do we really need this? > >> > >> Would you be okay if this was a inline function? This is used by user > >> land and kernel space code. > > > >Then your code is broken, please never do that. > > This brings up a good point. This header doesn't contain structures for userland so it is a uapi > type header. Should such headers only contain data structures? Yes, that would make more sense. thanks, greg k-h From okash.khawaja at gmail.com Tue Dec 15 20:34:34 2015 From: okash.khawaja at gmail.com (Okash Khawaja) Date: Tue, 15 Dec 2015 20:34:34 +0000 Subject: [lustre-devel] [PATCH] staging: lustre: fix address space mismatches In-Reply-To: <20151215184803.GB16129@kroah.com> References: <20151215165045.GA5213@bytefire-computer> <20151215184803.GB16129@kroah.com> Message-ID: <5612F531-9472-4E61-976D-44D116EF3C1F@gmail.com> > On 15 Dec 2015, at 18:48, Greg KH wrote: > >> On Tue, Dec 15, 2015 at 04:50:45PM +0000, Okash Khawaja wrote: >> This patch fixes address space warnings from sparse. Function >> lprocfs_write_helper() accepts user space buffer but was being >> passed kernel space buffer by these functions: >> >> contention_seconds_store() >> lockless_truncate_store() >> >> Since these functions are used to implement show and store functions of >> lustre_attr object and since lustre_attr object is used to implement object >> inheritance through use of `container_of`, the address space warnings >> show up at multiple places inside driver's code base. >> >> This patch creates a user space version of lustre_attr object lustre_attr_u. >> Keeping function names and signatures same - other than the __user attribute - >> ensures that object inheritance continues to work as it was, but address >> space discrepency is removed. That removes a whole bunch of address >> space warnings. >> >> Signed-off-by: Okash Khawaja >> --- >> drivers/staging/lustre/lustre/include/lprocfs_status.h | 16 ++++++++++++++++ >> drivers/staging/lustre/lustre/osc/lproc_osc.c | 12 ++++++------ >> 2 files changed, 22 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h >> index f18c0c7..df6d9d5 100644 >> --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h >> +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h >> @@ -698,6 +698,22 @@ static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store) >> #define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL) >> #define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store) >> >> +struct lustre_attr_u { >> + struct attribute attr; >> + ssize_t (*show)(struct kobject *kobj, struct attribute *attr, >> + char *buf); >> + ssize_t (*store)(struct kobject *kobj, struct attribute *attr, >> + const char __user *buf, size_t len); > > sysfs files do not have __user pointers, something is really wrong here > if that's the solution :( > > See the other comments in the mailing list archives for how messed up > the __user and kernel pointers are in lustre, and how I'd not recommend > anyone trying to fix them, unless you are a lustre developer and can > test all of your changes... > > sorry, > > greg k-h I see. Thanks for getting back promptly. Okash From shraddha.6596 at gmail.com Wed Dec 16 17:40:14 2015 From: shraddha.6596 at gmail.com (Shraddha) Date: Wed, 16 Dec 2015 23:10:14 +0530 Subject: [lustre-devel] [PATCH 0/3] Staging: lustre: Remove unused code Message-ID: <1450287617-7682-1-git-send-email-shraddha.6596@gmail.com> From: Shraddha Barke Remove unused functions. Shraddha Barke (3): Staging: lustre: include: Remove unused llog_backup declaration Staging: lustre: include: Remove unused md_should_create Staging: lustre: lnet: Remove functions LNetEQWait and LNetEQGet drivers/staging/lustre/include/linux/lnet/api.h | 6 ------ drivers/staging/lustre/lnet/lnet/lib-eq.c | 18 ------------------ drivers/staging/lustre/lustre/include/lustre_log.h | 3 --- drivers/staging/lustre/lustre/include/lustre_mds.h | 6 ------ 4 files changed, 33 deletions(-) -- 2.1.4 From shraddha.6596 at gmail.com Wed Dec 16 17:40:15 2015 From: shraddha.6596 at gmail.com (Shraddha) Date: Wed, 16 Dec 2015 23:10:15 +0530 Subject: [lustre-devel] [PATCH 1/3] Staging: lustre: include: Remove unused llog_backup declaration In-Reply-To: <1450287617-7682-1-git-send-email-shraddha.6596@gmail.com> References: <1450287617-7682-1-git-send-email-shraddha.6596@gmail.com> Message-ID: <1450287617-7682-2-git-send-email-shraddha.6596@gmail.com> From: Shraddha Barke Function llog_backup is declared in header file but not used. Thus remove it. Signed-off-by: Shraddha Barke --- drivers/staging/lustre/lustre/include/lustre_log.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_log.h b/drivers/staging/lustre/lustre/include/lustre_log.h index 1de0c4d..35196c4 100644 --- a/drivers/staging/lustre/lustre/include/lustre_log.h +++ b/drivers/staging/lustre/lustre/include/lustre_log.h @@ -94,9 +94,6 @@ int llog_open(const struct lu_env *env, struct llog_ctxt *ctxt, struct llog_handle **lgh, struct llog_logid *logid, char *name, enum llog_open_param open_param); int llog_close(const struct lu_env *env, struct llog_handle *cathandle); -int llog_backup(const struct lu_env *env, struct obd_device *obd, - struct llog_ctxt *ctxt, struct llog_ctxt *bak_ctxt, - char *name, char *backup); /* llog_process flags */ #define LLOG_FLAG_NODEAMON 0x0001 -- 2.1.4 From shraddha.6596 at gmail.com Wed Dec 16 17:40:16 2015 From: shraddha.6596 at gmail.com (Shraddha) Date: Wed, 16 Dec 2015 23:10:16 +0530 Subject: [lustre-devel] [PATCH 2/3] Staging: lustre: include: Remove unused md_should_create In-Reply-To: <1450287617-7682-1-git-send-email-shraddha.6596@gmail.com> References: <1450287617-7682-1-git-send-email-shraddha.6596@gmail.com> Message-ID: <1450287617-7682-3-git-send-email-shraddha.6596@gmail.com> From: Shraddha Barke Function md_should_create is defined but not used. Thus remove it. Signed-off-by: Shraddha Barke --- drivers/staging/lustre/lustre/include/lustre_mds.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/lustre_mds.h b/drivers/staging/lustre/lustre/include/lustre_mds.h index a16eb8b..95d27dd 100644 --- a/drivers/staging/lustre/lustre/include/lustre_mds.h +++ b/drivers/staging/lustre/lustre/include/lustre_mds.h @@ -62,12 +62,6 @@ struct mds_group_info { #define MDD_OBD_NAME "mdd_obd" #define MDD_OBD_UUID "mdd_obd_uuid" -static inline int md_should_create(__u64 flags) -{ - return !(flags & MDS_OPEN_DELAY_CREATE || - !(flags & FMODE_WRITE)); -} - /* these are local flags, used only on the client, private */ #define M_CHECK_STALE 0200000000 -- 2.1.4 From shraddha.6596 at gmail.com Wed Dec 16 17:40:17 2015 From: shraddha.6596 at gmail.com (Shraddha) Date: Wed, 16 Dec 2015 23:10:17 +0530 Subject: [lustre-devel] [PATCH 3/3] Staging: lustre: lnet: Remove functions LNetEQWait and LNetEQGet In-Reply-To: <1450287617-7682-1-git-send-email-shraddha.6596@gmail.com> References: <1450287617-7682-1-git-send-email-shraddha.6596@gmail.com> Message-ID: <1450287617-7682-4-git-send-email-shraddha.6596@gmail.com> From: Shraddha Barke Functions LNetEQWait and LNetEQGet are defined but not used. Thus remove it. Also remove corresponding declarations from header file. Signed-off-by: Shraddha Barke --- drivers/staging/lustre/include/linux/lnet/api.h | 6 ------ drivers/staging/lustre/lnet/lnet/lib-eq.c | 18 ------------------ 2 files changed, 24 deletions(-) diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h index 9493d5e..75285fd 100644 --- a/drivers/staging/lustre/include/linux/lnet/api.h +++ b/drivers/staging/lustre/include/linux/lnet/api.h @@ -161,12 +161,6 @@ int LNetEQAlloc(unsigned int count_in, int LNetEQFree(lnet_handle_eq_t eventq_in); -int LNetEQGet(lnet_handle_eq_t eventq_in, - lnet_event_t *event_out); - -int LNetEQWait(lnet_handle_eq_t eventq_in, - lnet_event_t *event_out); - int LNetEQPoll(lnet_handle_eq_t *eventqs_in, int neq_in, int timeout_ms, diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c index 60889eb..64f94a6 100644 --- a/drivers/staging/lustre/lnet/lnet/lib-eq.c +++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c @@ -282,15 +282,6 @@ lnet_eq_dequeue_event(lnet_eq_t *eq, lnet_event_t *ev) * at least one event between this event and the last event obtained from the * EQ has been dropped due to limited space in the EQ. */ -int -LNetEQGet(lnet_handle_eq_t eventq, lnet_event_t *event) -{ - int which; - - return LNetEQPoll(&eventq, 1, 0, - event, &which); -} -EXPORT_SYMBOL(LNetEQGet); /** * Block the calling process until there is an event in the EQ. @@ -308,15 +299,6 @@ EXPORT_SYMBOL(LNetEQGet); * at least one event between this event and the last event obtained from the * EQ has been dropped due to limited space in the EQ. */ -int -LNetEQWait(lnet_handle_eq_t eventq, lnet_event_t *event) -{ - int which; - - return LNetEQPoll(&eventq, 1, LNET_TIME_FOREVER, - event, &which); -} -EXPORT_SYMBOL(LNetEQWait); static int lnet_eq_wait_locked(int *timeout_ms) -- 2.1.4 From shraddha.6596 at gmail.com Thu Dec 17 21:10:25 2015 From: shraddha.6596 at gmail.com (Shraddha) Date: Fri, 18 Dec 2015 02:40:25 +0530 Subject: [lustre-devel] [PATCH 0/5] Staging: lustre: Code cleanups Message-ID: <1450386630-5662-1-git-send-email-shraddha.6596@gmail.com> From: Shraddha Barke These patches remove unused code and declare functions as static Shraddha Barke (5): Staging: lustre: obdclass: Declare cl_env_peek as static Staging: lustre: libcfs: Remove unused libcfs_debug_set_level Staging: lustre: osc: Declare as static Staging: lustre: osc: Declare osc_attr_set as static Staging: lustre: obdclass: Declare lu_site_hash_ops as static drivers/staging/lustre/lustre/libcfs/debug.c | 7 ------- drivers/staging/lustre/lustre/obdclass/cl_object.c | 3 +-- drivers/staging/lustre/lustre/obdclass/lu_object.c | 2 +- drivers/staging/lustre/lustre/osc/osc_cache.c | 10 +++++----- drivers/staging/lustre/lustre/osc/osc_object.c | 4 ++-- 5 files changed, 9 insertions(+), 17 deletions(-) -- 2.1.4 From shraddha.6596 at gmail.com Thu Dec 17 21:10:26 2015 From: shraddha.6596 at gmail.com (Shraddha) Date: Fri, 18 Dec 2015 02:40:26 +0530 Subject: [lustre-devel] [PATCH 1/5] Staging: lustre: obdclass: Declare cl_env_peek as static In-Reply-To: <1450386630-5662-1-git-send-email-shraddha.6596@gmail.com> References: <1450386630-5662-1-git-send-email-shraddha.6596@gmail.com> Message-ID: <1450386630-5662-2-git-send-email-shraddha.6596@gmail.com> From: Shraddha Barke Declare cl_env_peek as static since it is used only in this file. Also remove the EXPORT SYMBOL. Signed-off-by: Shraddha Barke --- drivers/staging/lustre/lustre/obdclass/cl_object.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index a1a6024..ed656a8 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -704,7 +704,7 @@ static inline struct cl_env *cl_env_container(struct lu_env *env) return container_of(env, struct cl_env, ce_lu); } -struct lu_env *cl_env_peek(int *refcheck) +static struct lu_env *cl_env_peek(int *refcheck) { struct lu_env *env; struct cl_env *cle; @@ -724,7 +724,6 @@ struct lu_env *cl_env_peek(int *refcheck) CDEBUG(D_OTHER, "%d@%p\n", cle ? cle->ce_ref : 0, cle); return env; } -EXPORT_SYMBOL(cl_env_peek); /** * Returns lu_env: if there already is an environment associated with the -- 2.1.4 From shraddha.6596 at gmail.com Thu Dec 17 21:10:27 2015 From: shraddha.6596 at gmail.com (Shraddha) Date: Fri, 18 Dec 2015 02:40:27 +0530 Subject: [lustre-devel] [PATCH 2/5] Staging: lustre: libcfs: Remove unused libcfs_debug_set_level In-Reply-To: <1450386630-5662-1-git-send-email-shraddha.6596@gmail.com> References: <1450386630-5662-1-git-send-email-shraddha.6596@gmail.com> Message-ID: <1450386630-5662-3-git-send-email-shraddha.6596@gmail.com> From: Shraddha Barke Function libcfs_debug_set_level is defined but not used. Thus remove it. Signed-off-by: Shraddha Barke --- drivers/staging/lustre/lustre/libcfs/debug.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index e56785a..0b38dad 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -557,10 +557,3 @@ int libcfs_debug_mark_buffer(const char *text) #undef DEBUG_SUBSYSTEM #define DEBUG_SUBSYSTEM S_LNET - -void libcfs_debug_set_level(unsigned int debug_level) -{ - pr_warn("Lustre: Setting portals debug level to %08x\n", - debug_level); - libcfs_debug = debug_level; -} -- 2.1.4 From shraddha.6596 at gmail.com Thu Dec 17 21:10:28 2015 From: shraddha.6596 at gmail.com (Shraddha) Date: Fri, 18 Dec 2015 02:40:28 +0530 Subject: [lustre-devel] [PATCH 3/5] Staging: lustre: osc: Declare as static In-Reply-To: <1450386630-5662-1-git-send-email-shraddha.6596@gmail.com> References: <1450386630-5662-1-git-send-email-shraddha.6596@gmail.com> Message-ID: <1450386630-5662-4-git-send-email-shraddha.6596@gmail.com> From: Shraddha Barke Declare osc_extent_find and osc_unreserve_grant as static since they are used only in this particular file. Signed-off-by: Shraddha Barke --- drivers/staging/lustre/lustre/osc/osc_cache.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_cache.c b/drivers/staging/lustre/lustre/osc/osc_cache.c index b1d1a87f..3f5a2a7d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_cache.c +++ b/drivers/staging/lustre/lustre/osc/osc_cache.c @@ -619,9 +619,9 @@ static inline int overlapped(struct osc_extent *ex1, struct osc_extent *ex2) * Find or create an extent which includes @index, core function to manage * extent tree. */ -struct osc_extent *osc_extent_find(const struct lu_env *env, - struct osc_object *obj, pgoff_t index, - int *grants) +static struct osc_extent *osc_extent_find(const struct lu_env *env, + struct osc_object *obj, pgoff_t index, + int *grants) { struct client_obd *cli = osc_cli(obj); @@ -1420,8 +1420,8 @@ static void __osc_unreserve_grant(struct client_obd *cli, } } -void osc_unreserve_grant(struct client_obd *cli, - unsigned int reserved, unsigned int unused) +static void osc_unreserve_grant(struct client_obd *cli, + unsigned int reserved, unsigned int unused) { client_obd_list_lock(&cli->cl_loi_list_lock); __osc_unreserve_grant(cli, reserved, unused); -- 2.1.4 From shraddha.6596 at gmail.com Thu Dec 17 21:10:29 2015 From: shraddha.6596 at gmail.com (Shraddha) Date: Fri, 18 Dec 2015 02:40:29 +0530 Subject: [lustre-devel] [PATCH 4/5] Staging: lustre: osc: Declare osc_attr_set as static In-Reply-To: <1450386630-5662-1-git-send-email-shraddha.6596@gmail.com> References: <1450386630-5662-1-git-send-email-shraddha.6596@gmail.com> Message-ID: <1450386630-5662-5-git-send-email-shraddha.6596@gmail.com> From: Shraddha Barke osc_attr_set is used only in this particular file. Thus declare it as static. Signed-off-by: Shraddha Barke --- drivers/staging/lustre/lustre/osc/osc_object.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/lustre/lustre/osc/osc_object.c b/drivers/staging/lustre/lustre/osc/osc_object.c index ba57f8d..2a171eb 100644 --- a/drivers/staging/lustre/lustre/osc/osc_object.c +++ b/drivers/staging/lustre/lustre/osc/osc_object.c @@ -158,8 +158,8 @@ static int osc_attr_get(const struct lu_env *env, struct cl_object *obj, return 0; } -int osc_attr_set(const struct lu_env *env, struct cl_object *obj, - const struct cl_attr *attr, unsigned valid) +static int osc_attr_set(const struct lu_env *env, struct cl_object *obj, + const struct cl_attr *attr, unsigned valid) { struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo; struct ost_lvb *lvb = &oinfo->loi_lvb; -- 2.1.4 From shraddha.6596 at gmail.com Thu Dec 17 21:10:30 2015 From: shraddha.6596 at gmail.com (Shraddha) Date: Fri, 18 Dec 2015 02:40:30 +0530 Subject: [lustre-devel] [PATCH 5/5] Staging: lustre: obdclass: Declare lu_site_hash_ops as static In-Reply-To: <1450386630-5662-1-git-send-email-shraddha.6596@gmail.com> References: <1450386630-5662-1-git-send-email-shraddha.6596@gmail.com> Message-ID: <1450386630-5662-6-git-send-email-shraddha.6596@gmail.com> From: Shraddha Barke lu_site_hash_ops is used only in this particular file. Thus declare it as static. Signed-off-by: Shraddha Barke --- drivers/staging/lustre/lustre/obdclass/lu_object.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c index 0193608..c47c544 100644 --- a/drivers/staging/lustre/lustre/obdclass/lu_object.c +++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c @@ -916,7 +916,7 @@ static void lu_obj_hop_put_locked(struct cfs_hash *hs, struct hlist_node *hnode) LBUG(); /* we should never called it */ } -struct cfs_hash_ops lu_site_hash_ops = { +static struct cfs_hash_ops lu_site_hash_ops = { .hs_hash = lu_obj_hop_hash, .hs_key = lu_obj_hop_key, .hs_keycmp = lu_obj_hop_keycmp, -- 2.1.4