Details

    • Technical task
    • Resolution: Fixed
    • Minor
    • Lustre 2.14.0
    • Lustre 2.14.0
    • 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.

      Attachments

        Issue Links

          Activity

            [LU-12923] replace CLASSERT() with BUILD_BUG_ON()

            Beyond a doubt.

            [lustre-release]# git grep -c CLASSERT
            contrib/scripts/spelling.txt:1
            [lustre-release]#
            arshad512 Arshad Hussain added a comment - Beyond a doubt. [lustre-release]# git grep -c CLASSERT contrib/scripts/spelling.txt:1 [lustre-release]#
            pjones Peter Jones added a comment -

            For real complete now?

            pjones Peter Jones added a comment - For real complete now?

            Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37188/
            Subject: LU-12923 libcfs: Remove CLASSERT() for libcfs_private.h
            Project: fs/lustre-release
            Branch: master
            Current Patch Set:
            Commit: fa70e91747dc712f3083649cb82194bd7c0c856f

            gerrit Gerrit Updater added a comment - Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37188/ Subject: LU-12923 libcfs: Remove CLASSERT() for libcfs_private.h Project: fs/lustre-release Branch: master Current Patch Set: Commit: fa70e91747dc712f3083649cb82194bd7c0c856f

            Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/37188
            Subject: LU-12923 libcfs: Remove CLASSERT() for libcfs_private.h
            Project: fs/lustre-release
            Branch: master
            Current Patch Set: 1
            Commit: f4c373f4485db07b98d74ebe8005b08f2064ca3a

            gerrit Gerrit Updater added a comment - Arshad Hussain (arshad.super@gmail.com) uploaded a new patch: https://review.whamcloud.com/37188 Subject: LU-12923 libcfs: Remove CLASSERT() for libcfs_private.h Project: fs/lustre-release Branch: master Current Patch Set: 1 Commit: f4c373f4485db07b98d74ebe8005b08f2064ca3a

            Aurelien,
            As James pointed out already, "spelling.txt" remains as it helps checkpatch to flag warning if any CLASSERT is left behind. For libcfs_private.h - this was missed ((again!), which is a bummer ) - Sorry. I will get this in.
             
            James,
            Only patch on master:branch open which is referring 'libcfs_private.h' is https://review.whamcloud.com/#/c/36975/ - This also does not touch CLASSERT(). What I found out, updating libcfs_private.h immediately will not affect any patch. I am going ahead with the change.

            arshad512 Arshad Hussain added a comment - Aurelien, As James pointed out already, "spelling.txt" remains as it helps checkpatch to flag warning if any CLASSERT is left behind. For libcfs_private.h - this was missed ((again!), which is a bummer ) - Sorry. I will get this in.   James, Only patch on master:branch open which is referring 'libcfs_private.h' is  https://review.whamcloud.com/#/c/36975/ - This also does not touch CLASSERT(). What I found out, updating libcfs_private.h immediately will not affect any patch. I am going ahead with the change.

            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.

            simmonsja James A Simmons added a comment - 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.

            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?

            degremoa Aurelien Degremont (Inactive) added a comment - 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?
            pjones Peter Jones added a comment -

            Landed for 2.14

            pjones Peter Jones added a comment - Landed for 2.14

            Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37113/
            Subject: LU-12923 lnet: Replace CLASSERT() with BUILD_BUG_ON()
            Project: fs/lustre-release
            Branch: master
            Current Patch Set:
            Commit: 81fff75016dae08332d1a6cdd5137fc4e3097665

            gerrit Gerrit Updater added a comment - Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37113/ Subject: LU-12923 lnet: Replace CLASSERT() with BUILD_BUG_ON() Project: fs/lustre-release Branch: master Current Patch Set: Commit: 81fff75016dae08332d1a6cdd5137fc4e3097665

            Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37111/
            Subject: LU-12923 lustre: Replace CLASSERT() with BUILD_BUG_ON()
            Project: fs/lustre-release
            Branch: master
            Current Patch Set:
            Commit: f0fa794d0fc35be8fb0839731d122a73395f2a05

            gerrit Gerrit Updater added a comment - Oleg Drokin (green@whamcloud.com) merged in patch https://review.whamcloud.com/37111/ Subject: LU-12923 lustre: Replace CLASSERT() with BUILD_BUG_ON() Project: fs/lustre-release Branch: master Current Patch Set: Commit: f0fa794d0fc35be8fb0839731d122a73395f2a05

            People

              arshad512 Arshad Hussain
              adilger Andreas Dilger
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: