diff options
author | Raghavendra G <rgowdapp@redhat.com> | 2013-08-13 10:46:50 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2013-09-03 10:28:03 +0530 |
commit | 2d1530e6987f961b76d8ed531beeafca50e6ccb1 (patch) | |
tree | 74463b071528acc5d0835b0a8967ed15bde65f24 | |
parent | adf94cb59510dc860ede9923e6cbfd132c495094 (diff) |
marker-quota: fix code that assumes loc->path is always non-null
Change-Id: I33d45521a06f008554cb43a3d6b53136b2f091d2
BUG: 969461
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
-rw-r--r-- | xlators/features/marker/src/marker-quota.c | 28 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix-handle.c | 1 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix.c | 2 |
3 files changed, 23 insertions, 8 deletions
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c index e71288e8..30c69a6b 100644 --- a/xlators/features/marker/src/marker-quota.c +++ b/xlators/features/marker/src/marker-quota.c @@ -1038,7 +1038,9 @@ mq_create_xattr (xlator_t *this, call_frame_t *frame) goto free_size; } - if (strcmp (local->loc.path, "/") != 0) { + if ((local->loc.path && strcmp (local->loc.path, "/") != 0) + || (local->loc.parent && !__is_root_gfid (local->loc.parent->gfid)) + || (!__is_root_gfid (local->loc.pargfid))) { contri = mq_add_new_contribution_node (this, ctx, &local->loc); if (contri == NULL) goto err; @@ -1107,7 +1109,12 @@ mq_check_n_set_inode_xattr (call_frame_t *frame, void *cookie, goto create_xattr; //check contribution xattr if not root - if (strcmp (local->loc.path, "/") != 0) { + if ((local->loc.path && strcmp (local->loc.path, "/") != 0) + || (!uuid_is_null (local->loc.pargfid) + && !__is_root_gfid (local->loc.pargfid)) + || (local->loc.parent + && !uuid_is_null (local->loc.parent->gfid) + && !__is_root_gfid (local->loc.parent->gfid))) { GET_CONTRI_KEY (contri_key, local->loc.parent->gfid, ret); if (ret < 0) goto out; @@ -2035,7 +2042,11 @@ mq_initiate_quota_txn (xlator_t *this, loc_t *loc) */ contribution = mq_get_contribution_node (loc->parent, ctx); if (!contribution) { - if (strcmp (loc->path, "/")) + if ((loc->path && strcmp (loc->path, "/")) + || (!uuid_is_null (loc->pargfid) + && !__is_root_gfid (loc->pargfid)) + || (loc->parent && !uuid_is_null (loc->parent->gfid) + && !__is_root_gfid (loc->parent->gfid))) gf_log_callingfn (this->name, GF_LOG_TRACE, "contribution node for the " "path (%s) with parent (%s) " @@ -2046,7 +2057,7 @@ mq_initiate_quota_txn (xlator_t *this, loc_t *loc) contribution = mq_add_new_contribution_node (this, ctx, loc); if (!contribution) { - if(strcmp (loc->path, "/")) + if(loc->path && strcmp (loc->path, "/")) gf_log_callingfn (this->name, GF_LOG_WARNING, "could not allocate " " contribution node for (%s) " @@ -2110,7 +2121,7 @@ mq_inspect_directory_xattr (xlator_t *this, contribution = mq_add_new_contribution_node (this, ctx, loc); if (contribution == NULL) { if (!uuid_is_null (loc->inode->gfid)) - gf_log (this->name, GF_LOG_WARNING, + gf_log (this->name, GF_LOG_DEBUG, "cannot add a new contribution node " "(%s)", uuid_utoa (loc->inode->gfid)); ret = -1; @@ -2126,7 +2137,10 @@ mq_inspect_directory_xattr (xlator_t *this, if (ret < 0) goto out; - if (strcmp (loc->path, "/") != 0) { + if ((loc->path && strcmp (loc->path, "/") != 0) + || (!uuid_is_null (loc->pargfid) && !__is_root_gfid (loc->pargfid)) + || (loc->parent && !uuid_is_null (loc->parent->gfid) && + !__is_root_gfid (loc->parent->gfid))) { not_root = _gf_true; GET_CONTRI_KEY (contri_key, contribution->gfid, ret); @@ -2199,7 +2213,7 @@ mq_inspect_file_xattr (xlator_t *this, contribution = mq_add_new_contribution_node (this, ctx, loc); if (contribution == NULL) { - gf_log_callingfn (this->name, GF_LOG_WARNING, "cannot allocate " + gf_log_callingfn (this->name, GF_LOG_DEBUG, "cannot allocate " "contribution node (path:%s)", loc->path); goto out; } diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c index c3449583..34c66d63 100644 --- a/xlators/storage/posix/src/posix-handle.c +++ b/xlators/storage/posix/src/posix-handle.c @@ -85,6 +85,7 @@ posix_make_ancestral_node (const char *priv_base_path, char *path, int pathsize, list_add_tail (&entry->list, &head->list); strcpy (real_path, priv_base_path); + strcat (real_path, "/"); strcat (real_path, dir_name); loc.inode = inode_ref (inode); uuid_copy (loc.gfid, inode->gfid); diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 415f007d..a4fb9881 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -121,7 +121,7 @@ posix_lookup (call_frame_t *frame, xlator_t *this, op_ret = dict_get_int32 (xdata, GF_GFIDLESS_LOOKUP, &gfidless); op_ret = -1; - if (uuid_is_null (loc->pargfid)) { + if (uuid_is_null (loc->pargfid) || (loc->name == NULL)) { /* nameless lookup */ MAKE_INODE_HANDLE (real_path, this, loc, &buf); } else { |