* [patch -v2 06/23] s390/vmcp: use simple_read_from_buffer
[not found] <20080601231329.223608711@gmail.com>
@ 2008-06-01 23:13 ` akinobu.mita
2008-06-02 8:53 ` Christian Borntraeger
2008-06-01 23:13 ` [patch -v2 07/23] s390: " akinobu.mita
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: akinobu.mita @ 2008-06-01 23:13 UTC (permalink / raw)
To: linux-kernel; +Cc: Martin Schwidefsky, Heiko Carstens, linux390, linux-s390
[-- Attachment #1: s390-vmcp-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1502 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
drivers/s390/char/vmcp.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
Index: 2.6-git/drivers/s390/char/vmcp.c
===================================================================
--- 2.6-git.orig/drivers/s390/char/vmcp.c
+++ 2.6-git/drivers/s390/char/vmcp.c
@@ -61,30 +61,22 @@ static int vmcp_release(struct inode *in
static ssize_t
vmcp_read(struct file *file, char __user *buff, size_t count, loff_t *ppos)
{
- size_t tocopy;
+ ssize_t ret;
struct vmcp_session *session;
- session = (struct vmcp_session *)file->private_data;
+ session = file->private_data;
if (mutex_lock_interruptible(&session->mutex))
return -ERESTARTSYS;
if (!session->response) {
mutex_unlock(&session->mutex);
return 0;
}
- if (*ppos > session->resp_size) {
- mutex_unlock(&session->mutex);
- return 0;
- }
- tocopy = min(session->resp_size - (size_t) (*ppos), count);
- tocopy = min(tocopy, session->bufsize - (size_t) (*ppos));
+ ret = simple_read_from_buffer(buff, count, ppos,
+ session->response, session->resp_size);
- if (copy_to_user(buff, session->response + (*ppos), tocopy)) {
- mutex_unlock(&session->mutex);
- return -EFAULT;
- }
mutex_unlock(&session->mutex);
- *ppos += tocopy;
- return tocopy;
+
+ return ret;
}
static ssize_t
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch -v2 07/23] s390: use simple_read_from_buffer
[not found] <20080601231329.223608711@gmail.com>
2008-06-01 23:13 ` [patch -v2 06/23] s390/vmcp: use simple_read_from_buffer akinobu.mita
@ 2008-06-01 23:13 ` akinobu.mita
2008-06-01 23:13 ` [patch -v2 20/23] s390/cio: use memory_read_from_buffer akinobu.mita
2008-06-01 23:13 ` [patch -v2 21/23] s390: " akinobu.mita
3 siblings, 0 replies; 6+ messages in thread
From: akinobu.mita @ 2008-06-01 23:13 UTC (permalink / raw)
To: linux-kernel; +Cc: Martin Schwidefsky, Heiko Carstens, linux390, linux-s390
[-- Attachment #1: hypfs-use-simple-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1487 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
arch/s390/hypfs/inode.c | 29 ++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)
Index: 2.6-git/arch/s390/hypfs/inode.c
===================================================================
--- 2.6-git.orig/arch/s390/hypfs/inode.c
+++ 2.6-git/arch/s390/hypfs/inode.c
@@ -150,33 +150,24 @@ static ssize_t hypfs_aio_read(struct kio
unsigned long nr_segs, loff_t offset)
{
char *data;
- size_t len;
+ ssize_t ret;
struct file *filp = iocb->ki_filp;
/* XXX: temporary */
char __user *buf = iov[0].iov_base;
size_t count = iov[0].iov_len;
- if (nr_segs != 1) {
- count = -EINVAL;
- goto out;
- }
+ if (nr_segs != 1)
+ return -EINVAL;
data = filp->private_data;
- len = strlen(data);
- if (offset > len) {
- count = 0;
- goto out;
- }
- if (count > len - offset)
- count = len - offset;
- if (copy_to_user(buf, data + offset, count)) {
- count = -EFAULT;
- goto out;
- }
- iocb->ki_pos += count;
+ ret = simple_read_from_buffer(buf, count, &offset, data, strlen(data));
+ if (ret <= 0)
+ return ret;
+
+ iocb->ki_pos += ret;
file_accessed(filp);
-out:
- return count;
+
+ return ret;
}
static ssize_t hypfs_aio_write(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t offset)
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch -v2 20/23] s390/cio: use memory_read_from_buffer
[not found] <20080601231329.223608711@gmail.com>
2008-06-01 23:13 ` [patch -v2 06/23] s390/vmcp: use simple_read_from_buffer akinobu.mita
2008-06-01 23:13 ` [patch -v2 07/23] s390: " akinobu.mita
@ 2008-06-01 23:13 ` akinobu.mita
2008-06-01 23:13 ` [patch -v2 21/23] s390: " akinobu.mita
3 siblings, 0 replies; 6+ messages in thread
From: akinobu.mita @ 2008-06-01 23:13 UTC (permalink / raw)
To: linux-kernel; +Cc: Martin Schwidefsky, Heiko Carstens, linux390, linux-s390
[-- Attachment #1: cio-use-memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1259 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
drivers/s390/cio/chp.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
Index: 2.6-git/drivers/s390/cio/chp.c
===================================================================
--- 2.6-git.orig/drivers/s390/cio/chp.c
+++ 2.6-git/drivers/s390/cio/chp.c
@@ -15,6 +15,7 @@
#include <linux/wait.h>
#include <linux/mutex.h>
#include <linux/errno.h>
+#include <linux/fs.h>
#include <asm/chpid.h>
#include <asm/sclp.h>
@@ -141,21 +142,14 @@ static ssize_t chp_measurement_chars_rea
{
struct channel_path *chp;
struct device *device;
- unsigned int size;
device = container_of(kobj, struct device, kobj);
chp = to_channelpath(device);
if (!chp->cmg_chars)
return 0;
- size = sizeof(struct cmg_chars);
-
- if (off > size)
- return 0;
- if (off + count > size)
- count = size - off;
- memcpy(buf, chp->cmg_chars + off, count);
- return count;
+ return memory_read_from_buffer(buf, count, &off,
+ chp->cmg_chars, sizeof(struct cmg_chars));
}
static struct bin_attribute chp_measurement_chars_attr = {
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* [patch -v2 21/23] s390: use memory_read_from_buffer
[not found] <20080601231329.223608711@gmail.com>
` (2 preceding siblings ...)
2008-06-01 23:13 ` [patch -v2 20/23] s390/cio: use memory_read_from_buffer akinobu.mita
@ 2008-06-01 23:13 ` akinobu.mita
3 siblings, 0 replies; 6+ messages in thread
From: akinobu.mita @ 2008-06-01 23:13 UTC (permalink / raw)
To: linux-kernel; +Cc: Martin Schwidefsky, Heiko Carstens, linux390, linux-s390
[-- Attachment #1: s390-ipl-use-memory-read-from-buffer.patch --]
[-- Type: text/plain, Size: 1685 bytes --]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: linux390@de.ibm.com
Cc: linux-s390@vger.kernel.org
---
arch/s390/kernel/ipl.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
Index: 2.6-git/arch/s390/kernel/ipl.c
===================================================================
--- 2.6-git.orig/arch/s390/kernel/ipl.c
+++ 2.6-git/arch/s390/kernel/ipl.c
@@ -14,6 +14,7 @@
#include <linux/delay.h>
#include <linux/reboot.h>
#include <linux/ctype.h>
+#include <linux/fs.h>
#include <asm/ipl.h>
#include <asm/smp.h>
#include <asm/setup.h>
@@ -285,14 +286,8 @@ static struct kobj_attribute sys_ipl_dev
static ssize_t ipl_parameter_read(struct kobject *kobj, struct bin_attribute *attr,
char *buf, loff_t off, size_t count)
{
- unsigned int size = IPL_PARMBLOCK_SIZE;
-
- if (off > size)
- return 0;
- if (off + count > size)
- count = size - off;
- memcpy(buf, (void *)IPL_PARMBLOCK_START + off, count);
- return count;
+ return memory_read_from_buffer(buf, count, &off, IPL_PARMBLOCK_START,
+ IPL_PARMBLOCK_SIZE);
}
static struct bin_attribute ipl_parameter_attr = {
@@ -310,12 +305,7 @@ static ssize_t ipl_scp_data_read(struct
unsigned int size = IPL_PARMBLOCK_START->ipl_info.fcp.scp_data_len;
void *scp_data = &IPL_PARMBLOCK_START->ipl_info.fcp.scp_data;
- if (off > size)
- return 0;
- if (off + count > size)
- count = size - off;
- memcpy(buf, scp_data + off, count);
- return count;
+ return memory_read_from_buffer(buf, count, &off, scp_data, size);
}
static struct bin_attribute ipl_scp_data_attr = {
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch -v2 06/23] s390/vmcp: use simple_read_from_buffer
2008-06-01 23:13 ` [patch -v2 06/23] s390/vmcp: use simple_read_from_buffer akinobu.mita
@ 2008-06-02 8:53 ` Christian Borntraeger
2008-06-02 12:28 ` Akinobu Mita
0 siblings, 1 reply; 6+ messages in thread
From: Christian Borntraeger @ 2008-06-02 8:53 UTC (permalink / raw)
To: akinobu.mita
Cc: linux-kernel, Martin Schwidefsky, Heiko Carstens, linux390,
linux-s390
Am Montag, 2. Juni 2008 schrieb akinobu.mita@gmail.com:
> - tocopy = min(session->resp_size - (size_t) (*ppos), count);
> - tocopy = min(tocopy, session->bufsize - (size_t) (*ppos));
> + ret = simple_read_from_buffer(buff, count, ppos,
> + session->response, session->resp_size);
>
Its not that simple. The z/VM Diagnose 8 has a quite interesting return value.
- session->bufsize is the size of the buffer as we allocated and know
- session->resp_size is the size of the data - no matter if the buffer was
large enough. z/VM is smart enough to not go beyond the buffer, but it tells
us how many bytes it skipped. resp_size contains bufsize + skipped_bytes.
Unfortunately there is no end of string delimiter and we have to use the
response size.
There are two cases:
1. The buffer was large enough, so we can use session->resp_size
2. The buffer was not large enough and output was truncated. we must now use
session->bufsize
Christian
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch -v2 06/23] s390/vmcp: use simple_read_from_buffer
2008-06-02 8:53 ` Christian Borntraeger
@ 2008-06-02 12:28 ` Akinobu Mita
0 siblings, 0 replies; 6+ messages in thread
From: Akinobu Mita @ 2008-06-02 12:28 UTC (permalink / raw)
To: Christian Borntraeger
Cc: linux-kernel, Martin Schwidefsky, Heiko Carstens, linux390,
linux-s390
2008/6/2 Christian Borntraeger <borntraeger@de.ibm.com>:
> Am Montag, 2. Juni 2008 schrieb akinobu.mita@gmail.com:
>
>> - tocopy = min(session->resp_size - (size_t) (*ppos), count);
>> - tocopy = min(tocopy, session->bufsize - (size_t) (*ppos));
>> + ret = simple_read_from_buffer(buff, count, ppos,
>> + session->response, session->resp_size);
>>
>
> Its not that simple. The z/VM Diagnose 8 has a quite interesting return value.
>
> - session->bufsize is the size of the buffer as we allocated and know
> - session->resp_size is the size of the data - no matter if the buffer was
> large enough. z/VM is smart enough to not go beyond the buffer, but it tells
> us how many bytes it skipped. resp_size contains bufsize + skipped_bytes.
>
> Unfortunately there is no end of string delimiter and we have to use the
> response size.
>
> There are two cases:
> 1. The buffer was large enough, so we can use session->resp_size
> 2. The buffer was not large enough and output was truncated. we must now use
> session->bufsize
Thanks. I made too much simplified the original code.
So I'll change these lines to be
size_t size = min_t(size_t, session->resp_size, session->bufsize);
ret = simple_read_from_buffer(buff, count, ppos, session->response, size);
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-06-02 12:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20080601231329.223608711@gmail.com>
2008-06-01 23:13 ` [patch -v2 06/23] s390/vmcp: use simple_read_from_buffer akinobu.mita
2008-06-02 8:53 ` Christian Borntraeger
2008-06-02 12:28 ` Akinobu Mita
2008-06-01 23:13 ` [patch -v2 07/23] s390: " akinobu.mita
2008-06-01 23:13 ` [patch -v2 20/23] s390/cio: use memory_read_from_buffer akinobu.mita
2008-06-01 23:13 ` [patch -v2 21/23] s390: " akinobu.mita
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox