From 1fc259cb73cb199052519f548dfbb1b83829b28f Mon Sep 17 00:00:00 2001 From: Vikas Gorur Date: Mon, 21 Sep 2009 05:19:47 +0000 Subject: storage/posix: Update nr_files after system call succeeds. In posix_open(), posix_create(), and posix_close(), update stats->nr_files only after the FOP has succeeded. Signed-off-by: Anand V. Avati BUG: 248 (Updating stats in posix is incorrect) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=248 --- xlators/storage/posix/src/posix.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'xlators/storage/posix') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index ef68aa72e3f..4f095d17bc9 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -1815,12 +1815,6 @@ posix_open (call_frame_t *frame, xlator_t *this, fd_ctx_set (fd, this, (uint64_t)(long)pfd); - LOCK (&priv->lock); - { - priv->stats.nr_files++; - } - UNLOCK (&priv->lock); - #ifndef HAVE_SET_FSID if (flags & O_CREAT) { op_ret = chown (real_path, frame->root->uid, gid); @@ -1863,6 +1857,12 @@ posix_open (call_frame_t *frame, xlator_t *this, } } + LOCK (&priv->lock); + { + priv->stats.nr_files++; + } + UNLOCK (&priv->lock); + op_ret = 0; out: @@ -2246,12 +2246,6 @@ posix_release (xlator_t *this, priv = this->private; - LOCK (&priv->lock); - { - priv->stats.nr_files--; - } - UNLOCK (&priv->lock); - ret = fd_ctx_get (fd, this, &tmp_pfd); if (ret < 0) { op_errno = -ret; @@ -2280,6 +2274,12 @@ posix_release (xlator_t *this, goto out; } + LOCK (&priv->lock); + { + priv->stats.nr_files--; + } + UNLOCK (&priv->lock); + op_ret = 0; out: -- cgit