You need to sign in or sign up before continuing.
提交 a178220d 编写于 作者: M Michael Holzheu 提交者: Martin Schwidefsky

s390/hypfs: Eliminate hypfs interval

Currently the binary hypfs interfaces provides new data only once within
an interval time of one second. This patch removes this restriction and
now new data is returned immediately on every read on a hypfs binary file.

This is done in order to allow more consistent snapshots for programs
that read multiple hypfs binary files.
Signed-off-by: NMichael Holzheu <holzheu@linux.vnet.ibm.com>
Signed-off-by: NMartin Schwidefsky <schwidefsky@de.ibm.com>
上级 34c0dad7
...@@ -53,7 +53,6 @@ struct hypfs_dbfs_data { ...@@ -53,7 +53,6 @@ struct hypfs_dbfs_data {
void *buf_free_ptr; void *buf_free_ptr;
size_t size; size_t size;
struct hypfs_dbfs_file *dbfs_file; struct hypfs_dbfs_file *dbfs_file;
struct kref kref;
}; };
struct hypfs_dbfs_file { struct hypfs_dbfs_file {
...@@ -65,8 +64,6 @@ struct hypfs_dbfs_file { ...@@ -65,8 +64,6 @@ struct hypfs_dbfs_file {
unsigned long); unsigned long);
/* Private data for hypfs_dbfs.c */ /* Private data for hypfs_dbfs.c */
struct hypfs_dbfs_data *data;
struct delayed_work data_free_work;
struct mutex lock; struct mutex lock;
struct dentry *dentry; struct dentry *dentry;
}; };
......
...@@ -17,33 +17,16 @@ static struct hypfs_dbfs_data *hypfs_dbfs_data_alloc(struct hypfs_dbfs_file *f) ...@@ -17,33 +17,16 @@ static struct hypfs_dbfs_data *hypfs_dbfs_data_alloc(struct hypfs_dbfs_file *f)
data = kmalloc(sizeof(*data), GFP_KERNEL); data = kmalloc(sizeof(*data), GFP_KERNEL);
if (!data) if (!data)
return NULL; return NULL;
kref_init(&data->kref);
data->dbfs_file = f; data->dbfs_file = f;
return data; return data;
} }
static void hypfs_dbfs_data_free(struct kref *kref) static void hypfs_dbfs_data_free(struct hypfs_dbfs_data *data)
{ {
struct hypfs_dbfs_data *data;
data = container_of(kref, struct hypfs_dbfs_data, kref);
data->dbfs_file->data_free(data->buf_free_ptr); data->dbfs_file->data_free(data->buf_free_ptr);
kfree(data); kfree(data);
} }
static void data_free_delayed(struct work_struct *work)
{
struct hypfs_dbfs_data *data;
struct hypfs_dbfs_file *df;
df = container_of(work, struct hypfs_dbfs_file, data_free_work.work);
mutex_lock(&df->lock);
data = df->data;
df->data = NULL;
mutex_unlock(&df->lock);
kref_put(&data->kref, hypfs_dbfs_data_free);
}
static ssize_t dbfs_read(struct file *file, char __user *buf, static ssize_t dbfs_read(struct file *file, char __user *buf,
size_t size, loff_t *ppos) size_t size, loff_t *ppos)
{ {
...@@ -56,28 +39,21 @@ static ssize_t dbfs_read(struct file *file, char __user *buf, ...@@ -56,28 +39,21 @@ static ssize_t dbfs_read(struct file *file, char __user *buf,
df = file_inode(file)->i_private; df = file_inode(file)->i_private;
mutex_lock(&df->lock); mutex_lock(&df->lock);
if (!df->data) {
data = hypfs_dbfs_data_alloc(df); data = hypfs_dbfs_data_alloc(df);
if (!data) { if (!data) {
mutex_unlock(&df->lock); mutex_unlock(&df->lock);
return -ENOMEM; return -ENOMEM;
} }
rc = df->data_create(&data->buf, &data->buf_free_ptr, rc = df->data_create(&data->buf, &data->buf_free_ptr, &data->size);
&data->size);
if (rc) { if (rc) {
mutex_unlock(&df->lock); mutex_unlock(&df->lock);
kfree(data); kfree(data);
return rc; return rc;
} }
df->data = data;
schedule_delayed_work(&df->data_free_work, HZ);
}
data = df->data;
kref_get(&data->kref);
mutex_unlock(&df->lock); mutex_unlock(&df->lock);
rc = simple_read_from_buffer(buf, size, ppos, data->buf, data->size); rc = simple_read_from_buffer(buf, size, ppos, data->buf, data->size);
kref_put(&data->kref, hypfs_dbfs_data_free); hypfs_dbfs_data_free(data);
return rc; return rc;
} }
...@@ -108,7 +84,6 @@ int hypfs_dbfs_create_file(struct hypfs_dbfs_file *df) ...@@ -108,7 +84,6 @@ int hypfs_dbfs_create_file(struct hypfs_dbfs_file *df)
if (IS_ERR(df->dentry)) if (IS_ERR(df->dentry))
return PTR_ERR(df->dentry); return PTR_ERR(df->dentry);
mutex_init(&df->lock); mutex_init(&df->lock);
INIT_DELAYED_WORK(&df->data_free_work, data_free_delayed);
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册