libcfs simplification
(LU-9859)
|
|
| Status: | Resolved |
| Project: | Lustre |
| Component/s: | None |
| Affects Version/s: | Lustre 2.14.0 |
| Fix Version/s: | Lustre 2.14.0 |
| Type: | Technical task | Priority: | Minor |
| Reporter: | Andreas Dilger | Assignee: | Arshad Hussain |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | easy | ||
| Issue Links: |
|
||||||||
| Rank (Obsolete): | 9223372036854775807 | ||||||||
| Description |
|
The Lustre-specific compile-time assertion CLASSERT() should be replaced with the standard kernel BUILD_BUG_ON() macro that does the same thing. NOTE that the logic of CLASSERT() is ensuring that the expression is true while BUILD_BUG_ON() is verifying if the expression is false, so the logic of each check should be reversed. All of these expressions are evaluated at compile time, so it is possible to mark all patches fixing this with Test-Parameters: trivial. The first patch in the series should update contrib/scripts/spelling.txt to add CLASSERT||BUILD_BUG_ON() so that new patches get a warning if they are using the old CLASSERT() macro. The last patch in the series should remove the CLASSERT() macro. There are currently 480 instances of CLASSERT() in the master branch, but a majority of them (318) are in the automatically-generated wirecheck.c, pack-generic.c and api-ni.c file, so most could be easily replaced by fixing the wiretest.c scripts. |
| Comments |
| Comment by James A Simmons [ 31/Oct/19 ] |
|
Are you going to take this work or should I. I have been planning to do this. |
| Comment by Andreas Dilger [ 31/Oct/19 ] |
|
I'm not planning on it, but added it as a separate task marked easy for tracking purposes. I was going to add a CLASSERT() in one of my patches and then thought I should use BUILD_BUG_ON() instead, and that it makes sense to formalize this transition. |
| Comment by Arshad Hussain [ 01/Nov/19 ] |
|
Andreas,James, - One more volunteer for this. Let me know if I can take this one. Thanks. |
| Comment by Andreas Dilger [ 01/Nov/19 ] |
|
arshad512 I'd be very grateful if you have the time to do this. No rush, as we haven't yet opened master for patch landings until after 2.13 is released, but that should be in a week or two. |
| Comment by Arshad Hussain [ 02/Nov/19 ] |
|
Andreas, more than glad to do this patch. And let me add this...as always ... Thank you! Few patches will come this weekend , next set of patch batches around next weekend. Thanks |
| Comment by Gerrit Updater [ 02/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36645 |
| Comment by Gerrit Updater [ 02/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36646 |
| Comment by Gerrit Updater [ 02/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36647 |
| Comment by Gerrit Updater [ 02/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36648 |
| Comment by Gerrit Updater [ 02/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36649 |
| Comment by Gerrit Updater [ 06/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36690 |
| Comment by Gerrit Updater [ 07/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36711 |
| Comment by Gerrit Updater [ 08/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36717 |
| Comment by Gerrit Updater [ 08/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36718 |
| Comment by Gerrit Updater [ 08/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36719 |
| Comment by Gerrit Updater [ 08/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36720 |
| Comment by Gerrit Updater [ 08/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36721 |
| Comment by Gerrit Updater [ 08/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36722 |
| Comment by Gerrit Updater [ 09/Nov/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36725 |
| Comment by Gerrit Updater [ 01/Dec/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/36902 |
| Comment by Gerrit Updater [ 06/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36645/ |
| Comment by Gerrit Updater [ 06/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36646/ |
| Comment by Gerrit Updater [ 06/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36647/ |
| Comment by Gerrit Updater [ 06/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36648/ |
| Comment by Gerrit Updater [ 06/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36717/ |
| Comment by Gerrit Updater [ 06/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36718/ |
| Comment by Gerrit Updater [ 06/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36719/ |
| Comment by Gerrit Updater [ 06/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36720/ |
| Comment by Gerrit Updater [ 06/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36721/ |
| Comment by Gerrit Updater [ 06/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36722/ |
| Comment by Gerrit Updater [ 16/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36649/ |
| Comment by Gerrit Updater [ 16/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36725/ |
| Comment by Gerrit Updater [ 20/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36711/ |
| Comment by Gerrit Updater [ 20/Dec/19 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/36902/ |
| Comment by Peter Jones [ 20/Dec/19 ] |
|
Everything currently in flight has landed - is this task now complete? |
| Comment by Arshad Hussain [ 29/Dec/19 ] |
|
Hi Peter, I was away traveling. I am catching up on my mails and messages now, sorry for delay response. Unfortunately, as I double checked it looks like few instances under files which escaped my scrutiny. So, this LU is almost done but not complete. I will address this quickly.
[lustre-release]$ find ./lustre/ -name "*.c" | xargs grep CLASSERT
./lustre/osd-zfs/osd_index.c: CLASSERT(sizeof(zde->lzd_reg) == 8);
./lustre/osd-zfs/osd_index.c: CLASSERT(sizeof(*zde) % 8 == 0);
./lustre/osd-zfs/osd_index.c: CLASSERT(sizeof(za->za_name) <= sizeof(it->ozi_name));
./lustre/ptlrpc/nodemap_storage.c: CLASSERT(sizeof(union nodemap_rec) == 32);
./lustre/mdd/mdd_object.c: CLASSERT(ARRAY_SIZE(info->mti_buf) >= 4);
Where I went wrong was, I was using below command to verify. Which unfortunately was give me false positives.
$ find ./lustre -name "*.c" | xargs ./contrib/scripts/checkpatch.pl -f --no-tree | grep CLASSERT | wc -l
|
| Comment by Gerrit Updater [ 29/Dec/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/37111 |
| Comment by Aurelien Degremont (Inactive) [ 30/Dec/19 ] |
|
Looks like lnet also needs one last patch: $ git grep -c CLASSERT lnet/ lnet/lnet/api-ni.c:96 lnet/utils/wirecheck.c:2
|
| Comment by Gerrit Updater [ 30/Dec/19 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/37113 |
| Comment by Arshad Hussain [ 30/Dec/19 ] |
|
Aurelien, Thanks for pointing out. Updated remaining CLASSERT() under lnet. |
| Comment by Gerrit Updater [ 10/Jan/20 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37111/ |
| Comment by Gerrit Updater [ 10/Jan/20 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37113/ |
| Comment by Peter Jones [ 10/Jan/20 ] |
|
Landed for 2.14 |
| Comment by Aurelien Degremont (Inactive) [ 10/Jan/20 ] |
|
What should we do with the last 2 occurrences? $ git grep CLASSERT contrib/scripts/spelling.txt:CLASSERT||BUILD_BUG_ON() libcfs/include/libcfs/libcfs_private.h:#define CLASSERT(cond) do {switch (1) {case (cond): case 0: break; } } while (0) I think they should also be removed? |
| Comment by James A Simmons [ 10/Jan/20 ] |
|
spelling.txt will remain since it tells people not use CLASSERT anymore. The define in libcfs_private.h does need to be removed but we should wait a bit since other patches in flight might land that have a CLASSERT. |
| Comment by Arshad Hussain [ 10/Jan/20 ] |
|
Aurelien, |
| Comment by Gerrit Updater [ 10/Jan/20 ] |
|
Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/37188 |
| Comment by Gerrit Updater [ 28/Jan/20 ] |
|
Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37188/ |
| Comment by Peter Jones [ 28/Jan/20 ] |
|
For real complete now? |
| Comment by Arshad Hussain [ 31/Jan/20 ] |
|
Beyond a doubt. [lustre-release]# git grep -c CLASSERT contrib/scripts/spelling.txt:1 [lustre-release]# |