Unverified Commit 2b0bbaa8 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!14206 v4 erofs/fscache/cachefiles: Add ondemand loading support

Merge Pull Request from: @ci-robot 
 
PR sync from: Zizhi Wo <wozizhi@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/XTB5GJ6OHR5OXCWBLI3YKFOEVO7HGOL3/ 
Changes since V1:
 - Modify the bugzilla link to synchronize with 5.10.
 - Fix comment syntax errors in patch 9.

Changes since V2:
 - Merge the introduced problem patch with the subsequent bugfix patches.

Changes since V3:
 - Fix a missing merge patch.

Baokun Li (1):

Yang Erkun (1):
  erofs: remove EXPERIMENTAL feature warning for fscache-based

Zizhi Wo (13):
  fscache: add a memory barrier for FSCACHE_VOLUME_CREATING
  cachefiles: modify inappropriate error return value in
    cachefiles_daemon_secctx
  fscache: modify the waiting mechanism with duplicate volumes
  erofs: add erofs switch to better control it
  erofs: add erofs_ondemand switch
  cachefiles: Add restrictions to cachefiles_daemon_cull()
  cachefiles: Introduce "dir_has_put" in cachefiles_volume
  fscache: Add the synchronous waiting mechanism for the volume unhash
  fscache: clean up for fscache_clear_volume_priv
  cachefiles: Fix NULL pointer dereference in object->file
  cachefiles: Clean up in cachefiles_commit_tmpfile()
  cachefiles: Fix incorrect length return value in
    cachefiles_ondemand_fd_write_iter()
  cachefiles: Fix missing pos updates in
    cachefiles_ondemand_fd_write_iter()


-- 
2.46.1
 
https://gitee.com/openeuler/kernel/issues/IB5UKT 
 
Link:https://gitee.com/openeuler/kernel/pulls/14206

 

Reviewed-by: default avatarHou Tao <houtao1@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 074c71be 1cdabef5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ obj-y := open.o read_write.o file_table.o super.o \
		stack.o fs_struct.o statfs.o fs_pin.o nsfs.o \
		fs_types.o fs_context.o fs_parser.o fsopen.o init.o \
		kernel_read_file.o mnt_idmapping.o remap_range.o
obj-y +=	fs_ctl.o

obj-$(CONFIG_BUFFER_HEAD)	+= buffer.o mpage.o
obj-$(CONFIG_PROC_FS)		+= proc_namespace.o
+2 −0
Original line number Diff line number Diff line
@@ -367,6 +367,7 @@ static void cachefiles_withdraw_volumes(struct cachefiles_cache *cache)
				continue;
			}
			list_del_init(&volume->cache_link);
			cachefiles_get_volume(volume);
		}
		spin_unlock(&cache->object_list_lock);
		if (!volume)
@@ -374,6 +375,7 @@ static void cachefiles_withdraw_volumes(struct cachefiles_cache *cache)

		cachefiles_withdraw_volume(volume);
		fscache_put_volume(vcookie, fscache_volume_put_withdraw);
		cachefiles_put_volume(volume);
	}

	_leave("");
+11 −1
Original line number Diff line number Diff line
@@ -587,7 +587,7 @@ static int cachefiles_daemon_secctx(struct cachefiles_cache *cache, char *args)

	if (cache->secctx) {
		pr_err("Second security context specified\n");
		return -EINVAL;
		return -EEXIST;
	}

	secctx = kstrdup(args, GFP_KERNEL);
@@ -654,6 +654,12 @@ static int cachefiles_daemon_cull(struct cachefiles_cache *cache, char *args)
	if (!d_can_lookup(path.dentry))
		goto notdir;

	/* limit the scope of cull */
	if (cache->mnt != path.mnt) {
		path_put(&path);
		return -EOPNOTSUPP;
	}

	cachefiles_begin_secure(cache, &saved_cred);
	ret = cachefiles_cull(cache, path.dentry, args);
	cachefiles_end_secure(cache, saved_cred);
@@ -780,6 +786,10 @@ static int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)

	if (IS_ENABLED(CONFIG_CACHEFILES_ONDEMAND)) {
		if (!strcmp(args, "ondemand")) {
			if (!cachefiles_ondemand_is_enabled()) {
				pr_err("ondemand mode is disabled\n");
				return -EINVAL;
			}
			set_bit(CACHEFILES_ONDEMAND_MODE, &cache->flags);
		} else if (*args) {
			pr_err("Invalid argument to the 'bind' command\n");
+21 −5
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ static
struct cachefiles_object *cachefiles_alloc_object(struct fscache_cookie *cookie)
{
	struct fscache_volume *vcookie = cookie->volume;
	struct cachefiles_volume *volume = vcookie->cache_priv;
	struct cachefiles_volume *volume = READ_ONCE(vcookie->cache_priv);
	struct cachefiles_object *object;

	_enter("{%s},%x,", vcookie->key, cookie->debug_id);
@@ -38,6 +38,15 @@ struct cachefiles_object *cachefiles_alloc_object(struct fscache_cookie *cookie)

	refcount_set(&object->ref, 1);

	/*
	 * After enabling sync_volume_unhash, fscache_relinquish_volume() may
	 * release cachefiles_volume while fscache_volume->ref is non-zero.
	 * However, cachefiles_object may still access cachefiles_cache through
	 * object->volume->cache (e.g., in cachefiles_ondemand_fd_release).
	 * Therefore, we need to pin cachefiles_volume through the object.
	 */
	cachefiles_get_volume(volume);

	spin_lock_init(&object->lock);
	INIT_LIST_HEAD(&object->cache_link);
	object->volume = volume;
@@ -96,6 +105,7 @@ void cachefiles_put_object(struct cachefiles_object *object,
		cachefiles_ondemand_deinit_obj_info(object);
		cache = object->volume->cache->cache;
		fscache_put_cookie(object->cookie, fscache_cookie_put_object);
		cachefiles_put_volume(object->volume);
		object->cookie = NULL;
		kmem_cache_free(cachefiles_object_jar, object);
		fscache_uncount_object(cache);
@@ -327,6 +337,8 @@ static void cachefiles_commit_object(struct cachefiles_object *object,
static void cachefiles_clean_up_object(struct cachefiles_object *object,
				       struct cachefiles_cache *cache)
{
	struct file *file;

	if (test_bit(FSCACHE_COOKIE_RETIRED, &object->cookie->flags)) {
		if (!test_bit(CACHEFILES_OBJECT_USING_TMPFILE, &object->flags)) {
			cachefiles_see_object(object, cachefiles_obj_see_clean_delete);
@@ -342,10 +354,14 @@ static void cachefiles_clean_up_object(struct cachefiles_object *object,
	}

	cachefiles_unmark_inode_in_use(object, object->file);
	if (object->file) {
		fput(object->file);

	spin_lock(&object->lock);
	file = object->file;
	object->file = NULL;
	}
	spin_unlock(&object->lock);

	if (file)
		fput(file);
}

/*
+5 −0
Original line number Diff line number Diff line
@@ -37,9 +37,12 @@ enum cachefiles_content {
 * Cached volume representation.
 */
struct cachefiles_volume {
	refcount_t			ref;
	struct cachefiles_cache		*cache;
	struct list_head		cache_link;	/* Link in cache->volumes */
	struct fscache_volume		*vcookie;	/* The netfs's representation */
	struct mutex			lock;		/* Lock for cachefiles_volume */
	bool				dir_has_put;	/* Indicates cache dir has been put */
	struct dentry			*dentry;	/* The volume dentry */
	struct dentry			*fanout[256];	/* Fanout subdirs */
};
@@ -405,6 +408,8 @@ static inline void cachefiles_end_secure(struct cachefiles_cache *cache,
/*
 * volume.c
 */
void cachefiles_get_volume(struct cachefiles_volume *volume);
void cachefiles_put_volume(struct cachefiles_volume *volume);
void cachefiles_acquire_volume(struct fscache_volume *volume);
void cachefiles_free_volume(struct fscache_volume *volume);
void cachefiles_withdraw_volume(struct cachefiles_volume *volume);
Loading