Improved File Block API CallsA low-level ctFILBLK() call on an index file that contains more than one additional member may fail with an FUSE_ERR (46, file number already in use) error. When establishing a low-level file block, the file block logic requires a user file number at the start of a consecutive range of two user file numbers that are not in use. However, an index having more than one additional member needs more than two consecutive user file numbers, and if the required number of user file numbers is not available, the attempt to open the index fails with FUSE_ERR. The file block logic now requests consecutive numbers up front to ensure an appropriate file number is obtained. The ctFILBLK() could also hang in particular cases.The file block routine has a polling loop that attempts to clear threads out of the c-tree core. The logic first set a status byte on all threads that have the file(s) to be blocked open and are inside the core. Then it checks to see if any threads that don't respond to the status byte change are being blocked (for example., waiting for a lock to be released). If so, it attempts to "kill" the blocks. However, the logic did not account for an extreme timing issue that would permit the block to be acquired after the checks for blocks had been completed. The result was that the file block routine looped indefinitely without making progress on the object of clearing threads from the core. Now the polling loop periodically rechecks the thread status, and it can clear blocks on subsequent passes around the loop. The thread that had its blocking lock request killed (the second application) returns from the lock request with an error FBLK_PND (801). This error signifies that a block attempt required the thread (application) to not complete its last request, and instead leave the core code. In addition to fixing this specific looping problem, additional changes have been made to the logic:
Note: The second thread in the above test will still receive an FBLK_PND (801) error when the file block routine is aborted in cases (1) and (2) above. Whenever a thread (application) receives an FBLK_PND (801) error it is free to retry the operation. If the block was successfully obtained, the retry will behave in accordance with the type of file block requested (the thread may be suspended or return an error). If the block was aborted (as in cases (1) and (2) above), then the retry should behave just as if no file block attempt had been made. |
|||