[LU-17022] Clean up flags and locking in struct obd_device Created: 09/Aug/23  Updated: 14/Sep/23

Status: Open
Project: Lustre
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: Neil Brown Assignee: Neil Brown
Resolution: Unresolved Votes: 0
Labels: None

Severity: 3
Rank (Obsolete): 9223372036854775807

 Description   

struct obd_device contains a number of flags using a single-bit bit-field.  These require a spinlock to ensure atomic updates as it documented in a comment.  However many places update these flags without a lock. Conversely sometime the lock is taken for only reading the flag, which provides no value.

The common practice in Linux is to use set_bit() etc which is atomic and requires no locking.  The flags should be converted.  Where a flag is both checked and set within a spinlock region, test_and_set_bit() or test_and_clear_bit() can be used.

The lock in question -> obd_dev_lock, is documented only as protecting these flag bit, but it actually protects a number of lists and other things.  This should be documented.

One of the fields it protects is  obd_conn_inprogress which would work better as an atomic_t, and which is waited for with a 'yield()' loop which is not good practice.  This should use wait_var_event etc.

The lock is also held across code that does not need locking, and this should be removed.

The name of the lock is easily confused with the global lock "obd_dev_lock".  One of these should be renamed.  Maybe obd_devs_lock for the global.

struct obd_export has similar issues deserving attention.

 

I propose to submit a number of patches to achieve all this with all but the last marked "trivial" so the heavy testing is only run on the complete set.



 Comments   
Comment by Gerrit Updater [ 09/Aug/23 ]

"Neil Brown <neilb@suse.de>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51899
Subject: LU-17022 obdclass: start converting obd flags to a bitmap
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 38dcb6bf170276d9e687f869ce7c41f3ea6ddd7e

Comment by Gerrit Updater [ 09/Aug/23 ]

"Neil Brown <neilb@suse.de>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51900
Subject: LU-17022 obdclass: convert recovery flags to bit ops
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 735b3c94b0b0241f4fe8a0eaf44b648d5e8efbc6

Comment by Gerrit Updater [ 09/Aug/23 ]

"Neil Brown <neilb@suse.de>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51901
Subject: LU-17022 obdclass: convert more flags to bitops
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 084d3a0ad425f7212bcf9e44ca10834bbd5bce1f

Comment by Gerrit Updater [ 09/Aug/23 ]

"Neil Brown <neilb@suse.de>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51902
Subject: LU-17022 obdclass: convert still more flags to bitops
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 6555724e093ea4cfafd6ef6f46f758e316d3df3c

Comment by Gerrit Updater [ 09/Aug/23 ]

"Neil Brown <neilb@suse.de>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51903
Subject: LU-17022 obdclass: change further flags to bitops
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 10b672c16fee0c46e7ba038f186837b8a224364f

Comment by Gerrit Updater [ 09/Aug/23 ]

"Neil Brown <neilb@suse.de>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51904
Subject: LU-17022 obdclass: change 4 flags to bitops
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: fd0478cd4d4e1a1126406496dd9538d011e899ba

Comment by Gerrit Updater [ 09/Aug/23 ]

"Neil Brown <neilb@suse.de>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51905
Subject: LU-17022 obdclass: convert remaining flags to bitops
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 3297364a2a382173e28b0cd1ae078d0a4cb2aa58

Comment by Gerrit Updater [ 09/Aug/23 ]

"Neil Brown <neilb@suse.de>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51906
Subject: LU-17022 obdclass: convert obd_conn_inprogress to atomic_t
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 61e8d23259a1a584f920fdcf7759ac74c4cbda10

Comment by Gerrit Updater [ 09/Aug/23 ]

"Neil Brown <neilb@suse.de>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51907
Subject: LU-17022 osd: convert od_connects to atomic_t
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 1229df8ab78f1646b6af9db91f60e8c3776fce8a

Comment by Gerrit Updater [ 09/Aug/23 ]

"Neil Brown <neilb@suse.de>" uploaded a new patch: https://review.whamcloud.com/c/fs/lustre-release/+/51908
Subject: LU-17022 obdclass: rename obd_dev_lock to obd_devs_lock
Project: fs/lustre-release
Branch: master
Current Patch Set: 1
Commit: 344beb5029d661657ecfff4bc9e19f19e25886c1

Generated at Sat Feb 10 03:31:57 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.