Re: [PATCH 1/3] Add r/w sysfs attribute for zcache_freeze

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 13, 2012 at 11:34:46AM +0100, Florian Schmaus wrote:
> From: Andor Daam <andor.daam@xxxxxxxxxxxxxx>
> 
> This patch makes dynamic enabling/disabling of zcache via a sysfsnode possible.

There should be an patch to the Documentation/ABI/testing for these parameters.

> The node is used to toggle the preexisting zcache_freeze variable to
> stop/start accepting pages by zcache.

What is the reasoning to do this in the frontend instead of the backend (Cleancache/frontswap)?

> 
> Signed-off-by: Andor Daam <andor.daam@xxxxxxxxxxxxxx>
> Signed-off-by: Florian Schmaus <fschmaus@xxxxxxxxx>
> Signed-off-by: Stefan Hengelein <ilendir@xxxxxxxxxxxxxx>
> ---
>  drivers/staging/zcache/zcache-main.c |   57 +++++++++++++++++++++++++++++-----
>  1 files changed, 49 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/zcache/zcache-main.c b/drivers/staging/zcache/zcache-main.c
> index 2734dac..1bece03 100644
> --- a/drivers/staging/zcache/zcache-main.c
> +++ b/drivers/staging/zcache/zcache-main.c
> @@ -469,6 +469,15 @@ out:
>  }
>  
>  /*
> + * When zcache is disabled ("frozen"), pools can be created and destroyed,
> + * but all puts (and thus all other operations that require memory allocation)
> + * must fail.  If zcache is unfrozen, accepts puts, then frozen again,
> + * data consistency requires all puts while frozen to be converted into
> + * flushes.
> + */
> +static bool zcache_freeze;
> +
> +/*
>   * The following routines handle shrinking of ephemeral pages by evicting
>   * pages "least valuable" first.
>   */
> @@ -913,6 +922,45 @@ static struct kobj_attribute zcache_zv_page_count_policy_percent_attr = {
>  		.show = zv_page_count_policy_percent_show,
>  		.store = zv_page_count_policy_percent_store,
>  };
> +
> +static ssize_t zcache_freeze_show(struct kobject *kobj,
> +						struct kobj_attribute *attr,
> +						char *buf)
> +{
> +	if (zcache_freeze)
> +		return sprintf(buf, "1\n");
> +	else
> +		return sprintf(buf, "0\n");
> +}
> +
> +static ssize_t zcache_freeze_store(struct kobject *kobj,
> +						struct kobj_attribute *attr,
> +						const char *buf, size_t count)
> +{
> +	unsigned int val;
> +	int err;
> +
> +	if (!capable(CAP_SYS_ADMIN))
> +		return -EPERM;
> +
> +	err = kstrtouint(buf, 10, &val);
> +	if (err)
> +		return -EINVAL;
> +
> +	if (val > 0)
> +		zcache_freeze = true;
> +	else
> +		zcache_freeze = false;
> +
> +	return count;
> +}
> +
> +static struct kobj_attribute zcache_freeze_attr = {
> +	.attr = { .name = "zcache_freeze", .mode = 0644 },
> +	.show = zcache_freeze_show,
> +	.store = zcache_freeze_store,
> +};
> +
>  #endif
>  
>  /*
> @@ -1515,6 +1563,7 @@ static struct attribute *zcache_attrs[] = {
>  	&zcache_zv_max_zsize_attr.attr,
>  	&zcache_zv_max_mean_zsize_attr.attr,
>  	&zcache_zv_page_count_policy_percent_attr.attr,
> +	&zcache_freeze_attr.attr,
>  	NULL,
>  };
>  
> @@ -1524,14 +1573,6 @@ static struct attribute_group zcache_attr_group = {
>  };
>  
>  #endif /* CONFIG_SYSFS */
> -/*
> - * When zcache is disabled ("frozen"), pools can be created and destroyed,
> - * but all puts (and thus all other operations that require memory allocation)
> - * must fail.  If zcache is unfrozen, accepts puts, then frozen again,
> - * data consistency requires all puts while frozen to be converted into
> - * flushes.
> - */
> -static bool zcache_freeze;
>  
>  /*
>   * zcache shrinker interface (only useful for ephemeral pages, so zbud only)
> -- 
> 1.7.5.4
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux