| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
#define __XOPEN_SOURCE 500 |
| 11 |
|
| 12 |
|
| 13 |
#ifndef _GNU_SOURCE |
| 14 |
#define _GNU_SOURCE |
| 15 |
#endif |
| 16 |
|
| 17 |
#include <openssl/md5.h> |
| 18 |
#include <stdint.h> |
| 19 |
#include <sys/time.h> |
| 20 |
#include <errno.h> |
| 21 |
#include <libgen.h> |
| 22 |
#include <pthread.h> |
| 23 |
#include <ftw.h> |
| 24 |
#include <sys/stat.h> |
| 25 |
#include <signal.h> |
| 26 |
#include <sys/uio.h> |
| 27 |
#include <unistd.h> |
| 28 |
|
| 29 |
#ifndef GF_BSD_HOST_OS |
| 30 |
#include <alloca.h> |
| 31 |
#endif |
| 32 |
|
| 33 |
#ifdef HAVE_LINKAT |
| 34 |
#include <fcntl.h> |
| 35 |
#endif |
| 36 |
|
| 37 |
#include "posix.h" |
| 38 |
#include "posix-inode-handle.h" |
| 39 |
#include <glusterfs/compat-errno.h> |
| 40 |
#include <glusterfs/compat.h> |
| 41 |
#include <glusterfs/syscall.h> |
| 42 |
#include <glusterfs/statedump.h> |
| 43 |
#include <glusterfs/locking.h> |
| 44 |
#include "posix-aio.h" |
| 45 |
#include "posix-io-uring.h" |
| 46 |
#include <glusterfs/glusterfs-acl.h> |
| 47 |
#include "posix-messages.h" |
| 48 |
#include <glusterfs/events.h> |
| 49 |
#include "posix-gfid-path.h" |
| 50 |
#include <glusterfs/compat-uuid.h> |
| 51 |
#include "timer-wheel.h" |
| 52 |
|
| 53 |
|
| 54 |
#define ALIGN_SIZE 4096 |
| 55 |
|
| 56 |
#undef HAVE_SET_FSID |
| 57 |
#ifdef HAVE_SET_FSID |
| 58 |
|
| 59 |
#define DECLARE_OLD_FS_ID_VAR \ |
| 60 |
uid_t old_fsuid; \ |
| 61 |
gid_t old_fsgid; |
| 62 |
|
| 63 |
#define SET_FS_ID(uid, gid) \ |
| 64 |
do { \ |
| 65 |
old_fsuid = setfsuid(uid); \ |
| 66 |
old_fsgid = setfsgid(gid); \ |
| 67 |
} while (0) |
| 68 |
|
| 69 |
#define SET_TO_OLD_FS_ID() \ |
| 70 |
do { \ |
| 71 |
setfsuid(old_fsuid); \ |
| 72 |
setfsgid(old_fsgid); \ |
| 73 |
} while (0) |
| 74 |
|
| 75 |
#else |
| 76 |
|
| 77 |
#define DECLARE_OLD_FS_ID_VAR |
| 78 |
#define SET_FS_ID(uid, gid) |
| 79 |
#define SET_TO_OLD_FS_ID() |
| 80 |
|
| 81 |
#endif |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
#if HAVE_UTIMENSAT |
| 90 |
#define SET_TIMESPEC_NSEC_OR_TIMEVAL_USEC(tv, nanosecs) tv.tv_nsec = nanosecs |
| 91 |
#else |
| 92 |
#define SET_TIMESPEC_NSEC_OR_TIMEVAL_USEC(tv, nanosecs) \ |
| 93 |
tv.tv_usec = nanosecs / 1000 |
| 94 |
#endif |
| 95 |
|
| 96 |
int32_t |
| 97 |
posix_priv(xlator_t *this) |
| 98 |
{ |
| 99 |
struct posix_private *priv = NULL; |
| 100 |
char key_prefix[GF_DUMP_MAX_BUF_LEN]; |
| 101 |
|
| 102 |
if (!this) |
| 103 |
return 0; |
| 104 |
|
| 105 |
(void)snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s", this->type, |
| 106 |
this->name); |
| 107 |
gf_proc_dump_add_section("%s", key_prefix); |
| 108 |
|
| 109 |
priv = this->private; |
| 110 |
|
| 111 |
if (!priv) |
| 112 |
return 0; |
| 113 |
|
| 114 |
gf_proc_dump_write("base_path", "%s", priv->base_path); |
| 115 |
gf_proc_dump_write("base_path_length", "%d", priv->base_path_length); |
| 116 |
gf_proc_dump_write("max_read", "%" PRId64, GF_ATOMIC_GET(priv->read_value)); |
| 117 |
gf_proc_dump_write("max_write", "%" PRId64, |
| 118 |
GF_ATOMIC_GET(priv->write_value)); |
| 119 |
|
| 120 |
return 0; |
| 121 |
} |
| 122 |
|
| 123 |
int32_t |
| 124 |
posix_inode(xlator_t *this) |
| 125 |
{ |
| 126 |
return 0; |
| 127 |
} |
| 128 |
|
| 129 |
static void |
| 130 |
delete_posix_diskxl(struct posix_private *priv, glusterfs_ctx_t *ctx) |
| 131 |
{ |
| 132 |
struct posix_diskxl *pxl = priv->pxl; |
| 133 |
uint32_t count = 1; |
| 134 |
|
| 135 |
if (pxl) { |
| 136 |
pthread_mutex_lock(&ctx->xl_lock); |
| 137 |
{ |
| 138 |
pxl->detach_notify = _gf_true; |
| 139 |
while (pxl->is_use) |
| 140 |
pthread_cond_wait(&pxl->cond, &ctx->xl_lock); |
| 141 |
list_del_init(&pxl->list); |
| 142 |
priv->pxl = NULL; |
| 143 |
count = --ctx->diskxl_count; |
| 144 |
if (count == 0) |
| 145 |
pthread_cond_signal(&ctx->xl_cond); |
| 146 |
} |
| 147 |
pthread_mutex_unlock(&ctx->xl_lock); |
| 148 |
pthread_cond_destroy(&pxl->cond); |
| 149 |
GF_FREE(pxl); |
| 150 |
if (count == 0) { |
| 151 |
pthread_join(ctx->disk_space_check, NULL); |
| 152 |
ctx->disk_space_check = 0; |
| 153 |
} |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
int32_t |
| 161 |
posix_notify(xlator_t *this, int32_t event, void *data, ...) |
| 162 |
{ |
| 163 |
xlator_t *victim = data; |
| 164 |
struct posix_private *priv = this->private; |
| 165 |
int ret = 0; |
| 166 |
struct timespec sleep_till = { |
| 167 |
0, |
| 168 |
}; |
| 169 |
glusterfs_ctx_t *ctx = this->ctx; |
| 170 |
|
| 171 |
switch (event) { |
| 172 |
case GF_EVENT_PARENT_UP: { |
| 173 |
|
| 174 |
default_notify(this, GF_EVENT_CHILD_UP, data); |
| 175 |
} break; |
| 176 |
|
| 177 |
case GF_EVENT_PARENT_DOWN: { |
| 178 |
if (!victim->cleanup_starting) |
| 179 |
break; |
| 180 |
|
| 181 |
if (priv->janitor) { |
| 182 |
pthread_mutex_lock(&priv->janitor_mutex); |
| 183 |
{ |
| 184 |
priv->janitor_task_stop = _gf_true; |
| 185 |
ret = gf_tw_del_timer(this->ctx->tw->timer_wheel, |
| 186 |
priv->janitor); |
| 187 |
if (!ret) { |
| 188 |
timespec_now_realtime(&sleep_till); |
| 189 |
sleep_till.tv_sec += 1; |
| 190 |
|
| 191 |
|
| 192 |
while (priv->janitor_task_stop) { |
| 193 |
(void)pthread_cond_timedwait(&priv->janitor_cond, |
| 194 |
&priv->janitor_mutex, |
| 195 |
&sleep_till); |
| 196 |
timespec_now_realtime(&sleep_till); |
| 197 |
sleep_till.tv_sec += 1; |
| 198 |
} |
| 199 |
} |
| 200 |
} |
| 201 |
pthread_mutex_unlock(&priv->janitor_mutex); |
| 202 |
GF_FREE(priv->janitor); |
| 203 |
} |
| 204 |
priv->janitor = NULL; |
| 205 |
pthread_mutex_lock(&ctx->fd_lock); |
| 206 |
{ |
| 207 |
while (priv->rel_fdcount > 0) { |
| 208 |
pthread_cond_wait(&priv->fd_cond, &ctx->fd_lock); |
| 209 |
} |
| 210 |
} |
| 211 |
pthread_mutex_unlock(&ctx->fd_lock); |
| 212 |
|
| 213 |
delete_posix_diskxl(priv, ctx); |
| 214 |
|
| 215 |
gf_log(this->name, GF_LOG_INFO, "Sending CHILD_DOWN for brick %s", |
| 216 |
victim->name); |
| 217 |
default_notify(this->parents->xlator, GF_EVENT_CHILD_DOWN, data); |
| 218 |
} break; |
| 219 |
default: |
| 220 |
|
| 221 |
break; |
| 222 |
} |
| 223 |
return 0; |
| 224 |
} |
| 225 |
|
| 226 |
int32_t |
| 227 |
mem_acct_init(xlator_t *this) |
| 228 |
{ |
| 229 |
int ret = -1; |
| 230 |
|
| 231 |
if (!this) |
| 232 |
return ret; |
| 233 |
|
| 234 |
ret = xlator_mem_acct_init(this, gf_posix_mt_end); |
| 235 |
|
| 236 |
if (ret != 0) { |
| 237 |
return ret; |
| 238 |
} |
| 239 |
|
| 240 |
return ret; |
| 241 |
} |
| 242 |
|
| 243 |
static int |
| 244 |
posix_set_owner(xlator_t *this, uid_t uid, gid_t gid) |
| 245 |
{ |
| 246 |
struct posix_private *priv = NULL; |
| 247 |
int ret = -1; |
| 248 |
struct stat st = { |
| 249 |
0, |
| 250 |
}; |
| 251 |
|
| 252 |
priv = this->private; |
| 253 |
|
| 254 |
ret = sys_lstat(priv->base_path, &st); |
| 255 |
if (ret) { |
| 256 |
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_DIR_OPERATION_FAILED, |
| 257 |
"Failed to stat " |
| 258 |
"brick path %s", |
| 259 |
priv->base_path); |
| 260 |
return ret; |
| 261 |
} |
| 262 |
|
| 263 |
if ((uid == -1 || st.st_uid == uid) && (gid == -1 || st.st_gid == gid)) |
| 264 |
return 0; |
| 265 |
|
| 266 |
ret = sys_chown(priv->base_path, uid, gid); |
| 267 |
if (ret) |
| 268 |
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_DIR_OPERATION_FAILED, |
| 269 |
"Failed to set uid/gid for" |
| 270 |
" brick path %s", |
| 271 |
priv->base_path); |
| 272 |
|
| 273 |
return ret; |
| 274 |
} |
| 275 |
static int |
| 276 |
set_gfid2path_separator(struct posix_private *priv, const char *str) |
| 277 |
{ |
| 278 |
int str_len = 0; |
| 279 |
|
| 280 |
str_len = strlen(str); |
| 281 |
if (str_len > 0 && str_len < 8) { |
| 282 |
strcpy(priv->gfid2path_sep, str); |
| 283 |
return 0; |
| 284 |
} |
| 285 |
|
| 286 |
return -1; |
| 287 |
} |
| 288 |
|
| 289 |
static int |
| 290 |
set_batch_fsync_mode(struct posix_private *priv, const char *str) |
| 291 |
{ |
| 292 |
if (strcmp(str, "none") == 0) |
| 293 |
priv->batch_fsync_mode = BATCH_NONE; |
| 294 |
else if (strcmp(str, "syncfs") == 0) |
| 295 |
priv->batch_fsync_mode = BATCH_SYNCFS; |
| 296 |
else if (strcmp(str, "syncfs-single-fsync") == 0) |
| 297 |
priv->batch_fsync_mode = BATCH_SYNCFS_SINGLE_FSYNC; |
| 298 |
else if (strcmp(str, "syncfs-reverse-fsync") == 0) |
| 299 |
priv->batch_fsync_mode = BATCH_SYNCFS_REVERSE_FSYNC; |
| 300 |
else if (strcmp(str, "reverse-fsync") == 0) |
| 301 |
priv->batch_fsync_mode = BATCH_REVERSE_FSYNC; |
| 302 |
else |
| 303 |
return -1; |
| 304 |
|
| 305 |
return 0; |
| 306 |
} |
| 307 |
|
| 308 |
#ifdef GF_DARWIN_HOST_OS |
| 309 |
static int |
| 310 |
set_xattr_user_namespace_mode(struct posix_private *priv, const char *str) |
| 311 |
{ |
| 312 |
if (strcmp(str, "none") == 0) |
| 313 |
priv->xattr_user_namespace = XATTR_NONE; |
| 314 |
else if (strcmp(str, "strip") == 0) |
| 315 |
priv->xattr_user_namespace = XATTR_STRIP; |
| 316 |
else if (strcmp(str, "append") == 0) |
| 317 |
priv->xattr_user_namespace = XATTR_APPEND; |
| 318 |
else if (strcmp(str, "both") == 0) |
| 319 |
priv->xattr_user_namespace = XATTR_BOTH; |
| 320 |
else |
| 321 |
return -1; |
| 322 |
return 0; |
| 323 |
} |
| 324 |
#endif |
| 325 |
|
| 326 |
int |
| 327 |
posix_reconfigure(xlator_t *this, dict_t *options) |
| 328 |
{ |
| 329 |
int ret = -1; |
| 330 |
struct posix_private *priv = NULL; |
| 331 |
int32_t uid = -1; |
| 332 |
int32_t gid = -1; |
| 333 |
char *batch_fsync_mode_str = NULL; |
| 334 |
char *gfid2path_sep = NULL; |
| 335 |
int32_t force_create_mode = -1; |
| 336 |
int32_t force_directory_mode = -1; |
| 337 |
int32_t create_mask = -1; |
| 338 |
int32_t create_directory_mask = -1; |
| 339 |
double old_disk_reserve = 0.0; |
| 340 |
|
| 341 |
priv = this->private; |
| 342 |
glusterfs_ctx_t *ctx = this->ctx; |
| 343 |
|
| 344 |
GF_OPTION_RECONF("brick-uid", uid, options, int32, out); |
| 345 |
GF_OPTION_RECONF("brick-gid", gid, options, int32, out); |
| 346 |
if (uid != -1 || gid != -1) |
| 347 |
posix_set_owner(this, uid, gid); |
| 348 |
|
| 349 |
GF_OPTION_RECONF("batch-fsync-delay-usec", priv->batch_fsync_delay_usec, |
| 350 |
options, uint32, out); |
| 351 |
|
| 352 |
GF_OPTION_RECONF("batch-fsync-mode", batch_fsync_mode_str, options, str, |
| 353 |
out); |
| 354 |
|
| 355 |
if (set_batch_fsync_mode(priv, batch_fsync_mode_str) != 0) { |
| 356 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, |
| 357 |
"Unknown mode string: %s", batch_fsync_mode_str); |
| 358 |
goto out; |
| 359 |
} |
| 360 |
|
| 361 |
GF_OPTION_RECONF("gfid2path-separator", gfid2path_sep, options, str, out); |
| 362 |
if (set_gfid2path_separator(priv, gfid2path_sep) != 0) { |
| 363 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, |
| 364 |
"Length of separator exceeds 7: %s", gfid2path_sep); |
| 365 |
goto out; |
| 366 |
} |
| 367 |
|
| 368 |
#ifdef GF_DARWIN_HOST_OS |
| 369 |
|
| 370 |
char *xattr_user_namespace_mode_str = NULL; |
| 371 |
|
| 372 |
GF_OPTION_RECONF("xattr-user-namespace-mode", xattr_user_namespace_mode_str, |
| 373 |
options, str, out); |
| 374 |
|
| 375 |
if (set_xattr_user_namespace_mode(priv, xattr_user_namespace_mode_str) != |
| 376 |
0) { |
| 377 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_UNKNOWN_ARGUMENT, |
| 378 |
"Unknown xattr user namespace mode string: %s", |
| 379 |
xattr_user_namespace_mode_str); |
| 380 |
goto out; |
| 381 |
} |
| 382 |
|
| 383 |
#endif |
| 384 |
|
| 385 |
GF_OPTION_RECONF("linux-aio", priv->aio_configured, options, bool, out); |
| 386 |
|
| 387 |
if (priv->aio_configured) |
| 388 |
posix_aio_on(this); |
| 389 |
else |
| 390 |
posix_aio_off(this); |
| 391 |
|
| 392 |
GF_OPTION_RECONF("linux-io_uring", priv->io_uring_configured, options, bool, |
| 393 |
out); |
| 394 |
|
| 395 |
if (priv->io_uring_configured) |
| 396 |
posix_io_uring_on(this); |
| 397 |
else |
| 398 |
posix_io_uring_off(this); |
| 399 |
|
| 400 |
GF_OPTION_RECONF("update-link-count-parent", priv->update_pgfid_nlinks, |
| 401 |
options, bool, out); |
| 402 |
|
| 403 |
GF_OPTION_RECONF("gfid2path", priv->gfid2path, options, bool, out); |
| 404 |
|
| 405 |
GF_OPTION_RECONF("node-uuid-pathinfo", priv->node_uuid_pathinfo, options, |
| 406 |
bool, out); |
| 407 |
|
| 408 |
if (priv->node_uuid_pathinfo && (gf_uuid_is_null(priv->glusterd_uuid))) { |
| 409 |
gf_msg(this->name, GF_LOG_INFO, 0, P_MSG_UUID_NULL, |
| 410 |
"glusterd uuid is NULL, pathinfo xattr would" |
| 411 |
" fallback to <hostname>:<export>"); |
| 412 |
} |
| 413 |
|
| 414 |
old_disk_reserve = priv->disk_reserve; |
| 415 |
GF_OPTION_RECONF("reserve", priv->disk_reserve, options, percent_or_size, |
| 416 |
out); |
| 417 |
|
| 418 |
priv->disk_unit_percent = _gf_false; |
| 419 |
if (priv->disk_reserve < 100.0) |
| 420 |
priv->disk_unit_percent = _gf_true; |
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
if (old_disk_reserve != priv->disk_reserve) { |
| 426 |
delete_posix_diskxl(priv, ctx); |
| 427 |
old_disk_reserve = 0; |
| 428 |
} |
| 429 |
|
| 430 |
if (!old_disk_reserve && priv->disk_reserve) { |
| 431 |
ret = posix_spawn_disk_space_check_thread(this); |
| 432 |
if (ret) { |
| 433 |
gf_msg(this->name, GF_LOG_INFO, 0, P_MSG_DISK_SPACE_CHECK_FAILED, |
| 434 |
"Getting disk space check from thread failed "); |
| 435 |
goto out; |
| 436 |
} |
| 437 |
} |
| 438 |
|
| 439 |
GF_OPTION_RECONF("health-check-interval", priv->health_check_interval, |
| 440 |
options, time, out); |
| 441 |
GF_OPTION_RECONF("health-check-timeout", priv->health_check_timeout, |
| 442 |
options, time, out); |
| 443 |
if (priv->health_check_interval) { |
| 444 |
ret = posix_spawn_health_check_thread(this); |
| 445 |
if (ret) |
| 446 |
goto out; |
| 447 |
} |
| 448 |
|
| 449 |
GF_OPTION_RECONF("shared-brick-count", priv->shared_brick_count, options, |
| 450 |
int32, out); |
| 451 |
|
| 452 |
GF_OPTION_RECONF("disable-landfill-purge", priv->disable_landfill_purge, |
| 453 |
options, bool, out); |
| 454 |
if (priv->disable_landfill_purge) { |
| 455 |
gf_log(this->name, GF_LOG_WARNING, |
| 456 |
"Janitor WILL NOT purge the landfill directory. " |
| 457 |
"Your landfill directory" |
| 458 |
" may fill up this brick."); |
| 459 |
} else { |
| 460 |
gf_msg_debug(this->name, 0, |
| 461 |
"Janitor will purge the landfill " |
| 462 |
"directory, which is default behavior"); |
| 463 |
} |
| 464 |
|
| 465 |
GF_OPTION_RECONF("force-create-mode", force_create_mode, options, int32, |
| 466 |
out); |
| 467 |
priv->force_create_mode = force_create_mode; |
| 468 |
|
| 469 |
GF_OPTION_RECONF("force-directory-mode", force_directory_mode, options, |
| 470 |
int32, out); |
| 471 |
priv->force_directory_mode = force_directory_mode; |
| 472 |
|
| 473 |
GF_OPTION_RECONF("create-mask", create_mask, options, int32, out); |
| 474 |
priv->create_mask = create_mask; |
| 475 |
|
| 476 |
GF_OPTION_RECONF("create-directory-mask", create_directory_mask, options, |
| 477 |
int32, out); |
| 478 |
priv->create_directory_mask = create_directory_mask; |
| 479 |
|
| 480 |
GF_OPTION_RECONF("max-hardlinks", priv->max_hardlinks, options, uint32, |
| 481 |
out); |
| 482 |
|
| 483 |
GF_OPTION_RECONF("fips-mode-rchecksum", priv->fips_mode_rchecksum, options, |
| 484 |
bool, out); |
| 485 |
|
| 486 |
GF_OPTION_RECONF("ctime", priv->ctime, options, bool, out); |
| 487 |
|
| 488 |
ret = 0; |
| 489 |
out: |
| 490 |
return ret; |
| 491 |
} |
| 492 |
|
| 493 |
static int32_t |
| 494 |
posix_delete_unlink_entry(const char *fpath, const struct stat *sb, |
| 495 |
int typeflag, struct FTW *ftwbuf) |
| 496 |
{ |
| 497 |
int ret = 0; |
| 498 |
|
| 499 |
if (!fpath) |
| 500 |
goto out; |
| 501 |
|
| 502 |
switch (typeflag) { |
| 503 |
case FTW_SL: |
| 504 |
case FTW_NS: |
| 505 |
case FTW_F: |
| 506 |
case FTW_SLN: |
| 507 |
ret = sys_unlink(fpath); |
| 508 |
break; |
| 509 |
case FTW_D: |
| 510 |
case FTW_DP: |
| 511 |
case FTW_DNR: |
| 512 |
if (ftwbuf->level != 0) { |
| 513 |
ret = sys_rmdir(fpath); |
| 514 |
} |
| 515 |
break; |
| 516 |
default: |
| 517 |
break; |
| 518 |
} |
| 519 |
if (ret) { |
| 520 |
gf_msg("posix_delete_unlink_entry", GF_LOG_WARNING, errno, |
| 521 |
P_MSG_HANDLE_CREATE, |
| 522 |
"Deletion of entries %s failed" |
| 523 |
"Please delete it manually", |
| 524 |
fpath); |
| 525 |
} |
| 526 |
out: |
| 527 |
return 0; |
| 528 |
} |
| 529 |
|
| 530 |
static int32_t |
| 531 |
posix_delete_unlink(const char *unlink_path) |
| 532 |
{ |
| 533 |
int ret = -1; |
| 534 |
int flags = 0; |
| 535 |
|
| 536 |
flags |= (FTW_DEPTH | FTW_PHYS); |
| 537 |
|
| 538 |
ret = nftw(unlink_path, posix_delete_unlink_entry, 2, flags); |
| 539 |
if (ret) { |
| 540 |
gf_msg("posix_delete_unlink", GF_LOG_ERROR, 0, P_MSG_HANDLE_CREATE, |
| 541 |
"Deleting files from %s failed", unlink_path); |
| 542 |
} |
| 543 |
return ret; |
| 544 |
} |
| 545 |
|
| 546 |
static int32_t |
| 547 |
posix_create_unlink_dir(xlator_t *this) |
| 548 |
{ |
| 549 |
struct posix_private *priv = NULL; |
| 550 |
struct stat stbuf; |
| 551 |
int ret = -1; |
| 552 |
uuid_t gfid = {0}; |
| 553 |
char gfid_str[64] = {0}; |
| 554 |
char unlink_path[PATH_MAX] = { |
| 555 |
0, |
| 556 |
}; |
| 557 |
char landfill_path[PATH_MAX] = { |
| 558 |
0, |
| 559 |
}; |
| 560 |
|
| 561 |
priv = this->private; |
| 562 |
|
| 563 |
(void)snprintf(unlink_path, sizeof(unlink_path), "%s/%s", priv->base_path, |
| 564 |
GF_UNLINK_PATH); |
| 565 |
|
| 566 |
gf_uuid_generate(gfid); |
| 567 |
uuid_utoa_r(gfid, gfid_str); |
| 568 |
|
| 569 |
(void)snprintf(landfill_path, sizeof(landfill_path), "%s/%s/%s", |
| 570 |
priv->base_path, GF_LANDFILL_PATH, gfid_str); |
| 571 |
|
| 572 |
ret = sys_stat(unlink_path, &stbuf); |
| 573 |
switch (ret) { |
| 574 |
case -1: |
| 575 |
if (errno != ENOENT) { |
| 576 |
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_HANDLE_CREATE, |
| 577 |
"Checking for %s failed", unlink_path); |
| 578 |
return -1; |
| 579 |
} |
| 580 |
break; |
| 581 |
case 0: |
| 582 |
if (!S_ISDIR(stbuf.st_mode)) { |
| 583 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_HANDLE_CREATE, |
| 584 |
"Not a directory: %s", unlink_path); |
| 585 |
return -1; |
| 586 |
} |
| 587 |
ret = posix_delete_unlink(unlink_path); |
| 588 |
return 0; |
| 589 |
default: |
| 590 |
break; |
| 591 |
} |
| 592 |
ret = sys_mkdir(unlink_path, 0600); |
| 593 |
if (ret) { |
| 594 |
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_HANDLE_CREATE, |
| 595 |
"Creating directory %s failed", unlink_path); |
| 596 |
return -1; |
| 597 |
} |
| 598 |
|
| 599 |
return 0; |
| 600 |
} |
| 601 |
|
| 602 |
static int |
| 603 |
posix_create_open_directory_based_fd(xlator_t *this, int pdirfd, char *dir_name) |
| 604 |
{ |
| 605 |
int ret = -1; |
| 606 |
|
| 607 |
ret = sys_openat(pdirfd, dir_name, (O_DIRECTORY | O_RDONLY), 0); |
| 608 |
if (ret < 0 && errno == ENOENT) { |
| 609 |
ret = sys_mkdirat(pdirfd, dir_name, 0700); |
| 610 |
if (ret < 0) { |
| 611 |
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_HANDLE_CREATE, |
| 612 |
"Creating directory %s failed", dir_name); |
| 613 |
goto out; |
| 614 |
} |
| 615 |
ret = sys_openat(pdirfd, dir_name, (O_DIRECTORY | O_RDONLY), 0); |
| 616 |
if (ret < 0 && errno != EEXIST) { |
| 617 |
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_HANDLE_CREATE, |
| 618 |
"error mkdir hash-1 %s ", dir_name); |
| 619 |
goto out; |
| 620 |
} |
| 621 |
} |
| 622 |
out: |
| 623 |
return ret; |
| 624 |
} |
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
int |
| 630 |
posix_init(xlator_t *this) |
| 631 |
{ |
| 632 |
struct posix_private *_private = NULL; |
| 633 |
data_t *dir_data = NULL; |
| 634 |
data_t *tmp_data = NULL; |
| 635 |
struct stat buf = { |
| 636 |
0, |
| 637 |
}; |
| 638 |
struct statvfs fs = { |
| 639 |
0, |
| 640 |
}; |
| 641 |
gf_boolean_t tmp_bool = 0; |
| 642 |
int ret = 0; |
| 643 |
int op_ret = -1; |
| 644 |
int op_errno = 0; |
| 645 |
ssize_t size = -1; |
| 646 |
uuid_t old_uuid = { |
| 647 |
0, |
| 648 |
}; |
| 649 |
uuid_t dict_uuid = { |
| 650 |
0, |
| 651 |
}; |
| 652 |
uuid_t gfid = { |
| 653 |
0, |
| 654 |
}; |
| 655 |
static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; |
| 656 |
char *guuid = NULL; |
| 657 |
int32_t uid = -1; |
| 658 |
int32_t gid = -1; |
| 659 |
char *batch_fsync_mode_str; |
| 660 |
char *gfid2path_sep = NULL; |
| 661 |
int force_create = -1; |
| 662 |
int force_directory = -1; |
| 663 |
int create_mask = -1; |
| 664 |
int create_directory_mask = -1; |
| 665 |
char dir_handle[PATH_MAX] = { |
| 666 |
0, |
| 667 |
}; |
| 668 |
int i; |
| 669 |
char fhash[4] = { |
| 670 |
0, |
| 671 |
}; |
| 672 |
int hdirfd = -1; |
| 673 |
char value; |
| 674 |
|
| 675 |
dir_data = dict_get(this->options, "directory"); |
| 676 |
|
| 677 |
if (this->children) { |
| 678 |
gf_msg(this->name, GF_LOG_CRITICAL, 0, P_MSG_SUBVOLUME_ERROR, |
| 679 |
"FATAL: storage/posix cannot have subvolumes"); |
| 680 |
ret = -1; |
| 681 |
goto out; |
| 682 |
} |
| 683 |
|
| 684 |
if (!this->parents) { |
| 685 |
gf_msg(this->name, GF_LOG_WARNING, 0, P_MSG_VOLUME_DANGLING, |
| 686 |
"Volume is dangling. Please check the volume file."); |
| 687 |
} |
| 688 |
|
| 689 |
if (!dir_data) { |
| 690 |
gf_msg(this->name, GF_LOG_CRITICAL, 0, P_MSG_EXPORT_DIR_MISSING, |
| 691 |
"Export directory not specified in volume file."); |
| 692 |
ret = -1; |
| 693 |
goto out; |
| 694 |
} |
| 695 |
|
| 696 |
umask(000); |
| 697 |
|
| 698 |
|
| 699 |
op_ret = sys_stat(dir_data->data, &buf); |
| 700 |
if ((op_ret != 0) || !S_ISDIR(buf.st_mode)) { |
| 701 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_DIR_OPERATION_FAILED, |
| 702 |
"Directory '%s' doesn't exist, exiting.", dir_data->data); |
| 703 |
ret = -1; |
| 704 |
goto out; |
| 705 |
} |
| 706 |
|
| 707 |
_private = GF_CALLOC(1, sizeof(*_private), gf_posix_mt_posix_private); |
| 708 |
if (!_private) { |
| 709 |
ret = -1; |
| 710 |
goto out; |
| 711 |
} |
| 712 |
|
| 713 |
_private->base_path = gf_strdup(dir_data->data); |
| 714 |
_private->base_path_length = dir_data->len - 1; |
| 715 |
|
| 716 |
if (sys_statvfs(_private->base_path, &fs) < 0) { |
| 717 |
ret = -1; |
| 718 |
goto out; |
| 719 |
} |
| 720 |
GF_ASSERT((fs.f_bsize & (fs.f_bsize - 1)) == 0); |
| 721 |
_private->base_bsize = fs.f_bsize; |
| 722 |
|
| 723 |
_private->dirfd = -1; |
| 724 |
_private->mount_lock = -1; |
| 725 |
for (i = 0; i < 256; i++) |
| 726 |
_private->arrdfd[i] = -1; |
| 727 |
|
| 728 |
ret = dict_get_str(this->options, "hostname", &_private->hostname); |
| 729 |
if (ret) |
| 730 |
_private->hostname = gf_gethostname(); |
| 731 |
|
| 732 |
|
| 733 |
size = sys_lgetxattr(dir_data->data, "user.x", &value, sizeof(value)); |
| 734 |
|
| 735 |
if ((size == -1) && (errno == EOPNOTSUPP)) { |
| 736 |
gf_msg(this->name, GF_LOG_DEBUG, 0, P_MSG_XDATA_GETXATTR, |
| 737 |
"getxattr returned %zd", size); |
| 738 |
tmp_data = dict_get(this->options, "mandate-attribute"); |
| 739 |
if (tmp_data) { |
| 740 |
if (gf_string2boolean(tmp_data->data, &tmp_bool) == -1) { |
| 741 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_OPTION, |
| 742 |
"wrong option provided for key " |
| 743 |
"\"mandate-attribute\""); |
| 744 |
ret = -1; |
| 745 |
goto out; |
| 746 |
} |
| 747 |
if (!tmp_bool) { |
| 748 |
gf_msg(this->name, GF_LOG_WARNING, 0, P_MSG_XATTR_NOTSUP, |
| 749 |
"Extended attribute not supported, " |
| 750 |
"starting as per option"); |
| 751 |
} else { |
| 752 |
gf_msg(this->name, GF_LOG_CRITICAL, 0, P_MSG_XATTR_NOTSUP, |
| 753 |
"Extended attribute not supported, " |
| 754 |
"exiting."); |
| 755 |
ret = -1; |
| 756 |
goto out; |
| 757 |
} |
| 758 |
} else { |
| 759 |
gf_msg(this->name, GF_LOG_CRITICAL, 0, P_MSG_XATTR_NOTSUP, |
| 760 |
"Extended attribute not supported, exiting."); |
| 761 |
ret = -1; |
| 762 |
goto out; |
| 763 |
} |
| 764 |
} |
| 765 |
|
| 766 |
tmp_data = dict_get(this->options, "volume-id"); |
| 767 |
if (tmp_data) { |
| 768 |
op_ret = gf_uuid_parse(tmp_data->data, dict_uuid); |
| 769 |
if (op_ret < 0) { |
| 770 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_VOLUME_ID, |
| 771 |
"wrong volume-id (%s) set" |
| 772 |
" in volume file", |
| 773 |
tmp_data->data); |
| 774 |
ret = -1; |
| 775 |
goto out; |
| 776 |
} |
| 777 |
size = sys_lgetxattr(dir_data->data, "trusted.glusterfs.volume-id", |
| 778 |
old_uuid, 16); |
| 779 |
if (size == 16) { |
| 780 |
if (gf_uuid_compare(old_uuid, dict_uuid)) { |
| 781 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_VOLUME_ID, |
| 782 |
"mismatching volume-id (%s) received. " |
| 783 |
"already is a part of volume %s ", |
| 784 |
tmp_data->data, uuid_utoa(old_uuid)); |
| 785 |
gf_event(EVENT_POSIX_ALREADY_PART_OF_VOLUME, |
| 786 |
"volume-id=%s;brick=%s:%s", uuid_utoa(old_uuid), |
| 787 |
_private->hostname, _private->base_path); |
| 788 |
ret = -1; |
| 789 |
goto out; |
| 790 |
} |
| 791 |
} else if ((size == -1) && (errno == ENODATA || errno == ENOATTR)) { |
| 792 |
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_VOLUME_ID_ABSENT, |
| 793 |
"Extended attribute trusted.glusterfs." |
| 794 |
"volume-id is absent"); |
| 795 |
gf_event(EVENT_POSIX_BRICK_NOT_IN_VOLUME, "brick=%s:%s", |
| 796 |
_private->hostname, _private->base_path); |
| 797 |
ret = -1; |
| 798 |
goto out; |
| 799 |
|
| 800 |
} else if ((size == -1) && (errno != ENODATA) && (errno != ENOATTR)) { |
| 801 |
|
| 802 |
gf_event(EVENT_POSIX_BRICK_VERIFICATION_FAILED, "brick=%s:%s", |
| 803 |
_private->hostname, _private->base_path); |
| 804 |
gf_msg(this->name, GF_LOG_WARNING, errno, |
| 805 |
P_MSG_VOLUME_ID_FETCH_FAILED, |
| 806 |
"%s: failed to fetch volume-id", dir_data->data); |
| 807 |
ret = -1; |
| 808 |
goto out; |
| 809 |
} else { |
| 810 |
ret = -1; |
| 811 |
gf_event(EVENT_POSIX_BRICK_VERIFICATION_FAILED, "brick=%s:%s", |
| 812 |
_private->hostname, _private->base_path); |
| 813 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_VOLUME_ID_FETCH_FAILED, |
| 814 |
"failed to fetch proper volume id from export"); |
| 815 |
goto out; |
| 816 |
} |
| 817 |
} |
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
size = sys_lgetxattr(dir_data->data, "trusted.gfid", gfid, 16); |
| 822 |
if (size == 16) { |
| 823 |
if (!__is_root_gfid(gfid)) { |
| 824 |
gf_msg(this->name, GF_LOG_WARNING, errno, P_MSG_GFID_SET_FAILED, |
| 825 |
"%s: gfid (%s) is not that of glusterfs '/' ", |
| 826 |
dir_data->data, uuid_utoa(gfid)); |
| 827 |
ret = -1; |
| 828 |
goto out; |
| 829 |
} |
| 830 |
} else if (size != -1) { |
| 831 |
|
| 832 |
gf_msg(this->name, GF_LOG_WARNING, errno, P_MSG_GFID_SET_FAILED, |
| 833 |
"%s: wrong value set as gfid", dir_data->data); |
| 834 |
ret = -1; |
| 835 |
goto out; |
| 836 |
} else if ((size == -1) && (errno != ENODATA) && (errno != ENOATTR)) { |
| 837 |
|
| 838 |
gf_msg(this->name, GF_LOG_WARNING, errno, P_MSG_GFID_SET_FAILED, |
| 839 |
"%s: failed to fetch gfid", dir_data->data); |
| 840 |
ret = -1; |
| 841 |
goto out; |
| 842 |
} else { |
| 843 |
|
| 844 |
size = sys_lsetxattr(dir_data->data, "trusted.gfid", rootgfid, 16, |
| 845 |
XATTR_CREATE); |
| 846 |
if (size == -1) { |
| 847 |
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_GFID_SET_FAILED, |
| 848 |
"%s: failed to set gfid", dir_data->data); |
| 849 |
ret = -1; |
| 850 |
goto out; |
| 851 |
} |
| 852 |
} |
| 853 |
|
| 854 |
ret = 0; |
| 855 |
|
| 856 |
size = sys_lgetxattr(dir_data->data, POSIX_ACL_ACCESS_XATTR, NULL, 0); |
| 857 |
if ((size < 0) && (errno == ENOTSUP)) { |
| 858 |
gf_msg(this->name, GF_LOG_WARNING, errno, P_MSG_ACL_NOTSUP, |
| 859 |
"Posix access control list is not supported."); |
| 860 |
gf_event(EVENT_POSIX_ACL_NOT_SUPPORTED, "brick=%s:%s", |
| 861 |
_private->hostname, _private->base_path); |
| 862 |
} |
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
_private->path_max = pathconf(_private->base_path, _PC_PATH_MAX); |
| 874 |
if (_private->path_max != -1 && |
| 875 |
_XOPEN_PATH_MAX + _private->base_path_length > _private->path_max) { |
| 876 |
ret = chdir(_private->base_path); |
| 877 |
if (ret) { |
| 878 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_BASEPATH_CHDIR_FAILED, |
| 879 |
"chdir() to \"%s\" failed", _private->base_path); |
| 880 |
goto out; |
| 881 |
} |
| 882 |
#ifdef __NetBSD__ |
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
|
| 891 |
|
| 892 |
sleep(1); |
| 893 |
#endif |
| 894 |
} |
| 895 |
|
| 896 |
LOCK_INIT(&_private->lock); |
| 897 |
GF_ATOMIC_INIT(_private->read_value, 0); |
| 898 |
GF_ATOMIC_INIT(_private->write_value, 0); |
| 899 |
|
| 900 |
_private->export_statfs = 1; |
| 901 |
tmp_data = dict_get(this->options, "export-statfs-size"); |
| 902 |
if (tmp_data) { |
| 903 |
if (gf_string2boolean(tmp_data->data, &_private->export_statfs) == -1) { |
| 904 |
ret = -1; |
| 905 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_OPTION_VAL, |
| 906 |
"'export-statfs-size' takes only boolean " |
| 907 |
"options"); |
| 908 |
goto out; |
| 909 |
} |
| 910 |
if (!_private->export_statfs) |
| 911 |
gf_msg_debug(this->name, 0, "'statfs()' returns dummy size"); |
| 912 |
} |
| 913 |
|
| 914 |
_private->background_unlink = 0; |
| 915 |
tmp_data = dict_get(this->options, "background-unlink"); |
| 916 |
if (tmp_data) { |
| 917 |
if (gf_string2boolean(tmp_data->data, &_private->background_unlink) == |
| 918 |
-1) { |
| 919 |
ret = -1; |
| 920 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_OPTION_VAL, |
| 921 |
"'background-unlink'" |
| 922 |
" takes only boolean options"); |
| 923 |
goto out; |
| 924 |
} |
| 925 |
|
| 926 |
if (_private->background_unlink) |
| 927 |
gf_msg_debug(this->name, 0, |
| 928 |
"unlinks will be performed in background"); |
| 929 |
} |
| 930 |
|
| 931 |
tmp_data = dict_get(this->options, "o-direct"); |
| 932 |
if (tmp_data) { |
| 933 |
if (gf_string2boolean(tmp_data->data, &_private->o_direct) == -1) { |
| 934 |
ret = -1; |
| 935 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_OPTION_VAL, |
| 936 |
"wrong option provided for 'o-direct'"); |
| 937 |
goto out; |
| 938 |
} |
| 939 |
if (_private->o_direct) |
| 940 |
gf_msg_debug(this->name, 0, |
| 941 |
"o-direct mode is enabled" |
| 942 |
" (O_DIRECT for every open)"); |
| 943 |
} |
| 944 |
|
| 945 |
tmp_data = dict_get(this->options, "update-link-count-parent"); |
| 946 |
if (tmp_data) { |
| 947 |
if (gf_string2boolean(tmp_data->data, &_private->update_pgfid_nlinks) == |
| 948 |
-1) { |
| 949 |
ret = -1; |
| 950 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_OPTION, |
| 951 |
"wrong value provided " |
| 952 |
"for 'update-link-count-parent'"); |
| 953 |
goto out; |
| 954 |
} |
| 955 |
if (_private->update_pgfid_nlinks) |
| 956 |
gf_msg_debug(this->name, 0, |
| 957 |
"update-link-count-parent" |
| 958 |
" is enabled. Thus for each file an " |
| 959 |
"extended attribute representing the " |
| 960 |
"number of hardlinks for that file " |
| 961 |
"within the same parent directory is" |
| 962 |
" set."); |
| 963 |
} |
| 964 |
|
| 965 |
ret = dict_get_str(this->options, "glusterd-uuid", &guuid); |
| 966 |
if (!ret) { |
| 967 |
if (gf_uuid_parse(guuid, _private->glusterd_uuid)) |
| 968 |
gf_msg(this->name, GF_LOG_WARNING, 0, P_MSG_INVALID_NODE_UUID, |
| 969 |
"Cannot parse " |
| 970 |
"glusterd (node) UUID, node-uuid xattr " |
| 971 |
"request would return - \"No such attribute\""); |
| 972 |
} else { |
| 973 |
gf_msg_debug(this->name, 0, |
| 974 |
"No glusterd (node) UUID passed -" |
| 975 |
" node-uuid xattr request will return \"No such" |
| 976 |
" attribute\""); |
| 977 |
} |
| 978 |
ret = 0; |
| 979 |
|
| 980 |
GF_OPTION_INIT("janitor-sleep-duration", _private->janitor_sleep_duration, |
| 981 |
time, out); |
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
_private->mount_lock = sys_open(dir_data->data, (O_DIRECTORY | O_RDONLY), |
| 987 |
0); |
| 988 |
if (_private->mount_lock < 0) { |
| 989 |
ret = -1; |
| 990 |
op_errno = errno; |
| 991 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_DIR_OPERATION_FAILED, |
| 992 |
"Could not lock brick directory (%s)", strerror(op_errno)); |
| 993 |
goto out; |
| 994 |
} |
| 995 |
|
| 996 |
gf_set_nofile(1048576, 65536); |
| 997 |
|
| 998 |
_private->shared_brick_count = 1; |
| 999 |
ret = dict_get_int32(this->options, "shared-brick-count", |
| 1000 |
&_private->shared_brick_count); |
| 1001 |
if (ret == -1) { |
| 1002 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_OPTION_VAL, |
| 1003 |
"'shared-brick-count' takes only integer " |
| 1004 |
"values"); |
| 1005 |
goto out; |
| 1006 |
} |
| 1007 |
|
| 1008 |
this->private = (void *)_private; |
| 1009 |
snprintf(dir_handle, sizeof(dir_handle), "%s/%s", _private->base_path, |
| 1010 |
GF_HIDDEN_PATH); |
| 1011 |
hdirfd = posix_create_open_directory_based_fd(this, _private->mount_lock, |
| 1012 |
dir_handle); |
| 1013 |
if (hdirfd < 0) { |
| 1014 |
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_HANDLE_CREATE, |
| 1015 |
"error open directory failed for dir %s", dir_handle); |
| 1016 |
ret = -1; |
| 1017 |
goto out; |
| 1018 |
} |
| 1019 |
_private->dirfd = hdirfd; |
| 1020 |
for (i = 0; i < 256; i++) { |
| 1021 |
snprintf(fhash, sizeof(fhash), "%02x", i); |
| 1022 |
_private->arrdfd[i] = posix_create_open_directory_based_fd(this, hdirfd, |
| 1023 |
fhash); |
| 1024 |
if (_private->arrdfd[i] < 0) { |
| 1025 |
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_HANDLE_CREATE, |
| 1026 |
"error openat failed for file %s", fhash); |
| 1027 |
ret = -1; |
| 1028 |
goto out; |
| 1029 |
} |
| 1030 |
} |
| 1031 |
|
| 1032 |
op_ret = posix_handle_init(this); |
| 1033 |
if (op_ret == -1) { |
| 1034 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_HANDLE_CREATE, |
| 1035 |
"Posix handle setup failed"); |
| 1036 |
ret = -1; |
| 1037 |
goto out; |
| 1038 |
} |
| 1039 |
|
| 1040 |
op_ret = posix_handle_trash_init(this); |
| 1041 |
if (op_ret < 0) { |
| 1042 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_HANDLE_CREATE_TRASH, |
| 1043 |
"Posix landfill setup failed"); |
| 1044 |
ret = -1; |
| 1045 |
goto out; |
| 1046 |
} |
| 1047 |
|
| 1048 |
op_ret = posix_create_unlink_dir(this); |
| 1049 |
if (op_ret == -1) { |
| 1050 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_HANDLE_CREATE, |
| 1051 |
"Creation of unlink directory failed"); |
| 1052 |
ret = -1; |
| 1053 |
goto out; |
| 1054 |
} |
| 1055 |
|
| 1056 |
_private->aio_init_done = _gf_false; |
| 1057 |
_private->aio_capable = _gf_false; |
| 1058 |
|
| 1059 |
GF_OPTION_INIT("brick-uid", uid, int32, out); |
| 1060 |
GF_OPTION_INIT("brick-gid", gid, int32, out); |
| 1061 |
if (uid != -1 || gid != -1) |
| 1062 |
posix_set_owner(this, uid, gid); |
| 1063 |
|
| 1064 |
GF_OPTION_INIT("linux-aio", _private->aio_configured, bool, out); |
| 1065 |
|
| 1066 |
if (_private->aio_configured) { |
| 1067 |
op_ret = posix_aio_on(this); |
| 1068 |
|
| 1069 |
if (op_ret == -1) { |
| 1070 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_POSIX_AIO, |
| 1071 |
"Posix AIO init failed"); |
| 1072 |
ret = -1; |
| 1073 |
goto out; |
| 1074 |
} |
| 1075 |
} |
| 1076 |
|
| 1077 |
GF_OPTION_INIT("linux-io_uring", _private->io_uring_configured, bool, out); |
| 1078 |
if (_private->io_uring_configured) { |
| 1079 |
op_ret = posix_io_uring_on(this); |
| 1080 |
if (op_ret < 0) { |
| 1081 |
_private->io_uring_configured = _gf_false; |
| 1082 |
} |
| 1083 |
} |
| 1084 |
|
| 1085 |
GF_OPTION_INIT("node-uuid-pathinfo", _private->node_uuid_pathinfo, bool, |
| 1086 |
out); |
| 1087 |
if (_private->node_uuid_pathinfo && |
| 1088 |
(gf_uuid_is_null(_private->glusterd_uuid))) { |
| 1089 |
gf_msg(this->name, GF_LOG_INFO, 0, P_MSG_UUID_NULL, |
| 1090 |
"glusterd uuid is NULL, pathinfo xattr would" |
| 1091 |
" fallback to <hostname>:<export>"); |
| 1092 |
} |
| 1093 |
|
| 1094 |
_private->disk_space_full = 0; |
| 1095 |
|
| 1096 |
GF_OPTION_INIT("reserve", _private->disk_reserve, percent_or_size, out); |
| 1097 |
|
| 1098 |
|
| 1099 |
_private->disk_unit_percent = _gf_false; |
| 1100 |
pthread_cond_init(&_private->fd_cond, NULL); |
| 1101 |
if (_private->disk_reserve < 100.0) |
| 1102 |
_private->disk_unit_percent = _gf_true; |
| 1103 |
|
| 1104 |
if (_private->disk_reserve) { |
| 1105 |
ret = posix_spawn_disk_space_check_thread(this); |
| 1106 |
if (ret) { |
| 1107 |
gf_msg(this->name, GF_LOG_INFO, 0, P_MSG_DISK_SPACE_CHECK_FAILED, |
| 1108 |
"Getting disk space check from thread failed "); |
| 1109 |
goto out; |
| 1110 |
} |
| 1111 |
} |
| 1112 |
|
| 1113 |
_private->health_check_active = _gf_false; |
| 1114 |
GF_OPTION_INIT("health-check-interval", _private->health_check_interval, |
| 1115 |
time, out); |
| 1116 |
GF_OPTION_INIT("health-check-timeout", _private->health_check_timeout, time, |
| 1117 |
out); |
| 1118 |
if (_private->health_check_interval) { |
| 1119 |
ret = posix_spawn_health_check_thread(this); |
| 1120 |
if (ret) |
| 1121 |
goto out; |
| 1122 |
} |
| 1123 |
posix_janitor_timer_start(this); |
| 1124 |
|
| 1125 |
pthread_mutex_init(&_private->fsync_mutex, NULL); |
| 1126 |
pthread_cond_init(&_private->fsync_cond, NULL); |
| 1127 |
pthread_mutex_init(&_private->janitor_mutex, NULL); |
| 1128 |
pthread_cond_init(&_private->janitor_cond, NULL); |
| 1129 |
pthread_cond_init(&_private->fd_cond, NULL); |
| 1130 |
INIT_LIST_HEAD(&_private->fsyncs); |
| 1131 |
_private->rel_fdcount = 0; |
| 1132 |
ret = posix_spawn_ctx_janitor_thread(this); |
| 1133 |
if (ret) |
| 1134 |
goto out; |
| 1135 |
|
| 1136 |
ret = gf_thread_create(&_private->fsyncer, NULL, posix_fsyncer, this, |
| 1137 |
"posixfsy"); |
| 1138 |
if (ret) { |
| 1139 |
gf_msg(this->name, GF_LOG_ERROR, errno, |
| 1140 |
P_MSG_FSYNCER_THREAD_CREATE_FAILED, |
| 1141 |
"fsyncer thread creation failed"); |
| 1142 |
goto out; |
| 1143 |
} |
| 1144 |
|
| 1145 |
GF_OPTION_INIT("batch-fsync-mode", batch_fsync_mode_str, str, out); |
| 1146 |
|
| 1147 |
if (set_batch_fsync_mode(_private, batch_fsync_mode_str) != 0) { |
| 1148 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, |
| 1149 |
"Unknown mode string: %s", batch_fsync_mode_str); |
| 1150 |
goto out; |
| 1151 |
} |
| 1152 |
|
| 1153 |
GF_OPTION_INIT("gfid2path", _private->gfid2path, bool, out); |
| 1154 |
|
| 1155 |
GF_OPTION_INIT("gfid2path-separator", gfid2path_sep, str, out); |
| 1156 |
if (set_gfid2path_separator(_private, gfid2path_sep) != 0) { |
| 1157 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, |
| 1158 |
"Length of separator exceeds 7: %s", gfid2path_sep); |
| 1159 |
goto out; |
| 1160 |
} |
| 1161 |
|
| 1162 |
#ifdef GF_DARWIN_HOST_OS |
| 1163 |
|
| 1164 |
char *xattr_user_namespace_mode_str = NULL; |
| 1165 |
|
| 1166 |
GF_OPTION_INIT("xattr-user-namespace-mode", xattr_user_namespace_mode_str, |
| 1167 |
str, out); |
| 1168 |
|
| 1169 |
if (set_xattr_user_namespace_mode(_private, |
| 1170 |
xattr_user_namespace_mode_str) != 0) { |
| 1171 |
gf_msg(this->name, GF_LOG_ERROR, 0, P_MSG_INVALID_ARGUMENT, |
| 1172 |
"Unknown xattr user namespace mode string: %s", |
| 1173 |
xattr_user_namespace_mode_str); |
| 1174 |
goto out; |
| 1175 |
} |
| 1176 |
#endif |
| 1177 |
|
| 1178 |
GF_OPTION_INIT("batch-fsync-delay-usec", _private->batch_fsync_delay_usec, |
| 1179 |
uint32, out); |
| 1180 |
|
| 1181 |
GF_OPTION_INIT("disable-landfill-purge", _private->disable_landfill_purge, |
| 1182 |
bool, out); |
| 1183 |
if (_private->disable_landfill_purge) { |
| 1184 |
gf_msg(this->name, GF_LOG_WARNING, 0, 0, |
| 1185 |
"Janitor WILL NOT purge the landfill directory. " |
| 1186 |
"Your landfill directory" |
| 1187 |
" may fill up this brick."); |
| 1188 |
} |
| 1189 |
|
| 1190 |
GF_OPTION_INIT("force-create-mode", force_create, int32, out); |
| 1191 |
_private->force_create_mode = force_create; |
| 1192 |
|
| 1193 |
GF_OPTION_INIT("force-directory-mode", force_directory, int32, out); |
| 1194 |
_private->force_directory_mode = force_directory; |
| 1195 |
|
| 1196 |
GF_OPTION_INIT("create-mask", create_mask, int32, out); |
| 1197 |
_private->create_mask = create_mask; |
| 1198 |
|
| 1199 |
GF_OPTION_INIT("create-directory-mask", create_directory_mask, int32, out); |
| 1200 |
_private->create_directory_mask = create_directory_mask; |
| 1201 |
|
| 1202 |
GF_OPTION_INIT("max-hardlinks", _private->max_hardlinks, uint32, out); |
| 1203 |
|
| 1204 |
GF_OPTION_INIT("fips-mode-rchecksum", _private->fips_mode_rchecksum, bool, |
| 1205 |
out); |
| 1206 |
|
| 1207 |
GF_OPTION_INIT("ctime", _private->ctime, bool, out); |
| 1208 |
|
| 1209 |
out: |
| 1210 |
if (ret) { |
| 1211 |
if (_private) { |
| 1212 |
if (_private->dirfd >= 0) { |
| 1213 |
sys_close(_private->dirfd); |
| 1214 |
_private->dirfd = -1; |
| 1215 |
} |
| 1216 |
|
| 1217 |
for (i = 0; i < 256; i++) { |
| 1218 |
if (_private->arrdfd[i] >= 0) { |
| 1219 |
sys_close(_private->arrdfd[i]); |
| 1220 |
_private->arrdfd[i] = -1; |
| 1221 |
} |
| 1222 |
} |
| 1223 |
|
| 1224 |
if (_private->mount_lock >= 0) { |
| 1225 |
(void)sys_close(_private->mount_lock); |
| 1226 |
_private->mount_lock = -1; |
| 1227 |
} |
| 1228 |
|
| 1229 |
GF_FREE(_private->base_path); |
| 1230 |
|
| 1231 |
GF_FREE(_private->trash_path); |
| 1232 |
|
| 1233 |
GF_FREE(_private); |
| 1234 |
} |
| 1235 |
|
| 1236 |
this->private = NULL; |
| 1237 |
} |
| 1238 |
return ret; |
| 1239 |
} |
| 1240 |
|
| 1241 |
void |
| 1242 |
posix_fini(xlator_t *this) |
| 1243 |
{ |
| 1244 |
struct posix_private *priv = this->private; |
| 1245 |
gf_boolean_t health_check = _gf_false; |
| 1246 |
glusterfs_ctx_t *ctx = this->ctx; |
| 1247 |
uint32_t count; |
| 1248 |
int ret = 0; |
| 1249 |
int i = 0; |
| 1250 |
|
| 1251 |
if (!priv) |
| 1252 |
return; |
| 1253 |
LOCK(&priv->lock); |
| 1254 |
{ |
| 1255 |
health_check = priv->health_check_active; |
| 1256 |
priv->health_check_active = _gf_false; |
| 1257 |
} |
| 1258 |
UNLOCK(&priv->lock); |
| 1259 |
|
| 1260 |
if (priv->dirfd >= 0) { |
| 1261 |
sys_close(priv->dirfd); |
| 1262 |
priv->dirfd = -1; |
| 1263 |
} |
| 1264 |
|
| 1265 |
for (i = 0; i < 256; i++) { |
| 1266 |
if (priv->arrdfd[i] >= 0) { |
| 1267 |
sys_close(priv->arrdfd[i]); |
| 1268 |
priv->arrdfd[i] = -1; |
| 1269 |
} |
| 1270 |
} |
| 1271 |
|
| 1272 |
if (health_check) { |
| 1273 |
(void)gf_thread_cleanup_xint(priv->health_check); |
| 1274 |
priv->health_check = 0; |
| 1275 |
} |
| 1276 |
|
| 1277 |
if (priv->janitor) { |
| 1278 |
|
| 1279 |
ret = gf_tw_del_timer(this->ctx->tw->timer_wheel, priv->janitor); |
| 1280 |
if (ret < 0) { |
| 1281 |
gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_TIMER_DELETE_FAILED, |
| 1282 |
"Failed to delete janitor timer"); |
| 1283 |
} |
| 1284 |
GF_FREE(priv->janitor); |
| 1285 |
priv->janitor = NULL; |
| 1286 |
} |
| 1287 |
|
| 1288 |
pthread_mutex_lock(&ctx->fd_lock); |
| 1289 |
{ |
| 1290 |
count = --ctx->pxl_count; |
| 1291 |
if (count == 0) { |
| 1292 |
pthread_cond_signal(&ctx->fd_cond); |
| 1293 |
} |
| 1294 |
} |
| 1295 |
pthread_mutex_unlock(&ctx->fd_lock); |
| 1296 |
|
| 1297 |
if (count == 0) { |
| 1298 |
pthread_join(ctx->janitor, NULL); |
| 1299 |
} |
| 1300 |
|
| 1301 |
pthread_mutex_lock(&ctx->xl_lock); |
| 1302 |
{ |
| 1303 |
count = --ctx->diskxl_count; |
| 1304 |
if (count == 0) |
| 1305 |
pthread_cond_signal(&ctx->xl_cond); |
| 1306 |
} |
| 1307 |
pthread_mutex_unlock(&ctx->xl_lock); |
| 1308 |
|
| 1309 |
if (count == 0) { |
| 1310 |
pthread_join(ctx->disk_space_check, NULL); |
| 1311 |
ctx->disk_space_check = 0; |
| 1312 |
} |
| 1313 |
|
| 1314 |
if (priv->fsyncer) { |
| 1315 |
(void)gf_thread_cleanup_xint(priv->fsyncer); |
| 1316 |
priv->fsyncer = 0; |
| 1317 |
} |
| 1318 |
|
| 1319 |
|
| 1320 |
if (priv->mount_lock >= 0) { |
| 1321 |
(void)sys_close(priv->mount_lock); |
| 1322 |
priv->mount_lock = -1; |
| 1323 |
} |
| 1324 |
|
| 1325 |
GF_FREE(priv->base_path); |
| 1326 |
LOCK_DESTROY(&priv->lock); |
| 1327 |
pthread_mutex_destroy(&priv->fsync_mutex); |
| 1328 |
pthread_cond_destroy(&priv->fsync_cond); |
| 1329 |
pthread_mutex_destroy(&priv->janitor_mutex); |
| 1330 |
pthread_cond_destroy(&priv->janitor_cond); |
| 1331 |
GF_FREE(priv->trash_path); |
| 1332 |
GF_FREE(priv); |
| 1333 |
this->private = NULL; |
| 1334 |
|
| 1335 |
return; |
| 1336 |
} |
| 1337 |
|
| 1338 |
struct volume_options posix_options[] = { |
| 1339 |
{.key = {"o-direct"}, .type = GF_OPTION_TYPE_BOOL}, |
| 1340 |
{.key = {"directory"}, |
| 1341 |
.type = GF_OPTION_TYPE_PATH, |
| 1342 |
.default_value = "{{brick.path}}"}, |
| 1343 |
{.key = {"hostname"}, .type = GF_OPTION_TYPE_ANY}, |
| 1344 |
{.key = {"export-statfs-size"}, |
| 1345 |
.type = GF_OPTION_TYPE_BOOL, |
| 1346 |
.default_value = "on"}, |
| 1347 |
{.key = {"mandate-attribute"}, .type = GF_OPTION_TYPE_BOOL}, |
| 1348 |
{.key = {"background-unlink"}, .type = GF_OPTION_TYPE_BOOL}, |
| 1349 |
{.key = {"janitor-sleep-duration"}, |
| 1350 |
.type = GF_OPTION_TYPE_INT, |
| 1351 |
.min = 1, |
| 1352 |
.validate = GF_OPT_VALIDATE_MIN, |
| 1353 |
.default_value = "10", |
| 1354 |
.description = "Interval (in seconds) between times the internal " |
| 1355 |
"'landfill' directory is emptied."}, |
| 1356 |
{.key = {"volume-id"}, |
| 1357 |
.type = GF_OPTION_TYPE_ANY, |
| 1358 |
.default_value = "{{brick.volumeid}}"}, |
| 1359 |
{.key = {"glusterd-uuid"}, .type = GF_OPTION_TYPE_STR}, |
| 1360 |
{.key = {"linux-aio"}, |
| 1361 |
.type = GF_OPTION_TYPE_BOOL, |
| 1362 |
.default_value = "off", |
| 1363 |
.description = "Support for native Linux AIO", |
| 1364 |
.op_version = {1}, |
| 1365 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1366 |
{.key = {"linux-io_uring"}, |
| 1367 |
.type = GF_OPTION_TYPE_BOOL, |
| 1368 |
.default_value = "off", |
| 1369 |
.description = "Support for Linux io_uring", |
| 1370 |
.op_version = {GD_OP_VERSION_9_0}, |
| 1371 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1372 |
{.key = {"brick-uid"}, |
| 1373 |
.type = GF_OPTION_TYPE_INT, |
| 1374 |
.min = -1, |
| 1375 |
.validate = GF_OPT_VALIDATE_MIN, |
| 1376 |
.default_value = "-1", |
| 1377 |
.description = "Support for setting uid of brick's owner", |
| 1378 |
.op_version = {1}, |
| 1379 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1380 |
{.key = {"brick-gid"}, |
| 1381 |
.type = GF_OPTION_TYPE_INT, |
| 1382 |
.min = -1, |
| 1383 |
.validate = GF_OPT_VALIDATE_MIN, |
| 1384 |
.default_value = "-1", |
| 1385 |
.description = "Support for setting gid of brick's owner", |
| 1386 |
.op_version = {1}, |
| 1387 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1388 |
{.key = {"node-uuid-pathinfo"}, |
| 1389 |
.type = GF_OPTION_TYPE_BOOL, |
| 1390 |
.default_value = "off", |
| 1391 |
.description = "return glusterd's node-uuid in pathinfo xattr" |
| 1392 |
" string instead of hostname", |
| 1393 |
.op_version = {3}, |
| 1394 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1395 |
{.key = {"health-check-interval"}, |
| 1396 |
.type = GF_OPTION_TYPE_INT, |
| 1397 |
.min = 0, |
| 1398 |
.default_value = "30", |
| 1399 |
.validate = GF_OPT_VALIDATE_MIN, |
| 1400 |
.description = "Interval in seconds for a filesystem health check, " |
| 1401 |
"set to 0 to disable", |
| 1402 |
.op_version = {3}, |
| 1403 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1404 |
{.key = {"health-check-timeout"}, |
| 1405 |
.type = GF_OPTION_TYPE_INT, |
| 1406 |
.min = 0, |
| 1407 |
.default_value = "20", |
| 1408 |
.validate = GF_OPT_VALIDATE_MIN, |
| 1409 |
.description = |
| 1410 |
"Interval in seconds to wait aio_write finish for health check, " |
| 1411 |
"set to 0 to disable", |
| 1412 |
.op_version = {GD_OP_VERSION_4_0_0}, |
| 1413 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1414 |
{.key = {"reserve"}, |
| 1415 |
.type = GF_OPTION_TYPE_PERCENT_OR_SIZET, |
| 1416 |
.min = 0, |
| 1417 |
.default_value = "1", |
| 1418 |
.validate = GF_OPT_VALIDATE_MIN, |
| 1419 |
.description = "Percentage/Size of disk space to be reserved." |
| 1420 |
" Set to 0 to disable", |
| 1421 |
.op_version = {GD_OP_VERSION_3_13_0}, |
| 1422 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1423 |
{.key = {"batch-fsync-mode"}, |
| 1424 |
.type = GF_OPTION_TYPE_STR, |
| 1425 |
.default_value = "reverse-fsync", |
| 1426 |
.description = |
| 1427 |
"Possible values:\n" |
| 1428 |
"\t- syncfs: Perform one syncfs() on behalf oa batch" |
| 1429 |
"of fsyncs.\n" |
| 1430 |
"\t- syncfs-single-fsync: Perform one syncfs() on behalf of a batch" |
| 1431 |
" of fsyncs and one fsync() per batch.\n" |
| 1432 |
"\t- syncfs-reverse-fsync: Perform one syncfs() on behalf of a batch" |
| 1433 |
" of fsyncs and fsync() each file in the batch in reverse order.\n" |
| 1434 |
" in reverse order.\n" |
| 1435 |
"\t- reverse-fsync: Perform fsync() of each file in the batch in" |
| 1436 |
" reverse order.", |
| 1437 |
.op_version = {3}, |
| 1438 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1439 |
{.key = {"batch-fsync-delay-usec"}, |
| 1440 |
.type = GF_OPTION_TYPE_INT, |
| 1441 |
.default_value = "0", |
| 1442 |
.description = "Num of usecs to wait for aggregating fsync" |
| 1443 |
" requests", |
| 1444 |
.op_version = {3}, |
| 1445 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1446 |
{.key = {"update-link-count-parent"}, |
| 1447 |
.type = GF_OPTION_TYPE_BOOL, |
| 1448 |
.default_value = "off", |
| 1449 |
.description = "Enable placeholders for gfid to path conversion", |
| 1450 |
.op_version = {GD_OP_VERSION_3_6_0}, |
| 1451 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1452 |
{.key = {"gfid2path"}, |
| 1453 |
.type = GF_OPTION_TYPE_BOOL, |
| 1454 |
#ifdef __NetBSD__ |
| 1455 |
|
| 1456 |
|
| 1457 |
|
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
.default_value = "off", |
| 1463 |
#else |
| 1464 |
.default_value = "on", |
| 1465 |
#endif |
| 1466 |
.description = "Enable logging metadata for gfid to path conversion", |
| 1467 |
.op_version = {GD_OP_VERSION_3_12_0}, |
| 1468 |
.flags = OPT_FLAG_SETTABLE}, |
| 1469 |
{.key = {"gfid2path-separator"}, |
| 1470 |
.type = GF_OPTION_TYPE_STR, |
| 1471 |
.default_value = ":", |
| 1472 |
.description = "Path separator for glusterfs.gfidtopath virt xattr", |
| 1473 |
.op_version = {GD_OP_VERSION_3_12_0}, |
| 1474 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1475 |
#if GF_DARWIN_HOST_OS |
| 1476 |
{.key = {"xattr-user-namespace-mode"}, |
| 1477 |
.type = GF_OPTION_TYPE_STR, |
| 1478 |
.default_value = "none", |
| 1479 |
.description = |
| 1480 |
"Option to control XATTR user namespace on the raw filesystem: " |
| 1481 |
"\t- None: Will use the user namespace, so files will be exchangeable " |
| 1482 |
"with Linux.\n" |
| 1483 |
" The raw filesystem will not be compatible with OS X Finder.\n" |
| 1484 |
"\t- Strip: Will strip the user namespace before setting. The raw " |
| 1485 |
"filesystem will work in OS X.\n", |
| 1486 |
.op_version = {GD_OP_VERSION_3_6_0}, |
| 1487 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC}, |
| 1488 |
#endif |
| 1489 |
{ |
| 1490 |
.key = {"shared-brick-count"}, |
| 1491 |
.type = GF_OPTION_TYPE_INT, |
| 1492 |
.default_value = "1", |
| 1493 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC, |
| 1494 |
.description = |
| 1495 |
"Number of bricks sharing the same backend export." |
| 1496 |
" Useful for displaying the proper usable size through statvfs() " |
| 1497 |
"call (df command)", |
| 1498 |
}, |
| 1499 |
{ |
| 1500 |
.key = {"disable-landfill-purge"}, |
| 1501 |
.type = GF_OPTION_TYPE_BOOL, |
| 1502 |
.default_value = "off", |
| 1503 |
.description = "Disable glusterfs/landfill purges. " |
| 1504 |
"WARNING: This can fill up a brick.", |
| 1505 |
.op_version = {GD_OP_VERSION_4_0_0}, |
| 1506 |
.tags = {"diagnosis"}, |
| 1507 |
}, |
| 1508 |
{.key = {"force-create-mode"}, |
| 1509 |
.type = GF_OPTION_TYPE_INT, |
| 1510 |
.min = 0000, |
| 1511 |
.max = 0777, |
| 1512 |
.default_value = "0000", |
| 1513 |
.validate = GF_OPT_VALIDATE_BOTH, |
| 1514 |
.description = "Mode bit permission that will always be set on a file."}, |
| 1515 |
{.key = {"force-directory-mode"}, |
| 1516 |
.type = GF_OPTION_TYPE_INT, |
| 1517 |
.min = 0000, |
| 1518 |
.max = 0777, |
| 1519 |
.default_value = "0000", |
| 1520 |
.validate = GF_OPT_VALIDATE_BOTH, |
| 1521 |
.description = "Mode bit permission that will be always set on directory"}, |
| 1522 |
{.key = {"create-mask"}, |
| 1523 |
.type = GF_OPTION_TYPE_INT, |
| 1524 |
.min = 0000, |
| 1525 |
.max = 0777, |
| 1526 |
.default_value = "0777", |
| 1527 |
.validate = GF_OPT_VALIDATE_BOTH, |
| 1528 |
.description = "Any bit not set here will be removed from the" |
| 1529 |
"modes set on a file when it is created"}, |
| 1530 |
{.key = {"create-directory-mask"}, |
| 1531 |
.type = GF_OPTION_TYPE_INT, |
| 1532 |
.min = 0000, |
| 1533 |
.max = 0777, |
| 1534 |
.default_value = "0777", |
| 1535 |
.validate = GF_OPT_VALIDATE_BOTH, |
| 1536 |
.description = "Any bit not set here will be removed from the" |
| 1537 |
"modes set on a directory when it is created"}, |
| 1538 |
{.key = {"max-hardlinks"}, |
| 1539 |
.type = GF_OPTION_TYPE_INT, |
| 1540 |
.min = 0, |
| 1541 |
.default_value = "100", |
| 1542 |
.op_version = {GD_OP_VERSION_4_0_0}, |
| 1543 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC, |
| 1544 |
.tags = {"posix"}, |
| 1545 |
.validate = GF_OPT_VALIDATE_MIN, |
| 1546 |
.description = "max number of hardlinks allowed on any one inode.\n" |
| 1547 |
"0 is unlimited, 1 prevents any hardlinking at all."}, |
| 1548 |
{.key = {"fips-mode-rchecksum"}, |
| 1549 |
.type = GF_OPTION_TYPE_BOOL, |
| 1550 |
.default_value = "off", |
| 1551 |
.op_version = {GD_OP_VERSION_4_0_0}, |
| 1552 |
.flags = OPT_FLAG_SETTABLE, |
| 1553 |
.tags = {"posix"}, |
| 1554 |
.description = "If enabled, posix_rchecksum uses the FIPS compliant" |
| 1555 |
"SHA256 checksum. MD5 otherwise."}, |
| 1556 |
{.key = {"ctime"}, |
| 1557 |
.type = GF_OPTION_TYPE_BOOL, |
| 1558 |
.default_value = "on", |
| 1559 |
.flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC, |
| 1560 |
.op_version = {GD_OP_VERSION_4_1_0}, |
| 1561 |
.tags = {"ctime"}, |
| 1562 |
.description = |
| 1563 |
"When this option is enabled, time attributes (ctime,mtime,atime) " |
| 1564 |
"are stored in xattr to keep it consistent across replica and " |
| 1565 |
"distribute set. The time attributes stored at the backend are " |
| 1566 |
"not considered "}, |
| 1567 |
{.key = {NULL}}, |
| 1568 |
}; |