aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Holzheu <holzheu@linux.vnet.ibm.com>2015-02-09 08:49:32 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2015-02-10 10:39:02 -0500
commita178220df3a55c3ec46c2c2f0788a377acdb79c3 (patch)
tree04b2a61d015f576e4d2a75a7d048788cd316d0d9
parent34c0dad752294f373a0720840f59e186788ba227 (diff)
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: Michael Holzheu <holzheu@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--arch/s390/hypfs/hypfs.h3
-rw-r--r--arch/s390/hypfs/hypfs_dbfs.c49
2 files changed, 12 insertions, 40 deletions
diff --git a/arch/s390/hypfs/hypfs.h b/arch/s390/hypfs/hypfs.h
index 36d093fa9fb3..eecde500ed49 100644
--- a/arch/s390/hypfs/hypfs.h
+++ b/arch/s390/hypfs/hypfs.h
@@ -53,7 +53,6 @@ struct hypfs_dbfs_data {
53 void *buf_free_ptr; 53 void *buf_free_ptr;
54 size_t size; 54 size_t size;
55 struct hypfs_dbfs_file *dbfs_file; 55 struct hypfs_dbfs_file *dbfs_file;
56 struct kref kref;
57}; 56};
58 57
59struct hypfs_dbfs_file { 58struct hypfs_dbfs_file {
@@ -65,8 +64,6 @@ struct hypfs_dbfs_file {
65 unsigned long); 64 unsigned long);
66 65
67 /* Private data for hypfs_dbfs.c */ 66 /* Private data for hypfs_dbfs.c */
68 struct hypfs_dbfs_data *data;
69 struct delayed_work data_free_work;
70 struct mutex lock; 67 struct mutex lock;
71 struct dentry *dentry; 68 struct dentry *dentry;
72}; 69};
diff --git a/arch/s390/hypfs/hypfs_dbfs.c b/arch/s390/hypfs/hypfs_dbfs.c
index 47fe1055c714..752f6df3e697 100644
--- a/arch/s390/hypfs/hypfs_dbfs.c
+++ b/arch/s390/hypfs/hypfs_dbfs.c
@@ -17,33 +17,16 @@ static struct hypfs_dbfs_data *hypfs_dbfs_data_alloc(struct hypfs_dbfs_file *f)
17 data = kmalloc(sizeof(*data), GFP_KERNEL); 17 data = kmalloc(sizeof(*data), GFP_KERNEL);
18 if (!data) 18 if (!data)
19 return NULL; 19 return NULL;
20 kref_init(&data->kref);
21 data->dbfs_file = f; 20 data->dbfs_file = f;
22 return data; 21 return data;
23} 22}
24 23
25static void hypfs_dbfs_data_free(struct kref *kref) 24static void hypfs_dbfs_data_free(struct hypfs_dbfs_data *data)
26{ 25{
27 struct hypfs_dbfs_data *data;
28
29 data = container_of(kref, struct hypfs_dbfs_data, kref);
30 data->dbfs_file->data_free(data->buf_free_ptr); 26 data->dbfs_file->data_free(data->buf_free_ptr);
31 kfree(data); 27 kfree(data);
32} 28}
33 29
34static void data_free_delayed(struct work_struct *work)
35{
36 struct hypfs_dbfs_data *data;
37 struct hypfs_dbfs_file *df;
38
39 df = container_of(work, struct hypfs_dbfs_file, data_free_work.work);
40 mutex_lock(&df->lock);
41 data = df->data;
42 df->data = NULL;
43 mutex_unlock(&df->lock);
44 kref_put(&data->kref, hypfs_dbfs_data_free);
45}
46
47static ssize_t dbfs_read(struct file *file, char __user *buf, 30static ssize_t dbfs_read(struct file *file, char __user *buf,
48 size_t size, loff_t *ppos) 31 size_t size, loff_t *ppos)
49{ 32{
@@ -56,28 +39,21 @@ static ssize_t dbfs_read(struct file *file, char __user *buf,
56 39
57 df = file_inode(file)->i_private; 40 df = file_inode(file)->i_private;
58 mutex_lock(&df->lock); 41 mutex_lock(&df->lock);
59 if (!df->data) { 42 data = hypfs_dbfs_data_alloc(df);
60 data = hypfs_dbfs_data_alloc(df); 43 if (!data) {
61 if (!data) { 44 mutex_unlock(&df->lock);
62 mutex_unlock(&df->lock); 45 return -ENOMEM;
63 return -ENOMEM; 46 }
64 } 47 rc = df->data_create(&data->buf, &data->buf_free_ptr, &data->size);
65 rc = df->data_create(&data->buf, &data->buf_free_ptr, 48 if (rc) {
66 &data->size); 49 mutex_unlock(&df->lock);
67 if (rc) { 50 kfree(data);
68 mutex_unlock(&df->lock); 51 return rc;
69 kfree(data);
70 return rc;
71 }
72 df->data = data;
73 schedule_delayed_work(&df->data_free_work, HZ);
74 } 52 }
75 data = df->data;
76 kref_get(&data->kref);
77 mutex_unlock(&df->lock); 53 mutex_unlock(&df->lock);
78 54
79 rc = simple_read_from_buffer(buf, size, ppos, data->buf, data->size); 55 rc = simple_read_from_buffer(buf, size, ppos, data->buf, data->size);
80 kref_put(&data->kref, hypfs_dbfs_data_free); 56 hypfs_dbfs_data_free(data);
81 return rc; 57 return rc;
82} 58}
83 59
@@ -108,7 +84,6 @@ int hypfs_dbfs_create_file(struct hypfs_dbfs_file *df)
108 if (IS_ERR(df->dentry)) 84 if (IS_ERR(df->dentry))
109 return PTR_ERR(df->dentry); 85 return PTR_ERR(df->dentry);
110 mutex_init(&df->lock); 86 mutex_init(&df->lock);
111 INIT_DELAYED_WORK(&df->data_free_work, data_free_delayed);
112 return 0; 87 return 0;
113} 88}
114 89