Skip to content
Snippets Groups Projects
Commit fb51f97c authored by Alessandro Rubini's avatar Alessandro Rubini
Browse files

buffers/kmalloc: fix buffer-full check, as size may change


If the user changes the buffer size, this might make more space for a
sleeping writer. Similarly, the buffer may be fuller than the new
value after a change, so we check for ">= limit" and not "== limit".

This doesn't apply to the vmalloc buffer, that currently doesn't allow
a size change.

Signed-off-by: default avatarAlessandro Rubini <rubini@gnudd.com>
Acked-by: default avatarFederico Vaga <federico.vaga@gmail.com>
parent 2300e624
Branches
Tags
No related merge requests found
......@@ -48,6 +48,11 @@ static DEFINE_ZATTR_STD(ZBUF, zbk_std_zattr) = {
static int zbk_conf_set(struct device *dev, struct zio_attribute *zattr,
uint32_t usr_val)
{
struct zio_bi *bi = to_zio_bi(dev);
/* If somebody is sleeping for write and we increase the size... */
wake_up_interruptible(&bi->q);
return 0;
}
struct zio_sysfs_operations zbk_sysfs_ops = {
......@@ -144,7 +149,7 @@ static int zbk_store_block(struct zio_bi *bi, struct zio_block *block)
/* add to the buffer instance or push to the trigger */
spin_lock(&bi->lock);
if (zbki->nitem == bi->zattr_set.std_zattr[ZATTR_ZBUF_MAXLEN].value)
if (zbki->nitem >= bi->zattr_set.std_zattr[ZATTR_ZBUF_MAXLEN].value)
goto out_unlock;
list_add_tail(&item->list, &zbki->list);
if (!zbki->nitem) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment