Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-15205

cfs_hash rehashing can race with hash iteration

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • Minor
    • Upstream
    • None
    • None
    • 3
    • 9223372036854775807

    Description

      when one thread leaving cfs hash iteration it checks whether it's time to rehash in cfs_hash_for_each_exit():

      	if (bits > 0) {
      		cfs_hash_rehash(hs, atomic_read(&hs->hs_count) <
      				    CFS_HASH_LOOP_HOG);
      

      then cfs_hash_rehash() can start rehashing immediately (not via worker thread):

      	if (!do_rehash) {
      		/* launch and return */
      		queue_work(cfs_rehash_wq, &hs->hs_rehash_work);
      		cfs_hash_unlock(hs, 1);
      		return;
      	}
      
      	/* rehash right now */
      	cfs_hash_unlock(hs, 1);
      
      	cfs_hash_rehash_worker(&hs->hs_rehash_work);
      

      if another thread is starting to iterate the same hash it can find it being rehashed and there is no way to wait for rehashing completion, that works for rehashing in a dedicated thread only:

      	if (cfs_hash_is_rehashing(hs))
      		cfs_hash_rehash_cancel(hs);
      

      so 2nd thread just proceed and find hash under rehashing:

      	LASSERT(!cfs_hash_is_rehashing(hs));

      Attachments

        Activity

          People

            wc-triage WC Triage
            bzzz Alex Zhuravlev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: