From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org
Cc: Melissa Howland <melissah@us.ibm.com>,
Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [patch 10/18] monwriter: Serialization bug for multithreaded applications.
Date: Tue, 07 Aug 2007 13:15:30 +0200 [thread overview]
Message-ID: <20070807111847.096356469@de.ibm.com> (raw)
In-Reply-To: 20070807111519.972871123@de.ibm.com
[-- Attachment #1: 010-monwriter.diff --]
[-- Type: text/plain, Size: 1866 bytes --]
From: Melissa Howland <melissah@us.ibm.com>
Locking added so that multithreaded applications can now do writes
from different threads without the risk of storage corruption.
Signed-off-by: Melissa Howland <melissah@us.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---
drivers/s390/char/monwriter.c | 6 ++++++
1 file changed, 6 insertions(+)
Index: quilt-2.6/drivers/s390/char/monwriter.c
===================================================================
--- quilt-2.6.orig/drivers/s390/char/monwriter.c
+++ quilt-2.6/drivers/s390/char/monwriter.c
@@ -17,6 +17,7 @@
#include <linux/miscdevice.h>
#include <linux/ctype.h>
#include <linux/poll.h>
+#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <asm/ebcdic.h>
#include <asm/io.h>
@@ -41,6 +42,7 @@ struct mon_private {
size_t hdr_to_read;
size_t data_to_read;
struct mon_buf *current_buf;
+ struct mutex thread_mutex;
};
/*
@@ -179,6 +181,7 @@ static int monwrite_open(struct inode *i
return -ENOMEM;
INIT_LIST_HEAD(&monpriv->list);
monpriv->hdr_to_read = sizeof(monpriv->hdr);
+ mutex_init(&monpriv->thread_mutex);
filp->private_data = monpriv;
return nonseekable_open(inode, filp);
}
@@ -209,6 +212,7 @@ static ssize_t monwrite_write(struct fil
void *to;
int rc;
+ mutex_lock(&monpriv->thread_mutex);
for (written = 0; written < count; ) {
if (monpriv->hdr_to_read) {
len = min(count - written, monpriv->hdr_to_read);
@@ -247,11 +251,13 @@ static ssize_t monwrite_write(struct fil
}
monpriv->hdr_to_read = sizeof(monpriv->hdr);
}
+ mutex_unlock(&monpriv->thread_mutex);
return written;
out_error:
monpriv->data_to_read = 0;
monpriv->hdr_to_read = sizeof(struct monwrite_hdr);
+ mutex_unlock(&monpriv->thread_mutex);
return rc;
}
--
blue skies,
Martin.
"Reality continues to ruin my life." - Calvin.
next prev parent reply other threads:[~2007-08-07 11:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-07 11:15 [patch 00/18] s390 patches against 2.6.23-rc2 Martin Schwidefsky
2007-08-07 11:15 ` [patch 01/18] cio: avoid memory leak on error in css_alloc_subchannel() Martin Schwidefsky
2007-08-07 11:15 ` [patch 02/18] hypfs: implement show_options Martin Schwidefsky
2007-08-07 11:15 ` [patch 03/18] qdio: make sure data structures are correctly aligned Martin Schwidefsky
2007-08-07 11:15 ` [patch 04/18] remove DEFAULT_MIGRATION_COST Martin Schwidefsky
2007-08-07 11:15 ` [patch 05/18] vmur: allocate single record buffers instead of one big data buffer Martin Schwidefsky
2007-08-07 11:15 ` [patch 06/18] vmur: use DECLARE_COMPLETION_ONSTACK to keep lockdep happy Martin Schwidefsky
2007-08-07 11:15 ` [patch 07/18] vmur: reject open on z/VM reader files with status HOLD Martin Schwidefsky
2007-08-07 11:15 ` [patch 08/18] vmur: add "top of queue" sanity check for reader open Martin Schwidefsky
2007-08-07 11:15 ` [patch 09/18] vmur: diag14 only works with buffers below 2GB Martin Schwidefsky
2007-08-07 11:15 ` Martin Schwidefsky [this message]
2007-08-07 11:15 ` [patch 11/18] cio: rename css to channel_subsystems Martin Schwidefsky
2007-08-07 11:15 ` [patch 12/18] cio: remove subchannel_add_files() Martin Schwidefsky
2007-08-07 11:15 ` [patch 13/18] cio: Fix some coding style issues in cmf Martin Schwidefsky
2007-08-07 11:15 ` [patch 14/18] cio: Kerneldoc comments for cmf Martin Schwidefsky
2007-08-07 11:15 ` [patch 15/18] cio: Add docbook comments Martin Schwidefsky
2007-08-07 11:15 ` [patch 16/18] cio: Add s390-drivers book Martin Schwidefsky
2007-08-07 11:15 ` [patch 17/18] zcrypt: make init/exit functions static Martin Schwidefsky
2007-08-07 11:15 ` [patch 18/18] Get rid of a bunch of sparse warnings again Martin Schwidefsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070807111847.096356469@de.ibm.com \
--to=schwidefsky@de.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=melissah@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox