summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-transaction.c
diff options
context:
space:
mode:
authorVikas Gorur <vikas@zresearch.com>2009-02-26 17:51:47 +0530
committerAnand V. Avati <avati@amp.gluster.com>2009-02-26 18:03:18 +0530
commitc445012fa990be5dbc0ccbace04187484ccd92f3 (patch)
treef05154080893cfc2a8bd1e77b555b429c6c4a2fc /xlators/cluster/afr/src/afr-transaction.c
parent523d23b94c21cf5cfdfd087409371d9d2dcf25a4 (diff)
protect fd_ctx get/set in afr_transaction and afr.c with locks
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-transaction.c')
-rw-r--r--xlators/cluster/afr/src/afr-transaction.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/xlators/cluster/afr/src/afr-transaction.c b/xlators/cluster/afr/src/afr-transaction.c
index 3df9f07e5..f9a0a8806 100644
--- a/xlators/cluster/afr/src/afr-transaction.c
+++ b/xlators/cluster/afr/src/afr-transaction.c
@@ -67,20 +67,24 @@ __mark_all_success (int32_t *pending, int child_count)
static int
__is_first_write_on_fd (xlator_t *this, fd_t *fd)
{
- int op_ret = 0;
- int _ret = -1;
-
- _ret = fd_ctx_get (fd, this, NULL);
- if (_ret < 0) {
- gf_log (this->name, GF_LOG_DEBUG,
- "first writev() on fd=%p, writing changelog",
- fd);
-
- _ret = fd_ctx_set (fd, this, 0xaf1);
- op_ret = 1;
- }
-
- return op_ret;
+ int op_ret = 0;
+ int _ret = -1;
+
+ LOCK (&fd->inode->lock);
+ {
+ _ret = fd_ctx_get (fd, this, NULL);
+ if (_ret < 0) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "first writev() on fd=%p, writing changelog",
+ fd);
+
+ _ret = fd_ctx_set (fd, this, 0xaf1);
+ op_ret = 1;
+ }
+ }
+ UNLOCK (&fd->inode->lock);
+
+ return op_ret;
}