summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/map/src/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster/map/src/map.c')
-rw-r--r--xlators/cluster/map/src/map.c563
1 files changed, 257 insertions, 306 deletions
diff --git a/xlators/cluster/map/src/map.c b/xlators/cluster/map/src/map.c
index 2ea60c456..6150a33ce 100644
--- a/xlators/cluster/map/src/map.c
+++ b/xlators/cluster/map/src/map.c
@@ -1,22 +1,12 @@
/*
- 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
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 3 of the License,
- or (at your option) any later version.
-
- GlusterFS is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see
- <http://www.gnu.org/licenses/>.
-*/
+ Copyright (c) 2010-2012 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
#ifndef _CONFIG_H
#define _CONFIG_H
#include "config.h"
@@ -36,87 +26,53 @@ map_stat_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- struct stat *buf)
+ struct iatt *buf)
{
call_frame_t *prev = NULL;
prev = cookie;
- map_itransform (this, prev->this, buf->st_ino, &buf->st_ino);
+ map_itransform (this, prev->this, buf->ia_ino, &buf->ia_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)
+map_setattr_cbk (call_frame_t *frame,
+ void *cookie,
+ xlator_t *this,
+ int32_t op_ret,
+ int32_t op_errno,
+ struct iatt *statpre,
+ struct iatt *statpost)
{
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);
+ map_itransform (this, prev->this, statpre->ia_ino, &statpre->ia_ino);
+ map_itransform (this, prev->this, statpost->ia_ino, &statpost->ia_ino);
- STACK_UNWIND (frame, op_ret, op_errno, buf);
+ STACK_UNWIND (frame, op_ret, op_errno, statpre, statpost);
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)
+map_fsetattr_cbk (call_frame_t *frame,
+ void *cookie,
+ xlator_t *this,
+ int32_t op_ret,
+ int32_t op_errno,
+ struct iatt *statpre,
+ struct iatt *statpost)
{
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;
-}
+ map_itransform (this, prev->this, statpre->ia_ino, &statpre->ia_ino);
+ map_itransform (this, prev->this, statpost->ia_ino, &statpost->ia_ino);
-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);
+ STACK_UNWIND (frame, op_ret, op_errno, statpre, statpost);
return 0;
}
@@ -126,14 +82,15 @@ map_truncate_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- struct stat *buf)
+ struct iatt *prebuf,
+ struct iatt *postbuf)
{
call_frame_t *prev = NULL;
prev = cookie;
- map_itransform (this, prev->this, buf->st_ino, &buf->st_ino);
+ map_itransform (this, prev->this, postbuf->ia_ino, &postbuf->ia_ino);
- STACK_UNWIND (frame, op_ret, op_errno, buf);
+ STACK_UNWIND (frame, op_ret, op_errno, prebuf, postbuf);
return 0;
}
@@ -143,31 +100,15 @@ map_ftruncate_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- struct stat *buf)
+ struct iatt *prebuf,
+ struct iatt *postbuf)
{
call_frame_t *prev = NULL;
prev = cookie;
- map_itransform (this, prev->this, buf->st_ino, &buf->st_ino);
+ map_itransform (this, prev->this, postbuf->ia_ino, &postbuf->ia_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);
+ STACK_UNWIND (frame, op_ret, op_errno, prebuf, postbuf);
return 0;
}
@@ -189,9 +130,10 @@ map_readlink_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- const char *path)
+ const char *path,
+ struct iatt *sbuf)
{
- STACK_UNWIND (frame, op_ret, op_errno, path);
+ STACK_UNWIND (frame, op_ret, op_errno, path, sbuf);
return 0;
}
@@ -200,9 +142,11 @@ map_unlink_cbk (call_frame_t *frame,
void *cookie,
xlator_t *this,
int32_t op_ret,
- int32_t op_errno)
+ int32_t op_errno,
+ struct iatt *preparent,
+ struct iatt *postparent)
{
- STACK_UNWIND (frame, op_ret, op_errno);
+ STACK_UNWIND (frame, op_ret, op_errno, preparent, postparent);
return 0;
}
@@ -211,9 +155,11 @@ map_rmdir_cbk (call_frame_t *frame,
void *cookie,
xlator_t *this,
int32_t op_ret,
- int32_t op_errno)
+ int32_t op_errno,
+ struct iatt *preparent,
+ struct iatt *postparent)
{
- STACK_UNWIND (frame, op_ret, op_errno);
+ STACK_UNWIND (frame, op_ret, op_errno, preparent, postparent);
return 0;
}
@@ -224,12 +170,16 @@ map_rename_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- struct stat *buf)
+ struct iatt *buf,
+ struct iatt *preoldparent,
+ struct iatt *postoldparent,
+ struct iatt *prenewparent,
+ struct iatt *postnewparent)
{
call_frame_t *prev = NULL;
prev = cookie;
- map_itransform (this, prev->this, buf->st_ino, &buf->st_ino);
+ map_itransform (this, prev->this, buf->ia_ino, &buf->ia_ino);
STACK_UNWIND (frame, op_ret, op_errno, buf);
return 0;
@@ -242,12 +192,14 @@ map_link_cbk (call_frame_t *frame,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
- struct stat *buf)
+ struct iatt *buf,
+ struct iatt *preparent,
+ struct iatt *postparent)
{
call_frame_t *prev = NULL;
prev = cookie;
- map_itransform (this, prev->this, buf->st_ino, &buf->st_ino);
+ map_itransform (this, prev->this, buf->ia_ino, &buf->ia_ino);
STACK_UNWIND (frame, op_ret, op_errno, inode, buf);
return 0;
@@ -267,20 +219,21 @@ map_open_cbk (call_frame_t *frame,
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)
+ void *cookie,
+ xlator_t *this,
+ int32_t op_ret,
+ int32_t op_errno,
+ struct iovec *vector,
+ int32_t count,
+ struct iatt *stbuf,
+ struct iobref *iobref)
{
call_frame_t *prev = NULL;
prev = cookie;
- map_itransform (this, prev->this, stbuf->st_ino, &stbuf->st_ino);
+ map_itransform (this, prev->this, stbuf->ia_ino, &stbuf->ia_ino);
- STACK_UNWIND (frame, op_ret, op_errno, vector, count, stbuf);
+ STACK_UNWIND (frame, op_ret, op_errno, vector, count, stbuf, iobref);
return 0;
}
@@ -290,14 +243,15 @@ map_writev_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- struct stat *stbuf)
+ struct iatt *prebuf,
+ struct iatt *postbuf)
{
call_frame_t *prev = NULL;
prev = cookie;
- map_itransform (this, prev->this, stbuf->st_ino, &stbuf->st_ino);
+ map_itransform (this, prev->this, postbuf->ia_ino, &postbuf->ia_ino);
- STACK_UNWIND (frame, op_ret, op_errno, stbuf);
+ STACK_UNWIND (frame, op_ret, op_errno, prebuf, postbuf);
return 0;
}
@@ -318,9 +272,11 @@ map_fsync_cbk (call_frame_t *frame,
void *cookie,
xlator_t *this,
int32_t op_ret,
- int32_t op_errno)
+ int32_t op_errno,
+ struct iatt *prebuf,
+ struct iatt *postbuf)
{
- STACK_UNWIND (frame, op_ret, op_errno);
+ STACK_UNWIND (frame, op_ret, op_errno, prebuf, postbuf);
return 0;
}
@@ -331,12 +287,12 @@ map_fstat_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- struct stat *buf)
+ struct iatt *buf)
{
call_frame_t *prev = NULL;
prev = cookie;
- map_itransform (this, prev->this, buf->st_ino, &buf->st_ino);
+ map_itransform (this, prev->this, buf->ia_ino, &buf->ia_ino);
STACK_UNWIND (frame, op_ret, op_errno, buf);
return 0;
@@ -472,7 +428,7 @@ map_lk_cbk (call_frame_t *frame,
xlator_t *this,
int32_t op_ret,
int32_t op_errno,
- struct flock *lock)
+ struct gf_flock *lock)
{
STACK_UNWIND (frame, op_ret, op_errno, lock);
return 0;
@@ -526,12 +482,14 @@ map_newentry_cbk (call_frame_t *frame,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
- struct stat *buf)
+ struct iatt *buf,
+ struct iatt *preparent,
+ struct iatt *postparent)
{
call_frame_t *prev = NULL;
prev = cookie;
- map_itransform (this, prev->this, buf->st_ino, &buf->st_ino);
+ map_itransform (this, prev->this, buf->ia_ino, &buf->ia_ino);
STACK_UNWIND (frame, op_ret, op_errno, inode, buf);
return 0;
@@ -547,12 +505,14 @@ map_create_cbk (call_frame_t *frame,
int32_t op_errno,
fd_t *fd,
inode_t *inode,
- struct stat *buf)
+ struct iatt *buf,
+ struct iatt *preparent,
+ struct iatt *postparent)
{
call_frame_t *prev = NULL;
prev = cookie;
- map_itransform (this, prev->this, buf->st_ino, &buf->st_ino);
+ map_itransform (this, prev->this, buf->ia_ino, &buf->ia_ino);
STACK_UNWIND (frame, op_ret, op_errno, fd, inode, buf);
return 0;
@@ -654,13 +614,14 @@ map_single_lookup_cbk (call_frame_t *frame,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
- struct stat *buf,
- dict_t *dict)
+ struct iatt *buf,
+ dict_t *dict,
+ struct iatt *postparent)
{
call_frame_t *prev = NULL;
prev = cookie;
- map_itransform (this, prev->this, buf->st_ino, &buf->st_ino);
+ map_itransform (this, prev->this, buf->ia_ino, &buf->ia_ino);
STACK_UNWIND (frame, op_ret, op_errno, inode, buf, dict);
@@ -674,8 +635,9 @@ map_root_lookup_cbk (call_frame_t *frame,
int32_t op_ret,
int32_t op_errno,
inode_t *inode,
- struct stat *buf,
- dict_t *dict)
+ struct iatt *buf,
+ dict_t *dict,
+ struct iatt *postparent)
{
int callcnt = 0;
map_local_t *local = NULL;
@@ -778,9 +740,36 @@ map_single_readdir_cbk (call_frame_t *frame,
}
+int32_t
+map_single_readdirp_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);
+ orig_entry->d_stat.ia_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)
+ int op_ret, int op_errno, gf_dirent_t *orig_entries);
+
+int
+map_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int op_ret, int op_errno, gf_dirent_t *orig_entries);
+
+int
+map_generic_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int op_ret, int op_errno, gf_dirent_t *orig_entries,
+ int whichop)
{
map_local_t *local = NULL;
gf_dirent_t entries;
@@ -815,6 +804,8 @@ map_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
map_itransform (this, subvol, orig_entry->d_off,
&entry->d_off);
+ if (whichop == GF_FOP_READDIRP)
+ entry->d_stat.ia_ino = entry->d_ino;
entry->d_type = orig_entry->d_type;
entry->d_len = orig_entry->d_len;
@@ -840,9 +831,14 @@ done:
goto unwind;
}
- STACK_WIND (frame, map_readdir_cbk,
- next_subvol, next_subvol->fops->readdir,
- local->fd, local->size, 0);
+ if (whichop == GF_FOP_READDIR)
+ STACK_WIND (frame, map_readdir_cbk, next_subvol,
+ next_subvol->fops->readdir, local->fd,
+ local->size, 0);
+ else
+ STACK_WIND (frame, map_readdirp_cbk, next_subvol,
+ next_subvol->fops->readdirp, local->fd,
+ local->size, 0);
return 0;
}
@@ -863,6 +859,26 @@ unwind:
}
+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_generic_readdir_cbk (frame, cookie, this, op_ret, op_errno,
+ orig_entries, GF_FOP_READDIR);
+ return 0;
+}
+
+
+int
+map_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int op_ret, int op_errno, gf_dirent_t *orig_entries)
+{
+ map_generic_readdir_cbk (frame, cookie, this, op_ret, op_errno,
+ orig_entries, GF_FOP_READDIRP);
+ return 0;
+}
+
+
/* Management operations */
static int32_t
@@ -879,23 +895,6 @@ map_checksum_cbk (call_frame_t *frame,
}
-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
@@ -927,82 +926,22 @@ map_stat (call_frame_t *frame,
return 0;
}
-
int32_t
-map_chmod (call_frame_t *frame,
- xlator_t *this,
- loc_t *loc,
- mode_t mode)
-{
- int32_t op_errno = 1;
- xlator_t *subvol = NULL;
-
- VALIDATE_OR_GOTO (frame, err);
- VALIDATE_OR_GOTO (this, err);
- VALIDATE_OR_GOTO (loc, err);
- VALIDATE_OR_GOTO (loc->inode, err);
- VALIDATE_OR_GOTO (loc->path, err);
-
- subvol = get_mapping_subvol_from_ctx (this, loc->inode);
- if (!subvol) {
- op_errno = EINVAL;
- goto err;
- }
-
- STACK_WIND (frame, map_chmod_cbk, subvol,
- subvol->fops->chmod, loc, mode);
- return 0;
- err:
- STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
-
- return 0;
-}
-
-int32_t
-map_fchmod (call_frame_t *frame,
- xlator_t *this,
- fd_t *fd,
- mode_t mode)
+map_setattr (call_frame_t *frame,
+ xlator_t *this,
+ loc_t *loc,
+ struct iatt *stbuf,
+ int32_t valid)
{
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_fchmod_cbk, subvol,
- subvol->fops->fchmod, fd, mode);
-
- return 0;
- err:
- STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
-
- return 0;
-}
-
-int32_t
-map_chown (call_frame_t *frame,
- xlator_t *this,
- loc_t *loc,
- uid_t uid,
- gid_t gid)
-{
- int32_t op_errno = 1;
- xlator_t *subvol = NULL;
-
- VALIDATE_OR_GOTO (frame, err);
- VALIDATE_OR_GOTO (this, err);
- VALIDATE_OR_GOTO (loc, err);
- VALIDATE_OR_GOTO (loc->inode, err);
- VALIDATE_OR_GOTO (loc->path, err);
+ GF_VALIDATE_OR_GOTO ("map", this, err);
+ GF_VALIDATE_OR_GOTO (this->name, frame, err);
+ GF_VALIDATE_OR_GOTO (this->name, loc, err);
+ GF_VALIDATE_OR_GOTO (this->name, loc->inode, err);
+ GF_VALIDATE_OR_GOTO (this->name, loc->path, err);
+ GF_VALIDATE_OR_GOTO (this->name, stbuf, err);
subvol = get_mapping_subvol_from_ctx (this, loc->inode);
if (!subvol) {
@@ -1010,8 +949,8 @@ map_chown (call_frame_t *frame,
goto err;
}
- STACK_WIND (frame, map_chown_cbk, subvol,
- subvol->fops->chown, loc, uid, gid);
+ STACK_WIND (frame, map_setattr_cbk, subvol,
+ subvol->fops->setattr, loc, stbuf, valid);
return 0;
err:
STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
@@ -1020,19 +959,19 @@ map_chown (call_frame_t *frame,
}
int32_t
-map_fchown (call_frame_t *frame,
- xlator_t *this,
- fd_t *fd,
- uid_t uid,
- gid_t gid)
+map_fsetattr (call_frame_t *frame,
+ xlator_t *this,
+ fd_t *fd,
+ struct iatt *stbuf,
+ int32_t valid)
{
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);
+ GF_VALIDATE_OR_GOTO ("map", this, err);
+ GF_VALIDATE_OR_GOTO (this->name, frame, err);
+ GF_VALIDATE_OR_GOTO (this->name, fd, err);
+ GF_VALIDATE_OR_GOTO (this->name, stbuf, err);
subvol = get_mapping_subvol_from_ctx (this, fd->inode);
if (!subvol) {
@@ -1040,9 +979,8 @@ map_fchown (call_frame_t *frame,
goto err;
}
- STACK_WIND (frame, map_fchown_cbk, subvol,
- subvol->fops->fchown, fd, uid, gid);
-
+ STACK_WIND (frame, map_fsetattr_cbk, subvol,
+ subvol->fops->fsetattr, fd, stbuf, valid);
return 0;
err:
STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
@@ -1112,37 +1050,6 @@ map_ftruncate (call_frame_t *frame,
}
int32_t
-map_utimens (call_frame_t *frame,
- xlator_t *this,
- loc_t *loc,
- struct timespec tv[2])
-{
- int32_t op_errno = 1;
- xlator_t *subvol = NULL;
-
- VALIDATE_OR_GOTO (frame, err);
- VALIDATE_OR_GOTO (this, err);
- VALIDATE_OR_GOTO (loc, err);
- VALIDATE_OR_GOTO (loc->inode, err);
- VALIDATE_OR_GOTO (loc->path, err);
-
- subvol = get_mapping_subvol_from_ctx (this, loc->inode);
- if (!subvol) {
- op_errno = EINVAL;
- goto err;
- }
-
- STACK_WIND (frame, map_utimens_cbk, subvol,
- subvol->fops->utimens, loc, tv);
-
- return 0;
- err:
- STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
-
- return 0;
-}
-
-int32_t
map_access (call_frame_t *frame,
xlator_t *this,
loc_t *loc,
@@ -1352,7 +1259,7 @@ int32_t
map_open (call_frame_t *frame,
xlator_t *this,
loc_t *loc,
- int32_t flags, fd_t *fd)
+ int32_t flags, fd_t *fd, int wbflags)
{
int32_t op_errno = 1;
xlator_t *subvol = NULL;
@@ -1370,7 +1277,7 @@ map_open (call_frame_t *frame,
}
STACK_WIND (frame, map_open_cbk, subvol,
- subvol->fops->open, loc, flags, fd);
+ subvol->fops->open, loc, flags, fd, wbflags);
return 0;
err:
@@ -1405,7 +1312,7 @@ map_readv (call_frame_t *frame,
return 0;
err:
- STACK_UNWIND (frame, -1, op_errno, NULL, NULL);
+ STACK_UNWIND (frame, -1, op_errno, NULL, 0, NULL, NULL);
return 0;
}
@@ -1416,7 +1323,8 @@ map_writev (call_frame_t *frame,
fd_t *fd,
struct iovec *vector,
int32_t count,
- off_t off)
+ off_t off,
+ struct iobref *iobref)
{
int32_t op_errno = 1;
xlator_t *subvol = NULL;
@@ -1433,7 +1341,7 @@ map_writev (call_frame_t *frame,
}
STACK_WIND (frame, map_writev_cbk, subvol,
- subvol->fops->writev, fd, vector, count, off);
+ subvol->fops->writev, fd, vector, count, off, iobref);
return 0;
err:
@@ -1852,7 +1760,7 @@ map_lk (call_frame_t *frame,
xlator_t *this,
fd_t *fd,
int32_t cmd,
- struct flock *lock)
+ struct gf_flock *lock)
{
int32_t op_errno = 1;
xlator_t *subvol = NULL;
@@ -1881,7 +1789,7 @@ map_lk (call_frame_t *frame,
int32_t
map_inodelk (call_frame_t *frame, xlator_t *this,
- const char *volume, loc_t *loc, int32_t cmd, struct flock *lock)
+ const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *lock)
{
int32_t op_errno = 1;
xlator_t *subvol = NULL;
@@ -1911,7 +1819,7 @@ map_inodelk (call_frame_t *frame, xlator_t *this,
int32_t
map_finodelk (call_frame_t *frame, xlator_t *this,
- const char *volume, fd_t *fd, int32_t cmd, struct flock *lock)
+ const char *volume, fd_t *fd, int32_t cmd, struct gf_flock *lock)
{
int32_t op_errno = 1;
xlator_t *subvol = NULL;
@@ -2229,7 +2137,8 @@ map_lookup (call_frame_t *frame,
return 0;
root_inode:
- local = CALLOC (1, sizeof (map_local_t));
+ local = GF_CALLOC (1, sizeof (map_local_t),
+ gf_map_mt_map_local_t);
frame->local = local;
local->call_count = priv->child_count;
@@ -2281,7 +2190,8 @@ map_statfs (call_frame_t *frame,
return 0;
root_inode:
- local = CALLOC (1, sizeof (map_local_t));
+ local = GF_CALLOC (1, sizeof (map_local_t),
+ gf_map_mt_map_local_t);
priv = this->private;
frame->local = local;
@@ -2333,7 +2243,8 @@ map_opendir (call_frame_t *frame,
return 0;
root_inode:
- local = CALLOC (1, sizeof (map_local_t));
+ local = GF_CALLOC (1, sizeof (map_local_t),
+ gf_map_mt_map_local_t);
priv = this->private;
frame->local = local;
@@ -2357,11 +2268,8 @@ map_opendir (call_frame_t *frame,
int32_t
-map_readdir (call_frame_t *frame,
- xlator_t *this,
- fd_t *fd,
- size_t size,
- off_t yoff)
+map_do_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t yoff, int whichop)
{
int32_t op_errno = EINVAL;
xlator_t *subvol = NULL;
@@ -2384,14 +2292,19 @@ map_readdir (call_frame_t *frame,
}
/* Just one callback */
- STACK_WIND (frame, map_single_readdir_cbk, subvol,
- subvol->fops->readdir, fd, size, yoff);
+ if (whichop == GF_FOP_READDIR)
+ STACK_WIND (frame, map_single_readdir_cbk, subvol,
+ subvol->fops->readdir, fd, size, yoff);
+ else
+ STACK_WIND (frame, map_single_readdirp_cbk, subvol,
+ subvol->fops->readdirp, fd, size, yoff);
return 0;
root_inode:
/* readdir on '/' */
- local = CALLOC (1, sizeof (map_local_t));
+ local = GF_CALLOC (1, sizeof (map_local_t),
+ gf_map_mt_map_local_t);
if (!local) {
gf_log (this->name, GF_LOG_ERROR,
"memory allocation failed :(");
@@ -2409,8 +2322,12 @@ 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);
+ if (whichop == GF_FOP_READDIR)
+ STACK_WIND (frame, map_readdir_cbk, xvol, xvol->fops->readdir,
+ fd, size, xoff);
+ else
+ STACK_WIND (frame, map_readdirp_cbk, xvol, xvol->fops->readdirp,
+ fd, size, xoff);
return 0;
err:
@@ -2420,6 +2337,24 @@ map_readdir (call_frame_t *frame,
}
+
+int32_t
+map_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t yoff)
+{
+ map_do_readdir (frame, this, fd, size, yoff, GF_FOP_READDIR);
+ return 0;
+}
+
+int32_t
+map_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t yoff)
+{
+ map_do_readdir (frame, this, fd, size, yoff, GF_FOP_READDIRP);
+ return 0;
+}
+
+
void
fini (xlator_t *this)
{
@@ -2430,22 +2365,40 @@ fini (xlator_t *this)
priv = this->private;
if (priv) {
- if (priv->xlarray)
- FREE (priv->xlarray);
+ GF_FREE (priv->xlarray);
trav_map = priv->map;
while (trav_map) {
tmp_map = trav_map;
trav_map = trav_map->next;
- FREE (tmp_map);
+ GF_FREE (tmp_map);
}
- FREE(priv);
+ GF_FREE(priv);
}
return;
}
+int32_t
+mem_acct_init (xlator_t *this)
+{
+ int ret = -1;
+
+ if (!this)
+ return ret;
+
+ ret = xlator_mem_acct_init (this, gf_map_mt_end + 1);
+
+ if (ret != 0) {
+ gf_log (this->name, GF_LOG_ERROR, "Memory accounting init"
+ "failed");
+ return ret;
+ }
+
+ return ret;
+}
+
int
init (xlator_t *this)
{
@@ -2462,6 +2415,7 @@ init (xlator_t *this)
char *subvol_str = NULL;
char *map_xl = NULL;
+
if (!this->children) {
gf_log (this->name,GF_LOG_ERROR,
"FATAL: map should have one or more child defined");
@@ -2473,7 +2427,8 @@ init (xlator_t *this)
"dangling volume. check volfile ");
}
- priv = CALLOC (1, sizeof (map_private_t));
+ priv = GF_CALLOC (1, sizeof (map_private_t),
+ gf_map_mt_map_private_t);
this->private = priv;
/* allocate xlator array */
@@ -2482,7 +2437,8 @@ init (xlator_t *this)
count++;
trav = trav->next;
}
- priv->xlarray = CALLOC (1, sizeof (struct map_xlator_array) * count);
+ priv->xlarray = GF_CALLOC (1, sizeof (struct map_xlator_array) * count,
+ gf_map_mt_map_xlator_array);
priv->child_count = count;
/* build xlator array */
@@ -2502,7 +2458,7 @@ init (xlator_t *this)
}
map_pair_str = strtok_r (pattern_string, ";", &tmp_str);
while (map_pair_str) {
- dup_map_pair = strdup (map_pair_str);
+ dup_map_pair = gf_strdup (map_pair_str);
dir_str = strtok_r (dup_map_pair, ":", &tmp_str1);
if (!dir_str) {
gf_log (this->name, GF_LOG_ERROR,
@@ -2524,7 +2480,7 @@ init (xlator_t *this)
goto err;
}
- FREE (dup_map_pair);
+ GF_FREE (dup_map_pair);
map_pair_str = strtok_r (NULL, ";", &tmp_str);
}
@@ -2555,12 +2511,7 @@ struct xlator_fops fops = {
.create = map_create,
.stat = map_stat,
- .chmod = map_chmod,
- .chown = map_chown,
- .fchown = map_fchown,
- .fchmod = map_fchmod,
.fstat = map_fstat,
- .utimens = map_utimens,
.truncate = map_truncate,
.ftruncate = map_ftruncate,
.access = map_access,
@@ -2579,6 +2530,7 @@ struct xlator_fops fops = {
.lk = map_lk,
.opendir = map_opendir,
.readdir = map_readdir,
+ .readdirp = map_readdirp,
.fsyncdir = map_fsyncdir,
.symlink = map_symlink,
.unlink = map_unlink,
@@ -2595,9 +2547,8 @@ struct xlator_fops fops = {
.setdents = map_setdents,
.getdents = map_getdents,
.checksum = map_checksum,
-};
-
-struct xlator_mops mops = {
+ .setattr = map_setattr,
+ .fsetattr = map_fsetattr,
};
struct xlator_cbks cbks = {