summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-07-14 13:58:20 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-14 14:44:26 -0700
commit654a720eed0bc5faaeeaa4eb34f1cfc10df76230 (patch)
treeb84419d192c46e39a40b7a3133666ddde453aba2 /xlators/storage
parente73a856e926465068f6f6cf5a0cace501589957c (diff)
proper way to do defrag of a mountpoint
Usage: "glusterfs-defrag <MOUNTPOINT>" there are new features added to distribute with this patch: * bash# getfattr -n trusted.distribute.linkinfo <file> Gives output in the format "<hostname>:<directory>", if there is a linkfile present, where hostname is server, directory is backend directory where the actual linkfile is present. * bash# getfattr -n trusted.glusterfs.pathinfo <path> Gives layout information if directory, and info about actual location of file in backend servers, in the form of 'hostname:directory'. (TODO: should extend it to all xlators) * bash# getfattr -n trusted.distribute.fix.layout <path> scales out the directory layout in distribute, so when new servers are added, layouts are fixed to include them. * removed 'scale-n-defrag.sh' as its no more required. * changed 'defrag.sh' to have a feature to specify target bricks, so defrag happens to only those nodes. moved the file to 'glusterfs-defrag', which now gets installed to '${prefix}/bin' * storage/posix: takes new option 'hostname' so it can resolve to same hostname given during 'gluster volume create'. with 'trusted.glusterfs.pathinfo' posix returns the value in 'hostname:real_path' format. Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1073 ('gluster defrag <VOLNAME>' fails in mainline) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1073
Diffstat (limited to 'xlators/storage')
-rw-r--r--xlators/storage/posix/src/posix.c55
-rw-r--r--xlators/storage/posix/src/posix.h2
2 files changed, 34 insertions, 23 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 7c0d165ac..2810bbd6a 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3032,6 +3032,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
size_t size = 0;
size_t remaining_size = 0;
char key[1024] = {0,};
+ char host_buf[1024] = {0,};
char gen_key[1024] = {0,};
char * value = NULL;
char * list = NULL;
@@ -3072,18 +3073,18 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
}
if (loc->inode && IA_ISREG (loc->inode->ia_type) && name &&
- (strcmp (name, "trusted.glusterfs.location") == 0)) {
- ret = dict_set_static_ptr (dict,
- "trusted.glusterfs.location",
- priv->hostname);
+ (strcmp (name, GF_XATTR_PATHINFO_KEY) == 0)) {
+ snprintf (host_buf, 1024, "%s:%s", priv->hostname,
+ real_path);
+ ret = dict_set_str (dict, GF_XATTR_PATHINFO_KEY,
+ host_buf);
if (ret < 0) {
gf_log (this->name, GF_LOG_WARNING,
- "could not set hostname (%s) in dictionary",
- priv->hostname);
+ "could not set value (%s) in dictionary",
+ host_buf);
}
goto done;
}
-
size = sys_llistxattr (real_path, NULL, 0);
if (size == -1) {
@@ -4260,17 +4261,16 @@ mem_acct_init (xlator_t *this)
int
init (xlator_t *this)
{
- int ret = 0;
- int op_ret = -1;
- gf_boolean_t tmp_bool = 0;
- struct stat buf = {0,};
- struct posix_private * _private = NULL;
- data_t * dir_data = NULL;
- data_t * tmp_data = NULL;
- uint64_t time64 = 0;
-
- int dict_ret = 0;
- int32_t janitor_sleep;
+ struct posix_private *_private = NULL;
+ data_t *dir_data = NULL;
+ data_t *tmp_data = NULL;
+ struct stat buf = {0,};
+ gf_boolean_t tmp_bool = 0;
+ uint64_t time64 = 0;
+ int dict_ret = 0;
+ int ret = 0;
+ int op_ret = -1;
+ int32_t janitor_sleep = 0;
dir_data = dict_get (this->options, "directory");
@@ -4370,10 +4370,19 @@ init (xlator_t *this)
LOCK_INIT (&_private->lock);
- ret = gethostname (_private->hostname, 256);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "could not find hostname (%s)", strerror (errno));
+ ret = dict_get_str (this->options, "hostname", &_private->hostname);
+ if (ret) {
+ _private->hostname = GF_CALLOC (256, sizeof (char),
+ gf_common_mt_char);
+ if (!_private->hostname) {
+ gf_log (this->name, GF_LOG_ERROR, "not enough memory");
+ goto out;
+ }
+ ret = gethostname (_private->hostname, 256);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "could not find hostname (%s)", strerror (errno));
+ }
}
_private->export_statfs = 1;
@@ -4574,6 +4583,8 @@ struct volume_options options[] = {
.type = GF_OPTION_TYPE_BOOL },
{ .key = {"directory"},
.type = GF_OPTION_TYPE_PATH },
+ { .key = {"hostname"},
+ .type = GF_OPTION_TYPE_ANY },
{ .key = {"export-statfs-size"},
.type = GF_OPTION_TYPE_BOOL },
{ .key = {"mandate-attribute"},
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h
index 0295a1f48..2aff0a6ca 100644
--- a/xlators/storage/posix/src/posix.h
+++ b/xlators/storage/posix/src/posix.h
@@ -73,7 +73,7 @@ struct posix_private {
gf_lock_t lock;
- char hostname[256];
+ char *hostname;
/* Statistics, provides activity of the server */
struct timeval prev_fetch_time;