849
894
op_errno = (op_errno == -1) ? errno : op_errno;
850
DHT_STACK_UNWIND (frame, -1, op_errno, NULL, NULL, NULL);
895
DHT_STACK_UNWIND (lookup, frame, -1, op_errno, NULL, NULL, NULL, NULL);
901
dht_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
902
int op_ret, int op_errno, struct stat *prebuf,
903
struct stat *postbuf)
905
dht_local_t *local = NULL;
906
int this_call_cnt = 0;
907
call_frame_t *prev = NULL;
910
local = frame->local;
916
local->op_errno = op_errno;
917
gf_log (this->name, GF_LOG_DEBUG,
918
"subvolume %s returned -1 (%s)",
919
prev->this->name, strerror (op_errno));
923
dht_stat_merge (this, &local->prebuf, prebuf, prev->this);
924
dht_stat_merge (this, &local->stbuf, postbuf, prev->this);
927
local->stbuf.st_ino = local->inode->ino;
928
local->prebuf.st_ino = local->inode->ino;
934
UNLOCK (&frame->lock);
936
this_call_cnt = dht_frame_return (frame);
937
if (is_last_call (this_call_cnt))
938
DHT_STACK_UNWIND (truncate, frame, local->op_ret, local->op_errno,
939
&local->prebuf, &local->stbuf);
993
1085
op_errno = (op_errno == -1) ? errno : op_errno;
994
DHT_STACK_UNWIND (frame, -1, op_errno, NULL);
1001
dht_chmod (call_frame_t *frame, xlator_t *this,
1002
loc_t *loc, mode_t mode)
1004
dht_layout_t *layout = NULL;
1005
dht_local_t *local = NULL;
1010
VALIDATE_OR_GOTO (frame, err);
1011
VALIDATE_OR_GOTO (this, err);
1012
VALIDATE_OR_GOTO (loc, err);
1013
VALIDATE_OR_GOTO (loc->inode, err);
1014
VALIDATE_OR_GOTO (loc->path, err);
1016
layout = dht_layout_get (this, loc->inode);
1019
gf_log (this->name, GF_LOG_DEBUG,
1020
"no layout for path=%s", loc->path);
1025
if (!layout_is_sane (layout)) {
1026
gf_log (this->name, GF_LOG_DEBUG,
1027
"layout is not sane for path=%s", loc->path);
1032
local = dht_local_init (frame);
1035
gf_log (this->name, GF_LOG_DEBUG,
1036
"memory allocation failed :(");
1040
local->inode = inode_ref (loc->inode);
1041
local->call_cnt = layout->cnt;
1043
for (i = 0; i < layout->cnt; i++) {
1044
STACK_WIND (frame, dht_attr_cbk,
1045
layout->list[i].xlator,
1046
layout->list[i].xlator->fops->chmod,
1053
op_errno = (op_errno == -1) ? errno : op_errno;
1054
DHT_STACK_UNWIND (frame, -1, op_errno, NULL);
1061
dht_chown (call_frame_t *frame, xlator_t *this,
1062
loc_t *loc, uid_t uid, gid_t gid)
1064
dht_layout_t *layout = NULL;
1065
dht_local_t *local = NULL;
1070
VALIDATE_OR_GOTO (frame, err);
1071
VALIDATE_OR_GOTO (this, err);
1072
VALIDATE_OR_GOTO (loc, err);
1073
VALIDATE_OR_GOTO (loc->inode, err);
1074
VALIDATE_OR_GOTO (loc->path, err);
1076
layout = dht_layout_get (this, loc->inode);
1078
gf_log (this->name, GF_LOG_DEBUG,
1079
"no layout for path=%s", loc->path);
1084
if (!layout_is_sane (layout)) {
1085
gf_log (this->name, GF_LOG_DEBUG,
1086
"layout is not sane for path=%s", loc->path);
1091
local = dht_local_init (frame);
1094
gf_log (this->name, GF_LOG_ERROR,
1099
local->inode = inode_ref (loc->inode);
1100
local->call_cnt = layout->cnt;
1102
for (i = 0; i < layout->cnt; i++) {
1103
STACK_WIND (frame, dht_attr_cbk,
1104
layout->list[i].xlator,
1105
layout->list[i].xlator->fops->chown,
1112
op_errno = (op_errno == -1) ? errno : op_errno;
1113
DHT_STACK_UNWIND (frame, -1, op_errno, NULL);
1120
dht_fchmod (call_frame_t *frame, xlator_t *this,
1121
fd_t *fd, mode_t mode)
1123
dht_layout_t *layout = NULL;
1124
dht_local_t *local = NULL;
1129
VALIDATE_OR_GOTO (frame, err);
1130
VALIDATE_OR_GOTO (this, err);
1131
VALIDATE_OR_GOTO (fd, err);
1134
layout = dht_layout_get (this, fd->inode);
1136
gf_log (this->name, GF_LOG_DEBUG,
1137
"no layout for fd=%p", fd);
1142
if (!layout_is_sane (layout)) {
1143
gf_log (this->name, GF_LOG_DEBUG,
1144
"layout is not sane for fd=%p", fd);
1149
local = dht_local_init (frame);
1152
gf_log (this->name, GF_LOG_ERROR,
1157
local->inode = inode_ref (fd->inode);
1158
local->call_cnt = layout->cnt;
1160
for (i = 0; i < layout->cnt; i++) {
1161
STACK_WIND (frame, dht_attr_cbk,
1162
layout->list[i].xlator,
1163
layout->list[i].xlator->fops->fchmod,
1170
op_errno = (op_errno == -1) ? errno : op_errno;
1171
DHT_STACK_UNWIND (frame, -1, op_errno, NULL);
1178
dht_fchown (call_frame_t *frame, xlator_t *this,
1179
fd_t *fd, uid_t uid, gid_t gid)
1181
dht_layout_t *layout = NULL;
1182
dht_local_t *local = NULL;
1187
VALIDATE_OR_GOTO (frame, err);
1188
VALIDATE_OR_GOTO (this, err);
1189
VALIDATE_OR_GOTO (fd, err);
1191
layout = dht_layout_get (this, fd->inode);
1193
gf_log (this->name, GF_LOG_DEBUG,
1194
"no layout for fd=%p", fd);
1199
if (!layout_is_sane (layout)) {
1200
gf_log (this->name, GF_LOG_DEBUG,
1201
"layout is not sane for fd=%p", fd);
1206
local = dht_local_init (frame);
1209
gf_log (this->name, GF_LOG_ERROR,
1214
local->inode = inode_ref (fd->inode);
1215
local->call_cnt = layout->cnt;
1217
for (i = 0; i < layout->cnt; i++) {
1218
STACK_WIND (frame, dht_attr_cbk,
1219
layout->list[i].xlator,
1220
layout->list[i].xlator->fops->fchown,
1227
op_errno = (op_errno == -1) ? errno : op_errno;
1228
DHT_STACK_UNWIND (frame, -1, op_errno, NULL);
1235
dht_utimens (call_frame_t *frame, xlator_t *this,
1236
loc_t *loc, struct timespec tv[2])
1238
dht_layout_t *layout = NULL;
1239
dht_local_t *local = NULL;
1244
VALIDATE_OR_GOTO (frame, err);
1245
VALIDATE_OR_GOTO (this, err);
1246
VALIDATE_OR_GOTO (loc, err);
1247
VALIDATE_OR_GOTO (loc->inode, err);
1248
VALIDATE_OR_GOTO (loc->path, err);
1250
layout = dht_layout_get (this, loc->inode);
1252
gf_log (this->name, GF_LOG_DEBUG,
1253
"no layout for path=%s", loc->path);
1258
if (!layout_is_sane (layout)) {
1259
gf_log (this->name, GF_LOG_DEBUG,
1260
"layout is not sane for path=%s", loc->path);
1265
local = dht_local_init (frame);
1268
gf_log (this->name, GF_LOG_ERROR,
1273
local->inode = inode_ref (loc->inode);
1274
local->call_cnt = layout->cnt;
1276
for (i = 0; i < layout->cnt; i++) {
1277
STACK_WIND (frame, dht_attr_cbk,
1278
layout->list[i].xlator,
1279
layout->list[i].xlator->fops->utimens,
1286
op_errno = (op_errno == -1) ? errno : op_errno;
1287
DHT_STACK_UNWIND (frame, -1, op_errno, NULL);
1086
DHT_STACK_UNWIND (fstat, frame, -1, op_errno, NULL);
1380
1179
op_errno = (op_errno == -1) ? errno : op_errno;
1381
DHT_STACK_UNWIND (frame, -1, op_errno, NULL);
1180
DHT_STACK_UNWIND (ftruncate, frame, -1, op_errno, NULL, NULL);
1187
dht_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1188
int op_ret, int op_errno, struct stat *preparent,
1189
struct stat *postparent)
1191
dht_local_t *local = NULL;
1192
int this_call_cnt = 0;
1193
call_frame_t *prev = NULL;
1196
local = frame->local;
1199
LOCK (&frame->lock);
1202
local->op_errno = op_errno;
1203
gf_log (this->name, GF_LOG_DEBUG,
1204
"subvolume %s returned -1 (%s)",
1205
prev->this->name, strerror (op_errno));
1212
UNLOCK (&frame->lock);
1214
this_call_cnt = dht_frame_return (frame);
1215
if (is_last_call (this_call_cnt))
1216
DHT_STACK_UNWIND (unlink, frame, local->op_ret, local->op_errno,
1224
dht_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
1225
int op_errno, struct stat *prebuf, struct stat *postbuf)
1227
dht_local_t *local = NULL;
1228
int this_call_cnt = 0;
1229
call_frame_t *prev = NULL;
1232
local = frame->local;
1235
LOCK (&frame->lock);
1238
local->op_errno = op_errno;
1239
gf_log (this->name, GF_LOG_DEBUG,
1240
"subvolume %s returned -1 (%s)",
1241
prev->this->name, strerror (op_errno));
1248
UNLOCK (&frame->lock);
1250
if (local && (op_ret == 0)) {
1251
prebuf->st_ino = local->st_ino;
1252
postbuf->st_ino = local->st_ino;
1255
this_call_cnt = dht_frame_return (frame);
1256
if (is_last_call (this_call_cnt))
1257
DHT_STACK_UNWIND (fsync, frame, local->op_ret, local->op_errno,
1388
1266
dht_err_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
1389
1267
int op_ret, int op_errno)
2097
2030
op_errno = (op_errno == -1) ? errno : op_errno;
2098
DHT_STACK_UNWIND (frame, -1, op_errno, NULL);
2031
DHT_STACK_UNWIND (opendir, frame, -1, op_errno, NULL);
2038
dht_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
2039
int op_errno, gf_dirent_t *orig_entries)
2041
dht_local_t *local = NULL;
2042
gf_dirent_t entries;
2043
gf_dirent_t *orig_entry = NULL;
2044
gf_dirent_t *entry = NULL;
2045
call_frame_t *prev = NULL;
2046
xlator_t *next_subvol = NULL;
2047
off_t next_offset = 0;
2051
INIT_LIST_HEAD (&entries.list);
2053
local = frame->local;
2058
list_for_each_entry (orig_entry, (&orig_entries->list), list) {
2059
next_offset = orig_entry->d_off;
2061
if (check_is_linkfile (NULL, (&orig_entry->d_stat), NULL)
2062
|| (check_is_dir (NULL, (&orig_entry->d_stat), NULL)
2063
&& (prev->this != dht_first_up_subvol (this)))) {
2067
entry = gf_dirent_for_name (orig_entry->d_name);
2069
gf_log (this->name, GF_LOG_ERROR,
2074
entry->d_stat = orig_entry->d_stat;
2076
dht_itransform (this, prev->this, orig_entry->d_ino,
2078
dht_itransform (this, prev->this, orig_entry->d_off,
2081
entry->d_stat.st_ino = entry->d_ino;
2082
entry->d_type = orig_entry->d_type;
2083
entry->d_len = orig_entry->d_len;
2085
list_add_tail (&entry->list, &entries.list);
2092
/* non-zero next_offset means that
2093
EOF is not yet hit on the current subvol
2095
if (next_offset == 0) {
2096
next_subvol = dht_subvol_next (this, prev->this);
2098
next_subvol = prev->this;
2105
STACK_WIND (frame, dht_readdirp_cbk,
2106
next_subvol, next_subvol->fops->readdirp,
2107
local->fd, local->size, next_offset);
2115
DHT_STACK_UNWIND (readdirp, frame, op_ret, op_errno, &entries);
2117
gf_dirent_free (&entries);
2105
2125
dht_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2106
2126
int op_ret, int op_errno, gf_dirent_t *orig_entries)
2217
2235
dht_deitransform (this, yoff, &xvol, (uint64_t *)&xoff);
2219
2237
/* TODO: do proper readdir */
2220
STACK_WIND (frame, dht_readdir_cbk,
2221
xvol, xvol->fops->readdir,
2238
if (whichop == GF_FOP_READDIR)
2239
STACK_WIND (frame, dht_readdir_cbk, xvol, xvol->fops->readdir,
2242
STACK_WIND (frame, dht_readdirp_cbk, xvol, xvol->fops->readdirp,
2227
2248
op_errno = (op_errno == -1) ? errno : op_errno;
2228
DHT_STACK_UNWIND (frame, -1, op_errno, NULL);
2249
DHT_STACK_UNWIND (readdir, frame, -1, op_errno, NULL);
2256
dht_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
2259
dht_do_readdir (frame, this, fd, size, yoff, GF_FOP_READDIR);
2264
dht_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
2267
dht_do_readdir (frame, this, fd, size, yoff, GF_FOP_READDIRP);
2235
2274
dht_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2236
2275
int op_ret, int op_errno)
2306
2345
dht_newfile_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2307
2346
int op_ret, int op_errno,
2308
inode_t *inode, struct stat *stbuf)
2347
inode_t *inode, struct stat *stbuf, struct stat *preparent,
2348
struct stat *postparent)
2310
2350
call_frame_t *prev = NULL;
2311
dht_layout_t *layout = NULL;
2352
dht_local_t *local = NULL;
2315
2355
if (op_ret == -1)
2358
local = frame->local;
2320
2367
dht_itransform (this, prev->this, stbuf->st_ino, &stbuf->st_ino);
2321
layout = dht_layout_for_subvol (this, prev->this);
2368
if (local->loc.parent) {
2369
preparent->st_ino = local->loc.parent->ino;
2370
postparent->st_ino = local->loc.parent->ino;
2373
ret = dht_layout_preset (this, prev->this, inode);
2324
2375
gf_log (this->name, GF_LOG_DEBUG,
2325
"no pre-set layout for subvolume %s",
2376
"could not set pre-set layout for subvolume %s",
2326
2377
prev->this->name);
2328
2379
op_errno = EINVAL;
2332
ret = inode_ctx_put (inode, this, (uint64_t)(long)layout);
2334
gf_log (this->name, GF_LOG_DEBUG,
2335
"could not set inode context");
2342
DHT_STACK_UNWIND (frame, op_ret, op_errno, inode, stbuf);
2384
* FIXME: st_size and st_blocks of preparent and postparent do not have
2385
* correct values. since, preparent and postparent buffers correspond
2386
* to a directory these two members should have values equal to sum of
2387
* corresponding values from each of the subvolume.
2388
* See dht_stat_merge for reference.
2391
DHT_STACK_UNWIND (mknod, frame, op_ret, op_errno, inode, stbuf, preparent,
2689
2769
dht_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
2690
2770
int op_ret, int op_errno,
2691
fd_t *fd, inode_t *inode, struct stat *stbuf)
2771
fd_t *fd, inode_t *inode, struct stat *stbuf,
2772
struct stat *preparent, struct stat *postparent)
2693
2774
call_frame_t *prev = NULL;
2694
dht_layout_t *layout = NULL;
2776
dht_local_t *local = NULL;
2697
2778
if (op_ret == -1)
2781
local = frame->local;
2702
2790
dht_itransform (this, prev->this, stbuf->st_ino, &stbuf->st_ino);
2703
layout = dht_layout_for_subvol (this, prev->this);
2706
gf_log (this->name, GF_LOG_DEBUG,
2707
"no pre-set layout for subvolume %s",
2714
ret = inode_ctx_put (inode, this, (uint64_t)(long)layout);
2791
if (local->loc.parent) {
2792
preparent->st_ino = local->loc.parent->ino;
2793
postparent->st_ino = local->loc.parent->ino;
2796
ret = dht_layout_preset (this, prev->this, inode);
2715
2797
if (ret != 0) {
2716
2798
gf_log (this->name, GF_LOG_DEBUG,
2717
"could not set inode context");
2799
"could not set preset layout for subvol %s",
2719
2802
op_errno = EINVAL;
2724
DHT_STACK_UNWIND (frame, op_ret, op_errno, fd, inode, stbuf);
2807
DHT_STACK_UNWIND (create, frame, op_ret, op_errno, fd, inode, stbuf, preparent,
3572
3685
op_errno = (op_errno == -1) ? errno : op_errno;
3573
DHT_STACK_UNWIND (frame, -1, op_errno);
3686
DHT_STACK_UNWIND (fentrylk, frame, -1, op_errno);
3693
dht_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
3694
int op_ret, int op_errno, struct stat *statpre,
3695
struct stat *statpost)
3697
dht_local_t *local = NULL;
3698
int this_call_cnt = 0;
3699
call_frame_t *prev = NULL;
3702
local = frame->local;
3705
LOCK (&frame->lock);
3708
local->op_errno = op_errno;
3709
gf_log (this->name, GF_LOG_DEBUG,
3710
"subvolume %s returned -1 (%s)",
3711
prev->this->name, strerror (op_errno));
3715
dht_stat_merge (this, &local->prebuf, statpre, prev->this);
3716
dht_stat_merge (this, &local->stbuf, statpost, prev->this);
3719
local->prebuf.st_ino = local->inode->ino;
3720
local->stbuf.st_ino = local->inode->ino;
3726
UNLOCK (&frame->lock);
3728
this_call_cnt = dht_frame_return (frame);
3729
if (is_last_call (this_call_cnt))
3730
DHT_STACK_UNWIND (setattr, frame, local->op_ret, local->op_errno,
3731
&local->prebuf, &local->stbuf);
3738
dht_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
3739
struct stat *stbuf, int32_t valid)
3741
dht_layout_t *layout = NULL;
3742
dht_local_t *local = NULL;
3747
VALIDATE_OR_GOTO (frame, err);
3748
VALIDATE_OR_GOTO (this, err);
3749
VALIDATE_OR_GOTO (loc, err);
3750
VALIDATE_OR_GOTO (loc->inode, err);
3751
VALIDATE_OR_GOTO (loc->path, err);
3753
local = dht_local_init (frame);
3756
gf_log (this->name, GF_LOG_DEBUG,
3757
"memory allocation failed :(");
3761
local->layout = layout = dht_layout_get (this, loc->inode);
3763
gf_log (this->name, GF_LOG_DEBUG,
3764
"no layout for path=%s", loc->path);
3769
if (!layout_is_sane (layout)) {
3770
gf_log (this->name, GF_LOG_DEBUG,
3771
"layout is not sane for path=%s", loc->path);
3776
local->inode = inode_ref (loc->inode);
3777
local->call_cnt = layout->cnt;
3779
for (i = 0; i < layout->cnt; i++) {
3780
STACK_WIND (frame, dht_setattr_cbk,
3781
layout->list[i].xlator,
3782
layout->list[i].xlator->fops->setattr,
3789
op_errno = (op_errno == -1) ? errno : op_errno;
3790
DHT_STACK_UNWIND (setattr, frame, -1, op_errno, NULL, NULL);
3797
dht_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, struct stat *stbuf,
3800
dht_layout_t *layout = NULL;
3801
dht_local_t *local = NULL;
3806
VALIDATE_OR_GOTO (frame, err);
3807
VALIDATE_OR_GOTO (this, err);
3808
VALIDATE_OR_GOTO (fd, err);
3810
local = dht_local_init (frame);
3813
gf_log (this->name, GF_LOG_ERROR,
3818
local->layout = layout = dht_layout_get (this, fd->inode);
3820
gf_log (this->name, GF_LOG_DEBUG,
3821
"no layout for fd=%p", fd);
3826
if (!layout_is_sane (layout)) {
3827
gf_log (this->name, GF_LOG_DEBUG,
3828
"layout is not sane for fd=%p", fd);
3833
local->inode = inode_ref (fd->inode);
3834
local->call_cnt = layout->cnt;
3836
for (i = 0; i < layout->cnt; i++) {
3837
STACK_WIND (frame, dht_setattr_cbk,
3838
layout->list[i].xlator,
3839
layout->list[i].xlator->fops->fsetattr,
3846
op_errno = (op_errno == -1) ? errno : op_errno;
3847
DHT_STACK_UNWIND (fsetattr, frame, -1, op_errno, NULL, NULL);