summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-self-heal-metadata.c
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2009-10-01 06:58:46 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-01 07:22:42 -0700
commit186a86f342625a9dce53fe537f8237c6099d5c54 (patch)
tree63ee2f3def75293b9f50acf9e49081fb1caad8ae /xlators/cluster/afr/src/afr-self-heal-metadata.c
parentdca4b2a23cb55e1e15fb393e7cbfd39b59280c9c (diff)
Global: Introduce setattr and fsetattr fops
Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 146 (Add setattr FOP) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=146
Diffstat (limited to 'xlators/cluster/afr/src/afr-self-heal-metadata.c')
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-metadata.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c
index 966b754b3..686446b5f 100644
--- a/xlators/cluster/afr/src/afr-self-heal-metadata.c
+++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c
@@ -306,8 +306,9 @@ afr_sh_metadata_sync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int
-afr_sh_metadata_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct stat *buf)
+afr_sh_metadata_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno,
+ struct stat *preop, struct stat *postop)
{
afr_sh_metadata_sync_cbk (frame, cookie, this, op_ret, op_errno);
@@ -335,8 +336,9 @@ afr_sh_metadata_sync (call_frame_t *frame, xlator_t *this, dict_t *xattr)
int active_sinks = 0;
int call_count = 0;
int i = 0;
- struct timespec ts[2];
+ struct stat stbuf;
+ int32_t valid = 0;
local = frame->local;
sh = &local->self_heal;
@@ -346,26 +348,36 @@ afr_sh_metadata_sync (call_frame_t *frame, xlator_t *this, dict_t *xattr)
active_sinks = sh->active_sinks;
/*
- * 4 calls per sink - chown, chmod, utimes, setxattr
+ * 2 calls per sink - setattr, setxattr
*/
if (xattr)
- call_count = active_sinks * 4;
+ call_count = active_sinks * 2;
else
- call_count = active_sinks * 3;
+ call_count = active_sinks;
local->call_count = call_count;
#ifdef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC
- ts[0] = sh->buf[source].st_atim;
- ts[1] = sh->buf[source].st_mtim;
+ stbuf.st_atim = sh->buf[source].st_atim;
+ stbuf.st_mtim = sh->buf[source].st_mtim;
+
#elif HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
- ts[0] = sh->buf[source].st_atimespec;
- ts[1] = sh->buf[source].st_mtimespec;
+ stbuf.st_atimespec = sh->buf[source].st_atimespec;
+ stbuf.st_mtimespec = sh->buf[source].st_mtimespec;
#else
- ts[0].tv_sec = sh->buf[source].st_atime;
- ts[1].tv_sec = sh->buf[source].st_mtime;
+ stbuf.st_atime = sh->buf[source].st_atime;
+ stbuf.st_mtime = sh->buf[source].st_mtime;
#endif
+ stbuf.st_uid = sh->buf[source].st_uid;
+ stbuf.st_gid = sh->buf[source].st_gid;
+
+ stbuf.st_mode = sh->buf[source].st_mode;
+
+ valid = GF_SET_ATTR_MODE |
+ GF_SET_ATTR_UID | GF_SET_ATTR_GID |
+ GF_SET_ATTR_ATIME | GF_SET_ATTR_MTIME;
+
for (i = 0; i < priv->child_count; i++) {
if (call_count == 0) {
break;
@@ -378,27 +390,13 @@ afr_sh_metadata_sync (call_frame_t *frame, xlator_t *this, dict_t *xattr)
local->loc.path, priv->children[source]->name,
priv->children[i]->name);
- STACK_WIND_COOKIE (frame, afr_sh_metadata_attr_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->chown,
- &local->loc,
- sh->buf[source].st_uid,
- sh->buf[source].st_gid);
-
- STACK_WIND_COOKIE (frame, afr_sh_metadata_attr_cbk,
+ STACK_WIND_COOKIE (frame, afr_sh_metadata_setattr_cbk,
(void *) (long) i,
priv->children[i],
- priv->children[i]->fops->chmod,
- &local->loc, sh->buf[source].st_mode);
+ priv->children[i]->fops->setattr,
+ &local->loc, &stbuf, valid);
- STACK_WIND_COOKIE (frame, afr_sh_metadata_attr_cbk,
- (void *) (long) i,
- priv->children[i],
- priv->children[i]->fops->utimens,
- &local->loc, ts);
-
- call_count = call_count - 3;
+ call_count--;
if (!xattr)
continue;