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

cfs_delete_from_page_cache() should not unlock page

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • Lustre 2.17.0
    • None
    • None
    • 3
    • 9223372036854775807

      cfs_delete_from_page_cache() had to be implemented because  delete_from_page_cache() Kernel external is no longer available in recent Kernels, this has started with upstream Kernel v5.16-rc4 and has been addressed by LU-16292 and fixed in associated Gerrit #49069.

      Looking more closely to cfs_delete_from_page_cache() code :

      /**
       * delete_from_page_cache is not exported anymore
       */
      #ifdef HAVE_DELETE_FROM_PAGE_CACHE
      #define cfs_delete_from_page_cache(page)        delete_from_page_cache((page))
      #else
      static inline void cfs_delete_from_page_cache(struct page *page)
      {
              if (!page->mapping)
                      return;
              LASSERT(PageLocked(page));
              get_page(page);
              unlock_page(page);
              /* on entry page is locked */
              if (S_ISREG(page->mapping->host->i_mode)) {
                      generic_error_remove_folio(page->mapping, page_folio(page));
              } else {
                      loff_t lstart = page->index << PAGE_SHIFT;
                      loff_t lend = lstart + PAGE_SIZE - 1;
      
      
                      truncate_inode_pages_range(page->mapping, lstart, lend);
              }
              lock_page(page);
              put_page(page);
      }
      #endif 

      and also to other places where generic_error_remove_folio() is also being called, in both Lustre and Kernel, I have strong assumptions that page should not be unlocked prior to call it..., this may cause a race where page->mapping may become NULL !

      I will cook a patch soon in this direction.

            bfaccini-nvda Bruno Faccini
            bfaccini-nvda Bruno Faccini
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: