From 63ece0f8bc81c2ec145465ff132a18ca47e50be5 Mon Sep 17 00:00:00 2001 From: vinayak hegde Date: Wed, 11 Nov 2009 22:52:01 +0000 Subject: cluster/stripe: Initialize frame->local before checking for directory or regular files. Signed-off-by: Vinayak Hegde Signed-off-by: Anand V. Avati BUG: 368 (setattr on a non-regular file makes glusterfs crash) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=368 --- xlators/cluster/stripe/src/stripe.c | 40 ++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'xlators/cluster/stripe/src/stripe.c') diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c index c2d500e922d..0b02060195e 100644 --- a/xlators/cluster/stripe/src/stripe.c +++ b/xlators/cluster/stripe/src/stripe.c @@ -893,6 +893,17 @@ stripe_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset) goto err; } + /* Initialization */ + local = CALLOC (1, sizeof (stripe_local_t)); + if (!local) { + op_errno = ENOMEM; + goto err; + } + local->op_ret = -1; + frame->local = local; + local->inode = loc->inode; + local->call_count = 1; + if (S_ISDIR (loc->inode->st_mode) || S_ISREG (loc->inode->st_mode)) send_fop_to_all = 1; @@ -900,15 +911,6 @@ stripe_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset) STACK_WIND (frame, stripe_truncate_cbk, trav->xlator, trav->xlator->fops->truncate, loc, offset); } else { - /* Initialization */ - local = CALLOC (1, sizeof (stripe_local_t)); - if (!local) { - op_errno = ENOMEM; - goto err; - } - local->op_ret = -1; - frame->local = local; - local->inode = loc->inode; local->call_count = priv->child_count; while (trav) { @@ -1032,6 +1034,17 @@ stripe_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, goto err; } + /* Initialization */ + local = CALLOC (1, sizeof (stripe_local_t)); + if (!local) { + op_errno = ENOMEM; + goto err; + } + local->op_ret = -1; + frame->local = local; + local->inode = loc->inode; + local->call_count = 1; + if (S_ISDIR (loc->inode->st_mode) || S_ISREG (loc->inode->st_mode)) send_fop_to_all = 1; @@ -1039,15 +1052,6 @@ stripe_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc, STACK_WIND (frame, stripe_setattr_cbk, trav->xlator, trav->xlator->fops->setattr, loc, stbuf, valid); } else { - /* Initialization */ - local = CALLOC (1, sizeof (stripe_local_t)); - if (!local) { - op_errno = ENOMEM; - goto err; - } - local->op_ret = -1; - frame->local = local; - local->inode = loc->inode; local->call_count = priv->child_count; while (trav) { -- cgit