diff options
Diffstat (limited to 'xlators/cluster/map')
-rw-r--r-- | xlators/cluster/map/src/map.c | 1708 |
1 files changed, 1065 insertions, 643 deletions
diff --git a/xlators/cluster/map/src/map.c b/xlators/cluster/map/src/map.c index f4859ee7199..2ea60c456eb 100644 --- a/xlators/cluster/map/src/map.c +++ b/xlators/cluster/map/src/map.c @@ -1,5 +1,5 @@ /* - Copyright (c) 2009-2009 Z RESEARCH, Inc. <http://www.zresearch.com> + Copyright (c) 2009 Z RESEARCH, Inc. <http://www.zresearch.com> This file is part of GlusterFS. GlusterFS is free software; you can redistribute it and/or modify @@ -25,11 +25,880 @@ #include "xlator.h" #include "map.h" -/* For <op>_cbk functions */ -#include "defaults.c" +/* TODO : + * -> support for 'get' 'put' API in through xattrs. + * -> define the behavior of notify() + */ + +static int32_t +map_stat_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *buf) + +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, buf); + return 0; +} + + +static int32_t +map_chmod_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *buf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, buf); + return 0; +} + + +static int32_t +map_fchmod_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *buf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, buf); + return 0; +} + + +static int32_t +map_chown_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *buf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, buf); + return 0; +} + + +static int32_t +map_fchown_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *buf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, buf); + return 0; +} + +static int32_t +map_truncate_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *buf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, buf); + return 0; +} + +static int32_t +map_ftruncate_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *buf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, buf); + return 0; +} + +int32_t +map_utimens_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *buf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, buf); + return 0; +} + + +static int32_t +map_access_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + +static int32_t +map_readlink_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + const char *path) +{ + STACK_UNWIND (frame, op_ret, op_errno, path); + return 0; +} + +static int32_t +map_unlink_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + +static int32_t +map_rmdir_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + + +static int32_t +map_rename_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *buf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, buf); + return 0; +} + +static int32_t +map_link_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + inode_t *inode, + struct stat *buf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, inode, buf); + return 0; +} + +static int32_t +map_open_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + fd_t *fd) +{ + STACK_UNWIND (frame, op_ret, op_errno, fd); + return 0; +} + +static int32_t +map_readv_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct iovec *vector, + int32_t count, + struct stat *stbuf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, stbuf->st_ino, &stbuf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, vector, count, stbuf); + return 0; +} + +static int32_t +map_writev_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *stbuf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, stbuf->st_ino, &stbuf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, stbuf); + return 0; +} + +static int32_t +map_flush_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + + +static int32_t +map_fsync_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + + +static int32_t +map_fstat_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct stat *buf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, buf); + return 0; +} + + +static int32_t +map_getdents_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + dir_entry_t *entries, + int32_t count) +{ + STACK_UNWIND (frame, op_ret, op_errno, entries, count); + return 0; +} + + +static int32_t +map_setdents_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + +static int32_t +map_fsyncdir_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + + +static int32_t +map_setxattr_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + + +static int32_t +map_fsetxattr_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + + +static int32_t +map_fgetxattr_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + dict_t *dict) +{ + STACK_UNWIND (frame, op_ret, op_errno, dict); + return 0; +} + + + +static int32_t +map_getxattr_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + dict_t *dict) +{ + STACK_UNWIND (frame, op_ret, op_errno, dict); + return 0; +} + +int32_t +map_xattrop_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + dict_t *dict) +{ + STACK_UNWIND (frame, op_ret, op_errno, dict); + return 0; +} + +int32_t +map_fxattrop_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + dict_t *dict) +{ + STACK_UNWIND (frame, op_ret, op_errno, dict); + return 0; +} + +static int32_t +map_removexattr_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + + +static int32_t +map_lk_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct flock *lock) +{ + STACK_UNWIND (frame, op_ret, op_errno, lock); + return 0; +} + + +static int32_t +map_inodelk_cbk (call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, int32_t op_errno) + +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + + + +static int32_t +map_finodelk_cbk (call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, int32_t op_errno) + +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + + +static int32_t +map_entrylk_cbk (call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, int32_t op_errno) + +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + + +static int32_t +map_fentrylk_cbk (call_frame_t *frame, void *cookie, + xlator_t *this, int32_t op_ret, int32_t op_errno) + +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + +static int32_t +map_newentry_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + inode_t *inode, + struct stat *buf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, inode, buf); + return 0; + +} + + +static int32_t +map_create_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + fd_t *fd, + inode_t *inode, + struct stat *buf) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, fd, inode, buf); + return 0; +} + + +/* + * map_normalize_stats - + */ +void +map_normalize_stats (struct statvfs *buf, + unsigned long bsize, + unsigned long frsize) +{ + double factor; + + if (buf->f_bsize != bsize) { + factor = ((double) buf->f_bsize) / bsize; + buf->f_bsize = bsize; + buf->f_bfree = (fsblkcnt_t) (factor * buf->f_bfree); + buf->f_bavail = (fsblkcnt_t) (factor * buf->f_bavail); + } + + if (buf->f_frsize != frsize) { + factor = ((double) buf->f_frsize) / frsize; + buf->f_frsize = frsize; + buf->f_blocks = (fsblkcnt_t) (factor * buf->f_blocks); + } +} int32_t +map_statfs_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + struct statvfs *stbuf) +{ + struct statvfs *dict_buf = NULL; + map_local_t *local = NULL; + int this_call_cnt = 0; + unsigned long bsize; + unsigned long frsize; + + local = frame->local; + + LOCK (&frame->lock); + { + this_call_cnt = --local->call_count; + + if (op_ret == -1) { + local->op_errno = op_errno; + goto unlock; + } + local->op_ret = 0; + + /* when a call is successfull, add it to local->dict */ + dict_buf = &local->statvfs; + + if (dict_buf->f_bsize != 0) { + bsize = max (dict_buf->f_bsize, + stbuf->f_bsize); + + frsize = max (dict_buf->f_frsize, + stbuf->f_frsize); + map_normalize_stats(dict_buf, bsize, frsize); + map_normalize_stats(stbuf, bsize, frsize); + } else { + dict_buf->f_bsize = stbuf->f_bsize; + dict_buf->f_frsize = stbuf->f_frsize; + } + + dict_buf->f_blocks += stbuf->f_blocks; + dict_buf->f_bfree += stbuf->f_bfree; + dict_buf->f_bavail += stbuf->f_bavail; + dict_buf->f_files += stbuf->f_files; + dict_buf->f_ffree += stbuf->f_ffree; + dict_buf->f_favail += stbuf->f_favail; + dict_buf->f_fsid = stbuf->f_fsid; + dict_buf->f_flag = stbuf->f_flag; + dict_buf->f_namemax = stbuf->f_namemax; + } +unlock: + UNLOCK (&frame->lock); + + if (!this_call_cnt) { + STACK_UNWIND (frame, local->op_ret, local->op_errno, + &local->statvfs); + } + + return 0; +} + +int32_t +map_single_lookup_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + inode_t *inode, + struct stat *buf, + dict_t *dict) +{ + call_frame_t *prev = NULL; + prev = cookie; + + map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); + + STACK_UNWIND (frame, op_ret, op_errno, inode, buf, dict); + + return 0; +} + +int32_t +map_root_lookup_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + inode_t *inode, + struct stat *buf, + dict_t *dict) +{ + int callcnt = 0; + map_local_t *local = NULL; + inode_t *tmp_inode = NULL; + dict_t *tmp_dict = NULL; + + local = frame->local; + LOCK (&frame->lock); + { + callcnt = --local->call_count; + if ((op_ret == 0) && (local->op_ret == -1)) { + local->op_ret = 0; + local->stbuf = *buf; + if (dict) + local->dict = dict_ref (dict); + local->inode = inode_ref (inode); + } + if (op_ret == -1) + local->op_errno = op_errno; + + } + UNLOCK (&frame->lock); + + if (!callcnt) { + tmp_dict = local->dict; + tmp_inode = local->inode; + + STACK_UNWIND (frame, local->op_ret, + local->op_errno, local->inode, + &local->stbuf, local->dict); + + inode_unref (local->inode); + if (tmp_dict) + dict_unref (tmp_dict); + } + + return 0; +} + + +int32_t +map_opendir_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + fd_t *fd) +{ + int callcnt = 0; + map_local_t *local = NULL; + fd_t *local_fd = NULL; + + local = frame->local; + LOCK (&frame->lock); + { + callcnt = --local->call_count; + + if (op_ret == -1) { + local->op_errno = op_errno; + goto unlock; + } + + local->op_ret = 0; + } + unlock: + UNLOCK (&frame->lock); + + if (!callcnt) { + local_fd = local->fd; + local->fd = NULL; + + STACK_UNWIND (frame, local->op_ret, + local->op_errno, local_fd); + + fd_unref (local_fd); + } + return 0; +} + +int32_t +map_single_readdir_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + gf_dirent_t *entries) +{ + call_frame_t *prev = NULL; + gf_dirent_t *orig_entry = NULL; + + prev = cookie; + + list_for_each_entry (orig_entry, &entries->list, list) { + map_itransform (this, prev->this, orig_entry->d_ino, + &orig_entry->d_ino); + } + STACK_UNWIND (frame, op_ret, op_errno, entries); + + return 0; +} + + +int +map_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int op_ret, int op_errno, gf_dirent_t *orig_entries) +{ + map_local_t *local = NULL; + gf_dirent_t entries; + gf_dirent_t *orig_entry = NULL; + gf_dirent_t *entry = NULL; + call_frame_t *prev = NULL; + xlator_t *subvol = NULL; + xlator_t *next_subvol = NULL; + off_t next_offset = 0; + int count = 0; + fd_t *local_fd = NULL; + + INIT_LIST_HEAD (&entries.list); + prev = cookie; + local = frame->local; + + if (op_ret < 0) + goto done; + + list_for_each_entry (orig_entry, &orig_entries->list, list) { + subvol = prev->this; + + entry = gf_dirent_for_name (orig_entry->d_name); + if (!entry) { + gf_log (this->name, GF_LOG_ERROR, + "memory allocation failed :("); + goto unwind; + } + + map_itransform (this, subvol, orig_entry->d_ino, + &entry->d_ino); + map_itransform (this, subvol, orig_entry->d_off, + &entry->d_off); + + entry->d_type = orig_entry->d_type; + entry->d_len = orig_entry->d_len; + + list_add_tail (&entry->list, &entries.list); + count++; + next_offset = orig_entry->d_off; + } + + op_ret = count; + +done: + if (count == 0) { + /* non-zero next_offset means that + EOF is not yet hit on the current subvol + */ + if (next_offset == 0) { + next_subvol = map_subvol_next (this, prev->this); + } else { + next_subvol = prev->this; + } + + if (!next_subvol) { + goto unwind; + } + + STACK_WIND (frame, map_readdir_cbk, + next_subvol, next_subvol->fops->readdir, + local->fd, local->size, 0); + return 0; + } + +unwind: + if (op_ret < 0) + op_ret = 0; + + local_fd = local->fd; + local->fd = NULL; + + STACK_UNWIND (frame, op_ret, op_errno, &entries); + + fd_unref (local_fd); + + gf_dirent_free (&entries); + + return 0; +} + + +/* Management operations */ + +static int32_t +map_checksum_cbk (call_frame_t *frame, + void *cookie, + xlator_t *this, + int32_t op_ret, + int32_t op_errno, + uint8_t *file_checksum, + uint8_t *dir_checksum) +{ + STACK_UNWIND (frame, op_ret, op_errno, file_checksum, dir_checksum); + return 0; +} + + +int32_t +map_lock_notify_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + + +int32_t +map_lock_fnotify_cbk (call_frame_t *frame, void *cookie, xlator_t *this, + int32_t op_ret, int32_t op_errno) +{ + STACK_UNWIND (frame, op_ret, op_errno); + return 0; +} + +/* Fops starts here */ + +int32_t map_stat (call_frame_t *frame, xlator_t *this, loc_t *loc) @@ -49,11 +918,7 @@ map_stat (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_stat_cbk, - subvol, - subvol->fops->stat, - loc); + STACK_WIND (frame, map_stat_cbk, subvol, subvol->fops->stat, loc); return 0; err: @@ -84,12 +949,8 @@ map_chmod (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_chmod_cbk, - subvol, - subvol->fops->chmod, - loc, - mode); + STACK_WIND (frame, map_chmod_cbk, subvol, + subvol->fops->chmod, loc, mode); return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -117,12 +978,9 @@ map_fchmod (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_fchmod_cbk, - subvol, - subvol->fops->fchmod, - fd, - mode); + STACK_WIND (frame, map_fchmod_cbk, subvol, + subvol->fops->fchmod, fd, mode); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -152,13 +1010,8 @@ map_chown (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_chown_cbk, - subvol, - subvol->fops->chown, - loc, - uid, - gid); + STACK_WIND (frame, map_chown_cbk, subvol, + subvol->fops->chown, loc, uid, gid); return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -187,13 +1040,9 @@ map_fchown (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_fchown_cbk, - subvol, - subvol->fops->fchown, - fd, - uid, - gid); + STACK_WIND (frame, map_fchown_cbk, subvol, + subvol->fops->fchown, fd, uid, gid); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -222,12 +1071,9 @@ map_truncate (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_truncate_cbk, - subvol, - subvol->fops->truncate, - loc, - offset); + STACK_WIND (frame, map_truncate_cbk, subvol, + subvol->fops->truncate, loc, offset); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -255,12 +1101,9 @@ map_ftruncate (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_ftruncate_cbk, - subvol, - subvol->fops->ftruncate, - fd, - offset); + STACK_WIND (frame, map_ftruncate_cbk, subvol, + subvol->fops->ftruncate, fd, offset); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -289,12 +1132,9 @@ map_utimens (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_utimens_cbk, - subvol, - subvol->fops->utimens, - loc, - tv); + STACK_WIND (frame, map_utimens_cbk, subvol, + subvol->fops->utimens, loc, tv); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -323,12 +1163,9 @@ map_access (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_access_cbk, - subvol, - subvol->fops->access, - loc, - mask); + STACK_WIND (frame, map_access_cbk, subvol, + subvol->fops->access, loc, mask); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -358,12 +1195,9 @@ map_readlink (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_readlink_cbk, - subvol, - subvol->fops->readlink, - loc, - size); + STACK_WIND (frame, map_readlink_cbk, subvol, + subvol->fops->readlink, loc, size); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -391,11 +1225,8 @@ map_unlink (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_unlink_cbk, - subvol, - subvol->fops->unlink, - loc); + STACK_WIND (frame, map_unlink_cbk, subvol, subvol->fops->unlink, loc); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -423,11 +1254,8 @@ map_rmdir (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_rmdir_cbk, - subvol, - subvol->fops->rmdir, - loc); + STACK_WIND (frame, map_rmdir_cbk, subvol, subvol->fops->rmdir, loc); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -460,19 +1288,16 @@ map_rename (call_frame_t *frame, } if (newloc->path) { - new_subvol = get_mapping_subvol_from_path (this, - newloc->path); + new_subvol = get_mapping_subvol_from_path (this, newloc->path); if (new_subvol && (new_subvol != old_subvol)) { op_errno = EXDEV; goto err; } } - STACK_WIND (frame, - default_rename_cbk, - old_subvol, - old_subvol->fops->rename, - oldloc, newloc); + STACK_WIND (frame, map_rename_cbk, old_subvol, + old_subvol->fops->rename, oldloc, newloc); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -505,19 +1330,16 @@ map_link (call_frame_t *frame, } if (newloc->path) { - new_subvol = get_mapping_subvol_from_path (this, - newloc->path); + new_subvol = get_mapping_subvol_from_path (this, newloc->path); if (new_subvol && (new_subvol != old_subvol)) { op_errno = EXDEV; goto err; } } - STACK_WIND (frame, - default_link_cbk, - old_subvol, - old_subvol->fops->link, - oldloc, newloc); + STACK_WIND (frame, map_link_cbk, old_subvol, + old_subvol->fops->link, oldloc, newloc); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -547,11 +1369,9 @@ map_open (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_open_cbk, - subvol, - subvol->fops->open, - loc, flags, fd); + STACK_WIND (frame, map_open_cbk, subvol, + subvol->fops->open, loc, flags, fd); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -580,13 +1400,9 @@ map_readv (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_readv_cbk, - subvol, - subvol->fops->readv, - fd, - size, - offset); + STACK_WIND (frame, map_readv_cbk, subvol, + subvol->fops->readv, fd, size, offset); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -616,14 +1432,9 @@ map_writev (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_writev_cbk, - subvol, - subvol->fops->writev, - fd, - vector, - count, - off); + STACK_WIND (frame, map_writev_cbk, subvol, + subvol->fops->writev, fd, vector, count, off); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -650,11 +1461,8 @@ map_flush (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_flush_cbk, - subvol, - subvol->fops->flush, - fd); + STACK_WIND (frame, map_flush_cbk, subvol, subvol->fops->flush, fd); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -683,12 +1491,9 @@ map_fsync (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_fsync_cbk, - subvol, - subvol->fops->fsync, - fd, - flags); + STACK_WIND (frame, map_fsync_cbk, subvol, + subvol->fops->fsync, fd, flags); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -715,11 +1520,8 @@ map_fstat (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_fstat_cbk, - subvol, - subvol->fops->fstat, - fd); + STACK_WIND (frame, map_fstat_cbk, subvol, subvol->fops->fstat, fd); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -749,14 +1551,9 @@ map_getdents (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_getdents_cbk, - subvol, - subvol->fops->getdents, - fd, - size, - offset, - flag); + STACK_WIND (frame, map_getdents_cbk, subvol, + subvol->fops->getdents, fd, size, offset, flag); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -786,14 +1583,9 @@ map_setdents (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_setdents_cbk, - subvol, - subvol->fops->setdents, - fd, - flags, - entries, - count); + STACK_WIND (frame, map_setdents_cbk, subvol, + subvol->fops->setdents, fd, flags, entries, count); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -822,12 +1614,9 @@ map_fsyncdir (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_fsyncdir_cbk, - subvol, - subvol->fops->fsyncdir, - fd, - flags); + STACK_WIND (frame, map_fsyncdir_cbk, subvol, + subvol->fops->fsyncdir, fd, flags); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -845,7 +1634,6 @@ map_setxattr (call_frame_t *frame, dict_t *dict, int32_t flags) { - /* TODO: support for 'get' 'put' API */ int32_t op_errno = 1; xlator_t *subvol = NULL; @@ -861,13 +1649,9 @@ map_setxattr (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_setxattr_cbk, - subvol, - subvol->fops->setxattr, - loc, - dict, - flags); + STACK_WIND (frame, map_setxattr_cbk, subvol, + subvol->fops->setxattr, loc, dict, flags); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -881,7 +1665,6 @@ map_getxattr (call_frame_t *frame, loc_t *loc, const char *name) { - /* TODO: support for 'get' 'put' API */ int32_t op_errno = 1; xlator_t *subvol = NULL; @@ -897,12 +1680,9 @@ map_getxattr (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_getxattr_cbk, - subvol, - subvol->fops->getxattr, - loc, - name); + STACK_WIND (frame, map_getxattr_cbk, subvol, + subvol->fops->getxattr, loc, name); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -910,6 +1690,69 @@ map_getxattr (call_frame_t *frame, return 0; } + +int32_t +map_fsetxattr (call_frame_t *frame, + xlator_t *this, + fd_t *fd, + dict_t *dict, + int32_t flags) +{ + int32_t op_errno = 1; + xlator_t *subvol = NULL; + + VALIDATE_OR_GOTO (frame, err); + VALIDATE_OR_GOTO (this, err); + VALIDATE_OR_GOTO (fd, err); + VALIDATE_OR_GOTO (fd->inode, err); + + subvol = get_mapping_subvol_from_ctx (this, fd->inode); + if (!subvol) { + op_errno = EINVAL; + goto err; + } + + STACK_WIND (frame, map_fsetxattr_cbk, subvol, + subvol->fops->fsetxattr, fd, dict, flags); + + return 0; + err: + STACK_UNWIND (frame, -1, op_errno, NULL, NULL); + + return 0; +} + +int32_t +map_fgetxattr (call_frame_t *frame, + xlator_t *this, + fd_t *fd, + const char *name) +{ + int32_t op_errno = 1; + xlator_t *subvol = NULL; + + VALIDATE_OR_GOTO (frame, err); + VALIDATE_OR_GOTO (this, err); + VALIDATE_OR_GOTO (fd, err); + VALIDATE_OR_GOTO (fd->inode, err); + + subvol = get_mapping_subvol_from_ctx (this, fd->inode); + if (!subvol) { + op_errno = EINVAL; + goto err; + } + + STACK_WIND (frame, map_fgetxattr_cbk, subvol, + subvol->fops->fgetxattr, fd, name); + + return 0; + err: + STACK_UNWIND (frame, -1, op_errno, NULL, NULL); + + return 0; +} + + int32_t map_xattrop (call_frame_t *frame, xlator_t *this, @@ -932,13 +1775,9 @@ map_xattrop (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_xattrop_cbk, - subvol, - subvol->fops->xattrop, - loc, - flags, - dict); + STACK_WIND (frame, map_xattrop_cbk, subvol, + subvol->fops->xattrop, loc, flags, dict); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -967,14 +1806,10 @@ map_fxattrop (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_fxattrop_cbk, - subvol, - subvol->fops->fxattrop, - fd, - flags, - dict); - return 0; + STACK_WIND (frame, map_fxattrop_cbk, subvol, + subvol->fops->fxattrop, fd, flags, dict); + + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -1002,12 +1837,9 @@ map_removexattr (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_removexattr_cbk, - subvol, - subvol->fops->removexattr, - loc, - name); + STACK_WIND (frame, map_removexattr_cbk, subvol, + subvol->fops->removexattr, loc, name); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -1036,13 +1868,9 @@ map_lk (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_lk_cbk, - subvol, - subvol->fops->lk, - fd, - cmd, - lock); + STACK_WIND (frame, map_lk_cbk, subvol, + subvol->fops->lk, fd, cmd, lock); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -1070,11 +1898,9 @@ map_inodelk (call_frame_t *frame, xlator_t *this, goto err; } - STACK_WIND (frame, - default_inodelk_cbk, - subvol, - subvol->fops->inodelk, - volume, loc, cmd, lock); + STACK_WIND (frame, map_inodelk_cbk, subvol, + subvol->fops->inodelk, volume, loc, cmd, lock); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -1101,11 +1927,9 @@ map_finodelk (call_frame_t *frame, xlator_t *this, goto err; } - STACK_WIND (frame, - default_finodelk_cbk, - subvol, - subvol->fops->finodelk, - volume, fd, cmd, lock); + STACK_WIND (frame, map_finodelk_cbk, subvol, + subvol->fops->finodelk, volume, fd, cmd, lock); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -1133,10 +1957,9 @@ map_entrylk (call_frame_t *frame, xlator_t *this, goto err; } - STACK_WIND (frame, default_entrylk_cbk, - subvol, - subvol->fops->entrylk, - volume, loc, basename, cmd, type); + STACK_WIND (frame, map_entrylk_cbk, subvol, + subvol->fops->entrylk, volume, loc, basename, cmd, type); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -1163,10 +1986,9 @@ map_fentrylk (call_frame_t *frame, xlator_t *this, goto err; } - STACK_WIND (frame, default_fentrylk_cbk, - subvol, - subvol->fops->fentrylk, - volume, fd, basename, cmd, type); + STACK_WIND (frame, map_fentrylk_cbk, subvol, + subvol->fops->fentrylk, volume, fd, basename, cmd, type); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -1195,12 +2017,9 @@ map_checksum (call_frame_t *frame, goto err; } - STACK_WIND (frame, - default_checksum_cbk, - subvol, - subvol->fops->checksum, - loc, - flag); + STACK_WIND (frame, map_checksum_cbk, subvol, + subvol->fops->checksum, loc, flag); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -1208,25 +2027,6 @@ map_checksum (call_frame_t *frame, return 0; } -static int32_t -map_newentry_cbk (call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - inode_t *inode, - struct stat *buf) -{ - call_frame_t *prev = NULL; - prev = cookie; - - map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); - - STACK_UNWIND (frame, op_ret, op_errno, inode, buf); - return 0; - -} - int32_t map_mknod (call_frame_t *frame, @@ -1257,11 +2057,9 @@ map_mknod (call_frame_t *frame, loc->path); } - STACK_WIND (frame, - map_newentry_cbk, - subvol, - subvol->fops->mknod, - loc, mode, rdev); + STACK_WIND (frame, map_newentry_cbk, subvol, + subvol->fops->mknod, loc, mode, rdev); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -1297,11 +2095,8 @@ map_mkdir (call_frame_t *frame, loc->path); } - STACK_WIND (frame, - map_newentry_cbk, - subvol, - subvol->fops->mkdir, - loc, mode); + STACK_WIND (frame, map_newentry_cbk, subvol, + subvol->fops->mkdir, loc, mode); return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -1338,11 +2133,9 @@ map_symlink (call_frame_t *frame, loc->path); } - STACK_WIND (frame, - map_newentry_cbk, - subvol, - subvol->fops->symlink, - linkpath, loc); + STACK_WIND (frame, map_newentry_cbk, subvol, + subvol->fops->symlink, linkpath, loc); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -1350,25 +2143,6 @@ map_symlink (call_frame_t *frame, return 0; } - -static int32_t -map_create_cbk (call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - fd_t *fd, - inode_t *inode, - struct stat *buf) -{ - call_frame_t *prev = NULL; - prev = cookie; - - map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); - STACK_UNWIND (frame, op_ret, op_errno, fd, inode, buf); - return 0; -} - int32_t map_create (call_frame_t *frame, xlator_t *this, @@ -1398,10 +2172,9 @@ map_create (call_frame_t *frame, loc->path); } - STACK_WIND (frame, map_create_cbk, - subvol, - subvol->fops->create, - loc, flags, mode, fd); + STACK_WIND (frame, map_create_cbk, subvol, + subvol->fops->create, loc, flags, mode, fd); + return 0; err: STACK_UNWIND (frame, -1, op_errno, NULL, NULL); @@ -1409,73 +2182,6 @@ map_create (call_frame_t *frame, return 0; } -int32_t -map_single_lookup_cbk (call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - inode_t *inode, - struct stat *buf, - dict_t *dict) -{ - call_frame_t *prev = NULL; - prev = cookie; - - map_itransform (this, prev->this, buf->st_ino, &buf->st_ino); - - STACK_UNWIND (frame, op_ret, op_errno, inode, buf, dict); - - return 0; -} - -int32_t -map_lookup_cbk (call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - inode_t *inode, - struct stat *buf, - dict_t *dict) -{ - int callcnt = 0; - map_local_t *local = NULL; - inode_t *tmp_inode = NULL; - dict_t *tmp_dict = NULL; - - local = frame->local; - LOCK (&frame->lock); - { - callcnt = --local->call_count; - if ((op_ret == 0) && (local->op_ret == -1)) { - local->op_ret = 0; - local->stbuf = *buf; - if (dict) - local->dict = dict_ref (dict); - local->inode = inode_ref (inode); - } - if (op_ret == -1) - local->op_errno = op_errno; - - } - UNLOCK (&frame->lock); - - if (!callcnt) { - tmp_dict = local->dict; - tmp_inode = local->inode; - - STACK_UNWIND (frame, local->op_ret, - local->op_errno, local->inode, - &local->stbuf, local->dict); - - inode_unref (local->inode); - if (tmp_dict) - dict_unref (tmp_dict); - } - - return 0; -} int32_t map_lookup (call_frame_t *frame, @@ -1517,12 +2223,8 @@ map_lookup (call_frame_t *frame, } /* Just one callback */ - STACK_WIND (frame, - map_single_lookup_cbk, - subvol, - subvol->fops->lookup, - loc, - xattr_req); + STACK_WIND (frame, map_single_lookup_cbk, subvol, + subvol->fops->lookup, loc, xattr_req); return 0; @@ -1535,12 +2237,8 @@ map_lookup (call_frame_t *frame, trav = this->children; while (trav) { - STACK_WIND (frame, - map_lookup_cbk, - trav->xlator, - trav->xlator->fops->lookup, - loc, - xattr_req); + STACK_WIND (frame, map_root_lookup_cbk, trav->xlator, + trav->xlator->fops->lookup, loc, xattr_req); trav = trav->next; } @@ -1551,95 +2249,9 @@ map_lookup (call_frame_t *frame, return 0; } -/* - * unify_normalize_stats - - */ -void -map_normalize_stats (struct statvfs *buf, - unsigned long bsize, - unsigned long frsize) -{ - double factor; - - if (buf->f_bsize != bsize) { - factor = ((double) buf->f_bsize) / bsize; - buf->f_bsize = bsize; - buf->f_bfree = (fsblkcnt_t) (factor * buf->f_bfree); - buf->f_bavail = (fsblkcnt_t) (factor * buf->f_bavail); - } - - if (buf->f_frsize != frsize) { - factor = ((double) buf->f_frsize) / frsize; - buf->f_frsize = frsize; - buf->f_blocks = (fsblkcnt_t) (factor * buf->f_blocks); - } -} int32_t -map_statfs_cbk (call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - struct statvfs *stbuf) -{ - struct statvfs *dict_buf = NULL; - map_local_t *local = NULL; - int this_call_cnt = 0; - unsigned long bsize; - unsigned long frsize; - - local = frame->local; - - LOCK (&frame->lock); - { - this_call_cnt = --local->call_count; - - if (op_ret == -1) { - local->op_errno = op_errno; - goto unlock; - } - local->op_ret = 0; - - /* when a call is successfull, add it to local->dict */ - dict_buf = &local->statvfs; - - if (dict_buf->f_bsize != 0) { - bsize = max (dict_buf->f_bsize, - stbuf->f_bsize); - - frsize = max (dict_buf->f_frsize, - stbuf->f_frsize); - map_normalize_stats(dict_buf, bsize, frsize); - map_normalize_stats(stbuf, bsize, frsize); - } else { - dict_buf->f_bsize = stbuf->f_bsize; - dict_buf->f_frsize = stbuf->f_frsize; - } - - dict_buf->f_blocks += stbuf->f_blocks; - dict_buf->f_bfree += stbuf->f_bfree; - dict_buf->f_bavail += stbuf->f_bavail; - dict_buf->f_files += stbuf->f_files; - dict_buf->f_ffree += stbuf->f_ffree; - dict_buf->f_favail += stbuf->f_favail; - dict_buf->f_fsid = stbuf->f_fsid; - dict_buf->f_flag = stbuf->f_flag; - dict_buf->f_namemax = stbuf->f_namemax; - } -unlock: - UNLOCK (&frame->lock); - - if (!this_call_cnt) { - STACK_UNWIND (frame, local->op_ret, local->op_errno, - &local->statvfs); - } - - return 0; -} - -int32_t map_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc) @@ -1664,11 +2276,7 @@ map_statfs (call_frame_t *frame, } /* Just one callback */ - STACK_WIND (frame, - default_statfs_cbk, - subvol, - subvol->fops->statfs, - loc); + STACK_WIND (frame, map_statfs_cbk, subvol, subvol->fops->statfs, loc); return 0; @@ -1682,11 +2290,8 @@ map_statfs (call_frame_t *frame, trav = this->children; while (trav) { - STACK_WIND (frame, - map_statfs_cbk, - trav->xlator, - trav->xlator->fops->statfs, - loc); + STACK_WIND (frame, map_statfs_cbk, trav->xlator, + trav->xlator->fops->statfs, loc); trav = trav->next; } @@ -1698,46 +2303,6 @@ map_statfs (call_frame_t *frame, } int32_t -map_opendir_cbk (call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - fd_t *fd) -{ - int callcnt = 0; - map_local_t *local = NULL; - fd_t *local_fd = NULL; - - local = frame->local; - LOCK (&frame->lock); - { - callcnt = --local->call_count; - - if (op_ret == -1) { - local->op_errno = op_errno; - goto unlock; - } - - local->op_ret = 0; - } - unlock: - UNLOCK (&frame->lock); - - if (!callcnt) { - local_fd = local->fd; - local->fd = NULL; - - STACK_UNWIND (frame, local->op_ret, - local->op_errno, local_fd); - - fd_unref (local_fd); - } - return 0; -} - - -int32_t map_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd) @@ -1762,11 +2327,9 @@ map_opendir (call_frame_t *frame, } /* Just one callback */ - STACK_WIND (frame, - default_opendir_cbk, - subvol, - subvol->fops->opendir, - loc, fd); + STACK_WIND (frame, map_opendir_cbk, subvol, + subvol->fops->opendir, loc, fd); + return 0; root_inode: @@ -1780,11 +2343,8 @@ map_opendir (call_frame_t *frame, trav = this->children; while (trav) { - STACK_WIND (frame, - map_opendir_cbk, - trav->xlator, - trav->xlator->fops->opendir, - loc, fd); + STACK_WIND (frame, map_opendir_cbk, trav->xlator, + trav->xlator->fops->opendir, loc, fd); trav = trav->next; } @@ -1797,104 +2357,6 @@ map_opendir (call_frame_t *frame, int32_t -map_single_readdir_cbk (call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - gf_dirent_t *entries) -{ - call_frame_t *prev = NULL; - gf_dirent_t *orig_entry = NULL; - - prev = cookie; - - list_for_each_entry (orig_entry, &entries->list, list) { - map_itransform (this, prev->this, orig_entry->d_ino, - &orig_entry->d_ino); - } - STACK_UNWIND (frame, op_ret, op_errno, entries); - - return 0; -} - - -int -map_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, - int op_ret, int op_errno, gf_dirent_t *orig_entries) -{ - map_local_t *local = NULL; - gf_dirent_t entries; - gf_dirent_t *orig_entry = NULL; - gf_dirent_t *entry = NULL; - call_frame_t *prev = NULL; - xlator_t *subvol = NULL; - xlator_t *next = NULL; - int count = 0; - fd_t *local_fd = NULL; - - INIT_LIST_HEAD (&entries.list); - prev = cookie; - local = frame->local; - - if (op_ret < 0) - goto done; - - list_for_each_entry (orig_entry, &orig_entries->list, list) { - subvol = prev->this; - - entry = gf_dirent_for_name (orig_entry->d_name); - if (!entry) { - gf_log (this->name, GF_LOG_ERROR, - "memory allocation failed :("); - goto unwind; - } - - map_itransform (this, subvol, orig_entry->d_ino, - &entry->d_ino); - map_itransform (this, subvol, orig_entry->d_off, - &entry->d_off); - - entry->d_type = orig_entry->d_type; - entry->d_len = orig_entry->d_len; - - list_add_tail (&entry->list, &entries.list); - count++; - } - - op_ret = count; - -done: - if (count == 0) { - next = map_subvol_next (this, prev->this); - if (!next) { - goto unwind; - } - - STACK_WIND (frame, map_readdir_cbk, - next, next->fops->readdir, - local->fd, local->size, 0); - return 0; - } - -unwind: - if (op_ret < 0) - op_ret = 0; - - local_fd = local->fd; - local->fd = NULL; - - STACK_UNWIND (frame, op_ret, op_errno, &entries); - - fd_unref (local_fd); - - gf_dirent_free (&entries); - - return 0; -} - - -int32_t map_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, @@ -1922,12 +2384,9 @@ map_readdir (call_frame_t *frame, } /* Just one callback */ - - STACK_WIND (frame, - map_single_readdir_cbk, - subvol, - subvol->fops->readdir, - fd, size, yoff); + STACK_WIND (frame, map_single_readdir_cbk, subvol, + subvol->fops->readdir, fd, size, yoff); + return 0; root_inode: @@ -1950,9 +2409,8 @@ map_readdir (call_frame_t *frame, map_deitransform (this, yoff, &xvol, (uint64_t *)&xoff); - STACK_WIND (frame, map_readdir_cbk, - xvol, xvol->fops->readdir, - fd, size, xoff); + STACK_WIND (frame, map_readdir_cbk, xvol, + xvol->fops->readdir, fd, size, xoff); return 0; err: @@ -1962,44 +2420,6 @@ map_readdir (call_frame_t *frame, } -#if 0 -/* TODO : do it later as currently only unify uses this mop and mostly - unify will be used below map */ -int32_t -map_stats_cbk (call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - struct xlator_stats *stats) -{ - STACK_UNWIND (frame, op_ret, op_errno, stats); - return 0; -} - - -int32_t -map_stats (call_frame_t *frame, - xlator_t *this, - int32_t flags) -{ - STACK_WIND (frame, - map_stats_cbk, - subvol, - subvol->mops->stats, - flags); - return 0; - err: - STACK_UNWIND (frame, -1, op_errno, NULL, NULL); - - return 0; -} -#endif /* if 0 */ - - -/* TODO: define the behavior of notify */ - - void fini (xlator_t *this) { @@ -2040,7 +2460,7 @@ init (xlator_t *this) char *dup_map_pair = NULL; char *dir_str = NULL; char *subvol_str = NULL; - char *default_xl = NULL; + char *map_xl = NULL; if (!this->children) { gf_log (this->name,GF_LOG_ERROR, @@ -2110,9 +2530,9 @@ init (xlator_t *this) } /* default-volume brick4 */ - ret = dict_get_str (this->options, "default-volume", &default_xl); + ret = dict_get_str (this->options, "default-volume", &map_xl); if (ret == 0) { - ret = assign_default_subvol (this, default_xl); + ret = assign_default_subvol (this, map_xl); if (ret != 0) { gf_log (this->name, GF_LOG_ERROR, "assigning default failed"); @@ -2147,6 +2567,8 @@ struct xlator_fops fops = { .readlink = map_readlink, .setxattr = map_setxattr, .getxattr = map_getxattr, + .fsetxattr = map_fsetxattr, + .fgetxattr = map_fgetxattr, .removexattr = map_removexattr, .open = map_open, .readv = map_readv, |