Commit bcbc151d authored by Zizhi Wo's avatar Zizhi Wo
Browse files

cachefiles: Introduce "dir_has_put" in cachefiles_volume

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



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

Introduce "dir_has_put" in "struct cachefiles_volume" to indicate whether
the cache directory has been put. It is used to replace the
previous method of determining whether __cachefiles_free_volume() has been
called by checking if "vcookie->cache_priv" is NULL.

__cachefiles_free_volume() function primarily performs cleanup operations
related to "cachefiles_volume". Therefore, it is more appropriate to set
"vcookie->cache_priv" to NULL within cachefiles_free_volume() as it
interacts more directly with "fscache_volume".

It also prepares for subsequent patches.

Signed-off-by: default avatarZizhi Wo <wozizhi@huawei.com>
parent 79f5c88b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ struct cachefiles_volume {
	struct cachefiles_cache		*cache;
	struct list_head		cache_link;	/* Link in cache->volumes */
	struct fscache_volume		*vcookie;	/* The netfs's representation */
	bool				dir_has_put;	/* Indicates cache dir has been put */
	struct dentry			*dentry;	/* The volume dentry */
	struct dentry			*fanout[256];	/* Fanout subdirs */
};
+9 −7
Original line number Diff line number Diff line
@@ -111,7 +111,10 @@ static void __cachefiles_free_volume(struct cachefiles_volume *volume)

	_enter("");

	volume->vcookie->cache_priv = NULL;
	if (volume->dir_has_put)
		return;

	volume->dir_has_put = true;

	for (i = 0; i < 256; i++)
		cachefiles_put_directory(volume->fanout[i]);
@@ -123,13 +126,12 @@ void cachefiles_free_volume(struct fscache_volume *vcookie)
{
	struct cachefiles_volume *volume = vcookie->cache_priv;

	if (volume) {
	spin_lock(&volume->cache->object_list_lock);
	list_del_init(&volume->cache_link);
	spin_unlock(&volume->cache->object_list_lock);
	vcookie->cache_priv = NULL;
	__cachefiles_free_volume(volume);
}
}

void cachefiles_withdraw_volume(struct cachefiles_volume *volume)
{