diff options
| author | Raghavendra G <raghavendra@gluster.com> | 2010-07-07 08:15:12 +0000 | 
|---|---|---|
| committer | Anand V. Avati <avati@dev.gluster.com> | 2010-07-08 02:24:27 -0700 | 
| commit | 2233d7d3c54bf2fc7dc291ae19d8516b44f6e6af (patch) | |
| tree | 2249e735be52d5967ac0ba2d4ab89043b83338c5 | |
| parent | c85998fec484a0060c2a7cbcbf7ed42a109c6478 (diff) | |
performance/io-cache: implement mknod fop.
- mknod_cbk has to initialize ioc_inode context, since there is a possibility
    that open following immediately after mknod may not result in lookup before
    open fop.
Signed-off-by: Raghavendra G <raghavendra@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 1054 (Crash in ioc_open_cbk)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1054
| -rw-r--r-- | xlators/performance/io-cache/src/io-cache.c | 86 | 
1 files changed, 85 insertions, 1 deletions
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c index e548c965c31..4c633d824b2 100644 --- a/xlators/performance/io-cache/src/io-cache.c +++ b/xlators/performance/io-cache/src/io-cache.c @@ -654,6 +654,89 @@ ioc_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,  	return 0;  } + +int32_t +ioc_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, +               int32_t op_ret, int32_t op_errno, inode_t *inode, +               struct iatt *buf, struct iatt *preparent, +               struct iatt *postparent) +{ +	ioc_local_t *local     = NULL; +	ioc_table_t *table     = NULL; +	ioc_inode_t *ioc_inode = NULL; +	uint32_t     weight    = 0xffffffff; +	const char  *path      = NULL; + +        local = frame->local; +        table = this->private; +        path = local->file_loc.path; + +	if (op_ret != -1) { +                /* assign weight */ +                weight = ioc_get_priority (table, path); + +                ioc_inode = ioc_inode_update (table, inode, weight); + +                ioc_inode_lock (ioc_inode); +                { +                        ioc_inode->cache.mtime = buf->ia_mtime; +                        ioc_inode->cache.mtime_nsec = buf->ia_mtime_nsec; +                        ioc_inode->ia_size = buf->ia_size; +                } +                ioc_inode_unlock (ioc_inode); + +                inode_ctx_put (inode, this, +                               (uint64_t)(long)ioc_inode); +	} +   +	frame->local = NULL; +	GF_FREE (local); + +	STACK_UNWIND_STRICT (mknod, frame, op_ret, op_errno, inode, buf, +                             preparent, postparent); +	return 0; +} + + +int32_t +ioc_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode, +           dev_t rdev) +{ +        ioc_local_t *local = NULL; +        int32_t      op_errno = -1, ret = -1; + +        local = GF_CALLOC (1, sizeof (*local), +                           gf_ioc_mt_ioc_local_t); +        if (local == NULL) { +                op_errno = ENOMEM; +                gf_log (this->name, GF_LOG_ERROR, "out of memory"); +                goto unwind; +        } + +        ret = loc_copy (&local->file_loc, loc); +        if (ret != 0) { +                op_errno = ENOMEM; +                gf_log (this->name, GF_LOG_ERROR, "out of memory"); +                goto unwind; +        } + +        frame->local = local; + +	STACK_WIND (frame, +		    ioc_mknod_cbk, +		    FIRST_CHILD(this), +		    FIRST_CHILD(this)->fops->mknod, +		    loc, mode, rdev); +        return 0; + +unwind: +	STACK_UNWIND_STRICT (mknod, frame, -1, op_errno, NULL, NULL, +                             NULL, NULL); + +	return 0; +} + +  /*   * ioc_open - open fop for io cache   * @frame: @@ -1596,7 +1679,8 @@ struct xlator_fops fops = {  	.ftruncate   = ioc_ftruncate,  	.lookup      = ioc_lookup,  	.lk          = ioc_lk, -        .setattr     = ioc_setattr +        .setattr     = ioc_setattr, +        .mknod       = ioc_mknod  };  | 
