Commit a8b9dd5e authored by Baokun Li's avatar Baokun Li
Browse files

cachefiles: clear FSCACHE_COOKIE_NO_DATA_YET for the new ondemand object

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB5UKT



--------------------------------

As follows, moving cachefiles_ondemand_init_object() outside the parent
dir lock also moves it before fscache_object_lookup_negative(). This causes
FSCACHE_COOKIE_NO_DATA_YET to be cleared before setting it when creating a
new data object. Eventually __fscache_read_or_alloc_page() reads the flag
and returns -ENODATA causing the mount to fail.

         mount         |    kworker
-----------------------------------------------
__fscache_read_or_alloc_page
                        cachefiles_walk_to_object
                          cachefiles_ondemand_init_object
                            cachefiles_ondemand_send_req
                            cachefiles_ondemand_copen
                              clear_bit(FSCACHE_COOKIE_NO_DATA_YET)
                          fscache_object_lookup_negative
                            set_bit(FSCACHE_COOKIE_NO_DATA_YET)
  if (test_bit(FSCACHE_COOKIE_NO_DATA_YET))
    object->cache->ops->allocate_page
      ret = -ENODATA

Hence for newly created data objects whose size is not 0, clear the
FSCACHE_COOKIE_NO_DATA_YET bit.

Signed-off-by: default avatarBaokun Li <libaokun1@huawei.com>
parent 621cbeb2
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -725,6 +725,11 @@ int cachefiles_walk_to_object(struct cachefiles_object *parent,
				 */
				file->f_mode |= FMODE_RANDOM;
				rcu_assign_pointer(object->file, file);

				/* Now the pages can be read. */
				if (object->new && object->fscache.store_limit_l)
					clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET,
						    &object->fscache.cookie->flags);
			}

			object->backer = object->dentry;