Skip to contentSkip to conversation

fs/fscache/cookie.c:504 __fscache_invalidate() warn: inconsistent returns 'cookie->lock'.

PATCH New Dan Carpenter 1 participant 1 message May 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 41/61 fs/fscache/cookie.c:504 __fscache_invalidate() warn: inconsistent returns 'cookie->lock'.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git fscache-iter
head:   59f33c90ef6c1a75d4af75e5f60d98c0d965b6a2
commit: 4d15b33ef7e1f76b879588e3104e5cc83299f229 [41/61] fscache, cachefiles: Rewrite invalidation
config: i386-allyesconfig (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build):
        git checkout 4d15b33ef7e1f76b879588e3104e5cc83299f229
        # save the attached .config to linux build tree
        make ARCH=i386 

If you fix the issue, kindly add following tag as appropriate

New smatch warnings:
fs/fscache/cookie.c:504 __fscache_invalidate() warn: inconsistent returns 'cookie->lock'.

# https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/commit/?id=4d15b33ef7e1f76b879588e3104e5cc83299f229
git remote add dhowells-fs https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git
git remote update dhowells-fs
git checkout 4d15b33ef7e1f76b879588e3104e5cc83299f229
vim +504 fs/fscache/cookie.c

4d15b33ef7e1f7 David Howells 2020-02-06  477  void __fscache_invalidate(struct fscache_cookie *cookie,
4d15b33ef7e1f7 David Howells 2020-02-06  478  			  const void *aux_data, loff_t new_size,
4d15b33ef7e1f7 David Howells 2020-02-06  479  			  unsigned int flags)
ef778e7ae67cd4 David Howells 2012-12-20  480  {
4d15b33ef7e1f7 David Howells 2020-02-06  481  	struct fscache_object *object = NULL;
4d15b33ef7e1f7 David Howells 2020-02-06  482  
fc9bade4eccbd7 David Howells 2020-02-06  483  	_enter("{%s}", cookie->type_name);
ef778e7ae67cd4 David Howells 2012-12-20  484  
ef778e7ae67cd4 David Howells 2012-12-20  485  	fscache_stat(&fscache_n_invalidates);
ef778e7ae67cd4 David Howells 2012-12-20  486  
ef778e7ae67cd4 David Howells 2012-12-20  487  	/* Only permit invalidation of data files.  Invalidating an index will
ef778e7ae67cd4 David Howells 2012-12-20  488  	 * require the caller to release all its attachments to the tree rooted
ef778e7ae67cd4 David Howells 2012-12-20  489  	 * there, and if it's doing that, it may as well just retire the
ef778e7ae67cd4 David Howells 2012-12-20  490  	 * cookie.
ef778e7ae67cd4 David Howells 2012-12-20  491  	 */
c7444f2954ac78 David Howells 2020-05-02  492  	ASSERTCMP(cookie->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
ef778e7ae67cd4 David Howells 2012-12-20  493  
13e34f199ebd59 David Howells 2020-02-06  494  	spin_lock(&cookie->lock);
4d15b33ef7e1f7 David Howells 2020-02-06  495  	fscache_update_aux(cookie, aux_data, &new_size);
13e34f199ebd59 David Howells 2020-02-06  496  	cookie->zero_point = new_size;
4d15b33ef7e1f7 David Howells 2020-02-06  497  
4d15b33ef7e1f7 David Howells 2020-02-06  498  	if (!hlist_empty(&cookie->backing_objects)) {
4d15b33ef7e1f7 David Howells 2020-02-06  499  		object = hlist_entry(cookie->backing_objects.first,
4d15b33ef7e1f7 David Howells 2020-02-06  500  				     struct fscache_object, cookie_link);
4d15b33ef7e1f7 David Howells 2020-02-06  501  		object->inval_counter++;
4d15b33ef7e1f7 David Howells 2020-02-06  502  	}
4d15b33ef7e1f7 David Howells 2020-02-06  503  
4d15b33ef7e1f7 David Howells 2020-02-06 @504  	switch (cookie->stage) {
                                                        ^^^^^^^^^^^^^
4d15b33ef7e1f7 David Howells 2020-02-06  505  	case FSCACHE_COOKIE_STAGE_QUIESCENT:
4d15b33ef7e1f7 David Howells 2020-02-06  506  	case FSCACHE_COOKIE_STAGE_DEAD:
4d15b33ef7e1f7 David Howells 2020-02-06  507  	case FSCACHE_COOKIE_STAGE_INITIALISING: /* Assume later checks will catch it */
4d15b33ef7e1f7 David Howells 2020-02-06  508  	case FSCACHE_COOKIE_STAGE_INVALIDATING: /* is_still_valid will catch it */
4d15b33ef7e1f7 David Howells 2020-02-06  509  		spin_unlock(&cookie->lock);
4d15b33ef7e1f7 David Howells 2020-02-06  510  		_leave(" [no %u]", cookie->stage);
4d15b33ef7e1f7 David Howells 2020-02-06  511  		return;
4d15b33ef7e1f7 David Howells 2020-02-06  512  
4d15b33ef7e1f7 David Howells 2020-02-06  513  	case FSCACHE_COOKIE_STAGE_LOOKING_UP:
4d15b33ef7e1f7 David Howells 2020-02-06  514  		_leave(" [look %x]", object->inval_counter);

drop the lock here?

4d15b33ef7e1f7 David Howells 2020-02-06  515  		return;
4d15b33ef7e1f7 David Howells 2020-02-06  516  
4d15b33ef7e1f7 David Howells 2020-02-06  517  	case FSCACHE_COOKIE_STAGE_NO_DATA_YET:
4d15b33ef7e1f7 David Howells 2020-02-06  518  	case FSCACHE_COOKIE_STAGE_ACTIVE:
4d15b33ef7e1f7 David Howells 2020-02-06  519  		cookie->stage = FSCACHE_COOKIE_STAGE_INVALIDATING;
4d15b33ef7e1f7 David Howells 2020-02-06  520  		wake_up_var(&cookie->stage);
4d15b33ef7e1f7 David Howells 2020-02-06  521  
4d15b33ef7e1f7 David Howells 2020-02-06  522  		atomic_inc(&cookie->n_ops);
4d15b33ef7e1f7 David Howells 2020-02-06  523  		object->cache->ops->grab_object(object, fscache_obj_get_inval);
13e34f199ebd59 David Howells 2020-02-06  524  		spin_unlock(&cookie->lock);
13e34f199ebd59 David Howells 2020-02-06  525  
4d15b33ef7e1f7 David Howells 2020-02-06  526  		fscache_dispatch(cookie, object, flags, fscache_invalidate_object);
4d15b33ef7e1f7 David Howells 2020-02-06  527  		_leave(" [inv]");
4d15b33ef7e1f7 David Howells 2020-02-06  528  		return;
4d15b33ef7e1f7 David Howells 2020-02-06  529  	}
ef778e7ae67cd4 David Howells 2012-12-20  530  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org